/** * Creates a deep clone of this {@link AIfStmIR} node while putting all * old node-new node relations in the map {@code oldToNewMap}. * @param oldToNewMap the map filled with the old node-new node relation * @return a deep clone of this {@link AIfStmIR} node */ public AIfStmIR clone(Map<INode,INode> oldToNewMap) { AIfStmIR node = new AIfStmIR( _sourceNode, _tag, _metaData, cloneNode(_ifExp, oldToNewMap), cloneNode(_thenStm, oldToNewMap), cloneList(_elseIf, oldToNewMap), cloneNode(_elseStm, oldToNewMap) ); oldToNewMap.put(this, node); return node; }
private AIfStmIR consMismatchCheck(AIdentifierVarExpIR successVar, SStmIR noMatchStm) { AIfStmIR ifCheck = new AIfStmIR(); ifCheck.setIfExp(transAssistant.consBoolCheck(successVar.getName(), true)); ifCheck.setThenStm(noMatchStm); return ifCheck; }
/** * Returns a deep clone of this {@link AIfStmIR} node. * @return a deep clone of this {@link AIfStmIR} node */ public AIfStmIR clone() { return new AIfStmIR( _sourceNode, _tag, _metaData, cloneNode(_ifExp), cloneNode(_thenStm), cloneList(_elseIf), cloneNode(_elseStm) ); }
protected List<SStmIR> consConditionalAdd(AIdentifierVarExpIR compResult, SStmIR collectionAdd) { if (predicate != null) { AIfStmIR condCollectionUnion = new AIfStmIR(); condCollectionUnion.setIfExp(predicate.clone()); condCollectionUnion.setThenStm(collectionAdd); return packStm(condCollectionUnion); } else { return packStm(collectionAdd); } }
AIfStmIR successVarCheck = new AIfStmIR(); successVarCheck.setIfExp(patternData.getSuccessVar().clone());
protected AIfStmIR consAndExpCheck(AAndBoolBinaryExpIR node, String andResultVarName) { SExpIR left = node.getLeft().clone(); SExpIR right = node.getRight().clone(); AIfStmIR leftCheck = new AIfStmIR(); leftCheck.setIfExp(left); AIfStmIR rightCheck = new AIfStmIR(); rightCheck.setIfExp(right); AAssignToExpStmIR assignAndVar = new AAssignToExpStmIR(); assignAndVar.setTarget(transAssistant.consBoolCheck(andResultVarName, false)); assignAndVar.setExp(transAssistant.getInfo().getAssistantManager().getExpAssistant().consBoolLiteral(true)); rightCheck.setThenStm(assignAndVar); leftCheck.setThenStm(rightCheck); return leftCheck; }
@Override public List<SStmIR> getPostOuterBlockStms(AIdentifierVarExpIR setVar, List<SPatternIR> patterns) { ALetBeStNoBindingRuntimeErrorExpIR noBinding = new ALetBeStNoBindingRuntimeErrorExpIR(); noBinding.setType(new AErrorTypeIR()); ARaiseErrorStmIR raise = new ARaiseErrorStmIR(); raise.setError(noBinding); AIfStmIR ifStm = new AIfStmIR(); ifStm.setIfExp(transAssist.consBoolCheck(successVarName, true)); ifStm.setThenStm(raise); return packStm(ifStm); } }
public AIfStmIR consConditionalIncrement(String counterName, SExpIR predicate) { AIdentifierVarExpIR col = new AIdentifierVarExpIR(); col.setType(new AIntNumericBasicTypeIR()); col.setIsLambda(false); col.setIsLocal(true); col.setName(counterName); AIncrementStmIR inc = new AIncrementStmIR(); inc.setVar(col); AIfStmIR ifStm = new AIfStmIR(); ifStm.setIfExp(predicate); ifStm.setThenStm(inc); return ifStm; }
raiseError.setError(runtimeError); AIfStmIR ifCheck = new AIfStmIR(); ifCheck.setIfExp(transAssistant.getInfo().getExpAssistant().negate(preCondCall)); ifCheck.setThenStm(raiseError);
AIfStmIR ifChecks = new AIfStmIR();
AIfStmIR whileCondCheck = new AIfStmIR(); whileCondCheck.setIfExp(transAssistant.consBoolCheck(whileCondName, true)); whileCondCheck.setThenStm(new ABreakStmIR());
private ABlockStmIR consUnionTypedTuplePatternCheck( boolean declarePatternVar, AUnionTypeIR unionType, PatternBlockData patternData, SExpIR actualValue, ATuplePatternIR tuplePattern) { ATupleTypeIR resTupleType = transAssistant.getInfo().getPatternAssistant().getTupleType(unionType, tuplePattern); ABlockStmIR tuplePatternCheck = consTuplePatternCheck(declarePatternVar, tuplePattern, resTupleType, patternData, actualValue, true); AIsOfClassExpIR instanceCheck = new AIsOfClassExpIR(); instanceCheck.setType(new ABoolBasicTypeIR()); instanceCheck.setCheckedType(patternData.getRootPatternVar().getType().clone()); instanceCheck.setExp(patternData.getRootPatternVar().clone()); AIfStmIR typeCheck = new AIfStmIR(); typeCheck.setIfExp(instanceCheck); typeCheck.setThenStm(tuplePatternCheck); ABlockStmIR block = new ABlockStmIR(); block.getStatements().add(typeCheck); return block; }
@Override public List<SStmIR> getPostOuterBlockStms(AIdentifierVarExpIR setVar, List<SPatternIR> patterns) { AEqualsBinaryExpIR noMatches = new AEqualsBinaryExpIR(); noMatches.setType(new ABoolBasicTypeIR()); noMatches.setLeft(transAssist.getInfo().getExpAssistant().consIdVar(counterName, new AIntNumericBasicTypeIR())); noMatches.setRight(transAssist.getInfo().getExpAssistant().consIntLiteral(0)); AIfStmIR ifStm = new AIfStmIR(); ifStm.setIfExp(noMatches); ifStm.setThenStm(consIotaMultipleResultsError()); return packStm(ifStm); }
@Override public void inATernaryIfExpIR(ATernaryIfExpIR node) throws AnalysisException { INode parent = node.parent(); if (parent instanceof AReturnStmIR) { AIfStmIR ifStm = new AIfStmIR(); ifStm.setSourceNode(node.getSourceNode()); ifStm.setIfExp(node.getCondition().clone()); AReturnStmIR thenStm = new AReturnStmIR(); thenStm.setExp(node.getTrueValue().clone()); ifStm.setThenStm(thenStm); AReturnStmIR elseStm = new AReturnStmIR(); elseStm.setExp(node.getFalseValue().clone()); ifStm.setElseStm(elseStm); baseAssistant.replaceNodeWithRecursively(parent, ifStm, this); } } }
protected SStmIR consOrExpCheck(AOrBoolBinaryExpIR node, String orResultVarName) { SExpIR left = node.getLeft().clone(); SExpIR right = node.getRight().clone(); AIfStmIR leftCheck = new AIfStmIR(); leftCheck.setIfExp(left); AAssignToExpStmIR setOrResultVarTrue = new AAssignToExpStmIR(); setOrResultVarTrue.setTarget(transAssistant.consBoolCheck(orResultVarName, false)); setOrResultVarTrue.setExp(transAssistant.getInfo().getAssistantManager().getExpAssistant().consBoolLiteral(true)); leftCheck.setThenStm(setOrResultVarTrue); AAssignToExpStmIR setOrResultVarToRightExp = new AAssignToExpStmIR(); setOrResultVarToRightExp.setTarget(transAssistant.consBoolCheck(orResultVarName, false)); setOrResultVarToRightExp.setExp(right); leftCheck.setElseStm(setOrResultVarToRightExp); return leftCheck; }
@Override public SStmIR caseAIfStm(AIfStm node, IRInfo question) throws AnalysisException { SExpIR ifExp = node.getIfExp().apply(question.getExpVisitor(), question); SStmIR thenStm = node.getThenStm().apply(question.getStmVisitor(), question); AIfStmIR ifStm = new AIfStmIR(); ifStm.setIfExp(ifExp); ifStm.setThenStm(thenStm); LinkedList<AElseIfStm> elseIfs = node.getElseIf(); for (AElseIfStm stm : elseIfs) { ifExp = stm.getElseIf().apply(question.getExpVisitor(), question); thenStm = stm.getThenStm().apply(question.getStmVisitor(), question); AElseIfStmIR elseIfStm = new AElseIfStmIR(); elseIfStm.setElseIf(ifExp); elseIfStm.setThenStm(thenStm); ifStm.getElseIf().add(elseIfStm); } if (node.getElseStm() != null) { SStmIR elseStm = node.getElseStm().apply(question.getStmVisitor(), question); ifStm.setElseStm(elseStm); } return ifStm; }
falseBranch.setExp(falseValue); AIfStmIR ifStm = new AIfStmIR(); ifStm.setIfExp(condition.clone()); ifStm.setThenStm(trueBranch);
LinkedList<STypeIR> types = tupleType.getTypes(); AIfStmIR fieldSizeCheck = new AIfStmIR(); fieldSizeCheck.setIfExp(patternData.getSuccessVar().clone()); fieldSizeCheck.setThenStm(consFieldCheckBlock(patternData, tuplePatternVar, patterns, types, cast));
assignInstance.setExp(newQuote); AIfStmIR ensureInstance = new AIfStmIR(); ensureInstance.setIfExp(nullCompare); ensureInstance.setThenStm(assignInstance);
assignHashcode.setExp(superCall); AIfStmIR hashcodeCheck = new AIfStmIR(); hashcodeCheck.setIfExp(hashcodeCompare); hashcodeCheck.setThenStm(assignHashcode);