mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 05:49:08 +00:00
boilerplate
This commit is contained in:
parent
07eed2c4a6
commit
10b6f33ed2
9 changed files with 295 additions and 19 deletions
|
@ -216,6 +216,31 @@ fn function_s<'a, 'i>(
|
|||
}
|
||||
}
|
||||
|
||||
ExpectFx {
|
||||
condition,
|
||||
region,
|
||||
lookups,
|
||||
layouts,
|
||||
remainder,
|
||||
} => {
|
||||
let continuation: &Stmt = *remainder;
|
||||
let new_continuation = function_s(env, w, c, continuation);
|
||||
|
||||
if std::ptr::eq(continuation, new_continuation) || continuation == new_continuation {
|
||||
stmt
|
||||
} else {
|
||||
let new_refcounting = ExpectFx {
|
||||
condition: *condition,
|
||||
region: *region,
|
||||
lookups,
|
||||
layouts,
|
||||
remainder: new_continuation,
|
||||
};
|
||||
|
||||
arena.alloc(new_refcounting)
|
||||
}
|
||||
}
|
||||
|
||||
Ret(_) | Jump(_, _) | RuntimeError(_) => stmt,
|
||||
}
|
||||
}
|
||||
|
@ -446,6 +471,39 @@ fn function_d_main<'a, 'i>(
|
|||
(arena.alloc(refcounting), found)
|
||||
}
|
||||
}
|
||||
ExpectFx {
|
||||
condition,
|
||||
region,
|
||||
lookups,
|
||||
layouts,
|
||||
remainder,
|
||||
} => {
|
||||
let (b, found) = function_d_main(env, x, c, remainder);
|
||||
|
||||
if found || *condition != x {
|
||||
let refcounting = ExpectFx {
|
||||
condition: *condition,
|
||||
region: *region,
|
||||
lookups,
|
||||
layouts,
|
||||
remainder: b,
|
||||
};
|
||||
|
||||
(arena.alloc(refcounting), found)
|
||||
} else {
|
||||
let b = try_function_s(env, x, c, b);
|
||||
|
||||
let refcounting = ExpectFx {
|
||||
condition: *condition,
|
||||
region: *region,
|
||||
lookups,
|
||||
layouts,
|
||||
remainder: b,
|
||||
};
|
||||
|
||||
(arena.alloc(refcounting), found)
|
||||
}
|
||||
}
|
||||
Join {
|
||||
id,
|
||||
parameters,
|
||||
|
@ -618,6 +676,26 @@ fn function_r<'a, 'i>(env: &mut Env<'a, 'i>, stmt: &'a Stmt<'a>) -> &'a Stmt<'a>
|
|||
arena.alloc(expect)
|
||||
}
|
||||
|
||||
ExpectFx {
|
||||
condition,
|
||||
region,
|
||||
lookups,
|
||||
layouts,
|
||||
remainder,
|
||||
} => {
|
||||
let b = function_r(env, remainder);
|
||||
|
||||
let expect = ExpectFx {
|
||||
condition: *condition,
|
||||
region: *region,
|
||||
lookups,
|
||||
layouts,
|
||||
remainder: b,
|
||||
};
|
||||
|
||||
arena.alloc(expect)
|
||||
}
|
||||
|
||||
Ret(_) | Jump(_, _) | RuntimeError(_) => {
|
||||
// terminals
|
||||
stmt
|
||||
|
@ -653,6 +731,11 @@ fn has_live_var<'a>(jp_live_vars: &JPLiveVarMap, stmt: &'a Stmt<'a>, needle: Sym
|
|||
remainder,
|
||||
..
|
||||
} => *condition == needle || has_live_var(jp_live_vars, remainder, needle),
|
||||
ExpectFx {
|
||||
condition,
|
||||
remainder,
|
||||
..
|
||||
} => *condition == needle || has_live_var(jp_live_vars, remainder, needle),
|
||||
Join {
|
||||
id,
|
||||
parameters,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue