mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
add inc field to Inc instruction
This commit is contained in:
parent
5a2b2cbcac
commit
15cbadf652
6 changed files with 21 additions and 14 deletions
|
@ -2026,7 +2026,7 @@ pub fn build_exp_stmt<'a, 'ctx, 'env>(
|
||||||
// This doesn't currently do anything
|
// This doesn't currently do anything
|
||||||
context.i64_type().const_zero().into()
|
context.i64_type().const_zero().into()
|
||||||
}
|
}
|
||||||
Inc(symbol, cont) => {
|
Inc(symbol, _inc, cont) => {
|
||||||
let (value, layout) = load_symbol_and_layout(env, scope, symbol);
|
let (value, layout) = load_symbol_and_layout(env, scope, symbol);
|
||||||
let layout = layout.clone();
|
let layout = layout.clone();
|
||||||
|
|
||||||
|
|
|
@ -381,7 +381,7 @@ where
|
||||||
self.set_last_seen(*sym, stmt);
|
self.set_last_seen(*sym, stmt);
|
||||||
}
|
}
|
||||||
Stmt::Rethrow => {}
|
Stmt::Rethrow => {}
|
||||||
Stmt::Inc(sym, following) => {
|
Stmt::Inc(sym, _inc, following) => {
|
||||||
self.set_last_seen(*sym, stmt);
|
self.set_last_seen(*sym, stmt);
|
||||||
self.scan_ast(following);
|
self.scan_ast(following);
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,7 +168,7 @@ impl<'a> ParamMap<'a> {
|
||||||
stack.extend(branches.iter().map(|b| &b.1));
|
stack.extend(branches.iter().map(|b| &b.1));
|
||||||
stack.push(default_branch);
|
stack.push(default_branch);
|
||||||
}
|
}
|
||||||
Inc(_, _) | Dec(_, _) => unreachable!("these have not been introduced yet"),
|
Inc(_, _, _) | Dec(_, _) => unreachable!("these have not been introduced yet"),
|
||||||
|
|
||||||
Ret(_) | Rethrow | Jump(_, _) | RuntimeError(_) => {
|
Ret(_) | Rethrow | Jump(_, _) | RuntimeError(_) => {
|
||||||
// these are terminal, do nothing
|
// these are terminal, do nothing
|
||||||
|
@ -513,7 +513,7 @@ impl<'a> BorrowInfState<'a> {
|
||||||
}
|
}
|
||||||
self.collect_stmt(default_branch);
|
self.collect_stmt(default_branch);
|
||||||
}
|
}
|
||||||
Inc(_, _) | Dec(_, _) => unreachable!("these have not been introduced yet"),
|
Inc(_, _, _) | Dec(_, _) => unreachable!("these have not been introduced yet"),
|
||||||
|
|
||||||
Ret(_) | RuntimeError(_) | Rethrow => {
|
Ret(_) | RuntimeError(_) | Rethrow => {
|
||||||
// these are terminal, do nothing
|
// these are terminal, do nothing
|
||||||
|
|
|
@ -52,7 +52,7 @@ pub fn occuring_variables(stmt: &Stmt<'_>) -> (MutSet<Symbol>, MutSet<Symbol>) {
|
||||||
|
|
||||||
Rethrow => {}
|
Rethrow => {}
|
||||||
|
|
||||||
Inc(symbol, cont) | Dec(symbol, cont) => {
|
Inc(symbol, _, cont) | Dec(symbol, cont) => {
|
||||||
result.insert(*symbol);
|
result.insert(*symbol);
|
||||||
stack.push(cont);
|
stack.push(cont);
|
||||||
}
|
}
|
||||||
|
@ -275,7 +275,7 @@ impl<'a> Context<'a> {
|
||||||
return stmt;
|
return stmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.arena.alloc(Stmt::Inc(symbol, stmt))
|
self.arena.alloc(Stmt::Inc(symbol, 1, stmt))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_dec(&self, symbol: Symbol, stmt: &'a Stmt<'a>) -> &'a Stmt<'a> {
|
fn add_dec(&self, symbol: Symbol, stmt: &'a Stmt<'a>) -> &'a Stmt<'a> {
|
||||||
|
@ -851,7 +851,7 @@ impl<'a> Context<'a> {
|
||||||
(switch, case_live_vars)
|
(switch, case_live_vars)
|
||||||
}
|
}
|
||||||
|
|
||||||
RuntimeError(_) | Inc(_, _) | Dec(_, _) => (stmt, MutSet::default()),
|
RuntimeError(_) | Inc(_, _, _) | Dec(_, _) => (stmt, MutSet::default()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -902,7 +902,7 @@ pub fn collect_stmt(
|
||||||
vars
|
vars
|
||||||
}
|
}
|
||||||
|
|
||||||
Inc(symbol, cont) | Dec(symbol, cont) => {
|
Inc(symbol, _, cont) | Dec(symbol, cont) => {
|
||||||
vars.insert(*symbol);
|
vars.insert(*symbol);
|
||||||
collect_stmt(cont, jp_live_vars, vars)
|
collect_stmt(cont, jp_live_vars, vars)
|
||||||
}
|
}
|
||||||
|
|
|
@ -766,7 +766,7 @@ pub enum Stmt<'a> {
|
||||||
},
|
},
|
||||||
Ret(Symbol),
|
Ret(Symbol),
|
||||||
Rethrow,
|
Rethrow,
|
||||||
Inc(Symbol, &'a Stmt<'a>),
|
Inc(Symbol, u64, &'a Stmt<'a>),
|
||||||
Dec(Symbol, &'a Stmt<'a>),
|
Dec(Symbol, &'a Stmt<'a>),
|
||||||
Join {
|
Join {
|
||||||
id: JoinPointId,
|
id: JoinPointId,
|
||||||
|
@ -1263,12 +1263,19 @@ impl<'a> Stmt<'a> {
|
||||||
.append(alloc.intersperse(it, alloc.space()))
|
.append(alloc.intersperse(it, alloc.space()))
|
||||||
.append(";")
|
.append(";")
|
||||||
}
|
}
|
||||||
Inc(symbol, cont) => alloc
|
Inc(symbol, 1, cont) => alloc
|
||||||
.text("inc ")
|
.text("inc ")
|
||||||
.append(symbol_to_doc(alloc, *symbol))
|
.append(symbol_to_doc(alloc, *symbol))
|
||||||
.append(";")
|
.append(";")
|
||||||
.append(alloc.hardline())
|
.append(alloc.hardline())
|
||||||
.append(cont.to_doc(alloc)),
|
.append(cont.to_doc(alloc)),
|
||||||
|
Inc(symbol, n, cont) => alloc
|
||||||
|
.text("inc ")
|
||||||
|
.append(alloc.text(format!("{}", n)))
|
||||||
|
.append(symbol_to_doc(alloc, *symbol))
|
||||||
|
.append(";")
|
||||||
|
.append(alloc.hardline())
|
||||||
|
.append(cont.to_doc(alloc)),
|
||||||
Dec(symbol, cont) => alloc
|
Dec(symbol, cont) => alloc
|
||||||
.text("dec ")
|
.text("dec ")
|
||||||
.append(symbol_to_doc(alloc, *symbol))
|
.append(symbol_to_doc(alloc, *symbol))
|
||||||
|
@ -4666,8 +4673,8 @@ fn substitute_in_stmt_help<'a>(
|
||||||
Some(s) => Some(arena.alloc(Ret(s))),
|
Some(s) => Some(arena.alloc(Ret(s))),
|
||||||
None => None,
|
None => None,
|
||||||
},
|
},
|
||||||
Inc(symbol, cont) => match substitute_in_stmt_help(arena, cont, subs) {
|
Inc(symbol, inc, cont) => match substitute_in_stmt_help(arena, cont, subs) {
|
||||||
Some(cont) => Some(arena.alloc(Inc(*symbol, cont))),
|
Some(cont) => Some(arena.alloc(Inc(*symbol, *inc, cont))),
|
||||||
None => None,
|
None => None,
|
||||||
},
|
},
|
||||||
Dec(symbol, cont) => match substitute_in_stmt_help(arena, cont, subs) {
|
Dec(symbol, cont) => match substitute_in_stmt_help(arena, cont, subs) {
|
||||||
|
|
|
@ -228,8 +228,8 @@ fn insert_jumps<'a>(
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Inc(symbol, cont) => match insert_jumps(arena, cont, goal_id, needle) {
|
Inc(symbol, inc, cont) => match insert_jumps(arena, cont, goal_id, needle) {
|
||||||
Some(cont) => Some(arena.alloc(Inc(*symbol, cont))),
|
Some(cont) => Some(arena.alloc(Inc(*symbol, *inc, cont))),
|
||||||
None => None,
|
None => None,
|
||||||
},
|
},
|
||||||
Dec(symbol, cont) => match insert_jumps(arena, cont, goal_id, needle) {
|
Dec(symbol, cont) => match insert_jumps(arena, cont, goal_id, needle) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue