mirror of
https://github.com/dschmenk/PLASMA.git
synced 2025-01-05 17:32:02 +00:00
Fixed lambda def count (forgot to add lambdas to overall def count)
This commit is contained in:
parent
dbc02bc1b6
commit
821dd14649
@ -395,7 +395,6 @@ def emit_lambdafunc(tag, cparms, lambda_seq)#0
|
||||
framesize = cparms * 2
|
||||
emit_enter(cparms)
|
||||
emit_seq(lambda_seq)
|
||||
emit_pending_seq
|
||||
emit_leave
|
||||
end
|
||||
//
|
||||
@ -441,9 +440,9 @@ def lookup_idglobal(nameptr, len)
|
||||
fin
|
||||
return idptr
|
||||
end
|
||||
def new_iddata(namestr, len, type, size)#0
|
||||
if idmatch(namestr, len, idglobal_tbl, globals); exit_err(ERR_DUP|ERR_ID); fin
|
||||
nametostr(namestr, len, lastglobal + idname)
|
||||
def new_iddata(nameptr, len, type, size)#0
|
||||
if idmatch(nameptr, len, idglobal_tbl, globals); exit_err(ERR_DUP|ERR_ID); fin
|
||||
nametostr(nameptr, len, lastglobal + idname)
|
||||
lastglobal=>idtype = type
|
||||
if type & EXTERN_TYPE
|
||||
lastglobal=>idval = new_tag(EXTERN_FIXUP|WORD_FIXUP)//datasize
|
||||
@ -467,29 +466,30 @@ def size_iddata(type, varsize, initsize)#0
|
||||
datasize = datasize + initsize
|
||||
fin
|
||||
end
|
||||
def new_idglobal(namestr, len, type, value, cparms, cvals)#0
|
||||
if idmatch(namestr, len, idglobal_tbl, globals); exit_err(ERR_DUP|ERR_ID); fin
|
||||
def new_idglobal(nameptr, len, type, value, cparms, cvals)#0
|
||||
if idmatch(nameptr, len, idglobal_tbl, globals); exit_err(ERR_DUP|ERR_ID); fin
|
||||
lastglobal=>idval = value
|
||||
lastglobal=>idtype = type
|
||||
lastglobal->funcparms = cparms
|
||||
lastglobal->funcvals = cvals
|
||||
nametostr(namestr, len, lastglobal + idname)
|
||||
nametostr(nameptr, len, lastglobal + idname)
|
||||
globals++
|
||||
lastglobal = lastglobal + t_id + len
|
||||
if lastglobal - idglobal_tbl > globalbufsz; exit_err(ERR_OVER|ERR_GLOBAL|ERR_ID|ERR_TABLE); fin
|
||||
end
|
||||
def new_idconst(namestr, len, value)#0
|
||||
new_idglobal(namestr, len, CONST_TYPE, value, 0, 0)
|
||||
def new_idconst(nameptr, len, value)#0
|
||||
new_idglobal(nameptr, len, CONST_TYPE, value, 0, 0)
|
||||
end
|
||||
def new_idfunc(namestr, len, type, tag, cfnparms, cfnvals)#0
|
||||
new_idglobal(namestr, len, type|FUNC_TYPE, tag, cfnparms, cfnvals)
|
||||
def new_idfunc(nameptr, len, type, tag, cfnparms, cfnvals)#0
|
||||
new_idglobal(nameptr, len, type|FUNC_TYPE, tag, cfnparms, cfnvals)
|
||||
if not (type & EXTERN_TYPE); def_cnt++; fin
|
||||
end
|
||||
def set_idfunc(namestr, len, tag, cparms, cvals)#0
|
||||
def set_idfunc(nameptr, len, tag, cparms, cvals)#0
|
||||
word idptr
|
||||
|
||||
idptr = lookup_idglobal(namestr, len)
|
||||
idptr = lookup_idglobal(nameptr, len)
|
||||
if idptr
|
||||
if not (idptr=>idtype & FUNC_TYPE); exit_err(ERR_UNDECL|ERR_CODE); fin
|
||||
if not (idptr=>idtype & FUNC_TYPE); exit_err(ERR_UNDECL|ERR_CODE); fin // DEBUG
|
||||
idptr=>idval = tag
|
||||
idptr->funcparms = cparms
|
||||
idptr->funcvals = cvals
|
||||
@ -533,11 +533,11 @@ def init_idglobal#0
|
||||
next
|
||||
op=>opnext = NULL
|
||||
end
|
||||
def new_idlocal(namestr, len, type, size)#0
|
||||
if idmatch(namestr, len, @idlocal_tbl, locals); exit_err(ERR_DUP|ERR_ID); fin
|
||||
def new_idlocal(nameptr, len, type, size)#0
|
||||
if idmatch(nameptr, len, @idlocal_tbl, locals); exit_err(ERR_DUP|ERR_ID); fin
|
||||
lastlocal=>idval = framesize
|
||||
lastlocal=>idtype = type | LOCAL_TYPE
|
||||
nametostr(namestr, len, lastlocal + idname)
|
||||
nametostr(nameptr, len, lastlocal + idname)
|
||||
locals++
|
||||
lastlocal = lastlocal + t_id + len
|
||||
if lastlocal - idlocal_tbl > localbufsz; exit_err(ERR_OVER|ERR_LOCAL|ERR_TABLE); fin
|
||||
@ -554,7 +554,6 @@ def save_idlocal#0
|
||||
savesize = framesize
|
||||
savelast = lastlocal
|
||||
memcpy(heapmark, idlocal_tbl, lastlocal - idlocal_tbl)
|
||||
init_idlocal
|
||||
end
|
||||
def restore_idlocal#0
|
||||
locals = savelocals
|
||||
|
@ -1070,13 +1070,17 @@ end
|
||||
def parse_lambda
|
||||
word func_tag
|
||||
byte cfnparms
|
||||
byte lambda_id[4]
|
||||
|
||||
if not infunc; exit_err(ERR_INVAL|ERR_STATE); fin
|
||||
save_idlocal
|
||||
if inlambda; puts("Nested lambdas!\n"); exit_err(0); fin
|
||||
//
|
||||
// Parse parameters and return value count
|
||||
//
|
||||
save_idlocal
|
||||
init_idlocal
|
||||
cfnparms = 0
|
||||
inlambda = TRUE
|
||||
if scan == OPEN_PAREN_TKN
|
||||
repeat
|
||||
if scan == ID_TKN
|
||||
@ -1100,17 +1104,16 @@ def parse_lambda
|
||||
//
|
||||
// Build an anonymous ID string for the Lambda function
|
||||
//
|
||||
lambda_id[lambda_cnt * 4 + 0] = 3
|
||||
lambda_id[lambda_cnt * 4 + 1] = '&'
|
||||
lambda_id[lambda_cnt * 4 + 2] = ((lambda_num >> 3) & $07) + '0'
|
||||
lambda_id[lambda_cnt * 4 + 3] = (lambda_num & $07) + '0'
|
||||
lambda_id:0 = 3 | ('&' << 8)
|
||||
lambda_id.2 = ((lambda_num >> 3) & $07) + '0'
|
||||
lambda_id.3 = (lambda_num & $07) + '0'
|
||||
lambda_num++
|
||||
if lookup_idglobal(@lambda_id[lambda_cnt * 4 + 1], 3)
|
||||
if lookup_idglobal(@lambda_id.1, 3)
|
||||
//
|
||||
// Lambda ID already exists (from failed scanning for '=')
|
||||
//
|
||||
func_tag = lambda_tag[lambda_cnt]
|
||||
set_idfunc(@lambda_id[lambda_cnt * 4 + 1], 3, func_tag, cfnparms, 1) // Override any predef type & tag
|
||||
set_idfunc(@lambda_id.1, 3, func_tag, cfnparms, 1) // Override any predef type & tag
|
||||
else
|
||||
//
|
||||
// Creat new Lambda ID
|
||||
@ -1118,10 +1121,11 @@ def parse_lambda
|
||||
func_tag = new_tag(WORD_FIXUP)
|
||||
lambda_tag[lambda_cnt] = func_tag
|
||||
lambda_cparms[lambda_cnt] = cfnparms
|
||||
new_idfunc(@lambda_id[lambda_cnt * 4 + 1], 3, FUNC_TYPE, func_tag, cfnparms, 1)
|
||||
new_idfunc(@lambda_id.1, 3, FUNC_TYPE, func_tag, cfnparms, 1)
|
||||
fin
|
||||
lambda_cnt++
|
||||
if lambda_cnt >= LAMBDANUM; parse_warn("Lambda function overflow"); fin
|
||||
inlambda = FALSE
|
||||
restore_idlocal
|
||||
return func_tag
|
||||
end
|
||||
@ -1136,7 +1140,6 @@ def parse_defs
|
||||
fin
|
||||
if token == DEF_TKN
|
||||
if scan <> ID_TKN; exit_err(ERR_INVAL|ERR_ID); fin
|
||||
def_cnt++
|
||||
lambda_cnt = 0
|
||||
cfnparms = 0
|
||||
infuncvals = 1
|
||||
|
@ -294,16 +294,15 @@ const RVALUE = 1
|
||||
const LAMBDANUM = 16
|
||||
byte[80] strconst
|
||||
word strconstptr
|
||||
byte infunc
|
||||
byte infunc, inlambda
|
||||
byte stack_loop
|
||||
byte prevstmnt
|
||||
word infuncvals
|
||||
word break_tag
|
||||
word cont_tag
|
||||
byte lambda_cnt, lambda_num
|
||||
byte[LAMBDANUM] lambda_id[4], lambda_cparms
|
||||
word[LAMBDANUM] lambda_seq
|
||||
word[LAMBDANUM] lambda_tag
|
||||
byte[LAMBDANUM] lambda_cparms
|
||||
word[LAMBDANUM] lambda_seq, lambda_tag
|
||||
predef parse_constexpr#3, parse_expr(codeseq)#2, parse_lambda
|
||||
//
|
||||
// Arg pointer
|
||||
|
Loading…
Reference in New Issue
Block a user