@Override public void caseAPlainCallStmIR(APlainCallStmIR node) throws AnalysisException { String initName = getInitName(node); if (initName == null) { // No 'initName' exists for non-constructor calls return; } APlainCallStmIR callStm = new APlainCallStmIR(); callStm.setType(new AVoidTypeIR()); callStm.setClassType(null); callStm.setName(initName); for (SExpIR a : node.getArgs()) { callStm.getArgs().add(a.clone()); } assist.replaceNodeWith(node, callStm); }
/** * Called by the {@link APlainCallStmIR} node from {@link APlainCallStmIR#apply(IAnalysis)}. * @param node the calling {@link APlainCallStmIR} node */ public void caseAPlainCallStmIR(APlainCallStmIR node, Q question) throws AnalysisException { _visitedNodes.add(node); inAPlainCallStmIR(node, question); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this, question); } { List<SExpIR> copy = new ArrayList<SExpIR>(node.getArgs()); for( SExpIR e : copy) { if(!_visitedNodes.contains(e)) { e.apply(this, question); } } } if(node.getClassType() != null && !_visitedNodes.contains(node.getClassType())) { node.getClassType().apply(this, question); } outAPlainCallStmIR(node, question); }
@Override public void caseAPlainCallStmIR(APlainCallStmIR node) throws AnalysisException { // Example: IO`println(...) STypeIR classType = node.getClassType(); if(classType instanceof AClassTypeIR) { String className = ((AClassTypeIR) classType).getName(); String methodName = node.getName(); // VDMUtil does not contain operations if(isUnsupportedIO(className, methodName)){ warn(node); } } }
/** * Returns a deep clone of this {@link APlainCallStmIR} node. * @return a deep clone of this {@link APlainCallStmIR} node */ public APlainCallStmIR clone() { return new APlainCallStmIR( _sourceNode, _tag, _metaData, cloneNode(_type), _isStatic, _name, cloneList(_args), cloneNode(_classType) ); }
definingClass.setSourceNode(node.getSourceNode()); APlainCallStmIR call = new APlainCallStmIR(); call.setClassType(definingClass); call.setName(opName); call.setIsStatic(false); call.setMetaData(node.getMetaData()); call.setSourceNode(node.getSourceNode()); call.setTag(node.getTag()); call.setType(node.getType().clone()); for(SExpIR a : node.getArgs()) call.getArgs().add(a.clone());
delegateType.setName(delegateMap.get(className)); APlainCallStmIR call = new APlainCallStmIR(); call.setClassType(delegateType); call.setIsStatic(m.getStatic()); call.setName(m.getName()); call.setSourceNode(m.getBody().getSourceNode()); call.setTag(m.getBody().getTag()); call.setType(m.getMethodType().getResult().clone()); call.getArgs().add(assist.getInfo().getExpAssistant().consIdVar(argName, param.getType().clone()));
protected SStmIR handlePlainCallStm(APlainCallStmIR callStmIR) throws AnalysisException STypeIR type = callStmIR.getType(); if (callStmIR.getIsStatic()) List<SExpIR> args = callStmIR.getArgs(); STypeIR classType = callStmIR.getClassType(); String name = callStmIR.getName(); SourceNode sourceNode = callStmIR.getSourceNode(); apply.setType(type.clone()); apply.setRoot(field); apply.setSourceNode(callStmIR.getSourceNode());
APlainCallStmIR callStm = new APlainCallStmIR(); callStm.setType(typeCg); callStm.setIsStatic(isStaticOrSl); callStm.setName(name); callStm.setClassType(classType); callStm.setArgs(argsCg);
args = plainCall.getArgs(); SourceNode source = plainCall.getSourceNode(); if (source != null) plainCall.setName(pre + plainCall.getName()); plainCall.setType(new ABoolBasicTypeIR());
STypeIR type = plainCall.getClassType(); String name = plainCall.getName(); LinkedList<SExpIR> args = plainCall.getArgs();
if (call.getArgs().isEmpty()) SourceNode source = call.getSourceNode(); if (source != null) if (argTypes.size() != call.getArgs().size()) for (int i = 0; i < call.getArgs().size(); i++) SExpIR a = call.getArgs().get(i);
@Override public void caseAPlainCallStmIR(APlainCallStmIR node) throws AnalysisException { STypeIR classType = node.getClassType(); String className = classType instanceof AClassTypeIR ? ((AClassTypeIR) classType).getName() : node.getAncestor(ADefaultClassDeclIR.class).getName(); handleCallStm(node, className); }
/** * Creates a new tree field only constructor {@code APlainCallStmIR TAG=plain} 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 classType_ the {@link STypeIR} node for the {@code classType} child of this {@link APlainCallStmIR} node */ public APlainCallStmIR(STypeIR type_, Boolean isStatic_, String name_, List<? extends SExpIR> args_, STypeIR classType_) { super(null,null,null,type_,isStatic_,name_,args_); this.setClassType(classType_); }
protected String getInvokedModule(SStmIR stm) { if (stm instanceof APlainCallStmIR) { APlainCallStmIR call = (APlainCallStmIR) stm; STypeIR type = call.getClassType(); if (type instanceof AClassTypeIR) { return ((AClassTypeIR) type).getName(); } } return traceEnclosingClass; }
private String getInitName(APlainCallStmIR node) { if (node.getSourceNode() != null && node.getSourceNode().getVdmNode() != null) { INode vdmNode = node.getSourceNode().getVdmNode(); if (vdmNode instanceof ACallStm) { ACallStm c = (ACallStm) vdmNode; PDefinition rootDef = c.getRootdef(); while (rootDef instanceof AInheritedDefinition) { rootDef = ((AInheritedDefinition) rootDef).getSuperdef(); } if (rootDef instanceof AExplicitOperationDefinition) { AExplicitOperationDefinition op = (AExplicitOperationDefinition) rootDef; if (op.getIsConstructor()) { return getObjectInitializerCall(op); } } } } return null; }
/** * Creates a deep clone of this {@link APlainCallStmIR} node while putting all * old node-new node relations in the map {@code oldToNewMap}. * @param oldToNewMap the map filled with the old node-new node relation * @return a deep clone of this {@link APlainCallStmIR} node */ public APlainCallStmIR clone(Map<INode,INode> oldToNewMap) { APlainCallStmIR node = new APlainCallStmIR( _sourceNode, _tag, _metaData, cloneNode(_type, oldToNewMap), _isStatic, _name, cloneList(_args, oldToNewMap), cloneNode(_classType, oldToNewMap) ); oldToNewMap.put(this, node); return node; }
/** * Creates a new complete constructor {@code APlainCallStmIR} 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 classType_ the {@link STypeIR} node for the {@code classType} child of this {@link APlainCallStmIR} node */ public APlainCallStmIR(SourceNode sourceNode_, Object tag_, List<? extends ClonableString> metaData_, STypeIR type_, Boolean isStatic_, String name_, List<? extends SExpIR> args_, STypeIR classType_) { super(sourceNode_,tag_,metaData_,type_,isStatic_,name_,args_); this.setClassType(classType_); }
public APlainCallStmIR consCallStm(AFieldDeclIR field) { APlainCallStmIR call = new APlainCallStmIR(); AExternalTypeIR classType = new AExternalTypeIR(); classType.setName(JavaFormat.UTILS_FILE); AIdentifierVarExpIR argument = new AIdentifierVarExpIR(); argument.setType(field.getType().clone()); argument.setIsLocal(false); argument.setName(field.getName()); call.setType(classType.clone()); call.setName("hashcode"); call.setClassType(classType.clone()); call.getArgs().add(argument); return call; }
/** * Called by the {@link APlainCallStmIR} node from {@link APlainCallStmIR#apply(IAnalysis)}. * @param node the calling {@link APlainCallStmIR} node */ public void caseAPlainCallStmIR(APlainCallStmIR node) throws AnalysisException { _visitedNodes.add(node); inAPlainCallStmIR(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this); } { List<SExpIR> copy = new ArrayList<SExpIR>(node.getArgs()); for( SExpIR e : copy) { if(!_visitedNodes.contains(e)) { e.apply(this); } } } if(node.getClassType() != null && !_visitedNodes.contains(node.getClassType())) { node.getClassType().apply(this); } outAPlainCallStmIR(node); }
private SStmIR buildTestExecutionStms(AIdentifierVarExpIR nodeVar, String traceEnclosingClassName) { AExternalTypeIR utilsType = new AExternalTypeIR(); utilsType.setName(tracePrefixes.traceNodeNodeClassName()); APlainCallStmIR executeTestsCall = new APlainCallStmIR(); executeTestsCall.setClassType(utilsType); executeTestsCall.setName(tracePrefixes.executeTestsMethodName()); executeTestsCall.setType(new AVoidTypeIR()); ATypeArgExpIR typeArg = new ATypeArgExpIR(); typeArg.setType(transAssistant.consClassType(traceEnclosingClassName)); executeTestsCall.getArgs().add(nodeVar.clone()); if (Settings.dialect != Dialect.VDM_SL) { executeTestsCall.getArgs().add(typeArg); } executeTestsCall.getArgs().add(transAssistant.getInfo().getExpAssistant().consIdVar(tracePrefixes.traceMethodParamName(), transAssistant.consClassType(tracePrefixes.testAccumulatorClassName()))); executeTestsCall.getArgs().add(transAssistant.getInfo().getExpAssistant().consIdVar(tracePrefixes.storeVarName(), transAssistant.consClassType(tracePrefixes.storeClassName()))); return executeTestsCall; }