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

[svn:parrot] r34556 - branches/rvar/languages/perl6/src/classes

From:
pmichaud
Date:
December 28, 2008 22:52
Subject:
[svn:parrot] r34556 - branches/rvar/languages/perl6/src/classes
Message ID:
20081229065240.F21CBCB9FA@x12.develooper.com
Author: pmichaud
Date: Sun Dec 28 22:52:40 2008
New Revision: 34556

Modified:
   branches/rvar/languages/perl6/src/classes/Object.pir
   branches/rvar/languages/perl6/src/classes/Signature.pir

Log:
[rakudo]:  Add Hash() coercion and hash parameters.


Modified: branches/rvar/languages/perl6/src/classes/Object.pir
==============================================================================
--- branches/rvar/languages/perl6/src/classes/Object.pir	(original)
+++ branches/rvar/languages/perl6/src/classes/Object.pir	Sun Dec 28 22:52:40 2008
@@ -225,6 +225,20 @@
     .return ($P0)
 .end
 
+.namespace []
+.sub 'Hash'
+    .param pmc source
+    $I0 = isa source, 'ObjectRef'
+    if $I0 goto make_hash
+    $I0 = can source, 'Hash'
+    unless $I0 goto make_hash
+    .tailcall source.'Hash'()
+  make_hash:
+    $P0 = new 'Perl6Hash'
+    $P0.'!STORE'(source)
+    .return ($P0)
+.end
+
 =item Iterator()
 
 =cut

Modified: branches/rvar/languages/perl6/src/classes/Signature.pir
==============================================================================
--- branches/rvar/languages/perl6/src/classes/Signature.pir	(original)
+++ branches/rvar/languages/perl6/src/classes/Signature.pir	Sun Dec 28 22:52:40 2008
@@ -200,6 +200,7 @@
     type = param['type']
     orig = callerlex[name]
     if sigil == '@' goto param_array
+    if sigil == '%' goto param_hash
     var = 'Scalar'(orig)
     ##  typecheck the argument
     if null type goto param_val_done
@@ -210,6 +211,8 @@
   param_array:
     var = 'Array'(orig)
     goto param_val_done
+  param_hash:
+    var = 'Hash'(orig)
   param_val_done:
     ## handle readonly/copy traits
     $S0 = param['readtype']



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