dillon1000/react
Commit
Browse files POC of new expression-oriented inference model for memoization within control-flow (#589)
* [hir] Core data types and lowering for new model * Handle more expressions, including using babel for binding resolution * test setup with pretty printing of ir * Basic codegen and improved pretty printing * avoid else block when if has no fallthrough * emit function declarations with mapped name/params * start of scope analysis * saving state pre-run * add slightly more complex example and flush out lowering/printing (jsx, new, variables) * Various improvements: * Convert logical expressions (|| and &&) to control flow, accounting for lazy evaluation semantics. * Handle expression statements * Improve printing of HIR for unsupported node kinds * Handle more cases of JSX by falling by to OtherStatement to wrap subtrees at coarse granularity. * improve HIR printing, lowering of expression statements * handle object expression printing * improve IR model for values/places along w codegen * more test cases * start of mutability inference * passable but still incorrect mutability inference * improved mutability inference, should cover most cases now * visualization of reference graph * correctly flow mutability backwards (have to actually set the capability) * separate visualization in output * consolidate on frozen/readonly/mutable capabilities * cleanup * conditional reassignment test (not quite working) * hack to output svg files for debugging * handle conditional reassignment * improve capture analysis * treat jsx as (interior) mutable; handle memberexpression lvalues * lots of comments; hook return is frozen * update main comment * inference for switch, which reveals a bug * fix yarn.lock
Changed paths58 files
First-parent comparisoncompiler/forget/package.json ModifiedA compiler/forget/src/HIR/BuildHIR.ts AddedA compiler/forget/src/HIR/Codegen.ts AddedA compiler/forget/src/HIR/DisjointSet.ts AddedA compiler/forget/src/HIR/HIR.ts AddedA compiler/forget/src/HIR/HIRBuilder.ts AddedA compiler/forget/src/HIR/InferMutability.ts AddedA compiler/forget/src/HIR/PrintHIR.ts AddedA compiler/forget/src/HIR/ScopeAnalysis.ts AddedA compiler/forget/src/HIR/todo.ts AddedA compiler/forget/src/__tests__/fixtures/hir-svg/call.svg AddedA compiler/forget/src/__tests__/fixtures/hir-svg/component.svg AddedA compiler/forget/src/__tests__/fixtures/hir-svg/conditional-break.svg AddedA compiler/forget/src/__tests__/fixtures/hir-svg/conditional-on-mutable.svg AddedA compiler/forget/src/__tests__/fixtures/hir-svg/constructor.svg AddedA compiler/forget/src/__tests__/fixtures/hir-svg/hook-call.svg AddedA compiler/forget/src/__tests__/fixtures/hir-svg/independent-across-if.svg AddedA compiler/forget/src/__tests__/fixtures/hir-svg/independent.svg AddedA compiler/forget/src/__tests__/fixtures/hir-svg/interdependent-across-if.svg AddedA compiler/forget/src/__tests__/fixtures/hir-svg/interdependent.svg AddedA compiler/forget/src/__tests__/fixtures/hir-svg/property-assignment.svg AddedA compiler/forget/src/__tests__/fixtures/hir-svg/reassignment-conditional.svg AddedA compiler/forget/src/__tests__/fixtures/hir-svg/reassignment.svg AddedA compiler/forget/src/__tests__/fixtures/hir-svg/simple.svg AddedA compiler/forget/src/__tests__/fixtures/hir-svg/switch.svg AddedA compiler/forget/src/__tests__/fixtures/hir/call.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/call.js AddedA compiler/forget/src/__tests__/fixtures/hir/component.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/component.js AddedA compiler/forget/src/__tests__/fixtures/hir/conditional-break.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/conditional-break.js AddedA compiler/forget/src/__tests__/fixtures/hir/conditional-on-mutable.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/conditional-on-mutable.js AddedA compiler/forget/src/__tests__/fixtures/hir/constructor.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/constructor.js AddedA compiler/forget/src/__tests__/fixtures/hir/hook-call.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/hook-call.js AddedA compiler/forget/src/__tests__/fixtures/hir/independent-across-if.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/independent-across-if.js AddedA compiler/forget/src/__tests__/fixtures/hir/independent.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/independent.js AddedA compiler/forget/src/__tests__/fixtures/hir/interdependent-across-if.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/interdependent-across-if.js AddedA compiler/forget/src/__tests__/fixtures/hir/interdependent.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/interdependent.js AddedA compiler/forget/src/__tests__/fixtures/hir/property-assignment.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/property-assignment.js AddedA compiler/forget/src/__tests__/fixtures/hir/reassignment-conditional.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/reassignment-conditional.js AddedA compiler/forget/src/__tests__/fixtures/hir/reassignment.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/reassignment.js AddedA compiler/forget/src/__tests__/fixtures/hir/simple.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/simple.js AddedA compiler/forget/src/__tests__/fixtures/hir/switch.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/switch.js AddedA compiler/forget/src/__tests__/hir-test.ts AddedM compiler/forget/tsconfig.json ModifiedM compiler/forget/yarn.lock ModifiedPatch
Files changed
Rendering syntax-highlighted changes…