aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/test/test_ldump.lua
diff options
context:
space:
mode:
Diffstat (limited to 'LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/test/test_ldump.lua')
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/test/test_ldump.lua99
1 files changed, 0 insertions, 99 deletions
diff --git a/LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/test/test_ldump.lua b/LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/test/test_ldump.lua
deleted file mode 100644
index 2d113dd..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/test/test_ldump.lua
+++ /dev/null
@@ -1,99 +0,0 @@
1--[[--------------------------------------------------------------------
2
3 test_ldump.lua
4 Test for ldump.lua
5 This file is part of Yueliang.
6
7 Copyright (c) 2006 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
19dofile("../lopcodes.lua")
20dofile("../ldump.lua")
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.lastlinedefined = 0
54F.nups = 0
55F.numparams = 0
56F.is_vararg = 2
57F.maxstacksize = 5
58F.sizecode = 7
59F.code = {}
60F.code[0] = { OP = 1, A = 0, Bx = 0 }
61F.code[1] = { OP = 1, A = 1, Bx = 1 }
62F.code[2] = { OP = 5, A = 2, Bx = 2 }
63F.code[3] = { OP = 0, A = 3, B = 0, C = 0 }
64F.code[4] = { OP = 0, A = 4, B = 1, C = 0 }
65F.code[5] = { OP = 28, A = 2, B = 3, C = 1 }
66F.code[6] = { OP = 30, A = 0, B = 1, C = 0 }
67F.sizek = 3
68F.k = {}
69F.k[0] = { value = 47 }
70F.k[1] = { value = "hello, world!" }
71F.k[2] = { value = "print" }
72F.sizep = 0
73F.p = {}
74F.sizelineinfo = 7
75F.lineinfo = {}
76F.lineinfo[0] = 1
77F.lineinfo[1] = 2
78F.lineinfo[2] = 3
79F.lineinfo[3] = 3
80F.lineinfo[4] = 3
81F.lineinfo[5] = 3
82F.lineinfo[6] = 3
83F.sizelocvars = 2
84F.locvars = {}
85F.locvars[0] = { varname = "a", startpc = 1, endpc = 6 }
86F.locvars[1] = { varname = "b", startpc = 2, endpc = 6 }
87F.sizeupvalues = 0
88F.upvalues = {}
89
90local L = {}
91--[[
92local Writer, Buff = luaU:make_setS()
93luaU:dump(L, F, Writer, Buff)
94for i = 1, string.len(Buff.data) do
95 io.stdout:write(string.byte(string.sub(Buff.data, i, i)).." ")
96end
97--]]
98local Writer, Buff = luaU:make_setF("try.out")
99luaU:dump(L, F, Writer, Buff)