mirror of
https://github.com/dschmenk/PLASMA.git
synced 2025-01-10 21:30:04 +00:00
CASE checking and limit to 64 cases on self-hosted compiler
This commit is contained in:
parent
b987b927d3
commit
f9a007398f
@ -283,8 +283,7 @@ def crunch_seq(seq, pass)
|
||||
if nextop=>opnext
|
||||
nextopnext = nextop=>opnext
|
||||
when nextopnext->opcode
|
||||
is ADD_CODE
|
||||
is INDEXB_CODE
|
||||
is ADD_CODE // INDEXB_CODE
|
||||
op=>opoffset = op=>opoffset + nextop=>opval
|
||||
freeops = 2
|
||||
break
|
||||
@ -322,8 +321,7 @@ def crunch_seq(seq, pass)
|
||||
if nextop=>opnext
|
||||
nextopnext = nextop=>opnext
|
||||
when nextopnext->opcode
|
||||
is ADD_CODE
|
||||
is INDEXB_CODE
|
||||
is ADD_CODE // INDEXB_CODE
|
||||
op=>opoffset = op=>opoffset + nextop=>opval
|
||||
freeops = 2
|
||||
break
|
||||
@ -361,8 +359,7 @@ def crunch_seq(seq, pass)
|
||||
break // GADDR_CODE
|
||||
is LLB_CODE
|
||||
when nextop->opcode
|
||||
is ADD_CODE
|
||||
is INDEXB_CODE
|
||||
is ADD_CODE // INDEXB_CODE
|
||||
op->opcode = ADDLB_CODE
|
||||
freeops = 1
|
||||
break
|
||||
@ -377,8 +374,7 @@ def crunch_seq(seq, pass)
|
||||
break // LLB_CODE
|
||||
is LLW_CODE
|
||||
when nextop->opcode
|
||||
is ADD_CODE
|
||||
is INDEXB_CODE
|
||||
is ADD_CODE // INDEXB_CODE
|
||||
op->opcode = ADDLW_CODE
|
||||
freeops = 1
|
||||
break
|
||||
@ -405,8 +401,7 @@ def crunch_seq(seq, pass)
|
||||
break // LLW_CODE
|
||||
is LAB_CODE
|
||||
when nextop->opcode
|
||||
is ADD_CODE
|
||||
is INDEXB_CODE
|
||||
is ADD_CODE // INDEXB_CODE
|
||||
op->opcode = ADDAB_CODE
|
||||
freeops = 1
|
||||
break
|
||||
@ -421,8 +416,7 @@ def crunch_seq(seq, pass)
|
||||
break // LAB_CODE
|
||||
is LAW_CODE
|
||||
when nextop->opcode
|
||||
is ADD_CODE
|
||||
is INDEXB_CODE
|
||||
is ADD_CODE // INDEXB_CODE
|
||||
op->opcode = ADDAW_CODE
|
||||
freeops = 1
|
||||
break
|
||||
|
@ -623,8 +623,6 @@ def keyin3
|
||||
key = keyctrlf; break
|
||||
is $80 | '\\'
|
||||
key = keydelete; break // Delete
|
||||
is keyenter
|
||||
key = keyctrlf; break
|
||||
//
|
||||
// Map OA+keypad
|
||||
//
|
||||
|
@ -829,7 +829,7 @@ t_opseq *parse_set(t_opseq *codeseq)
|
||||
int parse_stmnt(void)
|
||||
{
|
||||
int tag_prevbrk, tag_prevcnt, tag_else, tag_endif, tag_while, tag_wend, tag_repeat, tag_for, tag_choice, tag_of;
|
||||
int type, addr, step, cfnvals, prev_for, constsize, casecnt;
|
||||
int type, addr, step, cfnvals, prev_for, constsize, casecnt, i;
|
||||
int *caseval, *casetag;
|
||||
long constval;
|
||||
char *idptr;
|
||||
@ -1056,6 +1056,9 @@ int parse_stmnt(void)
|
||||
{
|
||||
constval = 0;
|
||||
parse_constexpr(&constval, &constsize);
|
||||
for (i = 0; i < casecnt; i++)
|
||||
if (caseval[i] == constval)
|
||||
parse_error("Duplicate CASE");
|
||||
tag_of = tag_new(BRANCH_TYPE);
|
||||
caseval[casecnt] = constval;
|
||||
casetag[casecnt] = tag_of;
|
||||
|
@ -598,10 +598,10 @@ def parse_set(codeseq)
|
||||
return codeseq
|
||||
end
|
||||
def parse_stmnt
|
||||
byte type, elem_type, elem_size, i, cfnvals, prev_for
|
||||
byte type, elem_type, elem_size, cfnvals, prev_for
|
||||
word seq, fromseq, toseq, tag_prevbrk, tag_prevcnt, tag_else, tag_endif, tag_while, tag_wend
|
||||
word tag_repeat, tag_for, tag_choice, tag_of, idptr, addr, stepdir
|
||||
word caseconst, casecnt, caseval, casetag
|
||||
word caseconst, casecnt, caseval, casetag, i
|
||||
|
||||
if token <> END_TKN and token <> DONE_TKN and token <> OF_TKN and token <> DEFAULT_TKN
|
||||
prevstmnt = token
|
||||
@ -794,8 +794,8 @@ def parse_stmnt
|
||||
tag_prevbrk = break_tag
|
||||
break_tag = new_tag(RELATIVE_FIXUP)
|
||||
tag_choice = new_tag(RELATIVE_FIXUP)
|
||||
caseval = heapalloc(512)
|
||||
casetag = heapalloc(512)
|
||||
caseval = heapalloc(CASENUM)
|
||||
casetag = heapalloc(CASENUM)
|
||||
casecnt = 0
|
||||
seq, cfnvals = parse_expr(NULL)
|
||||
if !seq; exit_err(ERR_INVAL|ERR_STATE); fin
|
||||
@ -809,7 +809,11 @@ def parse_stmnt
|
||||
while token <> ENDCASE_TKN
|
||||
when token
|
||||
is OF_TKN
|
||||
if casecnt == CASENUM; exit_err(ERR_OVER|ERR_TABLE); fin
|
||||
caseconst, drop, drop = parse_constexpr
|
||||
for i = 0 to casecnt-1
|
||||
if caseval=>[i] == caseconst; exit_err(ERR_DUP|ERR_STATE); fin
|
||||
next
|
||||
tag_of = new_tag(RELATIVE_FIXUP)
|
||||
caseval=>[casecnt] = caseconst
|
||||
casetag=>[casecnt] = tag_of
|
||||
|
@ -237,6 +237,7 @@ const FIXUPNUM = 2048
|
||||
const MODDEPNUM = 8
|
||||
const IDGLOBALSZ = 4096
|
||||
const IDLOCALSZ = 512
|
||||
const CASENUM = 64
|
||||
word fixup_cnt, tag_cnt = -1
|
||||
word fixup_tag, fixup_addr
|
||||
word tag_addr, tag_type
|
||||
|
Loading…
x
Reference in New Issue
Block a user