develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r33690 - in branches/assign: . languages/perl6/config/makefiles languages/perl6/src/classes runtime/parrot/library

From:
pmichaud
Date:
December 8, 2008 19:49
Subject:
[svn:parrot] r33690 - in branches/assign: . languages/perl6/config/makefiles languages/perl6/src/classes runtime/parrot/library
Message ID:
20081209034925.49A33CB9AF@x12.develooper.com
Author: pmichaud
Date: Mon Dec  8 19:49:24 2008
New Revision: 33690

Added:
   branches/assign/languages/perl6/src/classes/Positional.pir   (contents, props changed)
Modified:
   branches/assign/MANIFEST
   branches/assign/languages/perl6/config/makefiles/root.in
   branches/assign/languages/perl6/src/classes/List.pir
   branches/assign/runtime/parrot/library/P6object.pir

Log:
[rakudo]:  Refactor postcircumfix;<[ ]> to be a Role.


Modified: branches/assign/MANIFEST
==============================================================================
--- branches/assign/MANIFEST	(original)
+++ branches/assign/MANIFEST	Mon Dec  8 19:49:24 2008
@@ -1,7 +1,7 @@
 # ex: set ro:
 # $Id$
 #
-# generated by tools/dev/mk_manifest_and_skip.pl Mon Dec  8 06:34:03 2008 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Tue Dec  9 03:48:02 2008 UT
 #
 # See tools/dev/install_files.pl for documentation on the
 # format of this file.
@@ -2149,6 +2149,7 @@
 languages/perl6/src/classes/Object.pir                      [perl6]
 languages/perl6/src/classes/Order.pir                       [perl6]
 languages/perl6/src/classes/Pair.pir                        [perl6]
+languages/perl6/src/classes/Positional.pir                  [perl6]
 languages/perl6/src/classes/Protoobject.pir                 [perl6]
 languages/perl6/src/classes/Range.pir                       [perl6]
 languages/perl6/src/classes/Role.pir                        [perl6]

Modified: branches/assign/languages/perl6/config/makefiles/root.in
==============================================================================
--- branches/assign/languages/perl6/config/makefiles/root.in	(original)
+++ branches/assign/languages/perl6/config/makefiles/root.in	Mon Dec  8 19:49:24 2008
@@ -52,6 +52,7 @@
 BUILTINS_PIR = \
   src/classes/Object.pir \
   src/classes/Protoobject.pir \
+  src/classes/Positional.pir \
   src/classes/Any.pir \
   src/classes/Bool.pir \
   src/classes/Str.pir \

Modified: branches/assign/languages/perl6/src/classes/List.pir
==============================================================================
--- branches/assign/languages/perl6/src/classes/List.pir	(original)
+++ branches/assign/languages/perl6/src/classes/List.pir	Mon Dec  8 19:49:24 2008
@@ -11,6 +11,8 @@
     .local pmc p6meta, listproto
     p6meta = get_hll_global ['Perl6Object'], '$!P6META'
     listproto = p6meta.'new_class'('List', 'parent'=>'ResizablePMCArray Any')
+    $P0 = get_hll_global 'Positional'
+    p6meta.'add_role'($P0, 'to'=>listproto)
     p6meta.'register'('ResizablePMCArray', 'parent'=>listproto, 'protoobject'=>listproto)
 
     $P0 = get_hll_namespace ['List']
@@ -185,50 +187,6 @@
     .return (result)
 .end
 
-=back
-
-=head2 Operator methods
-
-=over
-
-=item postcircumfix:<[ ]>
-
-Returns a list element or slice.
-
-=cut
-
-.sub 'postcircumfix:[ ]' :method
-    .param pmc args            :slurpy
-    .param pmc options         :slurpy :named
-    .local pmc result
-    args.'!flatten'()
-    $I0 = args.'elems'()
-    if $I0 != 1 goto slice
-    $I0 = args[0]
-    result = self[$I0]
-    unless null result goto end
-    $P0 = get_hll_global 'Object'
-    result = new 'Failure'
-    self[$I0] = result
-    goto end
-  slice:
-    result = new 'List'
-  slice_loop:
-    unless args goto slice_done
-    $I0 = shift args
-    .local pmc elem
-    elem = self[$I0]
-    unless null elem goto slice_elem
-    elem = new 'Failure'
-    self[$I0] = elem
-  slice_elem:
-    push result, elem
-    goto slice_loop
-  slice_done:
-  end:
-    .return (result)
-.end
-
 
 =back
 

Added: branches/assign/languages/perl6/src/classes/Positional.pir
==============================================================================
--- (empty file)
+++ branches/assign/languages/perl6/src/classes/Positional.pir	Mon Dec  8 19:49:24 2008
@@ -0,0 +1,70 @@
+## $Id$
+
+=head1 NAME
+
+src/classes/Positional.pir - Positional Role
+
+=head1 DESCRIPTION
+
+=cut
+
+.namespace []
+
+.sub '' :anon :load :init
+    .local pmc positional
+    positional = '!keyword_role'('Positional')
+.end
+
+=head2 Methods
+
+=over
+
+=item postcircumfix:<[ ]>
+
+Returns a list element or slice.
+
+=cut
+
+.namespace ['Positional']
+.sub 'postcircumfix:[ ]' :method
+    .param pmc args            :slurpy
+    .param pmc options         :slurpy :named
+    .local pmc result
+    args.'!flatten'()
+    $I0 = args.'elems'()
+    if $I0 != 1 goto slice
+    $I0 = args[0]
+    result = self[$I0]
+    unless null result goto end
+    $P0 = get_hll_global 'Object'
+    result = new 'Failure'
+    self[$I0] = result
+    goto end
+  slice:
+    result = new 'List'
+  slice_loop:
+    unless args goto slice_done
+    $I0 = shift args
+    .local pmc elem
+    elem = self[$I0]
+    unless null elem goto slice_elem
+    elem = new 'Failure'
+    self[$I0] = elem
+  slice_elem:
+    push result, elem
+    goto slice_loop
+  slice_done:
+  end:
+    .return (result)
+.end
+
+=back
+
+=cut
+
+# Local Variables:
+#   mode: pir
+#   fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:
+

Modified: branches/assign/runtime/parrot/library/P6object.pir
==============================================================================
--- branches/assign/runtime/parrot/library/P6object.pir	(original)
+++ branches/assign/runtime/parrot/library/P6object.pir	Mon Dec  8 19:49:24 2008
@@ -252,6 +252,26 @@
 .end
 
 
+=item add_role(role, [, 'to'=>parrotclass])
+
+Add C<role> to C<parrotclass>.
+
+=cut
+
+.sub 'add_role' :method
+    .param pmc role
+    .param pmc options         :slurpy :named
+
+    $P0 = options['to']
+    unless null $P0 goto have_to
+    $P0 = self
+  have_to:
+    .local pmc parrotclass
+    parrotclass = self.'get_parrotclass'($P0)
+    parrotclass.'add_role'(role)
+.end
+
+
 =item register(parrotclass [, 'name'=>name] [, 'protoobject'=>proto] [, 'parent'=>parentclass] [, 'hll'=>hll])
 
 Sets objects of type C<parrotclass> to use C<protoobject>,



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About