tagged release 0.6.4
[parrot.git] / languages / ecmascript / js.pir
blob6f8e23617772963a16498fee6e32027849f3718b
1 =head1 NAME
3 js -- A compiler for js ECMAScript-262
5 =head1 SYNOPSIS
7   $ ./parrot languages/emcascript/js.pir script.js
9 =head1 DESCRIPTION
11 js is a compiler for ECMAScript-262 (3rd edition) running on Parrot.
13 =cut
16 #.include 'src/gen_builtins.pir'
18 ## Create a 'List' class; stolen from Rakudo.
19 ## At some point, this should be refactored/reused.
21 .namespace []
23 .sub '__onload' :load :init
24     $P0 = subclass 'ResizablePMCArray', 'List'
25 .end
27 ## Methods for the List class
29 .namespace ['List']
31 .sub 'elems' :method
32     $I0 = elements self
33     .return ($I0)
34 .end
36 .sub 'unshift' :method
37     .param pmc x
38     unshift self, x
39 .end
41 .sub 'shift' :method
42     .local pmc x
43     x = shift self
44     .return (x)
45 .end
50 .namespace ['JS::Compiler']
52 .loadlib 'js_group'
54 .sub 'onload' :load :init :anon
55     load_bytecode 'PCT.pbc'
56     load_bytecode 'Protoobject.pbc'
58     $P0 = get_hll_global 'Protomaker'
59     $P1 = get_class ['PCT::HLLCompiler']
60     $P0.'new_subclass'($P1, 'JS::Compiler')
62     ## Create a list called '@?BLOCK' and store it, so it can
63     ## be used in the parse actions.
64     ##
65     $P0 = new 'List'
66     set_hll_global ['JS';'Grammar';'Actions'], '@?BLOCK', $P0
67 .end
70 .sub 'init' :vtable :method
71     self.'language'('JS')
72     self.'parsegrammar'('JS::Grammar')
73     self.'parseactions'('JS::Grammar::Actions')
74 .end
77 .sub 'main' :main
78     .param pmc args
79     $P0 = compreg 'JS'
80     $P1 = $P0.'command_line'(args)
81 .end
84 .include 'src/gen_grammar.pir'
85 .include 'src/gen_actions.pir'
88 .namespace []
90 .include 'src/builtin/builtins.pir'
93 # Local Variables:
94 #   mode: pir
95 #   fill-column: 100
96 # End:
97 # vim: expandtab shiftwidth=4 ft=pir: