From 0ffa008675f226db42ad1483fcebd25daf2b529b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net> Date: Tue, 13 Jan 1998 23:53:52 -0800 Subject: [PATCH] __INIT now handled more smoothly Rev: src/interpret.c:1.58 Rev: src/program.c:1.49 --- src/interpret.c | 4 ++-- src/program.c | 37 ++++++++++++++++++++++--------------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/interpret.c b/src/interpret.c index 73837899a2..8d076ff5f2 100644 --- a/src/interpret.c +++ b/src/interpret.c @@ -4,7 +4,7 @@ ||| See the files COPYING and DISCLAIMER for more information. \*/ #include "global.h" -RCSID("$Id: interpret.c,v 1.57 1998/01/13 22:56:43 hubbe Exp $"); +RCSID("$Id: interpret.c,v 1.58 1998/01/14 07:53:52 hubbe Exp $"); #include "interpret.h" #include "object.h" #include "program.h" @@ -1531,7 +1531,7 @@ void mega_apply(enum apply_type type, INT32 args, void *arg1, void *arg2) if(fun<0) { - pop_n_elems(args); + pop_n_elems(sp-save_sp); push_int(0); return; } diff --git a/src/program.c b/src/program.c index c4d2e1a18b..275188c71a 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.48 1998/01/13 22:56:49 hubbe Exp $"); +RCSID("$Id: program.c,v 1.49 1998/01/14 07:53:52 hubbe Exp $"); #include "program.h" #include "object.h" #include "dynamic_buffer.h" @@ -697,12 +697,33 @@ if((char *)(p->X) < (char *)p || (char *)(p->X)> ((char *)p)+size) fatal("Progra struct program *end_first_pass(int finish) { + int e; struct program *prog; + struct pike_string *s; + + MAKE_CONSTANT_SHARED_STRING(s,"__INIT"); + + + /* Collect references to inherited __INIT functions */ + for(e=1;e<new_program->num_inherits;e++) + { + int id; + if(new_program->inherits[e].inherit_level!=1) continue; + id=low_reference_inherited_identifier(e, s); + if(id!=-1) + { + init_node=mknode(F_ARG_LIST, + init_node, + mkcastnode(void_type_string, + mkapplynode(mkidentifiernode(id),0))); + } + } /* * Define the __INIT function, but only if there was any code * to initialize. */ + if(init_node) { union idptr tmp; @@ -965,20 +986,6 @@ void do_inherit(struct svalue *prog, fun.id_flags |= ID_INHERITED; add_to_identifier_references(fun); } - - /* Ska det h{r vara s} h{r? */ - s=findstring("__INIT"); - if(s) - { - if(-1 != find_shared_string_identifier(s,p)) - { - e=reference_inherited_identifier(0, s); - init_node=mknode(F_ARG_LIST, - init_node, - mkcastnode(void_type_string, - mkapplynode(mkidentifiernode(e),0))); - } - } } void simple_do_inherit(struct pike_string *s, -- GitLab