MCPcopy Create free account
hub / github.com/ceifa/wasmoon / call

Method call

src/thread.ts:157–170  ·  view source on GitHub ↗
(name: string, ...args: any[])

Source from the content-addressed store, hash-verified

155 }
156
157 public call(name: string, ...args: any[]): MultiReturn {
158 const type = this.lua.lua_getglobal(this.address, name)
159 if (type !== LuaType.Function) {
160 throw new Error(`A function of type '${type}' was pushed, expected is ${LuaType.Function}`)
161 }
162
163 for (const arg of args) {
164 this.pushValue(arg)
165 }
166
167 const base = this.getTop() - args.length - 1 // The 1 is for the function to run
168 this.lua.lua_callk(this.address, args.length, LUA_MULTRET, 0, null)
169 return this.getStackValues(base)
170 }
171
172 public getStackValues(start = 0): MultiReturn {
173 const returns = this.getTop() - start

Callers 1

engine.test.jsFile · 0.80

Calls 3

pushValueMethod · 0.95
getTopMethod · 0.95
getStackValuesMethod · 0.95

Tested by

no test coverage detected