# Do not edit this file - Generated by Perlito6 9.0
use v5;
use utf8;
use strict;
use warnings;
no warnings ('redefine', 'once', 'void', 'uninitialized', 'misc', 'recursion');
use Perlito6::Perl5::Runtime;
use Perlito6::Perl5::Prelude;
our $MATCH = Perlito6::Match->new();
{
package GLOBAL;
    sub new { shift; bless { @_ }, "GLOBAL" }

    # use v6 
;
    use Perlito6::AST;
    {
    package Perlito6::JavaScript;
        sub new { shift; bless { @_ }, "Perlito6::JavaScript" }
        sub tab {
            my $level = $_[0];
            (('    ') x $level)
        };
        ((my  $Hash_safe_char = bless {}, 'HASH') = do {
    (my  $Hash_a = bless {}, 'HASH');
    ($Hash_a->{'_'} = 1);
    ($Hash_a->{','} = 1);
    ($Hash_a->{'.'} = 1);
    ($Hash_a->{':'} = 1);
    ($Hash_a->{'-'} = 1);
    ($Hash_a->{'+'} = 1);
    ($Hash_a->{'*'} = 1);
    ($Hash_a->{' '} = 1);
    ($Hash_a->{'('} = 1);
    ($Hash_a->{')'} = 1);
    ($Hash_a->{'<'} = 1);
    ($Hash_a->{'>'} = 1);
    ($Hash_a->{'['} = 1);
    ($Hash_a->{']'} = 1);
    $Hash_a
});
        sub escape_string {
            my $s = $_[0];
            (my  $List_out = bless [], 'ARRAY');
            ((my  $tmp) = '');
            if (($s eq '')) {
                return scalar ((chr(39) . chr(39)))
            };
            for my $i ( @{(bless [0 .. (Main::chars($s, ) - 1)], 'ARRAY')} ) {
                ((my  $c) = substr($s, $i, 1));
                if (((((((($c ge 'a')) && (($c le 'z')))) || (((($c ge 'A')) && (($c le 'Z'))))) || (((($c ge '0')) && (($c le '9'))))) || exists($Hash_safe_char->{$c}))) {
                    ($tmp = ($tmp . $c))
                }
                else {
                    if (($tmp ne '')) {
                        push( @{$List_out}, (chr(39) . $tmp . chr(39)) )
                    };
                    push( @{$List_out}, ('String.fromCharCode(' . do {
    ord($c)
} . ')') );
                    ($tmp = '')
                }
            };
            if (($tmp ne '')) {
                push( @{$List_out}, (chr(39) . $tmp . chr(39)) )
            };
            return scalar (Main::join($List_out, ' + '))
        };
        ((my  $Hash_reserved = bless {}, 'HASH') = do {
    (my  $Hash_a = bless {}, 'HASH');
    ($Hash_a->{'print'} = 1);
    $Hash_a
});
        sub escape_function {
            my $s = $_[0];
            if (exists($Hash_reserved->{$s})) {
                return scalar (('f_' . $s))
            };
            return scalar ($s)
        }
    }

;
    {
    package Perlito6::JavaScript::LexicalBlock;
        sub new { shift; bless { @_ }, "Perlito6::JavaScript::LexicalBlock" }
        sub block { $_[0]->{block} };
        sub needs_return { $_[0]->{needs_return} };
        sub top_level { $_[0]->{top_level} };
        sub emit_javascript {
            my $self = $_[0];
            $self->emit_javascript_indented(0)
        };
        sub emit_javascript_indented {
            my $self = $_[0];
            my $level = $_[1];
            if ($self->{top_level}) {
                ((my  $block) = Perlito6::JavaScript::LexicalBlock->new(('block' => $self->block()), ('needs_return' => $self->needs_return()), ('top_level' => 0)));
                return scalar ((Perlito6::JavaScript::tab($level) . 'try ' . chr(123) . (chr(10)) . $block->emit_javascript_indented(($level + 1)) . chr(59) . (chr(10)) . Perlito6::JavaScript::tab($level) . chr(125) . (chr(10)) . Perlito6::JavaScript::tab($level) . 'catch(err) ' . chr(123) . (chr(10)) . Perlito6::JavaScript::tab(($level + 1)) . 'if ( err instanceof Error ) ' . chr(123) . (chr(10)) . Perlito6::JavaScript::tab(($level + 2)) . 'throw(err)' . chr(59) . (chr(10)) . Perlito6::JavaScript::tab(($level + 1)) . chr(125) . (chr(10)) . Perlito6::JavaScript::tab(($level + 1)) . 'else ' . chr(123) . (chr(10)) . Perlito6::JavaScript::tab(($level + 2)) . 'return(err)' . chr(59) . (chr(10)) . Perlito6::JavaScript::tab(($level + 1)) . chr(125) . (chr(10)) . Perlito6::JavaScript::tab($level) . chr(125)))
            };
            (my  $List_block = bless [], 'ARRAY');
            for ( @{(defined $self->{block} ? $self->{block} : ($self->{block} ||= bless([], 'ARRAY')))} ) {
                if (defined($_)) {
                    push( @{$List_block}, $_ )
                }
            };
            if (!($List_block)) {
                return scalar ((Perlito6::JavaScript::tab($level) . 'null' . chr(59)))
            };
            (my  $List_str = bless [], 'ARRAY');
            for my $decl ( @{$List_block} ) {
                if ((Main::isa($decl, 'Decl') && ($decl->decl() eq 'my'))) {
                    push( @{$List_str}, (Perlito6::JavaScript::tab($level) . $decl->emit_javascript_init()) )
                };
                if ((Main::isa($decl, 'Apply') && ($decl->code() eq 'infix:<' . chr(61) . '>'))) {
                    ((my  $var) = $decl->arguments()->[0]);
                    if ((Main::isa($var, 'Decl') && ($var->decl() eq 'my'))) {
                        push( @{$List_str}, (Perlito6::JavaScript::tab($level) . $var->emit_javascript_init()) )
                    }
                }
            };
            (my  $last_statement);
            if ($self->{needs_return}) {
                ($last_statement = pop( @{$List_block} ))
            };
            for my $decl ( @{$List_block} ) {
                if (!(((Main::isa($decl, 'Decl') && ($decl->decl() eq 'my'))))) {
                    push( @{$List_str}, ($decl->emit_javascript_indented($level) . chr(59)) )
                }
            };
            if (($self->{needs_return} && $last_statement)) {
                if (Main::isa($last_statement, 'If')) {
                    ((my  $cond) = $last_statement->cond());
                    ((my  $body) = $last_statement->body());
                    ((my  $otherwise) = $last_statement->otherwise());
                    if ((Main::isa($cond, 'Var') && ($cond->sigil() eq chr(64)))) {
                        ($cond = Apply->new(('code' => 'prefix:<' . chr(64) . '>'), ('arguments' => do {
    (my  $List_a = bless [], 'ARRAY');
    (my  $List_v = bless [], 'ARRAY');
    push( @{$List_a}, $cond );
    $List_a
})))
                    };
                    ($body = Perlito6::JavaScript::LexicalBlock->new(('block' => $body->stmts()), ('needs_return' => 1)));
                    push( @{$List_str}, (Perlito6::JavaScript::tab($level) . 'if ( ' . Perlito6::JavaScript::escape_function('bool') . '(' . $cond->emit_javascript() . ') ) ' . chr(123) . ' return (function () ' . chr(123) . (chr(10)) . $body->emit_javascript_indented(($level + 1)) . (chr(10)) . Perlito6::JavaScript::tab($level) . chr(125) . ')()' . chr(59) . ' ' . chr(125)) );
                    if ($otherwise) {
                        ($otherwise = Perlito6::JavaScript::LexicalBlock->new(('block' => $otherwise->stmts()), ('needs_return' => 1)));
                        push( @{$List_str}, (Perlito6::JavaScript::tab($level) . 'else ' . chr(123) . ' return (function () ' . chr(123) . (chr(10)) . $otherwise->emit_javascript_indented(($level + 1)) . (chr(10)) . Perlito6::JavaScript::tab($level) . chr(125) . ')()' . chr(59) . ' ' . chr(125)) )
                    }
                }
                else {
                    if (((Main::isa($last_statement, 'Apply') && ($last_statement->code() eq 'return')) || Main::isa($last_statement, 'For'))) {
                        push( @{$List_str}, $last_statement->emit_javascript_indented($level) )
                    }
                    else {
                        push( @{$List_str}, (Perlito6::JavaScript::tab($level) . 'return(' . $last_statement->emit_javascript() . ')') )
                    }
                }
            };
            return scalar ((Main::join($List_str, (chr(10))) . chr(59)))
        }
    }

;
    {
    package CompUnit;
        sub new { shift; bless { @_ }, "CompUnit" }
        sub attributes { $_[0]->{attributes} };
        sub methods { $_[0]->{methods} };
        sub emit_javascript {
            my $self = $_[0];
            $self->emit_javascript_indented(0)
        };
        sub emit_javascript_indented {
            my $self = $_[0];
            my $level = $_[1];
            ((my  $class_name) = Main::to_javascript_namespace($self->{name}));
            ((my  $str) = (chr(47) . chr(47) . ' class ' . $self->{name} . (chr(10)) . 'if (typeof ' . $class_name . ' ' . chr(33) . chr(61) . chr(61) . ' ' . chr(39) . 'object' . chr(39) . ') ' . chr(123) . (chr(10)) . '  ' . $class_name . ' ' . chr(61) . ' function() ' . chr(123) . chr(125) . chr(59) . (chr(10)) . '  ' . $class_name . ' ' . chr(61) . ' new ' . $class_name . chr(59) . (chr(10)) . '  ' . $class_name . '.' . Perlito6::JavaScript::escape_function('isa') . ' ' . chr(61) . ' function (s) ' . chr(123) . ' return s ' . chr(61) . chr(61) . ' ' . chr(39) . $self->{name} . chr(39) . chr(59) . ' ' . chr(125) . chr(59) . (chr(10)) . '  ' . $class_name . '.' . Perlito6::JavaScript::escape_function('perl') . ' ' . chr(61) . ' function () ' . chr(123) . ' return ' . chr(39) . $self->{name} . '.new(' . chr(39) . ' + Main._dump(this) + ' . chr(39) . ')' . chr(39) . chr(59) . ' ' . chr(125) . chr(59) . (chr(10)) . chr(125) . (chr(10)) . '(function () ' . chr(123) . (chr(10)) . '  var v__NAMESPACE ' . chr(61) . ' ' . $class_name . chr(59) . (chr(10))));
            for my $decl ( @{(defined $self->{body} ? $self->{body} : ($self->{body} ||= bless([], 'ARRAY')))} ) {
                if ((Main::isa($decl, 'Decl') && (($decl->decl() eq 'my')))) {
                    ($str = ($str . '  ' . $decl->emit_javascript_init()))
                };
                if ((Main::isa($decl, 'Apply') && ($decl->code() eq 'infix:<' . chr(61) . '>'))) {
                    ((my  $var) = $decl->arguments()->[0]);
                    if ((Main::isa($var, 'Decl') && ($var->decl() eq 'my'))) {
                        ($str = ($str . '  ' . $var->emit_javascript_init()))
                    }
                }
            };
            for my $decl ( @{(defined $self->{body} ? $self->{body} : ($self->{body} ||= bless([], 'ARRAY')))} ) {
                if ((Main::isa($decl, 'Decl') && (($decl->decl() eq 'has')))) {
                    ($str = ($str . '  ' . chr(47) . chr(47) . ' accessor ' . $decl->var()->name() . (chr(10)) . '  ' . $class_name . '.v_' . $decl->var()->name() . ' ' . chr(61) . ' null' . chr(59) . (chr(10)) . '  ' . $class_name . '.' . Perlito6::JavaScript::escape_function($decl->var()->name()) . ' ' . chr(61) . ' function () ' . chr(123) . ' return this.v_' . $decl->var()->name() . chr(59) . ' ' . chr(125) . chr(59) . (chr(10))))
                };
                if (Main::isa($decl, 'Method')) {
                    ((my  $sig) = $decl->sig());
                    ((my  $pos) = $sig->positional());
                    ((my  $invocant) = $sig->invocant());
                    ((my  $block) = Perlito6::JavaScript::LexicalBlock->new(('block' => $decl->block()), ('needs_return' => 1), ('top_level' => 1)));
                    ($str = ($str . '  ' . chr(47) . chr(47) . ' method ' . $decl->name() . (chr(10)) . '  ' . $class_name . '.' . Perlito6::JavaScript::escape_function($decl->name()) . ' ' . chr(61) . ' function (' . Main::join(([ map { $_->emit_javascript() } @{( $pos )} ]), ', ') . ') ' . chr(123) . (chr(10)) . '    var ' . $invocant->emit_javascript() . ' ' . chr(61) . ' this' . chr(59) . (chr(10)) . $block->emit_javascript_indented(($level + 1)) . (chr(10)) . '  ' . chr(125) . (chr(10)) . '  ' . $class_name . '.' . Perlito6::JavaScript::escape_function($decl->name()) . chr(59) . '  ' . chr(47) . chr(47) . ' v8 bug workaround' . (chr(10))))
                };
                if (Main::isa($decl, 'Sub')) {
                    ((my  $sig) = $decl->sig());
                    ((my  $pos) = $sig->positional());
                    ((my  $block) = Perlito6::JavaScript::LexicalBlock->new(('block' => $decl->block()), ('needs_return' => 1), ('top_level' => 1)));
                    ($str = ($str . '  ' . chr(47) . chr(47) . ' sub ' . $decl->name() . (chr(10)) . '  ' . $class_name . '.' . Perlito6::JavaScript::escape_function($decl->name()) . ' ' . chr(61) . ' function (' . Main::join(([ map { $_->emit_javascript() } @{( $pos )} ]), ', ') . ') ' . chr(123) . (chr(10)) . $block->emit_javascript_indented(($level + 1)) . (chr(10)) . '  ' . chr(125) . (chr(10)) . '  ' . $class_name . '.' . Perlito6::JavaScript::escape_function($decl->name()) . chr(59) . '  ' . chr(47) . chr(47) . ' v8 bug workaround' . (chr(10))))
                }
            };
            for my $decl ( @{(defined $self->{body} ? $self->{body} : ($self->{body} ||= bless([], 'ARRAY')))} ) {
                if ((((!(((Main::isa($decl, 'Decl') && (((($decl->decl() eq 'has')) || (($decl->decl() eq 'my')))))))) && (!((Main::isa($decl, 'Method'))))) && (!((Main::isa($decl, 'Sub')))))) {
                    ($str = ($str . ($decl)->emit_javascript_indented(($level + 1)) . chr(59)))
                }
            };
            ($str = ($str . chr(125) . ')()' . (chr(10))))
        };
        sub emit_javascript_program {
            my $comp_units = $_[0];
            ((my  $str) = '');
            for my $comp_unit ( @{(($comp_units))} ) {
                ($str = ($str . $comp_unit->emit_javascript()))
            };
            return scalar ($str)
        }
    }

;
    {
    package Val::Int;
        sub new { shift; bless { @_ }, "Val::Int" }
        sub emit_javascript {
            my $self = $_[0];
            $self->emit_javascript_indented(0)
        };
        sub emit_javascript_indented {
            my $self = $_[0];
            my $level = $_[1];
            (Perlito6::JavaScript::tab($level) . $self->{int})
        }
    }

;
    {
    package Val::Bit;
        sub new { shift; bless { @_ }, "Val::Bit" }
        sub emit_javascript {
            my $self = $_[0];
            $self->emit_javascript_indented(0)
        };
        sub emit_javascript_indented {
            my $self = $_[0];
            my $level = $_[1];
            (Perlito6::JavaScript::tab($level) . (($self->{bit} ? 'true' : 'false')))
        }
    }

;
    {
    package Val::Num;
        sub new { shift; bless { @_ }, "Val::Num" }
        sub emit_javascript {
            my $self = $_[0];
            $self->emit_javascript_indented(0)
        };
        sub emit_javascript_indented {
            my $self = $_[0];
            my $level = $_[1];
            (Perlito6::JavaScript::tab($level) . $self->{num})
        }
    }

;
    {
    package Val::Buf;
        sub new { shift; bless { @_ }, "Val::Buf" }
        sub emit_javascript {
            my $self = $_[0];
            $self->emit_javascript_indented(0)
        };
        sub emit_javascript_indented {
            my $self = $_[0];
            my $level = $_[1];
            (Perlito6::JavaScript::tab($level) . Perlito6::JavaScript::escape_string($self->{buf}))
        }
    }

;
    {
    package Lit::Block;
        sub new { shift; bless { @_ }, "Lit::Block" }
        sub emit_javascript {
            my $self = $_[0];
            $self->emit_javascript_indented(0)
        };
        sub emit_javascript_indented {
            my $self = $_[0];
            my $level = $_[1];
            ((my  $sig) = 'v__');
            if ($self->{sig}) {
                ($sig = $self->{sig}->emit_javascript_indented(($level + 1)))
            };
            return scalar ((Perlito6::JavaScript::tab($level) . ('(function (' . $sig . ') ' . chr(123) . chr(10)) . (Perlito6::JavaScript::LexicalBlock->new(('block' => (defined $self->{stmts} ? $self->{stmts} : ($self->{stmts} ||= bless([], 'ARRAY')))), ('needs_return' => 1)))->emit_javascript_indented(($level + 1)) . (chr(10)) . Perlito6::JavaScript::tab($level) . chr(125) . ')'))
        }
    }

;
    {
    package Lit::Array;
        sub new { shift; bless { @_ }, "Lit::Array" }
        sub emit_javascript {
            my $self = $_[0];
            $self->emit_javascript_indented(0)
        };
        sub emit_javascript_indented {
            my $self = $_[0];
            my $level = $_[1];
            ((my  $ast) = $self->expand_interpolation());
            return scalar ($ast->emit_javascript_indented($level))
        }
    }

;
    {
    package Lit::Hash;
        sub new { shift; bless { @_ }, "Lit::Hash" }
        sub emit_javascript {
            my $self = $_[0];
            $self->emit_javascript_indented(0)
        };
        sub emit_javascript_indented {
            my $self = $_[0];
            my $level = $_[1];
            ((my  $ast) = $self->expand_interpolation());
            return scalar ($ast->emit_javascript_indented($level))
        }
    }

;
    {
    package Index;
        sub new { shift; bless { @_ }, "Index" }
        sub emit_javascript {
            my $self = $_[0];
            $self->emit_javascript_indented(0)
        };
        sub emit_javascript_indented {
            my $self = $_[0];
            my $level = $_[1];
            (Perlito6::JavaScript::tab($level) . $self->{obj}->emit_javascript() . '[' . $self->{index_exp}->emit_javascript() . ']')
        }
    }

;
    {
    package Lookup;
        sub new { shift; bless { @_ }, "Lookup" }
        sub emit_javascript {
            my $self = $_[0];
            $self->emit_javascript_indented(0)
        };
        sub emit_javascript_indented {
            my $self = $_[0];
            my $level = $_[1];
            ((my  $str) = '');
            ((my  $var) = $self->{obj});
            (my  $var_js);
            if (Main::isa($var, 'Lookup')) {
                ((my  $var1) = $var->obj());
                ((my  $var1_js) = $var1->emit_javascript());
                ($str = ($str . 'if (' . $var1_js . ' ' . chr(61) . chr(61) . ' null) ' . chr(123) . ' ' . $var1_js . ' ' . chr(61) . ' ' . chr(123) . chr(125) . ' ' . chr(125) . chr(59) . ' '));
                ($var_js = ($var1_js . '[' . $var->index_exp()->emit_javascript() . ']'))
            }
            else {
                ($var_js = $var->emit_javascript())
            };
            ($str = ($str . 'if (' . $var_js . ' ' . chr(61) . chr(61) . ' null) ' . chr(123) . ' ' . $var_js . ' ' . chr(61) . ' ' . chr(123) . chr(125) . ' ' . chr(125) . chr(59) . ' '));
            ((my  $index_js) = $self->{index_exp}->emit_javascript());
            ($str = ($str . 'return (' . $var_js . '[' . $index_js . '] ' . ')' . chr(59) . ' '));
            return scalar ((Perlito6::JavaScript::tab($level) . '(function () ' . chr(123) . ' ' . $str . chr(125) . ')()'))
        }
    }

;
    {
    package Var;
        sub new { shift; bless { @_ }, "Var" }
        sub emit_javascript {
            my $self = $_[0];
            $self->emit_javascript_indented(0)
        };
        sub emit_javascript_indented {
            my $self = $_[0];
            my $level = $_[1];
            ((my  $table) = do {
    (my  $Hash_a = bless {}, 'HASH');
    ($Hash_a->{chr(36)} = 'v_');
    ($Hash_a->{chr(64)} = 'List_');
    ($Hash_a->{chr(37)} = 'Hash_');
    ($Hash_a->{chr(38)} = 'Code_');
    $Hash_a
});
            ((my  $ns) = '');
            if ($self->{namespace}) {
                ($ns = (Main::to_javascript_namespace($self->{namespace}) . '.'))
            };
            ((($self->{twigil} eq '.')) ? (('v_self.v_' . $self->{name} . '')) : (((($self->{name} eq chr(47))) ? (($table->{$self->{sigil}} . 'MATCH')) : (($table->{$self->{sigil}} . $ns . $self->{name})))))
        };
        sub plain_name {
            my $self = $_[0];
            if ($self->{namespace}) {
                return scalar (($self->{namespace} . '.' . $self->{name}))
            };
            return scalar ($self->{name})
        }
    }

;
    {
    package Proto;
        sub new { shift; bless { @_ }, "Proto" }
        sub emit_javascript {
            my $self = $_[0];
            $self->emit_javascript_indented(0)
        };
        sub emit_javascript_indented {
            my $self = $_[0];
            my $level = $_[1];
            (Perlito6::JavaScript::tab($level) . Main::to_javascript_namespace($self->{name}))
        }
    }

;
    {
    package Call;
        sub new { shift; bless { @_ }, "Call" }
        ((my  $Hash_method_js = bless {}, 'HASH') = do {
    (my  $Hash_a = bless {}, 'HASH');
    ($Hash_a->{'perl'} = 'perl');
    ($Hash_a->{'isa'} = 'isa');
    ($Hash_a->{'id'} = 'id');
    ($Hash_a->{'scalar'} = 'scalar');
    ($Hash_a->{'keys'} = 'keys');
    ($Hash_a->{'values'} = 'values');
    ($Hash_a->{'pairs'} = 'pairs');
    ($Hash_a->{'elems'} = 'elems');
    ($Hash_a->{'say'} = 'say');
    ($Hash_a->{'chars'} = 'chars');
    $Hash_a
});
        ((my  $Hash_method_native_js = bless {}, 'HASH') = do {
    (my  $Hash_a = bless {}, 'HASH');
    ($Hash_a->{'join'} = 'join');
    ($Hash_a->{'split'} = 'split');
    ($Hash_a->{'shift'} = 'shift');
    ($Hash_a->{'unshift'} = 'unshift');
    ($Hash_a->{'push'} = 'push');
    ($Hash_a->{'pop'} = 'pop');
    $Hash_a
});
        sub emit_javascript {
            my $self = $_[0];
            $self->emit_javascript_indented(0)
        };
        sub emit_javascript_indented {
            my $self = $_[0];
            my $level = $_[1];
            ((my  $invocant) = $self->{invocant}->emit_javascript());
            if (($invocant eq 'self')) {
                ($invocant = 'v_self')
            };
            if (($self->{method} eq 'new')) {
                ((my  $str) = do {
    (my  $List_a = bless [], 'ARRAY');
    (my  $List_v = bless [], 'ARRAY');
    $List_a
});
                for my $field ( @{(defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY')))} ) {
                    if ((Main::isa($field, 'Apply') && ($field->code() eq 'infix:<' . chr(61) . '>>'))) {
                        push( @{$str}, ('v_' . $field->arguments()->[0]->buf() . ': ' . $field->arguments()->[1]->emit_javascript()) )
                    }
                    else {
                        die('Error in constructor, field: ', Main::perl($field, ))
                    }
                };
                return scalar (('(function () ' . chr(123) . ' ' . 'var tmp ' . chr(61) . ' ' . chr(123) . Main::join($str, ',') . chr(125) . chr(59) . ' ' . 'tmp.__proto__ ' . chr(61) . ' ' . Main::to_javascript_namespace($invocant) . chr(59) . ' ' . 'return tmp' . chr(59) . ' ' . chr(125) . ')()'))
            };
            if (exists($Hash_method_js->{$self->{method}})) {
                if (($self->{hyper})) {
                    return scalar (('(function (a_) ' . chr(123) . ' ' . 'var out ' . chr(61) . ' []' . chr(59) . ' ' . 'if ( a_ ' . chr(61) . chr(61) . ' null ) ' . chr(123) . ' return out' . chr(59) . ' ' . chr(125) . chr(59) . ' ' . 'for(var i ' . chr(61) . ' 0' . chr(59) . ' i < a_.length' . chr(59) . ' i++) ' . chr(123) . ' ' . 'out.push( ' . Perlito6::JavaScript::escape_function($self->{method}) . '(a_[i]) ) ' . chr(125) . ' return out' . chr(59) . ' ' . chr(125) . ')(' . $invocant . ')'))
                };
                return scalar ((Perlito6::JavaScript::escape_function($self->{method}) . '(' . $invocant . (((defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY'))) ? (', ' . Main::join(([ map { $_->emit_javascript() } @{( (defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY'))) )} ]), ', ')) : '')) . ')'))
            };
            if (exists($Hash_method_native_js->{$self->{method}})) {
                return scalar (($invocant . '.' . $self->{method} . '(' . Main::join(([ map { $_->emit_javascript() } @{( (defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY'))) )} ]), ', ') . ')'))
            };
            ((my  $meth) = $self->{method});
            if (($self->{hyper})) {
                return scalar (('(function (a_) ' . chr(123) . ' ' . 'var out ' . chr(61) . ' []' . chr(59) . ' ' . 'if ( a_ ' . chr(61) . chr(61) . ' null ) ' . chr(123) . ' return out' . chr(59) . ' ' . chr(125) . chr(59) . ' ' . 'for(var i ' . chr(61) . ' 0' . chr(59) . ' i < a_.length' . chr(59) . ' i++) ' . chr(123) . ' ' . 'out.push( a_[i].' . Perlito6::JavaScript::escape_function($meth) . '(' . Main::join(([ map { $_->emit_javascript() } @{( (defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY'))) )} ]), ', ') . ') ) ' . chr(125) . chr(59) . ' ' . 'return out' . chr(59) . ' ' . chr(125) . ')(' . $invocant . ')'))
            };
            if (($meth eq 'postcircumfix:<( )>')) {
                return scalar (('(' . $invocant . ')(' . Main::join(([ map { $_->emit_javascript() } @{( (defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY'))) )} ]), ', ') . ')'))
            };
            return scalar ((Perlito6::JavaScript::tab($level) . $invocant . '.' . Perlito6::JavaScript::escape_function($meth) . '(' . Main::join(([ map { $_->emit_javascript() } @{( (defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY'))) )} ]), ', ') . ')'))
        }
    }

;
    {
    package Apply;
        sub new { shift; bless { @_ }, "Apply" }
        ((my  $Hash_op_infix_js = bless {}, 'HASH') = do {
    (my  $Hash_a = bless {}, 'HASH');
    ($Hash_a->{'infix:<->'} = ' - ');
    ($Hash_a->{'infix:<*>'} = ' * ');
    ($Hash_a->{'infix:<' . chr(47) . '>'} = ' ' . chr(47) . ' ');
    ($Hash_a->{'infix:<>>'} = ' > ');
    ($Hash_a->{'infix:<<>'} = ' < ');
    ($Hash_a->{'infix:<>' . chr(61) . '>'} = ' >' . chr(61) . ' ');
    ($Hash_a->{'infix:<<' . chr(61) . '>'} = ' <' . chr(61) . ' ');
    ($Hash_a->{'infix:<eq>'} = ' ' . chr(61) . chr(61) . ' ');
    ($Hash_a->{'infix:<ne>'} = ' ' . chr(33) . chr(61) . ' ');
    ($Hash_a->{'infix:<le>'} = ' <' . chr(61) . ' ');
    ($Hash_a->{'infix:<ge>'} = ' >' . chr(61) . ' ');
    ($Hash_a->{'infix:<' . chr(61) . chr(61) . '>'} = ' ' . chr(61) . chr(61) . ' ');
    ($Hash_a->{'infix:<' . chr(33) . chr(61) . '>'} = ' ' . chr(33) . chr(61) . ' ');
    ($Hash_a->{'infix:<' . chr(61) . '>>'} = ', ');
    $Hash_a
});
        ((my  $Hash_op_global_js = bless {}, 'HASH') = do {
    (my  $Hash_a = bless {}, 'HASH');
    ($Hash_a->{'index'} = 1);
    ($Hash_a->{'die'} = 1);
    ($Hash_a->{'shift'} = 1);
    ($Hash_a->{'unshift'} = 1);
    ($Hash_a->{'push'} = 1);
    ($Hash_a->{'pop'} = 1);
    ($Hash_a->{'chr'} = 1);
    ($Hash_a->{'say'} = 1);
    ($Hash_a->{'print'} = 1);
    ($Hash_a->{'warn'} = 1);
    $Hash_a
});
        sub emit_javascript {
            my $self = $_[0];
            $self->emit_javascript_indented(0)
        };
        sub emit_javascript_indented {
            my $self = $_[0];
            my $level = $_[1];
            ((my  $apply) = $self->op_assign());
            if ($apply) {
                return scalar ($apply->emit_javascript_indented($level))
            };
            ((my  $code) = $self->{code});
            if (Main::isa($code, 'Str')) {

            }
            else {
                return scalar ((Perlito6::JavaScript::tab($level) . '(' . $self->{code}->emit_javascript() . ')->(' . Main::join(([ map { $_->emit() } @{( (defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY'))) )} ]), ', ') . ')'))
            };
            if (exists($Hash_op_infix_js->{$code})) {
                return scalar ((Perlito6::JavaScript::tab($level) . '(' . Main::join(([ map { $_->emit_javascript() } @{( (defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY'))) )} ]), $Hash_op_infix_js->{$code}) . ')'))
            };
            if (($code eq 'self')) {
                return scalar ((Perlito6::JavaScript::tab($level) . 'v_self'))
            };
            if (($code eq 'Mu')) {
                return scalar ((Perlito6::JavaScript::tab($level) . 'null'))
            };
            if (($code eq 'make')) {
                return scalar ((Perlito6::JavaScript::tab($level) . '(v_MATCH.v_capture ' . chr(61) . ' ' . Main::join(([ map { $_->emit_javascript() } @{( (defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY'))) )} ]), ', ') . ')'))
            };
            if (($code eq 'defined')) {
                return scalar ((Perlito6::JavaScript::tab($level) . '(' . Main::join(([ map { $_->emit_javascript() } @{( (defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY'))) )} ]), ' ') . ' ' . chr(33) . chr(61) . ' null)'))
            };
            if (($code eq 'substr')) {
                return scalar (('(' . ((defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY')))->[0])->emit_javascript() . ' ' . chr(124) . chr(124) . ' ' . chr(34) . chr(34) . ').substr(' . ((defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY')))->[1])->emit_javascript() . ((defined((defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY')))->[2]) ? (', ' . ((defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY')))->[2])->emit_javascript()) : '')) . ')'))
            };
            if (($code eq 'chr')) {
                return scalar (('String.fromCharCode(' . Perlito6::JavaScript::escape_function('num') . '(' . ((defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY')))->[0])->emit_javascript() . '))'))
            };
            if (($code eq 'ord')) {
                return scalar (('(' . ((defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY')))->[0])->emit_javascript() . ').charCodeAt(0)'))
            };
            if (($code eq 'Int')) {
                return scalar (('parseInt(' . ((defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY')))->[0])->emit_javascript() . ')'))
            };
            if (($code eq 'Num')) {
                return scalar (('parseFloat(' . ((defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY')))->[0])->emit_javascript() . ')'))
            };
            if (($code eq 'prefix:<' . chr(126) . '>')) {
                return scalar ((Perlito6::JavaScript::escape_function('string') . '(' . Main::join(([ map { $_->emit_javascript() } @{( (defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY'))) )} ]), ' ') . ')'))
            };
            if (($code eq 'prefix:<' . chr(33) . '>')) {
                return scalar (('( ' . Perlito6::JavaScript::escape_function('bool') . '(' . Main::join(([ map { $_->emit_javascript() } @{( (defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY'))) )} ]), ' ') . ') ' . chr(63) . ' false : true)'))
            };
            if (($code eq 'prefix:<' . chr(63) . '>')) {
                return scalar (('( ' . Perlito6::JavaScript::escape_function('bool') . '(' . Main::join(([ map { $_->emit_javascript() } @{( (defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY'))) )} ]), ' ') . ') ' . chr(63) . ' true : false)'))
            };
            if (($code eq 'prefix:<' . chr(36) . '>')) {
                return scalar ((Perlito6::JavaScript::escape_function('scalar') . '(' . Main::join(([ map { $_->emit_javascript() } @{( (defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY'))) )} ]), ' ') . ')'))
            };
            if (($code eq 'prefix:<' . chr(64) . '>')) {
                return scalar (('(' . Main::join(([ map { $_->emit_javascript() } @{( (defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY'))) )} ]), ' ') . ')'))
            };
            if (($code eq 'prefix:<' . chr(37) . '>')) {
                return scalar (('(' . Main::join(([ map { $_->emit_javascript() } @{( (defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY'))) )} ]), ' ') . ').' . Perlito6::JavaScript::escape_function('hash') . '()'))
            };
            if (($code eq 'postfix:<++>')) {
                return scalar (('(' . Main::join(([ map { $_->emit_javascript() } @{( (defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY'))) )} ]), ' ') . ')++'))
            };
            if (($code eq 'postfix:<-->')) {
                return scalar (('(' . Main::join(([ map { $_->emit_javascript() } @{( (defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY'))) )} ]), ' ') . ')--'))
            };
            if (($code eq 'prefix:<++>')) {
                return scalar (('++(' . Main::join(([ map { $_->emit_javascript() } @{( (defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY'))) )} ]), ' ') . ')'))
            };
            if (($code eq 'prefix:<-->')) {
                return scalar (('--(' . Main::join(([ map { $_->emit_javascript() } @{( (defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY'))) )} ]), ' ') . ')'))
            };
            if (($code eq 'infix:<x>')) {
                return scalar (('str_replicate(' . Main::join(([ map { $_->emit_javascript() } @{( (defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY'))) )} ]), ', ') . ')'))
            };
            if (($code eq 'list:<' . chr(126) . '>')) {
                return scalar (('(' . Perlito6::JavaScript::escape_function('string') . '(' . Main::join(([ map { $_->emit_javascript() } @{( (defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY'))) )} ]), (') + ' . Perlito6::JavaScript::escape_function('string') . '(')) . '))'))
            };
            if (($code eq 'infix:<+>')) {
                return scalar ((Perlito6::JavaScript::escape_function('add') . '(' . Main::join(([ map { $_->emit_javascript() } @{( (defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY'))) )} ]), ', ') . ')'))
            };
            if (($code eq 'infix:<..>')) {
                return scalar (('(function (a) ' . chr(123) . ' ' . 'for (var i' . chr(61) . (defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY')))->[0]->emit_javascript() . ', l' . chr(61) . (defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY')))->[1]->emit_javascript() . chr(59) . ' ' . 'i<' . chr(61) . 'l' . chr(59) . ' ++i)' . chr(123) . ' ' . 'a.push(i) ' . chr(125) . chr(59) . ' ' . 'return a ' . chr(125) . ')([])'))
            };
            if ((($code eq 'infix:<' . chr(38) . chr(38) . '>') || ($code eq 'infix:<and>'))) {
                return scalar ((Perlito6::JavaScript::escape_function('and') . '(' . (defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY')))->[0]->emit_javascript() . ', ' . 'function () ' . chr(123) . ' return ' . (defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY')))->[1]->emit_javascript() . chr(59) . ' ' . chr(125) . ')'))
            };
            if ((($code eq 'infix:<' . chr(124) . chr(124) . '>') || ($code eq 'infix:<or>'))) {
                return scalar ((Perlito6::JavaScript::escape_function('or') . '(' . (defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY')))->[0]->emit_javascript() . ', ' . 'function () ' . chr(123) . ' return ' . (defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY')))->[1]->emit_javascript() . chr(59) . ' ' . chr(125) . ')'))
            };
            if (($code eq 'infix:<' . chr(47) . chr(47) . '>')) {
                return scalar ((Perlito6::JavaScript::escape_function('defined_or') . '(' . (defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY')))->[0]->emit_javascript() . ', ' . 'function () ' . chr(123) . ' return ' . (defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY')))->[1]->emit_javascript() . chr(59) . ' ' . chr(125) . ')'))
            };
            if (($code eq 'infix:<' . chr(61) . chr(61) . chr(61) . '>')) {
                return scalar (('(' . Perlito6::JavaScript::escape_function('id') . '(' . ((defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY')))->[0])->emit_javascript() . ') ' . chr(61) . chr(61) . ' ' . Perlito6::JavaScript::escape_function('id') . '(' . ((defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY')))->[1])->emit_javascript() . '))'))
            };
            if (($code eq 'exists')) {
                ((my  $arg) = (defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY')))->[0]);
                if (Main::isa($arg, 'Lookup')) {
                    return scalar (('(' . ($arg->obj())->emit_javascript() . ').hasOwnProperty(' . ($arg->index_exp())->emit_javascript() . ')'))
                }
            };
            if (($code eq 'ternary:<' . chr(63) . chr(63) . ' ' . chr(33) . chr(33) . '>')) {
                return scalar (('( ' . Perlito6::JavaScript::escape_function('bool') . '(' . ((defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY')))->[0])->emit_javascript() . ')' . ' ' . chr(63) . ' ' . ((defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY')))->[1])->emit_javascript() . ' : ' . ((defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY')))->[2])->emit_javascript() . ')'))
            };
            if (($code eq 'circumfix:<( )>')) {
                return scalar (('(' . Main::join(([ map { $_->emit_javascript() } @{( (defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY'))) )} ]), ', ') . ')'))
            };
            if (($code eq 'infix:<' . chr(61) . '>')) {
                return scalar (emit_javascript_bind((defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY')))->[0], (defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY')))->[1]))
            };
            if (($code eq 'return')) {
                return scalar ((Perlito6::JavaScript::tab($level) . 'throw(' . (((defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY'))) ? (defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY')))->[0]->emit_javascript() : 'null')) . ')'))
            };
            if ($self->{namespace}) {
                ($code = (Main::to_javascript_namespace($self->{namespace}) . '.' . Perlito6::JavaScript::escape_function($code)))
            }
            else {
                if (!(exists($Hash_op_global_js->{$code}))) {
                    ($code = ('v__NAMESPACE.' . Perlito6::JavaScript::escape_function($code)))
                }
                else {
                    ($code = Perlito6::JavaScript::escape_function($self->{code}))
                }
            };
            (Perlito6::JavaScript::tab($level) . $code . '(' . Main::join(([ map { $_->emit_javascript() } @{( (defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY'))) )} ]), ', ') . ')')
        };
        sub emit_javascript_bind {
            my $parameters = $_[0];
            my $arguments = $_[1];
            if (Main::isa($parameters, 'Call')) {
                return scalar (('(' . ($parameters->invocant())->emit_javascript() . '.v_' . $parameters->method() . ' ' . chr(61) . ' ' . $arguments->emit_javascript() . ')'))
            };
            if (Main::isa($parameters, 'Lookup')) {
                ((my  $str) = '');
                ((my  $var) = $parameters->obj());
                (my  $var_js);
                if (Main::isa($var, 'Lookup')) {
                    ((my  $var1) = $var->obj());
                    ((my  $var1_js) = $var1->emit_javascript());
                    ($str = ($str . 'if (' . $var1_js . ' ' . chr(61) . chr(61) . ' null) ' . chr(123) . ' ' . $var1_js . ' ' . chr(61) . ' ' . chr(123) . chr(125) . ' ' . chr(125) . chr(59) . ' '));
                    ($var_js = ($var1_js . '[' . $var->index_exp()->emit_javascript() . ']'))
                }
                else {
                    ($var_js = $var->emit_javascript())
                };
                ($str = ($str . 'if (' . $var_js . ' ' . chr(61) . chr(61) . ' null) ' . chr(123) . ' ' . $var_js . ' ' . chr(61) . ' ' . chr(123) . chr(125) . ' ' . chr(125) . chr(59) . ' '));
                ((my  $index_js) = $parameters->index_exp()->emit_javascript());
                ($str = ($str . 'return (' . $var_js . '[' . $index_js . '] ' . ' ' . chr(61) . ' ' . $arguments->emit_javascript() . ')' . chr(59) . ' '));
                return scalar (('(function () ' . chr(123) . ' ' . $str . chr(125) . ')()'))
            };
            if (Main::isa($parameters, 'Index')) {
                ((my  $str) = '');
                ((my  $var) = $parameters->obj());
                (my  $var_js);
                if (Main::isa($var, 'Index')) {
                    ((my  $var1) = $var->obj());
                    ((my  $var1_js) = $var1->emit_javascript());
                    ($str = ($str . 'if (' . $var1_js . ' ' . chr(61) . chr(61) . ' null) ' . chr(123) . ' ' . $var1_js . ' ' . chr(61) . ' [] ' . chr(125) . chr(59) . ' '));
                    ($var_js = ($var1_js . '[' . $var->index_exp()->emit_javascript() . ']'))
                }
                else {
                    ($var_js = $var->emit_javascript())
                };
                ($str = ($str . 'if (' . $var_js . ' ' . chr(61) . chr(61) . ' null) ' . chr(123) . ' ' . $var_js . ' ' . chr(61) . ' [] ' . chr(125) . chr(59) . ' '));
                ((my  $index_js) = $parameters->index_exp()->emit_javascript());
                ($str = ($str . 'return (' . $var_js . '[' . $index_js . '] ' . ' ' . chr(61) . ' ' . $arguments->emit_javascript() . ')' . chr(59) . ' '));
                return scalar (('(function () ' . chr(123) . ' ' . $str . chr(125) . ')()'))
            };
            if (((Main::isa($parameters, 'Var') && ($parameters->sigil() eq chr(64))) || (Main::isa($parameters, 'Decl') && ($parameters->var()->sigil() eq chr(64))))) {
                ($arguments = Lit::Array->new(('array1' => do {
    (my  $List_a = bless [], 'ARRAY');
    (my  $List_v = bless [], 'ARRAY');
    push( @{$List_a}, $arguments );
    $List_a
})))
            }
            else {
                if (((Main::isa($parameters, 'Var') && ($parameters->sigil() eq chr(37))) || (Main::isa($parameters, 'Decl') && ($parameters->var()->sigil() eq chr(37))))) {
                    ($arguments = Lit::Hash->new(('hash1' => do {
    (my  $List_a = bless [], 'ARRAY');
    (my  $List_v = bless [], 'ARRAY');
    push( @{$List_a}, $arguments );
    $List_a
})))
                }
            };
            ('(' . $parameters->emit_javascript() . ' ' . chr(61) . ' ' . $arguments->emit_javascript() . ')')
        }
    }

;
    {
    package If;
        sub new { shift; bless { @_ }, "If" }
        sub emit_javascript {
            my $self = $_[0];
            $self->emit_javascript_indented(0)
        };
        sub emit_javascript_indented {
            my $self = $_[0];
            my $level = $_[1];
            ((my  $cond) = $self->{cond});
            if ((Main::isa($cond, 'Var') && ($cond->sigil() eq chr(64)))) {
                ($cond = Apply->new(('code' => 'prefix:<' . chr(64) . '>'), ('arguments' => do {
    (my  $List_a = bless [], 'ARRAY');
    (my  $List_v = bless [], 'ARRAY');
    push( @{$List_a}, $cond );
    $List_a
})))
            };
            ((my  $body) = Perlito6::JavaScript::LexicalBlock->new(('block' => $self->{body}->stmts()), ('needs_return' => 0)));
            ((my  $s) = (Perlito6::JavaScript::tab($level) . 'if ( ' . Perlito6::JavaScript::escape_function('bool') . '(' . $cond->emit_javascript() . ') ) ' . chr(123) . ' ' . '(function () ' . chr(123) . (chr(10)) . $body->emit_javascript_indented(($level + 1)) . (chr(10)) . Perlito6::JavaScript::tab($level) . chr(125) . ')()' . chr(59) . ' ' . chr(125)));
            if ($self->{otherwise}) {
                ((my  $otherwise) = Perlito6::JavaScript::LexicalBlock->new(('block' => $self->{otherwise}->stmts()), ('needs_return' => 0)));
                ($s = ($s . (chr(10)) . Perlito6::JavaScript::tab($level) . 'else ' . chr(123) . ' ' . '(function () ' . chr(123) . (chr(10)) . $otherwise->emit_javascript_indented(($level + 1)) . (chr(10)) . Perlito6::JavaScript::tab($level) . chr(125) . ')()' . chr(59) . ' ' . chr(125)))
            };
            return scalar ($s)
        }
    }

;
    {
    package While;
        sub new { shift; bless { @_ }, "While" }
        sub emit_javascript {
            my $self = $_[0];
            $self->emit_javascript_indented(0)
        };
        sub emit_javascript_indented {
            my $self = $_[0];
            my $level = $_[1];
            ((my  $body) = Perlito6::JavaScript::LexicalBlock->new(('block' => (defined $self->{body} ? $self->{body} : ($self->{body} ||= bless([], 'ARRAY')))->stmts()), ('needs_return' => 0)));
            return scalar ((Perlito6::JavaScript::tab($level) . 'for ( ' . (($self->{init} ? ($self->{init}->emit_javascript() . chr(59) . ' ') : chr(59) . ' ')) . (($self->{cond} ? (Perlito6::JavaScript::escape_function('bool') . '(' . $self->{cond}->emit_javascript() . ')' . chr(59) . ' ') : chr(59) . ' ')) . (($self->{continue} ? ($self->{continue}->emit_javascript() . ' ') : ' ')) . ') ' . chr(123) . ' ' . '(function () ' . chr(123) . ' ' . $body->emit_javascript_indented(($level + 1)) . ' ' . chr(125) . ')()' . ' ' . chr(125)))
        }
    }

;
    {
    package For;
        sub new { shift; bless { @_ }, "For" }
        sub emit_javascript {
            my $self = $_[0];
            $self->emit_javascript_indented(0)
        };
        sub emit_javascript_indented {
            my $self = $_[0];
            my $level = $_[1];
            ((my  $cond) = $self->{cond});
            if (!(((Main::isa($cond, 'Var') && ($cond->sigil() eq chr(64)))))) {
                ($cond = Lit::Array->new(('array1' => do {
    (my  $List_a = bless [], 'ARRAY');
    (my  $List_v = bless [], 'ARRAY');
    push( @{$List_a}, $cond );
    $List_a
})))
            };
            ((my  $body) = Perlito6::JavaScript::LexicalBlock->new(('block' => (defined $self->{body} ? $self->{body} : ($self->{body} ||= bless([], 'ARRAY')))->stmts()), ('needs_return' => 0)));
            ((my  $sig) = 'v__');
            if ($self->{body}->sig()) {
                ($sig = $self->{body}->sig()->emit_javascript_indented(($level + 1)))
            };
            (Perlito6::JavaScript::tab($level) . '(function (a_) ' . chr(123) . ' for (var i_ ' . chr(61) . ' 0' . chr(59) . ' i_ < a_.length ' . chr(59) . ' i_++) ' . chr(123) . ' ' . ('(function (' . $sig . ') ' . chr(123) . ' ') . $body->emit_javascript_indented(($level + 1)) . ' ' . chr(125) . ')(a_[i_]) ' . chr(125) . ' ' . chr(125) . ')' . '(' . $cond->emit_javascript() . ')')
        }
    }

;
    {
    package Decl;
        sub new { shift; bless { @_ }, "Decl" }
        sub emit_javascript {
            my $self = $_[0];
            $self->emit_javascript_indented(0)
        };
        sub emit_javascript_indented {
            my $self = $_[0];
            my $level = $_[1];
            (Perlito6::JavaScript::tab($level) . $self->{var}->emit_javascript())
        };
        sub emit_javascript_init {
            my $self = $_[0];
            if (($self->{decl} eq 'my')) {
                ((my  $str) = '');
                ($str = ($str . 'var ' . ($self->{var})->emit_javascript() . ' ' . chr(61) . ' '));
                if ((($self->{var})->sigil() eq chr(37))) {
                    ($str = ($str . chr(123) . chr(125) . chr(59) . (chr(10))))
                }
                else {
                    if ((($self->{var})->sigil() eq chr(64))) {
                        ($str = ($str . '[]' . chr(59) . (chr(10))))
                    }
                    else {
                        ($str = ($str . 'null' . chr(59) . (chr(10))))
                    }
                };
                return scalar ($str)
            }
            else {
                die(('not implemented: Decl ' . chr(39) . $self->{decl} . (chr(39))))
            }
        }
    }

;
    {
    package Method;
        sub new { shift; bless { @_ }, "Method" }
        sub emit_javascript {
            my $self = $_[0];
            $self->emit_javascript_indented(0)
        };
        sub emit_javascript_indented {
            my $self = $_[0];
            my $level = $_[1];
            ((my  $sig) = $self->{sig});
            ((my  $invocant) = $sig->invocant());
            ((my  $pos) = $sig->positional());
            ((my  $str) = Main::join([ map { $_->emit_javascript() } @{( $pos )} ], ', '));
            (Perlito6::JavaScript::tab($level) . 'function ' . $self->{name} . '(' . $str . ') ' . chr(123) . (chr(10)) . (Perlito6::JavaScript::LexicalBlock->new(('block' => (defined $self->{block} ? $self->{block} : ($self->{block} ||= bless([], 'ARRAY')))), ('needs_return' => 1), ('top_level' => 1)))->emit_javascript_indented(($level + 1)) . (chr(10)) . Perlito6::JavaScript::tab($level) . chr(125))
        }
    }

;
    {
    package Sub;
        sub new { shift; bless { @_ }, "Sub" }
        sub emit_javascript {
            my $self = $_[0];
            $self->emit_javascript_indented(0)
        };
        sub emit_javascript_indented {
            my $self = $_[0];
            my $level = $_[1];
            ((my  $sig) = $self->{sig});
            ((my  $pos) = $sig->positional());
            ((my  $str) = Main::join([ map { $_->emit_javascript() } @{( $pos )} ], ', '));
            (Perlito6::JavaScript::tab($level) . 'function ' . $self->{name} . '(' . $str . ') ' . chr(123) . (chr(10)) . (Perlito6::JavaScript::LexicalBlock->new(('block' => (defined $self->{block} ? $self->{block} : ($self->{block} ||= bless([], 'ARRAY')))), ('needs_return' => 1), ('top_level' => 1)))->emit_javascript_indented(($level + 1)) . (chr(10)) . Perlito6::JavaScript::tab($level) . chr(125))
        }
    }

;
    {
    package Do;
        sub new { shift; bless { @_ }, "Do" }
        sub emit_javascript {
            my $self = $_[0];
            $self->emit_javascript_indented(0)
        };
        sub emit_javascript_indented {
            my $self = $_[0];
            my $level = $_[1];
            ((my  $block) = $self->simplify()->block());
            return scalar ((Perlito6::JavaScript::tab($level) . '(function () ' . chr(123) . ' ' . (chr(10)) . (Perlito6::JavaScript::LexicalBlock->new(('block' => $block), ('needs_return' => 1)))->emit_javascript_indented(($level + 1)) . (chr(10)) . Perlito6::JavaScript::tab($level) . chr(125) . ')()'))
        }
    }

;
    {
    package Use;
        sub new { shift; bless { @_ }, "Use" }
        sub emit_javascript {
            my $self = $_[0];
            $self->emit_javascript_indented(0)
        };
        sub emit_javascript_indented {
            my $self = $_[0];
            my $level = $_[1];
            (Perlito6::JavaScript::tab($level) . chr(47) . chr(47) . ' use ' . $self->{mod} . (chr(10)))
        }
    }


}

1;
