move towards structure construction / deconstruction
This commit is contained in:
@@ -406,8 +406,30 @@ impl<M: Module> Backend<M> {
|
||||
}
|
||||
}
|
||||
|
||||
Expression::Construct(_, _, _, _) => unimplemented!(),
|
||||
Expression::FieldRef(_, _, _, _) => unimplemented!(),
|
||||
Expression::Construct(_, ty, name, fields) => {
|
||||
let Type::Structure(fields) = ty else {
|
||||
panic!("Got to backend with non-structure type in structure construction?!");
|
||||
};
|
||||
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
Expression::FieldRef(_, _, struct_type, val, field) => {
|
||||
let (structure, _) = self.compile_value_or_ref(val, variables, builder)?;
|
||||
|
||||
let Type::Structure(fields) = struct_type else {
|
||||
panic!("Got to backend with non-structure type in field reference?!");
|
||||
};
|
||||
|
||||
let Some((field_type, offset)) = fields.field_type_and_offset(&field) else {
|
||||
panic!("Got to backend with invalid field for structure type?!");
|
||||
};
|
||||
|
||||
let field_cranelift_type = self.translate_type(field_type).value_type;
|
||||
|
||||
let value = builder.ins().load(field_cranelift_type, MemFlags::new(), structure, offset);
|
||||
Ok((value, field_cranelift_type))
|
||||
}
|
||||
|
||||
Expression::Block(_, _, mut exprs) => match exprs.pop() {
|
||||
None => Ok((builder.ins().iconst(types::I64, 0), VOID_REPR_TYPE)),
|
||||
|
||||
Reference in New Issue
Block a user