Skip to content

Commit

Permalink
Fix compilation of CORE::infix:<*>(3, 3) (Radvendii)
Browse files Browse the repository at this point in the history
  • Loading branch information
sorear committed Dec 13, 2011
1 parent b273daf commit 758356b
Showing 1 changed file with 81 additions and 0 deletions.
81 changes: 81 additions & 0 deletions src/niecza
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,87 @@ class RxOp::Newline is RxOp {
augment class NieczaActions {
our $CCTrace = %*ENV<NIECZA_CC_TRACE> // False;

method process_name($/, :$declaring, :$defer, :$clean) {
return () unless defined $/;

my @ns = @( $<name>.ast<names> );
my $ext = '';
my $trail = @ns && !defined @ns[*-1];
pop @ns if $trail;

if !$clean {
for @( $<colonpair> ) {
$ext ~= $_.ast<ext> // (
$_.CURSOR.sorry("Invalid colonpair for name extension");
"";
)
}
}

for $defer ?? () !! @ns.grep(Op) {
$_ = ~self.trivial_eval($/, $_);
# XXX should this always stringify?
if $_ ~~ Cool {
$_ = ~$_;
} else {
$_ = "XXX";
$/.CURSOR.sorry("Name components must evaluate to strings");
}
}

if $declaring {
# class :: is ... { } is a placeholder for a lack of name
return () if $trail && !@ns;
$/.CURSOR.sorry("Illegal explicit declaration of a symbol table")
if $trail;
die "Unimplemented" if $defer;
return () unless @ns;
my $head = pop(@ns) ~ $ext;
return Any, $head unless @ns;

# the remainder is assumed to name an existing or new package
my $pkg;
$/.CURSOR.trymop({
$pkg = $*CURLEX<!sub>.compile_get_pkg(@ns, :auto);
});
return $pkg, $head;
}
else {
if $defer {
# The stuff returned here is processed by the variable rule,
# and also by method call generation

goto "dyn" if $trail;
goto "dyn" if $_.^isa(Op) for @ns;
my $pkg;
my @tail = @ns;
my $head = pop(@tail) ~ $ext;
unless @tail {
return { name => $head } unless @tail;
}
try { $pkg = $*CURLEX<!sub>.compile_get_pkg(@tail, :auto) };
goto "dyn" unless $pkg;

return { name => $head, pkg => $pkg };
dyn:
my @bits = map { $_, '::' }, @ns;
pop @bits if @bits;
push @bits, '::' if $trail;
push @bits, $ext;
return { iname => mkstringycat($/, @bits) };
}

$/.CURSOR.sorry("Class required, but symbol table name used instead")
if $trail;
return () unless @ns;
my $head = pop(@ns) ~ $ext;
my $pkg;
$/.CURSOR.trymop({
$pkg = $*CURLEX<!sub>.compile_get_pkg(@ns, $head);
});
return $pkg;
}
}
# UTS18 specifies a rule for "pulling up" negations in character classes,
# so we have to delay the negation, it seems; [0] = neg [1] = RxOp

Expand Down

0 comments on commit 758356b

Please sign in to comment.