Skip to content

Commit

Permalink
Merge pull request #787 from vrurg/better-backtrace
Browse files Browse the repository at this point in the history
Better backtrace
  • Loading branch information
vrurg committed Dec 10, 2022
2 parents d51a1c5 + 5df3bfb commit f7e399c
Show file tree
Hide file tree
Showing 28 changed files with 25 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/HLL/Compiler.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ class HLL::Compiler does HLL::Backend::Default {
|| %adverbs<show-config>;
self.nqpevent(%adverbs<nqpevent>) if %adverbs<nqpevent>;

my @*comp_line_directives;
my $result;
my $error;
my $has_error := 0;
Expand Down
13 changes: 11 additions & 2 deletions src/HLL/Grammar.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,17 @@ of the match.
method panic(*@args) {
my $pos := self.pos();
my $target := self.target();
@args.push(' at line ');
@args.push(HLL::Compiler.lineof($target, $pos) + 1);
my $actual-file := nqp::getlexdyn('$?FILES');
my @line-file := HLL::Compiler.linefileof($target, $pos, :cache, :directives);
if $actual-file {
@args.unshift('===SORRY!=== Error while compiling ' ~ $actual-file ~ "\n");
}
if @line-file[1] && (!$actual-file || nqp::isne_s($actual-file, @line-file[1])) {
@args.push(' at ' ~ @line-file[1] ~ ':' ~ @line-file[0])
}
else {
@args.push(' at line ' ~ @line-file[0]);
}
@args.push(', near "');
@args.push(nqp::escape(nqp::substr($target, $pos, 10)));
@args.push('"');
Expand Down
2 changes: 1 addition & 1 deletion src/NQP/Actions.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class NQP::Actions is HLL::Actions {
my $sunk := $ast.ann('sink');
$ast := $sunk if nqp::defined($sunk);
if $ast.ann('bareblock') { $ast := block_immediate($ast[0]); }
$ast := QAST::Stmts.new($ast) if nqp::istype($ast, QAST::Node);
$ast := QAST::Stmts.new($ast, :node($_)) if nqp::istype($ast, QAST::Node);
$ast_list.push( $ast );
}
}
Expand Down
10 changes: 8 additions & 2 deletions src/NQP/Grammar.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ grammar NQP::Grammar is HLL::Grammar {
|| <?MARKED('ws')>
|| <!ww>
[ \v+
| '#' \N*
| <.comment>
| ^^ <.pod_comment>
| \h+
]*
Expand All @@ -71,11 +71,17 @@ grammar NQP::Grammar is HLL::Grammar {
# :dba('horizontal whitespace')
[
| ^^ <?before \h* '=' [ \w | '\\'] > <.pod_comment>
| \h* '#' \N*
| \h* <.comment>
| \h+
]
}

proto token comment {*}

token comment:sym<#> {
'#' {} \N*
}

token pod_comment {
^^ \h* '='
[
Expand Down
2 changes: 1 addition & 1 deletion src/vm/jvm/QAST/Compiler.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -4457,7 +4457,7 @@ 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));
my $line := HLL::Compiler.lineof($node.orig(), $node.from(), :cache(1), :directives(0));
$il.append(JAST::Annotation.new( :line($line) ));
}

Expand Down
Binary file modified src/vm/jvm/stage0/JASTNodes.jar
Binary file not shown.
Binary file modified src/vm/jvm/stage0/ModuleLoader.jar
Binary file not shown.
Binary file modified src/vm/jvm/stage0/NQPCORE.setting.jar
Binary file not shown.
Binary file modified src/vm/jvm/stage0/NQPHLL.jar
Binary file not shown.
Binary file modified src/vm/jvm/stage0/NQPP6QRegex.jar
Binary file not shown.
Binary file modified src/vm/jvm/stage0/QAST.jar
Binary file not shown.
Binary file modified src/vm/jvm/stage0/QASTNode.jar
Binary file not shown.
Binary file modified src/vm/jvm/stage0/QRegex.jar
Binary file not shown.
Binary file modified src/vm/jvm/stage0/nqp.jar
Binary file not shown.
Binary file modified src/vm/jvm/stage0/nqpmo.jar
Binary file not shown.
Binary file modified src/vm/moar/stage0/MASTNodes.moarvm
Binary file not shown.
Binary file modified src/vm/moar/stage0/MASTOps.moarvm
Binary file not shown.
Binary file modified src/vm/moar/stage0/ModuleLoader.moarvm
Binary file not shown.
Binary file modified src/vm/moar/stage0/NQPCORE.setting.moarvm
Binary file not shown.
Binary file modified src/vm/moar/stage0/NQPHLL.moarvm
Binary file not shown.
Binary file modified src/vm/moar/stage0/NQPP6QRegex.moarvm
Binary file not shown.
Binary file modified src/vm/moar/stage0/QAST.moarvm
Binary file not shown.
Binary file modified src/vm/moar/stage0/QASTNode.moarvm
Binary file not shown.
Binary file modified src/vm/moar/stage0/QRegex.moarvm
Binary file not shown.
Binary file modified src/vm/moar/stage0/nqp.moarvm
Binary file not shown.
Binary file modified src/vm/moar/stage0/nqpmo.moarvm
Binary file not shown.
3 changes: 2 additions & 1 deletion t/nqp/114-pod-panic.t
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ my $args := nqp::list($cmd, $cmdargs);

# expected first line output to stderr:
# Obsolete pod format ... , please use =begin/=end instead at line 4, near "\n"
my $regex := /^ \h* Obsolete \h+ pod \h+ format \h+ .+ ',' \h+ please \h+ use \h+ '=begin/=end' \h+ instead \h+ /;
my $regex := /^ '===SORRY!=== Error while compiling pod-test.nqp' \n \h*
Obsolete \h+ pod \h+ format \h+ .+ ',' \h+ please \h+ use \h+ '=begin/=end' \h+ instead \h+ /;

# running with only stderr capture"
my @arr := run-command($args, :stderr);
Expand Down
2 changes: 1 addition & 1 deletion tools/build/gen-cat.pl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@


foreach my $file (@files) {
print "# From $file\n\n";
print "#line 1 NQP::$file\n";
open(my $fh, "<:utf8", $file) or die "$file: $!";
my $in_omit = 0;
my @conds;
Expand Down

0 comments on commit f7e399c

Please sign in to comment.