/// <summary> /// 実際に実行する部分。 /// </summary> protected virtual object ExecuteCore(TextReader stream, string filename) { Contract.Requires <ArgumentNullException>(stream != null); Contract.Requires <ArgumentNullException>(filename != null); Initialize(); Func <Scope, object> program; { // Compile var sw = Stopwatch.StartNew(); var token = Tokenizer.Tokenize(stream, filename); var ast = Parser.Parse(token, filename); var expr = ExpressionGenerator.Generate(ast, this.Factory, filename); expr = ExpressionOptimizer.Analyze(expr); program = CompilerHelpers.Compile(expr, true); //program = expr.Compile(); sw.Stop(); var ev = OnCompiled; if (ev != null) { ev(this, new EngineEventArgs(sw.ElapsedMilliseconds)); } } { // Execute var sw = Stopwatch.StartNew(); var result = program(this.Global); sw.Stop(); var ev = OnExecuted; if (ev != null) { ev(this, new EngineEventArgs(sw.ElapsedMilliseconds)); } return(result); } }