mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 14:54:47 +00:00
add index
This commit is contained in:
parent
e1af2eb7d0
commit
aba01ad62a
3 changed files with 28 additions and 16 deletions
|
@ -565,6 +565,11 @@ impl<'a> BorrowInfState<'a> {
|
||||||
EmptyArray => {
|
EmptyArray => {
|
||||||
self.own_var(z);
|
self.own_var(z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Call(call) => self.collect_call(z, call),
|
||||||
|
|
||||||
|
Literal(_) | RuntimeErrorFunction(_) => {}
|
||||||
|
|
||||||
AccessAtIndex { structure: x, .. } => {
|
AccessAtIndex { structure: x, .. } => {
|
||||||
// if the structure (record/tag/array) is owned, the extracted value is
|
// if the structure (record/tag/array) is owned, the extracted value is
|
||||||
if self.is_owned(*x) {
|
if self.is_owned(*x) {
|
||||||
|
@ -577,12 +582,16 @@ impl<'a> BorrowInfState<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Call(call) => self.collect_call(z, call),
|
CoerceToTagId { structure: x, .. } => {
|
||||||
|
// if the structure (record/tag/array) is owned, the extracted value is
|
||||||
|
if self.is_owned(*x) {
|
||||||
|
self.own_var(z);
|
||||||
|
}
|
||||||
|
|
||||||
Literal(_) | RuntimeErrorFunction(_) => {}
|
// if the extracted value is owned, the structure must be too
|
||||||
|
if self.is_owned(z) {
|
||||||
CoerceToTagId { .. } => {
|
self.own_var(*x);
|
||||||
// do nothing for now; when we extract the fields here, that must change
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GetTagId { structure: x, .. } => {
|
GetTagId { structure: x, .. } => {
|
||||||
|
|
|
@ -743,17 +743,6 @@ impl<'a> Context<'a> {
|
||||||
self.arena.alloc(Stmt::Let(z, v, l, b)),
|
self.arena.alloc(Stmt::Let(z, v, l, b)),
|
||||||
&b_live_vars,
|
&b_live_vars,
|
||||||
),
|
),
|
||||||
AccessAtIndex { structure: x, .. } => {
|
|
||||||
let b = self.add_dec_if_needed(x, b, b_live_vars);
|
|
||||||
let info_x = self.get_var_info(x);
|
|
||||||
let b = if info_x.consume {
|
|
||||||
self.add_inc(z, 1, b)
|
|
||||||
} else {
|
|
||||||
b
|
|
||||||
};
|
|
||||||
|
|
||||||
self.arena.alloc(Stmt::Let(z, v, l, b))
|
|
||||||
}
|
|
||||||
|
|
||||||
Call(crate::ir::Call {
|
Call(crate::ir::Call {
|
||||||
call_type,
|
call_type,
|
||||||
|
@ -766,6 +755,18 @@ impl<'a> Context<'a> {
|
||||||
self.arena.alloc(Stmt::Let(z, v, l, b))
|
self.arena.alloc(Stmt::Let(z, v, l, b))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AccessAtIndex { structure: x, .. } => {
|
||||||
|
let b = self.add_dec_if_needed(x, b, b_live_vars);
|
||||||
|
let info_x = self.get_var_info(x);
|
||||||
|
let b = if info_x.consume {
|
||||||
|
self.add_inc(z, 1, b)
|
||||||
|
} else {
|
||||||
|
b
|
||||||
|
};
|
||||||
|
|
||||||
|
self.arena.alloc(Stmt::Let(z, v, l, b))
|
||||||
|
}
|
||||||
|
|
||||||
GetTagId { structure: x, .. } => {
|
GetTagId { structure: x, .. } => {
|
||||||
let b = self.add_dec_if_needed(x, b, b_live_vars);
|
let b = self.add_dec_if_needed(x, b, b_live_vars);
|
||||||
let info_x = self.get_var_info(x);
|
let info_x = self.get_var_info(x);
|
||||||
|
|
|
@ -1200,6 +1200,8 @@ pub enum Expr<'a> {
|
||||||
CoerceToTagId {
|
CoerceToTagId {
|
||||||
structure: Symbol,
|
structure: Symbol,
|
||||||
tag_id: u8,
|
tag_id: u8,
|
||||||
|
union_layout: UnionLayout<'a>,
|
||||||
|
index: u64,
|
||||||
},
|
},
|
||||||
|
|
||||||
Array {
|
Array {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue