Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add ability to set Sub's PObj flags in init_pmc. Also add method to f…

…etch them for testing purposes

git-svn-id: https://svn.parrot.org/parrot/trunk@47950 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
commit 661b2968932310daf2efebf88c4b234264affdf0 1 parent 6aed0cf
bacek authored
Showing with 38 additions and 2 deletions.
  1. +38 −2 src/pmc/sub.pmc
View
40 src/pmc/sub.pmc
@@ -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)) {
@@ -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);
+ }
+
}
Please sign in to comment.
Something went wrong with that request. Please try again.