Example #1
0
        /// <summary>
        /// constructor 
        /// </summary>
        public Runtime(Parser parser)
        {
            m_parser = parser;

            m_executer = new Dictionary<int, Action<Statement>>()
            {
                { Statement.TYPE_PRINT, doPrint },
                { Statement.TYPE_ASSIGN, doAssign },
                { Statement.TYPE_IF, doIf },
                { Statement.TYPE_DATA, doData },
                { Statement.TYPE_READ, doRead },
                { Statement.TYPE_RESTORE, doRestore },
                { Statement.TYPE_GOTO, doGoto },
                { Statement.TYPE_END, doEnd },
                { Statement.TYPE_FOR_BEGIN, doForBegin },
                { Statement.TYPE_FOR_END, doForEnd },
                { Statement.TYPE_WHILE_BEGIN, onWhileBegin },
                { Statement.TYPE_WHILE_END, onWhileEnd },
                { Statement.TYPE_ON_GOTO, onOnGoto },
                { Statement.TYPE_GOSUB, onGoSub },
                { Statement.TYPE_RETURN, onReturn },
                { Statement.TYPE_POP, onPop },
                { Statement.TYPE_DEF_FN, onDefFn },
                { Statement.TYPE_DIM, onDim },
                { Statement.TYPE_SWAP, onSwap },
                { Statement.TYPE_INPUT, onInput },
                { Statement.TYPE_SIMPLE_CMD, onSimpleCmd },
                { Statement.TYPE_PARAM_CMD, onParamCmd },
            };

            // initial the context 
            m_dataRegion = new DataArea();
            m_symbolTable = new SymbolTable();
            m_forLoopStack = new Stack<ForRecord>();
            m_whileLoopStack = new Stack<WhileRecord>();
            m_goSubStack = new Stack<int>();

            m_innerFunc = new BuildinFunc();
        }
Example #2
0
        /// <summary>
        /// constructor
        /// </summary>
        public Runtime(Parser parser)
        {
            m_parser = parser;

            m_executer = new Dictionary <int, Action <Statement> >()
            {
                { Statement.TYPE_PRINT, doPrint },
                { Statement.TYPE_ASSIGN, doAssign },
                { Statement.TYPE_IF, doIf },
                { Statement.TYPE_DATA, doData },
                { Statement.TYPE_READ, doRead },
                { Statement.TYPE_RESTORE, doRestore },
                { Statement.TYPE_GOTO, doGoto },
                { Statement.TYPE_END, doEnd },
                { Statement.TYPE_FOR_BEGIN, doForBegin },
                { Statement.TYPE_FOR_END, doForEnd },
                { Statement.TYPE_WHILE_BEGIN, onWhileBegin },
                { Statement.TYPE_WHILE_END, onWhileEnd },
                { Statement.TYPE_ON_GOTO, onOnGoto },
                { Statement.TYPE_GOSUB, onGoSub },
                { Statement.TYPE_RETURN, onReturn },
                { Statement.TYPE_POP, onPop },
                { Statement.TYPE_DEF_FN, onDefFn },
                { Statement.TYPE_DIM, onDim },
                { Statement.TYPE_SWAP, onSwap },
                { Statement.TYPE_INPUT, onInput },
                { Statement.TYPE_SIMPLE_CMD, onSimpleCmd },
                { Statement.TYPE_PARAM_CMD, onParamCmd },
            };

            // initial the context
            m_dataRegion     = new DataArea();
            m_symbolTable    = new SymbolTable();
            m_forLoopStack   = new Stack <ForRecord>();
            m_whileLoopStack = new Stack <WhileRecord>();
            m_goSubStack     = new Stack <int>();

            m_innerFunc = new BuildinFunc();
        }