Permalink
Browse files

Perlito5 - js2 - fix namespace/bareword

  • Loading branch information...
1 parent 60cc0ca commit 8704d125564a2f0668bc0d7a6e3fa82d6106c870 @fglock committed Nov 30, 2012
Showing with 10 additions and 1 deletion.
  1. +3 −0 html/perlito5.js
  2. +3 −0 perlito5.pl
  3. +3 −0 src5/lib/Perlito5/Javascript2/Emitter.pm
  4. +1 −1 t5/01-perlito/26-syntax-namespace.t
View
3 html/perlito5.js
@@ -3182,6 +3182,9 @@ var p5100 = p5pkg['main'];
throw(p5context([('(p5want' + ' ? ' + p5str(p5call(v_self, "emit_javascript2", [v_level, 'list'], 0)) + ' : ' + p5str(p5call(v_self, "emit_javascript2", [v_level, 'list'], 0)) + '.length' + ')')], p5want));
};
};
+ if ( (p5str((v_self || (v_self = new p5HashRef({})))._hash_.p5hget('sigil')) == '::') ) {
+ throw(p5pkg["Perlito5::Javascript2"].escape_string(p5list_to_a((v_self || (v_self = new p5HashRef({})))._hash_.p5hget('namespace')), p5want));
+ };
if ( (p5str((v_self || (v_self = new p5HashRef({})))._hash_.p5hget('sigil')) == '&') ) {
throw(p5context([('p5pkg["' + p5str(p5or((v_self || (v_self = new p5HashRef({})))._hash_.p5hget('namespace'), function () { return p5pkg["Perlito5"]["v_PKG_NAME"] })) + '"]["' + p5str(v_str_name) + '"]')], p5want));
};
View
3 perlito5.pl
@@ -8527,6 +8527,9 @@ package Perlito5::AST::Var;
return (('(p5want' . ' ? ' . $self->emit_javascript2($level, 'list') . ' : ' . $self->emit_javascript2($level, 'list') . '.length' . ')'))
}
};
+ if (($self->{'sigil'} eq '::')) {
+ return (Perlito5::Javascript2::escape_string($self->{'namespace'}))
+ };
if (($self->{'sigil'} eq '&')) {
return (('p5pkg["' . (($self->{'namespace'} || $Perlito5::PKG_NAME)) . '"]["' . $str_name . '"]'))
};
View
3 src5/lib/Perlito5/Javascript2/Emitter.pm
@@ -999,6 +999,9 @@ package Perlito5::AST::Var;
}
}
+ if ( $self->{sigil} eq '::' ) {
+ return Perlito5::Javascript2::escape_string( $self->{namespace} );
+ }
if ( $self->{sigil} eq '&' ) {
return 'p5pkg["' . ($self->{namespace} || $Perlito5::PKG_NAME) . '"]["' . $str_name . '"]';
}
View
2 t5/01-perlito/26-syntax-namespace.t
@@ -45,7 +45,7 @@ my $x;
eval ' $x = B:: ';
$r = ">$x<";
print "not " if $r ne ">B<";
- say "ok 3 - double-colon after - B:: $x # TODO Parser bug"; # B
+ say "ok 3 - double-colon after - B:: $x"; # B
}
{

0 comments on commit 8704d12

Please sign in to comment.