pike.git/src/docode.c:1:
/*\
||| This file a part of Pike, and is copyright by Fredrik Hubinette
||| Pike is distributed as GPL (General Public License)
||| 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"
#include "pike_types.h"
#include "stralloc.h"
#include "interpret.h"
#include "constants.h"
#include "array.h"
#include "pike_macros.h"
#include "error.h"
pike.git/src/docode.c:795: Inside #if defined(DEBUG)
if(sp-save_sp != cases)
fatal("Count cases is wrong!\n");
#endif
f_aggregate(cases);
order=get_switch_order(sp[-1].u.array);
/* 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);
for(e=0;e<cases*2+1;e++)
if(current_switch_jumptable[e]==-1)
current_switch_jumptable[e]=current_switch_default;
sp[-1].u.array=order_array(sp[-1].u.array,order);
pike.git/src/docode.c:845:
#endif
return 0;
}
case F_CASE:
{
if(!current_switch_jumptable)
{
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.");
push_int(0);
tmp1=1;
}
pop_n_elems(tmp1-1);
current_switch_values_on_stack++;
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++]=ins_label(-1);
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)
{
yyerror("Error in second half of case label.");
push_int(0);
tmp1=1;
}
pop_n_elems(tmp1-1);
current_switch_values_on_stack++;
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;
}
case F_DEFAULT:
if(!current_switch_jumptable)
{
yyerror("Default outside switch.");
}else if(current_switch_default!=-1){
yyerror("Duplicate switch default.");
}else{