@Override public PAlternatives withTypeValueReplaced(MTType t) { return new PAlternatives( RCollections.map(myAlternatives, UnboxCondition.INSTANCE), RCollections.map(myAlternatives, UnboxResult.INSTANCE), myOtherwiseClauseResult, myType, t); }
@Override public PAlternatives replaceLast(PExp newExpression) { List<PExp> newConditions = RCollections.map(myAlternatives, UnboxCondition.INSTANCE); List<PExp> newResults = RCollections.map(myAlternatives, UnboxResult.INSTANCE); PExp newOtherwise = myOtherwiseClauseResult; if (myReturnedOtherwiseFlag) { newOtherwise = newExpression; } else { if (myCurAlternative == null) { newConditions.set(myCurAlternativeNum, newExpression); } else { newResults.set(myCurAlternativeNum, newExpression); } } return new PAlternatives(newConditions, newResults, newOtherwise, myType, myTypeValue); }
@Override public PAlternatives withSubExpressionReplaced(int index, PExp e) { List<PExp> newResults = RCollections.map(myAlternatives, UnboxResult.INSTANCE); List<PExp> newConditions = RCollections.map(myAlternatives, UnboxCondition.INSTANCE); PExp newOtherwise = myOtherwiseClauseResult; if (index < 0 || index > (myAlternatives.size() * 2) + 1) { throw new IndexOutOfBoundsException("" + index); } else { index /= 2; if (index % 2 == 0) { if (index < myAlternatives.size()) { newResults.set(index, e); } else { newOtherwise = e; } } else { newConditions.set(index, e); } } return new PAlternatives(newConditions, newResults, newOtherwise, myType, myTypeValue); }