static int AddNativeFunctionCallback(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 3); NativeCodeManager obj = (NativeCodeManager)LuaScriptMgr.GetUnityObjectSelf(L, 1, "NativeCodeManager"); string arg0 = LuaScriptMgr.GetLuaString(L, 2); Action <string[]> arg1 = null; LuaTypes funcType3 = LuaDLL.lua_type(L, 3); if (funcType3 != LuaTypes.LUA_TFUNCTION) { arg1 = (Action <string[]>)LuaScriptMgr.GetNetObject(L, 3, typeof(Action <string[]>)); } else { LuaFunction func = LuaScriptMgr.GetLuaFunction(L, 3); arg1 = (param0) => { int top = func.BeginPCall(); LuaScriptMgr.PushArray(L, param0); func.PCall(top, 1); func.EndPCall(top); }; } obj.AddNativeFunctionCallback(arg0, arg1); return(0); }
static int InitCenter(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 1); NativeCodeManager obj = (NativeCodeManager)LuaScriptMgr.GetUnityObjectSelf(L, 1, "NativeCodeManager"); obj.InitCenter(); return(0); }
static int GetUserInfo(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 1); NativeCodeManager obj = (NativeCodeManager)LuaScriptMgr.GetUnityObjectSelf(L, 1, "NativeCodeManager"); string o = obj.GetUserInfo(); LuaScriptMgr.Push(L, o); return(1); }
static int AppendQQGroup(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 2); NativeCodeManager obj = (NativeCodeManager)LuaScriptMgr.GetUnityObjectSelf(L, 1, "NativeCodeManager"); string arg0 = LuaScriptMgr.GetLuaString(L, 2); obj.AppendQQGroup(arg0); return(0); }
static int SetAppInfo(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 3); NativeCodeManager obj = (NativeCodeManager)LuaScriptMgr.GetUnityObjectSelf(L, 1, "NativeCodeManager"); string arg0 = LuaScriptMgr.GetLuaString(L, 2); string arg1 = LuaScriptMgr.GetLuaString(L, 3); obj.SetAppInfo(arg0, arg1); return(0); }
private static void logCodeBlock(CodeBlock codeBlock, long allCycles, long instructionCount, long callCount, int count, IList <int> sortedBackBranches) { string name = codeBlock.ClassName; NativeCodeManager nativeCodeManager = Compiler.Instance.NativeCodeManager; NativeCodeSequence nativeCodeSequence = nativeCodeManager.getCompiledNativeCodeBlock(codeBlock.StartAddress); if (nativeCodeSequence != null) { name = string.Format("{0} ({1})", name, nativeCodeSequence.Name); } int lowestAddress = codeBlock.LowestAddress; int highestAddress = codeBlock.HighestAddress; int Length = (highestAddress - lowestAddress) / 4 + 1; double percentage = 0; if (allCycles != 0) { percentage = (instructionCount / (double)allCycles) * 100; } //JAVA TO C# CONVERTER TODO TASK: The following line has a Java format specifier which cannot be directly translated to .NET: //ORIGINAL LINE: Console.WriteLine(String.format("%s %,d instructions (%2.3f%%), %,d calls (%08X - %08X, Length %d)", name, instructionCount, percentage, callCount, lowestAddress, highestAddress, Length)); Console.WriteLine(string.Format("%s %,d instructions (%2.3f%%), %,d calls (%08X - %08X, Length %d)", name, instructionCount, percentage, callCount, lowestAddress, highestAddress, Length)); if (count < detailedCodeBlockLogThreshold && codeBlock.Length <= codeLogMaxLength) { logCode(codeBlock); } foreach (int address in sortedBackBranches) { if (address < lowestAddress || address > highestAddress) { continue; } CodeInstruction codeInstruction = codeBlock.getCodeInstruction(address); if (codeInstruction == null) { continue; } int branchingToAddress = codeInstruction.BranchingTo; // Add 2 for branch instruction itself and delay slot int backBranchLength = (address - branchingToAddress) / 4 + 2; //JAVA TO C# CONVERTER TODO TASK: The following line has a Java format specifier which cannot be directly translated to .NET: //ORIGINAL LINE: Console.WriteLine(String.format(" Back Branch %08X %,d times (Length %d)", address, backBranchCounts.get(address), backBranchLength)); Console.WriteLine(string.Format(" Back Branch %08X %,d times (Length %d)", address, backBranchCounts[address], backBranchLength)); if (count < detailedCodeBlockLogThreshold && backBranchLength <= backBranchMaxLength) { logCode(codeBlock, branchingToAddress, backBranchLength, backBranchContextBefore, backBranchContextAfter, address); } } }
void Awake() { Debug.Log("Coo.Awake"); if (Coo.ID > 0) { Destroy(base.gameObject); return; } ID++; Coo.go = base.gameObject; Coo.monoBehaviour = this; GameObject cameraGO = GameObject.FindWithTag("UICamera"); if (cameraGO != null) { uiCamera = cameraGO.GetComponent <Camera>(); } debugLogManager = DebugLogManager.Instance; assetManager = AssetManager.Instance; configManager = ConfigManager.Instance; packetManager = PacketManager.Instance; soundManager = SoundManager.Instance; nativeManager = NativeCodeManager.Instance; //plotTalkManager = PlotTalkManager.Instance; callUtil = CallUtil.Instance; crashReporter = CrashReporter.Instance; luaManager = new LuaScriptMgr(); loadManager = gameObject.AddComponent <LoadManager>(); menuManager = gameObject.AddComponent <MenuManager>(); fps = gameObject.AddComponent <HUDFPS>(); fps.enabled = GameConst.VisiableFPS; ShakePhoneEvent shakePhoneEvent = GetComponent <ShakePhoneEvent>(); if (shakePhoneEvent == null) { shakePhoneEvent = base.gameObject.AddComponent <ShakePhoneEvent>(); } shakePhoneEvent.OnShake += OpenDebugLogPanel; GameObject.DontDestroyOnLoad(base.gameObject); }
private void Initialise() { Settings.Instance.registerSettingsListener("Compiler", "emu.ignoreInvalidMemoryAccess", new IgnoreInvalidMemoryAccessSettingsListerner(this)); Settings.Instance.registerSettingsListener("Compiler", "emu.compiler.methodMaxInstructions", new MethodMaxInstructionsSettingsListerner(this)); DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.IgnoringElementContentWhitespace = true; documentBuilderFactory.IgnoringComments = true; documentBuilderFactory.Coalescing = true; configuration = null; try { DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); configuration = documentBuilder.parse(new File("Compiler.xml")); } catch (ParserConfigurationException e) { Console.WriteLine(e); } catch (SAXException e) { Console.WriteLine(e); } catch (IOException e) { Console.WriteLine(e); } if (configuration != null) { nativeCodeManager = new NativeCodeManager(configuration.DocumentElement); } else { nativeCodeManager = new NativeCodeManager(null); } compilerTypeManager = new CompilerTypeManager(); reset(); }
public virtual void invalidateCodeBlock(CodeBlock codeBlock) { IExecutable executable = codeBlock.Executable; if (executable != null) { // If the application is invalidating the same code block too many times, // do no longer try to recompile it each time, interpret it. if (codeBlock.InstanceIndex > maxRecompileExecutable) { executable.Executable = new InterpretExecutable(codeBlock); } else { // Force a recompilation of the codeBlock at the next execution executable.Executable = new RecompileExecutable(codeBlock); } } NativeCodeManager.invalidateCompiledNativeCodeBlocks(codeBlock.LowestAddress, codeBlock.HighestAddress); }
private void scanNativeCodeSequences(CompilerContext context) { NativeCodeManager nativeCodeManager = context.NativeCodeManager; //JAVA TO C# CONVERTER WARNING: Unlike Java's ListIterator, enumerators in .NET do not allow altering the collection: for (IEnumerator <CodeInstruction> lit = codeInstructions.GetEnumerator(); lit.MoveNext();) { CodeInstruction codeInstruction = lit.Current; NativeCodeSequence nativeCodeSequence = nativeCodeManager.getNativeCodeSequence(codeInstruction, this); if (nativeCodeSequence != null) { if (nativeCodeSequence.Hook) { HookCodeInstruction hookCodeInstruction = new HookCodeInstruction(nativeCodeSequence, codeInstruction); // Replace the current code instruction by the hook code instruction //JAVA TO C# CONVERTER TODO TASK: .NET enumerators are read-only: lit.remove(); lit.add(hookCodeInstruction); } else { NativeCodeInstruction nativeCodeInstruction = new NativeCodeInstruction(codeInstruction.Address, nativeCodeSequence); if (nativeCodeInstruction.Branching) { IsBranchTarget = nativeCodeInstruction.BranchingTo; } if (nativeCodeSequence.WholeCodeBlock) { codeInstructions.Clear(); codeInstructions.AddLast(nativeCodeInstruction); } else { // Remove the first opcode that started this native code sequence //JAVA TO C# CONVERTER TODO TASK: .NET enumerators are read-only: lit.remove(); // Add any code instructions that need to be inserted before // the native code sequence IList <CodeInstruction> beforeCodeInstructions = nativeCodeSequence.BeforeCodeInstructions; if (beforeCodeInstructions != null) { foreach (CodeInstruction beforeCodeInstruction in beforeCodeInstructions) { CodeInstruction newCodeInstruction = new CodeInstruction(beforeCodeInstruction); newCodeInstruction.Address = codeInstruction.Address; lit.add(newCodeInstruction); } } // Add the native code sequence itself lit.add(nativeCodeInstruction); // Remove the further opcodes from the native code sequence //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: for (int i = nativeCodeSequence.NumOpcodes - 1; i > 0 && lit.hasNext(); i--) { lit.Current; //JAVA TO C# CONVERTER TODO TASK: .NET enumerators are read-only: lit.remove(); } } } } } }