Example #1
0
        public SkryptEngine Execute(string code, ParserOptions parserOptions, bool isImporting = false, LexicalEnvironment lexicalEnvironment = null)
        {
            var program = ParseProgram(code, parserOptions);

            return(Execute(program, isImporting, lexicalEnvironment));
        }
Example #2
0
        internal SkryptEngine Execute(SkryptParser.ProgramContext program, bool isImporting = false, LexicalEnvironment lexicalEnvironment = null)
        {
            if (SW == null)
            {
                SW = Stopwatch.StartNew();
            }
            else
            {
                SW.Start();
            }

            ProgramContext = program;

            if (MemoryLimit > 0)
            {
                ResetMemoryUsage();
            }

            Visitor.CurrentEnvironment = lexicalEnvironment ?? GlobalEnvironment;
            Visitor.Visit(ProgramContext);

            foreach (var kv in InitializeOnParse)
            {
                if (!kv.Value.IsInitialized)
                {
                    kv.Value.Initialize();
                }
            }

            if (!_discardGlobal)
            {
                CreateGlobals();
            }

            SW.Stop();

            return(this);
        }