/** * Called by the {@link AEqualsBinaryExpIR} node from {@link AEqualsBinaryExpIR#apply(IAnalysis)}. * @param node the calling {@link AEqualsBinaryExpIR} node */ public void caseAEqualsBinaryExpIR(AEqualsBinaryExpIR node) throws AnalysisException { _visitedNodes.add(node); inAEqualsBinaryExpIR(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this); } if(node.getLeft() != null && !_visitedNodes.contains(node.getLeft())) { node.getLeft().apply(this); } if(node.getRight() != null && !_visitedNodes.contains(node.getRight())) { node.getRight().apply(this); } outAEqualsBinaryExpIR(node); }
public static SExpIR consIsExpQuoteType(SExpIR exp, AQuoteTypeIR quoteType) { AQuoteLiteralExpIR lit = new AQuoteLiteralExpIR(); lit.setType(quoteType); lit.setValue(quoteType.getValue()); AEqualsBinaryExpIR equals = new AEqualsBinaryExpIR(); equals.setType(new ABoolBasicTypeIR()); equals.setLeft(exp); equals.setRight(lit); return equals; }
/** * Returns a deep clone of this {@link AEqualsBinaryExpIR} node. * @return a deep clone of this {@link AEqualsBinaryExpIR} node */ public AEqualsBinaryExpIR clone() { return new AEqualsBinaryExpIR( _sourceNode, _tag, _metaData, cloneNode(_type), cloneNode(_left), cloneNode(_right) ); }
perpred.setOpname(mutex.getOpnames().getFirst().toString()); AEqualsBinaryExpIR guard = new AEqualsBinaryExpIR(); zero.setValue(0L); guard.setLeft(histcount); guard.setRight(zero); zeronum.setValue(0L); AEqualsBinaryExpIR equalzero = new AEqualsBinaryExpIR(); equalzero.setLeft(addedhistcounter); equalzero.setRight(zeronum);
private AMethodDeclIR makeExecutableInit(AStateDeclIR node) { AMethodDeclIR meth = info.getDeclAssistant().funcToMethod(node.getInitDecl()); AReturnStmIR ret = new AReturnStmIR(); AEqualsBinaryExpIR initExp = (AEqualsBinaryExpIR) node.getInitExp(); ret.setExp(initExp.getRight().clone()); meth.setBody(ret); return meth; } }
public String formatEqualsBinaryExp(AEqualsBinaryExpIR node) throws AnalysisException { STypeIR leftNodeType = node.getLeft().getType(); if (leftNodeType instanceof SSeqTypeIR || leftNodeType instanceof SSetTypeIR || leftNodeType instanceof SMapTypeIR) { return handleCollectionComparison(node); } else { return handleEquals(node); } }
@Override public SExpIR caseAEqualsBinaryExp(AEqualsBinaryExp node, IRInfo question) throws AnalysisException { SExpIR eqBinExpCg = question.getExpAssistant().handleBinaryExp(node, new AEqualsBinaryExpIR(), question); // TODO: Update the type checker? // PVJ: For some reason the type checker does not decorate the SL // init expression (e.g. s = mk_StateName(1,2).) in state // definitions with a type (the type is null) // So this is really just to prevent null types // in the IR if (eqBinExpCg.getType() == null) { eqBinExpCg.setType(new ABoolBasicTypeIR()); } return eqBinExpCg; }
AEqualsBinaryExpIR firstBranch = new AEqualsBinaryExpIR(); firstBranch.setLeft(testVar); firstBranch.setRight(methNum); AEqualsBinaryExpIR Branches = new AEqualsBinaryExpIR(); Branches.setLeft(testVar); Branches.setRight(methNum);
private SExpIR getInitExp(AStateDeclIR stateDecl) { if (stateDecl.getInitExp() instanceof AEqualsBinaryExpIR) { AEqualsBinaryExpIR eqExp = (AEqualsBinaryExpIR) stateDecl.getInitExp(); return eqExp.getRight().clone(); } else { ANewExpIR defaultRecInit = new ANewExpIR(); defaultRecInit.setName(transAssistant.getTypeName(stateDecl)); defaultRecInit.setType(transAssistant.getRecType(stateDecl)); for (int i = 0; i < stateDecl.getFields().size(); i++) { defaultRecInit.getArgs().add(transAssistant.getInfo().getExpAssistant().consUndefinedExp()); } return defaultRecInit; } }
/** * Creates a deep clone of this {@link AEqualsBinaryExpIR} 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 AEqualsBinaryExpIR} node */ public AEqualsBinaryExpIR clone(Map<INode,INode> oldToNewMap) { AEqualsBinaryExpIR node = new AEqualsBinaryExpIR( _sourceNode, _tag, _metaData, cloneNode(_type, oldToNewMap), cloneNode(_left, oldToNewMap), cloneNode(_right, oldToNewMap) ); oldToNewMap.put(this, node); return node; }
@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); }
/** * Called by the {@link AEqualsBinaryExpIR} node from {@link AEqualsBinaryExpIR#apply(IIsaAnalysis)}. * @param node the calling {@link AEqualsBinaryExpIR} node */ public void caseAEqualsBinaryExpIR(AEqualsBinaryExpIR node) throws AnalysisException { _visitedNodes.add(node); inAEqualsBinaryExpIR(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this); } if(node.getLeft() != null && !_visitedNodes.contains(node.getLeft())) { node.getLeft().apply(this); } if(node.getRight() != null && !_visitedNodes.contains(node.getRight())) { node.getRight().apply(this); } outAEqualsBinaryExpIR(node); }
private ANotUnaryExpIR transNotEquals(ANotEqualsBinaryExpIR notEqual) { ANotUnaryExpIR notUnary = new ANotUnaryExpIR(); notUnary.setType(new ABoolBasicTypeIR()); AEqualsBinaryExpIR equal = new AEqualsBinaryExpIR(); equal.setType(new ABoolBasicTypeIR()); equal.setLeft(notEqual.getLeft().clone()); equal.setRight(notEqual.getRight().clone()); notUnary.setExp(equal); // Replace the "notEqual" expression with the transformed expression INode parent = notEqual.parent(); // It may be the case that the parent is null if we execute e.g. [1] <> [1] in isolation if (parent != null) { parent.replaceChild(notEqual, notUnary); notEqual.parent(null); } return notUnary; }
/** * Called by the {@link AEqualsBinaryExpIR} node from {@link AEqualsBinaryExpIR#apply(IAnalysis)}. * @param node the calling {@link AEqualsBinaryExpIR} node */ public void caseAEqualsBinaryExpIR(AEqualsBinaryExpIR node, Q question) throws AnalysisException { _visitedNodes.add(node); inAEqualsBinaryExpIR(node, question); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this, question); } if(node.getLeft() != null && !_visitedNodes.contains(node.getLeft())) { node.getLeft().apply(this, question); } if(node.getRight() != null && !_visitedNodes.contains(node.getRight())) { node.getRight().apply(this, question); } outAEqualsBinaryExpIR(node, question); }
public AEqualsBinaryExpIR consFieldComparison(ARecordDeclIR record, AFieldDeclIR field, String formalParamName) throws AnalysisException { // Example: fieldName == formalParamName.fieldName AEqualsBinaryExpIR fieldComparison = new AEqualsBinaryExpIR(); fieldComparison.setType(new ABoolBasicTypeIR()); AIdentifierVarExpIR instanceField = new AIdentifierVarExpIR(); instanceField.setType(field.getType().clone()); instanceField.setIsLocal(false); instanceField.setName(field.getName()); AFieldExpIR formalParamField = new AFieldExpIR(); formalParamField.setType(field.getType().clone()); AIdentifierVarExpIR formalParam = new AIdentifierVarExpIR(); ARecordTypeIR recordType = new ARecordTypeIR(); recordType.setName(consTypeName(record)); formalParam.setType(recordType); formalParam.setIsLocal(true); formalParam.setName(formalParamName); formalParamField.setObject(formalParam); formalParamField.setMemberName(field.getName()); fieldComparison.setLeft(instanceField); fieldComparison.setRight(formalParamField); return fieldComparison; }
/** * Called by the {@link AEqualsBinaryExpIR} node from {@link AEqualsBinaryExpIR#apply(IAnalysis)}. * @param node the calling {@link AEqualsBinaryExpIR} node */ public A caseAEqualsBinaryExpIR(AEqualsBinaryExpIR node) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node); mergeReturns(retVal,inAEqualsBinaryExpIR(node)); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { mergeReturns(retVal,node.getType().apply(this)); } if(node.getLeft() != null && !_visitedNodes.contains(node.getLeft())) { mergeReturns(retVal,node.getLeft().apply(this)); } if(node.getRight() != null && !_visitedNodes.contains(node.getRight())) { mergeReturns(retVal,node.getRight().apply(this)); } mergeReturns(retVal,outAEqualsBinaryExpIR(node)); return retVal; }
@Override public void caseAExists1QuantifierExpIR(AExists1QuantifierExpIR node) throws AnalysisException { SStmIR enclosingStm = transAssistant.getEnclosingStm(node, "exists1 expression"); SExpIR predicate = node.getPredicate(); ITempVarGen tempVarNameGen = transAssistant.getInfo().getTempVarNameGen(); String var = tempVarNameGen.nextVarName(prefixes.exists1()); Exists1QuantifierStrategy strategy = consExists1QuantifierStrategy(predicate, tempVarNameGen, var); List<SMultipleBindIR> multipleSetBinds = filterBindList(node, node.getBindList()); ABlockStmIR block = transAssistant.consComplexCompIterationBlock(multipleSetBinds, tempVarNameGen, strategy, iteVarPrefixes); if (multipleSetBinds.isEmpty()) { ABoolLiteralExpIR exists1Result = transAssistant.getInfo().getExpAssistant().consBoolLiteral(false); transAssistant.replaceNodeWith(node, exists1Result); } else { AIdentifierVarExpIR counter = new AIdentifierVarExpIR(); counter.setType(new AIntNumericBasicTypeIR()); counter.setIsLocal(true); counter.setName(var); AEqualsBinaryExpIR exists1Result = new AEqualsBinaryExpIR(); exists1Result.setType(new ABoolBasicTypeIR()); exists1Result.setLeft(counter); exists1Result.setRight(transAssistant.getInfo().getExpAssistant().consIntLiteral(1)); transform(enclosingStm, block, exists1Result, node); block.apply(this); } }
/** * Called by the {@link AEqualsBinaryExpIR} node from {@link AEqualsBinaryExpIR#apply(IAnalysis)}. * @param node the calling {@link AEqualsBinaryExpIR} node */ public A caseAEqualsBinaryExpIR(AEqualsBinaryExpIR node, Q question) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node, question); mergeReturns(retVal,inAEqualsBinaryExpIR(node, question)); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { mergeReturns(retVal,node.getType().apply(this, question)); } if(node.getLeft() != null && !_visitedNodes.contains(node.getLeft())) { mergeReturns(retVal,node.getLeft().apply(this, question)); } if(node.getRight() != null && !_visitedNodes.contains(node.getRight())) { mergeReturns(retVal,node.getRight().apply(this, question)); } mergeReturns(retVal,outAEqualsBinaryExpIR(node, question)); return retVal; }
patternData.setRootPatternVar(var); AEqualsBinaryExpIR check = new AEqualsBinaryExpIR(); check.setType(new ABoolBasicTypeIR()); check.setLeft(var); check.setRight(valueToMatch);