pike.git
/
src
/
program.c
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/program.c:3577:
Inside #if 0
#if 0 if(p->constants[e].name) free_string(p->constants[e].name); #endif /* 0 */ } } if(p->inherits) for(e=0; e<p->num_inherits; e++) { if (p->inherits[e].annotations)
-
free_
array
(p->inherits[e].annotations);
+
free_
multiset
(p->inherits[e].annotations);
if(p->inherits[e].name) free_string(p->inherits[e].name); if(e) { if(p->inherits[e].prog) free_program(p->inherits[e].prog); } if(p->inherits[e].parent) free_object(p->inherits[e].parent); }
pike.git/src/program.c:4350:
*/ static void add_program_annotation(int inh, struct svalue *val) { struct inherit *inherit = Pike_compiler->new_program->inherits + inh; if (inherit->inherit_level > 1) { Pike_fatal("Attempt to annotate inherit #%d at level %d!\n", inh, inherit->inherit_level); } if (val) { if (inherit->annotations) {
-
inherit->annotations = append
_
array
(inherit->annotations, val);
+
multiset
_
add
(inherit->annotations, val);
} else { push_svalue(val);
-
inherit->annotations =
aggregate
_
array(
1
)
;
+
f_aggregate_multiset(1);
+
inherit->annotations =
Pike
_
sp[-
1
].u.multiset
;
+
Pike_sp--;
} } } void compiler_add_program_annotations(int inh, node *annotations) { while(annotations) { node *val_node = CAR(annotations); annotations = CDR(annotations); if (val_node->token != F_CONSTANT) continue;
pike.git/src/program.c:4517:
OPT_SIDE_EFFECT|OPT_EXTERNAL_DEPEND); } } /* FIXME: Call end_pass() in annotations here? */ Pike_compiler->compiler_pass = COMPILER_PASS_LAST; } if (!Pike_compiler->num_parse_error) { prog = Pike_compiler->new_program;
+
/* NB: Need referenced msnodes! */
if (prog->inherits->annotations) {
-
struct
array
*
a
= prog->inherits->annotations;
-
for (
e
=
0
;
e
< a-
>
size
;
e++
) {
+
struct
multiset
*
l
= prog->inherits->annotations;
+
ptrdiff_t pos;
+
/* NB: multiset_first() adds an msnode_ref. */
+
for (
pos
=
multiset_first(l)
;
pos
>=
0
;
pos = multiset_next(l, pos
)
)
{
struct object *o; struct program *p; struct inherit *inh; int fun;
-
if (TYPEOF(
ITEM(a)
[
e
])
!
= PIKE_T_OBJECT)
continue;
-
o =
ITEM(a)
[
e
].u.object;
+
push_multiset_value(l, nodepos);
+
if (TYPEOF(
Pike_sp
[
-1
]) =
=
PIKE_T_OBJECT)
{
+
o =
Pike_sp
[
-1
].u.object;
p = o->prog;
-
if (
!
p)
continue;
-
inh = p->inherits + SUBTYPEOF(
ITEM(a)
[
e
]);
+
if (p)
{
+
inh = p->inherits + SUBTYPEOF(
Pike_sp
[
-1
]);
p = inh->prog; fun = find_identifier("end_pass", p);
-
if (fun
<
0)
continue;
+
if (fun
>=
0)
{
fun += inh->identifier_level; push_int(Pike_compiler->compiler_pass); ref_push_program(prog); ref_push_object_inherit(Pike_fp->current_object, Pike_fp->context - Pike_fp->current_program->inherits); safe_apply_low2(o, fun, 3, NULL); pop_stack(); } } }
-
+
pop_stack();
+
}
+
/* Remove the msnode_ref added by multiset_first(). */
+
sub_msnode_ref(l);
+
}
+
}
/* * Define the __INIT function, but only if there was any code * to initialize. */ if(Pike_compiler->init_node) { /* Inhibit this_function. */ Pike_compiler->compiler_frame->current_function_number = -2;
pike.git/src/program.c:5387:
inherit.parent=parent; inherit.parent_identifier=parent_identifier; inherit.parent_offset=INHERIT_PARENT; } }else{ inherit.parent_offset=parent_offset; inherit.parent_identifier=parent_identifier; } if (inherit.annotations) {
-
struct
array
*annotations;
-
int
e
;
-
int
found
_
inh
= 0;
-
inherit.annotations = annotations = copy_
array
(inherit.annotations);
-
for
(
e
=
0;
e
<
annotations
->
size;
e++
) {
-
if (TYPEOF(
ITEM(annotations)
[
e
]) == PIKE_T_OBJECT) {
+
struct
multiset
*annotations;
+
union
msnode *node = low_multiset_first(inherit.annotations->msd)
;
+
int
keep
_
annotations
= 0;
+
+
inherit.annotations = annotations = copy_
multiset
(inherit.annotations);
+
+
ref_push_object(Inherited_annotation);
+
+
while
(
node)
{
+
if (TYPEOF(node
->
i.ind)
!= T_DELETED
) {
+
low_push_multiset_index(node);
+
if (TYPEOF(
Pike_sp
[
-1
]) == PIKE_T_OBJECT) {
/* FIXME: Subtyped objects? */
-
struct object *ann =
ITEM(annotations)
[
e
].u.object;
+
struct object *ann =
Pike_sp
[
-1
].u.object;
if (ann->prog && ann->prog->inherits[0].annotations) { /* Check if it has the @Inherited annotation. */
-
struct
array
*
a
= ann->prog->inherits[0].annotations;
-
int
is_inherited
= 0;
-
int ee;
-
for (ee = 0; ee < a->size; ee++) {
-
if (
(TYPEOF(ITEM(a)[ee]) == PIKE
_
T_OBJECT) &&
-
(
ITEM(a)[ee].u.object
== Inherited
_
annotation
)) {
-
is_inherited = 1;
-
break;
-
}
-
}
-
if (is_inherited) {
-
found_inh++;
-
add_program_annotation(0,
&(ITEM(annotations
)
[e]))
;
+
struct
multiset
*
l
= ann->prog->inherits[0].annotations;
+
if (
multiset
_
lookup
(
l,
Pike
_
sp-2
)) {
+
add_program_annotation(0,
Pike_sp-1
);
-
/*
Switch
out the annotation with a placeholding marker
,
-
* so that we can perform the filtering (if any
)
-
*
more efficiently below.
-
*
-
* We use the Inherited
_
annotation object
-
* as the placeholding marker.
-
*/
-
add_ref(ITEM(
annotations
)[e].u.object
=
Inherited_annotation)
;
-
free_object(ann);
+
multiset_delete(annotations
,
Pike_sp-1
)
;
+
}
else
{
+
keep
_annotations =
1
;
}
-
+
} else {
+
keep_annotations = 1;
}
-
}
-
}
-
if (found_inh) {
-
if (found_inh == annotations->size) {
-
free_array(annotations);
-
inherit.annotations = NULL;
+
} else {
-
ref_push_object(Inherited_annotation);
-
inherit.
annotations =
-
subtract_array_svalue(annotations, Pike_sp - 1);
+
keep_
annotations =
1;
+
}
pop_stack();
-
free_array(annotations);
+
}
-
+
node = low_multiset_next(node);
}
-
+
if (!keep_annotations) {
+
free_multiset(annotations);
+
inherit.annotations = NULL;
}
-
+
pop_stack();
+
}
}else{ if(!inherit.parent) { if(parent && parent->next != parent && inherit.parent_offset) { struct object *par=parent; int e,pid=parent_identifier; for(e=1;e<inherit.parent_offset;e++) {
pike.git/src/program.c:7931:
push_undefined(); } for (i = 0; i < p->num_inherits; i++) { struct inherit *inh = p->inherits + i; if (inh->inherit_level > 0) { push_svalue(res + inh->inherit_level - 1); } else { push_undefined(); } if (inh->annotations) {
-
ref_push_
array
(inh->annotations);
-
f_mkmultiset(1);
+
ref_push_
multiset
(inh->annotations);
f_add(2); found = 1; } assign_svalue(res + inh->inherit_level, Pike_sp - 1); pop_stack(); } if (found) { return aggregate_array(Pike_sp - res); } pop_n_elems(Pike_sp - res);
pike.git/src/program.c:9018:
for(e = p->num_inherits - 1; e >= 0; e--) { if(p->inherits[e].parent) gc_mark_object_as_referenced(p->inherits[e].parent); if(e && p->inherits[e].prog) gc_mark_program_as_referenced(p->inherits[e].prog); if (p->inherits[e].annotations)
-
gc_mark_
array
_as_referenced(p->inherits[e].annotations);
+
gc_mark_
multiset
_as_referenced(p->inherits[e].annotations);
} #if defined (PIKE_DEBUG) || defined (DO_PIKE_CLEANUP) for (e = p->num_identifiers - 1; e >= 0; e--) gc_mark_type_as_referenced (p->identifiers[e].type); #endif for (e = p->num_annotations-1; e >= 0; e--) { if (p->annotations[e]) gc_mark_array_as_referenced(p->annotations[e]);
pike.git/src/program.c:9052:
for(e = p->num_inherits - 1; e >= 0; e--) { if(p->inherits[e].parent) gc_cycle_check_object(p->inherits[e].parent, 0); if(e && p->inherits[e].prog) gc_cycle_check_program(p->inherits[e].prog, 0); if (p->inherits[e].annotations)
-
gc_cycle_check_
array
(p->inherits[e].annotations, 0);
+
gc_cycle_check_
multiset
(p->inherits[e].annotations, 0);
} for (e = p->num_annotations - 1; e >= 0; e--) { if (p->annotations[e]) gc_cycle_check_array(p->annotations[e], 0); } /* Strong ref follows. It must be last. */ if(p->parent) gc_cycle_check_program(p->parent, 0);
pike.git/src/program.c:9226:
free_object(p->inherits[e].parent); p->inherits[e].parent=0; } if(e && p->inherits[e].prog) { free_program(p->inherits[e].prog); p->inherits[e].prog=0; } if (p->inherits[e].annotations) {
-
free_
array
(p->inherits[e].annotations);
+
free_
multiset
(p->inherits[e].annotations);
p->inherits[e].annotations = NULL; } } for (e = 0; e < p->num_annotations; e++) { do_free_array(p->annotations[e]); p->annotations[e] = NULL; } gc_free_extra_ref(p);