mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 14:54:47 +00:00
refactor Access into AccessAtIndex
This commit is contained in:
parent
18f34710e1
commit
e2a7c970bc
4 changed files with 43 additions and 94 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue