Example #1
0
 private void AddEvaluationContextReferencesTo(UnityScriptCompiler compiler)
 {
     int index = 0;
     Assembly[] assemblyReferences = this._context.ScriptContainer.GetAssemblyReferences();
     int length = assemblyReferences.Length;
     while (index < length)
     {
         compiler.Parameters.get_References().Add(assemblyReferences[index]);
         index++;
     }
 }
Example #2
0
 private Type DoCompile()
 {
     UnityScriptCompiler compiler = new UnityScriptCompiler();
     compiler.Parameters.set_Pipeline(AdjustPipeline(this._context, UnityScriptCompiler.Pipelines.CompileToMemory()));
     compiler.Parameters.ScriptBaseType = typeof(EvaluationScript);
     compiler.Parameters.GlobalVariablesBecomeFields = false;
     compiler.Parameters.ScriptMainMethod = "Run";
     compiler.Parameters.get_Input().Add(new StringInput("script", this._code + ";"));
     compiler.Parameters.set_Debug(false);
     compiler.Parameters.set_GenerateInMemory(true);
     this.AddEvaluationContextReferencesTo(compiler);
     this._compilationResult = compiler.Run();
     if (this._compilationResult.get_Errors().Count != 0)
     {
         throw new CompilationErrorsException(this._compilationResult.get_Errors());
     }
     return this._compilationResult.get_GeneratedAssembly().GetType("script");
 }