mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 07:14:46 +00:00
Inline LetRec and LetNonRec
This commit is contained in:
parent
319da4141e
commit
8665f23a29
1 changed files with 40 additions and 4 deletions
|
@ -1133,12 +1133,48 @@ pub fn inline_calls(var_store: &mut VarStore, scope: &mut Scope, expr: Expr) ->
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LetRec(_, _, _, _ /*Vec<Def>, Box<Located<Expr>>, Variable, Aliases */) => {
|
LetRec(defs, loc_expr, var, aliases) => {
|
||||||
todo!("inline for LetRec");
|
let mut new_defs = Vec::with_capacity(defs.len());
|
||||||
|
|
||||||
|
for def in defs {
|
||||||
|
new_defs.push(Def {
|
||||||
|
loc_pattern: def.loc_pattern,
|
||||||
|
loc_expr: Located {
|
||||||
|
region: def.loc_expr.region,
|
||||||
|
value: inline_calls(var_store, scope, def.loc_expr.value),
|
||||||
|
},
|
||||||
|
expr_var: def.expr_var,
|
||||||
|
pattern_vars: def.pattern_vars,
|
||||||
|
annotation: def.annotation,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
let loc_expr = Located {
|
||||||
|
region: loc_expr.region,
|
||||||
|
value: inline_calls(var_store, scope, loc_expr.value),
|
||||||
|
};
|
||||||
|
|
||||||
|
LetRec(new_defs, Box::new(loc_expr), var, aliases)
|
||||||
}
|
}
|
||||||
|
|
||||||
LetNonRec(_, _, _, _ /*Box<Def>, Box<Located<Expr>>, Variable, Aliases*/) => {
|
LetNonRec(def, loc_expr, var, aliases) => {
|
||||||
todo!("inline for LetNonRec");
|
let def = Def {
|
||||||
|
loc_pattern: def.loc_pattern,
|
||||||
|
loc_expr: Located {
|
||||||
|
region: def.loc_expr.region,
|
||||||
|
value: inline_calls(var_store, scope, def.loc_expr.value),
|
||||||
|
},
|
||||||
|
expr_var: def.expr_var,
|
||||||
|
pattern_vars: def.pattern_vars,
|
||||||
|
annotation: def.annotation,
|
||||||
|
};
|
||||||
|
|
||||||
|
let loc_expr = Located {
|
||||||
|
region: loc_expr.region,
|
||||||
|
value: inline_calls(var_store, scope, loc_expr.value),
|
||||||
|
};
|
||||||
|
|
||||||
|
LetNonRec(Box::new(def), Box::new(loc_expr), var, aliases)
|
||||||
}
|
}
|
||||||
|
|
||||||
Closure(var, symbol, recursive, patterns, boxed_expr) => {
|
Closure(var, symbol, recursive, patterns, boxed_expr) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue