Skip to content
This repository has been archived by the owner on Jun 9, 2018. It is now read-only.

Commit

Permalink
fix after ops massacre
Browse files Browse the repository at this point in the history
  • Loading branch information
fperrad committed May 28, 2010
1 parent 81fcdb3 commit f97d78f
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 24 deletions.
2 changes: 2 additions & 0 deletions lua.pir
Expand Up @@ -84,6 +84,8 @@ show version information.

=cut

.loadlib 'io_ops'

.sub '__gcstop' :anon :init
sweepoff # stop collector during initialization
.end
Expand Down
1 change: 1 addition & 0 deletions lua/POSTGrammar.tg
Expand Up @@ -127,6 +127,7 @@ PIRCODE
.tailcall $P0.'new'(start, 'node'=>node, 'prologue'=><<'PIRCODE')
.include "interpinfo.pasm"
.HLL "lua"
.loadlib "io_ops"
.loadlib "lua_group"
PIRCODE
}
Expand Down
21 changes: 12 additions & 9 deletions lua/lib/luamath.pir
Expand Up @@ -47,6 +47,10 @@ L<http://www.lua.org/manual/5.1/manual.html#5.6>.

.HLL 'lua'
.loadlib 'lua_group'
.loadlib 'io_ops'
.loadlib 'sys_ops'
.loadlib 'math_ops'
.loadlib 'trans_ops'
.namespace [ 'math' ]

.sub 'luaopen_math'
Expand Down Expand Up @@ -112,12 +116,6 @@ LIST
set $P1, 'huge'
_math[$P1] = $P0

load_bytecode 'Math/Rand.pbc'
$P0 = get_root_namespace ['parrot'; 'Math'; 'Rand']
$P1 = get_namespace
$P2 = split ' ', 'rand srand RAND_MAX'
$P0.'export_to'($P1, $P2)

.end


Expand Down Expand Up @@ -410,8 +408,11 @@ LIST
.local pmc res
.local int u
.local int l
$I0 = rand()
$I1 = RAND_MAX()
load_bytecode 'Math/Rand.pbc'
$P0 = get_root_global ['parrot'; 'Math'; 'Rand'], 'rand'
$I0 = $P0()
$P0 = get_root_global ['parrot'; 'Math'; 'Rand'], 'RAND_MAX'
$I1 = $P0()
inc $I1
$N0 = $I0 / $I1
new res, 'LuaNumber'
Expand Down Expand Up @@ -452,7 +453,9 @@ LIST
.param pmc seed :optional
.param pmc extra :slurpy
$I1 = lua_checknumber(1, seed)
srand($I1)
load_bytecode 'Math/Rand.pbc'
$P0 = get_root_global ['parrot'; 'Math'; 'Rand'], 'srand'
$P0($I1)
.end


Expand Down
2 changes: 2 additions & 0 deletions lua/lib/luaos.pir
Expand Up @@ -18,6 +18,8 @@ L<http://www.lua.org/manual/5.1/manual.html#5.8>.

.HLL 'lua'
.loadlib 'lua_group'
.loadlib 'io_ops'
.loadlib 'sys_ops'
.namespace [ 'os' ]

.sub 'luaopen_os'
Expand Down
2 changes: 2 additions & 0 deletions lua/lua51.pir
Expand Up @@ -24,6 +24,8 @@ Used by F<languages/lua/lua.pir>.

=cut

.loadlib 'io_ops'

.namespace [ 'Lua' ]

.sub '__onload' :anon :load
Expand Down
4 changes: 4 additions & 0 deletions luad.pir
Expand Up @@ -17,6 +17,10 @@ L<http://luaforge.net/projects/chunkspy/>

=cut

.loadlib 'io_ops'
.loadlib 'sys_ops'
.loadlib 'math_ops'
.loadlib 'trans_ops'
.loadlib 'lua_group'

.sub 'main' :main
Expand Down
5 changes: 3 additions & 2 deletions t/env.t
Expand Up @@ -43,9 +43,10 @@
cmd .= " "
cmd .= params
L1:
$P0 = open cmd, 'rp'
$P0 = new 'FileHandle'
$P0.'open'(cmd, 'rp')
$S0 = $P0.'readall'()
close $P0
$P0.'close'()
.return ($S0)
.end

Expand Down
5 changes: 3 additions & 2 deletions t/lexico.t
Expand Up @@ -33,9 +33,10 @@ L<http://www.lua.org/manual/5.1/manual.html#2.1>.
.sub 'lexico' :anon
.param string code
spew('lexico.lua', code)
$P0 = open 'parrot lua.pbc lexico.lua', 'rp'
$P0 = new 'FileHandle'
$P0.'open'('parrot lua.pbc lexico.lua', 'rp')
$S0 = $P0.'readall'()
close $P0
$P0.'close'()
.return ($S0)
.end

Expand Down
12 changes: 7 additions & 5 deletions t/luad.t
Expand Up @@ -22,9 +22,10 @@ by Kein-Hong Man
$P0 = loadlib 'os'
.include 'test_more.pir'

$P0 = open 'luac -v', 'rp'
$S0 = readline $P0
close $P0
$P0 = new 'FileHandle'
$P0.'open'('luac -v', 'rp')
$S0 = $P0.'readline'()
$P0.'close'()
$S0 = substr $S0, 0, 7
if $S0 == "Lua 5.1" goto L1
# skip_all("luac no available")
Expand Down Expand Up @@ -104,9 +105,10 @@ by Kein-Hong Man
.param string code
spew('luad.lua', code)
$I0 = spawnw 'luac -o luad.luac luad.lua'
$P0 = open 'parrot lua/luad.pbc luad.luac', 'rp'
$P0 = new 'FileHandle'
$P0.'open'('parrot lua/luad.pbc luad.luac', 'rp')
$S0 = $P0.'readall'()
close $P0
$P0.'close'()
.return ($S0)
.end

Expand Down
5 changes: 3 additions & 2 deletions t/shootout.t
Expand Up @@ -58,9 +58,10 @@ See L<http://shootout.alioth.debian.org>.
cmd .= " "
cmd .= params
L1:
$P0 = open cmd, 'rp'
$P0 = new 'FileHandle'
$P0.'open'(cmd, 'rp')
$S0 = $P0.'readall'()
close $P0
$P0.'close'()
.return ($S0)
.end

Expand Down
5 changes: 3 additions & 2 deletions t/test-from-lua.t
Expand Up @@ -55,9 +55,10 @@ Here is a one-line summary of each program:
.param string filename
.local string cmd
cmd = "parrot lua.pbc " . filename
$P0 = open cmd, 'rp'
$P0 = new 'FileHandle'
$P0.'open'(cmd, 'rp')
$S0 = $P0.'readall'()
close $P0
$P0.'close'()
.return ($S0)
.end
Expand Down
5 changes: 3 additions & 2 deletions t/test_lex.t
Expand Up @@ -56,9 +56,10 @@ L<http://www.lua.org/manual/5.1/manual.html#2.1>.
.sub 'lua_lex' :anon
.param string code
spew('test_lex.lua', code)
$P0 = open 'parrot test_lex.pir test_lex.lua', 'rp'
$P0 = new 'FileHandle'
$P0.'open'('parrot test_lex.pir test_lex.lua', 'rp')
$S0 = $P0.'readall'()
close $P0
$P0.'close'()
.return ($S0)
.end

Expand Down

0 comments on commit f97d78f

Please sign in to comment.