Permalink
Browse files

Fix Mu ~~ $smartmatch

  • Loading branch information...
1 parent b6269f8 commit 0e96ea225109ec5501fd54b35955f08de1f82026 @sorear committed Jun 3, 2011
Showing with 12 additions and 8 deletions.
  1. +5 −0 perf/perf.TODO
  2. +5 −4 src/Op.pm6
  3. +2 −4 src/OpHelpers.pm6
View
@@ -15,3 +15,8 @@ Reduce redundant Cursor creation for, e.g., { say 2 }
Reduce ContextHelper use in ws, or make it faster.
81537 Mu.new attr: 14093 RxOp.zyg,
+
+Junctions: $x == any($y,$z) could be optimized to a == that knows it
+is dealing with a junction. Once we have staticer types and can say
+that $x ~~ Any, then the == knows it has *exactly one* junction and
+can statically unroll the correct loop for epic win.
View
@@ -38,7 +38,7 @@ method code_labelled($body, $label) { self.code($body) } #OK not used
# binds. Further, we don't need to generate the bvalues explicitly, since
# we know they'll just be bound.
method code_bvalue($body, $ro, $rhscg) { #OK not used
- die "Illegal use of $.typename in bvalue context"; # XXX niecza
+ die "Illegal use of {self.WHAT.perl} in bvalue context";
}
method statement_level() { self }
@@ -633,7 +633,6 @@ class Attribute is Op {
has $.accessor; # Bool
has $.initializer; # Body, is rw
has $.typeconstraint; # Array of Str
- has $.sigil;
has $.rw;
method code($) { CgOp.corelex('Nil') }
@@ -702,7 +701,8 @@ class Lexical is Op {
method code_bvalue($ , $ro, $rhscg) {
CgOp.prog(
- CgOp.scopedlex($.name, CgOp.newboundvar(+?$ro, +(?($.list || $.hash)), $rhscg)),
+ CgOp.scopedlex($.name, defined($ro) ?? CgOp.newboundvar(+?$ro,
+ +(?($.list || $.hash)), $rhscg) !! $rhscg),
CgOp.scopedlex($.name));
}
}
@@ -740,7 +740,8 @@ class PackageVar is Op {
method code_bvalue($ , $ro, $rhscg) {
CgOp.prog(
CgOp.scopedlex($.slot,
- CgOp.newboundvar(+?$ro, +(?($.list || $.hash)), $rhscg)),
+ defined($ro) ?? CgOp.newboundvar(+?$ro,
+ +(?($.list || $.hash)), $rhscg) !! $rhscg),
CgOp.scopedlex($.slot));
}
}
View
@@ -20,12 +20,10 @@ sub mkbool($i) is export { ::Op::Lexical.new(name => $i ?? 'True' !! 'False') }
sub mktemptopic($/, $item, $expr) is export {
mklet(mklex($/, '$_'), -> $old_ {
::Op::StatementList.new(|node($/), children => [
- # XXX should be a raw bind
- ::Op::Bind.new(:!readonly, lhs => mklex($/, '$_'), rhs => $item),
+ ::Op::Bind.new(:readonly(Bool), lhs=>mklex($/,'$_'), rhs => $item),
mklet($expr, -> $result {
::Op::StatementList.new(children => [
- # XXX should be a raw bind
- ::Op::Bind.new(:!readonly, lhs => mklex($/, '$_'),
+ ::Op::Bind.new(:readonly(Bool), lhs => mklex($/, '$_'),
rhs => $old_),
$result]) }) ]) });
}

0 comments on commit 0e96ea2

Please sign in to comment.