Skip to content

Commit

Permalink
Merge pull request #786 from vrurg/rakuast-origins
Browse files Browse the repository at this point in the history
Add support for RakuAST::Origin::Match
  • Loading branch information
vrurg committed Dec 20, 2022
2 parents 0724fd6 + 3685c47 commit 315372e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
8 changes: 7 additions & 1 deletion src/vm/jvm/QAST/Compiler.nqp
Expand Up @@ -4457,7 +4457,13 @@ class QAST::CompilerJAST {
for @stmts {
if $_.node && nqp::can($_.node,'orig') {
my $node := $_.node;
my $line := HLL::Compiler.lineof($node.orig(), $node.from(), :cache(1), :directives(0));
my $line;
if nqp::can($node, 'orig-line') {
$line := $node.orig-line();
}
else {
$line := HLL::Compiler.lineof($node.orig(), $node.from(), :cache(1), :directuves(0));
}
$il.append(JAST::Annotation.new( :line($line) ));
}

Expand Down
14 changes: 11 additions & 3 deletions src/vm/moar/QAST/QASTCompilerMAST.nqp
Expand Up @@ -1469,9 +1469,17 @@ my class MASTCompilerInstance {
method compile_annotation($qast) {
my $node := $qast.node;
if nqp::isconcrete($node) && nqp::can($node,'orig') {
my @line_file := HLL::Compiler.linefileof($node.orig(), $node.from(), :cache(1), :directives(1));
my $line := @line_file[0];
my $file := @line_file[1] || $!file;
my $line;
my $file;
if nqp::can($node, 'file') && nqp::can($node, 'line') {
$line := $node.line();
$file := $node.file();
}
else {
my @line_file := HLL::Compiler.linefileof($node.orig(), $node.from(), :cache(1), :directives(1));
$line := @line_file[0];
$file := @line_file[1] || $!file;
}
MAST::Annotated.new(:$file, :$line);
}
}
Expand Down

0 comments on commit 315372e

Please sign in to comment.