Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Perlito5 - js - some support for my+if
  • Loading branch information
fglock committed Sep 12, 2013
1 parent efea5bc commit 91ab027
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
20 changes: 19 additions & 1 deletion html/perlito5.js
Expand Up @@ -13887,7 +13887,25 @@ return ((p5context([p5pkg["Perlito5::AST::Apply"].ref([p5pkg["Perlito5::AST::App
}
});
p5typeglob_set("Perlito5::AST::If", "emit_javascript2_get_decl", function (List__, p5want) {
return (p5context([], p5want));
try {
var v_self;
v_self = (List__.shift());
if ( (p5bool((v_self || (v_self = new p5HashRef({})))._hash_.p5hget('body')) && (p5str(p5pkg["Perlito5::AST::If"].ref([(v_self || (v_self = new p5HashRef({})))._hash_.p5hget('body')], 0)) != 'Perlito5::AST::Lit::Block')) ) {
throw(p5call((v_self || (v_self = new p5HashRef({})))._hash_.p5hget('body'), "emit_javascript2_get_decl", [], p5want))
};
if ( (p5bool((v_self || (v_self = new p5HashRef({})))._hash_.p5hget('otherwise')) && (p5str(p5pkg["Perlito5::AST::If"].ref([(v_self || (v_self = new p5HashRef({})))._hash_.p5hget('otherwise')], 0)) != 'Perlito5::AST::Lit::Block')) ) {
throw(p5call((v_self || (v_self = new p5HashRef({})))._hash_.p5hget('otherwise'), "emit_javascript2_get_decl", [], p5want))
};
return (p5context([], p5want));
}
catch(err) {
if ( err instanceof Error ) {
throw(err);
}
else {
return(err);
}
}
});
}, [0], false, ""
);
Expand Down
5 changes: 4 additions & 1 deletion perlito5.pl
Expand Up @@ -9859,7 +9859,10 @@ package Perlito5::AST::If;
return $s
};
sub Perlito5::AST::If::emit_javascript2_get_decl {
()
my $self = shift();
return $self->{'body'}->emit_javascript2_get_decl() if ($self->{'body'} && (ref($self->{'body'}) ne 'Perlito5::AST::Lit::Block'));
return $self->{'otherwise'}->emit_javascript2_get_decl() if ($self->{'otherwise'} && (ref($self->{'otherwise'}) ne 'Perlito5::AST::Lit::Block'));
return ()
}
};
package Perlito5::AST::When;
Expand Down
10 changes: 9 additions & 1 deletion src5/lib/Perlito5/Javascript2/Emitter.pm
Expand Up @@ -2616,7 +2616,15 @@ package Perlito5::AST::If;
}
return $s;
}
sub emit_javascript2_get_decl { () }
sub emit_javascript2_get_decl {
my $self = shift;
# NOTE - a declaration with modifier has undefined behaviour
return $self->{body}->emit_javascript2_get_decl
if $self->{body} && ref($self->{body}) ne 'Perlito5::AST::Lit::Block';
return $self->{otherwise}->emit_javascript2_get_decl
if $self->{otherwise} && ref($self->{otherwise}) ne 'Perlito5::AST::Lit::Block';
return ();
}
}


Expand Down

0 comments on commit 91ab027

Please sign in to comment.