From c0e446a857fa15f042838fbf0f818dc9471e4502 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net> Date: Tue, 23 Jun 1998 21:56:46 -0700 Subject: [PATCH] bugfix in :: Rev: src/program.c:1.95 Rev: src/program.h:1.44 Rev: src/testsuite.in:1.116 --- src/program.c | 78 +++++++++++++++++++++++++++++------------------- src/program.h | 5 +++- src/testsuite.in | 28 ++++++++++++++++- 3 files changed, 78 insertions(+), 33 deletions(-) diff --git a/src/program.c b/src/program.c index 1bc0429092..fd07cf4eed 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.94 1998/05/25 19:00:37 grubba Exp $"); +RCSID("$Id: program.c,v 1.95 1998/06/24 04:56:46 hubbe Exp $"); #include "program.h" #include "object.h" #include "dynamic_buffer.h" @@ -1037,7 +1037,11 @@ int low_reference_inherited_identifier(struct program_state *q, p=np->inherits[e].prog; i=find_shared_string_identifier(name,p); - if(i==-1) return i; + if(i==-1) + { + i=really_low_find_shared_string_identifier(name,p,1); + if(i==-1) return -1; + } if(p->identifier_references[i].id_flags & ID_HIDDEN) return -1; @@ -1839,6 +1843,46 @@ INT32 define_function(struct pike_string *name, } +int really_low_find_shared_string_identifier(struct pike_string *name, + struct program *prog, + int see_static) +{ + struct reference *funp; + struct identifier *fun; + int i,t; + for(i=0;i<(int)prog->num_identifier_references;i++) + { + funp = prog->identifier_references + i; + if(funp->id_flags & ID_HIDDEN) continue; + if(funp->id_flags & ID_HIDDEN) + if(!see_static) + continue; + fun = ID_FROM_PTR(prog, funp); + /* if(fun->func.offset == -1) continue; * Prototype */ + if(!is_same_string(fun->name,name)) continue; + if(funp->id_flags & ID_INHERITED) + { + if(funp->id_flags & ID_PRIVATE) continue; + for(t=0; t>=0 && t<(int)prog->num_identifier_references; t++) + { + struct reference *funpb; + struct identifier *funb; + + if(t==i) continue; + funpb=prog->identifier_references+t; + if(funpb->id_flags & (ID_HIDDEN|ID_STATIC)) continue; + if((funpb->id_flags & ID_INHERITED) && t<i) continue; + funb=ID_FROM_PTR(prog,funpb); + /* if(funb->func.offset == -1) continue; * prototype */ + if(fun->name==funb->name) t=-10; + } + if(t < 0) continue; + } + return i; + } + return -1; +} + /* * lookup the number of a function in a program given the name in * a shared_string @@ -1847,7 +1891,6 @@ int low_find_shared_string_identifier(struct pike_string *name, struct program *prog) { int max,min,tst; - struct reference *funp; struct identifier *fun; if(prog->flags & PROGRAM_FIXED) @@ -1872,34 +1915,7 @@ int low_find_shared_string_identifier(struct pike_string *name, min=tst+1; } }else{ - int i,t; - for(i=0;i<(int)prog->num_identifier_references;i++) - { - funp = prog->identifier_references + i; - if(funp->id_flags & ID_HIDDEN) continue; - fun = ID_FROM_PTR(prog, funp); - /* if(fun->func.offset == -1) continue; * Prototype */ - if(!is_same_string(fun->name,name)) continue; - if(funp->id_flags & ID_INHERITED) - { - if(funp->id_flags & ID_PRIVATE) continue; - for(t=0; t>=0 && t<(int)prog->num_identifier_references; t++) - { - struct reference *funpb; - struct identifier *funb; - - if(t==i) continue; - funpb=prog->identifier_references+t; - if(funpb->id_flags & (ID_HIDDEN|ID_STATIC)) continue; - if((funpb->id_flags & ID_INHERITED) && t<i) continue; - funb=ID_FROM_PTR(prog,funpb); - /* if(funb->func.offset == -1) continue; * prototype */ - if(fun->name==funb->name) t=-10; - } - if(t < 0) continue; - } - return i; - } + return really_low_find_shared_string_identifier(name,prog,0); } return -1; } diff --git a/src/program.h b/src/program.h index 825519a10e..7025dfefa2 100644 --- a/src/program.h +++ b/src/program.h @@ -5,7 +5,7 @@ \*/ /* - * $Id: program.h,v 1.43 1998/05/25 16:40:26 grubba Exp $ + * $Id: program.h,v 1.44 1998/06/24 04:56:46 hubbe Exp $ */ #ifndef PROGRAM_H #define PROGRAM_H @@ -335,6 +335,9 @@ INT32 define_function(struct pike_string *name, INT16 flags, INT8 function_flags, union idptr *func); +int really_low_find_shared_string_identifier(struct pike_string *name, + struct program *prog, + int see_static); int low_find_shared_string_identifier(struct pike_string *name, struct program *prog); struct ff_hash; diff --git a/src/testsuite.in b/src/testsuite.in index a1d2c47548..9d1edd693a 100644 --- a/src/testsuite.in +++ b/src/testsuite.in @@ -1,4 +1,4 @@ -stest_true([["$Id: testsuite.in,v 1.115 1998/05/25 20:48:03 marcus Exp $"]]) +stest_true([["$Id: testsuite.in,v 1.116 1998/06/24 04:56:46 hubbe Exp $"]]) cond([[all_constants()->_verify_internals]], [[ test_do(_verify_internals()) @@ -142,6 +142,32 @@ test_eq([[ "\007" & "\023"]],"\003") test_eq([[ "\007" | "\023"]],"\027") test_eq([[ "\007" ^ "\023"]],"\024") +test_compile_any([[ + class X { void hej() {} } + class Y { inherit X:banan; void hopp() { banan::hej(); } } +]]) + +test_compile_any([[ + class X { static void hej() {} } + class Y { inherit X:banan; void hopp() { ::hej(); } } +]]) + +test_compile_any([[ + class X { static void hej() {} } + class Y { inherit X; void hopp() { X::hej(); } } +]]) + +test_compile_any([[ + class X { static void hej() {} } + class Y { public inherit X:banan; void hopp() { banan::hej(); } } +]]) + +test_compile_any([[ + class X { static void hej() {} } + class Y { inherit X:banan; void hopp() { banan::hej(); } } +]]) + + // Testing the 'inline' keyword test_program([[class foo { inline int c() { return time(); } int d() { return c(); } }; class bar { inherit foo; int c() { return 0; } } int a() { return bar()->d(); }]],0) -- GitLab