public static void Ctor_String()
 {
     string message = "Created StackOverflowException";
     var exception = new StackOverflowException(message);
     Assert.Equal(message, exception.Message);
     Assert.Equal(COR_E_STACKOVERFLOW, exception.HResult);
 }
示例#2
0
    protected void ddlExceptionType_SelectedIndexChanged(object sender, EventArgs e)
    {
        string exType = ddlExceptionType.SelectedValue;

        switch (exType)
        {
        case "InvalidOperationException":
            InvalidOperationException ioe = new InvalidOperationException("This is a test.");
            throw ioe;

        case "ArgumentException":
            ArgumentException ae = new ArgumentException("This is a test.");
            throw ae;

        case "NullReferenceException":
            NullReferenceException ne = new NullReferenceException("This is a test.");
            throw ne;

        case "AccessViolationException":
            AccessViolationException ave = new AccessViolationException("This is a test.");
            throw ave;

        case "IndexOutOfRangeException":
            IndexOutOfRangeException iore = new IndexOutOfRangeException("This is a test.");
            throw iore;

        case "StackOverflowException":
            StackOverflowException soe = new StackOverflowException("This is a test.");
            throw soe;

        default:
            throw new Exception("This is a test.");
        }
    }
 public static void Ctor_Empty()
 {
     var exception = new StackOverflowException();
     Assert.NotNull(exception);
     Assert.NotEmpty(exception.Message);
     Assert.Equal(COR_E_STACKOVERFLOW, exception.HResult);
 }
示例#4
0
        public void Ctor_MessageAndInnerException()
        {
            var inner = new StackOverflowException();

            var ex = new SonarLintException("Binding failed", inner);

            ex.Message.Should().Be("Binding failed");
            ex.InnerException.Should().BeSameAs(inner);
        }
示例#5
0
        public void ctor_string_innerException()
        {
            string    expectedMessage        = "message";
            Exception expectedInnerException = new StackOverflowException();

            Exception target = this.CreateMock(expectedMessage, expectedInnerException);

            Assert.AreEqual <string>(expectedMessage, target.Message);
            Assert.AreEqual <Exception>(expectedInnerException, target.InnerException);
        }
示例#6
0
        public void StackOverflowFibonacci()
        {
            var iteracoes = 25;

            Action act = () => ProjetoCSharp.Fibonacci.CalculaFibonacci(iteracoes);

            StackOverflowException exception = Assert.Throws <StackOverflowException>(act);

            Assert.Equal("Stack Overflow", exception.Message);
        }
        public void MessageAndInnerExceptionConstructorTest()
        {
            const string message = "Exception message.";
            var          baseEx  = new StackOverflowException();

            var ex = new ExcelMapperConvertException(message, baseEx);

            Assert.AreEqual(message, ex.Message);
            Assert.AreEqual(baseEx.GetType(), ex.InnerException?.GetType());
        }
示例#8
0
        public void IsTestProject_CriticalExceptionOccurs_NotSuppressedOrLogged()
        {
            var critialException = new StackOverflowException("BANG!");

            fileSystem.Setup(x => x.File.ReadAllText(project.FilePath)).Throws(critialException);

            Action act = () => testSubject.IsTestProject(project);

            act.Should().ThrowExactly <StackOverflowException>().And.Message.Should().Be("BANG!");
            logger.Verify(x => x.WriteLine(It.IsAny <string>(), It.IsAny <object[]>()),
                          Times.Never);
        }
示例#9
0
        internal static void AssertStack()
        {
            var frames = new StackTrace().FrameCount;

            //Log.Debug("stack frames=" + frames);
            if (frames > 200)
            {
                Exception e = new StackOverflowException("stack frames=" + frames);
                Log.Error(e.ToString());
                throw e;
            }
        }
