Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[js] add a --source-map-debug flag to help with getting correcting so…
…urce maps
  • Loading branch information
pmurias committed Feb 13, 2016
1 parent b9ab65b commit 45927a6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/vm/js/Chunk.nqp
Expand Up @@ -61,6 +61,25 @@ class Chunk {
}
}

method source_map_debug() {
my $js := '';
for @!setup -> $part {
if nqp::isstr($part) {
$js := $js ~ $part;
} else {
$js := $js ~ $part.source_map_debug;
}
}

if nqp::defined($!node) && $!node.node {
my $node := $!node.node;
my $line := HLL::Compiler.lineof($node.orig(), $node.from(), :cache(1));
"/* LINE $line */\n" ~ $js ~ "/* END $line */"
} else {
$js;
}
}

method type() {
$!type;
}
Expand Down
4 changes: 4 additions & 0 deletions src/vm/js/Compiler.nqp
Expand Up @@ -1410,4 +1410,8 @@ class QAST::CompilerJS does DWIMYNameMangling does SerializeOnce {
method emit_with_source_map($ast) {
self.as_js_with_prelude($ast).with_source_map_info
}

method emit_with_source_map_debug($ast) {
self.as_js_with_prelude($ast).source_map_debug
}
}
4 changes: 3 additions & 1 deletion src/vm/js/HLL/Backend.nqp
Expand Up @@ -56,7 +56,9 @@ class HLLBackend::JavaScript {
my $backend := QAST::CompilerJS.new(nyi=>%adverbs<nyi> // 'ignore', cps=>%adverbs<cps> // 'on');


if %adverbs<source-map> {
if %adverbs<source-map-debug> {
$backend.emit_with_source_map_debug($qast);
} elsif %adverbs<source-map> {
$backend.emit_with_source_map($qast);
} else {
my $code := $backend.emit($qast);
Expand Down
1 change: 1 addition & 0 deletions src/vm/js/bin/nqp-js.nqp
Expand Up @@ -13,6 +13,7 @@ sub MAIN(*@ARGS) {

my @clo := $nqpcomp-cc.commandline_options();
@clo.push('source-map');
@clo.push('source-map-debug');
@clo.push('beautify');
@clo.push('cps=s');
@clo.push('nyi=s');
Expand Down

0 comments on commit 45927a6

Please sign in to comment.