diff --git a/ZenKit/DaedalusVm.cs b/ZenKit/DaedalusVm.cs index 35591b7..8c7eb05 100644 --- a/ZenKit/DaedalusVm.cs +++ b/ZenKit/DaedalusVm.cs @@ -215,6 +215,13 @@ public void Call(string name) if (!(sym is { Type: DaedalusDataType.Function })) throw new Exception("Symbol not found"); Native.ZkDaedalusVm_callFunction(Handle, sym.Handle); } + + public void Call(int symId) + { + var sym = GetSymbolByIndex((uint)symId); + if (!(sym is { Type: DaedalusDataType.Function })) throw new Exception("Symbol not found"); + Native.ZkDaedalusVm_callFunction(Handle, sym.Handle); + } public TR Call(string name) { @@ -225,6 +232,16 @@ public TR Call(string name) if (!sym.HasReturn) throw new InvalidOperationException("The function does not return anything!"); return Pop(); } + + public TR Call(int symId) + { + var sym = GetSymbolByIndex((uint)symId); + if (!(sym is { Type: DaedalusDataType.Function })) throw new Exception("Symbol not found"); + Native.ZkDaedalusVm_callFunction(Handle, sym.Handle); + + if (!sym.HasReturn) throw new InvalidOperationException("The function does not return anything!"); + return Pop(); + } public TR Call(string name, TP0 p0) { @@ -256,34 +273,64 @@ public TR Call(string name, TP0 p0, TP1 p1, TP2 p2, TP3 return Call(name); } - public void Call(string name, TP0 p0) + public TR Call(int symId, TP0 p0) + { + Push(p0); + return Call(symId); + } + + public TR Call(int symId, TP0 p0, TP1 p1) + { + Push(p0); + Push(p1); + return Call(symId); + } + + public TR Call(int symId, TP0 p0, TP1 p1, TP2 p2) + { + Push(p0); + Push(p1); + Push(p2); + return Call(symId); + } + + public TR Call(int symId, TP0 p0, TP1 p1, TP2 p2, TP3 p3) + { + Push(p0); + Push(p1); + Push(p2); + Push(p3); + return Call(symId); + } + + public void Call(int symId, TP0 p0) { Push(p0); - Call(name); + Call(symId); } - public void Call(string name, TP0 p0, TP1 p1) + public void Call(int symId, TP0 p0, TP1 p1) { Push(p0); Push(p1); - Call(name); + Call(symId); } - public void Call(string name, TP0 p0, TP1 p1, TP2 p2) + public void Call(int symId, TP0 p0, TP1 p1, TP2 p2) { Push(p0); Push(p1); Push(p2); - Call(name); + Call(symId); } - public void Call(string name, TP0 p0, TP1 p1, TP2 p2, TP3 p3) + public void Call(int symId, TP0 p0, TP1 p1, TP2 p2, TP3 p3) { Push(p0); Push(p1); Push(p2); Push(p3); - Call(name); + Call(symId); } public void RegisterExternalDefault(ExternalDefaultFunction cb)