示例#10
0
        public async Task BatchRequestRetriesExecutedWithAggregateException()
        {
            TimeSpan  deltaBackoff = TimeSpan.FromSeconds(0);
            const int maxRetries   = 5;
            int       serviceRequestFuncCallCount = 0;

            var request = new BatchRequest <
                JobScheduleListOptions,
                AzureOperationResponse <IPage <ProxyModels.CloudJobSchedule> > >(null, CancellationToken.None);

            request.ServiceRequestFunc = async(token) =>
            {
                ++serviceRequestFuncCallCount;

                Action throwsAction = () => { throw new StackOverflowException(); };
                Task   throwsTask1  = Task.Factory.StartNew(throwsAction);
                Task   throwsTask2  = Task.Factory.StartNew(throwsAction);
                await Task.WhenAll(throwsTask1, throwsTask2); //This will throw

                return(null);
            };

            IRetryPolicy policy = new LinearRetry(deltaBackoff, maxRetries);

            request.RetryPolicy = policy;

            Task executeRequestTask = request.ExecuteRequestAsync();

            //We will observe only 1 exception (not an Aggregate) from the throw
            StackOverflowException e = await Assert.ThrowsAsync <StackOverflowException>(async() => { await executeRequestTask; });

            //But the task itself should have the full set of exceptions which were hit
            AggregateException aggregateException = executeRequestTask.Exception;

            //TODO: Why can't this be 2?
            //Assert.Equal(2, aggregateException.InnerExceptions.Count);
            Assert.Equal(1, aggregateException.InnerExceptions.Count);

            Assert.Equal(maxRetries + 1, serviceRequestFuncCallCount);
            Assert.Equal(maxRetries + 1, request.OperationContext.RequestResults.Count);

            foreach (RequestResult requestResult in request.OperationContext.RequestResults)
            {
                Assert.IsType <StackOverflowException>(requestResult.Exception);
                Assert.Null(requestResult.RequestInformation.BatchError);
                Assert.Null(requestResult.RequestInformation.HttpStatusCode);
                Assert.Null(requestResult.RequestInformation.HttpStatusMessage);
                Assert.Null(requestResult.RequestInformation.ServiceRequestId);
                Assert.NotEqual(Guid.Empty, requestResult.RequestInformation.ClientRequestId);
            }
        }
示例#11
0
        public static void Cozy()
        {
            Console.WriteLine("\n-----------------------------------------------");
            Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);
            Console.WriteLine("-----------------------------------------------");

            System.Exception            e1 = new Exception();
            System.ApplicationException e2 = new ApplicationException();
            e2 = null;
            System.Reflection.TargetInvocationException e3 = new TargetInvocationException(e1);
            System.SystemException e4 = new SystemException();
            e4 = null;
            System.StackOverflowException e5 = new StackOverflowException();
            e5 = null;
        }
示例#12
0
 public static void Main(string[] args)
 {
     V1();
     try
     {
         V2();
     }
     catch (Exception ex)
     {
         StackOverflowException exception = new StackOverflowException(ex.Message, ex);
         Console.WriteLine(exception);
     }
     finally
     {
         Console.ReadLine();
     }
 }
示例#13
0
        private void PrintStackTrace(StackOverflowException _e)
        {
            Console.WriteLine("error: stack overflow");

            var st = GetStackTrace();

            var top = st[0];

            Console.WriteLine($"    at {top.ProcedureName}({top.ChunkName}):???");

            for (var i = 1; i < st.Length; i++)
            {
                var prev = st[i - 1];
                var curr = st[i];
                Console.WriteLine($"    at {curr.ProcedureName}({curr.ChunkName}):{prev.CallSiteLine}");
            }
        }
示例#14
0
        public void WriteWithUnsupportedExceptionTest()
        {
            var events = new []
            {
                new AsyncLogEventInfo()
            };
            var testTarget = Create();
            var exception  = new StackOverflowException();

            _eventsWriter.Setup(x => x.Write(events, testTarget)).Throws(exception).Verifiable();
            try
            {
                testTarget.WriteAsync(events);
                Assert.Fail();
            }
            catch (Exception e)
            {
                Assert.AreEqual(exception, e);
            }
        }
        public void UpdateStatusWhenOperationThrows(bool async)
        {
            StackOverflowException originalException = new StackOverflowException();
            TestOperation          testOperation     = new TestOperation()
            {
                OnUpdateState = _ => throw originalException
            };
            MockOperationInternal <int> operationInternal = testOperation.MockOperationInternal;

            StackOverflowException thrownException = async
                ? Assert.ThrowsAsync <StackOverflowException>(async() => await operationInternal.UpdateStatusAsync(CancellationToken.None))
                : Assert.Throws <StackOverflowException>(() => operationInternal.UpdateStatus(CancellationToken.None));

            Assert.AreEqual(originalException, thrownException);

            Assert.IsNull(operationInternal.RawResponse);
            Assert.False(operationInternal.HasCompleted);
            Assert.False(operationInternal.HasValue);
            Assert.Throws <InvalidOperationException>(() => _ = operationInternal.Value);
        }
