PLASMA compiler emits broken module if a constant is defined before imports
ZornsLemma opened this issue · 1 comments
ZornsLemma commented
If I modify test.pla to add a constant definition before the includes:
diff --git a/src/samplesrc/test.pla b/src/samplesrc/test.pla
index 73a29eb..a27c27c 100755
--- a/src/samplesrc/test.pla
+++ b/src/samplesrc/test.pla
@@ -1,6 +1,7 @@
//
// Include all imported modules and their data/functions.
//
+const foo = 42
include "inc/cmdsys.plh"
include "inc/testlib.plh"
//
the PLASMA compiler doesn't complain but it generates a broken module with the "end of module dependencies" zero byte too early (before CMDSYS, in this case):
; ACME COMPATIBLE OUTPUT
!WORD _SEGEND-_SEGBEGIN ; LENGTH OF HEADER + CODE/DATA + BYTECODE SEGMENT
_SEGBEGIN
!WORD $6502 ; MAGIC #
!WORD _SYSFLAGS ; SYSTEM FLAGS
!WORD _SUBSEG ; BYTECODE SUB-SEGMENT
!WORD _DEFCNT ; BYTECODE DEF COUNT
!WORD _INIT ; MODULE INITIALIZATION ROUTINE
; <stdin>: 0001: //
; <stdin>: 0002: // Include all imported modules and their data/functions.
; <stdin>: 0003: //
; <stdin>: 0004: const foo = 42
!BYTE $00 ; END OF MODULE DEPENDENCIES
; foo = 42
; <stdin>: 0005: include "inc/cmdsys.plh"
; inc/cmdsys.plh: 0001: import cmdsys
; DCI STRING: CMDSYS
!BYTE $C3,$CD,$C4,$D3,$D9,$53
; CMDSYS -> X000
I think this should either work or the compiler should refuse to compile the file because there's a constant definition in the wrong place.
dschmenk commented
I tried this with the latest (BETA) and it seems to work fine now.