-
Notifications
You must be signed in to change notification settings - Fork 3
/
pirate.pir
166 lines (128 loc) · 3.09 KB
/
pirate.pir
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# Copyright (C) 2007-2008, Parrot Foundation.
# $Id$
#.HLL 'PIRATE'
.loadlib 'pirate_ops'
.namespace []
.sub '' :anon :load :init
load_bytecode 'HLL.pbc'
load_bytecode 'nqp-setting.pbc'
.local pmc hllns, parrotns, imports
hllns = get_hll_namespace
parrotns = get_root_namespace ['parrot']
imports = split ' ', 'PAST POST PCT HLL Regex Hash ResizablePMCArray'
parrotns.'export_to'(hllns, imports)
.end
.loadlib 'gen/PIR/Actions.pbc'
.loadlib 'gen/PIR/Grammar.pbc'
.loadlib 'gen/PIR/Compiler.pbc'
#.HLL 'parrot'
.loadlib 'gen/POST/VanillaAllocator.pbc'
.loadlib 'gen/POST/Compiler.pbc'
.loadlib 'gen/POST/File.pbc'
.loadlib 'gen/POST/Sub.pbc'
.loadlib 'gen/POST/Call.pbc'
.loadlib 'gen/POST/Value.pbc'
.loadlib 'gen/POST/Constant.pbc'
.loadlib 'gen/POST/String.pbc'
.loadlib 'gen/POST/Register.pbc'
.loadlib 'gen/POST/Label.pbc'
.loadlib 'gen/POST/Key.pbc'
#.HLL 'PIRATE'
.namespace []
.sub 'main' :main
.param pmc args
.local pmc stages
# We actually create POST tree from Parse.
stages = split ' ', 'parse post pbc'
$P0 = compreg 'PIRATE'
$P0.'stages'(stages)
$P0.'addstage'('eliminate_constant_conditional', 'before'=>'pbc')
$P0.'addstage'('fold_arithmetic', 'before'=>'pbc')
$P0.'addstage'('swap_gtge', 'before'=>'pbc')
$P0.'command_line'(args)
exit 0
.end
#.HLL 'parrot'
.namespace ['PackfileRawSegment']
.sub 'push' :method
.param int value
push self, value
.end
.sub 'at' :method
.param int key
$I0 = self[key]
.return ($I0)
.end
.namespace ['PackfileFixupTable']
.sub 'push' :method
.param pmc value
$I0 = elements self
self[$I0] = value
.end
.namespace ['PackfileConstantTable']
.sub 'push' :method
.param pmc value
$I0 = elements self
self[$I0] = value
.return($I0)
.end
.namespace ['StringBuilder']
.sub 'push' :method
.param string value
push self, value
.end
.namespace ['PackfileConstantTable']
.sub 'get_or_create_string' :method
.param string str
$I0 = self.'get_or_create_constant'(str)
.return ($I0)
.end
.sub 'get_or_create_number' :method
.param num n
$I0 = self.'get_or_create_constant'(n)
.return ($I0)
.end
.sub 'get_or_create_pmc' :method
.param pmc p
$I0 = self.'get_or_create_constant'(p)
.return ($I0)
.end
.namespace ['FixedIntegerArray']
.sub 'elements' :vtable('get_number') :method
$I0 = self
.return ($I0)
.end
.namespace ['Key']
.sub 'set_str' :method
.param string s
self = s
.return ()
.end
.sub 'set_int' :method
.param int i
self = i
.return ()
.end
.sub 'push' :method
.param pmc p
push self, p
.return()
.end
# We can't use NQP for dynamically loaded stuff... It's broken somehow.
.namespace []
.sub "register_hll_lib"
.param string lib
register_hll_lib lib
.end
=head1 LICENSE
Copyright (C) 2007-2010, Parrot Foundation.
This is free software; you may redistribute it and/or modify
it under the same terms as Parrot.
=head1 AUTHOR
Klaas-Jan Stol <[email protected]>
=cut
# Local Variables:
# mode: pir
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir: