Author: jonathan
Date: Sat Apr  7 16:05:47 2007
New Revision: 18031

Added:
   trunk/t/oo/ops.t   (contents, props changed)
Modified:
   trunk/PBC_COMPAT
   trunk/src/ops/object.ops
   trunk/src/ops/ops.num

Log:
[PDD15]: Add the new addrole opcode plus a test for it. Invalidates PBCs - make 
realclean suggested.

Modified: trunk/PBC_COMPAT
==============================================================================
--- trunk/PBC_COMPAT    (original)
+++ trunk/PBC_COMPAT    Sat Apr  7 16:05:47 2007
@@ -28,6 +28,7 @@
 
 # please insert tab separated entries at the top of the list
 
+2007.04.07     jonathan        added addrole opcode
 2007.03.20     coke    released 0.4.10
 2007.02.22     pmichaud        released 0.4.9
 2007.01.16     particle        released 0.4.8

Modified: trunk/src/ops/object.ops
==============================================================================
--- trunk/src/ops/object.ops    (original)
+++ trunk/src/ops/object.ops    Sat Apr  7 16:05:47 2007
@@ -447,6 +447,17 @@
     goto NEXT();
 }
 
+=item B<addrole>(invar PMC, invar PMC)
+
+Compose the role $2 into $1.
+
+=cut
+
+inline op addrole(invar PMC, invar PMC) :object_classes {
+    VTABLE_add_role(interp, $1, $2);
+    goto NEXT();
+}
+
 =item B<addattribute>(invar PMC, in STR)
 
 Add the attribute named $2 to the class $1.

Modified: trunk/src/ops/ops.num
==============================================================================
--- trunk/src/ops/ops.num       (original)
+++ trunk/src/ops/ops.num       Sat Apr  7 16:05:47 2007
@@ -1224,3 +1224,4 @@
 stm_wait_ic                    1194
 stm_abort                      1195
 stm_depth_i                    1196
+addrole_p_p                    1197

Added: trunk/t/oo/ops.t
==============================================================================
--- (empty file)
+++ trunk/t/oo/ops.t    Sat Apr  7 16:05:47 2007
@@ -0,0 +1,49 @@
+#!perl
+# Copyright (C) 2007, The Perl Foundation.
+# $Id$
+
+use strict;
+use warnings;
+use lib qw( . lib ../lib ../../lib );
+use Test::More;
+use Parrot::Test tests => 1;
+
+=head1 NAME
+
+t/oo/ops.t - test OO related ops
+
+=head1 SYNOPSIS
+
+    % prove t/oo/ops.t
+
+=head1 DESCRIPTION
+
+Tests opcodes related to the OO implementation.
+
+=cut
+
+pir_output_is( <<'CODE', <<'OUT', 'addrole' );
+.sub 'test' :main
+    $P0 = new 'Role'
+    $P1 = new 'Class'
+    addrole $P1, $P0
+    print "ok 1 - addrole op executed\n"
+
+    $P2 = $P1.roles()
+    $I0 = elements $P2
+    if $I0 == 1 goto ok_2
+    print "not "
+ok_2:
+    print "ok 2 - addrole op actually added the role\n"
+.end
+CODE
+ok 1 - addrole op executed
+ok 2 - addrole op actually added the role
+OUT
+
+# Local Variables:
+#   mode: cperl
+#   cperl-indent-level: 4
+#   fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:

Reply via email to