mirror of
https://github.com/dschmenk/PLASMA.git
synced 2024-10-18 22:24:28 +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
|
if nextop=>opnext
|
||||||
nextopnext = nextop=>opnext
|
nextopnext = nextop=>opnext
|
||||||
when nextopnext->opcode
|
when nextopnext->opcode
|
||||||
is ADD_CODE
|
is ADD_CODE // INDEXB_CODE
|
||||||
is INDEXB_CODE
|
|
||||||
op=>opoffset = op=>opoffset + nextop=>opval
|
op=>opoffset = op=>opoffset + nextop=>opval
|
||||||
freeops = 2
|
freeops = 2
|
||||||
break
|
break
|
||||||
@ -322,8 +321,7 @@ def crunch_seq(seq, pass)
|
|||||||
if nextop=>opnext
|
if nextop=>opnext
|
||||||
nextopnext = nextop=>opnext
|
nextopnext = nextop=>opnext
|
||||||
when nextopnext->opcode
|
when nextopnext->opcode
|
||||||
is ADD_CODE
|
is ADD_CODE // INDEXB_CODE
|
||||||
is INDEXB_CODE
|
|
||||||
op=>opoffset = op=>opoffset + nextop=>opval
|
op=>opoffset = op=>opoffset + nextop=>opval
|
||||||
freeops = 2
|
freeops = 2
|
||||||
break
|
break
|
||||||
@ -361,8 +359,7 @@ def crunch_seq(seq, pass)
|
|||||||
break // GADDR_CODE
|
break // GADDR_CODE
|
||||||
is LLB_CODE
|
is LLB_CODE
|
||||||
when nextop->opcode
|
when nextop->opcode
|
||||||
is ADD_CODE
|
is ADD_CODE // INDEXB_CODE
|
||||||
is INDEXB_CODE
|
|
||||||
op->opcode = ADDLB_CODE
|
op->opcode = ADDLB_CODE
|
||||||
freeops = 1
|
freeops = 1
|
||||||
break
|
break
|
||||||
@ -377,8 +374,7 @@ def crunch_seq(seq, pass)
|
|||||||
break // LLB_CODE
|
break // LLB_CODE
|
||||||
is LLW_CODE
|
is LLW_CODE
|
||||||
when nextop->opcode
|
when nextop->opcode
|
||||||
is ADD_CODE
|
is ADD_CODE // INDEXB_CODE
|
||||||
is INDEXB_CODE
|
|
||||||
op->opcode = ADDLW_CODE
|
op->opcode = ADDLW_CODE
|
||||||
freeops = 1
|
freeops = 1
|
||||||
break
|
break
|
||||||
@ -405,8 +401,7 @@ def crunch_seq(seq, pass)
|
|||||||
break // LLW_CODE
|
break // LLW_CODE
|
||||||
is LAB_CODE
|
is LAB_CODE
|
||||||
when nextop->opcode
|
when nextop->opcode
|
||||||
is ADD_CODE
|
is ADD_CODE // INDEXB_CODE
|
||||||
is INDEXB_CODE
|
|
||||||
op->opcode = ADDAB_CODE
|
op->opcode = ADDAB_CODE
|
||||||
freeops = 1
|
freeops = 1
|
||||||
break
|
break
|
||||||
@ -421,8 +416,7 @@ def crunch_seq(seq, pass)
|
|||||||
break // LAB_CODE
|
break // LAB_CODE
|
||||||
is LAW_CODE
|
is LAW_CODE
|
||||||
when nextop->opcode
|
when nextop->opcode
|
||||||
is ADD_CODE
|
is ADD_CODE // INDEXB_CODE
|
||||||
is INDEXB_CODE
|
|
||||||
op->opcode = ADDAW_CODE
|
op->opcode = ADDAW_CODE
|
||||||
freeops = 1
|
freeops = 1
|
||||||
break
|
break
|
||||||
|
@ -623,8 +623,6 @@ def keyin3
|
|||||||
key = keyctrlf; break
|
key = keyctrlf; break
|
||||||
is $80 | '\\'
|
is $80 | '\\'
|
||||||
key = keydelete; break // Delete
|
key = keydelete; break // Delete
|
||||||
is keyenter
|
|
||||||
key = keyctrlf; break
|
|
||||||
//
|
//
|
||||||
// Map OA+keypad
|
// Map OA+keypad
|
||||||
//
|
//
|
||||||
|
@ -829,7 +829,7 @@ t_opseq *parse_set(t_opseq *codeseq)
|
|||||||
int parse_stmnt(void)
|
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 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;
|
int *caseval, *casetag;
|
||||||
long constval;
|
long constval;
|
||||||
char *idptr;
|
char *idptr;
|
||||||
@ -1056,6 +1056,9 @@ int parse_stmnt(void)
|
|||||||
{
|
{
|
||||||
constval = 0;
|
constval = 0;
|
||||||
parse_constexpr(&constval, &constsize);
|
parse_constexpr(&constval, &constsize);
|
||||||
|
for (i = 0; i < casecnt; i++)
|
||||||
|
if (caseval[i] == constval)
|
||||||
|
parse_error("Duplicate CASE");
|
||||||
tag_of = tag_new(BRANCH_TYPE);
|
tag_of = tag_new(BRANCH_TYPE);
|
||||||
caseval[casecnt] = constval;
|
caseval[casecnt] = constval;
|
||||||
casetag[casecnt] = tag_of;
|
casetag[casecnt] = tag_of;
|
||||||
|
@ -598,10 +598,10 @@ def parse_set(codeseq)
|
|||||||
return codeseq
|
return codeseq
|
||||||
end
|
end
|
||||||
def parse_stmnt
|
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 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 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
|
if token <> END_TKN and token <> DONE_TKN and token <> OF_TKN and token <> DEFAULT_TKN
|
||||||
prevstmnt = token
|
prevstmnt = token
|
||||||
@ -794,8 +794,8 @@ def parse_stmnt
|
|||||||
tag_prevbrk = break_tag
|
tag_prevbrk = break_tag
|
||||||
break_tag = new_tag(RELATIVE_FIXUP)
|
break_tag = new_tag(RELATIVE_FIXUP)
|
||||||
tag_choice = new_tag(RELATIVE_FIXUP)
|
tag_choice = new_tag(RELATIVE_FIXUP)
|
||||||
caseval = heapalloc(512)
|
caseval = heapalloc(CASENUM)
|
||||||
casetag = heapalloc(512)
|
casetag = heapalloc(CASENUM)
|
||||||
casecnt = 0
|
casecnt = 0
|
||||||
seq, cfnvals = parse_expr(NULL)
|
seq, cfnvals = parse_expr(NULL)
|
||||||
if !seq; exit_err(ERR_INVAL|ERR_STATE); fin
|
if !seq; exit_err(ERR_INVAL|ERR_STATE); fin
|
||||||
@ -809,7 +809,11 @@ def parse_stmnt
|
|||||||
while token <> ENDCASE_TKN
|
while token <> ENDCASE_TKN
|
||||||
when token
|
when token
|
||||||
is OF_TKN
|
is OF_TKN
|
||||||
|
if casecnt == CASENUM; exit_err(ERR_OVER|ERR_TABLE); fin
|
||||||
caseconst, drop, drop = parse_constexpr
|
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)
|
tag_of = new_tag(RELATIVE_FIXUP)
|
||||||
caseval=>[casecnt] = caseconst
|
caseval=>[casecnt] = caseconst
|
||||||
casetag=>[casecnt] = tag_of
|
casetag=>[casecnt] = tag_of
|
||||||
|
@ -237,6 +237,7 @@ const FIXUPNUM = 2048
|
|||||||
const MODDEPNUM = 8
|
const MODDEPNUM = 8
|
||||||
const IDGLOBALSZ = 4096
|
const IDGLOBALSZ = 4096
|
||||||
const IDLOCALSZ = 512
|
const IDLOCALSZ = 512
|
||||||
|
const CASENUM = 64
|
||||||
word fixup_cnt, tag_cnt = -1
|
word fixup_cnt, tag_cnt = -1
|
||||||
word fixup_tag, fixup_addr
|
word fixup_tag, fixup_addr
|
||||||
word tag_addr, tag_type
|
word tag_addr, tag_type
|
||||||
|
Loading…
Reference in New Issue
Block a user