Commit 6e203cf
committed
fix: Handle nested Block expressions in While loops and void function returns
This fixes two issues with Haxe/Reflaxe compilation:
1. CFG builder: Handle Expression(Block) in while loop bodies
- Haxe generates While body as Expression(Block(...)) instead of
direct statements
- Added flattening logic in typed_cfg.rs to recursively process
inner Block statements
2. Cranelift backend: Void functions now return instead of trap
- Functions with Void return type that fall through without explicit
return now emit `return_(&[])` instead of `trap unreachable`
- This fixes Haxe main() functions which return Void
Tested with SimpleWhileTest.hx which computes sum 0+1+2+3+4 = 10 using
a while loop - generates correct Cranelift IR with proper phi nodes.1 parent 2dfb421 commit 6e203cf
8 files changed
Lines changed: 526 additions & 1181 deletions
File tree
- crates/compiler/src
- reflaxe.zyntax
- test
- output
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1737 | 1737 | | |
1738 | 1738 | | |
1739 | 1739 | | |
1740 | | - | |
| 1740 | + | |
| 1741 | + | |
| 1742 | + | |
| 1743 | + | |
| 1744 | + | |
| 1745 | + | |
| 1746 | + | |
| 1747 | + | |
1741 | 1748 | | |
1742 | 1749 | | |
1743 | 1750 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
782 | 782 | | |
783 | 783 | | |
784 | 784 | | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
785 | 801 | | |
786 | 802 | | |
787 | 803 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
10 | 13 | | |
11 | 14 | | |
12 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
0 commit comments