diff options
| author | Ben Bridle <ben@derelict.engineering> | 2025-12-30 13:26:34 +1300 |
|---|---|---|
| committer | Ben Bridle <ben@derelict.engineering> | 2025-12-30 14:29:19 +1300 |
| commit | a7cfcd4ba9e86dce6d8366dc4122704a49d3909d (patch) | |
| tree | 471523e09dc8aa913c12b43f836647497846b73b /src/stages/semantic.rs | |
| parent | c5e626d27910e82df125d6d0c09037811488eeea (diff) | |
| download | torque-asm-a7cfcd4ba9e86dce6d8366dc4122704a49d3909d.zip | |
Defer evaluation of block arguments
When a block value is evaluated, the address tracker is immediately
incremented for each word in the evaluated block. This was causing an
issue when a block value was passed as an argument to a macro
invocation, because argument values would all be evaluated before the
macro body was evaluated. This meant that the value of every label in
the macro body would be pushed forward by the size of the block
argument, even if the block argument is inserted later in the macro.
Furthermore, the address tracker would be incremented exactly once
for each word in the block, even if the block is never inserted into
the macro or is inserted multiple times.
To fix this, we now defer evaluation of a block argument until exactly
when that block argument is inserted into a macro. Because a block
argument could be an invocation with a set of arguments passed to it,
we also store a copy of the current environment alongside the block
value so that it can be evaluated correctly at any time in the future.
Diffstat (limited to 'src/stages/semantic.rs')
0 files changed, 0 insertions, 0 deletions
