mirror of
https://github.com/dschmenk/PLASMA.git
synced 2025-01-24 20:31:12 +00:00
Allow to import module header itself
This commit is contained in:
parent
f78f2827dc
commit
cdb734d1ba
@ -804,7 +804,8 @@ t_opseq *parse_expr(t_opseq *codeseq, int *stackdepth)
|
|||||||
codeseq = gen_codetag(codeseq, tag_endtri);
|
codeseq = gen_codetag(codeseq, tag_endtri);
|
||||||
}
|
}
|
||||||
return (codeseq);
|
return (codeseq);
|
||||||
}t_opseq *parse_set(t_opseq *codeseq)
|
}
|
||||||
|
t_opseq *parse_set(t_opseq *codeseq)
|
||||||
{
|
{
|
||||||
char *setptr = tokenstr;
|
char *setptr = tokenstr;
|
||||||
int lparms = 0, rparms = 0;
|
int lparms = 0, rparms = 0;
|
||||||
|
@ -967,7 +967,7 @@ def parse_stmnt
|
|||||||
wend
|
wend
|
||||||
return scan == EOL_TKN
|
return scan == EOL_TKN
|
||||||
end
|
end
|
||||||
def parse_var(type, basesize)#0
|
def parse_var(type, basesize, ignore_var)#0
|
||||||
byte consttype, constsize, idlen
|
byte consttype, constsize, idlen
|
||||||
word idptr, constval, arraysize, size
|
word idptr, constval, arraysize, size
|
||||||
|
|
||||||
@ -995,7 +995,7 @@ def parse_var(type, basesize)#0
|
|||||||
arraysize = arraysize + emit_data(type, consttype, constval, constsize)
|
arraysize = arraysize + emit_data(type, consttype, constval, constsize)
|
||||||
loop
|
loop
|
||||||
size_iddata(PTR_TYPE, size, arraysize)
|
size_iddata(PTR_TYPE, size, arraysize)
|
||||||
else
|
elsif not ignore_var
|
||||||
if idlen
|
if idlen
|
||||||
if infunc
|
if infunc
|
||||||
new_idlocal(idptr, idlen, type, size)
|
new_idlocal(idptr, idlen, type, size)
|
||||||
@ -1066,7 +1066,7 @@ def parse_struc#0
|
|||||||
if token <> END_TKN; exit_err(ERR_MISS|ERR_CLOSE|ERR_STATE); fin
|
if token <> END_TKN; exit_err(ERR_MISS|ERR_CLOSE|ERR_STATE); fin
|
||||||
scan
|
scan
|
||||||
end
|
end
|
||||||
def parse_vars(type)
|
def parse_vars(type, ignore_vars)
|
||||||
byte idlen, cfnparms, cfnvals
|
byte idlen, cfnparms, cfnvals
|
||||||
word size, value, idptr
|
word size, value, idptr
|
||||||
|
|
||||||
@ -1107,7 +1107,7 @@ def parse_vars(type)
|
|||||||
rewind(tknptr)
|
rewind(tknptr)
|
||||||
fin
|
fin
|
||||||
if type & WORD_TYPE; size = size * 2; fin
|
if type & WORD_TYPE; size = size * 2; fin
|
||||||
repeat; parse_var(type, size); until token <> COMMA_TKN
|
repeat; parse_var(type, size, ignore_vars); until token <> COMMA_TKN
|
||||||
break
|
break
|
||||||
is PREDEF_TKN
|
is PREDEF_TKN
|
||||||
repeat
|
repeat
|
||||||
@ -1149,11 +1149,23 @@ def parse_vars(type)
|
|||||||
return TRUE
|
return TRUE
|
||||||
end
|
end
|
||||||
def parse_mods
|
def parse_mods
|
||||||
|
byte i, ignore_emit
|
||||||
|
|
||||||
if token == IMPORT_TKN
|
if token == IMPORT_TKN
|
||||||
if scan <> ID_TKN; exit_err(ERR_MISS|ERR_ID); fin
|
if scan <> ID_TKN; exit_err(ERR_MISS|ERR_ID); fin
|
||||||
new_moddep(tknptr, tknlen)
|
if tknlen == modfile
|
||||||
|
ignore_emit = TRUE
|
||||||
|
for i = 1 to tknlen
|
||||||
|
if toupper(tknptr->[i - 1]) <> modfile[i]; ignore_emit = FALSE; break; fin
|
||||||
|
next
|
||||||
|
else
|
||||||
|
ignore_emit = FALSE
|
||||||
|
fin
|
||||||
|
if not ignore_emit
|
||||||
|
new_moddep(tknptr, tknlen)
|
||||||
|
fin
|
||||||
scan
|
scan
|
||||||
while parse_vars(EXTERN_TYPE); nextln; loop
|
while parse_vars(EXTERN_TYPE, ignore_emit); nextln; loop
|
||||||
if token <> END_TKN; exit_err(ERR_MISS|ERR_CLOSE|ERR_STATE); fin
|
if token <> END_TKN; exit_err(ERR_MISS|ERR_CLOSE|ERR_STATE); fin
|
||||||
scan
|
scan
|
||||||
fin
|
fin
|
||||||
@ -1228,7 +1240,7 @@ def parse_defs
|
|||||||
when token
|
when token
|
||||||
is CONST_TKN
|
is CONST_TKN
|
||||||
is STRUC_TKN
|
is STRUC_TKN
|
||||||
return parse_vars(GLOBAL_TYPE)
|
return parse_vars(GLOBAL_TYPE, FALSE)
|
||||||
is EXPORT_TKN
|
is EXPORT_TKN
|
||||||
if scan <> DEF_TKN; exit_err(ERR_INVAL|ERR_STATE); fin
|
if scan <> DEF_TKN; exit_err(ERR_INVAL|ERR_STATE); fin
|
||||||
type = type | EXPORT_TYPE
|
type = type | EXPORT_TYPE
|
||||||
@ -1273,7 +1285,7 @@ def parse_defs
|
|||||||
defcodeptr = codeptr
|
defcodeptr = codeptr
|
||||||
emit_tag(func_tag)
|
emit_tag(func_tag)
|
||||||
new_dfd(func_tag)
|
new_dfd(func_tag)
|
||||||
while parse_vars(LOCAL_TYPE); nextln; loop
|
while parse_vars(LOCAL_TYPE, FALSE); nextln; loop
|
||||||
emit_enter(cfnparms)
|
emit_enter(cfnparms)
|
||||||
prevstmnt = 0
|
prevstmnt = 0
|
||||||
while parse_stmnt; nextln; loop
|
while parse_stmnt; nextln; loop
|
||||||
@ -1300,14 +1312,14 @@ def parse_module#0
|
|||||||
init_idglobal
|
init_idglobal
|
||||||
init_idlocal
|
init_idlocal
|
||||||
puts("Data+Code buffer size = "); puti(codebufsz); putln; putln
|
puts("Data+Code buffer size = "); puti(codebufsz); putln; putln
|
||||||
puts(@relfile);
|
puts(@modfile);
|
||||||
if nextln
|
if nextln
|
||||||
//
|
//
|
||||||
// Compile module
|
// Compile module
|
||||||
//
|
//
|
||||||
puts("\nDATA:");
|
puts("\nDATA:");
|
||||||
while parse_mods; nextln; loop
|
while parse_mods; nextln; loop
|
||||||
while parse_vars(GLOBAL_TYPE); nextln; loop
|
while parse_vars(GLOBAL_TYPE, FALSE); nextln; loop
|
||||||
emit_codeseg
|
emit_codeseg
|
||||||
puti(codeptr - codebuff); puts(@bytesln)
|
puti(codeptr - codebuff); puts(@bytesln)
|
||||||
while parse_defs; nextln; loop
|
while parse_defs; nextln; loop
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include "plasm.h"
|
#include "plasm.h"
|
||||||
|
|
||||||
|
@ -276,7 +276,7 @@ byte outflags
|
|||||||
// ProDOS/SOS file references
|
// ProDOS/SOS file references
|
||||||
//
|
//
|
||||||
byte refnum, srcref, incref
|
byte refnum, srcref, incref
|
||||||
byte[32] srcfile, incfile, relfile
|
byte[32] srcfile, incfile, relfile, modfile
|
||||||
word parsefile // Pointer to current file
|
word parsefile // Pointer to current file
|
||||||
word srcline // Saved source line number
|
word srcline // Saved source line number
|
||||||
//
|
//
|
||||||
@ -560,6 +560,15 @@ if ^arg
|
|||||||
//
|
//
|
||||||
strcpy(@relfile, "A.OUT")
|
strcpy(@relfile, "A.OUT")
|
||||||
fin
|
fin
|
||||||
|
modfile = 0
|
||||||
|
for srcref = 1 to relfile
|
||||||
|
if relfile[srcref] == '/'
|
||||||
|
modfile = 0
|
||||||
|
else
|
||||||
|
modfile++
|
||||||
|
modfile[modfile] = toupper(relfile[srcref])
|
||||||
|
fin
|
||||||
|
next
|
||||||
fin
|
fin
|
||||||
fin
|
fin
|
||||||
if srcfile and relfile
|
if srcfile and relfile
|
||||||
|
Loading…
x
Reference in New Issue
Block a user