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> = []

Used internally with addModuleTypeForCompilation for the manualDCE option.

A stack of ModuleTypes yet to be processed.

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

Used internally with addModuleTypeForCompilation for the manualDCE option.

A list of ModuleType unique identifiers that have been queued once.

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

This function is to be used in conjunction with the manualDCE option.

With manualDCE enabled, types encountered while compiling should be passed to this function to be added to the compilation queue.

Any repeats will NOT be re-queued, you are safe (as expected) to spam this function as much as you want.

You should essentially call this for: - The type of every variable compiled. - The type of every expression compiled. - All argument and return types for every function compiled.

Use addTypeForCompilation to pass a haxe.macro.Type instead.

addReservedVarName(name:String):Void

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

addTypeForCompilation(type:Type):Bool

See addModuleTypeForCompilation.

Works the same as addModuleTypeForCompilation but takes a haxe.macro.Type instead of haxe.macro.ModuleType.

Returns false if the haxe.macro.Type couldn't be converted to haxe.macro.ModuleType.

@:value({ priority : 0 })appendToExtraFile(path:OutputPath, content:String, priority:Int = 0):Void

Set the content or append it if it already exists.

priority dictates where the content is appended relative to other calls to these functions.

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.

filterTypes(moduleTypes:Array<ModuleType>):Array<ModuleType>

A function intended to be overriden by your compiler class.

This is called once at the start of compilation.

moduleTypes is an array of ALL types supplied by the Haxe compiler. Removing (or adding?) entries from this will change what modules are sent to your compiler.

moduleTypes is a unique copy made specifically for this function, so it is safe to modify directly and return it.

To enable the exact behavior supplied by the deprecated smartDCE option, the following code can be used:

public override function filterTypes(moduleTypes: Array<ModuleType>): Array<ModuleType> {
	final tracker = new reflaxe.input.ModuleUsageTracker(moduleTypes, this);
	return tracker.filteredTypes(this.options.customStdMeta);
}

generateFiles():Void

Generates the output.

generateFilesManually():Void

A function intended to be overriden by your compiler class.

This is called once at the end of compilation if options.fileOutputType is set to Manual.

This is where you can generate your output files manually instead of relying on Reflaxe's default output system.

Files should be saved using output.saveFile(path, content)

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

Generates an "injection" expression if possible.

// For example:
generateInjectionExpression("const booty <= (1,2)");

// Returns a dynamically-typed `TypedExpr` for the expression:
untyped __LANG__("const booty <= (1,2)");

getCurrentModule():Null<ModuleType>

Public getter for currentModule.

@:value({ priority : 0 })getExtraFileContent(path:OutputPath, priority:Int = 0):String

Returns the contents of the file if it exists.

priority dictates where the content is appended relative to other calls to these functions.

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.

priority dictates where the content is appended relative to other calls to these functions.

@: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 name of the file that will contain the output being generated.

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 set up fields to be referenced.

shouldGenerateClass(cls:ClassType):Bool

A function intended to be overriden by your compiler class.

This is called at the start of compilation for each class.

If false is returned, the class will not be sent to your compiler later.

shouldGenerateClassField(cls:ClassField):Bool

A function intended to be overriden by your compiler class.

This is called at the start of compilation for each class field.

If false is returned, a ClassFuncData or ClassVarData will not be generated for the field. The field will still be accessible from the ClassType however.

shouldGenerateEnum(enumType:EnumType):Bool

A function intended to be overriden by your compiler class.

This is called at the start of compilation for each enum.

If false is returned, the enum will not be sent to your compiler later.