[svn:parrot] r47950 - trunk/src/pmc
bacek at svn.parrot.org
bacek at svn.parrot.org
Thu Jul 1 21:51:09 UTC 2010
Author: bacek
Date: Thu Jul 1 21:51:08 2010
New Revision: 47950
URL: https://trac.parrot.org/parrot/changeset/47950
Log:
Add ability to set Sub's PObj flags in init_pmc. Also add method to fetch them for testing purposes
Modified:
trunk/src/pmc/sub.pmc
Modified: trunk/src/pmc/sub.pmc
==============================================================================
--- trunk/src/pmc/sub.pmc Thu Jul 1 20:47:29 2010 (r47949)
+++ trunk/src/pmc/sub.pmc Thu Jul 1 21:51:08 2010 (r47950)
@@ -185,8 +185,19 @@
/* 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 @@
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);
+ }
+
}
More information about the parrot-commits
mailing list