refactor Access into AccessAtIndex

This commit is contained in:
Folkert 2020-03-22 20:14:15 +01:00
parent 18f34710e1
commit e2a7c970bc
4 changed files with 43 additions and 94 deletions

View file

@ -72,9 +72,6 @@ pub fn build_expr<'a, 'ctx, 'env>(
build_branch2(env, scope, parent, conditional, procs)
}
Branches { .. } => {
panic!("TODO build_branches(env, scope, parent, cond_lhs, branches, procs)");
}
Switch {
cond,
branches,
@ -476,27 +473,6 @@ pub fn build_expr<'a, 'ctx, 'env>(
.unwrap();
wrapper_val.into_struct_value().into()
}
Access {
label,
struct_layout: Layout::Struct(sorted_fields),
record,
..
} => {
let builder = env.builder;
// Get index
let index = sorted_fields
.iter()
.position(|(local_label, _)| local_label == label)
.unwrap() as u32; // TODO
// Get Struct val
let struct_val = build_expr(env, &scope, parent, record, procs).into_struct_value();
builder
.build_extract_value(struct_val, index, "field_access")
.unwrap()
}
AccessAtIndex {
index,
expr,