Expression condExpression = conditionExpressions.getConditionExpression();
ExpressionContextPair pair;
pair = generateUnboxedArgument(JavaTypeName.BOOLEAN, condExpression, variableContext);
Block contextBlock = pair.getContextBlock();
JavaExpression condJavaExpression = pair.getJavaExpression();
ExpressionContextPair thenPart = genS_E (conditionExpressions.getThenExpression(), variableContext);
ExpressionContextPair elsePart = genS_E (conditionExpressions.getElseExpression(), variableContext);
// Note: both contexts are evaluated..
contextBlock.addStatement(thenPart.getContextBlock());
contextBlock.addStatement(elsePart.getContextBlock());
OperatorExpression ternaryExpression = new OperatorExpression.Ternary(condJavaExpression, new JavaExpression.CastExpression(JavaTypeNames.RTVALUE, thenPart.getJavaExpression()), elsePart.getJavaExpression());
return new ExpressionContextPair(ternaryExpression, contextBlock);
}
// With the changes to the compiler to lift inner cases into their own function
// we should never encounte a case at this level.
// Expression is a case/switch?
if (e.asSwitch() != null) {
throw new CodeGenerationException ("Encountered a case statement that wasn't at top level in schemeE.");
}
// Similarly, we should never encounter a data constructor field selection.
if (e.asDataConsSelection() != null) {
return generateDCFieldSelection(e.asDataConsSelection(), Scheme.E_SCHEME, variableContext);
//throw new CodeGenerationException ("Encountered a data constructor field selection at an inner level. schemeE.");
}
// R is a let var.
if (e.asLetNonRec() != null) {
return generateLetNonRec (e.asLetNonRec(), Scheme.E_SCHEME, null, variableContext);
}
if (e.asLetRec() != null) {
return generateLetRec (e.asLetRec(), Scheme.E_SCHEME, variableContext);
}
// R is an application?
Expression.Appl appl = e.asAppl();
if (appl != null) {
ExpressionContextPair ecp = buildApplicationChain (appl, Scheme.E_SCHEME, variableContext);
if (ecp == null) {
// This is a general application
ExpressionContextPair target = genS_C(appl.getE1(), variableContext);
ExpressionContextPair arg = genS_C(appl.getE2(), variableContext);
Block newContextBlock = target.getContextBlock();
newContextBlock.addStatement(arg.getContextBlock());
MethodInvocation applyMI = createInvocation(target.getJavaExpression(), APPLY, arg.getJavaExpression());
MethodInvocation evaluateMI = createInvocation(applyMI, EVALUATE, EXECUTION_CONTEXT_VAR);//, ExecutionContextClassName));
ecp = new ExpressionContextPair(evaluateMI, newContextBlock);