-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBRSCompilerInit.hx
More file actions
executable file
·54 lines (48 loc) · 1.46 KB
/
BRSCompilerInit.hx
File metadata and controls
executable file
·54 lines (48 loc) · 1.46 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
package brscompiler;
#if (macro || brs_runtime)
import haxe.macro.Context;
import reflaxe.BaseCompiler;
import reflaxe.ReflectCompiler;
import reflaxe.data.ClassFuncData;
import reflaxe.preprocessors.BasePreprocessor;
import reflaxe.preprocessors.ExpressionPreprocessor;
class BRSCompilerInit {
public static function Start() {
#if !eval
Sys.println("BRSCompilerInit.Start can only be called from a macro context.");
return;
#end
#if (haxe_ver < "4.3.0")
Sys.println("Reflaxe/brightscript requires Haxe version 4.3.0 or greater.");
return;
#end
ReflectCompiler.AddCompiler(new BRSCompiler(), {
expressionPreprocessors: [
SanitizeEverythingIsExpression({
convertIncrementAndDecrementOperators: true
}),
RemoveTemporaryVariables(OnlyAvoidTemporaryFieldAccess),
PreventRepeatVariables({}),
WrapLambdaCaptureVariablesInArray({}),
RemoveSingleExpressionBlocks,
RemoveConstantBoolIfs,
RemoveUnnecessaryBlocks,
// RemoveReassignedVariableDeclarations,
RemoveLocalVariableAliases,
MarkUnusedVariables,
],
fileOutputExtension: ".brs",
outputDirDefineName: "brightscript-output",
fileOutputType: SingleFile,
// fileOutputType: FilePerClass,
reservedVarNames: reservedNames(),
targetCodeInjectionName: "__brs__",
trackUsedTypes: true,
ignoreTypes: ["haxe.iterators.ArrayIterator"],
});
}
static function reservedNames() {
return ["pos", "end", "stop", "tab", "line", "next", "step", "run"];
}
}
#end