mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 05:49:08 +00:00
More lifting
This commit is contained in:
parent
bc5dc17ce9
commit
a59739bf20
1 changed files with 22 additions and 13 deletions
|
@ -2082,15 +2082,26 @@ fn from_can_let<'a>(
|
||||||
def: Box<roc_can::def::Def>,
|
def: Box<roc_can::def::Def>,
|
||||||
cont: Box<Loc<roc_can::expr::Expr>>,
|
cont: Box<Loc<roc_can::expr::Expr>>,
|
||||||
variable: Variable,
|
variable: Variable,
|
||||||
hole: Option<Stmt<'a>>,
|
opt_assigned_and_hole: Option<(Symbol, &'a Stmt<'a>)>,
|
||||||
) -> Stmt<'a> {
|
) -> Stmt<'a> {
|
||||||
use roc_can::expr::Expr::*;
|
use roc_can::expr::Expr::*;
|
||||||
|
|
||||||
macro_rules! lower_rest {
|
macro_rules! lower_rest {
|
||||||
($variable:expr, $expr:expr) => {
|
($variable:expr, $expr:expr) => {
|
||||||
match hole {
|
lower_rest!(env, procs, layout_cache, $variable, $expr)
|
||||||
None => from_can(env, $variable, $expr, procs, layout_cache),
|
};
|
||||||
Some(_) => unreachable!(),
|
($env:expr, $procs:expr, $layout_cache:expr, $variable:expr, $expr:expr) => {
|
||||||
|
match opt_assigned_and_hole {
|
||||||
|
None => from_can($env, $variable, $expr, $procs, $layout_cache),
|
||||||
|
Some((assigned, hole)) => with_hole(
|
||||||
|
$env,
|
||||||
|
$expr,
|
||||||
|
$variable,
|
||||||
|
$procs,
|
||||||
|
$layout_cache,
|
||||||
|
assigned,
|
||||||
|
hole,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -2129,7 +2140,7 @@ fn from_can_let<'a>(
|
||||||
|env: &mut Env<'a, '_>,
|
|env: &mut Env<'a, '_>,
|
||||||
procs: &mut Procs<'a>,
|
procs: &mut Procs<'a>,
|
||||||
layout_cache: &mut LayoutCache<'a>| {
|
layout_cache: &mut LayoutCache<'a>| {
|
||||||
from_can(env, def.expr_var, cont.value, procs, layout_cache)
|
lower_rest!(env, procs, layout_cache, variable, cont.value)
|
||||||
};
|
};
|
||||||
|
|
||||||
return handle_variable_aliasing(
|
return handle_variable_aliasing(
|
||||||
|
@ -3803,17 +3814,15 @@ pub fn with_hole<'a>(
|
||||||
}
|
}
|
||||||
LetNonRec(def, cont) => {
|
LetNonRec(def, cont) => {
|
||||||
if let roc_can::pattern::Pattern::Identifier(symbol) = def.loc_pattern.value {
|
if let roc_can::pattern::Pattern::Identifier(symbol) = def.loc_pattern.value {
|
||||||
if let Closure(closure_data) = def.loc_expr.value {
|
if matches!(def.loc_expr.value, Closure(_)) {
|
||||||
register_noncapturing_closure(env, procs, symbol, closure_data);
|
return from_can_let(
|
||||||
|
|
||||||
return with_hole(
|
|
||||||
env,
|
env,
|
||||||
cont.value,
|
|
||||||
variable,
|
|
||||||
procs,
|
procs,
|
||||||
layout_cache,
|
layout_cache,
|
||||||
assigned,
|
def,
|
||||||
hole,
|
cont,
|
||||||
|
variable,
|
||||||
|
Some((assigned, hole)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue