public boolean isRootRec(AApplyExpIR node) { return (node.getRoot() instanceof AFieldExpIR); }
@Override public SExpIR caseAApplyExpIR(AApplyExpIR node) throws AnalysisException { return node.getRoot().apply(this); }
public boolean isCharRead(AApplyExpIR applyExp) { return isStringType(applyExp.getRoot()) && applyExp.getArgs().size() == 1; }
public boolean isSeqApplication(AApplyExpIR applyExp) { return isSeqType(applyExp.getRoot()) && applyExp.getArgs().size() == 1; }
public boolean isMapApplication(AApplyExpIR applyExp) { return isMapType(applyExp.getRoot()) && applyExp.getArgs().size() == 1; }
public boolean isRoot(INode node) { if (node.parent() instanceof AApplyExpIR) { AApplyExpIR par = (AApplyExpIR) node.parent(); if (par.getRoot() == node) { return true; } } return false; } public boolean isRootRec(AApplyExpIR node)
private boolean cloneNotNeededUtilCall(INode node) { if (!(node instanceof AApplyExpIR)) { return false; } AApplyExpIR applyExp = (AApplyExpIR) node; SExpIR root = applyExp.getRoot(); if (!(root instanceof AExplicitVarExpIR)) { return false; } AExplicitVarExpIR explicitVar = (AExplicitVarExpIR) root; STypeIR classType = explicitVar.getClassType(); return classType instanceof AExternalTypeIR && ((AExternalTypeIR) classType).getName().equals(JavaFormat.UTILS_FILE); }
public SExpIR findSubject(SExpIR next) { while (next instanceof AFieldExpIR || next instanceof AMapSeqGetExpIR || next instanceof AApplyExpIR) { if (next instanceof AFieldExpIR) { next = ((AFieldExpIR) next).getObject(); } else if (next instanceof AMapSeqGetExpIR) { next = ((AMapSeqGetExpIR) next).getCol(); } else if (next instanceof AApplyExpIR) { next = ((AApplyExpIR) next).getRoot(); } } return next; }
private STypeIR getResultType(AFieldExpIR node, INode parent, STypeIR fieldObjType, TypeAssistantIR typeAssistant) { if (parent instanceof SExpIR) { if (parent instanceof AApplyExpIR && ((AApplyExpIR) parent).getRoot() == node) { return ((SExpIR) parent).getType().clone(); } } return fieldType(node, fieldObjType, typeAssistant); }
/** * 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); }
public boolean isLambda(AApplyExpIR applyExp) { SExpIR root = applyExp.getRoot(); if (root instanceof AApplyExpIR && root.getType() instanceof AMethodTypeIR) { return true; } if (!(root instanceof SVarExpIR)) { return false; } SVarExpIR varExp = (SVarExpIR) root; return varExp.getIsLambda() != null && varExp.getIsLambda(); }
/** * Called by the {@link AApplyExpIR} node from {@link AApplyExpIR#apply(IAnalysis)}. * @param node the calling {@link AApplyExpIR} node */ public void caseAApplyExpIR(AApplyExpIR node) throws AnalysisException { _visitedNodes.add(node); inAApplyExpIR(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this); } if(node.getRoot() != null && !_visitedNodes.contains(node.getRoot())) { node.getRoot().apply(this); } { List<SExpIR> copy = new ArrayList<SExpIR>(node.getArgs()); for( SExpIR e : copy) { if(!_visitedNodes.contains(e)) { e.apply(this); } } } outAApplyExpIR(node); }
/** * Called by the {@link AApplyExpIR} node from {@link AApplyExpIR#apply(IIsaAnalysis)}. * @param node the calling {@link AApplyExpIR} node */ public void caseAApplyExpIR(AApplyExpIR node) throws AnalysisException { _visitedNodes.add(node); inAApplyExpIR(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this); } if(node.getRoot() != null && !_visitedNodes.contains(node.getRoot())) { node.getRoot().apply(this); } { List<SExpIR> copy = new ArrayList<SExpIR>(node.getArgs()); for( SExpIR e : copy) { if(!_visitedNodes.contains(e)) { e.apply(this); } } } outAApplyExpIR(node); }
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; } }
/** * Called by the {@link AApplyExpIR} node from {@link AApplyExpIR#apply(IAnalysis)}. * @param node the calling {@link AApplyExpIR} node */ public A caseAApplyExpIR(AApplyExpIR node, Q question) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node, question); mergeReturns(retVal,inAApplyExpIR(node, question)); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { mergeReturns(retVal,node.getType().apply(this, question)); } if(node.getRoot() != null && !_visitedNodes.contains(node.getRoot())) { mergeReturns(retVal,node.getRoot().apply(this, question)); } { List<SExpIR> copy = new ArrayList<SExpIR>(node.getArgs()); for( SExpIR e : copy) { if(!_visitedNodes.contains(e)) { mergeReturns(retVal,e.apply(this, question)); } } } mergeReturns(retVal,outAApplyExpIR(node, question)); return retVal; }
/** * Called by the {@link AApplyExpIR} node from {@link AApplyExpIR#apply(IAnalysis)}. * @param node the calling {@link AApplyExpIR} node */ public A caseAApplyExpIR(AApplyExpIR node) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node); mergeReturns(retVal,inAApplyExpIR(node)); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { mergeReturns(retVal,node.getType().apply(this)); } if(node.getRoot() != null && !_visitedNodes.contains(node.getRoot())) { mergeReturns(retVal,node.getRoot().apply(this)); } { List<SExpIR> copy = new ArrayList<SExpIR>(node.getArgs()); for( SExpIR e : copy) { if(!_visitedNodes.contains(e)) { mergeReturns(retVal,e.apply(this)); } } } mergeReturns(retVal,outAApplyExpIR(node)); return retVal; }
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 cloneNotNeeded(INode parent) { while (parent instanceof ACastUnaryExpIR) { parent = parent.parent(); } if (parent instanceof AApplyExpIR) { // Cloning is not needed if the expression is // used to look up a value in a sequence or a map SExpIR root = ((AApplyExpIR) parent).getRoot(); if (!(root.getType() instanceof AMethodTypeIR)) { return true; } } return parent instanceof AFieldExpIR || parent instanceof AFieldNumberExpIR || parent instanceof ATupleSizeExpIR || parent instanceof ATupleCompatibilityExpIR || parent instanceof AEqualsBinaryExpIR || parent instanceof ANotEqualsBinaryExpIR || parent instanceof AAddrEqualsBinaryExpIR || parent instanceof AAddrNotEqualsBinaryExpIR || parent instanceof AForAllStmIR || parent instanceof AIsOfClassExpIR || parent instanceof SIsExpIR || cloneNotNeededCollectionOperator(parent) || cloneNotNeededUtilCall(parent); }
SExpIR root = node.getRoot(); root.apply(this);
&& ((AApplyExpIR) parent).getRoot() == node)