The super class all compilers should extend from. The behavior of how the Haxe AST is transpiled is configured by implementing the abstract methods.
Constructor
Variables
dynamicTypeStack:Array<ModuleType> = []
These fields are used for the dynamicDCE
option.
While enabled, use addModuleTypeForCompilation
to
add additional ModuleTypes to be compiled.
Methods
addReservedVarName(name:String):Void
Manually adds a reserved variable name that cannot be used in the output.
appendToExtraFile(path:OutputPath, content:String, priority:Int = 0):Void
Set the content or append it if it already exists. The "priority" allows for content to be appended at different places within the file.
compileAbstract(classType:AbstractType):Void
Compiles the provided abstract. Defined in GenericCompiler
.
It ignores all abstracts by default since Haxe converts them to function calls.
compileClass(classType:ClassType, varFields:Array<ClassVarData>, funcFields:Array<ClassFuncData>):Void
Compiles the provided class. Defined in GenericCompiler
.
Override compileClassImpl to configure the behavior.
compileEnum(enumType:EnumType, options:Array<EnumOptionData>):Void
Compiles the provided enum. Defined in GenericCompiler
.
Override compileEnumImpl to configure the behavior.
compileMetadata(metaAccess:Null<MetaAccess>, target:MetadataTarget):Null<String>
Compiles the Haxe metadata to the target's equivalent.
This function will always return null
unless
"allowMetaMetadata" is true or "metadataTemplates"
contains at least one entry.
compileTypedef(classType:DefType):Void
Compiles the provided typedef. Defined in GenericCompiler
.
It ignores all typedefs by default since Haxe redirects all types automatically.
compileVarName(name:String, ?expr:TypedExpr, ?field:ClassField):String
Compiles the provided variable name. Ensures it does not match any of the reserved variable names.
generateFilesManually():Void
If you wish to code how files are generated yourself, override this function in child class and set options.fileOutputType to "Manual".
Files should be saved using output.saveFile(path, content)
generateInjectionExpression(content:String, ?position:Position):TypedExpr
Generates an "injection" expression if possible.
generateOutputIterator():Iterator<DataAndFileInfo<StringOrBytes>>
Used to configure how output is generated automatically.
getExtraFileContent(path:OutputPath, priority:Int = 0):String
Returns the contents of the file if it exists. The "priority" can be specified to get content specifically assigned that priority level.
Returns an empty string if nothing exists.
getMainExpr():Null<TypedExpr>
Returns the "main" typed expression for the program.
For example, if -main MyClass
is set in the project,
the expression will be: MyClass.main()
.
Please note if using Haxe v4.2.5 or below, the main
class must be defined using -D mainClass
.
For example: -D mainClass=MyClass
.
getMainModule():Null<ModuleType>
Extracts the ModuleType
of the main class based on
getMainExpr
function.
onExpressionUnsuccessful(pos:Position):CompiledExpressionType
Given a haxe.macro.Position
, generates an error at the
position stating: "Could not generate expression".
replaceInExtraFile(path:OutputPath, content:String, priority:Int = 0):Void
Set the content or append it if it already exists. The "priority" allows for content to be appended at different places within the file.
setExtraFile(path:OutputPath, content:String = ""):Void
Set all the content for an arbitrary file added to the output folder.
setExtraFileIfEmpty(path:OutputPath, content:String = ""):Void
Set all the content for a file if it doesn't exist yet.
setOutputFileDir(dir:Null<String>):Void
Use while compiling a module type (typically through
one of the BaseCompiler
override methods like
compileClassImpl
) to set the output directory of
the file containing the output for the type being compiled.
Subdirectories can be used with the forward slash.
Setting to an empty String
or null
will result
in the file being generated in the top directory
(the output directory).
setOutputFileName(name:Null<String>):Void
Use while compiling a module type (typically through
one of the BaseCompiler
override methods like
compileClassImpl
) to set the name of the file
that will contain the output being generated.
Setting to an empty String
or null
will result
in the default file name being used.
setupModule(mt:Null<ModuleType>):Void
Called before compileClass, compileEnum, etc. to setup fields to be referenced.