Skip to content

Commit

Permalink
Fix DirectToStringCompiler expression hook
Browse files Browse the repository at this point in the history
  • Loading branch information
SomeRanDev committed Dec 11, 2023
1 parent ea46057 commit 9358712
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/reflaxe/DirectToStringCompiler.hx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import reflaxe.GenericCompiler;
import reflaxe.compiler.TargetCodeInjection;
import reflaxe.optimization.ExprOptimizer;
import reflaxe.output.DataAndFileInfo;
import reflaxe.output.PluginHook;
import reflaxe.output.StringOrBytes;

using StringTools;
Expand All @@ -32,7 +33,29 @@ abstract class DirectToStringCompiler extends GenericCompiler<String, String, St
}
}

return compileExpressionImpl(expr, topLevel);
// Copied from `GenericCompiler`, could there be better way to do this??

#if reflaxe_hooks
final hookResult = compileBeforeExpressionHook.call(null, this, expr, topLevel);
switch(hookResult) {
case IgnorePlugin:
case OutputNothing: return null;
case OverwriteOutput(output): return output;
}
#end

final result = compileExpressionImpl(expr, topLevel);

#if reflaxe_hooks
final hookResult = compileExpressionHook.call(result, this, expr, topLevel);
switch(hookResult) {
case IgnorePlugin:
case OutputNothing: return null;
case OverwriteOutput(output): return output;
}
#end

return result;
}

/**
Expand Down

0 comments on commit 9358712

Please sign in to comment.