perl.cvs.parrot
[Top] [All Lists]

[svn:parrot] r30671 - trunk/languages/perl6/src/builtins

Subject: [svn:parrot] r30671 - trunk/languages/perl6/src/builtins
From:
Date: Sun, 31 Aug 2008 11:29:13 -0700 PDT
Newsgroups: perl.cvs.parrot

Author: moritz
Date: Sun Aug 31 11:29:12 2008
New Revision: 30671

Modified:
   trunk/languages/perl6/src/builtins/any-str.pir

Log:
[rakudo] Str.subst can take a closure as second argument


Modified: trunk/languages/perl6/src/builtins/any-str.pir
==============================================================================
--- trunk/languages/perl6/src/builtins/any-str.pir      (original)
+++ trunk/languages/perl6/src/builtins/any-str.pir      Sun Aug 31 11:29:12 2008
@@ -371,7 +371,7 @@
 
 .sub subst :method :lex :multi(_, 'Sub', _)
     .param pmc regexp
-    .param string replacement
+    .param pmc replacement
     .local int pos
     .local int pos_after
     .local pmc retv
@@ -390,8 +390,23 @@
     $S0 = self
     $S1 = substr $S0, 0, pos
     $S2 = substr $S0, pos_after
+    # pre-match
     concat retv, $S1
+
+    # match
+    $I0 = isa replacement, 'Sub'
+    unless $I0 goto is_string
+
+    $S3 = match.'text'()
+    $S3 = replacement($S3)
+    concat retv, $S3
+    goto repl_done
+
+  is_string:
     concat retv, replacement
+
+  repl_done:
+    # post-match
     concat retv, $S2
 
     goto done

<Prev in Thread] Current Thread [Next in Thread>
  • [svn:parrot] r30671 - trunk/languages/perl6/src/builtins, moritz <=