pike.git/
src/
program.c
Branch:
Tag:
Non-build tags
All tags
No tags
1998-05-25
1998-05-25 15:22:23 by Henrik Grubbström (Grubba) <grubba@grubba.org>
a36d82e45758c7321a662ceeb3dde5dac6f477b2 (
54
lines) (+
53
/-
1
)
[
Show
|
Annotate
]
Branch:
7.9
Added support program_indices() and program_values().
Rev: src/program.c:1.92
4:
||| 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"
1993:
} /*
+
* 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 */ static int get_small_number(char **q)