示例#16
0
    public void Test()
    {
        string s1 = "";

        lock (s1) { }                           //NonComplaint

        lock ("Hello") { }                      //NonComplaint

        var o1 = new OutOfMemoryException();

        lock (o1) { }                           //NonComplaint

        var o2 = new StackOverflowException();

        lock (o2) { }                           //NonComplaint

        var o3 = new ExecutionEngineException();

        lock (o3) { }                                    //NonComplaint

        lock (System.Threading.Thread.CurrentThread) { } //NonComplaint

        lock (typeof(LockTest2)) { }                     //NonComplaint

        System.Reflection.MemberInfo mi = null;
        lock (mi) { }                           //NonComplaint

        System.Reflection.ConstructorInfo ci = null;
        lock (ci) { }                           //NonComplaint

        System.Reflection.ParameterInfo pi = null;
        lock (pi) { }                           //NonComplaint

        int[] values = { 1, 2, 3 };
        lock (values) { }                       //NonComplaint

        System.Reflection.MemberInfo[] values1 = null;
        lock (values1) { }

        lock (this) { }                                 //NonComplaint
    }
        public async Task UpdateStatusSetsFailedScopeWhenOperationThrows(bool async)
        {
            using ClientDiagnosticListener testListener = new ClientDiagnosticListener(DiagnosticNamespace);

            StackOverflowException originalException = new StackOverflowException();
            TestOperation          testOperation     = new TestOperation()
            {
                OnUpdateState = _ => throw originalException
            };
            MockOperationInternal <int> operationInternal = testOperation.MockOperationInternal;

            try
            {
                _ = async
                    ? await operationInternal.UpdateStatusAsync(CancellationToken.None)
                    : operationInternal.UpdateStatus(CancellationToken.None);
            }
            catch { }

            testListener.AssertScopeException($"{nameof(TestOperation)}.UpdateStatus", (Exception scopeException) =>
                                              Assert.AreEqual(originalException, scopeException));
        }
