mirror of
https://github.com/dschmenk/PLASMA.git
synced 2025-04-14 20:37:30 +00:00
Order caseblock values in ascending order
This commit is contained in:
parent
bbbe2d0d38
commit
ec0fdde747
@ -761,7 +761,7 @@ t_opseq *parse_expr(t_opseq *codeseq, int *stackdepth)
|
||||
if (stackdepth1 != *stackdepth)
|
||||
parse_error("Inconsistent AND value counts");
|
||||
codeseq = gen_codetag(codeseq, tag_or);
|
||||
}
|
||||
}
|
||||
else if (scantoken == TERNARY_TOKEN)
|
||||
{
|
||||
int tag_else, tag_endtri;
|
||||
@ -1056,14 +1056,23 @@ int parse_stmnt(void)
|
||||
{
|
||||
if (scantoken == OF_TOKEN)
|
||||
{
|
||||
tag_of = tag_new(BRANCH_TYPE);
|
||||
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;
|
||||
i = casecnt;
|
||||
while ((i > 0) && (caseval[i-1] > constval))
|
||||
{
|
||||
//
|
||||
// Move larger case consts up
|
||||
//
|
||||
caseval[i] = caseval[i-1];
|
||||
casetag[i] = casetag[i-1];
|
||||
i--;
|
||||
}
|
||||
if (casecnt && (caseval[i] == constval))
|
||||
parse_error("Duplicate CASE");
|
||||
caseval[i] = constval;
|
||||
casetag[i] = tag_of;
|
||||
casecnt++;
|
||||
emit_codetag(tag_of);
|
||||
while (parse_stmnt()) next_line();
|
||||
@ -1124,7 +1133,7 @@ int parse_stmnt(void)
|
||||
if (infunc)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
i = stack_loop;
|
||||
while (i >= 2)
|
||||
{
|
||||
|
@ -811,12 +811,19 @@ def parse_stmnt
|
||||
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
|
||||
i = casecnt
|
||||
while i > 0 and caseval=>[i-1] > caseconst
|
||||
//
|
||||
// Move larger case consts up
|
||||
//
|
||||
caseval=>[i] = caseval=>[i-1]
|
||||
casetag=>[i] = casetag=>[i-1]
|
||||
i--
|
||||
loop
|
||||
if casecnt and caseval=>[i] == caseconst; exit_err(ERR_DUP|ERR_STATE); fin
|
||||
caseval=>[i] = caseconst
|
||||
casetag=>[i] = tag_of
|
||||
casecnt++
|
||||
emit_tag(tag_of)
|
||||
while parse_stmnt
|
||||
|
Loading…
x
Reference in New Issue
Block a user