Skip to content

Commit

Permalink
Fix binding to package-scoped arrays (yet again), @*ARGS and %*ENV fl…
Browse files Browse the repository at this point in the history
…attening
  • Loading branch information
sorear committed Jun 27, 2011
1 parent 1ea7e81 commit 27122b4
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 82 deletions.
4 changes: 2 additions & 2 deletions lib/CORE.setting
Expand Up @@ -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)) };
Expand Down
4 changes: 2 additions & 2 deletions src/NieczaActions.pm6
Expand Up @@ -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("");
}
Expand Down
2 changes: 1 addition & 1 deletion src/Op.pm6
Expand Up @@ -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;
Expand Down
77 changes: 0 additions & 77 deletions src/niecza
Expand Up @@ -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: <
Expand Down
7 changes: 7 additions & 0 deletions test2.pl
Expand Up @@ -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';

# {
Expand Down

0 comments on commit 27122b4

Please sign in to comment.