Skip to content

Commit 564ecc5

Browse files
committed
asm: allow parameter references in files included from macros
1 parent f365669 commit 564ecc5

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

asm/compiler_expand.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ func (inst includeStatement) expand(c *Compiler, doc *ast.Document, prog *compil
244244
// We can just ignore the statement here since the error was already reported.
245245
return nil
246246
}
247-
prog.pushSection(incdoc, nil)
247+
prog.pushSection(incdoc, prog.cur.macroArgs)
248248
defer prog.popSection()
249249
c.expand(incdoc, prog)
250250
return nil

asm/testdata/compiler-tests.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,37 @@ instr-macro-variable-shadow:
847847
output:
848848
bytecode: "6001 6002"
849849

850+
instr-macro-variable-local:
851+
input:
852+
code: |
853+
#define %inner(inner) {
854+
push $inner
855+
push $outer ; not possible!
856+
}
857+
#define %outer(outer) {
858+
push $outer
859+
%inner(3)
860+
}
861+
%outer(1)
862+
output:
863+
errors:
864+
- ":3: undefined macro parameter $outer"
865+
866+
instr-macro-variable-in-include-file:
867+
input:
868+
code: |
869+
#define %mac(param) {
870+
#include "inc.eas"
871+
}
872+
%mac(1)
873+
files:
874+
inc.eas: |
875+
push $param
876+
push $param
877+
add
878+
output:
879+
bytecode: "6001 6001 01"
880+
850881
immediates:
851882
input:
852883
code: |

0 commit comments

Comments
 (0)