/** * 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_); }
/** * 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_); }
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; } }
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; } }
@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 SExpIR consInstanceCall(STypeIR instanceType, String instanceName, STypeIR returnType, String memberName, SExpIR... args) { AIdentifierVarExpIR instance = new AIdentifierVarExpIR(); instance.setType(instanceType.clone()); instance.setName(instanceName); instance.setIsLocal(true); AFieldExpIR fieldExp = new AFieldExpIR(); fieldExp.setMemberName(memberName); fieldExp.setObject(instance); AMethodTypeIR methodType = new AMethodTypeIR(); methodType.setResult(returnType.clone()); AApplyExpIR instanceCall = new AApplyExpIR(); instanceCall.setType(returnType.clone()); if (args != null) { for (SExpIR arg : args) { methodType.getParams().add(arg.getType().clone()); instanceCall.getArgs().add(arg); } } fieldExp.setType(methodType.clone()); instanceCall.setRoot(fieldExp); return instanceCall; }
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; }
condCall.setRoot(condVar);
@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; }
readStateCall.setRoot(readStateMethod); readStateCall.setType(f.getType().clone());
setConstructor.setRoot(setConstructorMember);
@Override public void caseAFieldExpIR(AFieldExpIR node) throws AnalysisException { node.getObject().apply(this); if (node.getObject().getType() instanceof ARecordTypeIR && !(node.parent() instanceof AApplyExpIR)) { AMethodTypeIR getterType = new AMethodTypeIR(); getterType.setResult(node.getType().clone()); AFieldExpIR getterField = node.clone(); getterField.setType(getterType); AApplyExpIR getCall = new AApplyExpIR(); getCall.setRoot(getterField); getCall.setType(node.getType().clone()); getCall.setSourceNode(node.getSourceNode()); getterField.setMemberName(consGetCallName(node.getMemberName())); /** * The getters added to the record classes do not copy object references representing values. Therefore we * need to take it into account when we do the field read call */ if (cloneFieldRead(node)) { getCall = makeCopy(getCall); } jmlGen.getJavaGen().getTransAssistant().replaceNodeWith(node, getCall); } }
apply.setRoot(field); apply.setSourceNode(callStmIR.getSourceNode());
superCall.setRoot(superVar);