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

bacek at svn.parrot.org bacek at svn.parrot.org
Thu Sep 17 08:34:28 UTC 2009


Author: bacek
Date: Thu Sep 17 08:34:27 2009
New Revision: 41314
URL: https://trac.parrot.org/parrot/changeset/41314

Log:
[core][t] Implement Sub.start_offs and end_offs accessors. Add limited test for 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:00 2009	(r41313)
+++ trunk/src/pmc/sub.pmc	Thu Sep 17 08:34:27 2009	(r41314)
@@ -909,6 +909,14 @@
 
 =over 4
 
+=item C<INTVAL start_offs()>
+
+Return the start offset of the Sub.
+
+=item C<INTVAL end_offs()>
+
+Return the start offset of the Sub.
+
 =item C<PMC *get_namespace()>
 
 Return the namespace PMC, where the Sub is defined.
@@ -943,6 +951,21 @@
 =cut
 
 */
+    METHOD start_offs() {
+        Parrot_Sub_attributes  *sub;
+        INTVAL                  start_offs;
+        PMC_get_sub(INTERP, SELF, sub);
+        start_offs = sub->start_offs;
+        RETURN(INTVAL start_offs);
+    }
+
+    METHOD end_offs() {
+        Parrot_Sub_attributes  *sub;
+        INTVAL                  end_offs;
+        PMC_get_sub(INTERP, SELF, sub);
+        end_offs = sub->end_offs;
+        RETURN(INTVAL end_offs);
+    }
 
     METHOD get_namespace() {
         PMC *_namespace;

Modified: trunk/t/pmc/sub.t
==============================================================================
--- trunk/t/pmc/sub.t	Thu Sep 17 08:34:00 2009	(r41313)
+++ trunk/t/pmc/sub.t	Thu Sep 17 08:34:27 2009	(r41314)
@@ -9,7 +9,7 @@
 use Test::More;
 use Parrot::Test::Util 'create_tempfile';
 
-use Parrot::Test tests => 68;
+use Parrot::Test tests => 69;
 use Parrot::Config;
 
 =head1 NAME
@@ -1634,6 +1634,30 @@
 hi
 OUTPUT
 
+pir_output_is( <<'CODE', <<'OUTPUT', 'init_pmc' );
+.sub 'main'
+    .local pmc init, s
+    init = new ['Hash']
+    init['start_offs']  = 42
+    init['end_offs']    = 115200
+
+    s = new ['Sub'], init
+
+    $I0 = s.'start_offs'()
+    print 'start_offs '
+    say $I0
+
+    print 'end_offs '
+    $I0 = s.'end_offs'()
+    say $I0
+
+    # We need more tests for other fields. And more accessors obviously.
+.end
+CODE
+start_offs 42
+end_offs 115200
+OUTPUT
+
 # Local Variables:
 #   mode: cperl
 #   cperl-indent-level: 4


More information about the parrot-commits mailing list