Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Perlito5 - perl6 - make build-5to6browser by default; cleanup
  • Loading branch information
fglock committed Oct 3, 2013
1 parent 0d6f509 commit bb6da3c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -4,7 +4,7 @@ PERL5_INC := -I./lib5

# default actions

all : build-5to5 build-5js build-5browser
all : build-5to5 build-5js build-5browser build-5to6browser

test-all : test-5to5 test-5js

Expand Down
5 changes: 3 additions & 2 deletions perlito5.pl
Expand Up @@ -12479,6 +12479,7 @@ package Perlito5::AST::Call;
package Perlito5::AST::Apply;
{
my %op_infix_js = ('infix:<->', ' - ', 'infix:<*>', ' * ', 'infix:<x>', ' x ', 'infix:<+>', ' + ', 'infix:<.>', ' ~ ', 'infix:</>', ' / ', 'infix:<>>', ' > ', 'infix:<<>', ' < ', 'infix:<>=>', ' >= ', 'infix:<<=>', ' <= ', 'infix:<eq>', ' eq ', 'infix:<ne>', ' ne ', 'infix:<le>', ' le ', 'infix:<ge>', ' ge ', 'infix:<==>', ' == ', 'infix:<!=>', ' != ', 'infix:<..>', ' .. ', 'infix:<&&>', ' && ', 'infix:<||>', ' || ', 'infix:<and>', ' and ', 'infix:<or>', ' or ', 'infix:<//>', ' // ');
my %special_var = (chr(15), '$*OS');
sub Perlito5::AST::Apply::emit_perl6 {
my $self = shift();
my $level = shift();
Expand Down Expand Up @@ -12512,7 +12513,7 @@ package Perlito5::AST::Apply;
if (($code eq 'map')) {
my $fun = $self->{'arguments'}->[0];
my $list = $self->{'arguments'}->[1];
return ('(function (a_) { ' . 'var out = []; ' . 'if ( a_ == null ) { return out; }; ' . 'for(var i = 0; i < a_.length; i++) { ' . 'my $_ = a_[i]; ' . 'out.push(' . $fun->emit_perl6() . ')' . '}; ' . 'return out;' . ' })(' . $list->emit_perl6() . ')')
return ('(map ' . $fun->emit_perl6() . ', ' . $list->emit_perl6() . ')')
};
if ((($code eq 'bless') || ($code eq 'ref'))) {
return ('Perlito5::Perl6::Runtime::' . $code . '( ' . join(', ', map($_->emit_perl6(), @{$self->{'arguments'}})) . ')')
Expand All @@ -12522,7 +12523,7 @@ package Perlito5::AST::Apply;
};
if (($code eq 'prefix:<$>')) {
my $arg = $self->{'arguments'}->[0];
return '$*OS' if ($arg->isa('Perlito5::AST::Val::Buf') && ($arg->{'buf'} eq chr(15)));
return $special_var{$arg->{'buf'}} if ($arg->isa('Perlito5::AST::Val::Buf') && exists($special_var{$arg->{'buf'}}));
return ('$(' . $arg->emit_perl6() . ')')
};
if (($code eq 'prefix:<@>')) {
Expand Down
17 changes: 7 additions & 10 deletions src5/lib/Perlito5/Perl6/Emitter.pm
Expand Up @@ -376,6 +376,10 @@ package Perlito5::AST::Apply;
'infix:<//>' => ' // ',
);

my %special_var = (
chr(15) => '$*OS', # $^O
);

sub emit_perl6 {
my $self = shift;
my $level = shift;
Expand Down Expand Up @@ -421,15 +425,7 @@ package Perlito5::AST::Apply;
my $fun = $self->{arguments}->[0];
my $list = $self->{arguments}->[1];
return
'(function (a_) { '
. 'var out = []; '
. 'if ( a_ == null ) { return out; }; '
. 'for(var i = 0; i < a_.length; i++) { '
. 'my $_ = a_[i]; '
. 'out.push(' . $fun->emit_perl6 . ')'
. '}; '
. 'return out;'
. ' })(' . $list->emit_perl6() . ')'
'(map ' . $fun->emit_perl6 . ', ' . $list->emit_perl6() . ')'
}

if ( $code eq 'bless'
Expand All @@ -447,7 +443,8 @@ package Perlito5::AST::Apply;
if ( $code eq 'prefix:<$>' ) {
my $arg = $self->{arguments}->[0];

return '$*OS' if $arg->isa('Perlito5::AST::Val::Buf') && $arg->{buf} eq chr(15); # $^O
return $special_var{$arg->{buf}}
if $arg->isa('Perlito5::AST::Val::Buf') && exists $special_var{$arg->{buf}};

return '$(' . $arg->emit_perl6 . ')';
}
Expand Down

0 comments on commit bb6da3c

Please sign in to comment.