/** * Called by the {@link AReturnStmIR} node from {@link AReturnStmIR#apply(IIsaAnalysis)}. * @param node the calling {@link AReturnStmIR} node */ public void caseAReturnStmIR(AReturnStmIR node) throws AnalysisException { _visitedNodes.add(node); inAReturnStmIR(node); if(node.getExp() != null && !_visitedNodes.contains(node.getExp())) { node.getExp().apply(this); } outAReturnStmIR(node); }
/** * Called by the {@link AReturnStmIR} node from {@link AReturnStmIR#apply(IAnalysis)}. * @param node the calling {@link AReturnStmIR} node */ public void caseAReturnStmIR(AReturnStmIR node) throws AnalysisException { _visitedNodes.add(node); inAReturnStmIR(node); if(node.getExp() != null && !_visitedNodes.contains(node.getExp())) { node.getExp().apply(this); } outAReturnStmIR(node); }
/** * Called by the {@link AReturnStmIR} node from {@link AReturnStmIR#apply(IAnalysis)}. * @param node the calling {@link AReturnStmIR} node */ public void caseAReturnStmIR(AReturnStmIR node, Q question) throws AnalysisException { _visitedNodes.add(node); inAReturnStmIR(node, question); if(node.getExp() != null && !_visitedNodes.contains(node.getExp())) { node.getExp().apply(this, question); } outAReturnStmIR(node, question); }
@Override public void caseAReturnStmIR(AReturnStmIR node) throws AnalysisException { if (node.getExp() == null) { return; // When the return type of the method is 'void' } if (node.getExp() instanceof ANullExpIR) { return; } node.getExp().apply(this); AMethodDeclIR methodDecl = node.getAncestor(AMethodDeclIR.class); STypeIR expectedType = methodDecl.getMethodType().getResult(); if (expectedType instanceof AUnknownTypeIR) { return; } if (!(expectedType instanceof AUnionTypeIR)) { correctTypes(node.getExp(), expectedType); } }
/** * Called by the {@link AReturnStmIR} node from {@link AReturnStmIR#apply(IAnalysis)}. * @param node the calling {@link AReturnStmIR} node */ public A caseAReturnStmIR(AReturnStmIR node) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node); mergeReturns(retVal,inAReturnStmIR(node)); if(node.getExp() != null && !_visitedNodes.contains(node.getExp())) { mergeReturns(retVal,node.getExp().apply(this)); } mergeReturns(retVal,outAReturnStmIR(node)); return retVal; }
/** * Called by the {@link AReturnStmIR} node from {@link AReturnStmIR#apply(IAnalysis)}. * @param node the calling {@link AReturnStmIR} node */ public A caseAReturnStmIR(AReturnStmIR node, Q question) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node, question); mergeReturns(retVal,inAReturnStmIR(node, question)); if(node.getExp() != null && !_visitedNodes.contains(node.getExp())) { mergeReturns(retVal,node.getExp().apply(this, question)); } mergeReturns(retVal,outAReturnStmIR(node, question)); return retVal; }
@Override public void caseAReturnStmIR(AReturnStmIR node) throws AnalysisException SExpIR result = node.getExp(); AVarDeclIR resultDecl = transAssistant.consDecl(funcResultVarName, method.getMethodType().getResult().clone(), node.getExp().clone()); AIdentifierVarExpIR resultVar = transAssistant.getInfo().getExpAssistant().consIdVar(funcResultVarName, resultDecl.getType().clone()); replacementBlock.getLocalDefs().add(resultDecl); transAssistant.replaceNodeWith(node.getExp(), postCheckCall); transAssistant.replaceNodeWith(node, replacementBlock);
@Override public void inAReturnStmIR(AReturnStmIR node) throws AnalysisException { SExpIR exp = node.getExp(); if (exp != null) { exp.apply(this); } else { return; } AMethodDeclIR method = node.getAncestor(AMethodDeclIR.class); AMethodTypeIR methodType = method.getMethodType(); if (methodType.getResult() instanceof AStringTypeIR) { if (!(exp.getType() instanceof SSeqTypeIR)) { return; } correctExpToString(exp); ; } else if (methodType.getResult() instanceof SSeqTypeIR) { if (!(exp.getType() instanceof AStringTypeIR)) { return; } correctExpToSeq(exp, exp.getType()); } }
public void handleReturn(AReturnStmIR node) throws AnalysisException { /** * The idea is to extract the return value to variable and return that variable. Then it becomes the * responsibility of the variable declaration case to assert if the named invariant type is violated. */ SExpIR exp = node.getExp(); AMethodDeclIR encMethod = decorator.getJmlGen().getUtil().getEnclosingMethod(node); if (encMethod == null) { return; } STypeIR returnType = encMethod.getMethodType().getResult(); AbstractTypeInfo typeInfo = util.findTypeInfo(returnType); if (!proceed(typeInfo)) { return; } String name = getInfo().getTempVarNameGen().nextVarName(RET_VAR_NAME_PREFIX); AIdentifierPatternIR id = getInfo().getPatternAssistant().consIdPattern(name); AIdentifierVarExpIR varExp = getInfo().getExpAssistant().consIdVar(name, returnType.clone()); getTransAssist().replaceNodeWith(exp, varExp); AVarDeclIR varDecl = getInfo().getDeclAssistant().consLocalVarDecl(returnType.clone(), id, exp.clone()); ABlockStmIR replBlock = new ABlockStmIR(); replBlock.getLocalDefs().add(varDecl); getTransAssist().replaceNodeWith(node, replBlock); replBlock.getStatements().add(node); varDecl.apply(decorator); }