From 14bb598e8ee57bf016546ace2016a972bce9a9a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net> Date: Sat, 6 May 2000 17:39:52 -0700 Subject: [PATCH] allow one cyclic recursion when resolving identifiers Rev: lib/master.pike.in:1.117 Rev: src/builtin_functions.c:1.273 Rev: src/cyclic.c:1.4 Rev: src/las.c:1.177 Rev: src/opcodes.c:1.75 Rev: src/program.c:1.236 --- lib/master.pike.in | 18 +++++++++++++----- src/builtin_functions.c | 4 ++-- src/cyclic.c | 12 +++++++++--- src/las.c | 10 ++++++---- src/opcodes.c | 8 ++++---- src/program.c | 4 ++-- 6 files changed, 36 insertions(+), 20 deletions(-) diff --git a/lib/master.pike.in b/lib/master.pike.in index 7cd0de1d39..f45c64ea3d 100644 --- a/lib/master.pike.in +++ b/lib/master.pike.in @@ -1,6 +1,6 @@ /* -*- Pike -*- * - * $Id: master.pike.in,v 1.116 2000/04/13 18:54:16 per Exp $ + * $Id: master.pike.in,v 1.117 2000/05/07 00:39:52 hubbe Exp $ * * Master-file for Pike. * @@ -589,17 +589,25 @@ object cast_to_object(string oname, string current_file) class dirnode { string dirname; - mixed module; + mixed module=module_checker(); mapping(string:mixed) cache=([]); array(string) files; void create(string name) { dirname=name; + } - if(module=findmodule(dirname+"/module")) - if(mixed tmp=module->_module_value) - module=tmp; + class module_checker + { + int `!() + { + module=0; + if(module=findmodule(dirname+"/module")) + if(mixed tmp=module->_module_value) + module=tmp; + return !module; + } } static mixed ind(string index) diff --git a/src/builtin_functions.c b/src/builtin_functions.c index 2f0fc1d544..d72bb411f1 100644 --- a/src/builtin_functions.c +++ b/src/builtin_functions.c @@ -5,7 +5,7 @@ \*/ /**/ #include "global.h" -RCSID("$Id: builtin_functions.c,v 1.272 2000/05/05 07:55:19 hubbe Exp $"); +RCSID("$Id: builtin_functions.c,v 1.273 2000/05/07 00:39:17 hubbe Exp $"); #include "interpret.h" #include "svalue.h" #include "pike_macros.h" @@ -2748,12 +2748,12 @@ void f_column(INT32 args) for(e=0;e<a->size;e++) index_no_free(ITEM(a)+e, ITEM(tmp)+e, val); - END_CYCLIC(); sp--; dmalloc_touch_svalue(sp); pop_n_elems(args); push_array(a); } + END_CYCLIC(); } #ifdef PIKE_DEBUG diff --git a/src/cyclic.c b/src/cyclic.c index 62e87a83ac..14bf52d561 100644 --- a/src/cyclic.c +++ b/src/cyclic.c @@ -1,7 +1,7 @@ #include "global.h" #include "cyclic.h" -RCSID("$Id: cyclic.c,v 1.3 1998/03/28 15:35:34 grubba Exp $"); +RCSID("$Id: cyclic.c,v 1.4 2000/05/07 00:39:17 hubbe Exp $"); #define CYCLIC_HASH_SIZE 4711 @@ -45,6 +45,7 @@ void *begin_cyclic(CYCLIC *c, void *b) { unsigned int h; + void *ret=0; CYCLIC *p; h=(int)id; @@ -58,8 +59,13 @@ void *begin_cyclic(CYCLIC *c, h%=CYCLIC_HASH_SIZE; for(p=cyclic_hash[h];p;p=p->next) + { if(a == p->a && b==p->b && id==p->id) - return p->ret; + { + ret=p->ret; + break; + } + } c->ret=(void *)1; c->a=a; @@ -69,5 +75,5 @@ void *begin_cyclic(CYCLIC *c, c->next=cyclic_hash[h]; cyclic_hash[h]=c; SET_ONERROR(c->onerr, low_unlink_cyclic, c); - return 0; + return ret; } diff --git a/src/las.c b/src/las.c index c5e13b16ff..464ba3c42e 100644 --- a/src/las.c +++ b/src/las.c @@ -5,7 +5,7 @@ \*/ /**/ #include "global.h" -RCSID("$Id: las.c,v 1.176 2000/05/01 02:11:25 hubbe Exp $"); +RCSID("$Id: las.c,v 1.177 2000/05/07 00:39:17 hubbe Exp $"); #include "language.h" #include "interpret.h" @@ -1230,14 +1230,16 @@ node *index_node(node *n, char *node_name, struct pike_string *id) default: { + int c; DECLARE_CYCLIC(); - if(BEGIN_CYCLIC(sp[-1].u.refs, id)) + c=(int)BEGIN_CYCLIC(sp[-1].u.refs, id); + if(c>1) { my_yyerror("Recursive module dependency in '%s'.",id->str); pop_stack(); push_int(0); }else{ - SET_CYCLIC_RET(1); + SET_CYCLIC_RET(c+1); ref_push_string(id); { struct svalue *save_sp = sp-2; @@ -1271,8 +1273,8 @@ node *index_node(node *n, char *node_name, struct pike_string *id) my_yyerror("Index '%s' not present in module.", id->str); } } - END_CYCLIC(); } + END_CYCLIC(); } } } diff --git a/src/opcodes.c b/src/opcodes.c index a933be50a2..d601094584 100644 --- a/src/opcodes.c +++ b/src/opcodes.c @@ -26,7 +26,7 @@ #include "bignum.h" #include "operators.h" -RCSID("$Id: opcodes.c,v 1.74 2000/04/20 02:41:45 hubbe Exp $"); +RCSID("$Id: opcodes.c,v 1.75 2000/05/07 00:39:17 hubbe Exp $"); void index_no_free(struct svalue *to,struct svalue *what,struct svalue *ind) { @@ -502,8 +502,8 @@ void o_cast(struct pike_string *type, INT32 run_time_type) if(save_sp!=sp) fatal("o_cast left stack droppings.\n"); #endif - END_CYCLIC(); } + END_CYCLIC(); assign_svalue(sp-3,sp-1); pop_stack(); } @@ -550,8 +550,8 @@ void o_cast(struct pike_string *type, INT32 run_time_type) fatal("o_cast left stack droppings.\n"); #endif order_multiset(m); - END_CYCLIC(); } + END_CYCLIC(); assign_svalue(sp-3,sp-1); pop_stack(); } @@ -604,8 +604,8 @@ void o_cast(struct pike_string *type, INT32 run_time_type) if(save_sp!=sp) fatal("o_cast left stack droppings.\n"); #endif - END_CYCLIC(); } + END_CYCLIC(); assign_svalue(sp-4,sp-1); pop_stack(); } diff --git a/src/program.c b/src/program.c index 1806d40a8a..53a68da267 100644 --- a/src/program.c +++ b/src/program.c @@ -5,7 +5,7 @@ \*/ /**/ #include "global.h" -RCSID("$Id: program.c,v 1.235 2000/05/01 02:11:25 hubbe Exp $"); +RCSID("$Id: program.c,v 1.236 2000/05/07 00:39:17 hubbe Exp $"); #include "program.h" #include "object.h" #include "dynamic_buffer.h" @@ -451,8 +451,8 @@ struct node_s *find_module_identifier(struct pike_string *ident, } } pop_stack(); - END_CYCLIC(); } + END_CYCLIC(); if(ret) return ret; } -- GitLab