Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
faldor20 committed Feb 13, 2024
1 parent 8ef460f commit ced074e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
11 changes: 8 additions & 3 deletions crates/compiler/can/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ pub enum Expr {
Box<(Variable, Loc<Expr>, Variable, Variable)>,
Vec<(Variable, Loc<Expr>)>,
CalledVia,
bool,
),
RunLowLevel {
op: LowLevel,
Expand Down Expand Up @@ -315,7 +316,7 @@ impl Expr {
Self::If { .. } => Category::If,
Self::LetRec(_, expr, _) => expr.value.category(),
Self::LetNonRec(_, expr) => expr.value.category(),
&Self::Call(_, _, called_via) => Category::CallResult(None, called_via),
&Self::Call(_, _, called_via, _) => Category::CallResult(None, called_via),
&Self::RunLowLevel { op, .. } => Category::LowLevelOpResult(op),
Self::ForeignCall { .. } => Category::ForeignCall,
Self::Closure(..) => Category::Lambda,
Expand Down Expand Up @@ -970,6 +971,7 @@ pub fn canonicalize_expr<'a>(
)),
args,
*application_style,
true,
)
}
RuntimeError(_) => {
Expand Down Expand Up @@ -1009,6 +1011,7 @@ pub fn canonicalize_expr<'a>(
)),
args,
*application_style,
false,
)
}
};
Expand Down Expand Up @@ -2292,7 +2295,7 @@ pub fn inline_calls(var_store: &mut VarStore, expr: Expr) -> Expr {
);
}

Call(boxed_tuple, args, called_via) => {
Call(boxed_tuple, args, called_via, tail_call) => {
let (fn_var, loc_expr, closure_var, expr_var) = *boxed_tuple;

match loc_expr.value {
Expand Down Expand Up @@ -2367,6 +2370,7 @@ pub fn inline_calls(var_store: &mut VarStore, expr: Expr) -> Expr {
Box::new((fn_var, loc_expr, closure_var, expr_var)),
args,
called_via,
tail_call,
)
}
}
Expand Down Expand Up @@ -2663,6 +2667,7 @@ fn desugar_str_segments(var_store: &mut VarStore, segments: Vec<StrSegment>) ->
(var_store.fresh(), loc_expr),
],
CalledVia::StringInterpolation,
false,
);

loc_expr = Loc::at(Region::zero(), expr);
Expand Down Expand Up @@ -3177,7 +3182,7 @@ pub(crate) fn get_lookup_symbols(expr: &Expr) -> Vec<ExpectLookup> {
stack.push(&def.loc_expr.value);
stack.push(&expr.value);
}
Expr::Call(boxed_expr, args, _called_via) => {
Expr::Call(boxed_expr, args, _called_via, tail_call) => {
stack.reserve(1 + args.len());

match &boxed_expr.1.value {
Expand Down
3 changes: 2 additions & 1 deletion crates/compiler/can/src/traverse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,9 @@ pub fn walk_expr<V: Visitor>(visitor: &mut V, expr: &Expr, var: Variable) {
visitor.visit_def(def);
visitor.visit_expr(&body.value, body.region, var);
}
Expr::Call(f, args, _called_via) => {
Expr::Call(f, args, _called_via, tail_call) => {
let (fn_var, loc_fn, _closure_var, _ret_var) = &**f;

walk_call(visitor, *fn_var, loc_fn, args);
}
Expr::Crash { msg, .. } => {
Expand Down

0 comments on commit ced074e

Please sign in to comment.