Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[js] Use null for empty named arguments in regexes and immediate bloc…
…k calls.
  • Loading branch information
pmurias committed Feb 16, 2016
1 parent 1a8567e commit 56f5d83
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/vm/js/Compiler.nqp
Expand Up @@ -907,7 +907,7 @@ class QAST::CompilerJS does DWIMYNameMangling does SerializeOnce {
my $cont := self.unique_var('cont');
my $result := self.unique_var('result');

my @args := [$outer_ctx,'{}'];
my @args := [$outer_ctx, 'null'];

@args.push($cont);

Expand All @@ -920,7 +920,7 @@ class QAST::CompilerJS does DWIMYNameMangling does SerializeOnce {

ChunkCPS.new($T_OBJ, $result, $setup, $cont, :$node);
} else {
my @args := [$outer_ctx,'{}'];
my @args := [$outer_ctx, 'null'];
for @extra_args -> $arg {
@args.push($arg.expr);
$setup.push($arg);
Expand Down Expand Up @@ -1155,7 +1155,7 @@ class QAST::CompilerJS does DWIMYNameMangling does SerializeOnce {

my $main := self.as_js($main_block, :want($T_OBJ));

$body := Chunk.void($block_js, $main, $main.expr ~ ".\$apply([null, \{\}].concat(nqp.args(module)));\n");
$body := Chunk.void($block_js, $main, $main.expr ~ ".\$apply([null, null].concat(nqp.args(module)));\n");

} else {
$body := $block_js;
Expand Down
8 changes: 4 additions & 4 deletions src/vm/js/RegexCompiler.nqp
Expand Up @@ -33,7 +33,7 @@ class RegexCompiler {

Chunk.new($T_OBJ, $!cursor, [
"{$!label} = {$!initial_label};\n",
"$start = self['!cursor_start_all']({$*CTX}, \{\}).array;\n",
"$start = self['!cursor_start_all']({$*CTX}, null).array;\n",
"{$!cursor} = $start[0];\n",
"{$!target} = $start[1];\n",
"{$!pos} = nqp.to_int($start[2], $*CTX);\n",
Expand Down Expand Up @@ -65,7 +65,7 @@ class RegexCompiler {
self.goto($jump),

self.case($!done_label),
"{$!cursor}['!cursor_fail']({$*CTX}, \{\});\n",
"{$!cursor}['!cursor_fail']({$*CTX}, null);\n",
"break {$!js_loop_label}\n",
"\}\n\}\n"
]);
Expand Down Expand Up @@ -240,7 +240,7 @@ class RegexCompiler {

my sub call($invocant, $method, *@args) {
nqp::unshift(@args, $*CTX);
nqp::unshift(@args, 'nqp.named([])');
nqp::unshift(@args, 'null');
$invocant ~ "[" ~ quote_string($method) ~ "](" ~ nqp::join(",", @args) ~ ")";
}

Expand Down Expand Up @@ -280,7 +280,7 @@ class RegexCompiler {
else {
#TODO think if arguments are possible, etc.
my $block := $!compiler.as_js($node[0][0], :want($T_OBJ));
$call := Chunk.new($T_OBJ, $block.expr ~ ".\$call({$*CTX},nqp.named([]),$!cursor)", [$block]);
$call := Chunk.new($T_OBJ, $block.expr ~ ".\$call({$*CTX}, null, $!cursor)", [$block]);
}

my $testop := $node.negate ?? '>=' !! '<';
Expand Down

0 comments on commit 56f5d83

Please sign in to comment.