[svn:parrot] r41851 - in branches/pcc_optimize_sig: src/pmc t/pmc
chromatic at svn.parrot.org
chromatic at svn.parrot.org
Wed Oct 14 07:02:03 UTC 2009
Author: chromatic
Date: Wed Oct 14 07:02:00 2009
New Revision: 41851
URL: https://trac.parrot.org/parrot/changeset/41851
Log:
[PMC] Added elements vtable entry to CallSignature PMC as well as tests.
Modified:
branches/pcc_optimize_sig/src/pmc/callsignature.pmc
branches/pcc_optimize_sig/t/pmc/callsignature.t
Modified: branches/pcc_optimize_sig/src/pmc/callsignature.pmc
==============================================================================
--- branches/pcc_optimize_sig/src/pmc/callsignature.pmc Wed Oct 14 02:12:37 2009 (r41850)
+++ branches/pcc_optimize_sig/src/pmc/callsignature.pmc Wed Oct 14 07:02:00 2009 (r41851)
@@ -532,6 +532,14 @@
}
}
+ VTABLE INTVAL elements () {
+ Parrot_CallSignature_attributes * const attrs = PARROT_CALLSIGNATURE(SELF);
+ if (!attrs)
+ return 0;
+
+ return attrs->num_positionals;
+ }
+
VTABLE void push_integer(INTVAL value) {
Pcc_cell *cell = CREATE_INTVAL_CELL;
APPEND_CELL(SELF, cell);
Modified: branches/pcc_optimize_sig/t/pmc/callsignature.t
==============================================================================
--- branches/pcc_optimize_sig/t/pmc/callsignature.t Wed Oct 14 02:12:37 2009 (r41850)
+++ branches/pcc_optimize_sig/t/pmc/callsignature.t Wed Oct 14 07:02:00 2009 (r41851)
@@ -19,7 +19,7 @@
.sub 'main' :main
.include 'test_more.pir'
- plan(46)
+ plan(56)
test_instantiate()
test_get_set_attrs()
@@ -63,11 +63,17 @@
$P1 = 100
push $P0, $P1
+ $I0 = elements $P0
+ is( $I0, 1, 'elements after push' )
+
$P2 = $P0[0]
is( $P2, 100, 'push_pmc/get_pmc_keyed_int pair' )
$P2 = pop $P0
is( $P2, 100, 'push_pmc/pop_pmc pair' )
+ $I0 = elements $P0
+ is( $I0, 0, 'elements after pop' )
+
push $P0, 200
$I0 = $P0[0]
is( $I0, 200, 'push_integer/get_integer_keyed_int pair' )
@@ -85,6 +91,9 @@
is( $S0, 'hello', 'push_string/get_string_keyed_int pair' )
$S0 = pop $P0
is( $S0, 'hello', 'push_string/pop_string pair' )
+
+ $I0 = elements $P0
+ is( $I0, 0, 'elements after push/pop' )
.end
.sub 'test_shift_unshift_indexed_access'
@@ -93,11 +102,18 @@
$P1 = 100
unshift $P0, $P1
+
+ $I0 = elements $P0
+ is( $I0, 1, 'elements after unshift' )
+
$P2 = $P0[0]
is( $P2, 100, 'unshift_pmc/get_pmc_keyed_int pair' )
$P2 = shift $P0
is( $P2, 100, 'unshift_pmc/shift_pmc pair' )
+ $I0 = elements $P0
+ is( $I0, 0, 'elements after unshift/shift' )
+
unshift $P0, 200
$I0 = $P0[0]
is( $I0, 200, 'unshift_integer/get_integer_keyed_int pair' )
@@ -115,20 +131,36 @@
is( $S0, 'hello', 'unshift_string/get_string_keyed_int pair' )
$S0 = shift $P0
is( $S0, 'hello', 'unshift_string/shift_string pair' )
+
+ $I0 = elements $P0
+ is( $I0, 0, 'elements after unshift/shift' )
.end
.sub 'test_indexed_access'
$P0 = new [ 'CallSignature' ]
$P0[0] = 100
+
+ $I0 = elements $P0
+ is( $I0, 1, 'elements after set_*_indexed' )
+
$P0[1] = 1.11
+ $I0 = elements $P0
+ is( $I0, 2, 'elements after set_*_indexed' )
+
$S0 = '2.22'
$P0[2] = $S0
+ $I0 = elements $P0
+ is( $I0, 3, 'elements after set_*_indexed' )
+
$P1 = new [ 'Float' ]
$P1 = 3.33
$P0[3] = $P1
+ $I0 = elements $P0
+ is( $I0, 4, 'elements after set_*_indexed' )
+
$I1 = $P0[0]
is( $I1, 100, 'set_integer_keyed_int/get_integer_keyed_int pair' )
More information about the parrot-commits
mailing list