示例#18
0
        /// <summary>
        /// Run fuzzer
        /// </summary>
        /// <param name="action">Action</param>
        /// <param name="args">Arguments</param>
        public static void Run(Action <Stream> action, FuzzerRunArgs args = null)
        {
            CoverageHelper.CreateCoverageListener();

            if (action == null)
            {
                throw new NullReferenceException(nameof(action));
            }

            // Check supervisor

            Mutex mutex;
            var   supervisor = FuzzerRunArgs.SupervisorType.None;

            if (args != null && args.Supervisor != FuzzerRunArgs.SupervisorType.None)
            {
                // Check if is the listener or the task with mutex

                mutex = new Mutex(false, "TuringMachine.Supervisor." + Client.PublicName, out var isNew);

                if (!isNew)
                {
                    Client.PublicName += $".{Process.GetCurrentProcess().Id}:{args.TaskId}";
                }
                else
                {
                    Client.PublicName += ".Supervisor";
                    supervisor         = args.Supervisor;
                }
            }
            else
            {
                mutex = null;
            }

            if (!Client.IsStarted)
            {
                // If you want other connection you must call this method before Run

                Client.Start(CommandLineOptions.Parse().GetConnection());
            }

            // Send current files

            Client.SendCurrentFiles(new OperationCanceledException(), null, true);

            // Fuzz

            var cancel  = new CancelEventArgs();
            var handler = new ConsoleCancelEventHandler((o, s) =>
            {
                cancel.Cancel = true;
                s.Cancel      = true;
            });

            Console.CancelKeyPress += handler;

            // Ensure data

            while (Client.GetInput() == null || Client.GetConfig() == null)
            {
                Thread.Sleep(50);
            }

            switch (supervisor)
            {
            case FuzzerRunArgs.SupervisorType.RegularSupervisor:
            {
                var pi = new ProcessStartInfoEx()
                {
                    FileName               = "dotnet",
                    Arguments              = string.Join(" ", Environment.GetCommandLineArgs().Select(u => u)),
                    WindowStyle            = ProcessWindowStyle.Normal,
                    RedirectStandardOutput = true,
                    RedirectStandardError  = true,
                    UseShellExecute        = false,
                    CreateNoWindow         = false,
                };

                while (!cancel.Cancel)
                {
                    using (var pr = new ProcessEx(pi))
                    {
                        pr.WaitForExit();

                        Exception exception;

                        switch (pr.ExitCode)
                        {
                        case StackOverflowExceptionCode:
                        {
                            exception = new StackOverflowException($"Unhandled exception: {pr.ExitCode}");
                            break;
                        }

                        default:
                        {
                            exception = new InvalidProgramException($"Unhandled exception: {pr.ExitCode}");
                            break;
                        }
                        }

                        if (Client.SendCurrentFiles(exception, pr.Output, true) == 0)
                        {
                            Client.SendLog(new FuzzerLog()
                                {
                                    Coverage = CoverageHelper.CurrentCoverage,
                                    InputId  = Guid.Empty,
                                    ConfigId = Guid.Empty,
                                });
                        }
                    }
                }
                break;
            }

            case FuzzerRunArgs.SupervisorType.None:
            {
                while (!cancel.Cancel)
                {
                    var input  = Client.GetInput();
                    var config = Client.GetConfig();

                    string     currentStreamPath  = null;
                    FileStream storeCurrentStream = null;

                    if (args?.StoreCurrent == true)
                    {
                        // Free current stream

                        currentStreamPath  = $"{input.Id}.{config.Id}.{Process.GetCurrentProcess().Id}.{args.TaskId}.current";
                        storeCurrentStream = new FileStream(currentStreamPath, FileMode.Create, FileAccess.ReadWrite, FileShare.Read);
                    }

                    using (var stream = new FuzzingStream(config, input, storeCurrentStream)
                        {
                            ExtraLogInformation = "TaskId: " + args.TaskId
                        })
                    {
                        var log = Client.Execute(action, stream);

                        if (log != null)
                        {
                            Client.SendLog(log);
                            args?.OnLog?.Invoke(log, cancel);
                        }
                    }

                    if (storeCurrentStream != null)
                    {
                        // Delete current stream

                        storeCurrentStream.Close();
                        storeCurrentStream.Dispose();
                        File.Delete(currentStreamPath);
                    }
                }
                break;
            }
            }

            Console.CancelKeyPress -= handler;
            mutex?.Dispose();
        }
示例#19
0
        public void TestCFibboRecursivo()
        {
            var e = new StackOverflowException();

            Assert.AreEqual(e, Ex3Calculadora.Program.fibonacciRecursivo(1000000));
        }
示例#20
0
 public CHIP8StackOverflowException(Byte maxStackSize)
 {
     _localException = new StackOverflowException(
         $"Maximum Stack level reached. The maximum level is currently {maxStackSize}.");
 }
