public IRSettings getSettings() { return generator.getIRInfo().getSettings(); }
public boolean importTraceSupport(SClassDeclIR node) { return info.getSettings().generateTraces() && !node.getTraces().isEmpty(); } }
public boolean genClassInvariant(SClassDeclIR clazz) { if (!info.getSettings().generateInvariants()) { return false; } return clazz.getInvariant() != null; }
protected boolean canBeGenerated() { // This only works for VDM-SL return Settings.dialect == Dialect.VDM_SL && getInfo().getSettings().generatePreConds(); }
private String formatInterfaceNames(List<String> interfaceNames, String keyword) { String implementsClause = keyword; String sep = " "; if (interfaceNames.isEmpty()) { // All classes must be declared Serializable when traces are being generated. if (info.getSettings().generateTraces() || getJavaSettings().makeClassesSerializable()) { return implementsClause + sep + java.io.Serializable.class.getName(); } else { return ""; } } for (int i = 0; i < interfaceNames.size(); i++) { implementsClause += sep + interfaceNames.get(i); sep = ", "; } if (info.getSettings().generateTraces() || getJavaSettings().makeClassesSerializable()) { implementsClause += sep + java.io.Serializable.class.getName(); } return implementsClause; }
public boolean genTypeDecl(ATypeDeclIR node) { if (node.getDecl() instanceof ARecordDeclIR) { return getJavaSettings().genRecsAsInnerClasses(); } else { return info.getSettings().generateInvariants(); } }
@Override public void caseAMethodDeclIR(AMethodDeclIR node) throws AnalysisException if (!transAssistant.getInfo().getSettings().generatePostCondChecks())
if(info.getSettings().generatePreConds()) { SDeclIR preCond = node.getPreCond(); if (preCond instanceof AMethodDeclIR) { AMethodDeclIR preCondMethod = (AMethodDeclIR) preCond; if (info.getSettings().makePreCondsPublic()) { preCondMethod.setAccess(IRConstants.PUBLIC); if(info.getSettings().generatePostConds()) { SDeclIR postCond = node.getPostCond(); if (postCond instanceof AMethodDeclIR) { AMethodDeclIR postCondMethod = (AMethodDeclIR) postCond; if (info.getSettings().makePostCondsPublic()) { postCondMethod.setAccess(IRConstants.PUBLIC);
IRInfo question) throws AnalysisException if (!question.getSettings().generateTraces())
@Override public void caseANamedTraceDeclIR(ANamedTraceDeclIR node) throws AnalysisException { if (!transAssistant.getInfo().getSettings().generateTraces()) { return; } TraceSupportedAnalysis supportedAnalysis = new TraceSupportedAnalysis(node); if (!traceIsSupported(supportedAnalysis)) { transAssistant.getInfo().addTransformationWarning(node, supportedAnalysis.getReason()); return; } ADefaultClassDeclIR enclosingClass = node.getAncestor(ADefaultClassDeclIR.class); if (enclosingClass != null) { enclosingClass.getMethods().add(consTraceMethod(node)); } else { log.error("Class enclosing trace could not be found so the generated trace could not be added as a method to the corresponding class"); } }
@Override public SDeclIR caseARecordInvariantType(ARecordInvariantType node, IRInfo question) throws AnalysisException { ILexNameToken name = node.getName(); LinkedList<AFieldField> fields = node.getFields(); ARecordDeclIR record = new ARecordDeclIR(); record.setName(name.getName()); if (node.getInvDef() != null && question.getSettings().generateInvariants()) { SDeclIR invCg = node.getInvDef().apply(question.getDeclVisitor(), question); record.setInvariant(invCg); } LinkedList<AFieldDeclIR> recordFields = record.getFields(); for (AFieldField aFieldField : fields) { SDeclIR res = aFieldField.apply(question.getDeclVisitor(), question); if (res instanceof AFieldDeclIR) { AFieldDeclIR fieldDecl = (AFieldDeclIR) res; recordFields.add(fieldDecl); } else { return null; } } return record; }
if (!transAssistant.getInfo().getSettings().generatePreCondChecks())
public STypeIR constructSeqType(SSeqTypeBase node, IRInfo question) throws AnalysisException { STypeIR seqOfCg = node.getSeqof().apply(question.getTypeVisitor(), question); boolean emptyCg = node.getEmpty(); boolean isSeq1 = node instanceof ASeq1SeqType; // This is a special case since sequence of characters are strings if (seqOfCg instanceof ACharBasicTypeIR && question.getSettings().getCharSeqAsString()) { AStringTypeIR stringTypeCg = new AStringTypeIR(); stringTypeCg.setSourceNode(new SourceNode(node)); return stringTypeCg; } ASeqSeqTypeIR seqType = new ASeqSeqTypeIR(); seqType.setSeqOf(seqOfCg); seqType.setEmpty(emptyCg); seqType.setSeq1(isSeq1); return seqType; }
@Override public SDeclIR caseATypeDefinition(ATypeDefinition node, IRInfo question) throws AnalysisException { String access = node.getAccess().getAccess().toString(); PType type = node.getType(); SDeclIR declCg = type.apply(question.getDeclVisitor(), question); SDeclIR invCg = question.getSettings().generateInvariants() && node.getInvdef() != null ? node.getInvdef().apply(question.getDeclVisitor(), question) : null; ATypeDeclIR typeDecl = new ATypeDeclIR(); typeDecl.setAccess(access); typeDecl.setDecl(declCg); typeDecl.setInv(invCg); return typeDecl; }
if(info.getSettings().addStateInvToModule()) { clazz.getFunctions().add(stateDecl.getInvDecl().clone());
private void handleStateUpdate(SStmIR node) if (!transAssistant.getInfo().getSettings().generateConc())
if (transAssistant.getInfo().getSettings().getCharSeqAsString())
if (question.getSettings().getCharSeqAsString())
? initPattern.apply(question.getPatternVisitor(), question) : null; SDeclIR invDeclCg = question.getSettings().generateInvariants() && invdef != null ? invdef.apply(question.getDeclVisitor(), question) : null; SExpIR invExpCg = invExp != null
if (transAssistant.getInfo().getSettings().getCharSeqAsString())