/** * Called by the {@link AApplyExpIR} node from {@link AApplyExpIR#apply(IAnalysis)}. * @param node the calling {@link AApplyExpIR} node */ public void caseAApplyExpIR(AApplyExpIR node, Q question) throws AnalysisException { _visitedNodes.add(node); inAApplyExpIR(node, question); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this, question); } if(node.getRoot() != null && !_visitedNodes.contains(node.getRoot())) { node.getRoot().apply(this, question); } { List<SExpIR> copy = new ArrayList<SExpIR>(node.getArgs()); for( SExpIR e : copy) { if(!_visitedNodes.contains(e)) { e.apply(this, question); } } } outAApplyExpIR(node, question); }
/** * Returns a deep clone of this {@link AApplyExpIR} node. * @return a deep clone of this {@link AApplyExpIR} node */ public AApplyExpIR clone() { return new AApplyExpIR( _sourceNode, _tag, _metaData, cloneNode(_type), cloneNode(_root), cloneList(_args) ); }
private SExpIR getAssignmentExp(INode node, SExpIR fieldExp) { INode parent = node.parent(); if (parent instanceof AApplyExpIR && ((AApplyExpIR) parent).getRoot() == node) { AApplyExpIR applyExp = (AApplyExpIR) parent.clone(); applyExp.setRoot(fieldExp); return applyExp; } else { return fieldExp; } }
/** * Creates a new complete constructor {@code AApplyExpIR} node with the given nodes as children. * @deprecated This method should not be used, use AstFactory instead. * The basic child nodes are removed from their previous parents. * @param root_ the {@link SExpIR} node for the {@code root} child of this {@link AApplyExpIR} node * @param args_ the {@link NodeList} node for the {@code args} child of this {@link AApplyExpIR} node */ public AApplyExpIR(SourceNode sourceNode_, Object tag_, List<? extends ClonableString> metaData_, STypeIR type_, SExpIR root_, List<? extends SExpIR> args_) { super(sourceNode_,tag_,metaData_,type_); this.setRoot(root_); this.setArgs(args_); }
@Override public SExpIR caseAApplyExp(AApplyExp node, IRInfo question) throws AnalysisException { PType type = node.getType(); PExp root = node.getRoot(); STypeIR typeCg = type.apply(question.getTypeVisitor(), question); SExpIR rootCg = root.apply(question.getExpVisitor(), question); AApplyExpIR applyExp = new AApplyExpIR(); applyExp.setType(typeCg); applyExp.setRoot(rootCg); for (PExp arg : node.getArgs()) { SExpIR argCg = arg.apply(question.getExpVisitor(), question); if (argCg != null) { applyExp.getArgs().add(argCg); } else { return null; } } return applyExp; }
public AApplyExpIR consUtilCall(STypeIR returnType, String memberName) { AExplicitVarExpIR member = new AExplicitVarExpIR(); AMethodTypeIR methodType = new AMethodTypeIR(); methodType.setResult(returnType.clone()); member.setType(methodType); member.setIsLambda(false); member.setIsLocal(false); AExternalTypeIR classType = new AExternalTypeIR(); classType.setName(JavaFormat.UTILS_FILE); member.setClassType(classType); member.setName(memberName); AApplyExpIR call = new AApplyExpIR(); call.setType(returnType.clone()); call.setRoot(member); return call; }
@Override public AApplyExpIR toStringOf(SExpIR exp) { AApplyExpIR utilsToStrCall = consUtilsToStringCall(); utilsToStrCall.getArgs().add(exp); return utilsToStrCall; } }
public boolean isRootRec(AApplyExpIR node) { return (node.getRoot() instanceof AFieldExpIR); }
public AMethodTypeIR getMethodType(AApplyExpIR node, List<SExpIR> args) throws AnalysisException { SExpIR root = node.getRoot(); STypeIR type = root.getType(); SClassDeclIR encClass = node.getAncestor(SClassDeclIR.class); if(encClass != null) SClassDeclIR encClass = node.getAncestor(SClassDeclIR.class); if(encClass != null) args.add(node.getArgs().get(i));
public AApplyExpIR consUtilCopyCall() { ATemplateTypeIR copyType = new ATemplateTypeIR(); copyType.setName("T"); AApplyExpIR copyCall = consUtilCall(copyType, COPY); SExpIR member = copyCall.getRoot(); if (member instanceof AExplicitVarExpIR && ((AExplicitVarExpIR) member).getType() instanceof AMethodTypeIR) { AMethodTypeIR methodType = (AMethodTypeIR) member.getType(); methodType.getParams().add(member.getType().clone()); } else { log.error("Expected type of call expression to be a method type at this point. Got: " + copyCall.getType()); } return copyCall; }
private boolean isPrePostArgument(SExpIR exp) { INode parent = exp.parent(); if (!(parent instanceof AApplyExpIR)) { return false; } AApplyExpIR applyExp = (AApplyExpIR) parent; Object tag = applyExp.getTag(); if (!(tag instanceof JavaValueSemanticsTag)) { return false; } JavaValueSemanticsTag javaTag = (JavaValueSemanticsTag) tag; if (javaTag.mustClone()) { return false; } return applyExp.getArgs().contains(exp); }
postCondCall.setTag(conditionalCallTag); AIdentifierVarExpIR resultVar = transAssistant.getInfo().getExpAssistant().consIdVar(funcResultVarName, resultDecl.getType().clone()); postCondCall.getArgs().add(resultVar.clone()); AStringLiteralExpIR methodName = transAssistant.getInfo().getExpAssistant().consStringLiteral(method.getName(), false); AApplyExpIR postCheckCall = postCheckCreator.consPostCheckCall(method, postCondCall, resultVar, methodName);
@SuppressWarnings("unchecked") @Override public SExpIR caseAApplyObjectDesignatorIR(AApplyObjectDesignatorIR node) throws AnalysisException { SObjectDesignatorIR object = node.getObject(); SourceNode sourceNode = node.getSourceNode(); LinkedList<SExpIR> args = node.getArgs(); SExpIR root = object.apply(this); STypeIR rootType = root.getType(); STypeIR applyType = null; if (rootType instanceof SSeqTypeIR) { applyType = ((SSeqTypeIR) rootType).getSeqOf(); } else if (rootType instanceof SMapTypeIR) { applyType = ((SMapTypeIR) rootType).getTo(); } else if (rootType instanceof AMethodTypeIR) { applyType = ((AMethodTypeIR) rootType).getResult(); } applyType = applyType.clone(); AApplyExpIR applyExp = new AApplyExpIR(); applyExp.setArgs((List<? extends SExpIR>) args.clone()); applyExp.setRoot(root); applyExp.setType(applyType); applyExp.setSourceNode(sourceNode); return applyExp; }
superVar.setIsLocal(false); AApplyExpIR superCall = new AApplyExpIR(); superCall.setType(consFieldType()); superCall.setRoot(superVar);
private AApplyExpIR makeCopy(AApplyExpIR getCall) { AApplyExpIR copyCall = jmlGen.getJavaGen().getJavaFormat().getJavaFormatAssistant().consUtilCopyCall(); copyCall.getArgs().add(getCall); return copyCall; }
@Override public SExpIR caseAApplyExpIR(AApplyExpIR node) throws AnalysisException { return node.getRoot().apply(this); }
/** * Creates a new tree field only constructor {@code AApplyExpIR TAG=apply} node with the given nodes as children. * @deprecated This method should not be used, use AstFactory instead. * The basic child nodes are removed from their previous parents. * @param root_ the {@link SExpIR} node for the {@code root} child of this {@link AApplyExpIR} node * @param args_ the {@link NodeList} node for the {@code args} child of this {@link AApplyExpIR} node */ public AApplyExpIR(STypeIR type_, SExpIR root_, List<? extends SExpIR> args_) { super(null,null,null,type_); this.setRoot(root_); this.setArgs(args_); }
public AApplyExpIR consPostCheckCall(AMethodDeclIR method, AApplyExpIR postCondCall, AIdentifierVarExpIR resultVar, AStringLiteralExpIR methodName) { AExternalTypeIR externalType = new AExternalTypeIR(); externalType.setName(JavaFormat.UTILS_FILE); AMethodTypeIR methodType = new AMethodTypeIR(); methodType.setResult(new ABoolBasicTypeIR()); methodType.getParams().add(method.getMethodType().getResult().clone()); methodType.getParams().add(new ABoolBasicTypeIR()); methodType.getParams().add(new AStringTypeIR()); AExplicitVarExpIR explicitVar = new AExplicitVarExpIR(); explicitVar.setType(methodType); explicitVar.setIsLambda(false); explicitVar.setIsLocal(false); explicitVar.setName(postCheckMethodName); explicitVar.setClassType(externalType); AApplyExpIR utilsCall = new AApplyExpIR(); utilsCall.setRoot(explicitVar); utilsCall.setType(methodType.getResult().clone()); utilsCall.getArgs().add(resultVar); utilsCall.getArgs().add(postCondCall); utilsCall.getArgs().add(methodName); return utilsCall; } }