public void AddRet() { CurrentInstructions.AddLast(new Instruction() { OpCode = InstructionType.RET }); }
public void AddConst(int index) { CurrentInstructions.AddLast(new Instruction() { OpCode = InstructionType.CONST, Params = BitConverter.GetBytes(index) }); }
public void AddLocal(int offset) { CurrentInstructions.AddLast(new Instruction() { OpCode = InstructionType.LOCAL, Params = BitConverter.GetBytes(offset) }); }
public void AddNewArr(VariableType variableType) { CurrentInstructions.AddLast(new Instruction() { OpCode = InstructionType.NEWARR, Params = new byte[] { (byte)(variableType.Tag) } }); }
public VariableType AddMod() { CurrentInstructions.AddLast(new Instruction() { OpCode = InstructionType.MOD }); return(VariableType.IntType); }
/// <summary> /// 请自行保证是static /// </summary> /// <param name="poolIndex"></param> public void AddStoreStatic(int poolIndex) { CurrentInstructions.AddLast(new Instruction() { OpCode = InstructionType.STORESTATIC, Params = BitConverter.GetBytes(poolIndex) }); }
public void AddNew(int classTypeIndex) { CurrentInstructions.AddLast(new Instruction() { OpCode = InstructionType.NEW, Params = BitConverter.GetBytes(classTypeIndex) }); }
public void AddPushA(uint value) { CurrentInstructions.AddLast(new Instruction() { OpCode = InstructionType.PUSHA, Params = BitConverter.GetBytes(value) }); }
public void AddCall(int methodIndex) { CurrentInstructions.AddLast(new Instruction() { OpCode = InstructionType.CALL, Params = BitConverter.GetBytes(methodIndex) }); }
public VariableType AddSetGtI() { CurrentInstructions.AddLast(new Instruction() { OpCode = InstructionType.SETGTI }); return(VariableType.ByteType); }
public VariableType AddNegI() { CurrentInstructions.AddLast(new Instruction() { OpCode = InstructionType.NEGI }); return(VariableType.IntType); }
/// <summary> /// 自行保证是non-static /// </summary> /// <param name="poolIndex"></param> public void AddLoadNonStatic(int poolIndex) { CurrentInstructions.AddLast(new Instruction() { OpCode = InstructionType.LOADNONSTATIC, Params = BitConverter.GetBytes(poolIndex) }); }
public VariableType AddI2D() { CurrentInstructions.AddLast(new Instruction() { OpCode = InstructionType.SETEQI }); return(VariableType.DoubleType); }
public void AddPushB(byte value) { CurrentInstructions.AddLast(new Instruction() { OpCode = InstructionType.PUSHB, Params = new byte[1] { value } }); }
public void AddJmp(BasicBlock target) { Instruction inst = new Instruction() { OpCode = InstructionType.JMP, Params = new byte[sizeof(int)] }; CurrentInstructions.AddLast(inst); CurrentBasicBlock.JmpTargets.Add(target); }
public void AddJCond(BasicBlock target1, BasicBlock target2) { Instruction inst = new Instruction() { OpCode = InstructionType.JCOND, Params = new byte[sizeof(int) * 2] }; CurrentInstructions.AddLast(inst); CurrentBasicBlock.JmpTargets.Add(target1); CurrentBasicBlock.JmpTargets.Add(target2); }
/// <summary> /// <para> /// On tick, it checks if the current instruction is completed or null, if so, it continues on to the next /// instruction /// </para> /// <para> /// If there are no more instructions, we will mark this coroutine as finished and to be removed & call /// <see cref="OnComplete" /> /// </para> /// </summary> /// <param name="deltaTime">The current deltaTime</param> public void Tick(float deltaTime) { if (Stop) { return; } if (CurrentInstructions == null) { goto finish; } var currentInstruction = CurrentInstructions.Current; var coroutineInstruction = currentInstruction as ICoroutineInstruction; if (!coroutineInstruction?.IsCompleted ?? false) { coroutineInstruction.Tick(deltaTime); return; } CurrentStage++; try { RestartStopWatch(Instance._stopwatch); Owner.TrackStart(); var ret = CurrentInstructions.MoveNext(); Owner.TrackEnd(); if (ret) { CheckStopwatch(); CheckForInstructionRecursion(); return; } } catch (Exception exception) { Instance.PrintError( "An exception occurred whilst executing coroutine from {0} {1} at stage {2}, level {3}:\n{4}\n{5}", Owner.Name, GetIdOrEmpty(), CurrentStage, CurrentLevel, exception.Message, exception.StackTrace); goto finish; } CurrentStage = 0; CurrentLevel++; if (UpdateCurrentInstructions()) { return; } finish: Stop = true; OnComplete?.Invoke(); }