Skip to content

Version 2.0.0

Compare
Choose a tag to compare
@SomeRanDev SomeRanDev released this 20 Dec 05:25
· 411 commits to main since this release

December 20th, 2022

Release Notes

This is a much more stable and usable version of Reflaxe. Created and tested while developing the first release of Haxe-to-GDScript.

@:nativeFunctionCode

Added support for @:nativeFunctionCode to help inject function content for the target language. Similar to Haxe/C#'s @:functionCode, but you can also use "{this}" and "{argX}" to inject the "this" expression OR an argument passed to the function respectively.

While you could use an "extern inline" function + injection function (ie __gdscript__) to achieve a similar result, this method bypasses typing issues the Haxe compiler has when you make certain standard library methods "extern inline".

@:nativeFunctionCode("{this}[{arg0}]")
public function charAt(index: Int): String;

Extra File Methods

There are now functions to help generate additional source files outside of the ones generated automatically for each module/class/etc. Both these extra files and files generated in manual mode are now tracked and also automatically deleted using the deleteOldOutput feature.

Files are also no longer modified if they already contain the desired output (helps prevent triggering file-watchers in engines/editors even if nothing has changed).

EIE Sanitizer Improvements

Made huge improvements to EverythingIsExpressionSanitizer.

Now supports:
• Properly converting while/do-while conditions to execute within the loop.
• Wrapping variables in arrays when captured by lambdas.
• Assignment expressions that are expected to return a value.
• Converting prefix/postfix increment/decrement operators.
• Wrapping references to non-physical functions in a lambda, allowing for functions that are always inlined or use @:native / @:nativeFunctionCode to be passed and called like objects.

More BaseCompiler Options

reservedVarNames - List of variable names that are reserved on the target. Reflaxe will rename any Haxe variables that share the same names.
unwrapTypedefs - Unwraps typedefs automatically, helpful for ensuring static-calls (i.e. Class<haxe.Log>) are accounted for in smartDCE.
wrapLambdaCaptureVarsInArray - Enables/disables wrapping lambda-captured variables in Array.
preventRepeatVars - If the target is picky about variable shadowing, this ensures all variable names are unique with each method.
convertUnopIncrement - Converts uses of the ++/-- operators to += 1/-= 1 for targets that don't support those unary operators.

BaseCompiler Events

Added more methods to override on BaseCompiler: onCompileStart, onCompileEnd, and onOutputComplete.

Repeat Variable Fixer

Added check/fixer to ensure there are no repeat variable names, even in sub-scopes. (GDScript very picky and doesn't even allow local variable shadowing). Can be enabled/disabled with preventRepeatVars option.

Redundant Var Decl. Remover

Added optimization feature to move variable declarations to a subsequent assignment if unused in-between and on same scope level. Helps clean up code after "Everything Is Expression" sanitizer.

@:native Constructor Support

Added support for @:native on constructors. Replaces the entire "new Class" part with a function name, similar to how Haxe/C++ works. @:nativeFunctionCode also works for injecting exact target code.

ExpressionModifier/ClassModifier

Added the ExpressionModifier and ClassModifier helper classes for easily modifying certain class methods or expression patterns pre-typing using @:build macros.

Bug Fixes

Various improvements and bug fixes to things like ModuleUsageTracker and ExprOptimizer. In general, recursive expression seeking is much more powerful and consistent now.