pike.git/
src/
program.c
Branch:
Tag:
Non-build tags
All tags
No tags
2018-11-06
2018-11-06 14:51:14 by Henrik Grubbström (Grubba) <grubba@grubba.org>
843d2ffb5117bf5c289979fea6ca78db685941df (
56
lines) (+
56
/-
0
)
[
Show
|
Annotate
]
Branch:
master
Compiler: First go at storing annotations.
1528:
#define RELOCATE_strings(ORIG,NEW) #define RELOCATE_inherits(ORIG,NEW) #define RELOCATE_identifiers(ORIG,NEW)
+
#define RELOCATE_annotations(ORIG,NEW)
#define RELOCATE_constants(ORIG,NEW) #define RELOCATE_relocations(ORIG,NEW)
1756:
#endif debug_add_to_identifiers(dummy);
+
if (Pike_compiler->current_annotations) {
+
compiler_add_annotations(n, Pike_compiler->current_annotations);
+
}
+
return n; }
3470:
if(p->strings[e]) free_string(p->strings[e]);
+
if (p->annotations) {
+
for (e = 0; e < p->num_annotations; e++) {
+
do_free_array(p->annotations[e]);
+
}
+
}
+
if(p->identifiers) { for(e=0; e<p->num_identifiers; e++)
3683:
Pike_compiler->last_file=0; }
+
if (Pike_compiler->current_annotations) {
+
free_node(Pike_compiler->current_annotations);
+
Pike_compiler->current_annotations = NULL;
+
}
+
if (Pike_compiler->current_attributes) { free_node(Pike_compiler->current_attributes); Pike_compiler->current_attributes = NULL;
4201:
} /**
+
* Add a single annotation for a symbol in the current program
+
* being compiled.
+
*
+
* @param id
+
* Identifier to annotate, -1 for the current program.
+
*
+
* @param val
+
* Annotation value. Should be an object implementing
+
* the Pike.Annotation interface.
+
*/
+
static void add_annotation(int id, struct svalue *val)
+
{
+
id += 1;
+
while (Pike_compiler->new_program->num_annotations <= id) {
+
add_to_annotations(NULL);
+
}
+
+
if (val) {
+
if (Pike_compiler->new_program->annotations[id]) {
+
Pike_compiler->new_program->annotations[id] =
+
append_array(Pike_compiler->new_program->annotations[id], val);
+
} else {
+
push_svalue(val);
+
Pike_compiler->new_program->annotations[id] = aggregate_array(1);
+
}
+
}
+
}
+
+
void compiler_add_annotations(int id, node *annotations)
+
{
+
while(annotations) {
+
node *val_node = CAR(annotations);
+
annotations = CDR(annotations);
+
if (val_node->token != F_CONSTANT) continue;
+
add_annotation(id, &val_node->u.sval);
+
}
+
}
+
+
/**
* End the current compilation pass. * * @param finish