mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Make it easier to debug lambdas
This commit is contained in:
@@ -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()) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
+2
-2
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user