pike.git / src / docode.c

version» Context lines:

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.18 1997/06/19 20:59:44 hubbe Exp $"); + RCSID("$Id: docode.c,v 1.19 1997/08/03 09:54:43 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:754:       case F_SWITCH:    {    INT32 e,cases,*order;    INT32 *jumptable;    INT32 prev_switch_values_on_stack = current_switch_values_on_stack;    INT32 prev_switch_case = current_switch_case;    INT32 prev_switch_default = current_switch_default;    INT32 *prev_switch_jumptable = current_switch_jumptable;    INT32 break_save = current_break; + #ifdef DEBUG +  struct svalue *save_sp=sp; + #endif       if(do_docode(CAR(n),0)!=1)    fatal("Internal compiler error, time to panic\n");       current_break=alloc_label();       cases=count_cases(CDR(n));       tmp1=emit(F_SWITCH,0);    emit(F_ALIGN,sizeof(INT32));
pike.git/src/docode.c:781:    for(e=0; e<cases*2+1; e++)    {    jumptable[e]=emit(F_POINTER, 0);    current_switch_jumptable[e]=-1;    }       current_switch_jumptable[current_switch_case++]=-1;       DO_CODE_BLOCK(CDR(n));    + #ifdef 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(current_switch_jumptable[ order[e]*2+2 ] !=    current_switch_jumptable[ order[e+1]*2+1 ])
pike.git/src/docode.c:824:    free((char *)current_switch_jumptable);       current_switch_jumptable = prev_switch_jumptable;    current_switch_default = prev_switch_default;    current_switch_case = prev_switch_case;    current_switch_values_on_stack = prev_switch_values_on_stack ;       emit(F_LABEL, current_break);       current_break=break_save; + #ifdef DEBUG +  if(recoveries && sp-evaluator_stack < recoveries->sp) +  fatal("Stack error after F_SWITCH (underflow)\n"); + #endif    return 0;    }       case F_CASE:    {    if(!current_switch_jumptable)    {    yyerror("Case outside switch.");    }else{    if(!is_const(CAR(n)))    yyerror("Case label isn't constant.");       tmp1=eval_low(CAR(n));    if(tmp1<1)    {    yyerror("Error in case label."); -  return 0; +  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))
pike.git/src/docode.c:862:    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;    tmp1=eval_low(CDR(n));    if(tmp1<1)    { -  pop_stack(); -  yyerror("Error in case label."); -  return 0; +  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;    }    return 0;