internal CompiledScript(GlobalMethodGenerator methodGen) { if (methodGen == null) { throw new ArgumentNullException("methodGen"); } this.methodGen = methodGen; }
/// <summary> /// Compiles source code into a quickly executed form, using the given compiler options. /// </summary> /// <param name="source"> The javascript source code to execute. </param> /// <param name="options"> Compiler options, or <c>null</c> to use the default options. </param> /// <returns> A CompiledScript instance, which can be executed as many times as needed. </returns> /// <exception cref="ArgumentNullException"> <paramref name="source"/> is a <c>null</c> reference. </exception> public static CompiledScript Compile(ScriptSource source, CompilerOptions options) { var methodGen = new GlobalMethodGenerator( source, // The source code. options ?? new CompilerOptions()); // The compiler options. // Parse methodGen.Parse(); // Optimize methodGen.Optimize(); // Generate code methodGen.GenerateCode(); return(new CompiledScript(methodGen)); }