develooper Front page | perl.cvs.parrot | Postings from January 2009

[svn:parrot] r35373 - trunk/languages/perl6/src/classes

From:
pmichaud
Date:
January 10, 2009 18:32
Subject:
[svn:parrot] r35373 - trunk/languages/perl6/src/classes
Message ID:
20090111023156.2DB3ACB9F9@x12.develooper.com
Author: pmichaud
Date: Sat Jan 10 18:31:54 2009
New Revision: 35373

Modified:
   trunk/languages/perl6/src/classes/Signature.pir

Log:
[rakudo]: add Positional/Associative checks for array/hash parameters.


Modified: trunk/languages/perl6/src/classes/Signature.pir
==============================================================================
--- trunk/languages/perl6/src/classes/Signature.pir	(original)
+++ trunk/languages/perl6/src/classes/Signature.pir	Sat Jan 10 18:31:54 2009
@@ -295,9 +295,19 @@
     unless $P0 goto err_param_type
     goto param_val_done
   param_array:
+    $I0 = does orig, 'Positional'
+    if $I0 goto param_array_1
+    $I0 = does orig, 'array'
+    unless $I0 goto err_array
+  param_array_1:
     var = '!CALLMETHOD'('Array', orig)
     goto param_val_done
   param_hash:
+    $I0 = does orig, 'Associative'
+    if $I0 goto param_hash_1
+    $I0 = does orig, 'hash'
+    unless $I0 goto err_hash
+  param_hash_1:
     var = '!CALLMETHOD'('Hash', orig)
   param_val_done:
     ## handle readonly/copy traits
@@ -321,12 +331,23 @@
   param_done:
   end:
     .return ()
+
   err_param_type:
-    $S0 = callersub
-    if $S0 goto have_callersub_name
-    $S0 = '<anon>'
-  have_callersub_name:
-    'die'('Parameter type check failed in call to ', $S0)
+    .local string errmsg
+    errmsg = 'Parameter type check failed'
+    goto err_throw
+  err_array:
+    errmsg = 'Non-Positional argument'
+    goto err_throw
+  err_hash:
+    errmsg = 'Non-Associative argument'
+  err_throw:
+    .local string callername
+    callername = callersub
+    if callername goto have_callername
+    callername = '<anon>'
+  have_callername:
+    'die'(errmsg, ' for ', name, ' in call to ', callername)
 .end
 
 



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