public CompileUnit[] Run() { CompilerContext compilerContext = _compiler.Run(); if (((ICollection)compilerContext.Errors).Count != 0) { throw new CompilationErrorsException(compilerContext.Errors); } CompileUnit compileUnit = compilerContext.CompileUnit; CompileUnit node = compileUnit.CloneNode(); return(new CompileUnit[] { ApplyCSharpTransformer(compileUnit), ApplyBooTransformer(node) }); }
private Type DoCompile() { UnityScriptCompiler compiler = new UnityScriptCompiler { Parameters = { Pipeline = AdjustPipeline(this._context, UnityScriptCompiler.Pipelines.CompileToMemory()), ScriptBaseType = typeof(EvaluationScript), GlobalVariablesBecomeFields = false, ScriptMainMethod = "Run" } }; compiler.Parameters.Input.Add(new StringInput("script", this._code + ";")); compiler.Parameters.Debug = false; compiler.Parameters.GenerateInMemory = true; this.AddEvaluationContextReferencesTo(compiler); this._compilationResult = compiler.Run(); if (this._compilationResult.Errors.Count != 0) { throw new CompilationErrorsException(this._compilationResult.Errors); } return(this._compilationResult.GeneratedAssembly.GetType("script")); }
public CompileUnit SetUpTypeInferenceSource() { CompilerPipeline compilerPipeline = UnityScriptCompiler.Pipelines.AdjustBooPipeline(new ResolveExpressions()); compilerPipeline.RemoveAt(compilerPipeline.Find(typeof(ApplySemantics))); compilerPipeline.BreakOnErrors = false; var unityScriptCompiler = new UnityScriptCompiler(new UnityScriptCompilerParameters(My <IReflectionTypeSystemProvider> .Instance, false)); CopyUnityScriptCompilerParametersTo(unityScriptCompiler); unityScriptCompiler.Parameters.Pipeline = compilerPipeline; unityScriptCompiler.Parameters.AddToEnvironment( typeof(TypeInferenceRuleProvider), GetCustomTypeInferenceRuleProvider); var compilerContext = unityScriptCompiler.Run(CompileUnit.CloneNode()); if (((ICollection)compilerContext.Errors).Count != 0) { throw new CompilationErrorsException(compilerContext.Errors); } return(compilerContext.CompileUnit); }