Skip to content
Browse files

Fix binding to package-scoped arrays (yet again), @*ARGS and %*ENV fl…

…attening
  • Loading branch information...
1 parent 1ea7e81 commit 27122b4143bc617e049dcae66bfbc05a29ec2d1b @sorear committed Jun 27, 2011
Showing with 12 additions and 82 deletions.
  1. +2 −2 lib/CORE.setting
  2. +2 −2 src/NieczaActions.pm6
  3. +1 −1 src/Op.pm6
  4. +0 −77 src/niecza
  5. +7 −0 test2.pl
View
4 lib/CORE.setting
@@ -1782,8 +1782,8 @@ INIT {
$PROCESS::IN ::= Q:CgOp { (box TextReader (treader_stdin)) };
$PROCESS::OUT ::= TextWriter.new;
$PROCESS::ARGFILES ::= IO::ArgFiles.new;
- @PROCESS::ARGS ::= Q:CgOp { (sysquery (i 0)) };
- %PROCESS::ENV ::= Q:CgOp { (sysquery (i 4)) };
+ @PROCESS::ARGS = Q:CgOp { (sysquery (i 0)) };
+ %PROCESS::ENV = Q:CgOp { (sysquery (i 4)) };
$PROCESS::EXECUTABLE_NAME ::= Q:CgOp { (sysquery (i 2)) };
$PROCESS::PROGRAM_NAME ::= Q:CgOp { (sysquery (i 1)) };
$PROCESS::BASE_DIRECTORY ::= Q:CgOp { (sysquery (i 3)) };
View
4 src/NieczaActions.pm6
@@ -916,8 +916,8 @@ method process_nibble($/, @bits, $prefix?) {
}
if $ast !~~ Op && defined($prefix) && $prefix ne "" {
- my $start_nl = !$n.from || ("\r\n".index(
- substr($/.orig, $n.from-1, 1).defined));
+ my $start_nl = !$n.from || "\r\n".index(
+ substr($n.orig, $n.from-1, 1)).defined;
$ast = $ast.split(/ ^^ [ <?{ $start_nl }> || <?after <[\r\n]> > ]
<before \h>[ $prefix || \h+ ]/).join("");
}
View
2 src/Op.pm6
@@ -648,7 +648,7 @@ class Lexical is Op {
$type = .typeconstraint // $type;
}
when ::Metamodel::Lexical::Common {
- $list = substr($!name,0,1) eq '%' || substr($!name,0,1) eq '@';
+ $list = substr(.name,0,1) eq '%' || substr(.name,0,1) eq '@';
}
default {
nextsame;
View
77 src/niecza
@@ -24,83 +24,6 @@ use Sig;
use STD;
augment class NieczaActions {
-sub mkstringycat($/, *@strings) {
- my @a;
- for @strings -> $s {
- my $i = ($s !~~ Op) ?? ::Op::StringLiteral.new(|node($/),
- text => $s) !! $s;
-
- # this *might* belong in an optimization pass
- if @a && @a[*-1] ~~ ::Op::StringLiteral &&
- $i ~~ ::Op::StringLiteral {
- @a[*-1] = ::Op::StringLiteral.new(|node($/),
- text => (@a[*-1].text ~ $i.text));
- } else {
- push @a, $i;
- }
- }
- if @a == 0 {
- return ::Op::StringLiteral.new(|node($/), text => "");
- } elsif @a == 1 {
- return (@a[0] ~~ ::Op::StringLiteral) ?? @a[0] !!
- mkcall($/, '&prefix:<~>', @a[0]);
- } else {
- return mkcall($/, '&infix:<~>', @a);
- }
-}
-method process_nibble($/, @bits, $prefix?) {
- my @acc;
- for @bits -> $n {
- my $ast = $n.ast;
-
- if $ast ~~ CClass {
- $n.CURSOR.sorry("Cannot use a character class in a string");
- $ast = "";
- }
-
- if $ast !~~ Op && defined($prefix) && $prefix ne "" {
- my $start_nl = !$n.from || "\r\n".index(
- substr($n.orig, $n.from-1, 1)).defined;
- $ast = $ast.split(/ ^^ [ <?{ $start_nl }> || <?after <[\r\n]> > ]
- <before \h>[ $prefix || \h+ ]/).join("");
- }
-
- push @acc, $ast;
- }
-
- my $post = $/.CURSOR.postprocessor;
- make mkstringycat($/, @acc);
-
- if $post eq 'null' {
- # already OK
- }
- # actually quotewords is a bit trickier than this...
- elsif $post eq 'words' || $post eq 'quotewords' {
- my $sl = $/.ast;
- if !$sl.^isa(::Op::StringLiteral) {
- make ::Op::CallMethod.new(|node($/), :name<words>, receiver => $sl);
- }
- else {
- my @tok = $sl.text.words;
- @tok = map { ::Op::StringLiteral.new(|node($/), text => $_) }, @tok;
-
- make ((@tok == 1) ?? @tok[0] !! ::Op::Paren.new(|node($/),
- inside => ::Op::SimpleParcel.new(|node($/), items => @tok)));
- }
- }
- elsif $post eq 'path' {
- # TODO could stand to be a lot fancier.
- make ::Op::CallMethod(|node($/), receiver => $/.ast, :name<IO>);
- }
- elsif $post eq 'run' {
- make mkcall($/, 'rungather', $/.ast);
- }
- else {
- $/.CURSOR.sorry("Unhandled postprocessor $post");
- }
-
- $/.ast;
-}
}
CgOp._register_ops: <
View
7 test2.pl
@@ -134,6 +134,13 @@
is $in.substr(0,8), 'Bar Foo', "spaces preserved after heredoc interpolation";
}
+{
+ ok @*ARGS.flattens, '@*ARGS is a flatteny thing';
+ ok %*ENV.flattens, '%*ENV is a flatteny thing';
+ @Y8158::z := [1,2,3];
+ ok @Y8158::z.flattens, 'binding to @foo::bar works';
+}
+
#is $?ORIG.substr(0,5), '# vim', '$?ORIG works';
# {

0 comments on commit 27122b4

Please sign in to comment.
Something went wrong with that request. Please try again.