示例#21
0
        public void TestWriteLog()
        {
            var dict = new Dictionary <string, string>
            {
                { "key1", "val1" },
                { "key2", "val2" },
                { "key3", "val3" },
            };

            var exception = new StackOverflowException("Exception message.");

            Log.LogLevel = LogLevel.Verbose;

            Log.Verbose("Message.");
            Log.Verbose("Message Dict={Val1}.", dict);
            Log.Verbose("Message Dict={Val1}, Num={Val2}.", dict, 1234);
            Log.Verbose("Message Dict={Val1}, Num={Val2}, Str={Val3}.", dict, 1234, "Hello");
            Log.Verbose("Message Dict={Val1}, Num={Val2}, Str={Val3}, Bool={Val4}.", dict, 1234, "Hello", true);
            Log.Verbose(exception, "Message.");
            Log.Verbose(exception, "Message Dict={Val1}.", dict);
            Log.Verbose(exception, "Message Dict={Val1}, Num={Val2}.", dict, 1234);
            Log.Verbose(exception, "Message Dict={Val1}, Num={Val2}, Str={Val3}.", dict, 1234, "Hello");
            Log.Verbose(exception, "Message Dict={Val1}, Num={Val2}, Str={Val3}, Bool={Val4}.", dict, 1234, "Hello", true);

            Log.Debug("Message.");
            Log.Debug("Message Dict={Val1}.", dict);
            Log.Debug("Message Dict={Val1}, Num={Val2}.", dict, 1234);
            Log.Debug("Message Dict={Val1}, Num={Val2}, Str={Val3}.", dict, 1234, "Hello");
            Log.Debug("Message Dict={Val1}, Num={Val2}, Str={Val3}, Bool={Val4}.", dict, 1234, "Hello", true);
            Log.Debug(exception, "Message.");
            Log.Debug(exception, "Message Dict={Val1}.", dict);
            Log.Debug(exception, "Message Dict={Val1}, Num={Val2}.", dict, 1234);
            Log.Debug(exception, "Message Dict={Val1}, Num={Val2}, Str={Val3}.", dict, 1234, "Hello");
            Log.Debug(exception, "Message Dict={Val1}, Num={Val2}, Str={Val3}, Bool={Val4}.", dict, 1234, "Hello", true);

            Log.Information("Message.");
            Log.Information("Message Dict={Val1}.", dict);
            Log.Information("Message Dict={Val1}, Num={Val2}.", dict, 1234);
            Log.Information("Message Dict={Val1}, Num={Val2}, Str={Val3}.", dict, 1234, "Hello");
            Log.Information("Message Dict={Val1}, Num={Val2}, Str={Val3}, Bool={Val4}.", dict, 1234, "Hello", true);
            Log.Information(exception, "Message.");
            Log.Information(exception, "Message Dict={Val1}.", dict);
            Log.Information(exception, "Message Dict={Val1}, Num={Val2}.", dict, 1234);
            Log.Information(exception, "Message Dict={Val1}, Num={Val2}, Str={Val3}.", dict, 1234, "Hello");
            Log.Information(exception, "Message Dict={Val1}, Num={Val2}, Str={Val3}, Bool={Val4}.", dict, 1234, "Hello", true);

            Log.Warning("Message.");
            Log.Warning("Message Dict={Val1}.", dict);
            Log.Warning("Message Dict={Val1}, Num={Val2}.", dict, 1234);
            Log.Warning("Message Dict={Val1}, Num={Val2}, Str={Val3}.", dict, 1234, "Hello");
            Log.Warning("Message Dict={Val1}, Num={Val2}, Str={Val3}, Bool={Val4}.", dict, 1234, "Hello", true);
            Log.Warning(exception, "Message.");
            Log.Warning(exception, "Message Dict={Val1}.", dict);
            Log.Warning(exception, "Message Dict={Val1}, Num={Val2}.", dict, 1234);
            Log.Warning(exception, "Message Dict={Val1}, Num={Val2}, Str={Val3}.", dict, 1234, "Hello");
            Log.Warning(exception, "Message Dict={Val1}, Num={Val2}, Str={Val3}, Bool={Val4}.", dict, 1234, "Hello", true);

            Log.Error("Message.");
            Log.Error("Message Dict={Val1}.", dict);
            Log.Error("Message Dict={Val1}, Num={Val2}.", dict, 1234);
            Log.Error("Message Dict={Val1}, Num={Val2}, Str={Val3}.", dict, 1234, "Hello");
            Log.Error("Message Dict={Val1}, Num={Val2}, Str={Val3}, Bool={Val4}.", dict, 1234, "Hello", true);
            Log.Error(exception, "Message.");
            Log.Error(exception, "Message Dict={Val1}.", dict);
            Log.Error(exception, "Message Dict={Val1}, Num={Val2}.", dict, 1234);
            Log.Error(exception, "Message Dict={Val1}, Num={Val2}, Str={Val3}.", dict, 1234, "Hello");
            Log.Error(exception, "Message Dict={Val1}, Num={Val2}, Str={Val3}, Bool={Val4}.", dict, 1234, "Hello", true);

            Log.Fatal("Message.");
            Log.Fatal("Message Dict={Val1}.", dict);
            Log.Fatal("Message Dict={Val1}, Num={Val2}.", dict, 1234);
            Log.Fatal("Message Dict={Val1}, Num={Val2}, Str={Val3}.", dict, 1234, "Hello");
            Log.Fatal("Message Dict={Val1}, Num={Val2}, Str={Val3}, Bool={Val4}.", dict, 1234, "Hello", true);
            Log.Fatal(exception, "Message.");
            Log.Fatal(exception, "Message Dict={Val1}.", dict);
            Log.Fatal(exception, "Message Dict={Val1}, Num={Val2}.", dict, 1234);
            Log.Fatal(exception, "Message Dict={Val1}, Num={Val2}, Str={Val3}.", dict, 1234, "Hello");
            Log.Fatal(exception, "Message Dict={Val1}, Num={Val2}, Str={Val3}, Bool={Val4}.", dict, 1234, "Hello", true);

            try
            {
                Func1();
            }
            catch (Exception ex)
            {
                // Test for stacktrace.
                Log.Verbose(ex, "Exception.");
                Log.Debug(ex, "Exception.");
                Log.Information(ex, "Exception.");
                Log.Warning(ex, "Exception.");
                Log.Error(ex, "Exception.");
                Log.Fatal(ex, "Exception.");
            }

            WriteLog(LogLevel.Verbose);
            WriteLog(LogLevel.Debug);
            WriteLog(LogLevel.Information);
            WriteLog(LogLevel.Warning);
            WriteLog(LogLevel.Error);
            WriteLog(LogLevel.Fatal);

            CheckLogLevel(LogLevel.Verbose);
            CheckLogLevel(LogLevel.Debug);
            CheckLogLevel(LogLevel.Information);
            CheckLogLevel(LogLevel.Warning);
            CheckLogLevel(LogLevel.Error);
            CheckLogLevel(LogLevel.Fatal);
            CheckLogLevel(LogLevel.Silent);
            CheckLogLevel(LogLevel.None);

            Log.LogLevel = LogLevel.Verbose;
            Log.Information("Logger will be closed.");

            Log.Close();
            Log.Verbose("This message will not be output.");
            Log.Debug("This message will not be output.");
            Log.Information("This message will not be output.");
            Log.Warning("This message will not be output.");
            Log.Error("This message will not be output.");
            Log.Fatal("This message will not be output.");

            Assert.False(Log.IsEnabled(LogLevel.Verbose));
            Assert.False(Log.IsEnabled(LogLevel.Debug));
            Assert.False(Log.IsEnabled(LogLevel.Information));
            Assert.False(Log.IsEnabled(LogLevel.Warning));
            Assert.False(Log.IsEnabled(LogLevel.Error));
            Assert.False(Log.IsEnabled(LogLevel.Fatal));
            Assert.False(Log.IsEnabled(LogLevel.Silent));
            Assert.False(Log.IsEnabled(LogLevel.None));

            output.WriteLine("Please check log files at: {0}", logDir.FindPathName(String.Empty));
        }
