/** * Called by the {@link AExplicitVarExpIR} node from {@link AExplicitVarExpIR#apply(IAnalysis)}. * @param node the calling {@link AExplicitVarExpIR} node */ public void caseAExplicitVarExpIR(AExplicitVarExpIR node) throws AnalysisException { _visitedNodes.add(node); inAExplicitVarExpIR(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this); } if(node.getClassType() != null && !_visitedNodes.contains(node.getClassType())) { node.getClassType().apply(this); } outAExplicitVarExpIR(node); }
private SVarExpIR consExplicitVar(String className, String name, boolean isLambda, STypeIR typeCg, boolean isLocalDef) { AExplicitVarExpIR varExp = new AExplicitVarExpIR(); AClassTypeIR classType = new AClassTypeIR(); classType.setName(className); varExp.setType(typeCg); varExp.setIsLocal(isLocalDef); varExp.setClassType(classType); varExp.setName(name); varExp.setIsLambda(isLambda); return varExp; }
/** * Returns a deep clone of this {@link AExplicitVarExpIR} node. * @return a deep clone of this {@link AExplicitVarExpIR} node */ public AExplicitVarExpIR clone() { return new AExplicitVarExpIR( _sourceNode, _tag, _metaData, cloneNode(_type), _isLambda, _isLocal, _name, cloneNode(_classType) ); }
@Override public void caseAIdentifierVarExpIR(AIdentifierVarExpIR node) throws AnalysisException { INode var = AssistantBase.getVdmNode(node); if(var instanceof AVariableExp) { PDefinition def = ((AVariableExp) var).getVardef(); if(def instanceof ARenamedDefinition) { ARenamedDefinition renamedDef = (ARenamedDefinition) def; AClassTypeIR definingClass = new AClassTypeIR(); definingClass.setName(renamedDef.getDef().getName().getModule()); definingClass.setSourceNode(node.getSourceNode()); AExplicitVarExpIR expVar = new AExplicitVarExpIR(); expVar.setName(renamedDef.getDef().getName().getName()); expVar.setType(node.getType().clone()); expVar.setIsLambda(node.getIsLambda()); expVar.setIsLocal(node.getIsLocal()); expVar.setMetaData(node.getMetaData()); expVar.setTag(node.getTag()); expVar.setSourceNode(node.getSourceNode()); expVar.setClassType(definingClass); assist.replaceNodeWith(node, expVar); } } }
AExplicitVarExpIR func = new AExplicitVarExpIR(); func.setClassType(classType); func.setIsLambda(false); func.setIsLocal(false); func.setSourceNode(sourceNode); func.setName(node.getName());
@Override public void caseAExplicitVarExpIR(AExplicitVarExpIR node) throws AnalysisException { // Examples: VDMUtil`seq_of_char2val[N] or IO`printf STypeIR classType = node.getClassType(); if(classType instanceof AClassTypeIR) { String className = ((AClassTypeIR) classType).getName(); String fieldName = node.getName(); if(isUnsupportedIO(className, fieldName) || isUnsupportedVDMUtil(className, fieldName)) { warn(node); } } }
STypeIR classType = ev.getClassType(); setConstructorMember.setName(getSetMethodName()); AExplicitVarExpIR typeArg = consTypeArg(getUtilClass()); String name = getUnsupportedTypeFieldName(); typeArg.setName(name); node.getArgs().add(typeArg); name = getUnsupportedTypeFieldName(); typeArg.setName(name);
@Override public void caseAExplicitVarExpIR(AExplicitVarExpIR node) throws AnalysisException { STypeIR classType = node.getClassType(); if(classType instanceof AClassTypeIR) { String fieldClassName = ((AClassTypeIR) classType).getName(); if(className.equals(fieldClassName)) { vars.add(node); } } } }
/** * Creates a new tree field only constructor {@code AExplicitVarExpIR TAG=explicit} 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 AExplicitVarExpIR} node */ public AExplicitVarExpIR(STypeIR type_, Boolean isLambda_, Boolean isLocal_, String name_, STypeIR classType_) { super(null,null,null,type_,isLambda_,isLocal_,name_); this.setClassType(classType_); }
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; }
public SVarExpIR idStateDesignatorToExp(AIdentifierStateDesignatorIR node) { if (node.getExplicit()) { AClassTypeIR classType = new AClassTypeIR(); classType.setName(node.getClassName()); AExplicitVarExpIR explicitVar = new AExplicitVarExpIR(); explicitVar.setClassType(classType); explicitVar.setIsLambda(false); explicitVar.setIsLocal(node.getIsLocal()); explicitVar.setName(node.getName()); explicitVar.setSourceNode(node.getSourceNode()); explicitVar.setTag(node.getTag()); explicitVar.setType(node.getType().clone()); return explicitVar; } else { AIdentifierVarExpIR idVar = consIdVar(node.getName(), node.getType().clone()); idVar.setTag(node.getTag()); idVar.setSourceNode(node.getSourceNode()); idVar.setIsLocal(node.getIsLocal()); return idVar; } }
STypeIR classType = expVar.getClassType(); fieldName = expVar.getName();
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); }
/** * Creates a deep clone of this {@link AExplicitVarExpIR} 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 AExplicitVarExpIR} node */ public AExplicitVarExpIR clone(Map<INode,INode> oldToNewMap) { AExplicitVarExpIR node = new AExplicitVarExpIR( _sourceNode, _tag, _metaData, cloneNode(_type, oldToNewMap), _isLambda, _isLocal, _name, cloneNode(_classType, oldToNewMap) ); oldToNewMap.put(this, node); return node; }
/** * Creates a new complete constructor {@code AExplicitVarExpIR} 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 AExplicitVarExpIR} node */ public AExplicitVarExpIR(SourceNode sourceNode_, Object tag_, List<? extends ClonableString> metaData_, STypeIR type_, Boolean isLambda_, Boolean isLocal_, String name_, STypeIR classType_) { super(sourceNode_,tag_,metaData_,type_,isLambda_,isLocal_,name_); this.setClassType(classType_); }
public AExplicitVarExpIR consTypeArg(String className) { AExternalTypeIR runtimeUtilClass = new AExternalTypeIR(); runtimeUtilClass.setName(className); AExternalTypeIR anyType = new AExternalTypeIR(); anyType.setName(getTypeArgumentFieldName()); AExplicitVarExpIR typeArg = new AExplicitVarExpIR(); typeArg.setClassType(runtimeUtilClass); typeArg.setIsLocal(false); typeArg.setIsLambda(false); typeArg.setType(anyType); return typeArg; }
/** * Called by the {@link AExplicitVarExpIR} node from {@link AExplicitVarExpIR#apply(IAnalysis)}. * @param node the calling {@link AExplicitVarExpIR} node */ public void caseAExplicitVarExpIR(AExplicitVarExpIR node, Q question) throws AnalysisException { _visitedNodes.add(node); inAExplicitVarExpIR(node, question); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this, question); } if(node.getClassType() != null && !_visitedNodes.contains(node.getClassType())) { node.getClassType().apply(this, question); } outAExplicitVarExpIR(node, question); }
@Override public void caseAExplicitVarExpIR(AExplicitVarExpIR node) throws AnalysisException { String pack = javaGen.getJavaSettings().getJavaRootPackage(); if (JavaCodeGenUtil.isValidJavaPackage(pack)) { STypeIR type = node.getClassType(); if (type instanceof AClassTypeIR) { AClassTypeIR classType = (AClassTypeIR) type; classType.setName(pack + "." + classType.getName()); } else { log.error("Expected type of explicit variable to be a class type at this point. Got: " + type); } } }
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; }
/** * Called by the {@link AExplicitVarExpIR} node from {@link AExplicitVarExpIR#apply(IIsaAnalysis)}. * @param node the calling {@link AExplicitVarExpIR} node */ public void caseAExplicitVarExpIR(AExplicitVarExpIR node) throws AnalysisException { _visitedNodes.add(node); inAExplicitVarExpIR(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this); } if(node.getClassType() != null && !_visitedNodes.contains(node.getClassType())) { node.getClassType().apply(this); } outAExplicitVarExpIR(node); }