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; }
@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); } } } }
@Override public void caseAClassTypeIR(AClassTypeIR node) throws AnalysisException { String name = node.getName(); if(mustRename(name)) { node.setName(consNewName(name)); } }
@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); }
@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); } } }
@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 ANewExpIR consDefaultConsCall(AClassTypeIR classType) { ANewExpIR initAltNode = new ANewExpIR(); initAltNode.setType(classType.clone()); initAltNode.setName(consTypeNameForClass(classType.getName())); return initAltNode; }
@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); } } }
@Override public void caseAFieldExpIR(AFieldExpIR node) throws AnalysisException { // Examples new IO().ferror() or myIoObj.ferror() STypeIR objType = node.getObject().getType(); if(objType instanceof AClassTypeIR) { AClassTypeIR classType = (AClassTypeIR) objType; String className = classType.getName(); String member = node.getMemberName(); if(isUnsupportedIO(className, member) || isUnsupportedVDMUtil(className, member)){ warn(node); } } }
private boolean memberExists(String memberName, INode parent, TypeAssistantIR typeAssistant, SExpIR fieldExp, STypeIR currentType) throws AnalysisException { if (fieldExp instanceof AFieldExpIR) { if (currentType instanceof AClassTypeIR) { String className = ((AClassTypeIR) currentType).getName(); return memberExists(parent, typeAssistant, className, memberName); } else if (currentType instanceof ARecordTypeIR) { ARecordTypeIR recordType = (ARecordTypeIR) currentType; return transAssistant.getInfo().getDeclAssistant().getFieldDecl(transAssistant.getInfo().getClasses(), recordType, memberName) != null; } } else if (fieldExp instanceof AFieldNumberExpIR && currentType instanceof ATupleTypeIR) { return true; // Could possibly be strengthened // AFieldNumberExpIR fieldNumberExp = (AFieldNumberExpIR) fieldExp; // return fieldNumberExp.getField() <= ((ATupleTypeIR) currentType).getTypes().size(); } return false; }
fieldType = typeAssistant.getFieldType(transAssistant.getInfo().getClasses(), classType.getName(), memberName); } else if (currentType instanceof ARecordTypeIR)
prefix = ((AClassTypeIR) type).getName() + "`";
if(assist.getInfo().getDeclAssistant().isLibraryName(((AClassTypeIR) classType).getName()))
? ((AClassTypeIR) classType).getName() : traceEnclosingClass; field.setType(getInfo().getTypeAssistant().getMethodType(getInfo(), fieldModule, name, args));
AMethodTypeIR methodType = typeAssistant.getMethodType(transAssistant.getInfo(), currentType.getName(), fieldName, args);