From 22edc2519e71f1171ac29fba9f864e6d796689ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net> Date: Thu, 29 Jan 1998 09:43:22 -0800 Subject: [PATCH] lambda() should now work as god intended again... Rev: src/language.yacc:1.58 Rev: src/program.c:1.60 --- src/language.yacc | 17 +++++++++++------ src/program.c | 17 ++++++++++++++--- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/language.yacc b/src/language.yacc index 21d480f46f..b5caf9c8a2 100644 --- a/src/language.yacc +++ b/src/language.yacc @@ -161,7 +161,7 @@ /* This is the grammar definition of Pike. */ #include "global.h" -RCSID("$Id: language.yacc,v 1.57 1998/01/29 06:02:29 hubbe Exp $"); +RCSID("$Id: language.yacc,v 1.58 1998/01/29 17:43:21 hubbe Exp $"); #ifdef HAVE_MEMORY_H #include <memory.h> #endif @@ -549,6 +549,7 @@ def: modifiers type_or_error optional_stars F_IDENTIFIER int e; if($10) { + int f; for(e=0; e<$7; e++) { if(!compiler_frame->variable[e].name || @@ -558,7 +559,7 @@ def: modifiers type_or_error optional_stars F_IDENTIFIER } } - dooptcode($4->u.sval.u.string, $10, $<n>9->u.sval.u.string, $1); + f=dooptcode($4->u.sval.u.string, $10, $<n>9->u.sval.u.string, $1); #ifdef DEBUG if(recoveries && sp-evaluator_stack < recoveries->sp) fatal("Stack error (underflow)\n"); @@ -918,13 +919,16 @@ lambda: F_LAMBDA type=pop_type(); - sprintf(buf,"__lambda_%ld",local_class_counter++); + sprintf(buf,"__lambda_%ld_%ld", + (long)new_program->id, + local_class_counter++); name=make_shared_string(buf); f=dooptcode(name, $4, type, - ID_PRIVATE); + ID_PRIVATE | ID_INLINE); + $$=mkidentifiernode(f); free_string(name); free_string(type); @@ -943,11 +947,12 @@ class: modifiers F_CLASS optional_identifier { struct pike_string *s; char buffer[42]; - sprintf(buffer,"__class_%ld",local_class_counter++); + sprintf(buffer,"__class_%ld_%ld",(long)new_program->id, + local_class_counter++); s=make_shared_string(buffer); $3=mkstrnode(s); free_string(s); - $1|=ID_PRIVATE; + $1|=ID_PRIVATE | ID_INLINE; } if(compiler_pass==1) { diff --git a/src/program.c b/src/program.c index ee30198258..c2dfb0eab5 100644 --- a/src/program.c +++ b/src/program.c @@ -4,7 +4,7 @@ ||| See the files COPYING and DISCLAIMER for more information. \*/ #include "global.h" -RCSID("$Id: program.c,v 1.59 1998/01/29 00:30:36 hubbe Exp $"); +RCSID("$Id: program.c,v 1.60 1998/01/29 17:43:22 hubbe Exp $"); #include "program.h" #include "object.h" #include "dynamic_buffer.h" @@ -1163,6 +1163,9 @@ int low_define_variable(struct pike_string *name, #ifdef DEBUG if(new_program->flags & (PROGRAM_FIXED | PROGRAM_OPTIMIZED)) fatal("Attempting to add variable to fixed program\n"); + + if(compiler_pass==2) + fatal("Internal error: Not allowed to add more identifiers during second compiler pass.\n"); #endif copy_shared_string(dummy.name, name); @@ -1243,7 +1246,7 @@ int define_variable(struct pike_string *name, if(PROG_FROM_INT(new_program, n) == new_program) my_yyerror("Variable '%s' defined twice.",name->str); - if(!(IDENTIFIERP(n)->id_flags & ID_INLINE)) + if(!(IDENTIFIERP(n)->id_flags & ID_INLINE) || compiler_pass!=1) { if(ID_FROM_INT(new_program, n)->type != type) my_yyerror("Illegal to redefine inherited variable with different type."); @@ -1331,6 +1334,9 @@ int add_constant(struct pike_string *name, #ifdef DEBUG if(new_program->flags & (PROGRAM_FIXED | PROGRAM_OPTIMIZED)) fatal("Attempting to add constant to fixed program\n"); + + if(compiler_pass==2) + fatal("Internal error: Not allowed to add more identifiers during second compiler pass.\n"); #endif copy_shared_string(dummy.name, name); @@ -1506,7 +1512,7 @@ INT32 define_function(struct pike_string *name, my_yyerror("Illegal to redefine 'nomask' function %s.",name->str); } - if(!(ref.id_flags & ID_INLINE)) + if(!(ref.id_flags & ID_INLINE) || compiler_pass!=1) { /* We modify the old definition if it is in this program */ if(ref.inherit_offset==0) @@ -1542,6 +1548,11 @@ INT32 define_function(struct pike_string *name, } } +#ifdef DEBUG + if(compiler_pass==2) + fatal("Internal error: Not allowed to add more identifiers during second compiler pass.\n"); +#endif + /* define a new function */ copy_shared_string(fun.name, name); -- GitLab