示例#22
0
        public bool Interpret()
        {
            int runtimeCount = 0;

            output = "";
            do
            {
                Pcode currentCode = pcodeList[pc++];

                switch (currentCode.f)
                {
                case Pcode.PC.LIT:                        //将常量值取到运行栈顶,a是常数值
                    sta[sp++] = currentCode.a;
                    break;

                case Pcode.PC.OPR:
                    switch (currentCode.a)
                    {
                    case 0:                                                           //OPR 0 0;函数调用结束后的返回
                        sp = bp;
                        pc = sta[sp + 2];
                        bp = sta[sp + 1];
                        break;

                    case 1:                                                      //OPR 0 1;栈顶元素取反
                        sta[sp - 1] = -sta[sp - 1];
                        break;

                    case 2:                                                        //OPR 0 2;次栈顶与栈顶相加,退两个栈元素,相加值进栈
                        sp--;
                        sta[sp - 1] += sta[sp];
                        break;

                    case 3:                                                         //OPR 0 3;次栈顶减栈顶
                        sp--;
                        sta[sp - 1] -= sta[sp];
                        break;

                    case 4:                                                      //OPR 0 4;次栈顶乘以栈顶
                        sp--;
                        sta[sp - 1] = sta[sp - 1] * sta[sp];
                        break;

                    case 5:                                                        //OPR 0 5;次栈顶处以栈顶
                        sp--;
                        sta[sp - 1] /= sta[sp];
                        break;

                    case 6:                                                        //OPR 0 6;栈顶元素的奇偶判断
                        sta[sp - 1] %= 2;
                        break;

                    case 7:                                                       //OPR 0 7;次栈顶对栈顶取模,退两个栈元素,余数进栈
                        sp--;
                        sta[sp - 1] %= sta[sp];
                        break;

                    case 8:                                                                     //OPR 0 8;==判断相等
                        sp--;
                        sta[sp - 1] = (sta[sp] == sta[sp - 1] ? 1 : 0);
                        break;

                    case 9:                                                                        //OPR 0 9;!=判断不相等
                        sp--;
                        sta[sp - 1] = (sta[sp] != sta[sp - 1] ? 1 : 0);
                        break;

                    case 10:                                                                       //OPR 0 10;<判断小于
                        sp--;
                        sta[sp - 1] = (sta[sp - 1] < sta[sp] ? 1 : 0);
                        break;

                    case 11:                                                                        //OPR 0 11;>=判断大于等于
                        sp--;
                        sta[sp - 1] = (sta[sp - 1] >= sta[sp] ? 1 : 0);
                        break;

                    case 12:                                                                        //OPG 0 12;>判断大于
                        sp--;
                        sta[sp - 1] = (sta[sp - 1] > sta[sp] ? 1 : 0);
                        break;

                    case 13:                                                                         //OPG 0 13;<=判断小于等于
                        sp--;
                        sta[sp - 1] = (sta[sp - 1] <= sta[sp] ? 1 : 0);
                        break;
                    }
                    break;

                case Pcode.PC.LOD:                               //LOD 0 a;将变量值放到栈顶,a是存储空间,l是调用层与说明层的层次差
                    sta[sp] = sta[Base(currentCode.l, sta, bp) + currentCode.a];
                    sp++;
                    break;

                case Pcode.PC.STO:                            //STO 0 a; 将栈顶内容送入某变量单元中 ,a是存储空间
                    sp--;
                    sta[Base(currentCode.l, sta, bp) + currentCode.a] = sta[sp];
                    break;

                case Pcode.PC.CAL:                           //CAL 0 a; 调用过程,a是被调用过程的目标程序入口地址
                    sta[sp]     = Base(currentCode.l, sta, bp);
                    sta[sp + 1] = bp;
                    sta[sp + 2] = pc;
                    bp          = sp;
                    pc          = currentCode.a;
                    break;

                case Pcode.PC.INT:                        //INT 0 a; 在运行栈中为被调用的过程开辟a个单元的数据区
                    sp += currentCode.a;
                    break;

                case Pcode.PC.JMP:                       //JMP 0 a; 无条件跳转至a地址
                    pc = currentCode.a;
                    break;

                case Pcode.PC.JPC:                       //JPC 0 a; 条件跳转,当栈顶布尔值非真则跳转至a地址,否则顺序执行(假转)
                    sp--;
                    if (sta[sp] == 0)
                    {
                        pc = currentCode.a;
                    }
                    break;

                case Pcode.PC.WRT:                      //WRT 0 a:栈顶值输出至屏幕
                    output += sta[sp - 1].ToString() + " ";
                    sp--;
                    break;

                case Pcode.PC.RED:                     //RED 0 a: 读入一个输入置于栈顶
                    if (inputptr >= input.Length)
                    {
                        return(false);
                    }
                    int tmp = int.Parse(input[inputptr++]);
                    sta[sp] = tmp;
                    sta[Base(currentCode.l, sta, bp) + currentCode.a] = sta[sp];
                    break;
                }
                runtimeCount++;
                if (runtimeCount > 1400)
                {
                    StackOverflowException e = new StackOverflowException();
                    throw e;
                }
            } while (pc != 0);

            return(true);
        }