forked from AbleOS/holey-bytes
adding habdler for tuples with known type
Signed-off-by: Jakub Doka <jakub.doka2@gmail.com>
This commit is contained in:
parent
f59c0c1092
commit
4b3b6af70e
|
@ -1151,9 +1151,11 @@ impl<'a> Codegen<'a> {
|
|||
|
||||
Some(Value::new(self.gen_null_check(cmped, ty, op)).ty(ty::Id::BOOL))
|
||||
}
|
||||
Expr::BinOp { left, pos, op, right }
|
||||
if !matches!(op, TokenKind::Assign | TokenKind::Decl) =>
|
||||
{
|
||||
Expr::BinOp { left, pos, op, right } => {
|
||||
debug_assert!(!matches!(
|
||||
op,
|
||||
TokenKind::Assign | TokenKind::Decl | TokenKind::Colon
|
||||
));
|
||||
let mut lhs = self.ptr_expr_ctx(left, ctx)?;
|
||||
self.implicit_unwrap(left.pos(), &mut lhs);
|
||||
|
||||
|
@ -1768,6 +1770,25 @@ impl<'a> Codegen<'a> {
|
|||
|
||||
Some(Value::ptr(mem).ty(aty))
|
||||
}
|
||||
(Some(ty::Kind::Tuple(tupl)), ListKind::Tuple) => {
|
||||
let mem = self.new_stack(pos, tupl.into());
|
||||
let mut offs = OffsetIter::new(tupl, self.tys);
|
||||
for field in fields {
|
||||
let Some((ty, offset)) = offs.next_ty(self.tys) else {
|
||||
self.error(
|
||||
field.pos(),
|
||||
"this init argumen overflows the field count",
|
||||
);
|
||||
break;
|
||||
};
|
||||
|
||||
let value = self.checked_expr(field, ty, "tuple field")?;
|
||||
let mem = self.offset(mem, offset);
|
||||
self.store_mem(mem, ty, value.id);
|
||||
}
|
||||
|
||||
Some(Value::ptr(mem).ty(tupl.into()))
|
||||
}
|
||||
(Some(t), ListKind::Tuple) => self.error(
|
||||
pos,
|
||||
fa!(
|
||||
|
|
Loading…
Reference in a new issue