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
82 lines (76 loc) · 2.37 KB
/
Copy pathUnityScriptCompiler.cs
File metadata and controls
82 lines (76 loc) · 2.37 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
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using UnityEditor.Utils;
using UnityEngineInternal;
namespace UnityEditor.Scripting.Compilers
{
internal class UnityScriptCompiler : MonoScriptCompilerBase
{
private static readonly Regex UnityEditorPattern = new Regex("UnityEditor\\.dll$", RegexOptions.ExplicitCapture);
public UnityScriptCompiler(MonoIsland island, bool runUpdater) : base(island, runUpdater)
{
}
protected override CompilerOutputParserBase CreateOutputParser()
{
return new UnityScriptCompilerOutputParser();
}
protected override Program StartCompiler()
{
List<string> list = new List<string>
{
"-debug",
"-target:library",
"-i:UnityEngine",
"-i:System.Collections",
"-base:UnityEngine.MonoBehaviour",
"-nowarn:BCW0016",
"-nowarn:BCW0003",
"-method:Main",
"-out:" + this._island._output,
"-x-type-inference-rule-attribute:" + typeof(TypeInferenceRuleAttribute)
};
if (this.StrictBuildTarget())
{
list.Add("-pragmas:strict,downcast");
}
foreach (string current in this._island._defines.Distinct<string>())
{
list.Add("-define:" + current);
}
string[] references = this._island._references;
for (int i = 0; i < references.Length; i++)
{
string fileName = references[i];
list.Add("-r:" + ScriptCompilerBase.PrepareFileName(fileName));
}
bool flag = Array.Exists<string>(this._island._references, new Predicate<string>(UnityScriptCompiler.UnityEditorPattern.IsMatch));
if (flag)
{
list.Add("-i:UnityEditor");
}
else if (!BuildPipeline.IsUnityScriptEvalSupported(this._island._target))
{
list.Add(string.Format("-disable-eval:eval is not supported on the current build target ({0}).", this._island._target));
}
string[] files = this._island._files;
for (int j = 0; j < files.Length; j++)
{
string fileName2 = files[j];
list.Add(ScriptCompilerBase.PrepareFileName(fileName2));
}
string compiler = Path.Combine(base.GetProfileDirectory(), "us.exe");
return base.StartCompiler(this._island._target, compiler, list);
}
private bool StrictBuildTarget()
{
return Array.IndexOf<string>(this._island._defines, "ENABLE_DUCK_TYPING") == -1;
}
protected override string[] GetStreamContainingCompilerMessages()
{
return base.GetStandardOutput();
}
}
}