pike.git/
src/
docode.c
Branch:
Tag:
Non-build tags
All tags
No tags
1997-09-19
1997-09-19 06:45:32 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>
ba62cf75ae87d44e669cfcc5e1ce37d899216110 (
64
lines) (+
41
/-
23
)
[
Show
|
Annotate
]
Branch:
7.9
switch() hacked
Rev: src/docode.c:1.22
Rev: src/language.yacc:1.49
4:
||| See the files COPYING and DISCLAIMER for more information. \*/ #include "global.h"
-
RCSID("$Id: docode.c,v 1.
21
1997/09/
09
03
:
36
:
11
hubbe Exp $");
+
RCSID("$Id: docode.c,v 1.
22
1997/09/
19
06
:
45
:
31
hubbe Exp $");
#include "las.h" #include "program.h" #include "language.h"
802:
/* Check for cases inside a range */ for(e=0; e<cases-1; e++) {
-
if(
current_switch_jumptable[
order[e]
*2+2
]
!=
-1)
+
if(order[e]
<
cases
-1)
{
-
if(current_switch_jumptable[
order
[
e
]
*2+2
] !=
-
current_switch_jumptable[ order[
e+1
]
*2+1
])
+
int o1=order[e]+1;
+
if(current_switch_jumptable[
o1]==current_switch_jumptable
[
o1+1
]
&&
+
current_switch_jumptable[
o1]==current_switch_jumptable[o1+2])
+
{
+
if(
order[
e
]
+1
!= order[e+1
])
yyerror("Case inside range.");
-
+
e++;
} }
-
+
}
if(current_switch_default < 0) current_switch_default = ins_label(-1);
852:
{ yyerror("Case outside switch."); }else{
-
if(!is_const(
CAR(n
))
)
+
node *lower=CAR(n);
+
if(!
lower) lower=CDR(n);
+
+
if(!
is_const(
lower
))
yyerror("Case label isn't constant.");
-
tmp1=eval_low(
CAR(n
)
)
;
+
tmp1=eval_low(
lower
);
if(tmp1<1) { yyerror("Error in case label.");
872:
if(CDR(n)) {
+
current_switch_jumptable[current_switch_case]=
+
current_switch_jumptable[current_switch_case-1];
+
current_switch_case++;
+
+
if(CAR(n))
+
{
if(!is_const(CDR(n))) yyerror("Case label isn't constant.");
-
current_switch_jumptable[current_switch_case+1]=
+
current_switch_jumptable[current_switch_case]= current_switch_jumptable[current_switch_case-1];
-
current_switch_
case+=2
;
+
current_switch_
case++
;
+
tmp1=eval_low(CDR(n)); if(tmp1<1) {
891:
for(tmp1=current_switch_values_on_stack; tmp1 > 1; tmp1--) if(is_equal(sp-tmp1, sp-1)) yyerror("Duplicate case.");
+
current_switch_jumptable[current_switch_case++]=-1;
}
-
+
}else{
current_switch_jumptable[current_switch_case++]=-1; }
-
+
}
return 0; }