Skip to content

Commit

Permalink
Add ability to set Sub's PObj flags in init_pmc. Also add method to f…
Browse files Browse the repository at this point in the history
…etch them for testing purposes

git-svn-id: https://svn.parrot.org/parrot/trunk@47950 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information
bacek committed Jul 1, 2010
1 parent 6aed0cf commit 661b296
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions src/pmc/sub.pmc
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,19 @@ surboutine is fully constructed but not attached to interpreter.

/* comp_flags is actually UINTVAL */
field = CONST_STRING(INTERP, "comp_flags");
if (VTABLE_exists_keyed_str(INTERP, init, field))
attrs->comp_flags = (UINTVAL)VTABLE_get_integer_keyed_str(INTERP, init, field);
if (VTABLE_exists_keyed_str(INTERP, init, field)) {
UINTVAL flags = (UINTVAL)VTABLE_get_integer_keyed_str(INTERP, init, field);
/* Mask comp flags only */
attrs->comp_flags = flags & SUB_COMP_FLAG_MASK;
}

/* In order to create Sub dynamicaly we have to set PObj flags */
field = CONST_STRING(INTERP, "pf_flags");
if (VTABLE_exists_keyed_str(INTERP, init, field)) {
UINTVAL flags = (UINTVAL)VTABLE_get_integer_keyed_str(INTERP, init, field);
/* Mask Sub specific flags only */
PObj_get_FLAGS(SELF) |= flags & SUB_FLAG_PF_MASK;
}

field = CONST_STRING(INTERP, "n_regs_used");
if (VTABLE_exists_keyed_str(INTERP, init, field)) {
Expand Down Expand Up @@ -1125,6 +1136,31 @@ slurpy arguments).

RETURN(INTVAL arity);
}

/*
=item C<INTVAL comp_flags()>

=item C<INTVAL pf_flags()>

(Experimental) Returns Sub flags.

=cut
*/
METHOD comp_flags() {
Parrot_Sub_attributes *sub;
INTVAL flags;

PMC_get_sub(INTERP, SELF, sub);
flags = sub->comp_flags;
RETURN(INTVAL flags);
}

METHOD pf_flags() {
/* Only PF specific flags */
INTVAL flags = PObj_get_FLAGS(SELF) & SUB_FLAG_PF_MASK;
RETURN(INTVAL flags);
}

}


Expand Down

0 comments on commit 661b296

Please sign in to comment.