Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Autothunkify left side of xx (fixes #70)

  • Loading branch information...
commit 2c52e86ee27c352878d324b6a0b1e8736b859077 1 parent 191508a
@sorear authored
Showing with 10 additions and 0 deletions.
  1. +1 −0  lib/CORE.setting
  2. +9 −0 src/niecza
View
1  lib/CORE.setting
@@ -1952,6 +1952,7 @@ sub prefix:<|> (\$item) { $item.Capture }
sub prefix:<^> ($limit) { 0 ..^ +$limit }
sub prefix:<so> is Niecza::absprec<h=> (\$item) { ?$item }
sub infix:<xx> is Niecza::absprec<s=> (\$list, $ct) { map { $list }, ($ct ~~ Whatever) ?? ^Inf !! ^$ct }
+sub _doreplicate($func, $ct) { map { $func() }, ($ct ~~ Whatever) ?? ^Inf !! ^$ct }
sub prefix:<abs> ($x) { Q:CgOp { (abs {$x}) } }
sub abs($x) { Q:CgOp { (abs {$x}) } }
sub floor($x) { Q:CgOp { (floor {$x}) } }
View
9 src/niecza
@@ -17,6 +17,14 @@ use RxOp;
use Sig;
use STD;
+class Operator::Replicate is Operator {
+ method as_function($/) { mklex($/, '&infix:<xx>') }
+ method with_args($/, *@args) {
+ mkcall($/, '&_doreplicate', ::GLOBAL::NieczaActions.block_expr($/,
+ ::GLOBAL::NieczaActions.thunk_sub(@args[0])), @args[1]);
+ }
+}
+
augment grammar STD {
method explain_mystery($nested?) {
my %post_types;
@@ -133,6 +141,7 @@ augment class RxOp::Sym {
}
augment class NieczaActions {
+method infix:sym<xx> ($/) { make ::Operator::Replicate.new }
method statement_prefix:BEGIN ($/) {
# MAJOR HACK - allows test code like BEGIN { @*INC.push: ... } to work
repeat while False {
Please sign in to comment.
Something went wrong with that request. Please try again.