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

[svn:parrot] r33917 - in trunk/languages/perl6/src: builtins classes

From:
pmichaud
Date:
December 15, 2008 07:53
Subject:
[svn:parrot] r33917 - in trunk/languages/perl6/src: builtins classes
Message ID:
20081215155256.0B0D1CBA12@x12.develooper.com
Author: pmichaud
Date: Mon Dec 15 07:52:54 2008
New Revision: 33917

Modified:
   trunk/languages/perl6/src/builtins/assign.pir
   trunk/languages/perl6/src/classes/Array.pir
   trunk/languages/perl6/src/classes/Object.pir

Log:
[rakudo]:  Refactor Scalar coercions.


Modified: trunk/languages/perl6/src/builtins/assign.pir
==============================================================================
--- trunk/languages/perl6/src/builtins/assign.pir	(original)
+++ trunk/languages/perl6/src/builtins/assign.pir	Mon Dec 15 07:52:54 2008
@@ -16,18 +16,7 @@
     .param pmc cont
     .param pmc source
 
-    $I0 = isa source, 'ObjectRef'
-    if $I0 goto have_source
-    $I0 = can source, 'Scalar'
-    if $I0 goto can_scalar
-    ##  source comes from outside Rakudo's type system
-    $I0 = does source, 'scalar'
-    if $I0 goto have_source
-    source = new 'ObjectRef', source
-    goto have_source
-  can_scalar:
-    source = source.'Scalar'()
-  have_source:
+    source = 'Scalar'(source)
     .local pmc ro, type
     getprop ro, 'readonly', cont
     if null ro goto ro_ok

Modified: trunk/languages/perl6/src/classes/Array.pir
==============================================================================
--- trunk/languages/perl6/src/classes/Array.pir	(original)
+++ trunk/languages/perl6/src/classes/Array.pir	Mon Dec 15 07:52:54 2008
@@ -100,7 +100,7 @@
 =cut
 
 .namespace ['Perl6Array']
-.sub 'list' :method
+.sub '' :method('list')
     .tailcall self.'values'()
 .end
 
@@ -246,13 +246,12 @@
     ## we create a new array here instead of emptying self in case
     ## the source argument contains self or elements of self.
     array = new 'ResizablePMCArray'
-    $P0 = get_hll_global 'list'
-    source = $P0(source)
+    source = 'list'(source)
     it = iter source
   array_loop:
     unless it goto array_done
     $P0 = shift it
-    $P0 = $P0.'Scalar'()
+    $P0 = 'Scalar'($P0)
     $P0 = clone $P0
     push array, $P0
     goto array_loop

Modified: trunk/languages/perl6/src/classes/Object.pir
==============================================================================
--- trunk/languages/perl6/src/classes/Object.pir	(original)
+++ trunk/languages/perl6/src/classes/Object.pir	Mon Dec 15 07:52:54 2008
@@ -160,7 +160,8 @@
 
 =cut
 
-.sub 'Scalar' :method
+.namespace ['Perl6Object']
+.sub '' :method('Scalar') :anon
     $I0 = isa self, 'ObjectRef'
     unless $I0 goto not_ref
     .return (self)
@@ -169,6 +170,21 @@
     .return ($P0)
 .end
 
+.namespace []
+.sub 'Scalar'
+    .param pmc source
+    $I0 = isa source, 'ObjectRef'
+    if $I0 goto done
+    $I0 = can source, 'Scalar'
+    if $I0 goto can_scalar
+    $I0 = does source, 'scalar'
+    source = new 'ObjectRef', source
+  done:
+    .return (source)
+  can_scalar:
+    .tailcall source.'Scalar'()
+.end
+
 =item Str()
 
 Return a string representation of the invocant.  Default is
@@ -176,6 +192,7 @@
 
 =cut
 
+.namespace ['Perl6Object']
 .sub 'Str' :method
     $P0 = new 'ResizableStringArray'
     $P1 = self.'WHAT'()



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