aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/luac.lua
diff options
context:
space:
mode:
Diffstat (limited to 'LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/luac.lua')
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/luac.lua71
1 files changed, 0 insertions, 71 deletions
diff --git a/LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/luac.lua b/LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/luac.lua
deleted file mode 100644
index 5f12f79..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/luac.lua
+++ /dev/null
@@ -1,71 +0,0 @@
1--[[--------------------------------------------------------------------
2
3 luac.lua
4 Primitive luac in Lua
5 This file is part of Yueliang.
6
7 Copyright (c) 2005-2007 Kein-Hong Man <khman@users.sf.net>
8 The COPYRIGHT file describes the conditions
9 under which this software may be distributed.
10
11 See the ChangeLog for more information.
12
13----------------------------------------------------------------------]]
14
15--[[--------------------------------------------------------------------
16-- Notes:
17-- * based on luac.lua in the test directory of the 5.1.2 distribution
18-- * usage: lua luac.lua file.lua
19----------------------------------------------------------------------]]
20
21------------------------------------------------------------------------
22-- load and initialize the required modules
23------------------------------------------------------------------------
24dofile("lzio.lua")
25dofile("llex.lua")
26dofile("lopcodes.lua")
27dofile("ldump.lua")
28dofile("lcode.lua")
29dofile("lparser.lua")
30
31luaX:init() -- required by llex
32local LuaState = {} -- dummy, not actually used, but retained since
33 -- the intention is to complete a straight port
34
35------------------------------------------------------------------------
36-- interfacing to yueliang
37------------------------------------------------------------------------
38
39-- currently asserts are enabled because the codebase hasn't been tested
40-- much (if you don't want asserts, just comment them out)
41function lua_assert(test)
42 if not test then error("assertion failed!") end
43end
44
45function yloadfile(filename)
46 -- luaZ:make_getF returns a file chunk reader
47 -- luaZ:init returns a zio input stream
48 local zio = luaZ:init(luaZ:make_getF(filename), nil)
49 if not zio then return end
50 -- luaY:parser parses the input stream
51 -- func is the function prototype in tabular form; in C, func can
52 -- now be used directly by the VM, this can't be done in Lua
53 local func = luaY:parser(LuaState, zio, nil, "@"..filename)
54 -- luaU:make_setS returns a string chunk writer
55 local writer, buff = luaU:make_setS()
56 -- luaU:dump builds a binary chunk
57 luaU:dump(LuaState, func, writer, buff)
58 -- a string.dump equivalent in returned
59 return buff.data
60end
61
62------------------------------------------------------------------------
63-- command line interface
64------------------------------------------------------------------------
65
66assert(arg[1] ~= nil and arg[2] == nil, "usage: lua luac.lua file.lua")
67local f = assert(io.open("luac.out","wb"))
68assert(f:write(assert(yloadfile(arg[1]))))
69assert(io.close(f))
70
71--end