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

new()

Variables

@:value([])read onlycompileEndCallbacks:Array<() ‑> Void> = []

@:value([])dynamicTypeStack:Array<ModuleType> = []

These fields are used for the dynamicDCE option. While enabled, use addModuleTypeForCompilation to add additional ModuleTypes to be compiled.

@:value([])dynamicTypesHandled:Array<String> = []

@:value([])read onlyexpressionPreprocessors:Array<ExpressionPreprocessor> = []

@:value([])read onlyextraFiles:Map<String, Map<Int, String>> = []

@:value({ })read onlyoptions:BaseCompilerOptions = { }

@:value(null)read onlyoutput:Null<OutputManager> = null

Methods

addModuleTypeForCompilation(mt:ModuleType):Void

addReservedVarName(name:String):Void

Manually adds a reserved variable name that cannot be used in the output.

@:value({ priority : 0 })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.

@:value({ field : null, expr : null })compileVarName(name:String, ?expr:TypedExpr, ?field:ClassField):String

Compiles the provided variable name. Ensures it does not match any of the reserved variable names.

extraFileExists(path:OutputPath):Bool

Check if an extra file exists.

generateFiles():Void

Generates the output.

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)

@:value({ position : null })generateInjectionExpression(content:String, ?position:Position):TypedExpr

Generates an "injection" expression if possible.

generateOutputIterator():Iterator<DataAndFileInfo<StringOrBytes>>

Used to configure how output is generated automatically.

getCurrentModule():Null<ModuleType>

@:value({ priority : 0 })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.

onAbstractAdded(cls:AbstractType, output:Null<String>):Void

onClassAdded(cls:ClassType, output:Null<String>):Void

onEnumAdded(cls:EnumType, output:Null<String>):Void

onExpressionUnsuccessful(pos:Position):CompiledExpressionType

Given a haxe.macro.Position, generates an error at the position stating: "Could not generate expression".

onTypedefAdded(cls:DefType, output:Null<String>):Void

@:value({ priority : 0 })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.

@:value({ content : "" })setExtraFile(path:OutputPath, content:String = ""):Void

Set all the content for an arbitrary file added to the output folder.

@:value({ content : "" })setExtraFileIfEmpty(path:OutputPath, content:String = ""):Void

Set all the content for a file if it doesn't exist yet.

setOutputDir(outputDir:String):Void

Sets the directory files will be generated in.

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.

shouldGenerateClass(cls:ClassType):Bool

shouldGenerateClassField(cls:ClassField):Bool

shouldGenerateEnum(enumType:EnumType):Bool