1 # Copyright (C) 2007-2008, The Perl Foundation.
10 Encapsulation of the compiler written in Perl as a Parrot registered compiler.
12 This encapsulation is used to implement some Lua functions :
24 It's a temporary work. Waiting for the real PIR compiler/interpreter.
34 .sub '__onload' :anon :load :init
35 $P0 = newclass [ 'Lua::PerlCompiler' ]
40 .namespace [ 'Lua::PerlCompiler' ]
43 .param string filename
53 .param string filename
55 fh = open filename, '>'
71 .sub 'load_script' :anon
72 .param string filename
75 pio = getclass 'ParrotIO'
77 content = pio.'slurp'(filename)
91 .sub 'compile_file' :anon
92 .param string filename
93 .const string out = 'luac.out'
95 $I0 = index filename, '.'
96 $S1 = substr filename, 0, $I0
100 $S0 = 'perl -Ilanguages/lua languages/lua/luac.pl '
106 pir = load_script($S1)
108 $P0 = getclass 'ParrotIO'
109 $S0 = $P0.'slurp'(out)
110 unlink(out) # cleaning up the temporary file
113 unlink(out) # cleaning up the temporary file
115 pir_comp = compreg 'PIR'
121 =item compile(pmc source)
127 .sub 'compile' :method
131 $P0 = getprop 'num', self
132 unless null $P0 goto L1
139 setprop self, 'num', $P0
141 save_lua(source, $S1)
142 .return compile_file($S1)
158 # vim: expandtab shiftwidth=4 ft=pir: