diff --git a/src/builtin_functions.c b/src/builtin_functions.c index 792c9db08996410666cc8a5572643027a9b5e304..6dee7fb32669ce04b3f98409375ec02c5fb88972 100644 --- a/src/builtin_functions.c +++ b/src/builtin_functions.c @@ -2,11 +2,11 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: builtin_functions.c,v 1.448 2002/10/15 14:57:29 grubba Exp $ +|| $Id: builtin_functions.c,v 1.449 2002/10/25 13:13:57 marcus Exp $ */ #include "global.h" -RCSID("$Id: builtin_functions.c,v 1.448 2002/10/15 14:57:29 grubba Exp $"); +RCSID("$Id: builtin_functions.c,v 1.449 2002/10/25 13:13:57 marcus Exp $"); #include "interpret.h" #include "svalue.h" #include "pike_macros.h" @@ -3115,8 +3115,8 @@ node *optimize_replace(node *n) INT16 lfun; struct object *replace_obj; node *ret = NULL; - INT32 args = eval_low(*arg1); /* NOTE: Addition splitted to ensure */ - args += eval_low(*arg2); /* correct evaluation order. */ + INT32 args = eval_low(*arg1,1); /* NOTE: Addition splitted to ensure */ + args += eval_low(*arg2,1); /* correct evaluation order. */ replace_obj = clone_object(multi_string_replace_program, args); diff --git a/src/docode.c b/src/docode.c index 093f527807b81952c03b1f63894f1dd73d7769a3..ea3546b1df7394eda25ee10df2b06180ffaa354f 100644 --- a/src/docode.c +++ b/src/docode.c @@ -2,11 +2,11 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: docode.c,v 1.150 2002/10/11 01:39:30 nilsson Exp $ +|| $Id: docode.c,v 1.151 2002/10/25 13:13:57 marcus Exp $ */ #include "global.h" -RCSID("$Id: docode.c,v 1.150 2002/10/11 01:39:30 nilsson Exp $"); +RCSID("$Id: docode.c,v 1.151 2002/10/25 13:13:57 marcus Exp $"); #include "las.h" #include "program.h" #include "pike_types.h" @@ -1715,7 +1715,7 @@ static int do_docode2(node *n, INT16 flags) } if (!Pike_compiler->num_parse_error) { - tmp1=eval_low(case_val); + tmp1=eval_low(case_val,1); if(tmp1<1) { yyerror("Error in case label."); diff --git a/src/language.yacc b/src/language.yacc index 959825e5e119f6d4e0b9f4e6e5f9a3f015927c19..8a94937162d7107b18468c79c1fb678335771634 100644 --- a/src/language.yacc +++ b/src/language.yacc @@ -2,7 +2,7 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: language.yacc,v 1.302 2002/10/12 11:54:30 grubba Exp $ +|| $Id: language.yacc,v 1.303 2002/10/25 13:13:57 marcus Exp $ */ %pure_parser @@ -113,7 +113,7 @@ /* This is the grammar definition of Pike. */ #include "global.h" -RCSID("$Id: language.yacc,v 1.302 2002/10/12 11:54:30 grubba Exp $"); +RCSID("$Id: language.yacc,v 1.303 2002/10/25 13:13:57 marcus Exp $"); #ifdef HAVE_MEMORY_H #include <memory.h> #endif @@ -546,7 +546,7 @@ constant_name: TOK_IDENTIFIER '=' safe_expr0 } else { if(!Pike_compiler->num_parse_error) { - ptrdiff_t tmp=eval_low($3); + ptrdiff_t tmp=eval_low($3,1); if(tmp < 1) { yyerror("Error in constant definition."); @@ -1725,7 +1725,7 @@ local_constant_name: TOK_IDENTIFIER '=' safe_expr0 if(Pike_compiler->compiler_pass==2) yyerror("Constant definition is not constant."); }else{ - ptrdiff_t tmp=eval_low($3); + ptrdiff_t tmp=eval_low($3,1); if(tmp < 1) { yyerror("Error in constant definition."); @@ -2526,7 +2526,7 @@ enum_value: /* EMPTY */ } else { if(!Pike_compiler->num_parse_error) { - ptrdiff_t tmp=eval_low($2); + ptrdiff_t tmp=eval_low($2,1); if(tmp < 1) { yyerror("Error in enum definition."); diff --git a/src/las.c b/src/las.c index f89042cf1f011125badf84d99708335e4d39b179..4359b0071db1406bf032afd72527928d93886aee 100644 --- a/src/las.c +++ b/src/las.c @@ -2,11 +2,11 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: las.c,v 1.305 2002/10/21 09:13:17 grubba Exp $ +|| $Id: las.c,v 1.306 2002/10/25 13:13:57 marcus Exp $ */ #include "global.h" -RCSID("$Id: las.c,v 1.305 2002/10/21 09:13:17 grubba Exp $"); +RCSID("$Id: las.c,v 1.306 2002/10/25 13:13:57 marcus Exp $"); #include "language.h" #include "interpret.h" @@ -1607,7 +1607,7 @@ void resolv_constant(node *n) char fnord[1000]; if(is_const(n)) { - ptrdiff_t args=eval_low(n); + ptrdiff_t args=eval_low(n,1); if(args==1) return; if(args!=-1) @@ -5282,7 +5282,7 @@ static void check_evaluation_time(struct callback *cb,void *tmp,void *ignored) } } -ptrdiff_t eval_low(node *n) +ptrdiff_t eval_low(node *n,int print_error) { unsigned INT16 num_strings, num_constants; INT32 jump; @@ -5337,31 +5337,31 @@ ptrdiff_t eval_low(node *n) if(apply_low_safe_and_stupid(Pike_compiler->fake_object, jump)) { -#if 0 - /* Generate error message */ - if(!Pike_compiler->catch_level) - { - struct svalue thrown = throw_value; - throw_value.type = T_INT; - yyerror("Error evaluating constant.\n"); - push_svalue(&thrown); - low_safe_apply_handler("compile_exception", - error_handler, compat_handler, 1); - if (SAFE_IS_ZERO(Pike_sp-1)) yy_describe_exception(&thrown); - pop_stack(); - free_svalue(&thrown); - } + if(print_error) + /* Generate error message */ + if(!Pike_compiler->catch_level) + { + struct svalue thrown = throw_value; + throw_value.type = T_INT; + yyerror("Error evaluating constant.\n"); + push_svalue(&thrown); + low_safe_apply_handler("compile_exception", + error_handler, compat_handler, 1); + if (SAFE_IS_ZERO(Pike_sp-1)) yy_describe_exception(&thrown); + pop_stack(); + free_svalue(&thrown); + } + else { + free_svalue(&throw_value); + throw_value.type = T_INT; + } else { free_svalue(&throw_value); throw_value.type = T_INT; + /* Assume the node will throw errors at runtime too. */ + n->tree_info |= OPT_SIDE_EFFECT; + n->node_info |= OPT_SIDE_EFFECT; } -#else /* !0 */ - free_svalue(&throw_value); - throw_value.type = T_INT; - /* Assume the node will throw errors at runtime too. */ - n->tree_info |= OPT_SIDE_EFFECT; - n->node_info |= OPT_SIDE_EFFECT; -#endif /* 0 */ }else{ if(foo.yes) pop_n_elems(Pike_sp-save_sp); @@ -5408,7 +5408,7 @@ static node *eval(node *n) if(!is_const(n) || n->token==':') return n; - args=eval_low(n); + args=eval_low(n,0); switch(args) { diff --git a/src/las.h b/src/las.h index 0a49ea7580ce15e148c6ca7c448368a801aede62..8eb4e4841266bfc57cf80402a76dcb72289ee271 100644 --- a/src/las.h +++ b/src/las.h @@ -2,7 +2,7 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: las.h,v 1.58 2002/10/11 01:39:32 nilsson Exp $ +|| $Id: las.h,v 1.59 2002/10/25 13:13:57 marcus Exp $ */ #ifndef LAS_H @@ -165,7 +165,7 @@ void print_tree(node *n); struct used_vars; void fix_type_field(node *n); struct timer_oflo; -ptrdiff_t eval_low(node *n); +ptrdiff_t eval_low(node *n,int print_error); int dooptcode(struct pike_string *name, node *n, struct pike_type *type,