Created
November 19, 2016 15:05
-
-
Save MasterDuke17/6a8beb41230b2b9f425b71b52ef52ab5 to your computer and use it in GitHub Desktop.
rakudo-jvm line directive support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/vm/jvm/QAST/Compiler.nqp b/src/vm/jvm/QAST/Compiler.nqp | |
index af9361c..3fd0426 100644 | |
--- a/src/vm/jvm/QAST/Compiler.nqp | |
+++ b/src/vm/jvm/QAST/Compiler.nqp | |
@@ -4192,8 +4192,10 @@ 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)); | |
- $il.append(JAST::Annotation.new( :line($line) )); | |
+ my @line_file := HLL::Compiler.linefileof($node.orig(), $node.from(), :cache(1), :directives(1)); | |
+ my $line := @line_file[0]; | |
+ my $filename := @line_file[1] || $*JCLASS.filename(); | |
+ $il.append(JAST::Annotation.new( :$line, :$filename )); | |
} | |
my $void := $all_void || $i != $resultchild; | |
diff --git a/src/vm/jvm/QAST/JASTNodes.nqp b/src/vm/jvm/QAST/JASTNodes.nqp | |
index f448db0..f210d3f 100644 | |
--- a/src/vm/jvm/QAST/JASTNodes.nqp | |
+++ b/src/vm/jvm/QAST/JASTNodes.nqp | |
@@ -29,6 +29,7 @@ class JAST::Class is JAST::Node { | |
method super(*@value) { @value ?? ($!super := @value[0]) !! $!super } | |
method serialized(*@value) { @value ?? ($!serialized := @value[0]) !! $!serialized } | |
method methods() { @!methods } | |
+ method filename() { $!filename } | |
method dump() { | |
my @dumped; | |
@@ -396,9 +397,10 @@ class JAST::Annotation is JAST::Node { | |
} | |
method line() { $!line } | |
- | |
+ | |
method dump(@dumped) { | |
- nqp::push(@dumped, ".line $!line") | |
+ nqp::push(@dumped, ".line $!line"); | |
+ nqp::push(@dumped, ".filename " ~ self.filename()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment