Make it easier to debug lambdas

This commit is contained in:
Joe Savona
2023-02-22 14:07:33 -08:00
parent 8da443b673
commit 1d0aa64b24
3 changed files with 8 additions and 7 deletions
+5 -3
View File
@@ -55,9 +55,10 @@ export function lower(
options: EnvironmentOptions | null,
capturedRefs: t.Identifier[] = [],
// the outermost function being compiled, in case lower() is called recursively (for lambdas)
parent: NodePath<t.Function> | null = null
parent: NodePath<t.Function> | null = null,
environment: Environment | null = null
): Result<HIRFunction, CompilerError> {
const env = new Environment(options);
const env = environment ?? new Environment(options);
const builder = new HIRBuilder(env, parent ?? func, capturedRefs);
const context: Place[] = [];
@@ -1349,7 +1350,8 @@ function lowerExpression(
expr,
builder.environment.options,
[...builder.context, ...captured.identifiers],
builder.parentFunction
builder.parentFunction,
builder.environment
);
let loweredFunc: HIRFunction;
if (lowering.isErr()) {
+1 -2
View File
@@ -333,13 +333,12 @@ export function printInstructionValue(instrValue: ReactiveValue): string {
break;
}
case "FunctionExpression": {
// const fn = generate(instrValue.expr).code;
const fn = printFunction(instrValue.loweredFunc)
.split("\n")
.map((line) => ` ${line}`)
.join("\n");
const deps = instrValue.dependencies
.map((i) => printIdentifier(i.identifier))
.map((dep) => printPlace(dep))
.join(",");
value = `Function @deps[${deps}]:\n${fn}`;
break;
@@ -19,9 +19,9 @@ function component({ mutator }) {
## Code
```javascript
function component(t10) {
function component(t15) {
const $ = React.unstable_useMemoCache(7);
const t0 = t10;
const t0 = t15;
const mutator = t0.mutator;
const c_0 = $[0] !== mutator;
let poke;