An extended version of the GenericCompiler that uses String for all the "compile" function return types.

Constructor

new()

Methods

compileClassFuncExpr(expr:TypedExpr):String

Alias for compileClassVarExpr for function expressions.

This might be updated with additional behavior in future versions of Reflaxe, so be sure to use for functions even if it works identically to compileClassVarExpr.

compileClassVarExpr(expr:TypedExpr):String

Returns the result of compileExpressionsIntoLines from the expr.

@:value({ topLevel : false })compileExpression(expr:TypedExpr, topLevel:Bool = false):Null<String>

Overridden to add target-code injection support.

compileExpressionForCodeInject(expr:TypedExpr):Null<String>

Compiles an expression for a target code injection argument.

compileExpressionsIntoLines(exprList:Array<TypedExpr>):String

Convert a list of expressions to lines of output code. The lines of code are spaced out to make it feel like it was human-written.

compileNFCThisExpression(expr:TypedExpr, meta:Null<MetaAccess>):String

Compiles the {this} expression for @:nativeFunctionCode.

@:value({ custom : null, typeParamsCallback : null })compileNativeFunctionCodeMeta(callExpr:TypedExpr, arguments:Array<TypedExpr>, ?typeParamsCallback:Int ‑> Null<String>, ?custom:String ‑> String):Null<String>

This function is for compiling the result of functions using the @:nativeFunctionCode meta.

@:value({ typeParams : null })compileNativeTypeCodeMeta(type:Type, ?typeParams:Array<() ‑> String>):Null<String>

This function is for compiling the result of functions using the @:nativeTypeCode meta.

@:value({ varCpp : null })compileNativeVariableCodeMeta(fieldExpr:TypedExpr, ?varCpp:String):Null<String>

This function is for compiling the result of functions using the @:nativeVariableCode meta.

generateOutputIterator():Iterator<DataAndFileInfo<StringOrBytes>>

Iterate through all output Strings.

injectExpressionPrefixContent(content:String):Bool

If called while compiling multiple expressions, this will inject content prior to the expression currently being compiled.

Inherited Variables

Defined by BaseCompiler

@: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

Inherited Methods

Defined by GenericCompiler

compileAbstract(abstractType:AbstractType):Void

Compiles the provided abstract. Override compileAbstractImpl to configure the behavior.

compileAbstractImpl(abstractType:AbstractType):Null<CompiledAbstractType>

compileClass(classType:ClassType, varFields:Array<ClassVarData>, funcFields:Array<ClassFuncData>):Void

Compiles the provided class. Override compileClassImpl to configure the behavior.

compileClassImpl(classType:ClassType, varFields:Array<ClassVarData>, funcFields:Array<ClassFuncData>):Null<CompiledClassType>

compileEnum(enumType:EnumType, options:Array<EnumOptionData>):Void

Compiles the provided enum. Override compileEnumImpl to configure the behavior.

compileEnumImpl(enumType:EnumType, options:Array<EnumOptionData>):Null<CompiledEnumType>

compileExpressionImpl(expr:TypedExpr, topLevel:Bool):Null<CompiledExpressionType>

compileExpressionOrError(expr:TypedExpr):CompiledExpressionType

Compiles the provided expression. Generates an error using Context.error if unsuccessful.

compileTypedef(typedefType:DefType):Void

Compiles the provided typedef. Override compileTypedefImpl to configure the behavior.

compileTypedefImpl(typedefType:DefType):Null<CompiledTypedefType>

Defined by BaseCompiler

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.

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.

@: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.

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