evaluateCases method
Implementation
EvaluateOutput evaluateCases(EvaluateInput input) {
final cases = input.expr.cases.cases;
for (final case_ in cases) {
if (case_.isOtherwise) {
return evaluateExpr(
EvaluateInput(defStack: input.defStack, expr: case_.otherwise));
} else {
final boolVal = evaluateExpr(
EvaluateInput(defStack: input.defStack, expr: case_.when));
if (boolVal.status != EvaluateOutput_Status.OK) {
return boolVal;
}
if (boolVal.value.type != Value_Type.BOOL) {
return _errorUnexpectedType(
case_.when.path, boolVal.value.type, [Value_Type.BOOL]);
}
if (boolVal.value.bool_2) {
return evaluateExpr(
EvaluateInput(defStack: input.defStack, expr: case_.then));
}
}
}
return _errorCasesNotExhaustive(input.expr.path.append(['cases']));
}