Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Perlito5 - js - infrastructure for variable redeclaration

  • Loading branch information...
commit 5b2a060fac75153cc5d858ccbefc88b47a297e21 1 parent 88e5ab4
@fglock authored
View
6 html/perlito5.js
@@ -12205,6 +12205,9 @@ return (p5context([(p5str((p5pkg["Perlito5::Javascript2::LexicalBlock"]["v__"] |
var List_var_decl= [];
List_var_decl = p5list_to_a(p5call(v_decl, "emit_javascript2_get_decl", [], 1));
p5for_lex(function (v_arg) {
+ var v_perl5_name;
+ v_perl5_name = (p5call((v_arg || (v_arg = new p5HashRef({})))._hash_.p5hget('var'), "perl5_name", [], 0));
+ if ( p5bool((p5make_package("Perlito5")["v_VAR"] || (p5make_package("Perlito5")["v_VAR"] = new p5ArrayRef([])))._array_.p5aget_hash(0)._hash_.p5hget(p5str(v_perl5_name))) ) {};
List_str.p5push(p5list_to_a(p5call(v_arg, "emit_javascript2_init", [], 1)));
}, p5list_to_a(List_var_decl), false, "");
if ( !( (p5bool(p5call(v_decl, "isa", ['Perlito5::AST::Decl'], 0)) && (p5str(p5call(v_decl, "decl", [], 0)) == 'my'))) ) {
@@ -12216,6 +12219,9 @@ return (p5context([(p5str((p5pkg["Perlito5::Javascript2::LexicalBlock"]["v__"] |
var List_var_decl= [];
List_var_decl = p5list_to_a(p5call(v_last_statement, "emit_javascript2_get_decl", [], 1));
p5for_lex(function (v_arg) {
+ var v_perl5_name;
+ v_perl5_name = (p5call((v_arg || (v_arg = new p5HashRef({})))._hash_.p5hget('var'), "perl5_name", [], 0));
+ if ( p5bool((p5make_package("Perlito5")["v_VAR"] || (p5make_package("Perlito5")["v_VAR"] = new p5ArrayRef([])))._array_.p5aget_hash(0)._hash_.p5hget(p5str(v_perl5_name))) ) {};
List_str.p5push(p5list_to_a(p5call(v_arg, "emit_javascript2_init", [], 1)));
}, p5list_to_a(List_var_decl), false, "");
if ( (((p5bool(p5call(v_last_statement, "isa", ['Perlito5::AST::Apply'], 0)) && (p5str(p5call(v_last_statement, "code", [], 0)) == 'return')) && p5bool((v_self || (v_self = new p5HashRef({})))._hash_.p5hget('top_level'))) && p5bool((v_last_statement || (v_last_statement = new p5HashRef({})))._hash_.p5hget_array('arguments')._array_)) ) {
View
4 perlito5.pl
@@ -8694,6 +8694,8 @@ package Perlito5::Javascript2::LexicalBlock;
}
my @var_decl = $decl->emit_javascript2_get_decl();
for my $arg (@var_decl) {
+ my $perl5_name = $arg->{'var'}->perl5_name();
+ if ($Perlito5::VAR->[0]->{$perl5_name}) {}
push(@str, $arg->emit_javascript2_init())
}
if (!($decl->isa('Perlito5::AST::Decl') && $decl->decl() eq 'my')) {
@@ -8703,6 +8705,8 @@ package Perlito5::Javascript2::LexicalBlock;
if ($self->{'needs_return'} && $last_statement) {
my @var_decl = $last_statement->emit_javascript2_get_decl();
for my $arg (@var_decl) {
+ my $perl5_name = $arg->{'var'}->perl5_name();
+ if ($Perlito5::VAR->[0]->{$perl5_name}) {}
push(@str, $arg->emit_javascript2_init())
}
if ($last_statement->isa('Perlito5::AST::Apply') && $last_statement->code() eq 'return' && $self->{'top_level'} && @{$last_statement->{'arguments'}}) {
View
14 src5/lib/Perlito5/Javascript2/Emitter.pm
@@ -518,6 +518,13 @@ package Perlito5::Javascript2::LexicalBlock;
my @var_decl = $decl->emit_javascript2_get_decl();
for my $arg (@var_decl) {
+
+ my $perl5_name = $arg->{'var'}->perl5_name();
+ if ( $Perlito5::VAR->[0]->{$perl5_name} ) {
+ # TODO - create a new context for the redeclared variable
+ # print "redeclared $perl5_name\n"
+ }
+
push @str, $arg->emit_javascript2_init;
}
@@ -530,6 +537,13 @@ package Perlito5::Javascript2::LexicalBlock;
my @var_decl = $last_statement->emit_javascript2_get_decl();
for my $arg (@var_decl) {
+
+ my $perl5_name = $arg->{'var'}->perl5_name();
+ if ( $Perlito5::VAR->[0]->{$perl5_name} ) {
+ # TODO - create a new context for the redeclared variable
+ # print "redeclared $perl5_name\n"
+ }
+
push @str, $arg->emit_javascript2_init;
}
Please sign in to comment.
Something went wrong with that request. Please try again.