*/
JMultiExpression multi = new JMultiExpression(info);
JExpression instance = maybeMakeTempAssignment(multi, x.getInstance());
// instance.method(arg, arg)
JMethodCall localCall = new JMethodCall(info, instance, x.getTarget());
localCall.addArgs(x.getArgs());
// We need a second copy of the arguments for the else expression
CloneExpressionVisitor cloner = new CloneExpressionVisitor(program);
// instance.jsoMethod(arg, arg)
JMethodCall jsoCall = new JMethodCall(info,
cloner.cloneExpression(instance), jsoMethod);
jsoCall.addArgs(cloner.cloneExpressions(x.getArgs()));
// Cast.isJavaScriptObject() ? instance.jsoMethod() :
// instance.method();
JConditional newExpr = makeIsJsoConditional(info,
cloner.cloneExpression(instance), x.getType(), jsoCall, localCall);
multi.exprs.add(newExpr);
// We may only have the ternary operation if there's no side-effect
ctx.replaceMe(multi.exprs.size() == 1 ? multi.exprs.get(0) : multi);
} else {
/*
* ... otherwise, if there's only a JSO implementation, we'll just
* call that directly.
*/
JMethodCall jsoCall = new JMethodCall(info, x.getInstance(),
jsoMethod);
jsoCall.addArgs(x.getArgs());
ctx.replaceMe(jsoCall);
}
}
}