inAFuncDeclIR(node, question); if(node.getPreCond() != null && !_visitedNodes.contains(node.getPreCond())) node.getPreCond().apply(this, question); if(node.getPostCond() != null && !_visitedNodes.contains(node.getPostCond())) node.getPostCond().apply(this, question); if(node.getMethodType() != null && !_visitedNodes.contains(node.getMethodType())) node.getMethodType().apply(this, question); List<AFormalParamLocalParamIR> copy = new ArrayList<AFormalParamLocalParamIR>(node.getFormalParams()); for( AFormalParamLocalParamIR e : copy) List<ATemplateTypeIR> copy = new ArrayList<ATemplateTypeIR>(node.getTemplateTypes()); for( ATemplateTypeIR e : copy) List<STypeIR> copy = new ArrayList<STypeIR>(node.getRaises()); for( STypeIR e : copy) if(node.getBody() != null && !_visitedNodes.contains(node.getBody())) node.getBody().apply(this, question);
/** * Called by the {@link AMrFuncGroupDeclIR} node from {@link AMrFuncGroupDeclIR#apply(IIsaAnalysis)}. * @param node the calling {@link AMrFuncGroupDeclIR} node */ public void caseAMrFuncGroupDeclIR(AMrFuncGroupDeclIR node) throws AnalysisException { _visitedNodes.add(node); inAMrFuncGroupDeclIR(node); { List<AFuncDeclIR> copy = new ArrayList<AFuncDeclIR>(node.getFuncs()); for( AFuncDeclIR e : copy) { if(!_visitedNodes.contains(e)) { e.apply(this); } } } outAMrFuncGroupDeclIR(node); }
public AMethodDeclIR funcToMethod(AFuncDeclIR node) SDeclIR preCond = node.getPreCond(); SDeclIR postCond = node.getPostCond(); String access = node.getAccess(); Boolean isAbstract = node.getAbstract(); LinkedList<ATemplateTypeIR> templateTypes = node.getTemplateTypes(); AMethodTypeIR methodType = node.getMethodType(); LinkedList<AFormalParamLocalParamIR> formalParams = node.getFormalParams(); String name = node.getName(); SExpIR body = node.getBody(); SourceNode sourceNode = node.getSourceNode(); method.setStatic(true); method.setIsConstructor(false); method.setImplicit(node.getImplicit());
@Override public void caseAFuncDeclIR(AFuncDeclIR node) throws AnalysisException { handleMethodOrFunc(node.getBody(), node.getPreCond(), node.getPostCond()); }
public String hackInv(ARecordDeclIR type) { if (type.getInvariant() != null) { AFuncDeclIR invFunc = (AFuncDeclIR) type.getInvariant(); StringBuilder sb = new StringBuilder(); sb.append("inv "); sb.append(invFunc.getFormalParams().get(0).getPattern().toString()); sb.append(" == "); sb.append(invFunc.getName()); sb.append("("); sb.append("&"); sb.append(invFunc.getFormalParams().get(0).getPattern().toString()); sb.append(")"); return sb.toString(); } return ""; }
AFuncDeclIR method = new AFuncDeclIR(); method.setAccess(accessCg); method.setMethodType(methodTypeCg); method.setName(funcNameCg); LinkedList<AFormalParamLocalParamIR> formalParameters = method.getFormalParams(); method.setBody(new ANotImplementedExpIR()); } else if (node.getIsCurried()) method.setBody(topLambda); } else method.setBody(bodyCg); boolean isAbstract = method.getBody() == null; method.setAbstract(isAbstract); ATemplateTypeIR templateType = new ATemplateTypeIR(); templateType.setName(typeParam.getName()); method.getTemplateTypes().add(templateType); SDeclIR preCondCg = preCond != null ? preCond.apply(question.getDeclVisitor(), question) : null; method.setPreCond(preCondCg); method.setPostCond(postCondCg);
AFuncDeclIR func = new AFuncDeclIR(); AExplicitFunctionDefinition preCond = node.getPredef(); SDeclIR preCondCg = preCond != null ? preCond.apply(question.getDeclVisitor(), question) : null; func.setPreCond(preCondCg); func.setPostCond(postCondCg); ATemplateTypeIR templateType = new ATemplateTypeIR(); templateType.setName(typeParam.getName()); func.getTemplateTypes().add(templateType); func.setAbstract(false); func.setAccess(accessCg); func.setImplicit(true); func.setBody(new ANotImplementedExpIR()); func.setBody(node.getBody().apply(question.getExpVisitor(), question)); func.setFormalParams(question.getDeclAssistant().consFormalParams(node.getParamPatterns(), question)); func.setMethodType((AMethodTypeIR) typeCg); func.setName(funcNameCg);
@Override public void caseAFuncDeclIR(AFuncDeclIR node) throws AnalysisException { super.caseAFuncDeclIR(node); if (!node.getTemplateTypes().isEmpty()) { for(ATemplateTypeIR t : node.getTemplateTypes()) { AFormalParamLocalParamIR param = new AFormalParamLocalParamIR(); param.setType(new AUnknownTypeIR()); param.setPattern(assist.getInfo().getPatternAssistant().consIdPattern(toTypeArgName(t))); node.getFormalParams().add(param); } } }
if (d instanceof AFuncDeclIR) n = ((AFuncDeclIR) d).getName();
public String hackResultName(AFuncDeclIR func) throws AnalysisException { SourceNode x = func.getSourceNode(); if (x.getVdmNode() instanceof AImplicitFunctionDefinition) { AImplicitFunctionDefinition iFunc = (AImplicitFunctionDefinition) x.getVdmNode(); return iFunc.getResult().getPattern().toString(); } throw new AnalysisException("Expected AFuncDeclIR in implicit function source. Got: " + x.getVdmNode().getClass().toString()); }
public String hackInv(ANamedTypeDeclIR type) { ATypeDeclIR tDecl = (ATypeDeclIR) type.parent(); if (tDecl.getInv() != null) { AFuncDeclIR invFunc = (AFuncDeclIR) tDecl.getInv(); StringBuilder sb = new StringBuilder(); sb.append("inv "); sb.append(invFunc.getFormalParams().get(0).getPattern().toString()); sb.append(" == "); sb.append(invFunc.getName()); sb.append("("); sb.append("&"); sb.append(invFunc.getFormalParams().get(0).getPattern().toString()); sb.append(")"); return sb.toString(); } return ""; }
inAFuncDeclIR(node); if(node.getPreCond() != null && !_visitedNodes.contains(node.getPreCond())) node.getPreCond().apply(this); if(node.getPostCond() != null && !_visitedNodes.contains(node.getPostCond())) node.getPostCond().apply(this); if(node.getMethodType() != null && !_visitedNodes.contains(node.getMethodType())) node.getMethodType().apply(this); List<AFormalParamLocalParamIR> copy = new ArrayList<AFormalParamLocalParamIR>(node.getFormalParams()); for( AFormalParamLocalParamIR e : copy) List<ATemplateTypeIR> copy = new ArrayList<ATemplateTypeIR>(node.getTemplateTypes()); for( ATemplateTypeIR e : copy) List<STypeIR> copy = new ArrayList<STypeIR>(node.getRaises()); for( STypeIR e : copy) if(node.getBody() != null && !_visitedNodes.contains(node.getBody())) node.getBody().apply(this);
e.apply(this);
inAFuncDeclIR(node); if(node.getPreCond() != null && !_visitedNodes.contains(node.getPreCond())) node.getPreCond().apply(this); if(node.getPostCond() != null && !_visitedNodes.contains(node.getPostCond())) node.getPostCond().apply(this); if(node.getMethodType() != null && !_visitedNodes.contains(node.getMethodType())) node.getMethodType().apply(this); List<AFormalParamLocalParamIR> copy = new ArrayList<AFormalParamLocalParamIR>(node.getFormalParams()); for( AFormalParamLocalParamIR e : copy) List<ATemplateTypeIR> copy = new ArrayList<ATemplateTypeIR>(node.getTemplateTypes()); for( ATemplateTypeIR e : copy) List<STypeIR> copy = new ArrayList<STypeIR>(node.getRaises()); for( STypeIR e : copy) if(node.getBody() != null && !_visitedNodes.contains(node.getBody())) node.getBody().apply(this);
e.apply(this);
mergeReturns(retVal,inAFuncDeclIR(node, question)); if(node.getPreCond() != null && !_visitedNodes.contains(node.getPreCond())) mergeReturns(retVal,node.getPreCond().apply(this, question)); if(node.getPostCond() != null && !_visitedNodes.contains(node.getPostCond())) mergeReturns(retVal,node.getPostCond().apply(this, question)); if(node.getMethodType() != null && !_visitedNodes.contains(node.getMethodType())) mergeReturns(retVal,node.getMethodType().apply(this, question)); List<AFormalParamLocalParamIR> copy = new ArrayList<AFormalParamLocalParamIR>(node.getFormalParams()); for( AFormalParamLocalParamIR e : copy) List<ATemplateTypeIR> copy = new ArrayList<ATemplateTypeIR>(node.getTemplateTypes()); for( ATemplateTypeIR e : copy) List<STypeIR> copy = new ArrayList<STypeIR>(node.getRaises()); for( STypeIR e : copy) if(node.getBody() != null && !_visitedNodes.contains(node.getBody())) mergeReturns(retVal,node.getBody().apply(this, question));
e.apply(this);
mergeReturns(retVal,inAFuncDeclIR(node)); if(node.getPreCond() != null && !_visitedNodes.contains(node.getPreCond())) mergeReturns(retVal,node.getPreCond().apply(this)); if(node.getPostCond() != null && !_visitedNodes.contains(node.getPostCond())) mergeReturns(retVal,node.getPostCond().apply(this)); if(node.getMethodType() != null && !_visitedNodes.contains(node.getMethodType())) mergeReturns(retVal,node.getMethodType().apply(this)); List<AFormalParamLocalParamIR> copy = new ArrayList<AFormalParamLocalParamIR>(node.getFormalParams()); for( AFormalParamLocalParamIR e : copy) List<ATemplateTypeIR> copy = new ArrayList<ATemplateTypeIR>(node.getTemplateTypes()); for( ATemplateTypeIR e : copy) List<STypeIR> copy = new ArrayList<STypeIR>(node.getRaises()); for( STypeIR e : copy) if(node.getBody() != null && !_visitedNodes.contains(node.getBody())) mergeReturns(retVal,node.getBody().apply(this));
e.apply(this, question);
e.apply(this);