Skip to content

Commit

Permalink
WIP: Refactor function invokations to use safe context for isNull arg…
Browse files Browse the repository at this point in the history
…uments

This is not currently working (yet), but the idea is to support safe referencing of non-existent variables.
  • Loading branch information
michaelborn committed Jan 5, 2024
1 parent 1a96f59 commit d9fc7b2
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,24 @@ public BoxFunctionInvocationTransformer( JavaTranspiler transpiler ) {
@Override
public Node transform( BoxNode node, TransformerContext context ) throws IllegalStateException {

BoxFunctionInvocation function = ( BoxFunctionInvocation ) node;
String side = context == TransformerContext.NONE ? "" : "(" + context.toString() + ") ";
BoxFunctionInvocation function = ( BoxFunctionInvocation ) node;
String methodName = function.getName().getName();
boolean isSafeMethodCall = methodName.equalsIgnoreCase( "isnull" );
TransformerContext safe = isSafeMethodCall ? TransformerContext.SAFE : context;
String side = safe == TransformerContext.NONE ? "" : "(" + safe.toString() + ") ";

logger.info( side + node.getSourceText() );

Map<String, String> values = new HashMap<>() {

{
put( "functionName", createKey( function.getName().getName() ).toString() );
put( "functionName", createKey( methodName ).toString() );
put( "contextName", transpiler.peekContextName() );
}
};

for ( int i = 0; i < function.getArguments().size(); i++ ) {
Expression expr = ( Expression ) transpiler.transform( function.getArguments().get( i ) );
Expression expr = ( Expression ) transpiler.transform( function.getArguments().get( i ), safe );
values.put( "arg" + i, expr.toString() );
}
String template = getTemplate( function );
Expand Down

0 comments on commit d9fc7b2

Please sign in to comment.