[svn:parrot] r41315 - in trunk: src/pmc t/pmc

bacek at svn.parrot.org bacek at svn.parrot.org
Thu Sep 17 09:03:59 UTC 2009


Author: bacek
Date: Thu Sep 17 09:03:57 2009
New Revision: 41315
URL: https://trac.parrot.org/parrot/changeset/41315

Log:
[core] Implement initialisation of n_regs_used in Sub.init_pmc.

Modified:
   trunk/src/pmc/sub.pmc
   trunk/t/pmc/sub.t

Modified: trunk/src/pmc/sub.pmc
==============================================================================
--- trunk/src/pmc/sub.pmc	Thu Sep 17 08:34:27 2009	(r41314)
+++ trunk/src/pmc/sub.pmc	Thu Sep 17 09:03:57 2009	(r41315)
@@ -170,12 +170,19 @@
         if (VTABLE_exists_keyed_str(INTERP, init, field))
             attrs->comp_flags = (UINTVAL)VTABLE_get_integer_keyed_str(INTERP, init, field);
 
+        field = CONST_STRING(INTERP, "n_regs_used");
+        if (VTABLE_exists_keyed_str(INTERP, init, field)) {
+            PMC   *tmp = VTABLE_get_pmc_keyed_str(INTERP, init, field);
+            INTVAL i;
+            for (i = 0; i < 4; ++i)
+                attrs->n_regs_used[i] = VTABLE_get_integer_keyed_int(INTERP, tmp, i);
+        }
+
         /*
         C<eval_pmc> and C<ctx> are not handled here. And shouldn't be handled
         here at all because of run-time nature.
         */
         
-        /* TODO Implement initialisation of n_regs_used via FIA */
         /* TODO Implement initialisation of arg_info via nested Hash */
         PObj_custom_mark_destroy_SETALL(SELF);
     }

Modified: trunk/t/pmc/sub.t
==============================================================================
--- trunk/t/pmc/sub.t	Thu Sep 17 08:34:27 2009	(r41314)
+++ trunk/t/pmc/sub.t	Thu Sep 17 09:03:57 2009	(r41315)
@@ -1636,10 +1636,19 @@
 
 pir_output_is( <<'CODE', <<'OUTPUT', 'init_pmc' );
 .sub 'main'
-    .local pmc init, s
+    .local pmc init, s, regs
+    
     init = new ['Hash']
     init['start_offs']  = 42
     init['end_offs']    = 115200
+    
+    regs = new ['FixedIntegerArray']
+    regs = 4
+    regs[0] = 1
+    regs[1] = 2
+    regs[2] = 6
+    regs[3] = 24
+    init['n_regs_used'] = regs
 
     s = new ['Sub'], init
 
@@ -1651,11 +1660,31 @@
     $I0 = s.'end_offs'()
     say $I0
 
+    $I0 = s.'__get_regs_used'('I')
+    print 'I regs '
+    say $I0
+
+    $I0 = s.'__get_regs_used'('N')
+    print 'N regs '
+    say $I0
+
+    $I0 = s.'__get_regs_used'('S')
+    print 'S regs '
+    say $I0
+
+    $I0 = s.'__get_regs_used'('P')
+    print 'P regs '
+    say $I0
+
     # We need more tests for other fields. And more accessors obviously.
 .end
 CODE
 start_offs 42
 end_offs 115200
+I regs 1
+N regs 2
+S regs 6
+P regs 24
 OUTPUT
 
 # Local Variables:


More information about the parrot-commits mailing list