Method: Immunio::LuaVM#call

Defined in:
lib/immunio/vm.rb

#call(code, vars = nil) ⇒ Object



233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'lib/immunio/vm.rb', line 233

def call(code, vars = nil)
  lua_call do
    # Setup the error handler
    @error_handler.load_onto_stack
    @call_function.error_handler = @call_function.send :stack_top

    # For the VM heavy thread test, we need to cause out-of-order execution
    # in methods modifying the Lua stack. Here we tell Ruby to swap out
    # threads if we are in the thread test.
    Thread.pass if $IMMUNIO_IN_THREAD_TEST

    ret = @call_function.call code, vars
    @state.send :stack_pop # Pop the error handler
    Array === ret ? ret.first : ret
  end
end