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

NotFound at svn.parrot.org NotFound at svn.parrot.org
Thu Jul 29 20:57:06 UTC 2010


Author: NotFound
Date: Thu Jul 29 20:57:06 2010
New Revision: 48220
URL: https://trac.parrot.org/parrot/changeset/48220

Log:
implement OpLib vtable elements and add tests for it and get_pmc_keyed_int

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

Modified: trunk/src/pmc/oplib.pmc
==============================================================================
--- trunk/src/pmc/oplib.pmc	Thu Jul 29 19:46:36 2010	(r48219)
+++ trunk/src/pmc/oplib.pmc	Thu Jul 29 20:57:06 2010	(r48220)
@@ -99,10 +99,14 @@
         }
     }
 
-    VTABLE INTVAL get_integer() {
+    VTABLE INTVAL elements() {
         return INTERP->op_lib->op_count;
     }
 
+    VTABLE INTVAL get_integer() {
+        return STATICSELF.elements();
+    }
+
     METHOD op_family(STRING *shortname)
     {
         char * const sname = Parrot_str_to_cstring(INTERP, shortname);

Modified: trunk/t/pmc/oplib.t
==============================================================================
--- trunk/t/pmc/oplib.t	Thu Jul 29 19:46:36 2010	(r48219)
+++ trunk/t/pmc/oplib.t	Thu Jul 29 20:57:06 2010	(r48220)
@@ -12,10 +12,13 @@
 
 =cut
 
+.include 'except_types.pasm'
+
 .sub main :main
     .include 'test_more.pir'
-    plan(5)
+    plan(7)
     new_oplib()
+    check_elements()
     get_end()
     get_no_opcode()
     family_end()
@@ -28,6 +31,29 @@
     nok($I0, "new OpLib")
 .end
 
+.sub check_elements
+    .local pmc oplib, op, eh
+    .local int n, i
+    oplib = new ['OpLib']
+    n = elements oplib
+    i = n - 1
+    op = oplib[i]
+    i = isnull op
+    is(i, 0, 'last opcode exists')
+    eh = new ['ExceptionHandler']
+    eh.'handle_types'(.EXCEPTION_OUT_OF_BOUNDS)
+    set_addr eh, catch
+    push_eh eh
+    op = oplib[n]
+    nok(1, 'out of bounds opcode number should throw')
+    goto end
+  catch:
+    finalize eh
+    pop_eh
+    ok(1, 'out of bounds opcode number throws')
+  end:
+.end
+
 .sub get_end
     $P0 = new ['OpLib']
     # Assumption: we'll always have an end opcode.


More information about the parrot-commits mailing list