aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/test_ldump.lua
diff options
context:
space:
mode:
Diffstat (limited to 'LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/test_ldump.lua')
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/test_ldump.lua98
1 files changed, 0 insertions, 98 deletions
diff --git a/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/test_ldump.lua b/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/test_ldump.lua
deleted file mode 100644
index d867688..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/test_ldump.lua
+++ /dev/null
@@ -1,98 +0,0 @@
1--[[--------------------------------------------------------------------
2
3 test_ldump.lua
4 Test for ldump.lua
5 This file is part of Yueliang.
6
7 Copyright (c) 2005 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-- test dump chunkwriter style
17------------------------------------------------------------------------
18
19require("../lopcodes")
20require("../ldump")
21
22-- Original typedef:
23--int (*lua_Chunkwriter) (lua_State *L, const void* p, size_t sz, void* ud);
24
25local MyWriter, MyBuff = luaU:make_setS()
26if not MyWriter then
27 error("failed to initialize using make_setS")
28end
29MyWriter("hello, ", MyBuff)
30MyWriter("world!", MyBuff)
31print(MyBuff.data)
32
33local MyWriter, MyBuff = luaU:make_setF("try.txt")
34if not MyWriter then
35 error("failed to initialize using make_setF")
36end
37MyWriter("hello, ", MyBuff)
38MyWriter("world!", MyBuff)
39MyWriter(nil, MyBuff)
40
41------------------------------------------------------------------------
42-- test output of a function prototype
43-- * data can be copied from a ChunkSpy listing output
44------------------------------------------------------------------------
45-- local a = 47
46-- local b = "hello, world!"
47-- print(a, b)
48------------------------------------------------------------------------
49
50local F = {}
51F.source = "sample.lua"
52F.lineDefined = 0
53F.nups = 0
54F.numparams = 0
55F.is_vararg = 0
56F.maxstacksize = 5
57F.sizelineinfo = 7
58F.lineinfo = {}
59F.lineinfo[0] = 1
60F.lineinfo[1] = 2
61F.lineinfo[2] = 3
62F.lineinfo[3] = 3
63F.lineinfo[4] = 3
64F.lineinfo[5] = 3
65F.lineinfo[6] = 3
66F.sizelocvars = 2
67F.locvars = {}
68F.locvars[0] = { varname = "a", startpc = 1, endpc = 6 }
69F.locvars[1] = { varname = "b", startpc = 2, endpc = 6 }
70F.sizeupvalues = 0
71F.upvalues = {}
72F.sizek = 3
73F.k = {}
74F.k[0] = { value = 47 }
75F.k[1] = { value = "hello, world!" }
76F.k[2] = { value = "print" }
77F.sizep = 0
78F.p = {}
79F.sizecode = 7
80F.code = {}
81F.code[0] = { OP = 1, A = 0, Bx = 0 }
82F.code[1] = { OP = 1, A = 1, Bx = 1 }
83F.code[2] = { OP = 5, A = 2, Bx = 2 }
84F.code[3] = { OP = 0, A = 3, B = 0, C = 0 }
85F.code[4] = { OP = 0, A = 4, B = 1, C = 0 }
86F.code[5] = { OP = 25, A = 2, B = 3, C = 1 }
87F.code[6] = { OP = 27, A = 0, B = 1, C = 0 }
88
89local L = {}
90--[[
91local Writer, Buff = luaU:make_setS()
92luaU:dump(L, F, Writer, Buff)
93for i = 1, string.len(Buff.data) do
94 io.stdout:write(string.byte(string.sub(Buff.data, i, i)).." ")
95end
96--]]
97local Writer, Buff = luaU:make_setF("try.out")
98luaU:dump(L, F, Writer, Buff)