예제 #1
0
        //выполнение инструкции call
        private void ExecuteCall(Instruction inst)
        {
            CallInst callInst = (CallInst)inst;

            PushNewFuncIntoStack(callInst.CallerFunc);
            ExecuteFuncion(callInst.CallerFunc);
        }
예제 #2
0
        //выполнение текущей инструкции
        public OutputMessage ExecuteCurrentInst(bool stepInto, CancellationToken cancellationToken)
        {
            mCancelToken = cancellationToken;
            try
            {
                if (stepInto && mCurrentInst.Type == InstType.CALL)
                {
                    //выполнение вызова с заходом
                    CallInst callInst = (CallInst)mCurrentInst;
                    PushNewFuncIntoStack(callInst.CallerFunc, mCurrentInstNo);
                    mCurrentFunc   = callInst.CallerFunc;
                    mCurrentInstNo = -1;
                }
                else
                {
                    //выполнение инструкции
                    ExecuteInstruction(mCurrentInst);
                }
                mCurrentInstNo++;


                while (mInnerView.Functions[mCurrentFunc].Length <= mCurrentInstNo)
                {
                    //последняя инструкция функции выполнена
                    if (mStackTrace.Count != 1)
                    {
                        //возвращение из функции
                        mCurrentInstNo = mStackTrace.Pop().InstNo + 1;
                        mCurrentFunc   = mStackTrace.Peek().FuncName;
                    }
                    else
                    {
                        //завершение работы программы
                        mOutputMessage.LineNo = -1;
                        return(mOutputMessage);
                    }
                }
                mCurrentInst = mInnerView.Functions[mCurrentFunc][mCurrentInstNo];

                mStackTrace.Peek().LineNo = mCurrentInst.LineNo;

                //заполнение вывода
                FillOutputMessage();
            }
            catch (OperationCanceledException)
            {
                mOutputMessage.Output += "Cancel\n";
            }
            catch (Exception e)
            {
                mOutputMessage.Output += $"{e.Message}\n";
            }

            return(mOutputMessage);
        }