public object[] Execute(Executable exe, string pkgname, string entryName, object[] paramToExec = null, int retValueCount = 0) { Execute(exe); // 找到包入口 var func = exe.GetFuncByName(new ObjectName(pkgname, entryName)) as ValuePhoFunc; if (func == null) { throw new RuntimeException("unknown start package name: " + pkgname); } // 参数转到栈上 ObjectListToDataStack(paramToExec); var rtpkg = GetRuntimePackageByName(pkgname); var argCount = paramToExec != null ? paramToExec.Length:0; ExecuteFunc(exe, rtpkg, func, argCount, retValueCount); if (retValueCount > 0) { var retValue = new object[retValueCount]; for (int i = 0; i < retValueCount; i++) { retValue[i] = Convertor.ValueToNativeValue(DataStack.Get(-(i + 1))); } return(retValue); } return(null); }
internal void LinkCommandEntry(Executable exe) { foreach (var cmd in Commands) { switch (cmd.Op) { case Opcode.LOADF: case Opcode.CLOSURE: { var entry = exe.GetFuncByName(cmd.EntryName); if (entry == null) { throw new RuntimeException("func entry not found: " + cmd.EntryName); } cmd.DataA = entry.ID; } break; case Opcode.NEW: { var entry = exe.GetClassTypeByName(cmd.EntryName); if (entry == null) { throw new RuntimeException("func entry not found: " + cmd.EntryName); } cmd.DataA = entry.ID; } break; } } }