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

Commit

Permalink
remove opcodes getstdin/getstdout/getstderr
Browse files Browse the repository at this point in the history
  • Loading branch information
fperrad committed Jun 3, 2010
1 parent 6f78f52 commit 3defd23
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
4 changes: 3 additions & 1 deletion lua/lib/luaaux.pir
Expand Up @@ -673,6 +673,7 @@ This function only loads the chunk; it does not run it.
=cut

.include 'stat.pasm'
.include 'stdio.pasm'

.sub 'lua_loadfile'
.param string filename
Expand All @@ -682,7 +683,8 @@ This function only loads the chunk; it does not run it.
.local pmc f
unless filename == '' goto L1
chunkname = '=stdin'
f = getstdin
$P0 = getinterp
f = $P0.'stdhandle'(.PIO_STDIN_FILENO)
goto L2
L1:
chunkname = filename
Expand Down
5 changes: 4 additions & 1 deletion lua/lib/luadebug.pir
Expand Up @@ -75,11 +75,14 @@ function, and so have no direct access to local variables.

=cut

.include 'stdio.pasm'

.sub 'debug'
.param pmc extra :slurpy
.local string buffer
.local pmc stdin
stdin = getstdin
$P0 = getinterp
stdin = $P0.'stdhandle'(.PIO_STDIN_FILENO)
L1:
printerr 'lua_debug> '
buffer = readline stdin
Expand Down
11 changes: 7 additions & 4 deletions lua/lib/luaio.pir
Expand Up @@ -98,7 +98,7 @@ LIST

.const int IO_INPUT = 1
.const int IO_OUTPUT = 2

.include 'stdio.pasm'

.sub 'createstdfiles' :anon
.param pmc mt
Expand All @@ -110,24 +110,27 @@ LIST
new $P1, 'LuaString'
new $P3, 'LuaNumber'

.local pmc interp
interp = getinterp

set $P1, 'stdin'
$P2 = getstdin
$P2 = interp.'stdhandle'(.PIO_STDIN_FILENO)
$P0 = lua_newuserdata($P2, mt)
$P0.'setfenv'(env)
io[$P1] = $P0
set $P3, IO_INPUT
io_env[$P3] = $P0

set $P1, 'stdout'
$P2 = getstdout
$P2 = interp.'stdhandle'(.PIO_STDOUT_FILENO)
$P0 = lua_newuserdata($P2, mt)
$P0.'setfenv'(env)
io[$P1] = $P0
set $P3, IO_OUTPUT
io_env[$P3] = $P0

set $P1, 'stderr'
$P2 = getstderr
$P2 = interp.'stdhandle'(.PIO_STDERR_FILENO)
$P0 = lua_newuserdata($P2, mt)
$P0.'setfenv'(env)
io[$P1] = $P0
Expand Down

0 comments on commit 3defd23

Please sign in to comment.