Commit 5de6d3b
committed
lowering: Canonicalize to builtins for global assignment
This adjusts lowering to emit `setglobal!` for assignment to globals,
thus making the `=` expr head used only for slots in `CodeInfo` and
entirely absent in `IRCode`. The primary reason for this is just
to reduce the number of special cases that compiler passes have
to reason about. In IRCode, `=` was already essentially equivalent
to `setglobal!`, so there's no good reason not to canonicalize.
Finally, the `=` syntax form for globals already gets recognized
specially to insert `convert` calls to their declared binding
type, so this doesn't impose any additional requirements on
lowering to distinguish local from global assignments. In general,
I'd also like to separate syntax and intermediate forms as much
as possible where their semantics differ, which this accomplises
by just using the builtin.
This change is mostly semantically invisible, except that spliced-in
GlobalRefs now declare their binding because they are indistinguishable
from ordinary assignments at the stage where I inserted the lowering.
If we want to, we can preserve the difference, but it'd be a bit
more annoying for not much benefit, because:
1. The spliced in version was only recently made to work anyway, and
2. The semantics of when exactly bindings are declared is still messy
on master anyway and will get tweaked shortly in further binding
partitions work.1 parent f1b0b01 commit 5de6d3b
File tree
8 files changed
+23
-63
lines changed- Compiler
- src
- ssair
- test
- src
- test
8 files changed
+23
-63
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4020 | 4020 | | |
4021 | 4021 | | |
4022 | 4022 | | |
4023 | | - | |
4024 | | - | |
4025 | | - | |
4026 | | - | |
4027 | | - | |
4028 | | - | |
4029 | | - | |
| 4023 | + | |
4030 | 4024 | | |
4031 | 4025 | | |
4032 | 4026 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1408 | 1408 | | |
1409 | 1409 | | |
1410 | 1410 | | |
1411 | | - | |
1412 | | - | |
1413 | | - | |
1414 | | - | |
1415 | | - | |
1416 | | - | |
1417 | | - | |
1418 | | - | |
1419 | | - | |
1420 | | - | |
| 1411 | + | |
1421 | 1412 | | |
1422 | 1413 | | |
1423 | 1414 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
642 | 642 | | |
643 | 643 | | |
644 | 644 | | |
645 | | - | |
646 | | - | |
647 | | - | |
648 | | - | |
649 | | - | |
650 | | - | |
651 | | - | |
652 | 645 | | |
653 | 646 | | |
654 | 647 | | |
| |||
981 | 974 | | |
982 | 975 | | |
983 | 976 | | |
984 | | - | |
985 | | - | |
986 | | - | |
987 | | - | |
988 | | - | |
989 | 977 | | |
990 | 978 | | |
991 | 979 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
363 | 363 | | |
364 | 364 | | |
365 | 365 | | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
| 366 | + | |
| 367 | + | |
374 | 368 | | |
375 | 369 | | |
376 | 370 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2111 | 2111 | | |
2112 | 2112 | | |
2113 | 2113 | | |
2114 | | - | |
| 2114 | + | |
2115 | 2115 | | |
2116 | 2116 | | |
2117 | 2117 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
569 | 569 | | |
570 | 570 | | |
571 | 571 | | |
572 | | - | |
573 | | - | |
574 | | - | |
575 | | - | |
576 | | - | |
577 | | - | |
578 | | - | |
579 | | - | |
580 | | - | |
581 | | - | |
582 | | - | |
583 | | - | |
584 | | - | |
585 | | - | |
586 | | - | |
587 | | - | |
588 | | - | |
589 | | - | |
590 | | - | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
591 | 577 | | |
592 | 578 | | |
593 | 579 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4607 | 4607 | | |
4608 | 4608 | | |
4609 | 4609 | | |
| 4610 | + | |
| 4611 | + | |
| 4612 | + | |
| 4613 | + | |
| 4614 | + | |
| 4615 | + | |
4610 | 4616 | | |
4611 | 4617 | | |
4612 | 4618 | | |
4613 | | - | |
| 4619 | + | |
4614 | 4620 | | |
4615 | 4621 | | |
4616 | | - | |
4617 | | - | |
| 4622 | + | |
| 4623 | + | |
4618 | 4624 | | |
4619 | 4625 | | |
4620 | 4626 | | |
| |||
4693 | 4699 | | |
4694 | 4700 | | |
4695 | 4701 | | |
4696 | | - | |
| 4702 | + | |
4697 | 4703 | | |
4698 | 4704 | | |
4699 | 4705 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3713 | 3713 | | |
3714 | 3714 | | |
3715 | 3715 | | |
3716 | | - | |
| 3716 | + | |
3717 | 3717 | | |
3718 | 3718 | | |
3719 | 3719 | | |
| |||
3728 | 3728 | | |
3729 | 3729 | | |
3730 | 3730 | | |
3731 | | - | |
| 3731 | + | |
3732 | 3732 | | |
3733 | 3733 | | |
3734 | 3734 | | |
| |||
3744 | 3744 | | |
3745 | 3745 | | |
3746 | 3746 | | |
| 3747 | + | |
3747 | 3748 | | |
3748 | 3749 | | |
3749 | 3750 | | |
| |||
0 commit comments