Uh oh!
There was an error while loading. Please reload this page.
forked from leegao/LuaInLua
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathluac.lua
More file actions
Latest commit
44 lines (40 loc) · 1.28 KB
/
Copy pathluac.lua
File metadata and controls
44 lines (40 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
-- Compiles and loads a piece of lua code
localparser=require'lua.parser'
localcompiler=require'lua.compiler'
localdump=require'bytecode.dump'
localutils=require'common.utils'
localfunctionmain(file)
localtree=parser(io.open(file, 'r'):read('*all'))
localprototype=compiler(tree)
localbytecode=dump.dump(prototype)
localfunc, err=loadstring(tostring(bytecode))
localfunctiondumper_(proto, level)
localindent= (''):rep(level)
print(indent..'Level ' ..level)
print(indent.."Code")
forpc, opinipairs(proto.code) do
print(indent..pc, '(line ' ..proto.debug.lineinfo[pc] ..')', op)
end
print(indent.."Constants")
forid, constinipairs(proto.constants) do
print(indent..id, const)
end
print(indent.."Upvalues")
forid, upinipairs(proto.upvalues) do
print(indent..id-1, proto.debug.upvalues[id], up.instack==1and'local' or'upval', up.index)
end
forfuncinutils.loop(proto.constants.functions) do
dumper_(func, level+1)
end
end
localfunctiondumper()
dumper_(prototype, 0)
end
iferrthen
print("Error during bytecode loading, dumping state...")
dumper()
error(err)
end
returnfunc, bytecode, prototype, dumper
end
returnmain