mirror of
https://github.com/roc-lang/roc.git
synced 2024-08-16 14:20:56 +03:00
Merge pull request #6168 from roc-lang/dbg-inspect-no-inline
change debug to call `Inspect.inspect` instead of inlining it
This commit is contained in:
commit
142681f77e
@ -565,7 +565,8 @@ pub fn desugar_expr<'a>(
|
|||||||
}
|
}
|
||||||
Dbg(condition, continuation) => {
|
Dbg(condition, continuation) => {
|
||||||
// Desugars a `dbg x` statement into essentially
|
// Desugars a `dbg x` statement into essentially
|
||||||
// Inspect.toInspector x |> Inspect.apply (Inspect.init {}) |> Inspect.toDbgStr |> LowLevelDbg
|
// TODO(#6167): Switch back to `Inspect.toInspector x |> Inspect.apply (Inspect.init {}) |> Inspect.toDbgStr |> LowLevelDbg`
|
||||||
|
// Inspect.inspect x |> Inspect.toDbgStr |> LowLevelDbg
|
||||||
let desugared_continuation = &*arena.alloc(desugar_expr(
|
let desugared_continuation = &*arena.alloc(desugar_expr(
|
||||||
arena,
|
arena,
|
||||||
continuation,
|
continuation,
|
||||||
@ -576,56 +577,19 @@ pub fn desugar_expr<'a>(
|
|||||||
|
|
||||||
let region = condition.region;
|
let region = condition.region;
|
||||||
// Inspect.toInspector x
|
// Inspect.toInspector x
|
||||||
let to_inspector_fn = Var {
|
let inspect_fn = Var {
|
||||||
module_name: ModuleName::INSPECT,
|
module_name: ModuleName::INSPECT,
|
||||||
ident: "toInspector",
|
ident: "inspect",
|
||||||
};
|
};
|
||||||
let loc_to_inspector_fn_var = arena.alloc(Loc {
|
let loc_inspect_fn_var = arena.alloc(Loc {
|
||||||
value: to_inspector_fn,
|
value: inspect_fn,
|
||||||
region,
|
region,
|
||||||
});
|
});
|
||||||
let desugared_to_inspector_args =
|
let desugared_inspect_args =
|
||||||
arena.alloc([desugar_expr(arena, condition, src, line_info, module_path)]);
|
arena.alloc([desugar_expr(arena, condition, src, line_info, module_path)]);
|
||||||
|
|
||||||
let inspector = arena.alloc(Loc {
|
|
||||||
value: Apply(
|
|
||||||
loc_to_inspector_fn_var,
|
|
||||||
desugared_to_inspector_args,
|
|
||||||
CalledVia::Space,
|
|
||||||
),
|
|
||||||
region,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Inspect.init {}
|
|
||||||
let init_fn = Var {
|
|
||||||
module_name: ModuleName::INSPECT,
|
|
||||||
ident: "init",
|
|
||||||
};
|
|
||||||
let loc_init_fn_var = arena.alloc(Loc {
|
|
||||||
value: init_fn,
|
|
||||||
region,
|
|
||||||
});
|
|
||||||
let empty_record_args = arena.alloc([&*arena.alloc(Loc {
|
|
||||||
value: Record(Collection::empty()),
|
|
||||||
region,
|
|
||||||
})]);
|
|
||||||
let formatter = arena.alloc(Loc {
|
let formatter = arena.alloc(Loc {
|
||||||
value: Apply(loc_init_fn_var, empty_record_args, CalledVia::Space),
|
value: Apply(loc_inspect_fn_var, desugared_inspect_args, CalledVia::Space),
|
||||||
region,
|
|
||||||
});
|
|
||||||
|
|
||||||
// |> Inspect.apply (Inspect.init {})
|
|
||||||
let apply_fn = Var {
|
|
||||||
module_name: ModuleName::INSPECT,
|
|
||||||
ident: "apply",
|
|
||||||
};
|
|
||||||
let loc_apply_fn_var = arena.alloc(Loc {
|
|
||||||
value: apply_fn,
|
|
||||||
region,
|
|
||||||
});
|
|
||||||
let apply_args = arena.alloc([&*inspector, &*formatter]);
|
|
||||||
let applied_formatter = arena.alloc(Loc {
|
|
||||||
value: Apply(loc_apply_fn_var, apply_args, CalledVia::Space),
|
|
||||||
region,
|
region,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -638,7 +602,7 @@ pub fn desugar_expr<'a>(
|
|||||||
value: to_dbg_str,
|
value: to_dbg_str,
|
||||||
region,
|
region,
|
||||||
});
|
});
|
||||||
let to_dbg_str_args = arena.alloc([&*applied_formatter]);
|
let to_dbg_str_args = arena.alloc([&*formatter]);
|
||||||
let dbg_str = arena.alloc(Loc {
|
let dbg_str = arena.alloc(Loc {
|
||||||
value: Apply(loc_to_dbg_str_fn_var, to_dbg_str_args, CalledVia::Space),
|
value: Apply(loc_to_dbg_str_fn_var, to_dbg_str_args, CalledVia::Space),
|
||||||
region,
|
region,
|
||||||
|
@ -3,46 +3,46 @@ procedure Bool.2 ():
|
|||||||
ret Bool.23;
|
ret Bool.23;
|
||||||
|
|
||||||
procedure Inspect.249 (Inspect.250, Inspect.248):
|
procedure Inspect.249 (Inspect.250, Inspect.248):
|
||||||
let Inspect.320 : Str = "\"";
|
let Inspect.323 : Str = "\"";
|
||||||
let Inspect.319 : Str = CallByName Inspect.61 Inspect.250 Inspect.320;
|
let Inspect.322 : Str = CallByName Inspect.61 Inspect.250 Inspect.323;
|
||||||
let Inspect.315 : Str = CallByName Inspect.61 Inspect.319 Inspect.248;
|
let Inspect.318 : Str = CallByName Inspect.61 Inspect.322 Inspect.248;
|
||||||
let Inspect.316 : Str = "\"";
|
let Inspect.319 : Str = "\"";
|
||||||
let Inspect.314 : Str = CallByName Inspect.61 Inspect.315 Inspect.316;
|
let Inspect.317 : Str = CallByName Inspect.61 Inspect.318 Inspect.319;
|
||||||
ret Inspect.314;
|
ret Inspect.317;
|
||||||
|
|
||||||
procedure Inspect.30 (Inspect.147):
|
procedure Inspect.30 (Inspect.147):
|
||||||
ret Inspect.147;
|
ret Inspect.147;
|
||||||
|
|
||||||
procedure Inspect.31 (Inspect.305, Inspect.149):
|
|
||||||
let Inspect.307 : Str = CallByName Inspect.249 Inspect.149 Inspect.305;
|
|
||||||
ret Inspect.307;
|
|
||||||
|
|
||||||
procedure Inspect.35 (Inspect.300):
|
procedure Inspect.35 (Inspect.300):
|
||||||
ret Inspect.300;
|
ret Inspect.300;
|
||||||
|
|
||||||
procedure Inspect.36 (Inspect.304):
|
procedure Inspect.36 (Inspect.304):
|
||||||
let Inspect.309 : Str = "";
|
let Inspect.311 : Str = "";
|
||||||
ret Inspect.309;
|
ret Inspect.311;
|
||||||
|
|
||||||
procedure Inspect.44 (Inspect.248):
|
procedure Inspect.44 (Inspect.248):
|
||||||
let Inspect.310 : Str = CallByName Inspect.30 Inspect.248;
|
let Inspect.313 : Str = CallByName Inspect.30 Inspect.248;
|
||||||
ret Inspect.310;
|
ret Inspect.313;
|
||||||
|
|
||||||
|
procedure Inspect.5 (Inspect.150):
|
||||||
|
let Inspect.312 : Str = CallByName Inspect.44 Inspect.150;
|
||||||
|
let Inspect.309 : {} = Struct {};
|
||||||
|
let Inspect.308 : Str = CallByName Inspect.36 Inspect.309;
|
||||||
|
let Inspect.307 : Str = CallByName Inspect.249 Inspect.308 Inspect.312;
|
||||||
|
ret Inspect.307;
|
||||||
|
|
||||||
procedure Inspect.61 (Inspect.303, Inspect.298):
|
procedure Inspect.61 (Inspect.303, Inspect.298):
|
||||||
let Inspect.318 : Str = CallByName Str.3 Inspect.303 Inspect.298;
|
let Inspect.321 : Str = CallByName Str.3 Inspect.303 Inspect.298;
|
||||||
dec Inspect.298;
|
dec Inspect.298;
|
||||||
ret Inspect.318;
|
ret Inspect.321;
|
||||||
|
|
||||||
procedure Str.3 (#Attr.2, #Attr.3):
|
procedure Str.3 (#Attr.2, #Attr.3):
|
||||||
let Str.292 : Str = lowlevel StrConcat #Attr.2 #Attr.3;
|
let Str.292 : Str = lowlevel StrConcat #Attr.2 #Attr.3;
|
||||||
ret Str.292;
|
ret Str.292;
|
||||||
|
|
||||||
procedure Test.1 ():
|
procedure Test.1 ():
|
||||||
let Test.8 : Str = "";
|
let Test.5 : Str = "";
|
||||||
let Test.5 : Str = CallByName Inspect.44 Test.8;
|
let Test.4 : Str = CallByName Inspect.5 Test.5;
|
||||||
let Test.7 : {} = Struct {};
|
|
||||||
let Test.6 : Str = CallByName Inspect.36 Test.7;
|
|
||||||
let Test.4 : Str = CallByName Inspect.31 Test.5 Test.6;
|
|
||||||
let Test.0 : Str = CallByName Inspect.35 Test.4;
|
let Test.0 : Str = CallByName Inspect.35 Test.4;
|
||||||
dbg Test.0;
|
dbg Test.0;
|
||||||
dec Test.0;
|
dec Test.0;
|
||||||
|
@ -1,44 +1,44 @@
|
|||||||
procedure Inspect.249 (Inspect.250, Inspect.248):
|
procedure Inspect.249 (Inspect.250, Inspect.248):
|
||||||
let Inspect.320 : Str = "\"";
|
let Inspect.323 : Str = "\"";
|
||||||
let Inspect.319 : Str = CallByName Inspect.61 Inspect.250 Inspect.320;
|
let Inspect.322 : Str = CallByName Inspect.61 Inspect.250 Inspect.323;
|
||||||
let Inspect.315 : Str = CallByName Inspect.61 Inspect.319 Inspect.248;
|
let Inspect.318 : Str = CallByName Inspect.61 Inspect.322 Inspect.248;
|
||||||
let Inspect.316 : Str = "\"";
|
let Inspect.319 : Str = "\"";
|
||||||
let Inspect.314 : Str = CallByName Inspect.61 Inspect.315 Inspect.316;
|
let Inspect.317 : Str = CallByName Inspect.61 Inspect.318 Inspect.319;
|
||||||
ret Inspect.314;
|
ret Inspect.317;
|
||||||
|
|
||||||
procedure Inspect.30 (Inspect.147):
|
procedure Inspect.30 (Inspect.147):
|
||||||
ret Inspect.147;
|
ret Inspect.147;
|
||||||
|
|
||||||
procedure Inspect.31 (Inspect.305, Inspect.149):
|
|
||||||
let Inspect.307 : Str = CallByName Inspect.249 Inspect.149 Inspect.305;
|
|
||||||
ret Inspect.307;
|
|
||||||
|
|
||||||
procedure Inspect.35 (Inspect.300):
|
procedure Inspect.35 (Inspect.300):
|
||||||
ret Inspect.300;
|
ret Inspect.300;
|
||||||
|
|
||||||
procedure Inspect.36 (Inspect.304):
|
procedure Inspect.36 (Inspect.304):
|
||||||
let Inspect.309 : Str = "";
|
let Inspect.311 : Str = "";
|
||||||
ret Inspect.309;
|
ret Inspect.311;
|
||||||
|
|
||||||
procedure Inspect.44 (Inspect.248):
|
procedure Inspect.44 (Inspect.248):
|
||||||
let Inspect.310 : Str = CallByName Inspect.30 Inspect.248;
|
let Inspect.313 : Str = CallByName Inspect.30 Inspect.248;
|
||||||
ret Inspect.310;
|
ret Inspect.313;
|
||||||
|
|
||||||
|
procedure Inspect.5 (Inspect.150):
|
||||||
|
let Inspect.312 : Str = CallByName Inspect.44 Inspect.150;
|
||||||
|
let Inspect.309 : {} = Struct {};
|
||||||
|
let Inspect.308 : Str = CallByName Inspect.36 Inspect.309;
|
||||||
|
let Inspect.307 : Str = CallByName Inspect.249 Inspect.308 Inspect.312;
|
||||||
|
ret Inspect.307;
|
||||||
|
|
||||||
procedure Inspect.61 (Inspect.303, Inspect.298):
|
procedure Inspect.61 (Inspect.303, Inspect.298):
|
||||||
let Inspect.318 : Str = CallByName Str.3 Inspect.303 Inspect.298;
|
let Inspect.321 : Str = CallByName Str.3 Inspect.303 Inspect.298;
|
||||||
dec Inspect.298;
|
dec Inspect.298;
|
||||||
ret Inspect.318;
|
ret Inspect.321;
|
||||||
|
|
||||||
procedure Str.3 (#Attr.2, #Attr.3):
|
procedure Str.3 (#Attr.2, #Attr.3):
|
||||||
let Str.292 : Str = lowlevel StrConcat #Attr.2 #Attr.3;
|
let Str.292 : Str = lowlevel StrConcat #Attr.2 #Attr.3;
|
||||||
ret Str.292;
|
ret Str.292;
|
||||||
|
|
||||||
procedure Test.0 ():
|
procedure Test.0 ():
|
||||||
let Test.7 : Str = "";
|
let Test.4 : Str = "";
|
||||||
let Test.4 : Str = CallByName Inspect.44 Test.7;
|
let Test.3 : Str = CallByName Inspect.5 Test.4;
|
||||||
let Test.6 : {} = Struct {};
|
|
||||||
let Test.5 : Str = CallByName Inspect.36 Test.6;
|
|
||||||
let Test.3 : Str = CallByName Inspect.31 Test.4 Test.5;
|
|
||||||
let Test.1 : Str = CallByName Inspect.35 Test.3;
|
let Test.1 : Str = CallByName Inspect.35 Test.3;
|
||||||
dbg Test.1;
|
dbg Test.1;
|
||||||
dec Test.1;
|
dec Test.1;
|
||||||
|
@ -9,44 +9,44 @@ main =
|
|||||||
|
|
||||||
# -emit:mono
|
# -emit:mono
|
||||||
procedure Inspect.251 (Inspect.252):
|
procedure Inspect.251 (Inspect.252):
|
||||||
let Inspect.314 : Str = "<opaque>";
|
let Inspect.317 : Str = "<opaque>";
|
||||||
let Inspect.313 : Str = CallByName Inspect.61 Inspect.252 Inspect.314;
|
let Inspect.316 : Str = CallByName Inspect.61 Inspect.252 Inspect.317;
|
||||||
ret Inspect.313;
|
ret Inspect.316;
|
||||||
|
|
||||||
procedure Inspect.30 (Inspect.147):
|
procedure Inspect.30 (Inspect.147):
|
||||||
ret Inspect.147;
|
ret Inspect.147;
|
||||||
|
|
||||||
procedure Inspect.31 (Inspect.305, Inspect.149):
|
|
||||||
let Inspect.307 : Str = CallByName Inspect.251 Inspect.149;
|
|
||||||
ret Inspect.307;
|
|
||||||
|
|
||||||
procedure Inspect.35 (Inspect.300):
|
procedure Inspect.35 (Inspect.300):
|
||||||
ret Inspect.300;
|
ret Inspect.300;
|
||||||
|
|
||||||
procedure Inspect.36 (Inspect.304):
|
procedure Inspect.36 (Inspect.304):
|
||||||
let Inspect.309 : Str = "";
|
let Inspect.311 : Str = "";
|
||||||
ret Inspect.309;
|
ret Inspect.311;
|
||||||
|
|
||||||
procedure Inspect.45 (Inspect.302):
|
procedure Inspect.45 (Inspect.302):
|
||||||
let Inspect.311 : {} = Struct {};
|
let Inspect.314 : {} = Struct {};
|
||||||
let Inspect.310 : {} = CallByName Inspect.30 Inspect.311;
|
let Inspect.313 : {} = CallByName Inspect.30 Inspect.314;
|
||||||
ret Inspect.310;
|
ret Inspect.313;
|
||||||
|
|
||||||
|
procedure Inspect.5 (Inspect.150):
|
||||||
|
let Inspect.312 : {} = CallByName Inspect.45 Inspect.150;
|
||||||
|
let Inspect.309 : {} = Struct {};
|
||||||
|
let Inspect.308 : Str = CallByName Inspect.36 Inspect.309;
|
||||||
|
let Inspect.307 : Str = CallByName Inspect.251 Inspect.308;
|
||||||
|
ret Inspect.307;
|
||||||
|
|
||||||
procedure Inspect.61 (Inspect.303, Inspect.298):
|
procedure Inspect.61 (Inspect.303, Inspect.298):
|
||||||
let Inspect.316 : Str = CallByName Str.3 Inspect.303 Inspect.298;
|
let Inspect.319 : Str = CallByName Str.3 Inspect.303 Inspect.298;
|
||||||
dec Inspect.298;
|
dec Inspect.298;
|
||||||
ret Inspect.316;
|
ret Inspect.319;
|
||||||
|
|
||||||
procedure Str.3 (#Attr.2, #Attr.3):
|
procedure Str.3 (#Attr.2, #Attr.3):
|
||||||
let Str.292 : Str = lowlevel StrConcat #Attr.2 #Attr.3;
|
let Str.292 : Str = lowlevel StrConcat #Attr.2 #Attr.3;
|
||||||
ret Str.292;
|
ret Str.292;
|
||||||
|
|
||||||
procedure Test.0 ():
|
procedure Test.0 ():
|
||||||
let Test.8 : {} = Struct {};
|
let Test.5 : {} = Struct {};
|
||||||
let Test.5 : {} = CallByName Inspect.45 Test.8;
|
let Test.4 : Str = CallByName Inspect.5 Test.5;
|
||||||
let Test.7 : {} = Struct {};
|
|
||||||
let Test.6 : Str = CallByName Inspect.36 Test.7;
|
|
||||||
let Test.4 : Str = CallByName Inspect.31 Test.5 Test.6;
|
|
||||||
let Test.2 : Str = CallByName Inspect.35 Test.4;
|
let Test.2 : Str = CallByName Inspect.35 Test.4;
|
||||||
dbg Test.2;
|
dbg Test.2;
|
||||||
dec Test.2;
|
dec Test.2;
|
||||||
|
@ -12,43 +12,43 @@ main =
|
|||||||
|
|
||||||
# -emit:mono
|
# -emit:mono
|
||||||
procedure Inspect.251 (Inspect.252):
|
procedure Inspect.251 (Inspect.252):
|
||||||
let Inspect.314 : Str = "<opaque>";
|
let Inspect.317 : Str = "<opaque>";
|
||||||
let Inspect.313 : Str = CallByName Inspect.61 Inspect.252 Inspect.314;
|
let Inspect.316 : Str = CallByName Inspect.61 Inspect.252 Inspect.317;
|
||||||
ret Inspect.313;
|
ret Inspect.316;
|
||||||
|
|
||||||
procedure Inspect.30 (Inspect.147):
|
procedure Inspect.30 (Inspect.147):
|
||||||
ret Inspect.147;
|
ret Inspect.147;
|
||||||
|
|
||||||
procedure Inspect.31 (Inspect.305, Inspect.149):
|
|
||||||
let Inspect.307 : Str = CallByName Inspect.251 Inspect.149;
|
|
||||||
ret Inspect.307;
|
|
||||||
|
|
||||||
procedure Inspect.35 (Inspect.300):
|
procedure Inspect.35 (Inspect.300):
|
||||||
ret Inspect.300;
|
ret Inspect.300;
|
||||||
|
|
||||||
procedure Inspect.36 (Inspect.304):
|
procedure Inspect.36 (Inspect.304):
|
||||||
let Inspect.309 : Str = "";
|
let Inspect.311 : Str = "";
|
||||||
ret Inspect.309;
|
ret Inspect.311;
|
||||||
|
|
||||||
procedure Inspect.45 (Inspect.302):
|
procedure Inspect.45 (Inspect.302):
|
||||||
let Inspect.311 : {} = Struct {};
|
let Inspect.314 : {} = Struct {};
|
||||||
let Inspect.310 : {} = CallByName Inspect.30 Inspect.311;
|
let Inspect.313 : {} = CallByName Inspect.30 Inspect.314;
|
||||||
ret Inspect.310;
|
ret Inspect.313;
|
||||||
|
|
||||||
|
procedure Inspect.5 (Inspect.150):
|
||||||
|
let Inspect.312 : {} = CallByName Inspect.45 Inspect.150;
|
||||||
|
let Inspect.309 : {} = Struct {};
|
||||||
|
let Inspect.308 : Str = CallByName Inspect.36 Inspect.309;
|
||||||
|
let Inspect.307 : Str = CallByName Inspect.251 Inspect.308;
|
||||||
|
ret Inspect.307;
|
||||||
|
|
||||||
procedure Inspect.61 (Inspect.303, Inspect.298):
|
procedure Inspect.61 (Inspect.303, Inspect.298):
|
||||||
let Inspect.316 : Str = CallByName Str.3 Inspect.303 Inspect.298;
|
let Inspect.319 : Str = CallByName Str.3 Inspect.303 Inspect.298;
|
||||||
dec Inspect.298;
|
dec Inspect.298;
|
||||||
ret Inspect.316;
|
ret Inspect.319;
|
||||||
|
|
||||||
procedure Str.3 (#Attr.2, #Attr.3):
|
procedure Str.3 (#Attr.2, #Attr.3):
|
||||||
let Str.292 : Str = lowlevel StrConcat #Attr.2 #Attr.3;
|
let Str.292 : Str = lowlevel StrConcat #Attr.2 #Attr.3;
|
||||||
ret Str.292;
|
ret Str.292;
|
||||||
|
|
||||||
procedure Test.2 (Test.3):
|
procedure Test.2 (Test.3):
|
||||||
let Test.9 : {} = CallByName Inspect.45 Test.3;
|
let Test.8 : Str = CallByName Inspect.5 Test.3;
|
||||||
let Test.11 : {} = Struct {};
|
|
||||||
let Test.10 : Str = CallByName Inspect.36 Test.11;
|
|
||||||
let Test.8 : Str = CallByName Inspect.31 Test.9 Test.10;
|
|
||||||
let Test.4 : Str = CallByName Inspect.35 Test.8;
|
let Test.4 : Str = CallByName Inspect.35 Test.8;
|
||||||
dbg Test.4;
|
dbg Test.4;
|
||||||
dec Test.4;
|
dec Test.4;
|
||||||
|
Loading…
Reference in New Issue
Block a user