Skip to content

Commit

Permalink
RakuAST: avoid deparsing when we have access to the source.
Browse files Browse the repository at this point in the history
  • Loading branch information
niner committed May 2, 2024
1 parent 80ae959 commit 4988fb3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Raku/ast/code.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -2854,7 +2854,7 @@ class RakuAST::CurryThunk
method new(Str $original-expression) {
my $obj := nqp::create(self);
nqp::bindattr($obj, RakuAST::CurryThunk, '$!parameters', []);
nqp::bindattr($obj, RakuAST::CurryThunk, '$!original-expression', $original-expression);
nqp::bindattr($obj, RakuAST::CurryThunk, '$!original-expression', nqp::hllizefor($original-expression, 'Raku'));
$obj
}

Expand Down
2 changes: 1 addition & 1 deletion src/Raku/ast/expressions.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class RakuAST::Expression

# This creates the curry. Parameters are always added via CurryThunk.IMPL-ADD-PARAM
method IMPL-CURRY() {
my $thunk := RakuAST::CurryThunk.new(self.DEPARSE);
my $thunk := RakuAST::CurryThunk.new(self.origin ?? self.origin.Str !! self.DEPARSE);
self.wrap-with-thunk($thunk);
$thunk
}
Expand Down
3 changes: 2 additions & 1 deletion src/Raku/ast/name.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ class RakuAST::Name
}
else {
nqp::push_s($canon-parts, '') if nqp::elems($!parts) == 1;
nqp::push_s($canon-parts, '(' ~ $_.expr.DEPARSE ~ ')');
my $expr := $_.expr;
nqp::push_s($canon-parts, '(' ~ ($expr.origin ?? $expr.origin.Str !! $expr.DEPARSE) ~ ')');
}
}
else {
Expand Down
7 changes: 6 additions & 1 deletion src/Raku/ast/pair.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,12 @@ class RakuAST::ColonPair
my $value := self.simple-compile-time-quote-value;
$value := self.value.IMPL-INTERPRET(RakuAST::IMPL::InterpContext.new)
if !$value && self.value.IMPL-CAN-INTERPRET;
$!key ~ ($value ?? self.IMPL-QUOTE-VALUE($value) !! self.value.DEPARSE)
$!key ~ (
$value
?? self.IMPL-QUOTE-VALUE($value)
!! self.value.origin
?? self.value.origin.Str
!! self.value.DEPARSE)
}

method PRODUCE-IMPLICIT-LOOKUPS() {
Expand Down

0 comments on commit 4988fb3

Please sign in to comment.