Beispiel #1
0
        private void construct(TextReader stream, FunctionDefinition[] functionDefinitions, VariableDefinition[] variableDefinitions)
        {
            Debug.Assert(stream != null);
            Debug.Assert(functionDefinitions != null);

            m_compileTimeErrorHandler = new ErrorHandler();
            m_runtimeErrorHandler = new ErrorHandler();
            m_tokens = Tokenize(stream);
            m_ast = Parse(m_tokens);
            if(m_compileTimeErrorHandler.getErrors().Count > 0) { m_compileTimeErrorHandler.printErrorsToConsole(); return; }

            AddLocalVariables(m_ast, variableDefinitions);
            ExternalFunctionCreator externalFunctionCreator = AddExternalFunctions(functionDefinitions, m_ast);
            Scope globalScope = CreateScopeTree(m_ast);

            if(m_compileTimeErrorHandler.getErrors().Count > 0) { m_compileTimeErrorHandler.printErrorsToConsole(); return; }

            m_interpreter = new InterpreterTwo(m_ast, globalScope, m_runtimeErrorHandler, externalFunctionCreator);
            m_started = false;

            //PaintAST(m_ast);
        }
Beispiel #2
0
 public void HardReset()
 {
     // Setting these three things to null actually fixes the memory leak!
     m_ast = null;
     m_interpreter = null;
     m_programIterator = null;
 }