pike.git
/
src
/
docode.c
version
»
Context lines:
10
20
40
80
file
none
3
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.
60
1999
/
12
/
13
01
:
21
:
13
grubba Exp $");
+
RCSID("$Id: docode.c,v 1.
61
2000
/
01
/
04
00
:
17
:
00
grubba 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:28:
static int do_docode2(node *n,int flags); INT32 current_break=-1; INT32 current_continue=-1; static INT32 current_switch_case; static INT32 current_switch_default; static INT32 current_switch_values_on_stack; static INT32 *current_switch_jumptable =0;
+
static struct pike_string *current_switch_type = NULL;
void upd_int(int offset, INT32 tmp) { MEMCPY(new_program->program+offset, (char *)&tmp,sizeof(tmp)); } INT32 read_int(int offset) { return EXTRACT_INT(new_program->program+offset); }
pike.git/src/docode.c:822:
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;
+
struct pike_string *prev_switch_type = current_switch_type;
#ifdef PIKE_DEBUG struct svalue *save_sp=sp; #endif if(do_docode(CAR(n),0)!=1) fatal("Internal compiler error, time to panic\n");
-
+
if (!(CAR(n) && (current_switch_type = CAR(n)->type))) {
+
current_switch_type = mixed_type_string;
+
}
+
current_break=alloc_label(); cases=count_cases(CDR(n)); tmp1=emit(F_SWITCH,0); emit(F_ALIGN,sizeof(INT32)); current_switch_values_on_stack=0; current_switch_case=1; current_switch_default=-1;
pike.git/src/docode.c:900:
update_arg(tmp1, store_constant(sp-1,1,0)); pop_stack(); free((char *)jumptable); 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 ;
+
current_switch_values_on_stack = prev_switch_values_on_stack
;
+
current_switch_type = prev_switch_type
;
emit(F_LABEL, current_break); current_break=break_save; #ifdef PIKE_DEBUG if(recoveries && sp-evaluator_stack < recoveries->sp) fatal("Stack error after F_SWITCH (underflow)\n"); #endif return 0; }
pike.git/src/docode.c:924:
if(!current_switch_jumptable) { yyerror("Case outside switch."); }else{ node *lower=CAR(n); if(!lower) lower=CDR(n); if(!is_const(lower)) yyerror("Case label isn't constant.");
+
if (lower && lower->type) {
+
if (!pike_types_le(lower->type, current_switch_type)) {
+
if (!match_types(lower->type, current_switch_type)) {
+
yytype_error("Type mismatch in case.",
+
current_switch_type, lower->type, 0);
+
} else if (lex.pragmas & ID_STRICT_TYPES) {
+
yytype_error("Type mismatch in case.",
+
current_switch_type, lower->type, YYTE_IS_WARNING);
+
}
+
}
+
}
+
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--)