Skip to content

Commit 2ed0dbc

Browse files
author
Rerumu
committed
Improved public API names
1 parent d96aaf7 commit 2ed0dbc

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

example.lua

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
local env = getfenv(0)
22
local fio
33

4-
local function wrap_func(fn) return fio.wrap_lua(fio.stm_lua(string.dump(fn)), env) end
4+
local function wrap_func(fn)
5+
local bc = string.dump(fn)
6+
local state = fio.bc_to_state(bc)
7+
8+
return fio.wrap_state(state, env)
9+
end
510

611
fio = require('source')
712
-- fio = wrap_func(loadfile('source.lua'))() -- self running, uncomment to test

source.lua

+6-6
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ if not table.move then
2929
end
3030
end
3131

32-
local stm_lua_bytecode
33-
local wrap_lua_func
32+
local lua_bc_to_state
33+
local lua_wrap_state
3434
local stm_lua_func
3535

3636
-- SETLIST config
@@ -465,7 +465,7 @@ function stm_lua_func(S, psrc)
465465
return proto
466466
end
467467

468-
function stm_lua_bytecode(src)
468+
function lua_bc_to_state(src)
469469
-- func reader
470470
local rdr_func
471471

@@ -929,7 +929,7 @@ local function run_lua_func(state, env, upvals)
929929
pc = pc + nups
930930
end
931931

932-
memory[inst.A] = wrap_lua_func(sub, env, uvlist)
932+
memory[inst.A] = lua_wrap_state(sub, env, uvlist)
933933
else
934934
--[[TESTSET]]
935935
local A = inst.A
@@ -1030,7 +1030,7 @@ local function run_lua_func(state, env, upvals)
10301030
end
10311031
end
10321032

1033-
function wrap_lua_func(proto, env, upval)
1033+
function lua_wrap_state(proto, env, upval)
10341034
local function wrapped(...)
10351035
local passed = table.pack(...)
10361036
local memory = table.create(proto.max_stack)
@@ -1064,4 +1064,4 @@ function wrap_lua_func(proto, env, upval)
10641064
return wrapped
10651065
end
10661066

1067-
return {stm_lua = stm_lua_bytecode, wrap_lua = wrap_lua_func}
1067+
return {bc_to_state = lua_bc_to_state, wrap_state = lua_wrap_state}

0 commit comments

Comments
 (0)