forked from MattRix/UnityDecompiled
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnityScriptCompiler.cs
More file actions
91 lines (77 loc) · 3.7 KB
/
Copy pathUnityScriptCompiler.cs
File metadata and controls
91 lines (77 loc) · 3.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
namespace UnityScript
{
using Boo.Lang.Compiler;
using Boo.Lang.Compiler.Ast;
using Boo.Lang.Compiler.Pipelines;
using Boo.Lang.Compiler.Steps;
using System;
using UnityScript.Steps;
[Serializable]
public class UnityScriptCompiler
{
protected BooCompiler _compiler;
protected UnityScriptCompilerParameters _parameters;
public UnityScriptCompiler() : this(new UnityScriptCompilerParameters())
{
}
public UnityScriptCompiler(UnityScriptCompilerParameters parameters)
{
if (parameters == null)
{
throw new ArgumentNullException("parameters");
}
this._parameters = parameters;
this._compiler = new BooCompiler(this._parameters);
}
public CompilerContext Run() =>
this._compiler.Run();
public CompilerContext Run(CompileUnit compileUnit) =>
this._compiler.Run(compileUnit);
public UnityScriptCompilerParameters Parameters =>
this._parameters;
public static class Pipelines
{
public static CompilerPipeline AdjustBooPipeline(CompilerPipeline pipeline)
{
pipeline.Insert(0, new PreProcess());
pipeline.Replace(typeof(Parsing), new UnityScript.Steps.Parse());
pipeline.Replace(typeof(IntroduceGlobalNamespaces), new IntroduceUnityGlobalNamespaces());
pipeline.InsertAfter(typeof(PreErrorChecking), new ApplySemantics());
pipeline.InsertAfter(typeof(ApplySemantics), new ApplyDefaultVisibility());
pipeline.InsertBefore(typeof(ExpandDuckTypedExpressions), new ProcessAssignmentToDuckMembers());
pipeline.Replace(typeof(ProcessMethodBodiesWithDuckTyping), new ProcessUnityScriptMethods());
pipeline.InsertAfter(typeof(ProcessUnityScriptMethods), new AutoExplodeVarArgsInvocations());
pipeline.InsertAfter(typeof(ProcessUnityScriptMethods), new ProcessEvalInvocations());
pipeline.ReplaceOptional(typeof(ExpandDuckTypedExpressions), new ExpandUnityDuckTypedExpressions());
pipeline.InsertBefore(typeof(EmitAssembly), new Lint());
pipeline.InsertBefore(typeof(EmitAssembly), new EnableRawArrayIndexing());
pipeline.InsertAfter(typeof(BindBaseTypes), new CheckBaseTypes());
return pipeline;
}
public static CompilerPipeline Compile() =>
AdjustBooPipeline(new Boo.Lang.Compiler.Pipelines.Compile());
public static CompilerPipeline CompileToBoo() =>
AdjustBooPipeline(new Boo.Lang.Compiler.Pipelines.CompileToBoo());
public static CompilerPipeline CompileToFile() =>
AdjustBooPipeline(new Boo.Lang.Compiler.Pipelines.CompileToFile());
public static CompilerPipeline CompileToMemory() =>
AdjustBooPipeline(new Boo.Lang.Compiler.Pipelines.CompileToMemory());
public static CompilerPipeline Parse()
{
CompilerPipeline pipeline;
CompilerPipeline pipeline1 = pipeline = RawParsing();
pipeline.Add(new ApplySemantics());
pipeline.Add(new ApplyDefaultVisibility());
return pipeline;
}
public static CompilerPipeline RawParsing()
{
CompilerPipeline pipeline;
CompilerPipeline pipeline1 = pipeline = new CompilerPipeline();
pipeline.Add(new PreProcess());
pipeline.Add(new UnityScript.Steps.Parse());
return pipeline;
}
}
}
}