コード例 #1
0
 public void AddRet()
 {
     CurrentInstructions.AddLast(new Instruction()
     {
         OpCode = InstructionType.RET
     });
 }
コード例 #2
0
 public void AddConst(int index)
 {
     CurrentInstructions.AddLast(new Instruction()
     {
         OpCode = InstructionType.CONST,
         Params = BitConverter.GetBytes(index)
     });
 }
コード例 #3
0
 public void AddLocal(int offset)
 {
     CurrentInstructions.AddLast(new Instruction()
     {
         OpCode = InstructionType.LOCAL,
         Params = BitConverter.GetBytes(offset)
     });
 }
コード例 #4
0
 public void AddNewArr(VariableType variableType)
 {
     CurrentInstructions.AddLast(new Instruction()
     {
         OpCode = InstructionType.NEWARR,
         Params = new byte[] { (byte)(variableType.Tag) }
     });
 }
コード例 #5
0
 public VariableType AddMod()
 {
     CurrentInstructions.AddLast(new Instruction()
     {
         OpCode = InstructionType.MOD
     });
     return(VariableType.IntType);
 }
コード例 #6
0
 /// <summary>
 /// 请自行保证是static
 /// </summary>
 /// <param name="poolIndex"></param>
 public void AddStoreStatic(int poolIndex)
 {
     CurrentInstructions.AddLast(new Instruction()
     {
         OpCode = InstructionType.STORESTATIC,
         Params = BitConverter.GetBytes(poolIndex)
     });
 }
コード例 #7
0
 public void AddNew(int classTypeIndex)
 {
     CurrentInstructions.AddLast(new Instruction()
     {
         OpCode = InstructionType.NEW,
         Params = BitConverter.GetBytes(classTypeIndex)
     });
 }
コード例 #8
0
 public void AddPushA(uint value)
 {
     CurrentInstructions.AddLast(new Instruction()
     {
         OpCode = InstructionType.PUSHA,
         Params = BitConverter.GetBytes(value)
     });
 }
コード例 #9
0
ファイル: MiscInstructions.cs プロジェクト: XiPotatonium/XiVM
 public void AddCall(int methodIndex)
 {
     CurrentInstructions.AddLast(new Instruction()
     {
         OpCode = InstructionType.CALL,
         Params = BitConverter.GetBytes(methodIndex)
     });
 }
コード例 #10
0
 public VariableType AddSetGtI()
 {
     CurrentInstructions.AddLast(new Instruction()
     {
         OpCode = InstructionType.SETGTI
     });
     return(VariableType.ByteType);
 }
コード例 #11
0
 public VariableType AddNegI()
 {
     CurrentInstructions.AddLast(new Instruction()
     {
         OpCode = InstructionType.NEGI
     });
     return(VariableType.IntType);
 }
コード例 #12
0
 /// <summary>
 /// 自行保证是non-static
 /// </summary>
 /// <param name="poolIndex"></param>
 public void AddLoadNonStatic(int poolIndex)
 {
     CurrentInstructions.AddLast(new Instruction()
     {
         OpCode = InstructionType.LOADNONSTATIC,
         Params = BitConverter.GetBytes(poolIndex)
     });
 }
コード例 #13
0
 public VariableType AddI2D()
 {
     CurrentInstructions.AddLast(new Instruction()
     {
         OpCode = InstructionType.SETEQI
     });
     return(VariableType.DoubleType);
 }
コード例 #14
0
 public void AddPushB(byte value)
 {
     CurrentInstructions.AddLast(new Instruction()
     {
         OpCode = InstructionType.PUSHB,
         Params = new byte[1] {
             value
         }
     });
 }
コード例 #15
0
        public void AddJmp(BasicBlock target)
        {
            Instruction inst = new Instruction()
            {
                OpCode = InstructionType.JMP,
                Params = new byte[sizeof(int)]
            };

            CurrentInstructions.AddLast(inst);
            CurrentBasicBlock.JmpTargets.Add(target);
        }
コード例 #16
0
        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);
        }
コード例 #17
0
ファイル: Coroutines.cs プロジェクト: birthdates/Coroutines
            /// <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();
            }