diff --git a/src/program.c b/src/program.c index 4c208296b3f7c6336c9f9ea4cb7aa735cfdcef90..95c441369e7a80e0197869450e3bd28895d370dc 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.91 1998/05/15 19:01:38 grubba Exp $"); +RCSID("$Id: program.c,v 1.92 1998/05/25 15:22:23 grubba Exp $"); #include "program.h" #include "object.h" #include "dynamic_buffer.h" @@ -1992,6 +1992,57 @@ int store_constant(struct svalue *foo, int equal) return e; } +/* + * program examination functions available from Pike. + */ + +struct array *program_indices(struct program *p) +{ + int e; + int n = 0; + struct array *res; + for (e = p->num_identifier_references; e--; ) { + struct identifier *id; + if (p->identifier_references[e].id_flags & ID_HIDDEN) { + continue; + } + id = ID_FROM_INT(p, e); + if (IDENTIFIER_IS_CONSTANT(id->identifier_flags)) { + ref_push_string(ID_FROM_INT(p, e)->name); + n++; + } + } + f_aggregate(n); + res = sp[-1].u.array; + add_ref(res); + pop_stack(); + return(res); +} + +struct array *program_values(struct program *p) +{ + int e; + int n = 0; + struct array *res; + for(e = p->num_identifier_references; e--; ) { + struct identifier *id; + if (p->identifier_references[e].id_flags & ID_HIDDEN) { + continue; + } + id = ID_FROM_INT(p, e); + if (IDENTIFIER_IS_CONSTANT(id->identifier_flags)) { + struct program *p2 = PROG_FROM_INT(p, e); + push_svalue(p2->constants + id->func.offset); + n++; + } + } + f_aggregate(n); + res = sp[-1].u.array; + add_ref(res); + pop_stack(); + return(res); +} + /* * Line number support routines, now also tells what file we are in */