Skip to content
Browse files

Finish removing "easy" cases of direct cross-module class referencing

  • Loading branch information...
1 parent d6e29a5 commit f5fd473f34b5967c160671e2b5f3f90a95d73c2e @sorear committed Jan 14, 2012
Showing with 601 additions and 426 deletions.
  1. +1 −7 Makefile
  2. +2 −0 src/CClass.pm6
  3. +3 −0 src/CgOp.pm6
  4. +10 −8 src/NieczaActions.pm6
  5. +3 −0 src/NieczaPassSimplifier.pm6
  6. +310 −234 src/Op.pm6
  7. +20 −17 src/OpHelpers.pm6
  8. +66 −35 src/Operator.pm6
  9. +7 −5 src/OptBeta.pm6
  10. +3 −1 src/OptRxSimple.pm6
  11. +168 −117 src/RxOp.pm6
  12. +6 −2 src/Sig.pm6
  13. +2 −0 src/niecza
View
8 Makefile
@@ -118,14 +118,8 @@ boot/obj/Run.NieczaBackendDotnet.ser: boot/obj/Run.CompilerBlob.dll
# grep -r '^use' src/*.pm6 | sed 's|src/\(.*\)\.pm6:use \(.*\);|boot/obj/Run.\1.ser: boot/obj/Run.\2.ser|' | grep -v MONKEY_TYPING
boot/obj/Run.NieczaActions.ser: boot/obj/Run.OpHelpers.ser
-boot/obj/Run.NieczaFrontendSTD.ser: boot/obj/Run.NieczaGrammar.ser
boot/obj/Run.NieczaFrontendSTD.ser: boot/obj/Run.STD.ser
+boot/obj/Run.NieczaFrontendSTD.ser: boot/obj/Run.NieczaGrammar.ser
boot/obj/Run.NieczaGrammar.ser: boot/obj/Run.STD.ser
boot/obj/Run.Operator.ser: boot/obj/Run.OpHelpers.ser
-boot/obj/Run.Operator.ser: boot/obj/Run.Sig.ser
-boot/obj/Run.Op.ser: boot/obj/Run.CgOp.ser
-boot/obj/Run.OptBeta.ser: boot/obj/Run.CgOp.ser
boot/obj/Run.OptRxSimple.ser: boot/obj/Run.RxOp.ser
-boot/obj/Run.RxOp.ser: boot/obj/Run.CClass.ser
-boot/obj/Run.RxOp.ser: boot/obj/Run.CgOp.ser
-boot/obj/Run.Sig.ser: boot/obj/Run.CgOp.ser
View
2 src/CClass.pm6
@@ -1,3 +1,4 @@
+our ($CClass);
class CClass;
has $.terms;
@@ -90,3 +91,4 @@ our &internal = sub ($name) {
die "unknown internal cclass $name";
}
method internal($name) { &internal($name) }
+INIT { $CClass = CClass }
View
3 src/CgOp.pm6
@@ -1,3 +1,4 @@
+our ($CgOp);
class CgOp;
method _cgop(*@bits) {
@@ -115,3 +116,5 @@ method methodcall($obj, $name, *@args) {
my ($sig, $aout) = CgOp._process_arglist(@args);
CgOp._cgop('methodcall', $name, $sig, $obj, @$aout);
}
+
+INIT { $CgOp = CgOp }
View
18 src/NieczaActions.pm6
@@ -23,7 +23,7 @@ our ($Operator, $Operator_Method, $Operator_Replicate, $Operator_FlipFlop,
$Operator_DotEq, $Operator_Mixin, $Operator_Let, $Operator_PostCall,
$Operator_Function, $Operator_CompoundAssign);
-our ($CgOp, $CClass, $Sig, $SigParameter);
+our ($CgOp, $CClass, $Sig, $SigParameter, $OptRxSimple, $OptBeta, $Actions);
class NieczaActions;
@@ -459,8 +459,8 @@ method rxembed($/, $op, $) {
method op_for_regex($/, $rxop) {
my @lift = $rxop.oplift;
- my $ltm = ::GLOBAL::OptRxSimple.run_lad($rxop.lad);
- my ($orxop, $mb) = ::GLOBAL::OptRxSimple.run($rxop);
+ my $ltm = $OptRxSimple.run_lad($rxop.lad);
+ my ($orxop, $mb) = $OptRxSimple.run($rxop);
my $sub = self.thunk_sub($OpRegexBody.new(pos=>$/,
canback => $mb, pre => @lift, rxop => $orxop),
class => 'Regex', params => ['self'], :$ltm);
@@ -484,7 +484,7 @@ method quote:m ($/) {
method encapsulate_regex($/, $rxop, :$passcut = False) {
my @lift = $rxop.oplift;
my $lad = $rxop.lad;
- my ($nrxop, $mb) = ::GLOBAL::OptRxSimple.run($rxop);
+ my ($nrxop, $mb) = $OptRxSimple.run($rxop);
my $subop = self.thunk_sub(
$OpRegexBody.new(canback => $mb, pre => @lift, :$passcut,
rxop => $nrxop), ltm => $lad, class => 'Regex', params => ['self']);
@@ -545,9 +545,9 @@ method regex_def($/) {
}
my @lift = $ast.oplift;
- my $ltm = ::GLOBAL::OptRxSimple.run_lad($ast.lad);
+ my $ltm = $OptRxSimple.run_lad($ast.lad);
$*CURLEX<!sub>.set_ltm($ltm);
- ($ast, my $mb) = ::GLOBAL::OptRxSimple.run($ast);
+ ($ast, my $mb) = $OptRxSimple.run($ast);
if $<regex_block><onlystar> {
$*CURLEX<!sub>.finish_dispatcher('regex');
} else {
@@ -1410,7 +1410,7 @@ method circumfix:sym<{ }> ($/) {
if self.check_hash($/) {
make mkcall($/, '&_hash_constructor',
- ::GLOBAL::OptBeta.make_call($var));
+ $OptBeta.make_call($var));
}
}
@@ -3627,7 +3627,7 @@ method block_expr($/, $pb) {
method inliney_call($/, $block, *@parms) {
my $sym = self.gensym;
$*CURLEX<!sub>.add_my_sub($sym, $block);
- ::GLOBAL::OptBeta.make_call($sym, @parms);
+ $OptBeta.make_call($sym, @parms);
}
# this is intended to be called after parsing the longname for a sub,
@@ -3981,3 +3981,5 @@ method comp_unit($/) {
make $*unit;
}
+
+INIT { $Actions = NieczaActions }
View
3 src/NieczaPassSimplifier.pm6
@@ -1,5 +1,6 @@
our ($OpSimplePair, $OpCallSub, $OpLexical, $OpBuiltin, $OpTake,
$OpControl, $OpMakeJunction, $OpGeneralConst);
+our ($PassSimplifier);
class NieczaPassSimplifier;
@@ -176,3 +177,5 @@ sub run_optree($body, $op, $nv) {
$func($body, $nv, $invname, $op);
}
+
+INIT { $PassSimplifier = NieczaPassSimplifier; }
View
544 src/Op.pm6
@@ -1,6 +1,18 @@
-class Op;
+our ($CgOp, $Actions, $OptBeta);
+our ($Op, $OpAttribute, $OpBareBlock, $OpBuiltin, $OpCallLike, $OpCallMethod,
+ $OpCallSub, $OpCatchyWrapper, $OpCgOp, $OpConditional, $OpConstantDecl,
+ $OpContextVar, $OpDoOnceLoop, $OpForLoop, $OpGather, $OpGeneralConst,
+ $OpGeneralLoop, $OpGetBlock, $OpGetSlot, $OpHereStub, $OpImmedForLoop,
+ $OpIndirectVar, $OpLabelled, $OpLetVar, $OpLexical, $OpMakeCursor, $OpNum,
+ $OpParen, $OpRegexBody, $OpRequire, $OpShortCircuit, $OpSimplePair,
+ $OpSimpleParcel, $OpStart, $OpStateDecl, $OpStatementList,
+ $OpStringLiteral, $OpTemporize, $OpTry, $OpWhatever, $OpWhateverCode,
+ $OpWhen, $OpWhileLoop, $OpYada, $OpYouAreHere, $OpROify, $OpSetSlot,
+ $OpLexicalBind, $OpInterrogative, $OpShortCircuitAssign, $OpControl,
+ $OpMakeJunction, $OpSubDef, $OpTake, $OpAssign, $OpLet, $OpLetScope,
+ $OpTopicalHook, $OpLeaveHook, $OpLabelHook, $OpFlipFlop);
-use CgOp;
+class Op;
has Match $.pos;
@@ -12,21 +24,21 @@ method ctxzyg($) { map { $_, 1 }, self.zyg }
method cgop($body) {
if $!pos -> $p {
- CgOp.ann($p.CURSOR.lineof($p.pos), self.code($body));
+ $CgOp.ann($p.CURSOR.lineof($p.pos), self.code($body));
} else {
self.code($body);
}
}
method to_bind($/, $ro, $rhs) { #OK not used
$/.CURSOR.sorry("Cannot use bind operator with this LHS");
- ::Op::StatementList.new;
+ $OpStatementList.new;
}
# ick
method cgop_labelled($body, $label) {
if $!pos -> $p {
- CgOp.ann($p.CURSOR.lineof($p.pos), self.code_labelled($body, $label));
+ $CgOp.ann($p.CURSOR.lineof($p.pos), self.code_labelled($body, $label));
} else {
self.code_labelled($body, $label);
}
@@ -57,10 +69,10 @@ method const_value() { }
return $node.cgop($body) if $node ~~ Op;
return $node if $node !~~ List;
my ($cmd, @vals) = @$node;
- if ::GLOBAL::CgOp.^can($cmd) {
- ::GLOBAL::CgOp."$cmd"(|(map &rec, @vals));
+ if $CgOp.^can($cmd) {
+ $CgOp."$cmd"(|(map &rec, @vals));
} else {
- ::GLOBAL::CgOp._cgop($cmd, |(map &rec, @vals));
+ $CgOp._cgop($cmd, |(map &rec, @vals));
}
}
rec($.optree);
@@ -82,9 +94,9 @@ class StatementList is Op {
method const_value() { $!children[0].const_value if $!children == 1 }
method code($body) {
my @ch = map { $_.cgop($body) }, @$.children;
- my $end = @ch ?? pop(@ch) !! CgOp.corelex('Nil');
+ my $end = @ch ?? pop(@ch) !! $CgOp.corelex('Nil');
- CgOp.prog((map { CgOp.sink($_) }, @ch), $end);
+ $CgOp.prog((map { $CgOp.sink($_) }, @ch), $end);
}
}
@@ -100,19 +112,19 @@ class CallLike is Op {
}
method getargs() {
- $.args ?? @$.args !! (map { ::Op::Paren.new(inside => $_) },
+ $.args ?? @$.args !! (map { $OpParen.new(inside => $_) },
@$.positionals );
}
sub parsearglist($body, @args) {
my @out;
for @args -> $a {
- if $a.^isa(::Op::SimplePair) {
+ if $a.^isa($OpSimplePair) {
push @out, ":" ~ $a.key, $a.value.cgop($body);
- } elsif $a.^isa(::Op::CallSub) && $a.invocant.^isa(::Op::Lexical)
+ } elsif $a.^isa($OpCallSub) && $a.invocant.^isa($OpLexical)
&& $a.invocant.name eq '&prefix:<|>'
&& $a.positionals == 1 {
- push @out, 'flatcap', CgOp.fetch(CgOp.methodcall(
+ push @out, 'flatcap', $CgOp.fetch($CgOp.methodcall(
$a.positionals[0].cgop($body), 'Capture'));
} else {
push @out, $a.cgop($body);
@@ -134,18 +146,18 @@ class CallSub is CallLike {
method zyg() { $.invocant, @( $.args // $.positionals ) } # XXX callsame
method adverb($adv) {
- Op::CallSub.new(invocant => $.invocant, args => [ self.getargs, $adv ])
+ $OpCallSub.new(invocant => $.invocant, args => [ self.getargs, $adv ])
}
method code($body) {
- CgOp.subcall(CgOp.fetch($.invocant.cgop($body)), self.argblock($body));
+ $CgOp.subcall($CgOp.fetch($.invocant.cgop($body)), self.argblock($body));
}
method to_bind($/, $ro, $rhs) {
- if $!invocant ~~ ::Op::Lexical && substr($!invocant.name, 0, 15)
+ if $!invocant ~~ $OpLexical && substr($!invocant.name, 0, 15)
eq '&postcircumfix:' {
- return self.adverb(::Op::SimplePair.new(key => 'BIND_VALUE',
- value => $ro ?? ::Op::ROify.new(child => $rhs) !! $rhs));
+ return self.adverb($OpSimplePair.new(key => 'BIND_VALUE',
+ value => $ro ?? $OpROify.new(child => $rhs) !! $rhs));
}
nextsame;
}
@@ -159,7 +171,7 @@ class CallMethod is CallLike {
has $.ismeta = ''; # Str
method adverb($adv) {
- Op::CallMethod.new(receiver => $.receiver, name => $.name,
+ $OpCallMethod.new(receiver => $.receiver, name => $.name,
private => $.private, pclass => $.pclass,
ismeta => $!ismeta, args => [ self.getargs, $adv ])
}
@@ -168,34 +180,34 @@ class CallMethod is CallLike {
@( $.args // $.positionals ) } # XXX callsame
method code($body) {
- my $name = ($.name ~~ Op) ?? CgOp.obj_getstr($.name.cgop($body))
- !! CgOp.str($.name);
+ my $name = ($.name ~~ Op) ?? $CgOp.obj_getstr($.name.cgop($body))
+ !! $CgOp.str($.name);
my $meta = $!ismeta // '';
if $.private {
- my $kl = CgOp.class_ref('mo', $!pclass);
+ my $kl = $CgOp.class_ref('mo', $!pclass);
if $!pclass.kind eq 'prole' {
- $kl = CgOp.obj_llhow(CgOp.fetch(CgOp.scopedlex('$?CLASS')));
+ $kl = $CgOp.obj_llhow($CgOp.fetch($CgOp.scopedlex('$?CLASS')));
}
- CgOp.subcall(CgOp.stab_privatemethod($kl, $name),
+ $CgOp.subcall($CgOp.stab_privatemethod($kl, $name),
$.receiver.cgop($body), self.argblock($body));
} elsif $meta eq '^' {
- CgOp.let($.receiver.cgop($body), -> $r {
- CgOp.methodcall(CgOp.newscalar(CgOp.how(CgOp.fetch($r))),
+ $CgOp.let($.receiver.cgop($body), -> $r {
+ $CgOp.methodcall($CgOp.newscalar($CgOp.how($CgOp.fetch($r))),
$name, $r, self.argblock($body))});
} elsif $meta eq '?' {
# TODO maybe use a lower-level check
- CgOp.let($.receiver.cgop($body), -> $r { CgOp.let($name, -> $n {
- CgOp.ternary(
- CgOp.obj_getbool(CgOp.methodcall(CgOp.newscalar(CgOp.how(
- CgOp.fetch($r))), "can", $r, CgOp.box('Str',$n))),
- CgOp.methodcall($r, $n, self.argblock($body)),
- CgOp.scopedlex('Nil'))})});
+ $CgOp.let($.receiver.cgop($body), -> $r { $CgOp.let($name, -> $n {
+ $CgOp.ternary(
+ $CgOp.obj_getbool($CgOp.methodcall($CgOp.newscalar($CgOp.how(
+ $CgOp.fetch($r))), "can", $r, $CgOp.box('Str',$n))),
+ $CgOp.methodcall($r, $n, self.argblock($body)),
+ $CgOp.scopedlex('Nil'))})});
} elsif $!pclass {
- CgOp.methodcall($.receiver.cgop($body), 'dispatch:<::>',
- CgOp.class_ref('typeVar', $!pclass), CgOp.box("Str",$name),
+ $CgOp.methodcall($.receiver.cgop($body), 'dispatch:<::>',
+ $CgOp.class_ref('typeVar', $!pclass), $CgOp.box("Str",$name),
self.argblock($body));
} else {
- CgOp.methodcall($.receiver.cgop($body),
+ $CgOp.methodcall($.receiver.cgop($body),
$name, self.argblock($body));
}
}
@@ -208,16 +220,16 @@ class GetSlot is Op {
method zyg() { $.object }
method code($body) {
- my $kl = CgOp.class_ref('mo', $!type);
+ my $kl = $CgOp.class_ref('mo', $!type);
if $!type.kind eq 'prole' {
- $kl = CgOp.obj_llhow(CgOp.fetch(CgOp.scopedlex('$?CLASS')));
+ $kl = $CgOp.obj_llhow($CgOp.fetch($CgOp.scopedlex('$?CLASS')));
}
- CgOp.getslot($kl, $.name, 'var', CgOp.fetch($.object.cgop($body)));
+ $CgOp.getslot($kl, $.name, 'var', $CgOp.fetch($.object.cgop($body)));
}
method to_bind($/, $ro, $rhs) {
- return ::Op::SetSlot.new(:$!object, :$!name, :$!type,
- value => $ro ?? ::Op::ROify.new(child => $rhs) !! $rhs);
+ return $OpSetSlot.new(:$!object, :$!name, :$!type,
+ value => $ro ?? $OpROify.new(child => $rhs) !! $rhs);
}
}
@@ -230,13 +242,13 @@ class Op::SetSlot is Op {
method zyg() { $!object, $!value }
method code($body) {
- my $kl = CgOp.class_ref('mo', $!type);
+ my $kl = $CgOp.class_ref('mo', $!type);
if $!type.kind eq 'prole' {
- $kl = CgOp.obj_llhow(CgOp.fetch(CgOp.scopedlex('$?CLASS')));
+ $kl = $CgOp.obj_llhow($CgOp.fetch($CgOp.scopedlex('$?CLASS')));
}
- CgOp.let($!value.cgop($body), -> $v {
- CgOp.prog(CgOp.setslot($kl, $!name,
- CgOp.fetch($!object.cgop($body)), $v), $v) });
+ $CgOp.let($!value.cgop($body), -> $v {
+ $CgOp.prog($CgOp.setslot($kl, $!name,
+ $CgOp.fetch($!object.cgop($body)), $v), $v) });
}
}
@@ -257,7 +269,7 @@ class SimplePair is Op {
method zyg() { $.value }
method code($body) {
- CgOp._cgop("pair", CgOp.const(CgOp.string_var($.key)), $.value.cgop($body));
+ $CgOp._cgop("pair", $CgOp.const($CgOp.string_var($.key)), $.value.cgop($body));
}
}
@@ -270,7 +282,7 @@ class SimpleParcel is Op {
}
method code($body) {
- CgOp._cgop("comma", map { $_.cgop($body) }, @$.items);
+ $CgOp._cgop("comma", map { $_.cgop($body) }, @$.items);
}
}
@@ -283,15 +295,15 @@ class Interrogative is Op {
my $c;
given $!name {
when "VAR" {
- return CgOp.var_get_var($!receiver.cgop($body));
+ return $CgOp.var_get_var($!receiver.cgop($body));
}
- $c = CgOp.fetch($.receiver.cgop($body));
- when "HOW" { $c = CgOp.how($c); }
- when "WHO" { $c = CgOp.who($c); }
- when "WHAT" { $c = CgOp.obj_what($c); }
+ $c = $CgOp.fetch($.receiver.cgop($body));
+ when "HOW" { $c = $CgOp.how($c); }
+ when "WHO" { $c = $CgOp.who($c); }
+ when "WHAT" { $c = $CgOp.obj_what($c); }
default { die "Invalid interrogative $_"; }
}
- CgOp.newscalar($c);
+ $CgOp.newscalar($c);
}
}
@@ -310,7 +322,7 @@ class Yada is Op {
has $.kind = die "Yada.kind required"; #Str
method onlystub() { True }
- method code($ ) { CgOp.die(">>>Stub code executed") }
+ method code($ ) { $CgOp.die(">>>Stub code executed") }
}
class ShortCircuit is Op {
@@ -323,16 +335,16 @@ class ShortCircuit is Op {
method red2($sym, $o2) {
if $!kind eq '&&' {
- CgOp.ternary(CgOp.obj_getbool($sym), $o2, $sym);
+ $CgOp.ternary($CgOp.obj_getbool($sym), $o2, $sym);
}
elsif $!kind eq '||' {
- CgOp.ternary(CgOp.obj_getbool($sym), $sym, $o2);
+ $CgOp.ternary($CgOp.obj_getbool($sym), $sym, $o2);
}
elsif $!kind eq 'andthen' {
- CgOp.ternary(CgOp.obj_getdef($sym), $o2, $sym);
+ $CgOp.ternary($CgOp.obj_getdef($sym), $o2, $sym);
}
elsif $!kind eq '//' {
- CgOp.ternary(CgOp.obj_getdef($sym), $sym, $o2);
+ $CgOp.ternary($CgOp.obj_getdef($sym), $sym, $o2);
}
else {
die "That's not a sensible short circuit, now is it?";
@@ -344,7 +356,7 @@ class ShortCircuit is Op {
my $acc = (shift @r).cgop($body);
for @r {
- $acc = CgOp.let($_.cgop($body), -> $v { self.red2($v, $acc) });
+ $acc = $CgOp.let($_.cgop($body), -> $v { self.red2($v, $acc) });
}
$acc;
@@ -358,32 +370,32 @@ class ShortCircuitAssign is Op {
method zyg() { $.lhs, $.rhs }
method code($body) {
- my $sym = ::GLOBAL::NieczaActions.gensym;
- my $assn = CgOp.assign(CgOp.letvar($sym), $.rhs.cgop($body));
- my $cond = CgOp.letvar($sym);
+ my $sym = $Actions.gensym;
+ my $assn = $CgOp.assign($CgOp.letvar($sym), $.rhs.cgop($body));
+ my $cond = $CgOp.letvar($sym);
my $cassn;
if $.kind eq '&&' {
- $cassn = CgOp.ternary(CgOp.obj_getbool($cond), $assn, $cond);
+ $cassn = $CgOp.ternary($CgOp.obj_getbool($cond), $assn, $cond);
}
elsif $.kind eq '||' {
- $cassn = CgOp.ternary(CgOp.obj_getbool($cond), $cond, $assn);
+ $cassn = $CgOp.ternary($CgOp.obj_getbool($cond), $cond, $assn);
}
elsif $.kind eq 'andthen' {
- $cassn = CgOp.ternary(CgOp.obj_getdef($cond), $assn, $cond);
+ $cassn = $CgOp.ternary($CgOp.obj_getdef($cond), $assn, $cond);
}
elsif $.kind eq '//' {
- $cassn = CgOp.ternary(CgOp.obj_getdef($cond), $cond, $assn);
+ $cassn = $CgOp.ternary($CgOp.obj_getdef($cond), $cond, $assn);
}
- CgOp.letn($sym, $.lhs.cgop($body), $cassn);
+ $CgOp.letn($sym, $.lhs.cgop($body), $cassn);
}
}
class StringLiteral is Op {
has $.text = die "StringLiteral.text required"; # Str
- method code($) { CgOp.const(CgOp.string_var($.text)); }
+ method code($) { $CgOp.const($CgOp.string_var($.text)); }
method const_value() { $*unit.string_constant(~$!text) }
}
@@ -399,10 +411,10 @@ class Conditional is Op {
}
method code($body) {
- CgOp.ternary(
- CgOp.obj_getbool($.check.cgop($body)),
- ($.true ?? $.true.cgop($body) !! CgOp.corelex('Nil')),
- ($.false ?? $.false.cgop($body) !! CgOp.corelex('Nil')));
+ $CgOp.ternary(
+ $CgOp.obj_getbool($.check.cgop($body)),
+ ($.true ?? $.true.cgop($body) !! $CgOp.corelex('Nil')),
+ ($.false ?? $.false.cgop($body) !! $CgOp.corelex('Nil')));
}
}
@@ -417,21 +429,21 @@ class WhileLoop is Op {
method code($body) { self.code_labelled($body,'') }
method code_labelled($body, $l) {
- my $id = ::GLOBAL::NieczaActions.genid;
+ my $id = $Actions.genid;
my $cond = $!need_cond ??
- CgOp.prog(CgOp.letvar('!cond', $.check.cgop($body)),
- CgOp.obj_getbool(CgOp.letvar('!cond'))) !!
- CgOp.obj_getbool($.check.cgop($body));
+ $CgOp.prog($CgOp.letvar('!cond', $.check.cgop($body)),
+ $CgOp.obj_getbool($CgOp.letvar('!cond'))) !!
+ $CgOp.obj_getbool($.check.cgop($body));
my @loop =
- CgOp.whileloop(+$.until, +$.once, $cond,
- CgOp.sink(CgOp.xspan("redo$id", "next$id", 0, $.body.cgop($body),
+ $CgOp.whileloop(+$.until, +$.once, $cond,
+ $CgOp.sink($CgOp.xspan("redo$id", "next$id", 0, $.body.cgop($body),
1, $l, "next$id", 2, $l, "last$id", 3, $l, "redo$id"))),
- CgOp.label("last$id"),
- CgOp.corelex('Nil');
+ $CgOp.label("last$id"),
+ $CgOp.corelex('Nil');
- $!need_cond ?? CgOp.letn('!cond', CgOp.scopedlex('Any'), @loop) !!
- CgOp.prog(@loop)
+ $!need_cond ?? $CgOp.letn('!cond', $CgOp.scopedlex('Any'), @loop) !!
+ $CgOp.prog(@loop)
}
}
@@ -451,20 +463,20 @@ class GeneralLoop is Op {
method code($body) { self.code_labelled($body,'') }
method code_labelled($body, $l) {
- my $id = ::GLOBAL::NieczaActions.genid;
-
- CgOp.prog(
- ($.init ?? CgOp.sink($.init.cgop($body)) !! ()),
- CgOp.whileloop(0, 0,
- ($.cond ?? CgOp.obj_getbool($.cond.cgop($body)) !!
- CgOp.bool(1)),
- CgOp.prog(
- CgOp.sink(CgOp.xspan("redo$id", "next$id", 0,
+ my $id = $Actions.genid;
+
+ $CgOp.prog(
+ ($.init ?? $CgOp.sink($.init.cgop($body)) !! ()),
+ $CgOp.whileloop(0, 0,
+ ($.cond ?? $CgOp.obj_getbool($.cond.cgop($body)) !!
+ $CgOp.bool(1)),
+ $CgOp.prog(
+ $CgOp.sink($CgOp.xspan("redo$id", "next$id", 0,
$.body.cgop($body), 1, $l, "next$id",
2, $l, "last$id", 3, $l, "redo$id")),
- ($.step ?? CgOp.sink($.step.cgop($body)) !! ()))),
- CgOp.label("last$id"),
- CgOp.corelex('Nil'));
+ ($.step ?? $CgOp.sink($.step.cgop($body)) !! ()))),
+ $CgOp.label("last$id"),
+ $CgOp.corelex('Nil'));
}
}
@@ -474,17 +486,17 @@ class ForLoop is Op {
method zyg() { $.source, $.sink }
method code($body) {
- CgOp.methodcall(CgOp.subcall(CgOp.fetch(CgOp.corelex('&flat')),
- $.source.cgop($body)), 'map', CgOp.scopedlex($!sin));
+ $CgOp.methodcall($CgOp.subcall($CgOp.fetch($CgOp.corelex('&flat')),
+ $.source.cgop($body)), 'map', $CgOp.scopedlex($!sin));
}
method statement_level() {
my $body = $*CURLEX<!sub>.lookup_lex($!sink)[4];
- my $var = [ map { ::GLOBAL::NieczaActions.gensym },
+ my $var = [ map { $Actions.gensym },
0 ..^ $body.count ];
- ::Op::ImmedForLoop.new(source => $!source, var => $var,
- sink => ::GLOBAL::OptBeta.make_call($!sink,
- map { ::Op::LetVar.new(name => $_) }, @$var));
+ $OpImmedForLoop.new(source => $!source, var => $var,
+ sink => $OptBeta.make_call($!sink,
+ map { $OpLetVar.new(name => $_) }, @$var));
}
}
@@ -502,24 +514,24 @@ class ImmedForLoop is Op {
method code($body) { self.code_labelled($body, '') }
method code_labelled($body, $l) {
- my $id = ::GLOBAL::NieczaActions.genid;
+ my $id = $Actions.genid;
- CgOp.rnull(CgOp.letn(
- "!iter$id", CgOp.start_iter($.source.cgop($body)),
- (map { $_, CgOp.null('var') }, @$.var),
- CgOp.label("again$id"),
+ $CgOp.rnull($CgOp.letn(
+ "!iter$id", $CgOp.start_iter($.source.cgop($body)),
+ (map { $_, $CgOp.null('var') }, @$.var),
+ $CgOp.label("again$id"),
(map {
- CgOp.ncgoto("last$id",
- CgOp.iter_hasflat(CgOp.letvar("!iter$id"))),
- CgOp.letvar($_, CgOp.vvarlist_shift(CgOp.letvar("!iter$id")))
+ $CgOp.ncgoto("last$id",
+ $CgOp.iter_hasflat($CgOp.letvar("!iter$id"))),
+ $CgOp.letvar($_, $CgOp.vvarlist_shift($CgOp.letvar("!iter$id")))
}, @$.var),
- CgOp.sink(CgOp.xspan("redo$id", "next$id", 0,
+ $CgOp.sink($CgOp.xspan("redo$id", "next$id", 0,
$.sink.cgop($body),
1, $l, "next$id",
2, $l, "last$id",
3, $l, "redo$id")),
- CgOp.goto("again$id"),
- CgOp.label("last$id")));
+ $CgOp.goto("again$id"),
+ $CgOp.label("last$id")));
}
}
@@ -529,7 +541,7 @@ class Labelled is Op {
method zyg() { $.stmt }
method code($body) {
- CgOp.prog(CgOp.label("goto_$.name"),$.stmt.cgop_labelled($body,$.name));
+ $CgOp.prog($CgOp.label("goto_$.name"),$.stmt.cgop_labelled($body,$.name));
}
method statement_level() {
@@ -543,15 +555,15 @@ class When is Op {
method zyg() { $.match, $.body }
method code($body) {
- my $id = ::GLOBAL::NieczaActions.genid;
+ my $id = $Actions.genid;
- CgOp.ternary(CgOp.obj_getbool(CgOp.methodcall(
- $.match.cgop($body), 'ACCEPTS', CgOp.scopedlex('$_'))),
- CgOp.xspan("start$id", "end$id", 0, CgOp.prog(
- CgOp.control(6, CgOp.null('frame'), CgOp.int(-1),
- CgOp.null('str'), $.body.cgop($body))),
+ $CgOp.ternary($CgOp.obj_getbool($CgOp.methodcall(
+ $.match.cgop($body), 'ACCEPTS', $CgOp.scopedlex('$_'))),
+ $CgOp.xspan("start$id", "end$id", 0, $CgOp.prog(
+ $CgOp.control(6, $CgOp.null('frame'), $CgOp.int(-1),
+ $CgOp.null('str'), $.body.cgop($body))),
7, '', "end$id"),
- CgOp.corelex('Nil'));
+ $CgOp.corelex('Nil'));
}
}
@@ -564,12 +576,12 @@ class Start is Op {
method ctxzyg($f) { $.body, $f }
method code($body) {
- CgOp.ternary(
- CgOp.obj_getbool(CgOp.scopedlex($.condvar)),
- CgOp.corelex('Nil'),
- CgOp.prog(
- CgOp.sink(CgOp.assign(CgOp.scopedlex($.condvar),
- CgOp.box('Bool', CgOp.bool(1)))),
+ $CgOp.ternary(
+ $CgOp.obj_getbool($CgOp.scopedlex($.condvar)),
+ $CgOp.corelex('Nil'),
+ $CgOp.prog(
+ $CgOp.sink($CgOp.assign($CgOp.scopedlex($.condvar),
+ $CgOp.box('Bool', $CgOp.bool(1)))),
$.body.cgop($body)));
}
}
@@ -579,9 +591,9 @@ class Try is Op {
method zyg() { $.body }
method code($body) {
- my $id = ::GLOBAL::NieczaActions.genid;
+ my $id = $Actions.genid;
- CgOp.xspan("start$id", "end$id", 1, $.body.cgop($body),
+ $CgOp.xspan("start$id", "end$id", 1, $.body.cgop($body),
5, '', "end$id");
}
}
@@ -594,8 +606,8 @@ class Control is Op {
method zyg() { $.payload }
method code($body) {
- CgOp.control($.number, CgOp.null('frame'), CgOp.int(-1),
- ($.name eq '' ?? CgOp.null('str') !! CgOp.str($.name)),
+ $CgOp.control($.number, $CgOp.null('frame'), $CgOp.int(-1),
+ ($.name eq '' ?? $CgOp.null('str') !! $CgOp.str($.name)),
$.payload.cgop($body));
}
}
@@ -605,7 +617,7 @@ class MakeJunction is Op {
has @.zyg;
method code($body) {
- CgOp.makejunction($!typecode, map *.cgop($body), @!zyg)
+ $CgOp.makejunction($!typecode, map *.cgop($body), @!zyg)
}
}
@@ -614,9 +626,9 @@ class MakeJunction is Op {
method code($) {
if $.value ~~ Array {
- CgOp.const(CgOp.exactnum(|$.value))
+ $CgOp.const($CgOp.exactnum(|$.value))
} else {
- CgOp.const(CgOp.box('Num', CgOp.double($.value)))
+ $CgOp.const($CgOp.box('Num', $CgOp.double($.value)))
}
}
method const_value() { $*unit.numeric_constant(@($!value)) }
@@ -627,31 +639,31 @@ class Attribute is Op {
has $.name; # Str
has $.initializer; # Metamodel::Attribute
- method code($) { CgOp.corelex('Nil') }
+ method code($) { $CgOp.corelex('Nil') }
}
class Whatever is Op {
has $.slot = die "Whatever.slot required"; # Str
- method code($) { CgOp.corelex('$__Whatever') }
+ method code($) { $CgOp.corelex('$__Whatever') }
}
class WhateverCode is Op {
has $.ops = die "WhateverCode.ops required"; # Op
has $.vars = die "WhateverCode.vars required"; # Array of Str
has $.slot = die "WhateverCode.slot required"; # Str
- method code($) { CgOp.scopedlex($.slot) }
+ method code($) { $CgOp.scopedlex($.slot) }
}
class BareBlock is Op {
has $.var = die "BareBlock.var required"; # Str
- method code($) { CgOp.scopedlex($!var) }
+ method code($) { $CgOp.scopedlex($!var) }
method statement_level() {
$*CURLEX<!sub>.lookup_lex($!var).[4].set_run_once;
- ::GLOBAL::OptBeta.make_call($!var);
+ $OptBeta.make_call($!var);
}
}
@@ -660,7 +672,7 @@ class SubDef is Op {
has $.symbol; # Str, is rw
has $.once = False; # is rw, Bool
- method code($) { CgOp.scopedlex($.symbol) }
+ method code($) { $CgOp.scopedlex($.symbol) }
}
class Lexical is Op {
@@ -670,12 +682,12 @@ class Lexical is Op {
has $.list; # Bool
has $.hash; # Bool
- method code($) { CgOp.scopedlex($.name) }
+ method code($) { $CgOp.scopedlex($.name) }
method to_bind($/, $ro, $rhs) {
my @lex = $*CURLEX<!sub>.lookup_lex($!name) or
($/.CURSOR.sorry("Cannot find definition for binding???"),
- return ::Op::StatementList.new);
+ return $OpStatementList.new);
my $list = False;
my $type = $*CURLEX<!sub>.compile_get_pkg('Mu');
given @lex[0] {
@@ -690,35 +702,35 @@ class Lexical is Op {
nextsame;
}
}
- ::Op::LexicalBind.new(name => $!name, :$ro, :$rhs, :$list, :$type);
+ $OpLexicalBind.new(name => $!name, :$ro, :$rhs, :$list, :$type);
}
}
class ConstantDecl is Op {
has $.name = die "ConstantDecl.name required"; # Str
has $.init; # Op, is rw
- method code($ ) { CgOp.scopedlex($.name) }
+ method code($ ) { $CgOp.scopedlex($.name) }
}
class ContextVar is Op {
has $.name = die "ContextVar.name required"; # Str
has $.uplevel = 0; # Int
- method code($ ) { CgOp.context_get($!name, +$!uplevel); }
+ method code($ ) { $CgOp.context_get($!name, +$!uplevel); }
}
class Require is Op {
has $.unit = die "Require.unit required"; # Str
- method code($ ) { CgOp.rnull(CgOp.do_require($.unit)) }
+ method code($ ) { $CgOp.rnull($CgOp.do_require($.unit)) }
}
class Take is Op {
has $.value = die "Take.value required"; # Op
method zyg() { $.value }
- method code($body) { CgOp.take($.value.cgop($body)) }
+ method code($body) { $CgOp.take($.value.cgop($body)) }
}
class Gather is Op {
@@ -729,17 +741,17 @@ class Gather is Op {
# construct a GatherIterator with said frame
# construct a List from the iterator
- CgOp.subcall(CgOp.fetch(CgOp.corelex('&_gather')),
- CgOp.newscalar(CgOp.startgather(
- CgOp.fetch(CgOp.scopedlex($.var)))));
+ $CgOp.subcall($CgOp.fetch($CgOp.corelex('&_gather')),
+ $CgOp.newscalar($CgOp.startgather(
+ $CgOp.fetch($CgOp.scopedlex($.var)))));
}
}
class MakeCursor is Op {
method code($ ) {
- CgOp.prog(
- CgOp.scopedlex('$/', CgOp.newscalar(CgOp.rxcall('MakeCursor'))),
- CgOp.scopedlex('$/'));
+ $CgOp.prog(
+ $CgOp.scopedlex('$/', $CgOp.newscalar($CgOp.rxcall('MakeCursor'))),
+ $CgOp.scopedlex('$/'));
}
}
@@ -750,7 +762,7 @@ class MakeCursor is Op {
class LetVar is Op {
has $.name = die "LetVar.name required"; # Str
- method code($ ) { CgOp.letvar($.name) }
+ method code($ ) { $CgOp.letvar($.name) }
}
class RegexBody is Op {
@@ -770,46 +782,46 @@ class RegexBody is Op {
for keys $u {
push @mcaps, $_ if $u{$_} >= 2;
}
- my @pre = map { CgOp.sink($_.cgop($body)) }, @$.pre;
+ my @pre = map { $CgOp.sink($_.cgop($body)) }, @$.pre;
my @core = $.rxop.code($body);
- unshift @pre, CgOp.scopedlex('$*GOAL',
- CgOp.context_get('$*GOAL', 1)) if $body.has_lexical('$*GOAL');
+ unshift @pre, $CgOp.scopedlex('$*GOAL',
+ $CgOp.context_get('$*GOAL', 1)) if $body.has_lexical('$*GOAL');
- CgOp.prog(
+ $CgOp.prog(
@pre,
- CgOp.rxinit(CgOp.str($.name),
- CgOp.cast('cursor', CgOp.fetch(CgOp.scopedlex('self'))),
+ $CgOp.rxinit($CgOp.str($.name),
+ $CgOp.cast('cursor', $CgOp.fetch($CgOp.scopedlex('self'))),
+$.passcut),
- CgOp.rxpushcapture(CgOp.null('var'), @mcaps),
+ $CgOp.rxpushcapture($CgOp.null('var'), @mcaps),
@core,
- ($.canback ?? CgOp.rxend !! CgOp.rxfinalend),
- CgOp.label('backtrack'),
- CgOp.rxbacktrack,
- CgOp.null('var'));
+ ($.canback ?? $CgOp.rxend !! $CgOp.rxfinalend),
+ $CgOp.label('backtrack'),
+ $CgOp.rxbacktrack,
+ $CgOp.null('var'));
}
}
class YouAreHere is Op {
has $.unitname; # Str
method code($ ) {
- CgOp.you_are_here(CgOp.str($.unitname))
+ $CgOp.you_are_here($CgOp.str($.unitname))
}
}
class GetBlock is Op {
has Bool $.routine;
method code($body is copy) {
constant %good = (:Routine, :Submethod, :Regex, :Method, :Sub); #OK
- my $op = CgOp.callframe;
+ my $op = $CgOp.callframe;
loop {
die "No current routine" if !$body;
last if !$body.transparent &&
(!$!routine || %good{$body.class});
$body .= outer;
- $op = CgOp.frame_outer($op);
+ $op = $CgOp.frame_outer($op);
}
- CgOp.newscalar(CgOp.frame_sub($op));
+ $CgOp.newscalar($CgOp.frame_sub($op));
}
}
@@ -824,7 +836,7 @@ class Assign is Op {
method zyg() { $.lhs, $.rhs }
method code($body) {
- CgOp.assign($.lhs.cgop($body), $.rhs.cgop($body));
+ $CgOp.assign($.lhs.cgop($body), $.rhs.cgop($body));
}
}
@@ -838,7 +850,7 @@ class Builtin is Op {
method code($body) {
my @a = (map { $_.cgop($body) }, @$.args);
- CgOp._cgop($!name, |@a);
+ $CgOp._cgop($!name, |@a);
}
}
@@ -851,7 +863,7 @@ class Let is Op {
method zyg() { ($.to // Nil), $.in }
method code($body) {
- CgOp.letn($.var, ($.to ?? $.to.cgop($body) !! CgOp.null($.type)),
+ $CgOp.letn($.var, ($.to ?? $.to.cgop($body) !! $CgOp.null($.type)),
$.in.cgop($body));
}
}
@@ -864,7 +876,7 @@ class LetScope is Op {
method zyg() { $.inner }
method code($body) {
- CgOp.letscope(+$.transparent, @($.names), $.inner.cgop($body));
+ $CgOp.letscope(+$.transparent, @($.names), $.inner.cgop($body));
}
}
@@ -874,9 +886,9 @@ class TopicalHook is Op {
method zyg() { $.inner }
method code($body) {
- my $id = ::GLOBAL::NieczaActions.genid;
+ my $id = $Actions.genid;
- CgOp.xspan("start$id", "end$id", 0, $.inner.cgop($body),
+ $CgOp.xspan("start$id", "end$id", 0, $.inner.cgop($body),
6, '', "end$id");
}
}
@@ -886,9 +898,9 @@ class LeaveHook is Op {
method zyg() { $.inner }
method code($body) {
- my $id = ::GLOBAL::NieczaActions.genid;
+ my $id = $Actions.genid;
- CgOp.xspan("start$id", "end$id", 0, $.inner.cgop($body),
+ $CgOp.xspan("start$id", "end$id", 0, $.inner.cgop($body),
11, '', "end$id");
}
}
@@ -899,9 +911,9 @@ class LabelHook is Op {
method zyg() { $.inner }
method code($body) {
- my $id = ::GLOBAL::NieczaActions.genid;
+ my $id = $Actions.genid;
- CgOp.xspan("start$id", "end$id", 0, $.inner.cgop($body),
+ $CgOp.xspan("start$id", "end$id", 0, $.inner.cgop($body),
map({ 8, $_, "goto_$_" }, @$.labels));
}
}
@@ -915,18 +927,18 @@ class LexicalBind is Op {
method zyg() { $.rhs }
method code($body) {
- CgOp.prog(
- CgOp.scopedlex($!name, !defined($!type) ?? $!rhs.cgop($body) !!
- CgOp.newboundvar(+$!ro, +$!list,
- CgOp.class_ref('mo', @($!type)), $!rhs.cgop($body))),
- CgOp.scopedlex($!name))
+ $CgOp.prog(
+ $CgOp.scopedlex($!name, !defined($!type) ?? $!rhs.cgop($body) !!
+ $CgOp.newboundvar(+$!ro, +$!list,
+ $CgOp.class_ref('mo', @($!type)), $!rhs.cgop($body))),
+ $CgOp.scopedlex($!name))
}
}
class ROify is Op {
has $.child;
method zyg() { $.child }
- method code($body) { CgOp.newscalar(CgOp.fetch($!child.cgop($body))) }
+ method code($body) { $CgOp.newscalar($CgOp.fetch($!child.cgop($body))) }
}
class Op::StateDecl is Op {
@@ -944,9 +956,9 @@ class Op::DoOnceLoop is Op {
method code($body) { self.code_labelled($body,'') }
method code_labelled($body, $l) {
- my $id = ::GLOBAL::NieczaActions.genid;
+ my $id = $Actions.genid;
- CgOp.xspan("redo$id", "next$id", 0, $.body.cgop($body),
+ $CgOp.xspan("redo$id", "next$id", 0, $.body.cgop($body),
1, $l, "next$id", 2, $l, "next$id", 3, $l, "redo$id");
}
}
@@ -965,63 +977,63 @@ class Op::FlipFlop is Op {
method code($body) {
my @code;
- my $flop = "flop" ~ ::GLOBAL::NieczaActions.genid;
- my $check = "check" ~ ::GLOBAL::NieczaActions.genid;
- my $end = "end" ~ ::GLOBAL::NieczaActions.genid;
+ my $flop = "flop" ~ $Actions.genid;
+ my $check = "check" ~ $Actions.genid;
+ my $end = "end" ~ $Actions.genid;
my $use_hide = $!excl_lhs && !$!sedlike;
- push @code, CgOp.cgoto($flop,
- CgOp.obj_getbool(CgOp.scopedlex($!state_var)));
- push @code, CgOp.ncgoto($end, CgOp.obj_getbool($!lhs.cgop($body)));
+ push @code, $CgOp.cgoto($flop,
+ $CgOp.obj_getbool($CgOp.scopedlex($!state_var)));
+ push @code, $CgOp.ncgoto($end, $CgOp.obj_getbool($!lhs.cgop($body)));
if $!sedlike {
- push @code, CgOp.sink(CgOp._cgop("preinc",
- CgOp.scopedlex($!state_var)));
- push @code, CgOp.sink(CgOp.assign(CgOp.letvar("!ret"),
- CgOp.scopedlex($!state_var))) unless $!excl_lhs;
- push @code, CgOp.goto($end);
+ push @code, $CgOp.sink($CgOp._cgop("preinc",
+ $CgOp.scopedlex($!state_var)));
+ push @code, $CgOp.sink($CgOp.assign($CgOp.letvar("!ret"),
+ $CgOp.scopedlex($!state_var))) unless $!excl_lhs;
+ push @code, $CgOp.goto($end);
}
else {
- push @code, CgOp.letvar("!hide", CgOp.int(1)) if $use_hide;
+ push @code, $CgOp.letvar("!hide", $CgOp.int(1)) if $use_hide;
}
- push @code, CgOp.label($flop);
- push @code, CgOp.sink(CgOp._cgop("preinc",
- CgOp.scopedlex($!state_var)));
- push @code, CgOp.ncgoto($check, CgOp.obj_getbool($!rhs.cgop($body)));
- push @code, CgOp.sink(CgOp.assign(CgOp.letvar("!ret"),
- CgOp.scopedlex($!state_var))) unless $!excl_rhs;
- push @code, CgOp.sink(CgOp.assign(CgOp.scopedlex($!state_var),
- CgOp.const(CgOp.exactnum(10, 0))));
- push @code, CgOp.goto($end);
-
- push @code, CgOp.label($check);
+ push @code, $CgOp.label($flop);
+ push @code, $CgOp.sink($CgOp._cgop("preinc",
+ $CgOp.scopedlex($!state_var)));
+ push @code, $CgOp.ncgoto($check, $CgOp.obj_getbool($!rhs.cgop($body)));
+ push @code, $CgOp.sink($CgOp.assign($CgOp.letvar("!ret"),
+ $CgOp.scopedlex($!state_var))) unless $!excl_rhs;
+ push @code, $CgOp.sink($CgOp.assign($CgOp.scopedlex($!state_var),
+ $CgOp.const($CgOp.exactnum(10, 0))));
+ push @code, $CgOp.goto($end);
+
+ push @code, $CgOp.label($check);
# reached if !flopping, !ret will NOT be set at this point, we
# may be in a lhs if !sedlike
- push @code, CgOp.sink(CgOp.assign(CgOp.letvar("!ret"),
- CgOp.scopedlex($!state_var)));
-
- push @code, CgOp.label($end);
- push @code, CgOp.ternary(
- CgOp.compare('==', CgOp.letvar('!hide'), CgOp.int(1)),
- CgOp.sink(CgOp.assign(CgOp.letvar("!ret"),CgOp.string_var(''))),
- CgOp.prog()) if $use_hide;
-
- CgOp.letn(
- '!ret', CgOp.newrwscalar(CgOp.fetch(CgOp.string_var(''))),
- ($use_hide ?? ('!hide', CgOp.int(0)) !! ()),
+ push @code, $CgOp.sink($CgOp.assign($CgOp.letvar("!ret"),
+ $CgOp.scopedlex($!state_var)));
+
+ push @code, $CgOp.label($end);
+ push @code, $CgOp.ternary(
+ $CgOp.compare('==', $CgOp.letvar('!hide'), $CgOp.int(1)),
+ $CgOp.sink($CgOp.assign($CgOp.letvar("!ret"),$CgOp.string_var(''))),
+ $CgOp.prog()) if $use_hide;
+
+ $CgOp.letn(
+ '!ret', $CgOp.newrwscalar($CgOp.fetch($CgOp.string_var(''))),
+ ($use_hide ?? ('!hide', $CgOp.int(0)) !! ()),
@code,
- CgOp.letvar('!ret'));
+ $CgOp.letvar('!ret'));
}
}
class Op::Temporize is Op {
has Op $.var;
has Int $.mode;
method zyg() { $!var }
- method code($body) { CgOp.temporize($!var.code($body), CgOp.callframe,
- CgOp.int($!mode)) }
+ method code($body) { $CgOp.temporize($!var.code($body), $CgOp.callframe,
+ $CgOp.int($!mode)) }
}
class Op::IndirectVar is Op {
@@ -1031,9 +1043,9 @@ class Op::IndirectVar is Op {
method zyg() { $!name }
method code($body) {
- CgOp.sc_indir(CgOp.sc_root(), CgOp.obj_getstr($!name.cgop($body)),
- CgOp.bool($!bind_ro ?? 1 !! 0),
- $!bind ?? $!bind.cgop($body) !! CgOp.null('var'))
+ $CgOp.sc_indir($CgOp.sc_root(), $CgOp.obj_getstr($!name.cgop($body)),
+ $CgOp.bool($!bind_ro ?? 1 !! 0),
+ $!bind ?? $!bind.cgop($body) !! $CgOp.null('var'))
}
method to_bind($/, $ro, $rhs) { self.new(name => $!name, bind_ro => $ro,
@@ -1045,19 +1057,83 @@ class Op::CatchyWrapper is Op {
method zyg() { $!inner }
method code($body) {
- my $id = ::GLOBAL::NieczaActions.genid;
+ my $id = $Actions.genid;
- CgOp.xspan("start$id", "end$id", 0, CgOp.prog(
- CgOp.sink($!inner.cgop($body)),
- CgOp.return(CgOp.scopedlex('False')),
- CgOp.label("caught$id"),
- CgOp.scopedlex('True')),
+ $CgOp.xspan("start$id", "end$id", 0, $CgOp.prog(
+ $CgOp.sink($!inner.cgop($body)),
+ $CgOp.return($CgOp.scopedlex('False')),
+ $CgOp.label("caught$id"),
+ $CgOp.scopedlex('True')),
6, '', "caught$id");
}
}
class Op::GeneralConst is Op {
has $.value;
method const_value() { $!value }
- method code($) { CgOp.const($!value) }
+ method code($) { $CgOp.const($!value) }
+}
+
+INIT {
+ $Op = Op;
+ $OpCgOp = Op::CgOp;
+ $OpStatementList = Op::StatementList;
+ $OpCallLike = Op::CallLike;
+ $OpCallSub = Op::CallSub;
+ $OpCallMethod = Op::CallMethod;
+ $OpGetSlot = Op::GetSlot;
+ $OpSetSlot = Op::SetSlot;
+ $OpParen = Op::Paren;
+ $OpSimplePair = Op::SimplePair;
+ $OpSimpleParcel = Op::SimpleParcel;
+ $OpInterrogative = Op::Interrogative;
+ $OpHereStub = Op::HereStub;
+ $OpYada = Op::Yada;
+ $OpShortCircuit = Op::ShortCircuit;
+ $OpShortCircuitAssign = Op::ShortCircuitAssign;
+ $OpStringLiteral = Op::StringLiteral;
+ $OpConditional = Op::Conditional;
+ $OpWhileLoop = Op::WhileLoop;
+ $OpGeneralLoop = Op::GeneralLoop;
+ $OpForLoop = Op::ForLoop;
+ $OpImmedForLoop = Op::ImmedForLoop;
+ $OpLabelled = Op::Labelled;
+ $OpWhen = Op::When;
+ $OpStart = Op::Start;
+ $OpTry = Op::Try;
+ $OpControl = Op::Control;
+ $OpMakeJunction = Op::MakeJunction;
+ $OpNum = Op::Num;
+ $OpAttribute = Op::Attribute;
+ $OpWhatever = Op::Whatever;
+ $OpWhateverCode = Op::WhateverCode;
+ $OpBareBlock = Op::BareBlock;
+ $OpSubDef = Op::SubDef;
+ $OpLexical = Op::Lexical;
+ $OpConstantDecl = Op::ConstantDecl;
+ $OpContextVar = Op::ContextVar;
+ $OpRequire = Op::Require;
+ $OpTake = Op::Take;
+ $OpGather = Op::Gather;
+ $OpMakeCursor = Op::MakeCursor;
+ $OpLetVar = Op::LetVar;
+ $OpRegexBody = Op::RegexBody;
+ $OpYouAreHere = Op::YouAreHere;
+ $OpGetBlock = Op::GetBlock;
+ $OpAssign = Op::Assign;
+ $OpBuiltin = Op::Builtin;
+ $OpLet = Op::Let;
+ $OpLetScope = Op::LetScope;
+ $OpTopicalHook = Op::TopicalHook;
+ $OpLeaveHook = Op::LeaveHook;
+ $OpLabelHook = Op::LabelHook;
+ $OpLexicalBind = Op::LexicalBind;
+ $OpROify = Op::ROify;
+ $OpStateDecl = Op::StateDecl;
+ $OpDoOnceLoop = Op::DoOnceLoop;
+ $OpFlipFlop = Op::FlipFlop;
+ $OpTemporize = Op::Temporize;
+ $OpIndirectVar = Op::IndirectVar;
+ $OpCatchyWrapper = Op::CatchyWrapper;
+ $OpGeneralConst = Op::GeneralConst;
}
View
37 src/OpHelpers.pm6
@@ -1,3 +1,6 @@
+our ($Actions, $OpLetVar, $OpLexical, $Op, $OpLet, $OpCallSub, $OpLexicalBind,
+ $OpStatementList, $OpStringLiteral);
+
module OpHelpers;
sub mnode($M) is export {
@@ -7,55 +10,55 @@ sub mnode($M) is export {
}
sub mklet($value, $body) is export {
- my $var = ::GLOBAL::NieczaActions.gensym;
- ::Op::Let.new(var => $var, to => $value,
- in => $body(::Op::LetVar.new(name => $var)));
+ my $var = $Actions.gensym;
+ $OpLet.new(var => $var, to => $value,
+ in => $body($OpLetVar.new(name => $var)));
}
sub mkcall($/, $name, *@positionals) is export {
$/.CURSOR.mark_used($name);
$*CURLEX<!sub>.noninlinable if $name eq '&eval'; # HACK
- ::Op::CallSub.new(pos=>$/,
- invocant => ::Op::Lexical.new(pos=>$/, :$name), :@positionals);
+ $OpCallSub.new(pos=>$/,
+ invocant => $OpLexical.new(pos=>$/, :$name), :@positionals);
}
sub mklex($/, $name, *%_) is export {
$/.CURSOR.mark_used($name);
$*CURLEX<!sub>.noninlinable if $name eq '&eval'; # HACK
- ::Op::Lexical.new(pos=>$/, :$name, |%_);
+ $OpLexical.new(pos=>$/, :$name, |%_);
}
-sub mkbool($i) is export { ::Op::Lexical.new(name => $i ?? 'True' !! 'False') }
+sub mkbool($i) is export { $OpLexical.new(name => $i ?? 'True' !! 'False') }
sub mktemptopic($/, $item, $expr) is export {
mklet(mklex($/, '$_'), -> $old_ {
- ::Op::StatementList.new(pos=>$/, children => [
- ::Op::LexicalBind.new(:name<$_>, rhs => $item),
+ $OpStatementList.new(pos=>$/, children => [
+ $OpLexicalBind.new(:name<$_>, rhs => $item),
mklet($expr, -> $result {
- ::Op::StatementList.new(children => [
- ::Op::LexicalBind.new(:name<$_>, rhs => $old_),
+ $OpStatementList.new(children => [
+ $OpLexicalBind.new(:name<$_>, rhs => $old_),
$result]) }) ]) });
}
sub mkstringycat($/, *@strings) is export {
my @a;
for @strings -> $s {
- my $i = ($s !~~ ::GLOBAL::Op) ?? ::Op::StringLiteral.new(pos=>$/,
+ my $i = ($s !~~ $Op) ?? $OpStringLiteral.new(pos=>$/,
text => $s) !! $s;
# this *might* belong in an optimization pass
- if @a && @a[*-1] ~~ ::Op::StringLiteral &&
- $i ~~ ::Op::StringLiteral {
- @a[*-1] = ::Op::StringLiteral.new(pos=>$/,
+ if @a && @a[*-1] ~~ $OpStringLiteral &&
+ $i ~~ $OpStringLiteral {
+ @a[*-1] = $OpStringLiteral.new(pos=>$/,
text => (@a[*-1].text ~ $i.text));
} else {
push @a, $i;
}
}
if @a == 0 {
- return ::Op::StringLiteral.new(pos=>$/, text => "");
+ return $OpStringLiteral.new(pos=>$/, text => "");
} elsif @a == 1 {
- return (@a[0] ~~ ::Op::StringLiteral) ?? @a[0] !!
+ return (@a[0] ~~ $OpStringLiteral) ?? @a[0] !!
mkcall($/, '&prefix:<~>', @a[0]);
} else {
return mkcall($/, '&infix:<~>', @a);
View
101 src/Operator.pm6
@@ -2,9 +2,20 @@
# they abstract functions, macros, and some syntactic forms like
# method calls.
#
+our ($Operator, $Operator_Method, $Operator_Replicate, $Operator_FlipFlop,
+ $Operator_SmartMatch, $Operator_Comma, $Operator_Binding,
+ $Operator_ShortCircuit, $Operator_Ternary, $Operator_Temp,
+ $Operator_DotEq, $Operator_Mixin, $Operator_Let, $Operator_PostCall,
+ $Operator_Function, $Operator_CompoundAssign, $Operator_MetaNot);
+
+our ($OpCallSub, $OpCallMethod, $OpConditional, $OpContextVar, $OpFlipFlop,
+ $OpInterrogative, $OpLexical, $OpShortCircuit, $OpSimplePair,
+ $OpSimpleParcel, $OpStatementList, $OpTemporize, $OpWhatever);
+
+our ($Actions);
+
class Operator;
-use Sig;
use OpHelpers;
method with_args ($/, *@_) { !!! }
@@ -17,24 +28,24 @@ method as_function($/) {
method whatever_curry() { False }
method assignish() { False }
-method meta_assign() { ::Operator::CompoundAssign.new(base => self); }
-method meta_not() { ::Operator::MetaNot.new(base => self); }
+method meta_assign() { $Operator_CompoundAssign.new(base => self); }
+method meta_not() { $Operator_MetaNot.new(base => self); }
method meta_fun($/, $fun, $arity, *@extra) {
- ::Operator::Function.new(function => mklex($/, $fun), :$arity,
+ $Operator_Function.new(function => mklex($/, $fun), :$arity,
preargs => [ @extra, self.as_function($/) ])
}
method funop($/, $name, $arity, *@args) {
- ::Operator::Function.new(function => mklex($/, $name), :@args, :$arity)
+ $Operator_Function.new(function => mklex($/, $name), :@args, :$arity)
}
method wrap_in_function($/) {
my @args;
my $i = -self.arity;
- while $i++ { push @args, ::GLOBAL::NieczaActions.gensym }
+ while $i++ { push @args, $Actions.gensym }
my $do = self.with_args($/, map { mklex($/, $_) }, @args);
- ::GLOBAL::NieczaActions.block_expr($/,
- ::GLOBAL::NieczaActions.thunk_sub($do, params => @args));
+ $Actions.block_expr($/,
+ $Actions.thunk_sub($do, params => @args));
}
class Function is Operator {
@@ -53,12 +64,12 @@ class Function is Operator {
}
method with_args($/, *@args) {
- ::Op::CallSub.new(pos=>$/, invocant => $.function,
+ $OpCallSub.new(pos=>$/, invocant => $.function,
positionals => [ @$.preargs, @args, @$.args ])
}
method !name() {
- $.function.^isa(::Op::Lexical) ?? $.function.name !! ""
+ $.function.^isa($OpLexical) ?? $.function.name !! ""
}
method assignish() { self!name eq '&infix:<=>' }
@@ -74,7 +85,7 @@ class PostCall is Operator {
has $.args = [];
method with_args($/, *@args) {
- ::Op::CallSub.new(pos=>$/,
+ $OpCallSub.new(pos=>$/,
invocant => @args[0],
args => [ @$.args ]);
}
@@ -102,9 +113,9 @@ class Method is Operator {
if $!name eq any(< HOW WHAT WHO VAR >) && !$!private && !$!meta {
if $!args {
$/.CURSOR.sorry("Interrogative operator $.name does not take arguments");
- return ::Op::StatementList.new;
+ return $OpStatementList.new;
}
- ::Op::Interrogative.new(pos=>$/, receiver => @args[0],
+ $OpInterrogative.new(pos=>$/, receiver => @args[0],
name => $.name);
} else {
$*CURLEX<!sub>.noninlinable if $!name eq 'eval';
@@ -123,7 +134,7 @@ class Method is Operator {
} else {
$pclass = $.package;
}
- ::Op::CallMethod.new(pos=>$/,
+ $OpCallMethod.new(pos=>$/,
receiver => @args[0],
ismeta => $.meta,
name => $.name,
@@ -141,10 +152,10 @@ class Operator::FlipFlop is Operator {
has Bool $.sedlike;
method with_args($/, *@args) {
- my $state_var = ::GLOBAL::NieczaActions.gensym;
+ my $state_var = $Actions.gensym;
$*CURLEX<!sub>.add_state_name(Str, $state_var);
- @args[1] := mklex($/, 'False') if @args[1].^isa(::Op::Whatever);
- ::Op::FlipFlop.new(pos=>$/, :$state_var, :$!excl_lhs, :$!excl_rhs,
+ @args[1] := mklex($/, 'False') if @args[1].^isa($OpWhatever);
+ $OpFlipFlop.new(pos=>$/, :$state_var, :$!excl_lhs, :$!excl_rhs,
:$!sedlike, :lhs(@args[0]), :rhs(@args[1]))
}
@@ -155,7 +166,7 @@ class ShortCircuit is Operator {
has $.kind; # Str
method with_args($/, *@args) {
- ::Op::ShortCircuit.new(pos=>$/, kind => $.kind, args => [ @args ])
+ $OpShortCircuit.new(pos=>$/, kind => $.kind, args => [ @args ])
}
method whatever_curry() { True }
@@ -166,8 +177,8 @@ class CompoundAssign is Operator {
method with_args($/, *@rest) {
my $left = shift @rest;
- if $left.^isa(::Op::Lexical) {
- my $nlft = ::Op::Lexical.new(pos=>$/, name => $left.name);
+ if $left.^isa($OpLexical) {
+ my $nlft = $OpLexical.new(pos=>$/, name => $left.name);
mkcall($/, '&infix:<=>', $left, $.base.with_args($/, $nlft, @rest));
} else {
mklet($left, -> $ll {
@@ -209,48 +220,48 @@ class Comma is Operator {
method with_args($/, *@args) {
my @bits;
for @args -> $a {
- push @bits, $a.^isa(::Op::SimpleParcel) ?? @( $a.items ) !! $a;
+ push @bits, $a.^isa($OpSimpleParcel) ?? @( $a.items ) !! $a;
}
- ::Op::SimpleParcel.new(pos=>$/, items => @bits);
+ $OpSimpleParcel.new(pos=>$/, items => @bits);
}
method as_function($/) { mklex($/, '&infix:<,>') }
}
class Ternary is Operator {
has $.middle; # Op
method with_args($/, *@args) {
- ::Op::Conditional.new(pos=>$/, check => @args[0], true => $.middle,
+ $OpConditional.new(pos=>$/, check => @args[0], true => $.middle,
false => @args[1]);
}
}
class Temp is Operator {
method with_args($/, *@args) {
my $rarg = @args[0];
- if !$rarg.^isa(::Op::ContextVar) || $rarg.uplevel {
+ if !$rarg.^isa($OpContextVar) || $rarg.uplevel {
$*CURLEX<!sub>.noninlinable;
- return ::Op::Temporize.new(pos=>$/, mode => 0, var => $rarg);
+ return $OpTemporize.new(pos=>$/, mode => 0, var => $rarg);
}
my $hash = substr($rarg.name,0,1) eq '%';
my $list = substr($rarg.name,0,1) eq '@';
$*CURLEX<!sub>.add_my_name($rarg.name, :$hash, :$list);
mkcall($/, '&infix:<=>',
- ::Op::Lexical.new(name => $rarg.name, :$hash, :$list),
- ::Op::ContextVar.new(name => $rarg.name, uplevel => 1));
+ $OpLexical.new(name => $rarg.name, :$hash, :$list),
+ $OpContextVar.new(name => $rarg.name, uplevel => 1));
}
}
class Operator::Let is Operator {
method with_args($/, *@args) {
$*CURLEX<!sub>.noninlinable;
- return ::Op::Temporize.new(pos=>$/, mode => 1, var => @args[0]);
+ return $OpTemporize.new(pos=>$/, mode => 1, var => @args[0]);
}
}
class SmartMatch is Operator {
method as_function($/) { mklex($/, '&infix:<~~>') }
method with_args($/, *@args) {
- mktemptopic($/, @args[0], ::Op::CallMethod.new(receiver => @args[1],
+ mktemptopic($/, @args[0], $OpCallMethod.new(receiver => @args[1],
name => 'ACCEPTS', args => [ mklex($/, '$_') ]));
}
}
@@ -267,22 +278,42 @@ class DotEq is Operator {
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]);
+ mkcall($/, '&_doreplicate', $Actions.block_expr($/,
+ $Actions.thunk_sub(@args[0])), @args[1]);
}
}
# A bit hackish; handles the macro aspects of $foo does Role(23)
class Operator::Mixin is Operator::Function {
method with_args($/, *@args) {
- if @args[1] ~~ ::Op::CallSub {
- nextsame if @args[1].invocant ~~ ::Op::Lexical && @args[1].invocant.name eq '&_param_role_inst';
+ if @args[1] ~~ $OpCallSub {
+ nextsame if @args[1].invocant ~~ $OpLexical && @args[1].invocant.name eq '&_param_role_inst';
$/.CURSOR.sorry("Can only provide exactly one initial value to a mixin") unless @args[1].getargs.elems == 1;
- ::Op::CallSub.new(pos=>$/, invocant => $.function,
- args => [@args[0], @args[1].invocant, ::Op::SimplePair.new(
+ $OpCallSub.new(pos=>$/, invocant => $.function,
+ args => [@args[0], @args[1].invocant, $OpSimplePair.new(
key => 'value', value => @args[1].getargs[0] // mklex($/,'Nil'))]);
} else {
nextsame;
}
}
}
+
+INIT {
+ $Operator = Operator;
+ $Operator_Function = Operator::Function;
+ $Operator_PostCall = Operator::PostCall;
+ $Operator_Method = Operator::Method;
+ $Operator_FlipFlop = Operator::FlipFlop;
+ $Operator_ShortCircuit = Operator::ShortCircuit;
+ $Operator_CompoundAssign = Operator::CompoundAssign;
+ $Operator_MetaNot = Operator::MetaNot;
+ $Operator_Binding = Operator::Binding;
+ $Operator_Comma = Operator::Comma;
+ $Operator_Ternary = Operator::Ternary;
+ $Operator_Temp = Operator::Temp;
+ $Operator_Let = Operator::Let;
+ $Operator_SmartMatch = Operator::SmartMatch;
+ $Operator_DotEq = Operator::DotEq;
+ $Operator_Replicate = Operator::Replicate;
+ $Operator_Mixin = Operator::Mixin;
+}
View
12 src/OptBeta.pm6
@@ -1,18 +1,20 @@
-class OptBeta;
+our ($CgOp, $OpCallSub, $OpLexical, $OpCgOp, $OptBeta);
-use CgOp;
+class OptBeta;
# A simple Perl6 compiler generates a lot of expressions of the form
# (-> $x { block })($y), due to control structures and regexes. Try to clean
# that up here.
method make_call($var, *@params) {
- my $nonopt = ::Op::CallSub.new(
+ my $nonopt = $OpCallSub.new(
positionals => [ @params ],
- invocant => ::Op::Lexical.new(name => $var));
+ invocant => $OpLexical.new(name => $var));
my @lex = $*CURLEX<!sub>.lookup_lex($var) or return $nonopt;
return $nonopt unless @lex[0] eq 'sub' && @lex[4].is_inlinable;
@lex[4].set_inlined;
- return ::Op::CgOp.new(optree => [ "_inline", @lex[4], @params ]);
+ return $OpCgOp.new(optree => [ "_inline", @lex[4], @params ]);
}
+
+INIT { $OptBeta = OptBeta }
View
4 src/OptRxSimple.pm6
@@ -1,3 +1,4 @@
+our ($OptRxSimple);
class OptRxSimple;
use MONKEY_TYPING;
@@ -77,7 +78,7 @@ augment class RxOp::Sequence { #OK exist
augment class RxOp::Alt { #OK exist
method rxsimp($cut) {
- my @lads = map { ::GLOBAL::OptRxSimple.run_lad($_.lad) }, @$.zyg;
+ my @lads = map { OptRxSimple.run_lad($_.lad) }, @$.zyg;
my @kids = map *.rxsimp($cut), @$.zyg;
::RxOp::Alt.new(
optimized_lads => @lads,
@@ -225,3 +226,4 @@ augment class RxOp::BeforeString { #OK exist
augment class RxOp::NotBeforeString { #OK exist
method mayback() { False }
}
+INIT { $OptRxSimple = OptRxSimple }
View
285 src/RxOp.pm6
@@ -1,7 +1,16 @@
-class RxOp;
+our ($RxOp, $RxOpCapturing, $RxOpSym, $RxOpString, $RxOpVarString,
+ $RxOpQuantifier, $RxOpSequence, $RxOpConj, $RxOpAltBase, $RxOpSeqAlt,
+ $RxOpConfineLang, $RxOpCut, $RxOpBeforeString, $RxOpZeroWidthCCs,
+ $RxOpNotBeforeString, $RxOpZeroWidth, $RxOpNotBefore, $RxOpBefore,
+ $RxOpTilde, $RxOpSubrule, $RxOpSigspace, $RxOpCutLTM, $RxOpCutRule,
+ $RxOpCutBrack, $RxOpSetLang, $RxOpAlt, $RxOpCheckBlock, $RxOpSaveValue,
+ $RxOpVoidBlock, $RxOpStatement, $RxOpProtoRedis, $RxOpAny,
+ $RxOpQuantCClass, $RxOpCClassElem, $RxOpNone, $RxOpNewline,
+ $RxOpStringCap, $RxOpListPrim, $RxOpEndpoint);
+
+our ($CgOp, $CClass);
-use CgOp;
-use CClass;
+class RxOp;
has $.zyg = []; # Array of RxOp
@@ -10,7 +19,7 @@ method ctxopzyg() { map *.ctxopzyg, @$!zyg }
method oplift() { map *.oplift, @$!zyg }
method uncut() { self }
-method tocclist() { CClass }
+method tocclist() { $CClass }
# all that matters is 0-1-infty; $*in_quant valid here
method used_caps() {
@@ -58,18 +67,18 @@ class Sym is Capturing {
my $t = $.text;
# We aren't going to make a real Match unless somebody comes up with
# a good reason.
- my $p = CgOp.rxpushcapture(CgOp.string_var($t), @$.captures);
+ my $p = $CgOp.rxpushcapture($CgOp.string_var($t), @$.captures);
my $ic = $.igcase ?? "NoCase" !! "";
my @e = !defined($.endsym) ?? () !!
::RxOp::Subrule.new(method => $.endsym, :selfcut).code($body);
if chars($t) == 1 {
- $p, CgOp.rxbprim("ExactOne$ic", CgOp.char($t)), @e;
+ $p, $CgOp.rxbprim("ExactOne$ic", $CgOp.char($t)), @e;
} else {
- $p, CgOp.rxbprim("Exact$ic", CgOp.str($t)), @e;
+ $p, $CgOp.rxbprim("Exact$ic", $CgOp.str($t)), @e;
}
}
- method tocclist() { $!text.comb.map({ CClass.enum($_) }) }
+ method tocclist() { $!text.comb.map({ $CClass.enum($_) }) }
method lad() {
my $m = [ ($!igcase ?? 'StrNoCase' !! 'Str'), $!text ];
@@ -85,13 +94,13 @@ class String is RxOp {
my $t = $!text;
my $ic = $!igcase ?? "NoCase" !! "";
if chars($t) == 1 {
- CgOp.rxbprim("ExactOne$ic", CgOp.char($t));
+ $CgOp.rxbprim("ExactOne$ic", $CgOp.char($t));
} else {
- CgOp.rxbprim("Exact$ic", CgOp.str($t));
+ $CgOp.rxbprim("Exact$ic", $CgOp.str($t));
}
}
- method tocclist() { $!text.comb.map({ CClass.enum($_) }) }
+ method tocclist() { $!text.comb.map({ $CClass.enum($_) }) }
method lad() {
[ ($!igcase ?? 'StrNoCase' !! 'Str'), $!text ];
@@ -104,7 +113,7 @@ class VarString is RxOp {
method opzyg() { $!ops }
method code($body) {
- CgOp.rxbprim('Exact', CgOp.obj_getstr($!ops.cgop($body)));
+ $CgOp.rxbprim('Exact', $CgOp.obj_getstr($!ops.cgop($body)));
}
method lad() { ['Imp'] }
@@ -134,68 +143,68 @@ class Quantifier is RxOp {
}
method code($body) {
- my $rmin = $!closure ?? CgOp.letvar('!min') !! CgOp.int($!min);
- my $rmax = $!closure ?? CgOp.letvar('!max') !! CgOp.int($!max//2**31-1);
+ my $rmin = $!closure ?? $CgOp.letvar('!min') !! $CgOp.int($!min);
+ my $rmax = $!closure ?? $CgOp.letvar('!max') !! $CgOp.int($!max//2**31-1);
my $exit = self.label;
my $repeat = self.label;
my $sep = self.label;
my @code;
- push @code, CgOp.cgoto('backtrack',
- CgOp.compare('>', CgOp.int(0), $rmax)) if $!closure ||