Calls a method that has been made ready in a Method handle, taking class and parameters from current slot stack.
Parameters
- methodHandle
- Handle to the method.
Returns
- EinhugurWren.InterpretResult
Remarks
using EinhugurWren
var conf as new Configuration(addressof WriteCallback, addressof ErrorCallback)
var vm as new VM(conf)
var script as string = _
"class MyClass {" + EndOfLine + _
"static myMethod() {" + EndOfLine + _
"System.print(""Hello from first method"")" + EndOfLine + _
"}" + EndOfLine + _
"static myMethod2(x) {" + EndOfLine + _
"System.print(""Hello from second method "" + x.toString)" + EndOfLine + _
"}" + EndOfLine + _
"}" + EndOfLine
var result as InterpretResult = vm.Interpret("main", script)
if result = InterpretResult.SUCCESS then
var classHandle as Handle = vm.GetClassHandle("main", "MyClass")
var methodHandle as Handle = vm.CreateCallHandle("myMethod()")
vm.EnsureSlots(1)
vm.SlotHandle(0) = classHandle
var callResult as InterpretResult = vm.CallMethod(methodHandle)
if callResult <> InterpretResult.SUCCESS then
MessageBox "We got error"
end if
var methodHandle2 as Handle = vm.CreateCallHandle("myMethod2(_)")
vm.EnsureSlots(2)
vm.SlotHandle(0) = classHandle
vm.SlotDouble(1) = 123
callResult = vm.CallMethod(methodHandle2)
if callResult <> InterpretResult.SUCCESS then
MessageBox "We got error"
end if
end if
See Also
VM Class