diff --git a/core/ast/pom.xml b/core/ast/pom.xml index 9f4410c94c..b7eb5cf946 100644 --- a/core/ast/pom.xml +++ b/core/ast/pom.xml @@ -4,7 +4,7 @@ org.overturetool core - 2.2.0 + 2.2.2 ../pom.xml diff --git a/core/ast/src/main/java/org/overture/ast/factory/AstFactory.java b/core/ast/src/main/java/org/overture/ast/factory/AstFactory.java index aaae1f9e39..102b8fb7d1 100644 --- a/core/ast/src/main/java/org/overture/ast/factory/AstFactory.java +++ b/core/ast/src/main/java/org/overture/ast/factory/AstFactory.java @@ -989,6 +989,11 @@ public static APerSyncDefinition newAPerSyncDefinition( result.setOpname(opname); result.setGuard(guard); + + if(guard != null) + { + guard.parent(result); + } return result; } diff --git a/core/ast/src/main/resources/overtureII.astv2.tostring b/core/ast/src/main/resources/overtureII.astv2.tostring index 99c9f46841..d4c5aa44e2 100644 --- a/core/ast/src/main/resources/overtureII.astv2.tostring +++ b/core/ast/src/main/resources/overtureII.astv2.tostring @@ -186,6 +186,9 @@ import org.overture.ast.util.ToStringUtil; %definition->value = [pattern] +$($[type]$ == null ? "" : ":" + $[type]$) + " = " +$ [expression] +%modules->module= "module " [name]$.getName()+ "\n definitions\n" + ToStringUtil.getDefinitionListString($[defs]$)$ + + "end " [name]$.getName()$ + "\n" +//return (_name!=null?_name.toString():this.getClass().getSimpleName())+ (_imports!=null?_imports.toString():this.getClass().getSimpleName())+ (_exports!=null?_exports.toString():this.getClass().getSimpleName())+ (_defs!=null?_defs.toString():this.getClass().getSimpleName())+ (_files!=null?_files.toString():this.getClass().getSimpleName())+ (_importdefs!=null?_importdefs.toString():this.getClass().getSimpleName())+ (_exportdefs!=null?_exportdefs.toString():this.getClass().getSimpleName())+ (_isFlat!=null?_isFlat.toString():this.getClass().getSimpleName())+ (_typeChecked!=null?_typeChecked.toString():this.getClass().getSimpleName())+ (_isDLModule!=null?_isDLModule.toString():this.getClass().getSimpleName()); //%definition->value = [pattern] " : " [expType] " = " [expression] diff --git a/core/codegen-runtime/pom.xml b/core/codegen-runtime/pom.xml index ab2724d134..a7385e8cf2 100644 --- a/core/codegen-runtime/pom.xml +++ b/core/codegen-runtime/pom.xml @@ -1,15 +1,31 @@ - 4.0.0 + 4.0.0 - - org.overturetool - core - 2.2.0 - ../pom.xml - + + org.overturetool + core + 2.2.2 + ../pom.xml + - org.overturetool.core - codegen-runtime - VDM Code Generator Runtime + org.overturetool.core + codegen-runtime + VDM Code Generator Runtime + + + + maven-source-plugin + + + attach-sources + + jar-no-fork + + + + + + + diff --git a/core/codegen/pom.xml b/core/codegen/pom.xml index 3cdfd28194..7eef63c03a 100644 --- a/core/codegen/pom.xml +++ b/core/codegen/pom.xml @@ -4,7 +4,7 @@ org.overturetool core - 2.2.0 + 2.2.2 ../pom.xml diff --git a/core/codegen/src/main/java/org/overture/codegen/assistant/DeclAssistantCG.java b/core/codegen/src/main/java/org/overture/codegen/assistant/DeclAssistantCG.java index 9fe5603eea..92d1cd7420 100644 --- a/core/codegen/src/main/java/org/overture/codegen/assistant/DeclAssistantCG.java +++ b/core/codegen/src/main/java/org/overture/codegen/assistant/DeclAssistantCG.java @@ -29,6 +29,7 @@ import org.overture.ast.analysis.AnalysisException; import org.overture.ast.definitions.AClassClassDefinition; import org.overture.ast.definitions.AEqualsDefinition; +import org.overture.ast.definitions.AExplicitFunctionDefinition; import org.overture.ast.definitions.AValueDefinition; import org.overture.ast.definitions.PDefinition; import org.overture.ast.definitions.SClassDefinition; @@ -36,12 +37,17 @@ import org.overture.ast.definitions.SOperationDefinition; import org.overture.ast.intf.lex.ILexNameToken; import org.overture.ast.node.INode; +import org.overture.ast.patterns.APatternListTypePair; +import org.overture.ast.patterns.PPattern; +import org.overture.ast.statements.ASubclassResponsibilityStm; import org.overture.codegen.cgast.SDeclCG; import org.overture.codegen.cgast.SExpCG; import org.overture.codegen.cgast.SPatternCG; +import org.overture.codegen.cgast.SStmCG; import org.overture.codegen.cgast.STypeCG; import org.overture.codegen.cgast.declarations.AClassDeclCG; import org.overture.codegen.cgast.declarations.AFieldDeclCG; +import org.overture.codegen.cgast.declarations.AFormalParamLocalParamCG; import org.overture.codegen.cgast.declarations.AMethodDeclCG; import org.overture.codegen.cgast.declarations.ARecordDeclCG; import org.overture.codegen.cgast.declarations.ATypeDeclCG; @@ -51,6 +57,7 @@ import org.overture.codegen.cgast.types.ABoolBasicTypeCG; import org.overture.codegen.cgast.types.ACharBasicTypeCG; import org.overture.codegen.cgast.types.AIntNumericBasicTypeCG; +import org.overture.codegen.cgast.types.AMethodTypeCG; import org.overture.codegen.cgast.types.ANat1NumericBasicTypeCG; import org.overture.codegen.cgast.types.ANatNumericBasicTypeCG; import org.overture.codegen.cgast.types.ARealNumericBasicTypeCG; @@ -411,6 +418,19 @@ public AFieldDeclCG getFieldDecl(List classes, return record.getFields().get(number); } + + public AFieldDeclCG getFieldDecl(AClassDeclCG clazz, String fieldName) + { + for(AFieldDeclCG field : clazz.getFields()) + { + if(field.getName().equals(fieldName)) + { + return field; + } + } + + return null; + } public AFieldDeclCG getFieldDecl(List classes, ARecordTypeCG recordType, String memberName) @@ -486,4 +506,74 @@ public AFieldDeclCG getFieldDecl(List classes, return field; } + + public AMethodDeclCG initMethod(SOperationDefinition node, IRInfo question) throws AnalysisException + { + String access = node.getAccess().getAccess().toString(); + boolean isStatic = question.getTcFactory().createPDefinitionAssistant().isStatic(node); + boolean isAsync = question.getTcFactory().createPAccessSpecifierAssistant().isAsync(node.getAccess()); + String operationName = node.getName().getName(); + STypeCG type = node.getType().apply(question.getTypeVisitor(), question); + + if (!(type instanceof AMethodTypeCG)) + { + return null; + } + + AMethodTypeCG methodType = (AMethodTypeCG) type; + + SStmCG bodyCg = null; + if (node.getBody() != null) + { + bodyCg = node.getBody().apply(question.getStmVisitor(), question); + } + + boolean isConstructor = node.getIsConstructor(); + boolean isAbstract = node.getBody() instanceof ASubclassResponsibilityStm; + + AMethodDeclCG method = new AMethodDeclCG(); + + method.setAccess(access); + method.setStatic(isStatic); + method.setAsync(isAsync); + method.setMethodType(methodType); + method.setName(operationName); + method.setBody(bodyCg); + method.setIsConstructor(isConstructor); + method.setAbstract(isAbstract); + + AExplicitFunctionDefinition preCond = node.getPredef(); + SDeclCG preCondCg = preCond != null ? preCond.apply(question.getDeclVisitor(), question) : null; + method.setPreCond(preCondCg); + + AExplicitFunctionDefinition postCond = node.getPostdef(); + SDeclCG postCondCg = postCond != null ? postCond.apply(question.getDeclVisitor(), question) : null; + method.setPostCond(postCondCg); + + return method; + } + + + public List consFormalParams( + List params, IRInfo question) + throws AnalysisException + { + List paramsCg = new LinkedList<>(); + for(APatternListTypePair patternListPair : params) + { + STypeCG pairTypeCg = patternListPair.getType().apply(question.getTypeVisitor(), question); + + for(PPattern p : patternListPair.getPatterns()) + { + SPatternCG patternCg = p.apply(question.getPatternVisitor(), question); + + AFormalParamLocalParamCG paramCg = new AFormalParamLocalParamCG(); + paramCg.setPattern(patternCg); + paramCg.setType(pairTypeCg.clone()); + + paramsCg.add(paramCg); + } + } + return paramsCg; + } } diff --git a/core/codegen/src/main/java/org/overture/codegen/assistant/ExpAssistantCG.java b/core/codegen/src/main/java/org/overture/codegen/assistant/ExpAssistantCG.java index 00e07e57f7..3bd50e81dd 100644 --- a/core/codegen/src/main/java/org/overture/codegen/assistant/ExpAssistantCG.java +++ b/core/codegen/src/main/java/org/overture/codegen/assistant/ExpAssistantCG.java @@ -21,18 +21,20 @@ */ package org.overture.codegen.assistant; +import java.util.HashSet; import java.util.LinkedList; import java.util.List; +import java.util.Set; import org.overture.ast.analysis.AnalysisException; import org.overture.ast.definitions.AAssignmentDefinition; import org.overture.ast.definitions.AInstanceVariableDefinition; import org.overture.ast.definitions.AValueDefinition; import org.overture.ast.definitions.PDefinition; -import org.overture.ast.definitions.SClassDefinition; import org.overture.ast.definitions.SFunctionDefinition; import org.overture.ast.definitions.SOperationDefinition; import org.overture.ast.expressions.ACaseAlternative; +import org.overture.ast.expressions.ALambdaExp; import org.overture.ast.expressions.ARealLiteralExp; import org.overture.ast.expressions.PExp; import org.overture.ast.expressions.SBinaryExp; @@ -299,17 +301,41 @@ public AStringLiteralExpCG getDefaultStringlValue() public boolean isAssigned(PExp exp) { - SClassDefinition classDef = exp.getAncestor(SClassDefinition.class); + org.overture.ast.node.INode parent = exp.parent(); - if (classDef == null) + if (parent == null) { return false; } - return exp.getAncestor(AInstanceVariableDefinition.class) != null - || exp.getAncestor(AValueDefinition.class) != null - || exp.getAncestor(AAssignmentDefinition.class) != null - || exp.getAncestor(AAssignmentStm.class) != null; + Set visitedNodes = new HashSet<>(); + visitedNodes.add(parent); + + do + { + if (parent instanceof AInstanceVariableDefinition + | parent instanceof AValueDefinition + | parent instanceof AAssignmentDefinition + | parent instanceof AAssignmentStm) + { + return true; + } + + if (parent instanceof ALambdaExp) + { + return false; + } + + parent = parent.parent(); + + if (parent != null) + { + visitedNodes.add(parent); + } + + } while (parent != null && !visitedNodes.contains(parent)); + + return false; } public AHeaderLetBeStCG consHeader(ASetMultipleBindCG binding, diff --git a/core/codegen/src/main/java/org/overture/codegen/assistant/TypeAssistantCG.java b/core/codegen/src/main/java/org/overture/codegen/assistant/TypeAssistantCG.java index b763efc23f..9586cdf6da 100644 --- a/core/codegen/src/main/java/org/overture/codegen/assistant/TypeAssistantCG.java +++ b/core/codegen/src/main/java/org/overture/codegen/assistant/TypeAssistantCG.java @@ -39,6 +39,7 @@ import org.overture.ast.types.PType; import org.overture.ast.types.SSeqTypeBase; import org.overture.ast.util.PTypeSet; +import org.overture.codegen.cgast.INode; import org.overture.codegen.cgast.SExpCG; import org.overture.codegen.cgast.SObjectDesignatorCG; import org.overture.codegen.cgast.STypeCG; @@ -49,8 +50,6 @@ import org.overture.codegen.cgast.expressions.AApplyExpCG; import org.overture.codegen.cgast.expressions.SBinaryExpCG; import org.overture.codegen.cgast.statements.AApplyObjectDesignatorCG; -import org.overture.codegen.cgast.statements.AFieldObjectDesignatorCG; -import org.overture.codegen.cgast.statements.AIdentifierObjectDesignatorCG; import org.overture.codegen.cgast.types.ABoolBasicTypeCG; import org.overture.codegen.cgast.types.ABoolBasicTypeWrappersTypeCG; import org.overture.codegen.cgast.types.ACharBasicTypeCG; @@ -75,6 +74,7 @@ import org.overture.codegen.cgast.types.ATokenBasicTypeCG; import org.overture.codegen.cgast.types.ATupleTypeCG; import org.overture.codegen.cgast.types.AUnionTypeCG; +import org.overture.codegen.cgast.types.AUnknownTypeCG; import org.overture.codegen.cgast.types.SBasicTypeCG; import org.overture.codegen.cgast.types.SMapTypeCG; import org.overture.codegen.cgast.types.SSeqTypeCG; @@ -82,6 +82,7 @@ import org.overture.codegen.ir.IRInfo; import org.overture.codegen.ir.SourceNode; import org.overture.codegen.logging.Logger; +import org.overture.codegen.trans.uniontypes.ObjectDesignatorToExpCG; import org.overture.typechecker.TypeComparator; import org.overture.typechecker.assistant.definition.PDefinitionAssistantTC; import org.overture.typechecker.assistant.type.PTypeAssistantTC; @@ -93,6 +94,71 @@ public TypeAssistantCG(AssistantManager assistantManager) super(assistantManager); } + public STypeCG getFieldExpType(IRInfo info, List classes, String fieldName, String fieldModule, + SObjectDesignatorCG obj, INode parent) + throws AnalysisException, org.overture.codegen.cgast.analysis.AnalysisException + { + if (parent instanceof AApplyObjectDesignatorCG) + { + AApplyObjectDesignatorCG apply = (AApplyObjectDesignatorCG) parent; + LinkedList args = apply.getArgs(); + + if (fieldModule != null) + { + // It is a class + AClassDeclCG clazz = info.getDeclAssistant().findClass(classes, fieldModule); + AFieldDeclCG field = info.getDeclAssistant().getFieldDecl(clazz, fieldModule); + + if(field != null) + { + return field.getType().clone(); + } + else + { + // It must be a method + return info.getTypeAssistant().getMethodType(info, classes, fieldModule, fieldName, args); + } + } + } + return getFieldType(info, classes, fieldName, fieldModule, obj); + } + + private STypeCG getFieldType(IRInfo info, List classes, + String fieldName, String fieldModule, SObjectDesignatorCG obj) + { + if (fieldModule != null) + { + // It is a class + return info.getTypeAssistant().getFieldType(classes, fieldModule, fieldName); + } else + { + // It is a record + try + { + ObjectDesignatorToExpCG converter = new ObjectDesignatorToExpCG(info, classes); + SExpCG objExp = obj.apply(converter); + + if (objExp.getType() instanceof ARecordTypeCG) + { + STypeCG fieldExpType = info.getTypeAssistant().getFieldType(classes, (ARecordTypeCG) objExp.getType(), fieldName); + + if (fieldExpType == null) + { + Logger.getLog().printErrorln("Lookup of field type gave nothing in 'TypeAssistantCG'"); + } + + return fieldExpType; + } + } + catch (org.overture.codegen.cgast.analysis.AnalysisException e) + { + } + } + + Logger.getLog().printErrorln("Could not determine field type of field expression in 'TypeAssistantCG'"); + return new AUnknownTypeCG(); + } + public AMethodTypeCG getMethodType(IRInfo info, List classes, String fieldModule, String fieldName, List args) throws org.overture.codegen.cgast.analysis.AnalysisException @@ -330,100 +396,7 @@ public boolean isUnionOfType(AUnionType unionType, return true; } - - public STypeCG findElementType(AApplyObjectDesignatorCG designator, - List classes, IRInfo info) - { - int appliesCount = 0; - - AApplyObjectDesignatorCG mostRecentApply = designator; - SObjectDesignatorCG object = designator.getObject(); - - while (object != null) - { - if (object instanceof AIdentifierObjectDesignatorCG) - { - AIdentifierObjectDesignatorCG id = (AIdentifierObjectDesignatorCG) object; - - STypeCG type = id.getExp().getType(); - - return findElementType(appliesCount, type); - } else if (object instanceof AApplyObjectDesignatorCG) - { - mostRecentApply = (AApplyObjectDesignatorCG) object; - appliesCount++; - object = mostRecentApply.getObject(); - } else if (object instanceof AFieldObjectDesignatorCG) - { - AFieldObjectDesignatorCG fieldObj = (AFieldObjectDesignatorCG) object; - object = fieldObj.getObject(); - - return findElementType(classes, info, appliesCount, mostRecentApply, fieldObj); - } else - { - return null; - } - } - - return null; - } - - private STypeCG findElementType(int appliesCount, STypeCG type) - { - int methodTypesCount = 0; - - while (type instanceof AMethodTypeCG) - { - methodTypesCount++; - AMethodTypeCG methodType = (AMethodTypeCG) type; - type = methodType.getResult(); - } - - while (type instanceof SSeqTypeCG || type instanceof SMapTypeCG) - { - if (type instanceof SSeqTypeCG) - { - type = ((SSeqTypeCG) type).getSeqOf(); - } - - if (type instanceof SMapTypeCG) - { - type = ((SMapTypeCG) type).getTo(); - } - - if (appliesCount == methodTypesCount) - { - return type; - } - - methodTypesCount++; - } - - return null; - } - - private STypeCG findElementType(List classes, IRInfo info, - int appliesCount, AApplyObjectDesignatorCG mostRecentApply, - AFieldObjectDesignatorCG fieldObj) - { - try - { - STypeCG type = getFieldType(classes, fieldObj.getFieldModule(), fieldObj.getFieldName()); - - if (type == null) - { - type = getMethodType(info, classes, fieldObj.getFieldModule(), fieldObj.getFieldName(), mostRecentApply.getArgs()); - } - - return findElementType(appliesCount, type); - - } catch (org.overture.codegen.cgast.analysis.AnalysisException e) - { - e.printStackTrace(); - return null; - } - } - + public PType getType(IRInfo question, AUnionType unionType, PPattern pattern) { PTypeSet possibleTypes = new PTypeSet(question.getTcFactory()); diff --git a/core/codegen/src/main/java/org/overture/codegen/ir/CodeGenBase.java b/core/codegen/src/main/java/org/overture/codegen/ir/CodeGenBase.java index 381494420f..87f49d202b 100644 --- a/core/codegen/src/main/java/org/overture/codegen/ir/CodeGenBase.java +++ b/core/codegen/src/main/java/org/overture/codegen/ir/CodeGenBase.java @@ -15,6 +15,7 @@ public class CodeGenBase public static final String OBJ_EXP_NAME_PREFIX = "obj_"; public static final String TERNARY_IF_EXP_NAME_PREFIX = "ternaryIfExp_"; public static final String CALL_STM_OBJ_NAME_PREFIX = "callStmObj_"; + public static final String CASES_EXP_NAME_PREFIX = "casesExp_"; public static final String CASES_EXP_RESULT_NAME_PREFIX = "casesExpResult_"; public static final String AND_EXP_NAME_PREFIX = "andResult_"; public static final String OR_EXP_NAME_PREFIX = "orResult_"; diff --git a/core/codegen/src/main/java/org/overture/codegen/merging/MergeVisitor.java b/core/codegen/src/main/java/org/overture/codegen/merging/MergeVisitor.java index 1064aa837d..d822a3af30 100644 --- a/core/codegen/src/main/java/org/overture/codegen/merging/MergeVisitor.java +++ b/core/codegen/src/main/java/org/overture/codegen/merging/MergeVisitor.java @@ -49,6 +49,11 @@ public class MergeVisitor extends QuestionAdaptor private List mergeErrors; + /** + * Default constructor. NOT for use by extensions. + * @param templateStructure + * @param templateCallables + */ public MergeVisitor(TemplateStructure templateStructure, TemplateCallable[] templateCallables) { @@ -59,6 +64,19 @@ public MergeVisitor(TemplateStructure templateStructure, this.unsupportedInTargLang = new HashSet(); } + /** + * Extensible constructor. + * @param templateManager + * @param templateCallables + */ + public MergeVisitor(TemplateManager templateManager, TemplateCallable[] templateCallables){ + this.templates = templateManager; + this.nodeContexts = new Stack(); + this.templateCallables = templateCallables; + this.mergeErrors = new LinkedList(); + this.unsupportedInTargLang = new HashSet(); + } + public List getMergeErrors() { return mergeErrors; @@ -69,12 +87,6 @@ public boolean hasMergeErrors() return !mergeErrors.isEmpty(); } - public void dropMergeErrors() - { - // Don't clear it if others are using the list - mergeErrors = new LinkedList(); - } - public Set getUnsupportedInTargLang() { return unsupportedInTargLang; @@ -85,6 +97,13 @@ public boolean hasUnsupportedTargLangNodes() return unsupportedInTargLang != null && !unsupportedInTargLang.isEmpty(); } + public void init() + { + // Avoid clearing the data structures if others are using them + mergeErrors = new LinkedList(); + unsupportedInTargLang = new HashSet(); + } + private void initCodeGenContext(INode node, TemplateCallable[] templateCallables) { diff --git a/core/codegen/src/main/java/org/overture/codegen/merging/TemplateManager.java b/core/codegen/src/main/java/org/overture/codegen/merging/TemplateManager.java index f79dd1bba3..9089d67dd5 100644 --- a/core/codegen/src/main/java/org/overture/codegen/merging/TemplateManager.java +++ b/core/codegen/src/main/java/org/overture/codegen/merging/TemplateManager.java @@ -112,9 +112,13 @@ public class TemplateManager { - private HashMap, String> nodeTemplateFileNames; + /** + * Mapping IR classes and template locations. Initialize with {@link TemplateManager#initNodeTemplateFileNames()} + * and insert/update as necessary. + */ + protected HashMap, String> nodeTemplateFileNames; - private TemplateStructure templateStructure; + protected TemplateStructure templateStructure; public TemplateManager(TemplateStructure templateStructure) { @@ -122,7 +126,11 @@ public TemplateManager(TemplateStructure templateStructure) initNodeTemplateFileNames(); } - private void initNodeTemplateFileNames() + /** + * Initialize the mapping of IR nodes and templates with the most common + * nodes used. Folder structure is specified with {@link TemplateStructure} + */ + protected void initNodeTemplateFileNames() { nodeTemplateFileNames = new HashMap, String>(); diff --git a/core/codegen/src/main/java/org/overture/codegen/trans/CallObjStmTransformation.java b/core/codegen/src/main/java/org/overture/codegen/trans/CallObjStmTransformation.java new file mode 100644 index 0000000000..89c2fd428f --- /dev/null +++ b/core/codegen/src/main/java/org/overture/codegen/trans/CallObjStmTransformation.java @@ -0,0 +1,44 @@ +package org.overture.codegen.trans; + +import java.util.List; + +import org.overture.codegen.cgast.analysis.AnalysisException; +import org.overture.codegen.cgast.analysis.DepthFirstAnalysisAdaptor; +import org.overture.codegen.cgast.declarations.AClassDeclCG; +import org.overture.codegen.cgast.statements.ACallObjectExpStmCG; +import org.overture.codegen.cgast.statements.ACallObjectStmCG; +import org.overture.codegen.ir.IRInfo; +import org.overture.codegen.logging.Logger; +import org.overture.codegen.trans.uniontypes.ObjectDesignatorToExpCG; + +public class CallObjStmTransformation extends DepthFirstAnalysisAdaptor +{ + private ObjectDesignatorToExpCG converter; + + public CallObjStmTransformation(IRInfo info, List classes) + { + this.converter = new ObjectDesignatorToExpCG(info, classes); + } + + @Override + public void caseACallObjectStmCG(ACallObjectStmCG node) + throws AnalysisException + { + ACallObjectExpStmCG callObjExpStm = new ACallObjectExpStmCG(); + callObjExpStm.setArgs(node.getArgs()); + callObjExpStm.setObj(node.getDesignator().apply(converter)); + callObjExpStm.setFieldName(node.getFieldName()); + callObjExpStm.setSourceNode(node.getSourceNode()); + callObjExpStm.setTag(node.getTag()); + callObjExpStm.setType(node.getType()); + + if(node.parent() != null) + { + node.parent().replaceChild(node, callObjExpStm); + } + else + { + Logger.getLog().printErrorln("Could not find parent of " + node + " in " + "'CallObjStmTransformation'"); + } + } +} diff --git a/core/codegen/src/main/java/org/overture/codegen/trans/conc/InstanceVarPPEvalTransformation.java b/core/codegen/src/main/java/org/overture/codegen/trans/conc/InstanceVarPPEvalTransformation.java index d6daf6d9a1..f89cc1cb5a 100644 --- a/core/codegen/src/main/java/org/overture/codegen/trans/conc/InstanceVarPPEvalTransformation.java +++ b/core/codegen/src/main/java/org/overture/codegen/trans/conc/InstanceVarPPEvalTransformation.java @@ -10,8 +10,7 @@ import org.overture.codegen.cgast.expressions.AIdentifierVarExpCG; import org.overture.codegen.cgast.statements.AAssignmentStmCG; import org.overture.codegen.cgast.statements.ABlockStmCG; -import org.overture.codegen.cgast.statements.ACallObjectStmCG; -import org.overture.codegen.cgast.statements.AIdentifierObjectDesignatorCG; +import org.overture.codegen.cgast.statements.ACallObjectExpStmCG; import org.overture.codegen.cgast.types.AVoidTypeCG; import org.overture.codegen.ir.IRGeneratedTag; import org.overture.codegen.ir.IRInfo; @@ -82,11 +81,8 @@ public void caseAAssignmentStmCG(AAssignmentStmCG node) sentinelVar.setName(SENTINEL_FIELD_NAME); sentinelVar.setType(fieldType); - AIdentifierObjectDesignatorCG sentinel = new AIdentifierObjectDesignatorCG(); - sentinel.setExp(sentinelVar); - - ACallObjectStmCG callSentinel = new ACallObjectStmCG(); - callSentinel.setDesignator(sentinel); + ACallObjectExpStmCG callSentinel = new ACallObjectExpStmCG(); + callSentinel.setObj(sentinelVar); callSentinel.setFieldName("stateChanged"); callSentinel.setType(new AVoidTypeCG()); diff --git a/core/codegen/src/main/java/org/overture/codegen/trans/patterns/PatternTransformation.java b/core/codegen/src/main/java/org/overture/codegen/trans/patterns/PatternTransformation.java index 42a5dde297..89792e3ba2 100644 --- a/core/codegen/src/main/java/org/overture/codegen/trans/patterns/PatternTransformation.java +++ b/core/codegen/src/main/java/org/overture/codegen/trans/patterns/PatternTransformation.java @@ -54,6 +54,7 @@ import org.overture.codegen.cgast.expressions.ARealLiteralExpCG; import org.overture.codegen.cgast.expressions.ATupleCompatibilityExpCG; import org.overture.codegen.cgast.expressions.AUndefinedExpCG; +import org.overture.codegen.cgast.expressions.SVarExpCG; import org.overture.codegen.cgast.patterns.ABoolPatternCG; import org.overture.codegen.cgast.patterns.ACharPatternCG; import org.overture.codegen.cgast.patterns.AIdentifierPatternCG; @@ -98,10 +99,12 @@ public class PatternTransformation extends DepthFirstAnalysisAdaptor private TempVarPrefixes varPrefixes; + private String casesExpNamePrefix; + public PatternTransformation(List classes, TempVarPrefixes varPrefixes, IRInfo info, TransAssistantCG transformationAssistant, - PatternMatchConfig config) + PatternMatchConfig config, String casesExpNamePrefix) { this.classes = classes; this.info = info; @@ -109,6 +112,8 @@ public PatternTransformation(List classes, this.varPrefixes = varPrefixes; this.config = config; + + this.casesExpNamePrefix = casesExpNamePrefix; } @Override @@ -135,13 +140,25 @@ public void caseACasesStmCG(ACasesStmCG node) throws AnalysisException List nodeCases = node.getCases(); SPatternCG firstOriginal = nodeCases.get(0).getPattern().clone(); - List patternInfo = extractFromCases(nodeCases, node.getExp()); + ABlockStmCG replacementBlock = new ABlockStmCG(); + String expName = info.getTempVarNameGen().nextVarName(casesExpNamePrefix); + SExpCG exp = node.getExp(); + + if (!(node.getExp() instanceof SVarExpCG)) + { + AVarDeclCG expVarDecl = info.getDeclAssistant().consLocalVarDecl(node.getExp().getType().clone(), + transformationAssistant.consIdPattern(expName), node.getExp().clone()); + replacementBlock.getLocalDefs().add(expVarDecl); + exp = transformationAssistant.consIdentifierVar(expName, + node.getExp().getType().clone()); + } + + List patternInfo = extractFromCases(nodeCases, exp); PatternBlockData patternData = new PatternBlockData(MismatchHandling.NONE); List blocks = consPatternHandlingBlockCases(patternInfo, patternData); - ABlockStmCG replacementBlock = new ABlockStmCG(); replacementBlock.getStatements().add(blocks.get(0)); ANotUnaryExpCG notSuccess = info.getExpAssistant().negate(patternData.getSuccessVar()); @@ -665,10 +682,24 @@ else if(type instanceof AUnionTypeCG) { ARecordPatternCG recordPattern = (ARecordPatternCG) pattern; ARecordTypeCG recordType = (ARecordTypeCG) recordPattern.getType(); - boolean checkRecordPattern = checkRecordPattern(actualValue); - return consRecordPatternCheck(declarePatternVar, recordPattern, - recordType, patternData, actualValue, checkRecordPattern); + if(type instanceof ARecordTypeCG) + { + + return consRecordPatternCheck(declarePatternVar, recordPattern, + recordType, patternData, actualValue, checkRecordPattern(actualValue)); + + } + else if(type instanceof AUnionTypeCG) + { + return consRecordPatternCheck(declarePatternVar, recordPattern, + recordType, patternData, actualValue, true); + } + else + { + Logger.getLog().printErrorln("Expected record type or union type" + + "in PatternTransformation. Got: " + type); + } } return null; @@ -737,6 +768,18 @@ private ABlockStmCG consRecordPatternCheck(boolean declarePattern, { AIdentifierPatternCG idPattern = getIdPattern(config.getName(recordPattern.getClass())); + AIdentifierVarExpCG recordPatternVar = new AIdentifierVarExpCG(); + recordPatternVar.setType(recordType.clone()); + recordPatternVar.setName(idPattern.getName()); + recordPatternVar.setIsLambda(false); + recordPatternVar.setIsLocal(true); + patternData.setRootPatternVar(recordPatternVar); + + if(!declarePattern) + { + actualValue = recordPatternVar; + } + ABlockStmCG recordPatternBlock = initPattern(declarePattern, recordPattern, recordType, actualValue, idPattern); ARecordDeclCG record = info.getAssistantManager().getDeclAssistant().findRecord(classes, recordType); @@ -756,13 +799,8 @@ private ABlockStmCG consRecordPatternCheck(boolean declarePattern, types.add(currentField.getType()); } - AIdentifierVarExpCG recordPatternVar = new AIdentifierVarExpCG(); - recordPatternVar.setType(recordType.clone()); - recordPatternVar.setName(idPattern.getName()); - recordPatternVar.setIsLambda(false); - recordPatternVar.setIsLocal(true); - - ABlockStmCG fieldCheckBlock = consFieldCheckBlock(patternData, recordPatternVar, recordPattern.getPatterns(), types, false); + ABlockStmCG fieldCheckBlock = consFieldCheckBlock(patternData, recordPatternVar, + recordPattern.getPatterns(), types, checkRecordType && !declarePattern); recordPatternBlock.getStatements().add(fieldCheckBlock); @@ -1049,7 +1087,7 @@ private SExpCG consFieldValueToMatch(AIdentifierVarExpCG patternVar, return consTupleFieldExp(patternVar, fieldNumber, currentType, cast); } else if (patternVar.getType() instanceof ARecordTypeCG) { - return consRecFieldExp(patternVar, fieldNumber, currentType); + return consRecFieldExp(patternVar, fieldNumber, currentType, cast); } return null; @@ -1207,8 +1245,8 @@ private AFieldNumberExpCG consTupleFieldExp( return fieldNumberExp; } - private AFieldExpCG consRecFieldExp(AIdentifierVarExpCG patternVar, int i, - STypeCG currentType) + private SExpCG consRecFieldExp(AIdentifierVarExpCG patternVar, int i, + STypeCG currentType, boolean cast) { ARecordTypeCG recordType = (ARecordTypeCG) patternVar.getType(); @@ -1216,7 +1254,16 @@ private AFieldExpCG consRecFieldExp(AIdentifierVarExpCG patternVar, int i, String fieldName = recordField.getName(); AFieldExpCG fieldExp = consRecFieldExp(patternVar, currentType, fieldName); - + + if(cast) + { + ACastUnaryExpCG casted = new ACastUnaryExpCG(); + casted.setType(recordType.clone()); + casted.setExp(fieldExp.getObject()); + + fieldExp.setObject(casted); + } + return fieldExp; } @@ -1247,7 +1294,7 @@ private DeclarationTag fetchTag(PCG node) return null; } - + private boolean checkRecordPattern(SExpCG actualValue) { return actualValue != null && actualValue.getType() instanceof AUnionTypeCG; diff --git a/core/codegen/src/main/java/org/overture/codegen/trans/uniontypes/ObjectDesignatorToExpCG.java b/core/codegen/src/main/java/org/overture/codegen/trans/uniontypes/ObjectDesignatorToExpCG.java index ec83ec50e7..91fd5c051b 100644 --- a/core/codegen/src/main/java/org/overture/codegen/trans/uniontypes/ObjectDesignatorToExpCG.java +++ b/core/codegen/src/main/java/org/overture/codegen/trans/uniontypes/ObjectDesignatorToExpCG.java @@ -24,7 +24,6 @@ import java.util.LinkedList; import java.util.List; -import org.overture.codegen.assistant.TypeAssistantCG; import org.overture.codegen.cgast.INode; import org.overture.codegen.cgast.SExpCG; import org.overture.codegen.cgast.SObjectDesignatorCG; @@ -42,10 +41,12 @@ import org.overture.codegen.cgast.statements.ASelfObjectDesignatorCG; import org.overture.codegen.cgast.types.AClassTypeCG; import org.overture.codegen.cgast.types.AMethodTypeCG; +import org.overture.codegen.cgast.types.AUnknownTypeCG; import org.overture.codegen.cgast.types.SMapTypeCG; import org.overture.codegen.cgast.types.SSeqTypeCG; import org.overture.codegen.ir.IRInfo; import org.overture.codegen.ir.SourceNode; +import org.overture.codegen.logging.Logger; public class ObjectDesignatorToExpCG extends AnswerAdaptor { @@ -103,20 +104,16 @@ public SExpCG caseAFieldObjectDesignatorCG(AFieldObjectDesignatorCG node) SObjectDesignatorCG obj = node.getObject(); SourceNode sourceNode = node.getSourceNode(); - STypeCG fieldExpType = null; - - TypeAssistantCG typeAssistant = info.getAssistantManager().getTypeAssistant(); - INode parent = node.parent(); - if (parent instanceof AApplyObjectDesignatorCG) + STypeCG fieldExpType = null; + try { - AApplyObjectDesignatorCG apply = (AApplyObjectDesignatorCG) parent; - LinkedList args = apply.getArgs(); - fieldExpType = typeAssistant.getMethodType(info, classes, fieldModule, fieldName, args); - } else + fieldExpType = info.getTypeAssistant().getFieldExpType(info, classes, fieldName, fieldModule, obj, parent); + } catch (org.overture.ast.analysis.AnalysisException e) { - fieldExpType = typeAssistant.getFieldType(classes, fieldModule, fieldName); + Logger.getLog().printErrorln("Could not find field expression type of " + node + " in 'ObjectDesignatorToExpCG'"); + fieldExpType = new AUnknownTypeCG(); } SExpCG objExp = obj.apply(this); diff --git a/core/codegen/src/main/java/org/overture/codegen/trans/uniontypes/UnionTypeTransformation.java b/core/codegen/src/main/java/org/overture/codegen/trans/uniontypes/UnionTypeTransformation.java index 9c3e81c34e..b1f7725705 100644 --- a/core/codegen/src/main/java/org/overture/codegen/trans/uniontypes/UnionTypeTransformation.java +++ b/core/codegen/src/main/java/org/overture/codegen/trans/uniontypes/UnionTypeTransformation.java @@ -30,7 +30,6 @@ import org.overture.codegen.assistant.TypeAssistantCG; import org.overture.codegen.cgast.INode; import org.overture.codegen.cgast.SExpCG; -import org.overture.codegen.cgast.SObjectDesignatorCG; import org.overture.codegen.cgast.SStmCG; import org.overture.codegen.cgast.STypeCG; import org.overture.codegen.cgast.analysis.AnalysisException; @@ -57,12 +56,11 @@ import org.overture.codegen.cgast.expressions.SNumericBinaryExpCG; import org.overture.codegen.cgast.expressions.SUnaryExpCG; import org.overture.codegen.cgast.expressions.SVarExpBase; +import org.overture.codegen.cgast.expressions.SVarExpCG; import org.overture.codegen.cgast.patterns.AIdentifierPatternCG; import org.overture.codegen.cgast.statements.ABlockStmCG; import org.overture.codegen.cgast.statements.ACallObjectExpStmCG; -import org.overture.codegen.cgast.statements.ACallObjectStmCG; import org.overture.codegen.cgast.statements.AElseIfStmCG; -import org.overture.codegen.cgast.statements.AIdentifierObjectDesignatorCG; import org.overture.codegen.cgast.statements.AIfStmCG; import org.overture.codegen.cgast.statements.ALocalAssignmentStmCG; import org.overture.codegen.cgast.statements.APlainCallStmCG; @@ -686,7 +684,7 @@ private void handleCallStm(SCallStmCG node, String className) throws AnalysisExc @SuppressWarnings("unchecked") @Override - public void inACallObjectStmCG(ACallObjectStmCG node) + public void inACallObjectExpStmCG(ACallObjectExpStmCG node) throws AnalysisException { for (SExpCG arg : node.getArgs()) @@ -694,11 +692,7 @@ public void inACallObjectStmCG(ACallObjectStmCG node) arg.apply(this); } - SObjectDesignatorCG designator = node.getDesignator(); - - ObjectDesignatorToExpCG converter = new ObjectDesignatorToExpCG(info, classes); - - SExpCG objExp = designator.apply(converter); + SExpCG objExp = node.getObj(); STypeCG objType = objExp.getType(); if (!(objType instanceof AUnionTypeCG)) @@ -722,11 +716,10 @@ public void inACallObjectStmCG(ACallObjectStmCG node) ABlockStmCG replacementBlock = new ABlockStmCG(); - if (!(designator instanceof AIdentifierObjectDesignatorCG)) + if (!(objExp instanceof SVarExpCG)) { String callStmObjName = info.getTempVarNameGen().nextVarName(callStmObjPrefix); - AIdentifierPatternCG id = new AIdentifierPatternCG(); id.setName(callStmObjName); AVarDeclCG objDecl = info.getDeclAssistant(). diff --git a/core/codegen/src/main/java/org/overture/codegen/utils/GeneralCodeGenUtils.java b/core/codegen/src/main/java/org/overture/codegen/utils/GeneralCodeGenUtils.java index ed877edbba..ca131b3ea5 100644 --- a/core/codegen/src/main/java/org/overture/codegen/utils/GeneralCodeGenUtils.java +++ b/core/codegen/src/main/java/org/overture/codegen/utils/GeneralCodeGenUtils.java @@ -109,6 +109,11 @@ public static TypeCheckResult validateExp(String exp) return typeCheckResult; } + public static void replaceInFile(File file, String regex, String replacement) + { + replaceInFile(file.getAbsolutePath(), regex, replacement); + } + public static void replaceInFile(String filePath, String regex, String replacement) { diff --git a/core/codegen/src/main/java/org/overture/codegen/utils/LexNameTokenWrapper.java b/core/codegen/src/main/java/org/overture/codegen/utils/LexNameTokenWrapper.java index f34244b72f..2d281b34ba 100644 --- a/core/codegen/src/main/java/org/overture/codegen/utils/LexNameTokenWrapper.java +++ b/core/codegen/src/main/java/org/overture/codegen/utils/LexNameTokenWrapper.java @@ -46,10 +46,14 @@ public String toString() @Override public int hashCode() { - return 0; - // This ensures that equals are being - // used when instances of this class are - // stored in collections + int hashCode = 0; + + if(name != null) + { + hashCode += name.hashCode(); + } + + return hashCode; } @Override diff --git a/core/codegen/src/main/java/org/overture/codegen/vdm2java/JavaCodeGenMain.java b/core/codegen/src/main/java/org/overture/codegen/vdm2java/JavaCodeGenMain.java index 86cdce0b9e..dbd0a9a036 100644 --- a/core/codegen/src/main/java/org/overture/codegen/vdm2java/JavaCodeGenMain.java +++ b/core/codegen/src/main/java/org/overture/codegen/vdm2java/JavaCodeGenMain.java @@ -91,13 +91,13 @@ public static void main(String[] args) if(generatedClass.hasUnsupportedIrNodes()) { - Logger.getLog().println("Following VDM constructs are not supported by the IR:"); + Logger.getLog().println("Following VDM constructs are not supported by the code generator:"); JavaCodeGenUtil.printUnsupportedIrNodes(generatedClass.getUnsupportedInIr()); } if(generatedClass.hasUnsupportedTargLangNodes()) { - Logger.getLog().println("Following IR constructs are not supported by the backend/target languages:"); + Logger.getLog().println("Following constructs are not supported by the code generator:"); JavaCodeGenUtil.printUnsupportedNodes(generatedClass.getUnsupportedInTargLang()); } diff --git a/core/codegen/src/main/java/org/overture/codegen/vdm2java/JavaCodeGenUtil.java b/core/codegen/src/main/java/org/overture/codegen/vdm2java/JavaCodeGenUtil.java index 415a9cf31a..0e1153ca69 100644 --- a/core/codegen/src/main/java/org/overture/codegen/vdm2java/JavaCodeGenUtil.java +++ b/core/codegen/src/main/java/org/overture/codegen/vdm2java/JavaCodeGenUtil.java @@ -336,8 +336,6 @@ public static void printUnsupportedIrNodes(Set unsupportedNodes) List nodesSorted = locationAssistant.getVdmNodeInfoLocationSorted(unsupportedNodes); - Logger.getLog().println("Following VDM constructs are not supported by the IR: "); - for (VdmNodeInfo vdmNodeInfo : nodesSorted) { Logger.getLog().print(vdmNodeInfo.getNode().toString()); diff --git a/core/codegen/src/main/java/org/overture/codegen/vdm2java/JavaFormat.java b/core/codegen/src/main/java/org/overture/codegen/vdm2java/JavaFormat.java index d12d62e123..11618aabb6 100644 --- a/core/codegen/src/main/java/org/overture/codegen/vdm2java/JavaFormat.java +++ b/core/codegen/src/main/java/org/overture/codegen/vdm2java/JavaFormat.java @@ -68,7 +68,6 @@ import org.overture.codegen.cgast.expressions.SUnaryExpCG; import org.overture.codegen.cgast.expressions.SVarExpCG; import org.overture.codegen.cgast.name.ATypeNameCG; -import org.overture.codegen.cgast.statements.AApplyObjectDesignatorCG; import org.overture.codegen.cgast.statements.AAssignmentStmCG; import org.overture.codegen.cgast.statements.ABlockStmCG; import org.overture.codegen.cgast.statements.AForLoopStmCG; @@ -177,7 +176,7 @@ public JavaSettings getJavaSettings() public void init() { - mergeVisitor.dropMergeErrors(); + mergeVisitor.init(); } public void setClasses(List classes) @@ -840,12 +839,7 @@ public String nextVarName(String prefix) { return info.getTempVarNameGen().nextVarName(prefix); } - - public STypeCG findElementType(AApplyObjectDesignatorCG designator) - { - return info.getAssistantManager().getTypeAssistant().findElementType(designator, classes, info); - } - + public boolean isLoopVar(AVarDeclCG localVar) { return localVar.parent() instanceof AForLoopStmCG; diff --git a/core/codegen/src/main/java/org/overture/codegen/vdm2java/JavaTransSeries.java b/core/codegen/src/main/java/org/overture/codegen/vdm2java/JavaTransSeries.java index 5d9e649f48..8c0ff383b4 100644 --- a/core/codegen/src/main/java/org/overture/codegen/vdm2java/JavaTransSeries.java +++ b/core/codegen/src/main/java/org/overture/codegen/vdm2java/JavaTransSeries.java @@ -7,6 +7,7 @@ import org.overture.codegen.cgast.expressions.AIntLiteralExpCG; import org.overture.codegen.cgast.types.AExternalTypeCG; import org.overture.codegen.ir.IRInfo; +import org.overture.codegen.trans.CallObjStmTransformation; import org.overture.codegen.trans.IPostCheckCreator; import org.overture.codegen.trans.IsExpTransformation; import org.overture.codegen.trans.PostCheckTransformation; @@ -51,12 +52,13 @@ public DepthFirstAnalysisAdaptor[] consAnalyses(List classes, FuncTransformation funcTransformation = new FuncTransformation(transAssistant); IRInfo irInfo = codeGen.getIRGenerator().getIRInfo(); + CallObjStmTransformation callObjTransformation = new CallObjStmTransformation(irInfo, classes); PrePostTransformation prePostTransformation = new PrePostTransformation(irInfo); IfExpTransformation ifExpTransformation = new IfExpTransformation(transAssistant); FunctionValueTransformation funcValueTransformation = new FunctionValueTransformation(irInfo, transAssistant, functionValueAssistant, INTERFACE_NAME_PREFIX, TEMPLATE_TYPE_PREFIX, EVAL_METHOD_PREFIX, PARAM_NAME_PREFIX); ILanguageIterator langIterator = new JavaLanguageIterator(transAssistant, irInfo.getTempVarNameGen(), codeGen.getTempVarPrefixes()); TransformationVisitor transVisitor = new TransformationVisitor(irInfo, classes, codeGen.getTempVarPrefixes(), transAssistant, consExists1CounterData(), langIterator, TERNARY_IF_EXP_NAME_PREFIX, CASES_EXP_RESULT_NAME_PREFIX, AND_EXP_NAME_PREFIX, OR_EXP_NAME_PREFIX, WHILE_COND_NAME_PREFIX, REC_MODIFIER_NAME_PREFIX); - PatternTransformation patternTransformation = new PatternTransformation(classes, codeGen.getTempVarPrefixes(), irInfo, transAssistant, new PatternMatchConfig()); + PatternTransformation patternTransformation = new PatternTransformation(classes, codeGen.getTempVarPrefixes(), irInfo, transAssistant, new PatternMatchConfig(), CASES_EXP_NAME_PREFIX); PreCheckTransformation preCheckTransformation = new PreCheckTransformation(irInfo, transAssistant, new JavaValueSemanticsTag(false)); PostCheckTransformation postCheckTransformation = new PostCheckTransformation(postCheckCreator, irInfo, transAssistant, FUNC_RESULT_NAME_PREFIX, new JavaValueSemanticsTag(false)); IsExpTransformation isExpTransformation = new IsExpTransformation(irInfo, transAssistant, IS_EXP_SUBJECT_NAME_PREFIX); @@ -72,6 +74,7 @@ public DepthFirstAnalysisAdaptor[] consAnalyses(List classes, JavaClassToStringTrans javaToStringTransformation = new JavaClassToStringTrans(irInfo); DepthFirstAnalysisAdaptor[] analyses = new DepthFirstAnalysisAdaptor[] { + callObjTransformation, funcTransformation, prePostTransformation, ifExpTransformation, funcValueTransformation, transVisitor, patternTransformation, preCheckTransformation, postCheckTransformation, diff --git a/core/codegen/src/main/java/org/overture/codegen/vdm2java/JavaValueSemantics.java b/core/codegen/src/main/java/org/overture/codegen/vdm2java/JavaValueSemantics.java index cd6cdfcd7a..f02ed76072 100644 --- a/core/codegen/src/main/java/org/overture/codegen/vdm2java/JavaValueSemantics.java +++ b/core/codegen/src/main/java/org/overture/codegen/vdm2java/JavaValueSemantics.java @@ -49,9 +49,7 @@ import org.overture.codegen.cgast.expressions.ASetSubsetBinaryExpCG; import org.overture.codegen.cgast.expressions.ATupleCompatibilityExpCG; import org.overture.codegen.cgast.expressions.ATupleSizeExpCG; -import org.overture.codegen.cgast.statements.AApplyObjectDesignatorCG; import org.overture.codegen.cgast.statements.AForAllStmCG; -import org.overture.codegen.cgast.statements.AIdentifierObjectDesignatorCG; import org.overture.codegen.cgast.statements.ALocalAssignmentStmCG; import org.overture.codegen.cgast.types.AExternalTypeCG; import org.overture.codegen.cgast.types.AMethodTypeCG; @@ -166,19 +164,6 @@ public boolean shouldClone(SExpCG exp) return false; } - if (parent instanceof AIdentifierObjectDesignatorCG) - { - // Don't clone the variable associated with an identifier object designator - return false; - } - - if (parent instanceof AApplyObjectDesignatorCG) - { - // No need to clone the expression - we only use it for lookup - return usesStructuralEquivalence(exp.getType()) - && javaFormat.findElementType((AApplyObjectDesignatorCG) parent) == null; - } - if (parent instanceof ALocalAssignmentStmCG) { ALocalAssignmentStmCG assignment = (ALocalAssignmentStmCG) parent; diff --git a/core/codegen/src/main/java/org/overture/codegen/visitor/AbstractVisitorCG.java b/core/codegen/src/main/java/org/overture/codegen/visitor/AbstractVisitorCG.java index 4d167fc887..24f5fa4f78 100644 --- a/core/codegen/src/main/java/org/overture/codegen/visitor/AbstractVisitorCG.java +++ b/core/codegen/src/main/java/org/overture/codegen/visitor/AbstractVisitorCG.java @@ -30,7 +30,6 @@ public class AbstractVisitorCG extends QuestionAnswerAdaptor { - @Override public A defaultINode(INode node, Q question) throws AnalysisException { @@ -40,8 +39,6 @@ public A defaultINode(INode node, Q question) throws AnalysisException } question.addUnsupportedNode(node); - // Logger.getLog().printErrorln("Code generation does not support the following VDM construct: " + - // node.getClass().getName() + ": " + node.toString()); return null; } @@ -59,5 +56,4 @@ public A createNewReturnValue(Object node, Q question) { return null; } - } diff --git a/core/codegen/src/main/java/org/overture/codegen/visitor/DeclVisitorCG.java b/core/codegen/src/main/java/org/overture/codegen/visitor/DeclVisitorCG.java index ab5fa6bf53..97dd934fe5 100644 --- a/core/codegen/src/main/java/org/overture/codegen/visitor/DeclVisitorCG.java +++ b/core/codegen/src/main/java/org/overture/codegen/visitor/DeclVisitorCG.java @@ -29,6 +29,8 @@ import org.overture.ast.definitions.AClassInvariantDefinition; import org.overture.ast.definitions.AExplicitFunctionDefinition; import org.overture.ast.definitions.AExplicitOperationDefinition; +import org.overture.ast.definitions.AImplicitFunctionDefinition; +import org.overture.ast.definitions.AImplicitOperationDefinition; import org.overture.ast.definitions.AInstanceVariableDefinition; import org.overture.ast.definitions.AMutexSyncDefinition; import org.overture.ast.definitions.ANamedTraceDefinition; @@ -58,8 +60,8 @@ import org.overture.codegen.cgast.declarations.AFuncDeclCG; import org.overture.codegen.cgast.declarations.AMethodDeclCG; import org.overture.codegen.cgast.declarations.AMutexSyncDeclCG; -import org.overture.codegen.cgast.declarations.ANamedTypeDeclCG; import org.overture.codegen.cgast.declarations.ANamedTraceDeclCG; +import org.overture.codegen.cgast.declarations.ANamedTypeDeclCG; import org.overture.codegen.cgast.declarations.APersyncDeclCG; import org.overture.codegen.cgast.declarations.ARecordDeclCG; import org.overture.codegen.cgast.declarations.AThreadDeclCG; @@ -67,6 +69,7 @@ import org.overture.codegen.cgast.expressions.ALambdaExpCG; import org.overture.codegen.cgast.expressions.ANotImplementedExpCG; import org.overture.codegen.cgast.name.ATokenNameCG; +import org.overture.codegen.cgast.statements.ANotImplementedStmCG; import org.overture.codegen.cgast.traces.ATraceDeclTermCG; import org.overture.codegen.cgast.types.AMethodTypeCG; import org.overture.codegen.cgast.types.ATemplateTypeCG; @@ -118,6 +121,7 @@ public SDeclCG caseANamedTraceDefinition(ANamedTraceDefinition node, else { Logger.getLog().printErrorln("Expected term to be of type ATraceDeclTermCG. Got: " + termCg); + return null; } } @@ -161,8 +165,6 @@ public SDeclCG caseARecordInvariantType(ARecordInvariantType node, recordFields.add(fieldDecl); } else { - question.addUnsupportedNode(node, - "Could not generate fields of record: " + name); return null; } } @@ -320,44 +322,77 @@ public SDeclCG caseAExplicitFunctionDefinition( return method; } - + @Override - public SDeclCG caseAExplicitOperationDefinition( - AExplicitOperationDefinition node, IRInfo question) + public SDeclCG caseAImplicitFunctionDefinition( + AImplicitFunctionDefinition node, IRInfo question) throws AnalysisException { - String access = node.getAccess().getAccess().toString(); - boolean isStatic = question.getTcFactory().createPDefinitionAssistant().isStatic(node); - boolean isAsync = question.getTcFactory().createPAccessSpecifierAssistant().isAsync(node.getAccess()); - String operationName = node.getName().getName(); - STypeCG type = node.getType().apply(question.getTypeVisitor(), question); - - if (!(type instanceof AMethodTypeCG)) + String accessCg = node.getAccess().getAccess().toString(); + String funcNameCg = node.getName().getName(); + + STypeCG typeCg = node.getType().apply(question.getTypeVisitor(), question); + + if (!(typeCg instanceof AMethodTypeCG)) { - question.addUnsupportedNode(node, "Expected method type for explicit operation. Got: " - + type); + question.addUnsupportedNode(node, "Expected method type for implicit function. Got: " + + typeCg); return null; } - AMethodTypeCG methodType = (AMethodTypeCG) type; - SStmCG body = node.getBody().apply(question.getStmVisitor(), question); - boolean isConstructor = node.getIsConstructor(); - boolean isAbstract = body == null; + AFuncDeclCG func = new AFuncDeclCG(); + AExplicitFunctionDefinition preCond = node.getPredef(); + SDeclCG preCondCg = preCond != null ? preCond.apply(question.getDeclVisitor(), question) : null; + func.setPreCond(preCondCg); + + AExplicitFunctionDefinition postCond = node.getPostdef(); + SDeclCG postCondCg = postCond != null ? postCond.apply(question.getDeclVisitor(), question) : null; + func.setPostCond(postCondCg); - AMethodDeclCG method = new AMethodDeclCG(); - method.setAccess(access); - method.setStatic(isStatic); - method.setAsync(isAsync); - method.setMethodType(methodType); - method.setName(operationName); - method.setBody(body); - method.setIsConstructor(isConstructor); - method.setAbstract(isAbstract); + // If the function uses any type parameters they will be + // registered as part of the method declaration + List typeParams = node.getTypeParams(); + for (int i = 0; i < typeParams.size(); i++) + { + ILexNameToken typeParam = typeParams.get(i); + ATemplateTypeCG templateType = new ATemplateTypeCG(); + templateType.setName(typeParam.getName()); + func.getTemplateTypes().add(templateType); + } + + func.setAbstract(false); + func.setAccess(accessCg); + func.setBody(new ANotImplementedExpCG()); + func.setFormalParams(question.getDeclAssistant(). + consFormalParams(node.getParamPatterns(), question)); + func.setMethodType((AMethodTypeCG) typeCg); + func.setName(funcNameCg); + + // The implicit function is currently constructed without the result information: + //SPatternCG resPatternCg = node.getResult().getPattern().apply(question.getPatternVisitor(), question); + //STypeCG resTypeCg = node.getResult().getType().apply(question.getTypeVisitor(), question); + return func; + } + + @Override + public SDeclCG caseAExplicitOperationDefinition( + AExplicitOperationDefinition node, IRInfo question) + throws AnalysisException + { + AMethodDeclCG method = question.getDeclAssistant().initMethod(node, question); + + if(method == null) + { + question.addUnsupportedNode(node, "Expected method type for explicit operation. Got: " + + node.getType()); + return null; + } + List ptypes = ((AOperationType) node.getType()).getParameters(); LinkedList paramPatterns = node.getParameterPatterns(); - + LinkedList formalParameters = method.getFormalParams(); for (int i = 0; i < ptypes.size(); i++) @@ -371,15 +406,36 @@ public SDeclCG caseAExplicitOperationDefinition( formalParameters.add(param); } + + return method; + } + + @Override + public SDeclCG caseAImplicitOperationDefinition( + AImplicitOperationDefinition node, IRInfo question) + throws AnalysisException + { + AMethodDeclCG method = question.getDeclAssistant().initMethod(node, question); - AExplicitFunctionDefinition preCond = node.getPredef(); - SDeclCG preCondCg = preCond != null ? preCond.apply(question.getDeclVisitor(), question) : null; - method.setPreCond(preCondCg); - - AExplicitFunctionDefinition postCond = node.getPostdef(); - SDeclCG postCondCg = postCond != null ? postCond.apply(question.getDeclVisitor(), question) : null; - method.setPostCond(postCondCg); + if(method == null) + { + question.addUnsupportedNode(node, "Expected method type for explicit operation. Got: " + + node.getType()); + return null; + } + // The curent IR construction does not include: + // + // Name of result and its type: + // APatternTypePair res = node.getResult(); + // Ext clauses (read and write): + // LinkedList externals = node.getExternals(); + // Exceptions thrown: + // LinkedList errors = node.getErrors(); + + method.setBody(new ANotImplementedStmCG()); + method.setFormalParams(question.getDeclAssistant(). + consFormalParams(node.getParameterPatterns(), question)); return method; } diff --git a/core/codegen/src/main/java/org/overture/codegen/visitor/ExpVisitorCG.java b/core/codegen/src/main/java/org/overture/codegen/visitor/ExpVisitorCG.java index e2403dc016..9c35a3e452 100644 --- a/core/codegen/src/main/java/org/overture/codegen/visitor/ExpVisitorCG.java +++ b/core/codegen/src/main/java/org/overture/codegen/visitor/ExpVisitorCG.java @@ -201,7 +201,12 @@ public SExpCG caseANotYetSpecifiedExp(ANotYetSpecifiedExp node, public SExpCG caseATimeExp(ATimeExp node, IRInfo question) throws AnalysisException { - return new ATimeExpCG(); + STypeCG typeCg = node.getType().apply(question.getTypeVisitor(), question); + + ATimeExpCG timeExp = new ATimeExpCG(); + timeExp.setType(typeCg); + + return timeExp; } @Override @@ -427,7 +432,14 @@ public SExpCG caseASetEnumSetExp(ASetEnumSetExp node, IRInfo question) for (PExp member : members) { - membersCg.add(member.apply(question.getExpVisitor(), question)); + SExpCG memberCg = member.apply(question.getExpVisitor(), question); + if (memberCg != null) + { + membersCg.add(memberCg); + } else + { + return null; + } } return enumSet; @@ -514,6 +526,7 @@ public SExpCG caseASetCompSetExp(ASetCompSetExp node, IRInfo question) { question.addUnsupportedNode(node, "Generation of a multiple set bind was expected to yield a ASetMultipleBindCG. Got: " + multipleBindCg); + return null; } bindingsCg.add((ASetMultipleBindCG) multipleBindCg); @@ -661,7 +674,15 @@ public SExpCG caseATupleExp(ATupleExp node, IRInfo question) for (PExp exp : args) { SExpCG expCg = exp.apply(question.getExpVisitor(), question); - tupleExp.getArgs().add(expCg); + + if (expCg != null) + { + tupleExp.getArgs().add(expCg); + } + else + { + return null; + } } return tupleExp; @@ -702,7 +723,14 @@ public SExpCG caseAFuncInstatiationExp(AFuncInstatiationExp node, for (PType actualType : actualTypes) { STypeCG actualTypeCg = actualType.apply(question.getTypeVisitor(), question); - methodInst.getActualTypes().add(actualTypeCg); + + if (actualTypeCg != null) + { + methodInst.getActualTypes().add(actualTypeCg); + } else + { + return null; + } } methodInst.setFunc(funcCg); @@ -851,7 +879,15 @@ public SExpCG caseAMkTypeExp(AMkTypeExp node, IRInfo question) for (PExp arg : nodeArgs) { - newExpArgs.add(arg.apply(question.getExpVisitor(), question)); + SExpCG argCg = arg.apply(question.getExpVisitor(), question); + + if (argCg != null) + { + newExpArgs.add(argCg); + } else + { + return null; + } } return newExp; @@ -1004,16 +1040,18 @@ public SExpCG caseAMapEnumMapExp(AMapEnumMapExp node, IRInfo question) LinkedList members = node.getMembers(); for (PExp member : members) { - SExpCG exp = member.apply(question.getExpVisitor(), question); + SExpCG memberCg = member.apply(question.getExpVisitor(), question); - if (!(exp instanceof AMapletExpCG)) + if (!(memberCg instanceof AMapletExpCG)) { question.addUnsupportedNode(node, - "Got expected map enumeration member: " + exp); + "Got expected map enumeration member: " + memberCg); return null; } - - enumMap.getMembers().add((AMapletExpCG) exp); + else + { + enumMap.getMembers().add((AMapletExpCG) memberCg); + } } return enumMap; @@ -1086,6 +1124,7 @@ public SExpCG caseAMapCompMapExp(AMapCompMapExp node, IRInfo question) { question.addUnsupportedNode(node, "Generation of map comprehension expected a maplet expression. Got: " + firstCg); + return null; } AMapletExpCG mapletExpCg = (AMapletExpCG) firstCg; @@ -1208,12 +1247,14 @@ public SExpCG caseASeqEnumSeqExp(ASeqEnumSeqExp node, IRInfo question) { SExpCG memberCg = member.apply(question.getExpVisitor(), question); - if(memberCg == null) + if(memberCg != null) + { + enumSeq.getMembers().add(memberCg); + } + else { return null; } - - enumSeq.getMembers().add(memberCg); } return enumSeq; @@ -1270,14 +1311,15 @@ public SExpCG caseAApplyExp(AApplyExp node, IRInfo question) { SExpCG argCg = arg.apply(question.getExpVisitor(), question); - if (argCg == null) + if (argCg != null) + { + applyExp.getArgs().add(argCg); + } + else { - question.addUnsupportedNode(node, "Apply expression is not supported for the argument: " - + arg); return null; } - applyExp.getArgs().add(argCg); } return applyExp; @@ -1393,7 +1435,15 @@ public SExpCG caseANewExp(ANewExp node, IRInfo question) LinkedList newExpArgs = newExp.getArgs(); for (PExp arg : nodeArgs) { - newExpArgs.add(arg.apply(question.getExpVisitor(), question)); + SExpCG argCg = arg.apply(question.getExpVisitor(), question); + + if (argCg != null) + { + newExpArgs.add(argCg); + } else + { + return null; + } } return newExp; diff --git a/core/codegen/src/main/java/org/overture/codegen/visitor/MultipleBindVisitorCG.java b/core/codegen/src/main/java/org/overture/codegen/visitor/MultipleBindVisitorCG.java index 60f3604751..388925a2a3 100644 --- a/core/codegen/src/main/java/org/overture/codegen/visitor/MultipleBindVisitorCG.java +++ b/core/codegen/src/main/java/org/overture/codegen/visitor/MultipleBindVisitorCG.java @@ -49,7 +49,15 @@ public SMultipleBindCG caseASetMultipleBind(ASetMultipleBind node, for (PPattern pattern : patterns) { SPatternCG patternTempCg = pattern.apply(question.getPatternVisitor(), question); - patternsCg.add(patternTempCg); + + if (patternTempCg != null) + { + patternsCg.add(patternTempCg); + } + else + { + return null; + } } SExpCG setCg = set.apply(question.getExpVisitor(), question); diff --git a/core/codegen/src/main/java/org/overture/codegen/visitor/ObjectDesignatorVisitorCG.java b/core/codegen/src/main/java/org/overture/codegen/visitor/ObjectDesignatorVisitorCG.java index d3c7b0384b..78ae74a0fb 100644 --- a/core/codegen/src/main/java/org/overture/codegen/visitor/ObjectDesignatorVisitorCG.java +++ b/core/codegen/src/main/java/org/overture/codegen/visitor/ObjectDesignatorVisitorCG.java @@ -27,7 +27,6 @@ import org.overture.ast.expressions.ANewExp; import org.overture.ast.expressions.AVariableExp; import org.overture.ast.expressions.PExp; -import org.overture.ast.intf.lex.ILexNameToken; import org.overture.ast.statements.AApplyObjectDesignator; import org.overture.ast.statements.AFieldObjectDesignator; import org.overture.ast.statements.AIdentifierObjectDesignator; @@ -63,7 +62,14 @@ public SObjectDesignatorCG caseAApplyObjectDesignator( for (PExp arg : node.getArgs()) { SExpCG argCg = arg.apply(question.getExpVisitor(), question); - newExpArgs.add(argCg); + + if (argCg != null) + { + newExpArgs.add(argCg); + } else + { + return null; + } } return applyObjDesignator; @@ -74,11 +80,21 @@ public SObjectDesignatorCG caseAFieldObjectDesignator( AFieldObjectDesignator node, IRInfo question) throws AnalysisException { - ILexNameToken field = node.getField(); PObjectDesignator obj = node.getObject(); - String fieldCg = field.getName(); - String fieldModuleCg = field.getModule(); + String fieldCg = null; + String fieldModuleCg = null; + + if(node.getField() != null) + { + fieldCg = node.getField().getName(); + fieldModuleCg = node.getField().getModule(); + } + else + { + fieldCg = node.getFieldName() != null ? node.getFieldName().getName() : null; + } + SObjectDesignatorCG objCg = obj.apply(question.getObjectDesignatorVisitor(), question); AFieldObjectDesignatorCG fieldObjDesignator = new AFieldObjectDesignatorCG(); diff --git a/core/codegen/src/main/java/org/overture/codegen/visitor/PatternVisitorCG.java b/core/codegen/src/main/java/org/overture/codegen/visitor/PatternVisitorCG.java index 3e748c41af..c4774660d0 100644 --- a/core/codegen/src/main/java/org/overture/codegen/visitor/PatternVisitorCG.java +++ b/core/codegen/src/main/java/org/overture/codegen/visitor/PatternVisitorCG.java @@ -159,7 +159,15 @@ public SPatternCG caseATuplePattern(ATuplePattern node, IRInfo question) for (PPattern currentPattern : node.getPlist()) { SPatternCG patternCg = currentPattern.apply(question.getPatternVisitor(), question); - tuplePatternCg.getPatterns().add(patternCg); + + if(patternCg != null) + { + tuplePatternCg.getPatterns().add(patternCg); + } + else + { + return null; + } } return tuplePatternCg; @@ -181,7 +189,15 @@ public SPatternCG caseARecordPattern(ARecordPattern node, IRInfo question) for (PPattern currentPattern : node.getPlist()) { SPatternCG patternCg = currentPattern.apply(question.getPatternVisitor(), question); - recordPatternCg.getPatterns().add(patternCg); + + if(patternCg != null) + { + recordPatternCg.getPatterns().add(patternCg); + } + else + { + return null; + } } return recordPatternCg; diff --git a/core/codegen/src/main/java/org/overture/codegen/visitor/StmVisitorCG.java b/core/codegen/src/main/java/org/overture/codegen/visitor/StmVisitorCG.java index 6a0ab27202..2daadb5762 100644 --- a/core/codegen/src/main/java/org/overture/codegen/visitor/StmVisitorCG.java +++ b/core/codegen/src/main/java/org/overture/codegen/visitor/StmVisitorCG.java @@ -126,7 +126,15 @@ public SStmCG caseAPeriodicStm(APeriodicStm node, IRInfo question) for(PExp exp : node.getArgs()) { SExpCG expCg = exp.apply(question.getExpVisitor(), question); - periodicStmCg.getArgs().add(expCg); + + if(expCg != null) + { + periodicStmCg.getArgs().add(expCg); + } + else + { + return null; + } } return periodicStmCg; @@ -143,7 +151,16 @@ public SStmCG caseAAtomicStm(AAtomicStm node, IRInfo question) for (AAssignmentStm assignment : assignments) { - stmsCg.add(assignment.apply(question.getStmVisitor(), question)); + SStmCG stmCg = assignment.apply(question.getStmVisitor(), question); + + if(stmCg != null) + { + stmsCg.add(stmCg); + } + else + { + return null; + } } return stmBlock; @@ -168,8 +185,6 @@ public SStmCG caseALetBeStStm(ALetBeStStm node, IRInfo question) if (!(multipleBindCg instanceof ASetMultipleBindCG)) { - question.addUnsupportedNode(node, "Generation of a multiple set bind was expected to yield a ASetMultipleBindCG. Got: " - + multipleBindCg); return null; } @@ -259,6 +274,10 @@ public SStmCG caseABlockSimpleBlockStm(ABlockSimpleBlockStm node, { blockStm.getStatements().add(stmCg); } + else + { + return null; + } } return blockStm; @@ -340,19 +359,18 @@ public SStmCG caseACallStm(ACallStm node, IRInfo question) List argsCg = new LinkedList(); - for (int i = 0; i < args.size(); i++) + for (PExp arg : args) { - PExp arg = args.get(i); SExpCG argCg = arg.apply(question.getExpVisitor(), question); - if (argCg == null) + if (argCg != null) + { + argsCg.add(argCg); + } + else { - question.addUnsupportedNode(node, "A Call statement is not supported for the argument: " - + arg); return null; } - - argsCg.add(argCg); } boolean isStatic = question.getTcFactory().createPDefinitionAssistant().isStatic(rootdef); @@ -465,19 +483,18 @@ public SStmCG caseACallObjectStm(ACallObjectStm node, IRInfo question) callObject.setDesignator(objectDesignatorCg); callObject.setFieldName(fieldNameCg); - for (int i = 0; i < args.size(); i++) + for (PExp arg : args) { - PExp arg = args.get(i); SExpCG argCg = arg.apply(question.getExpVisitor(), question); - if (argCg == null) + if (argCg != null) + { + callObject.getArgs().add(argCg); + } + else { - question.addUnsupportedNode(node, "A Call object statement is not supported for the argument: " - + arg); return null; } - - callObject.getArgs().add(argCg); } return callObject; diff --git a/core/codegen/src/main/java/org/overture/codegen/visitor/TypeVisitorCG.java b/core/codegen/src/main/java/org/overture/codegen/visitor/TypeVisitorCG.java index 7921fed5e9..93ba95e9fc 100644 --- a/core/codegen/src/main/java/org/overture/codegen/visitor/TypeVisitorCG.java +++ b/core/codegen/src/main/java/org/overture/codegen/visitor/TypeVisitorCG.java @@ -113,7 +113,15 @@ public STypeCG caseAUnionType(AUnionType node, IRInfo question) for (PType type : types) { STypeCG typeCg = type.apply(question.getTypeVisitor(), question); - unionTypeCg.getTypes().add(typeCg); + + if(typeCg != null) + { + unionTypeCg.getTypes().add(typeCg); + } + else + { + return null; + } } return unionTypeCg; @@ -188,8 +196,15 @@ public STypeCG caseAProductType(AProductType node, IRInfo question) for (PType type : types) { STypeCG typeCg = type.apply(question.getTypeVisitor(), question); - tuple.getTypes().add(typeCg); - + + if (typeCg != null) + { + tuple.getTypes().add(typeCg); + } + else + { + return null; + } } return tuple; diff --git a/core/codegen/src/main/resources/JavaTemplates/ObjectDesignator/Apply.vm b/core/codegen/src/main/resources/JavaTemplates/ObjectDesignator/Apply.vm deleted file mode 100644 index fd9b9db5e8..0000000000 --- a/core/codegen/src/main/resources/JavaTemplates/ObjectDesignator/Apply.vm +++ /dev/null @@ -1,9 +0,0 @@ -#set( $args = $JavaFormat.formatArgs($node.getArgs()) ) -## -#set( $elementType = $JavaFormat.findElementType($node) ) -## -#if ( $JavaFormat.isNull($elementType) ) - ${JavaFormat.format($node.getObject())}(${args}) -#else - ((${JavaFormat.format($elementType)}) ${JavaFormat.format($node.getObject())}.get(${args})) -#end diff --git a/core/codegen/src/main/resources/JavaTemplates/ObjectDesignator/Field.vm b/core/codegen/src/main/resources/JavaTemplates/ObjectDesignator/Field.vm deleted file mode 100644 index f6c8b96598..0000000000 --- a/core/codegen/src/main/resources/JavaTemplates/ObjectDesignator/Field.vm +++ /dev/null @@ -1 +0,0 @@ -$JavaFormat.format($node.getObject()).$node.getFieldName() \ No newline at end of file diff --git a/core/codegen/src/main/resources/JavaTemplates/ObjectDesignator/Identifier.vm b/core/codegen/src/main/resources/JavaTemplates/ObjectDesignator/Identifier.vm deleted file mode 100644 index 4951d20597..0000000000 --- a/core/codegen/src/main/resources/JavaTemplates/ObjectDesignator/Identifier.vm +++ /dev/null @@ -1 +0,0 @@ -$JavaFormat.format($node.getExp()) \ No newline at end of file diff --git a/core/codegen/src/main/resources/JavaTemplates/ObjectDesignator/New.vm b/core/codegen/src/main/resources/JavaTemplates/ObjectDesignator/New.vm deleted file mode 100644 index 4951d20597..0000000000 --- a/core/codegen/src/main/resources/JavaTemplates/ObjectDesignator/New.vm +++ /dev/null @@ -1 +0,0 @@ -$JavaFormat.format($node.getExp()) \ No newline at end of file diff --git a/core/codegen/src/main/resources/JavaTemplates/ObjectDesignator/Self.vm b/core/codegen/src/main/resources/JavaTemplates/ObjectDesignator/Self.vm deleted file mode 100644 index a2a3f4f1e3..0000000000 --- a/core/codegen/src/main/resources/JavaTemplates/ObjectDesignator/Self.vm +++ /dev/null @@ -1 +0,0 @@ -this \ No newline at end of file diff --git a/core/codegen/src/main/resources/cg.astv2 b/core/codegen/src/main/resources/cg.astv2 index 753d522f83..f8dbf25368 100644 --- a/core/codegen/src/main/resources/cg.astv2 +++ b/core/codegen/src/main/resources/cg.astv2 @@ -99,7 +99,6 @@ CG {-> package='org.overture.codegen.cgast' (preCond):CG.#decl (postCond):CG.#decl [access]:java_String - [async]:java_Boolean [abstract]:java_Boolean [methodType]:CG.#type.method [name]:java_String @@ -166,7 +165,9 @@ CG {-> package='org.overture.codegen.cgast' | {namedType} [name]:java_String [type]:CG.#type - | {namedTrace} [pathname]:CG.#name.token* [terms]:CG.#term.traceDecl* + | {namedTrace} + [pathname]:CG.#name.token* + [terms]:CG.#term.traceDecl* ; #stateDesignator {-> package='org.overture.codegen.cgast.statements' @@ -223,6 +224,10 @@ CG {-> package='org.overture.codegen.cgast' | {try} [stm]:CG.#stm [catchClauses]:CG.#decl.catchClause* [finally]:CG.#stm | {periodic} [opname]:java_String [args]:CG.#exp* //| Sporadic + | {stackDecl} + [type]:CG.#type + [name]:java_String + [args]:CG.#exp* ; #call {-> package='org.overture.codegen.cgast.statements' diff --git a/core/codegen/src/test/resources/classic_specs/CashDispenserPP.result b/core/codegen/src/test/resources/classic_specs/CashDispenserPP.result index 3807366f65..678c85d2a6 100644 --- a/core/codegen/src/test/resources/classic_specs/CashDispenserPP.result +++ b/core/codegen/src/test/resources/classic_specs/CashDispenserPP.result @@ -49,7 +49,7 @@ public class SimpleTest { Number pglid1 = 1L; resource.AddAccount(pglid1, pglacc1); resource.AddLetterbox(clock, new Letterbox()); - ((Till) tills.get(1L)).InsertCard(c1); + ((Till) MapUtil.get(tills, 1L)).InsertCard(c1); if (Utils.equals(((Till) MapUtil.get(tills, 1L)).Validate( 123456L), quotes.PinOk.getInstance())) { @@ -346,7 +346,7 @@ public class CentralResource { public Number GetBalance(final Number accountId) { if (MapUtil.dom(Utils.clone(accounts)).contains(accountId)) { - return ((Account) accounts.get(accountId)).GetBalance(); + return ((Account) MapUtil.get(accounts, accountId)).GetBalance(); } else { return null; } @@ -355,7 +355,7 @@ public class CentralResource { public Boolean Withdrawal(final Number accountId, final Number cardId, final Number amount) { if (IsLegalCard(accountId, cardId)) { - return ((Account) accounts.get(accountId)).Withdrawal(cardId, + return ((Account) MapUtil.get(accounts, accountId)).Withdrawal(cardId, amount, clock.GetDate()); } else { return false; diff --git a/core/codegen/src/test/resources/cloning_specs/CashDispenserPP.result b/core/codegen/src/test/resources/cloning_specs/CashDispenserPP.result index e61c9bc022..45306dc236 100644 --- a/core/codegen/src/test/resources/cloning_specs/CashDispenserPP.result +++ b/core/codegen/src/test/resources/cloning_specs/CashDispenserPP.result @@ -49,7 +49,7 @@ public class SimpleTest { Number pglid1 = 1L; resource.AddAccount(pglid1, pglacc1); resource.AddLetterbox(clock, new Letterbox()); - ((Till) tills.get(1L)).InsertCard(c1); + ((Till) MapUtil.get(tills, 1L)).InsertCard(c1); if (Utils.equals(((Till) MapUtil.get(tills, 1L)).Validate( 123456L), quotes.PinOk.getInstance())) { @@ -341,7 +341,7 @@ public class CentralResource { public Number GetBalance(final Number accountId) { if (MapUtil.dom(accounts).contains(accountId)) { - return ((Account) accounts.get(accountId)).GetBalance(); + return ((Account) MapUtil.get(accounts, accountId)).GetBalance(); } else { return null; } @@ -350,7 +350,7 @@ public class CentralResource { public Boolean Withdrawal(final Number accountId, final Number cardId, final Number amount) { if (IsLegalCard(accountId, cardId)) { - return ((Account) accounts.get(accountId)).Withdrawal(cardId, + return ((Account) MapUtil.get(accounts, accountId)).Withdrawal(cardId, amount, clock.GetDate()); } else { return false; diff --git a/core/codegen/src/test/resources/complex_expressions/ApplyObjectDesignatorClone.result b/core/codegen/src/test/resources/complex_expressions/ApplyObjectDesignatorClone.result index b840e594b3..af5c0856c2 100644 --- a/core/codegen/src/test/resources/complex_expressions/ApplyObjectDesignatorClone.result +++ b/core/codegen/src/test/resources/complex_expressions/ApplyObjectDesignatorClone.result @@ -17,14 +17,14 @@ public class A { public Number op1() { Tuple a = Tuple.mk_(1L, 2L); - return ((A) x.get(a)).no(); + return ((A) MapUtil.get(x, a)).no(); } public Number op2() { Tuple a = Tuple.mk_('x', 'y'); Tuple b = Tuple.mk_(1L, 2L); - return ((A) m(Utils.clone(a), Utils.clone(a)).get(b)).no(); + return ((A) MapUtil.get(m(Utils.clone(a), Utils.clone(a)), b)).no(); } public VDMMap m(final Tuple p, final Tuple q) { diff --git a/core/codegen/src/test/resources/complex_expressions/ApplyObjectDesignatorMapLookup.result b/core/codegen/src/test/resources/complex_expressions/ApplyObjectDesignatorMapLookup.result index ac5e4ddb66..dcbcb01dce 100644 --- a/core/codegen/src/test/resources/complex_expressions/ApplyObjectDesignatorMapLookup.result +++ b/core/codegen/src/test/resources/complex_expressions/ApplyObjectDesignatorMapLookup.result @@ -48,7 +48,7 @@ public class Entry { public static Object Run() { Storage s = new Storage(); - return ((X) s.getXs().get(1L)).fun(); + return ((X) MapUtil.get(s.getXs(), 1L)).fun(); } public String toString() { diff --git a/core/codegen/src/test/resources/complex_expressions/ApplyObjectDesignatorMapType.result b/core/codegen/src/test/resources/complex_expressions/ApplyObjectDesignatorMapType.result index a909f1afdb..a1a2ebbe54 100644 --- a/core/codegen/src/test/resources/complex_expressions/ApplyObjectDesignatorMapType.result +++ b/core/codegen/src/test/resources/complex_expressions/ApplyObjectDesignatorMapType.result @@ -15,15 +15,16 @@ public class X { } public Number m1() { - return ((X) xs.get(1L)).f(); + return ((X) MapUtil.get(xs, 1L)).f(); } public Number m2() { - return ((X) ((VDMMap) ys.get(1L)).get(1L)).f(); + return ((X) MapUtil.get(((VDMMap) MapUtil.get(ys, 1L)), 1L)).f(); } public Number m3() { - return ((X) ((VDMMap) ((VDMMap) zs.get(1L)).get(1L)).get(1L)).f(); + return ((X) MapUtil.get(((VDMMap) MapUtil.get( + ((VDMMap) MapUtil.get(zs, 1L)), 1L)), 1L)).f(); } public Number m4() { @@ -31,15 +32,16 @@ public class X { } public Number m5() { - return ((X) map_xs(1L, 2L).get(1L)).f(); + return ((X) MapUtil.get(map_xs(1L, 2L), 1L)).f(); } public Number m6() { - return ((X) ((VDMMap) map_ys(1L, 2L).get(1L)).get(1L)).f(); + return ((X) MapUtil.get(((VDMMap) MapUtil.get(map_ys(1L, 2L), 1L)), 1L)).f(); } public Number m7() { - return ((X) ((VDMMap) ((VDMMap) map_zs(1L, 2L).get(1L)).get(1L)).get(1L)).f(); + return ((X) MapUtil.get(((VDMMap) MapUtil.get( + ((VDMMap) MapUtil.get(map_zs(1L, 2L), 1L)), 1L)), 1L)).f(); } public VDMMap map_xs(final Number pa, final Number pb) { diff --git a/core/codegen/src/test/resources/complex_expressions/ApplyObjectDesignatorWithRecFieldObj1 b/core/codegen/src/test/resources/complex_expressions/ApplyObjectDesignatorWithRecFieldObj1 new file mode 100644 index 0000000000..5e4d60a1b9 --- /dev/null +++ b/core/codegen/src/test/resources/complex_expressions/ApplyObjectDesignatorWithRecFieldObj1 @@ -0,0 +1,23 @@ +class Entry + +types + +public +A :: + es : seq of Entry; + +operations + +public static Run : () ==> ? +Run () == +let a = mk_A([new Entry()]) +in + op(a); + +public static op : A ==> nat +op (a) == a.es(1).getConst(); + +public getConst : () ==> nat +getConst () == return 5; + +end Entry \ No newline at end of file diff --git a/core/codegen/src/test/resources/complex_expressions/ApplyObjectDesignatorWithRecFieldObj1.result b/core/codegen/src/test/resources/complex_expressions/ApplyObjectDesignatorWithRecFieldObj1.result new file mode 100644 index 0000000000..3ef5f80dd5 --- /dev/null +++ b/core/codegen/src/test/resources/complex_expressions/ApplyObjectDesignatorWithRecFieldObj1.result @@ -0,0 +1,59 @@ +import org.overture.codegen.runtime.*; + +import java.util.*; + + +public class Entry { + public Entry() { + } + + public static Object Run() { + A a = new A(SeqUtil.seq(new Entry())); + + return op(Utils.clone(a)); + } + + public static Number op(final A a) { + return ((Entry) a.es.get(Utils.index(1L))).getConst(); + } + + public Number getConst() { + return 5L; + } + + public String toString() { + return "Entry{}"; + } + + public static class A implements Record { + public VDMSeq es; + + public A(final VDMSeq _es) { + es = (_es != null) ? Utils.clone(_es) : null; + } + + public boolean equals(final Object obj) { + if (!(obj instanceof A)) { + return false; + } + + A other = ((A) obj); + + return Utils.equals(es, other.es); + } + + public int hashCode() { + return Utils.hashCode(es); + } + + public A clone() { + return new A(es); + } + + public String toString() { + return "mk_Entry`A" + Utils.formatFields(es); + } + } +} + +########## diff --git a/core/codegen/src/test/resources/complex_expressions/ApplyObjectDesignatorWithRecFieldObj2 b/core/codegen/src/test/resources/complex_expressions/ApplyObjectDesignatorWithRecFieldObj2 new file mode 100644 index 0000000000..54951bbabb --- /dev/null +++ b/core/codegen/src/test/resources/complex_expressions/ApplyObjectDesignatorWithRecFieldObj2 @@ -0,0 +1,32 @@ +class Entry + +types + +public +A :: + bs : seq of B; + +public +B :: + c : C; + +public +C :: + e : Entry; + + +operations + +public static Run : () ==> ? +Run () == +let a = mk_A([mk_B(mk_C(new Entry()))]) +in + op(a); + +public static op : A ==> nat +op (a) == a.bs(1).c.e.getConst(); + +public getConst : () ==> nat +getConst () == return 5; + +end Entry \ No newline at end of file diff --git a/core/codegen/src/test/resources/complex_expressions/ApplyObjectDesignatorWithRecFieldObj2.result b/core/codegen/src/test/resources/complex_expressions/ApplyObjectDesignatorWithRecFieldObj2.result new file mode 100644 index 0000000000..2b54f7dc66 --- /dev/null +++ b/core/codegen/src/test/resources/complex_expressions/ApplyObjectDesignatorWithRecFieldObj2.result @@ -0,0 +1,119 @@ +import org.overture.codegen.runtime.*; + +import java.util.*; + + +public class Entry { + public Entry() { + } + + public static Object Run() { + A a = new A(SeqUtil.seq(new B(new C(new Entry())))); + + return op(Utils.clone(a)); + } + + public static Number op(final A a) { + return ((B) a.bs.get(Utils.index(1L))).c.e.getConst(); + } + + public Number getConst() { + return 5L; + } + + public String toString() { + return "Entry{}"; + } + + public static class A implements Record { + public VDMSeq bs; + + public A(final VDMSeq _bs) { + bs = (_bs != null) ? Utils.clone(_bs) : null; + } + + public boolean equals(final Object obj) { + if (!(obj instanceof A)) { + return false; + } + + A other = ((A) obj); + + return Utils.equals(bs, other.bs); + } + + public int hashCode() { + return Utils.hashCode(bs); + } + + public A clone() { + return new A(bs); + } + + public String toString() { + return "mk_Entry`A" + Utils.formatFields(bs); + } + } + + public static class B implements Record { + public C c; + + public B(final C _c) { + c = (_c != null) ? Utils.clone(_c) : null; + } + + public boolean equals(final Object obj) { + if (!(obj instanceof B)) { + return false; + } + + B other = ((B) obj); + + return Utils.equals(c, other.c); + } + + public int hashCode() { + return Utils.hashCode(c); + } + + public B clone() { + return new B(c); + } + + public String toString() { + return "mk_Entry`B" + Utils.formatFields(c); + } + } + + public static class C implements Record { + public Entry e; + + public C(final Entry _e) { + e = (_e != null) ? _e : null; + } + + public boolean equals(final Object obj) { + if (!(obj instanceof C)) { + return false; + } + + C other = ((C) obj); + + return Utils.equals(e, other.e); + } + + public int hashCode() { + return Utils.hashCode(e); + } + + public C clone() { + return new C(e); + } + + public String toString() { + return "mk_Entry`C" + Utils.formatFields(e); + } + } +} + +########## diff --git a/core/codegen/src/test/resources/complex_expressions/FieldDesignatorOfRecObj b/core/codegen/src/test/resources/complex_expressions/FieldDesignatorOfRecObj new file mode 100644 index 0000000000..8bcfd1f04f --- /dev/null +++ b/core/codegen/src/test/resources/complex_expressions/FieldDesignatorOfRecObj @@ -0,0 +1,19 @@ +class Entry + +types + +public R :: + e : [Entry]; + +operations + +public static Run : () ==> ? +Run () == op1(mk_R(new Entry())); + +public static op1 : R ==> nat +op1(r) == r.e.getConst(); + +public getConst: () ==> nat +getConst() == return 1; + +end Entry \ No newline at end of file diff --git a/core/codegen/src/test/resources/complex_expressions/FieldDesignatorOfRecObj.result b/core/codegen/src/test/resources/complex_expressions/FieldDesignatorOfRecObj.result new file mode 100644 index 0000000000..b9f66a55a9 --- /dev/null +++ b/core/codegen/src/test/resources/complex_expressions/FieldDesignatorOfRecObj.result @@ -0,0 +1,57 @@ +import org.overture.codegen.runtime.*; + +import java.util.*; + + +public class Entry { + public Entry() { + } + + public static Object Run() { + return op1(new R(new Entry())); + } + + public static Number op1(final R r) { + return r.e.getConst(); + } + + public Number getConst() { + return 1L; + } + + public String toString() { + return "Entry{}"; + } + + public static class R implements Record { + public Entry e; + + public R(final Entry _e) { + e = (_e != null) ? _e : null; + } + + public boolean equals(final Object obj) { + if (!(obj instanceof R)) { + return false; + } + + R other = ((R) obj); + + return Utils.equals(e, other.e); + } + + public int hashCode() { + return Utils.hashCode(e); + } + + public R clone() { + return new R(e); + } + + public String toString() { + return "mk_Entry`R" + Utils.formatFields(e); + } + } +} + +########## diff --git a/core/codegen/src/test/resources/complex_expressions/FieldDesignatorOfRecObjChainOfThree b/core/codegen/src/test/resources/complex_expressions/FieldDesignatorOfRecObjChainOfThree new file mode 100644 index 0000000000..c4564f56d6 --- /dev/null +++ b/core/codegen/src/test/resources/complex_expressions/FieldDesignatorOfRecObjChainOfThree @@ -0,0 +1,25 @@ +class Entry + +types + +public R1 :: + r2 : R2; + +public R2 :: + r3 : R3; + +public R3 :: + e : [Entry]; + +operations + +public static Run : () ==> ? +Run () == op1(mk_R1(mk_R2(mk_R3(new Entry())))); + +public static op1 : R1 ==> nat +op1(r1) == r1.r2.r3.e.getConst(); + +public getConst: () ==> nat +getConst() == return 3; + +end Entry \ No newline at end of file diff --git a/core/codegen/src/test/resources/complex_expressions/FieldDesignatorOfRecObjChainOfThree.result b/core/codegen/src/test/resources/complex_expressions/FieldDesignatorOfRecObjChainOfThree.result new file mode 100644 index 0000000000..4602a3070d --- /dev/null +++ b/core/codegen/src/test/resources/complex_expressions/FieldDesignatorOfRecObjChainOfThree.result @@ -0,0 +1,117 @@ +import org.overture.codegen.runtime.*; + +import java.util.*; + + +public class Entry { + public Entry() { + } + + public static Object Run() { + return op1(new R1(new R2(new R3(new Entry())))); + } + + public static Number op1(final R1 r1) { + return r1.r2.r3.e.getConst(); + } + + public Number getConst() { + return 3L; + } + + public String toString() { + return "Entry{}"; + } + + public static class R1 implements Record { + public R2 r2; + + public R1(final R2 _r2) { + r2 = (_r2 != null) ? Utils.clone(_r2) : null; + } + + public boolean equals(final Object obj) { + if (!(obj instanceof R1)) { + return false; + } + + R1 other = ((R1) obj); + + return Utils.equals(r2, other.r2); + } + + public int hashCode() { + return Utils.hashCode(r2); + } + + public R1 clone() { + return new R1(r2); + } + + public String toString() { + return "mk_Entry`R1" + Utils.formatFields(r2); + } + } + + public static class R2 implements Record { + public R3 r3; + + public R2(final R3 _r3) { + r3 = (_r3 != null) ? Utils.clone(_r3) : null; + } + + public boolean equals(final Object obj) { + if (!(obj instanceof R2)) { + return false; + } + + R2 other = ((R2) obj); + + return Utils.equals(r3, other.r3); + } + + public int hashCode() { + return Utils.hashCode(r3); + } + + public R2 clone() { + return new R2(r3); + } + + public String toString() { + return "mk_Entry`R2" + Utils.formatFields(r3); + } + } + + public static class R3 implements Record { + public Entry e; + + public R3(final Entry _e) { + e = (_e != null) ? _e : null; + } + + public boolean equals(final Object obj) { + if (!(obj instanceof R3)) { + return false; + } + + R3 other = ((R3) obj); + + return Utils.equals(e, other.e); + } + + public int hashCode() { + return Utils.hashCode(e); + } + + public R3 clone() { + return new R3(e); + } + + public String toString() { + return "mk_Entry`R3" + Utils.formatFields(e); + } + } +} + +########## diff --git a/core/codegen/src/test/resources/complex_expressions/FieldDesignatorOfRecObjChainOfTwo b/core/codegen/src/test/resources/complex_expressions/FieldDesignatorOfRecObjChainOfTwo new file mode 100644 index 0000000000..bd273da9d3 --- /dev/null +++ b/core/codegen/src/test/resources/complex_expressions/FieldDesignatorOfRecObjChainOfTwo @@ -0,0 +1,22 @@ +class Entry + +types + +public R1 :: + r2 : R2; + +public R2 :: + e : [Entry]; + +operations + +public static Run : () ==> ? +Run () == op1(mk_R1(mk_R2(new Entry()))); + +public static op1 : R1 ==> nat +op1(r1) == r1.r2.e.getConst(); + +public getConst: () ==> nat +getConst() == return 2; + +end Entry \ No newline at end of file diff --git a/core/codegen/src/test/resources/complex_expressions/FieldDesignatorOfRecObjChainOfTwo.result b/core/codegen/src/test/resources/complex_expressions/FieldDesignatorOfRecObjChainOfTwo.result new file mode 100644 index 0000000000..6960632d56 --- /dev/null +++ b/core/codegen/src/test/resources/complex_expressions/FieldDesignatorOfRecObjChainOfTwo.result @@ -0,0 +1,87 @@ +import org.overture.codegen.runtime.*; + +import java.util.*; + + +public class Entry { + public Entry() { + } + + public static Object Run() { + return op1(new R1(new R2(new Entry()))); + } + + public static Number op1(final R1 r1) { + return r1.r2.e.getConst(); + } + + public Number getConst() { + return 2L; + } + + public String toString() { + return "Entry{}"; + } + + public static class R1 implements Record { + public R2 r2; + + public R1(final R2 _r2) { + r2 = (_r2 != null) ? Utils.clone(_r2) : null; + } + + public boolean equals(final Object obj) { + if (!(obj instanceof R1)) { + return false; + } + + R1 other = ((R1) obj); + + return Utils.equals(r2, other.r2); + } + + public int hashCode() { + return Utils.hashCode(r2); + } + + public R1 clone() { + return new R1(r2); + } + + public String toString() { + return "mk_Entry`R1" + Utils.formatFields(r2); + } + } + + public static class R2 implements Record { + public Entry e; + + public R2(final Entry _e) { + e = (_e != null) ? _e : null; + } + + public boolean equals(final Object obj) { + if (!(obj instanceof R2)) { + return false; + } + + R2 other = ((R2) obj); + + return Utils.equals(e, other.e); + } + + public int hashCode() { + return Utils.hashCode(e); + } + + public R2 clone() { + return new R2(e); + } + + public String toString() { + return "mk_Entry`R2" + Utils.formatFields(e); + } + } +} + +########## diff --git a/core/codegen/src/test/resources/function_value_specs/LambdaWithLet b/core/codegen/src/test/resources/function_value_specs/LambdaWithLet new file mode 100644 index 0000000000..ca2c0009af --- /dev/null +++ b/core/codegen/src/test/resources/function_value_specs/LambdaWithLet @@ -0,0 +1,11 @@ +class Entry + +operations + +public static Run : () ==> ? +Run () == +let f = (lambda x : nat & let y = x in y) +in + return f(2); + +end Entry diff --git a/core/codegen/src/test/resources/function_value_specs/LambdaWithLet.result b/core/codegen/src/test/resources/function_value_specs/LambdaWithLet.result new file mode 100644 index 0000000000..271b9aa07d --- /dev/null +++ b/core/codegen/src/test/resources/function_value_specs/LambdaWithLet.result @@ -0,0 +1,34 @@ +import org.overture.codegen.runtime.*; + +import java.util.*; + + +public class Entry { + public Entry() { + } + + public static Object Run() { + Func_1 f = new Func_1() { + public Number eval(final Number x) { + { + Number y = x; + + return y; + } + } + }; + + return f.eval(2L); + } + + public String toString() { + return "Entry{}"; + } +} + +########## +public interface Func_1 { + public abstract T_2 eval(final T_1 param_1); +} + +########## diff --git a/core/codegen/src/test/resources/pattern_specs/CasesStmOpCallExp b/core/codegen/src/test/resources/pattern_specs/CasesStmOpCallExp new file mode 100644 index 0000000000..013bce55fc --- /dev/null +++ b/core/codegen/src/test/resources/pattern_specs/CasesStmOpCallExp @@ -0,0 +1,24 @@ +class Entry + +types + +public A :: a : int; +public B :: b : int; + +operations + +public static Run : () ==> ? +Run () == +( + cases rec(): + mk_A(9) -> return 11, + mk_B(9) -> return 111, + mk_B(10) -> return 1111 + end; + return -1; +); + +public static rec : () ==> A|B +rec () == return mk_B(10); + +end Entry \ No newline at end of file diff --git a/core/codegen/src/test/resources/pattern_specs/CasesStmOpCallExp.result b/core/codegen/src/test/resources/pattern_specs/CasesStmOpCallExp.result new file mode 100644 index 0000000000..2c42a7d58e --- /dev/null +++ b/core/codegen/src/test/resources/pattern_specs/CasesStmOpCallExp.result @@ -0,0 +1,126 @@ +import org.overture.codegen.runtime.*; + +import java.util.*; + + +public class Entry { + public Entry() { + } + + public static Object Run() { + Object casesExp_1 = rec(); + Boolean success_1 = true; + + if (casesExp_1 instanceof A) { + A recordPattern_1 = ((A) casesExp_1); + Number intPattern_1 = recordPattern_1.a; + success_1 = Utils.equals(intPattern_1, 9L); + } else { + success_1 = false; + } + + if (!(success_1)) { + if (casesExp_1 instanceof B) { + B recordPattern_2 = ((B) casesExp_1); + success_1 = true; + + Number intPattern_2 = recordPattern_2.b; + success_1 = Utils.equals(intPattern_2, 9L); + } else { + success_1 = false; + } + + if (!(success_1)) { + if (casesExp_1 instanceof B) { + B recordPattern_3 = ((B) casesExp_1); + success_1 = true; + + Number intPattern_3 = recordPattern_3.b; + success_1 = Utils.equals(intPattern_3, 10L); + } else { + success_1 = false; + } + + if (success_1) { + return 1111L; + } + } else { + return 111L; + } + } else { + return 11L; + } + + return -1L; + } + + public static Object rec() { + return new B(10L); + } + + public String toString() { + return "Entry{}"; + } + + public static class A implements Record { + public Number a; + + public A(final Number _a) { + a = _a; + } + + public boolean equals(final Object obj) { + if (!(obj instanceof A)) { + return false; + } + + A other = ((A) obj); + + return Utils.equals(a, other.a); + } + + public int hashCode() { + return Utils.hashCode(a); + } + + public A clone() { + return new A(a); + } + + public String toString() { + return "mk_Entry`A" + Utils.formatFields(a); + } + } + + public static class B implements Record { + public Number b; + + public B(final Number _b) { + b = _b; + } + + public boolean equals(final Object obj) { + if (!(obj instanceof B)) { + return false; + } + + B other = ((B) obj); + + return Utils.equals(b, other.b); + } + + public int hashCode() { + return Utils.hashCode(b); + } + + public B clone() { + return new B(b); + } + + public String toString() { + return "mk_Entry`B" + Utils.formatFields(b); + } + } +} + +########## diff --git a/core/codegen/src/test/resources/pattern_specs/LetBeStRecPattern b/core/codegen/src/test/resources/pattern_specs/LetBeStRecPattern new file mode 100644 index 0000000000..d93e3a5235 --- /dev/null +++ b/core/codegen/src/test/resources/pattern_specs/LetBeStRecPattern @@ -0,0 +1,19 @@ +class Entry + +values + +xs : set of (nat | A) = {1,2,3,4,mk_A(5), 6, 7, 8} + +types + +A :: a : int; + +operations + +public static Run : () ==> ? +Run () == +let mk_A(a) in set xs be st a = 5 +in + return a; + +end Entry \ No newline at end of file diff --git a/core/codegen/src/test/resources/pattern_specs/LetBeStRecPattern.result b/core/codegen/src/test/resources/pattern_specs/LetBeStRecPattern.result new file mode 100644 index 0000000000..a20718a289 --- /dev/null +++ b/core/codegen/src/test/resources/pattern_specs/LetBeStRecPattern.result @@ -0,0 +1,79 @@ +import org.overture.codegen.runtime.*; + +import java.util.*; + + +public class Entry { + private static final VDMSet xs = SetUtil.set(1L, 2L, 3L, 4L, new A(5L), 6L, + 7L, 8L); + + public Entry() { + } + + public static Object Run() { + Object recordPattern_1 = null; + Boolean success_1 = false; + VDMSet set_1 = Utils.clone(xs); + Number a = null; + + for (Iterator iterator_1 = set_1.iterator(); + iterator_1.hasNext() && !(success_1);) { + recordPattern_1 = ((Object) iterator_1.next()); + + if (recordPattern_1 instanceof A) { + success_1 = true; + a = ((A) recordPattern_1).a; + } else { + success_1 = false; + } + + if (!(success_1)) { + continue; + } + + success_1 = Utils.equals(a, 5L); + } + + if (!(success_1)) { + throw new RuntimeException("Let Be St found no applicable bindings"); + } + + return a; + } + + public String toString() { + return "Entry{" + "xs = " + Utils.toString(xs) + "}"; + } + + private static class A implements Record { + public Number a; + + public A(final Number _a) { + a = _a; + } + + public boolean equals(final Object obj) { + if (!(obj instanceof A)) { + return false; + } + + A other = ((A) obj); + + return Utils.equals(a, other.a); + } + + public int hashCode() { + return Utils.hashCode(a); + } + + public A clone() { + return new A(a); + } + + public String toString() { + return "mk_Entry`A" + Utils.formatFields(a); + } + } +} + +########## diff --git a/core/codegen/src/test/resources/pre_post_specs/ImplicitFunc b/core/codegen/src/test/resources/pre_post_specs/ImplicitFunc new file mode 100644 index 0000000000..ed0708d9cf --- /dev/null +++ b/core/codegen/src/test/resources/pre_post_specs/ImplicitFunc @@ -0,0 +1,20 @@ +class Entry + +operations + +public static Run : () ==> (nat * nat) +Run () == +let b = not true +in + if b then + return doImpl(5, 7) + else + return mk_(7, 5); + +functions + +doImpl (left,right: nat) res: nat, res2 : nat +pre true +post left + right = res; + +end Entry \ No newline at end of file diff --git a/core/codegen/src/test/resources/pre_post_specs/ImplicitFunc.result b/core/codegen/src/test/resources/pre_post_specs/ImplicitFunc.result new file mode 100644 index 0000000000..700fb381da --- /dev/null +++ b/core/codegen/src/test/resources/pre_post_specs/ImplicitFunc.result @@ -0,0 +1,55 @@ +import org.overture.codegen.runtime.*; + +import java.util.*; + + +public class Entry { + public Entry() { + } + + public static Tuple Run() { + Boolean b = !true; + + if (b) { + return doImpl(5L, 7L); + } else { + return Tuple.mk_(7L, 5L); + } + } + + private static Tuple doImpl(final Number left, final Number right) { + if (!(pre_doImpl(left, right))) { + throw new RuntimeException("Precondition failure: pre_doImpl"); + } + + throw new UnsupportedOperationException(); + } + + private static Boolean pre_doImpl(final Number left, final Number right) { + return true; + } + + private static Boolean post_doImpl(final Number left, final Number right, + final Tuple tuplePattern_1) { + Boolean success_1 = tuplePattern_1.compatible(Number.class, Number.class); + Number res = null; + Number res2 = null; + + if (success_1) { + res = ((Number) tuplePattern_1.get(0)); + res2 = ((Number) tuplePattern_1.get(1)); + } + + if (!(success_1)) { + throw new RuntimeException("Tuple pattern match failed"); + } + + return Utils.equals(left.longValue() + right.longValue(), res); + } + + public String toString() { + return "Entry{}"; + } +} + +########## diff --git a/core/codegen/src/test/resources/pre_post_specs/ImplicitOp b/core/codegen/src/test/resources/pre_post_specs/ImplicitOp new file mode 100644 index 0000000000..65f519ea46 --- /dev/null +++ b/core/codegen/src/test/resources/pre_post_specs/ImplicitOp @@ -0,0 +1,18 @@ +class Entry + +operations + +public static Run : () ==> ? +Run () == +let b = not true +in + if b then + return addImpl(5, 7) + else + return 5 + 7; + +static addImpl (left,right: nat) res: nat +pre true +post left + right = res; + +end Entry \ No newline at end of file diff --git a/core/codegen/src/test/resources/pre_post_specs/ImplicitOp.result b/core/codegen/src/test/resources/pre_post_specs/ImplicitOp.result new file mode 100644 index 0000000000..ce6bd3e7d4 --- /dev/null +++ b/core/codegen/src/test/resources/pre_post_specs/ImplicitOp.result @@ -0,0 +1,42 @@ +import org.overture.codegen.runtime.*; + +import java.util.*; + + +public class Entry { + public Entry() { + } + + public static Object Run() { + Boolean b = !true; + + if (b) { + return addImpl(5L, 7L); + } else { + return 5L + 7L; + } + } + + private static Number addImpl(final Number left, final Number right) { + if (!(pre_addImpl(left, right))) { + throw new RuntimeException("Precondition failure: pre_addImpl"); + } + + throw new UnsupportedOperationException(); + } + + private static Boolean pre_addImpl(final Number left, final Number right) { + return true; + } + + private static Boolean post_addImpl(final Number left, final Number right, + final Number res, final VDMMap self) { + return Utils.equals(left.longValue() + right.longValue(), res); + } + + public String toString() { + return "Entry{}"; + } +} + +########## diff --git a/core/codegen/src/test/resources/union_type_specs/LetBeStRecElem b/core/codegen/src/test/resources/union_type_specs/LetBeStRecElem new file mode 100644 index 0000000000..83104f5430 --- /dev/null +++ b/core/codegen/src/test/resources/union_type_specs/LetBeStRecElem @@ -0,0 +1,19 @@ +class Entry + +values + +xs : set of (nat | A) = {mk_A(5)} + +types + +A :: a : int; + +operations + +public static Run : () ==> ? +Run () == +let r in set xs be st r.a = 5 +in + return r.a; + +end Entry \ No newline at end of file diff --git a/core/codegen/src/test/resources/union_type_specs/LetBeStRecElem.result b/core/codegen/src/test/resources/union_type_specs/LetBeStRecElem.result new file mode 100644 index 0000000000..4d169c68e9 --- /dev/null +++ b/core/codegen/src/test/resources/union_type_specs/LetBeStRecElem.result @@ -0,0 +1,82 @@ +import org.overture.codegen.runtime.*; + +import java.util.*; + + +public class Entry { + private static final VDMSet xs = SetUtil.set(new A(5L)); + + public Entry() { + } + + public static Object Run() { + Object r = null; + Boolean success_1 = false; + VDMSet set_1 = Utils.clone(xs); + + for (Iterator iterator_1 = set_1.iterator(); + iterator_1.hasNext() && !(success_1);) { + r = ((Object) iterator_1.next()); + + Number apply_1 = null; + + if (r instanceof A) { + apply_1 = ((A) r).a; + } else { + throw new RuntimeException("Missing member: a"); + } + + success_1 = Utils.equals(apply_1, 5L); + } + + if (!(success_1)) { + throw new RuntimeException("Let Be St found no applicable bindings"); + } + + Number apply_2 = null; + + if (r instanceof A) { + apply_2 = ((A) r).a; + } else { + throw new RuntimeException("Missing member: a"); + } + + return apply_2; + } + + public String toString() { + return "Entry{" + "xs = " + Utils.toString(xs) + "}"; + } + + private static class A implements Record { + public Number a; + + public A(final Number _a) { + a = _a; + } + + public boolean equals(final Object obj) { + if (!(obj instanceof A)) { + return false; + } + + A other = ((A) obj); + + return Utils.equals(a, other.a); + } + + public int hashCode() { + return Utils.hashCode(a); + } + + public A clone() { + return new A(a); + } + + public String toString() { + return "mk_Entry`A" + Utils.formatFields(a); + } + } +} + +########## diff --git a/core/combinatorialtesting/ctruntime/pom.xml b/core/combinatorialtesting/ctruntime/pom.xml index b463dc16cf..c298804a73 100644 --- a/core/combinatorialtesting/ctruntime/pom.xml +++ b/core/combinatorialtesting/ctruntime/pom.xml @@ -4,7 +4,7 @@ org.overturetool.core combinatorialtesting - 2.2.0 + 2.2.2 ../pom.xml diff --git a/core/combinatorialtesting/ctruntime/src/main/java/org/overture/ct/ctruntime/TraceInterpreter.java b/core/combinatorialtesting/ctruntime/src/main/java/org/overture/ct/ctruntime/TraceInterpreter.java index 84b23aceec..e331a479bb 100644 --- a/core/combinatorialtesting/ctruntime/src/main/java/org/overture/ct/ctruntime/TraceInterpreter.java +++ b/core/combinatorialtesting/ctruntime/src/main/java/org/overture/ct/ctruntime/TraceInterpreter.java @@ -31,8 +31,10 @@ import org.overture.ast.definitions.PDefinition; import org.overture.ast.definitions.SClassDefinition; import org.overture.ast.modules.AModuleModules; +import org.overture.ast.node.INode; import org.overture.ast.statements.PStm; import org.overture.ast.typechecker.NameScope; +import org.overture.ast.util.modules.CombinedDefaultModule; import org.overture.config.Settings; import org.overture.ct.utils.TraceXmlWrapper; import org.overture.interpreter.runtime.ClassInterpreter; @@ -48,6 +50,7 @@ import org.overture.interpreter.traces.Verdict; import org.overture.typechecker.Environment; import org.overture.typechecker.FlatEnvironment; +import org.overture.typechecker.ModuleEnvironment; import org.overture.typechecker.PrivateClassEnvironment; import org.overture.typechecker.assistant.ITypeCheckerAssistantFactory; @@ -177,7 +180,7 @@ private void processTraces(List definitions, String className, } infoCompleted(); - + if (DEBUG) { System.out.println("Completed"); @@ -255,13 +258,38 @@ private void evaluateTests(String className, TraceXmlWrapper storage, tests = ctxt.assistantFactory.createANamedTraceDefinitionAssistant().getTests(mtd, ctxt, subset, traceReductionType, seed); int size = tests.size(); - + infoProcessingTrace(className, mtd.getName().getName(), size); if (storage != null) { storage.StartTrace(mtd.getName().getName(), mtd.getLocation().getFile().getName(), mtd.getLocation().getStartLine(), mtd.getLocation().getStartPos(), size, new Float(subset), TraceReductionType.valueOf(traceReductionType.toString()), new Long(seed)); } + INode traceContainer = null; + Environment rootEnv = null; + if (interpreter instanceof ClassInterpreter) + { + traceContainer = mtd.getClassDefinition(); + rootEnv = new PrivateClassEnvironment(interpreter.getAssistantFactory(), mtd.getClassDefinition(), interpreter.getGlobalEnvironment()); + ; + } else + { + traceContainer = mtd.parent(); + if(((AModuleModules)traceContainer).getIsFlat()) + { + //search for the combined module + for(AModuleModules m : ((ModuleInterpreter)interpreter).modules) + { + if(m instanceof CombinedDefaultModule) + { + traceContainer = m; + break; + } + } + } + rootEnv = new ModuleEnvironment(interpreter.getAssistantFactory(), (AModuleModules) traceContainer); + } + int n = 1; int faildCount = 0; @@ -269,7 +297,7 @@ private void evaluateTests(String className, TraceXmlWrapper storage, int skippedCount = 0; StopWatch.set(); - + for (CallSequence test : tests) { StopWatch.stop("Getting test"); @@ -283,7 +311,13 @@ private void evaluateTests(String className, TraceXmlWrapper storage, boolean typeOk = false; try { - typeCheck(mtd.getClassDefinition(), interpreter, test); + if (interpreter instanceof ClassInterpreter) + { + typeCheck(traceContainer, interpreter, test, rootEnv); + } else + { + typeCheck(traceContainer, interpreter, test, rootEnv); + } typeOk = true; } catch (Exception e) { @@ -341,8 +375,7 @@ private void evaluateTests(String className, TraceXmlWrapper storage, { storage.AddSkippedResult(new Integer(n).toString()); } - } - else + } else { if (verdict == Verdict.ERROR) @@ -398,28 +431,34 @@ private void evaluateTests(String className, TraceXmlWrapper storage, * @throws AnalysisException * @throws Exception */ - protected void typeCheck(SClassDefinition classdef, - Interpreter interpreter, CallSequence test) - throws AnalysisException, Exception + protected void typeCheck(INode classdef, Interpreter interpreter, + CallSequence test, Environment outer) throws AnalysisException, + Exception { - Environment env = null; + FlatEnvironment env = null; - if (interpreter instanceof ClassInterpreter) + if (classdef instanceof SClassDefinition) { - env = new FlatEnvironment(interpreter.getAssistantFactory(), classdef.apply(interpreter.getAssistantFactory().getSelfDefinitionFinder()), new PrivateClassEnvironment(interpreter.getAssistantFactory(), classdef, interpreter.getGlobalEnvironment())); + + env = new FlatEnvironment(interpreter.getAssistantFactory(), classdef.apply(interpreter.getAssistantFactory().getSelfDefinitionFinder()), outer); } else { - env = new FlatEnvironment(interpreter.getAssistantFactory(), new Vector(), interpreter.getGlobalEnvironment()); + + env = new FlatEnvironment(interpreter.getAssistantFactory(), new Vector(), outer); } - for (PStm statement : test) + for (int i = 0; i < test.size(); i++) { + PStm statement = test.get(i); + if (statement instanceof TraceVariableStatement) { ((TraceVariableStatement) statement).typeCheck(env, NameScope.NAMESANDSTATE); } else { - interpreter.typeCheck(statement.clone(), env); + statement = statement.clone(); + test.set(i, statement); + interpreter.typeCheck(statement, env); } } diff --git a/core/combinatorialtesting/ctruntime/src/main/java/org/overture/ct/ctruntime/utils/CtHelper.java b/core/combinatorialtesting/ctruntime/src/main/java/org/overture/ct/ctruntime/utils/CtHelper.java index 12d3c59170..5eea7460ab 100644 --- a/core/combinatorialtesting/ctruntime/src/main/java/org/overture/ct/ctruntime/utils/CtHelper.java +++ b/core/combinatorialtesting/ctruntime/src/main/java/org/overture/ct/ctruntime/utils/CtHelper.java @@ -28,47 +28,85 @@ import java.io.OutputStream; import java.net.ServerSocket; import java.net.Socket; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.Vector; + +import org.overture.ast.lex.Dialect; +import org.overture.config.Release; public class CtHelper { - public String[] buildArgs(final String traceName, final int port, - File traceFolder, File specfile) - + public static class CtTestData { - // Passing 'null' indicates no trace reduction - return buildArgs(traceName, port, traceFolder, specfile, null); + public final String traceName; + public int port; + public final File traceFolder; + public final List specFiles= new Vector<>(); + public TraceReductionInfo reduction; + + public CtTestData(String traceName, File traceFolder, + File specFile, TraceReductionInfo second) + { + this.traceName = traceName; + this.traceFolder = traceFolder; + this.specFiles.add( specFile); + this.reduction = second; + + } + public CtTestData(String traceName, File traceFolder, + List specFiles, TraceReductionInfo second) + { + this.traceName = traceName; + this.traceFolder = traceFolder; + this.specFiles.addAll( specFiles); + this.reduction = second; + + } } - public String[] buildArgs(final String traceName, final int port, - File traceFolder, File specfile, TraceReductionInfo info) + public String[] buildArgs(Dialect dialect, Release release, CtTestData data) { - if (info == null) + if (data.reduction == null) { - info = new TraceReductionInfo(); + data.reduction= new TraceReductionInfo(); } + + String[] args = new String[] { "-h", "localhost", "-p", - port + "", + data.port + "", "-k", "whatever", "-e", - "DEFAULT", - "-vdmsl", + dialect == Dialect.VDM_SL ? "DEFAULT" : "Entry", + dialect.getArgstring(), "-r", "vdm10", "-t", - traceName, + data.traceName, "-tracefolder", - traceFolder.toURI().toASCIIString(), - specfile.toURI().toASCIIString(), + data.traceFolder.toURI().toASCIIString(), + // spec files here "-traceReduction", - "{" + info.getSubset() + "," - + info.getReductionType().toString() + "," - + info.getSeed() + "}" }; - return args; + "{" + data.reduction.getSubset() + "," + + data.reduction.getReductionType().toString() + "," + + data.reduction.getSeed() + "}" }; + + List argArray = new Vector(Arrays.asList(args)); + + + for (Iterator itr = data.specFiles.iterator(); itr.hasNext();) + { + argArray.add(argArray.size()-2, itr.next().toURI().toASCIIString()); + + } + + return argArray.toArray(new String[argArray.size()]); } public Thread consCtClientThread(final ServerSocket socket, final Data data) diff --git a/core/combinatorialtesting/ctruntime/src/test/java/org/overture/ct/ctruntime/tests/CtMultiFileNoReductionSlTestCase.java b/core/combinatorialtesting/ctruntime/src/test/java/org/overture/ct/ctruntime/tests/CtMultiFileNoReductionSlTestCase.java new file mode 100644 index 0000000000..8381d1cc9d --- /dev/null +++ b/core/combinatorialtesting/ctruntime/src/test/java/org/overture/ct/ctruntime/tests/CtMultiFileNoReductionSlTestCase.java @@ -0,0 +1,84 @@ +/* + * #%~ + * Combinatorial Testing Runtime + * %% + * Copyright (C) 2008 - 2014 Overture + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * . + * #~% + */ +package org.overture.ct.ctruntime.tests; + +import java.io.File; +import java.util.Collection; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; +import org.overture.ast.lex.Dialect; +import org.overture.config.Release; +import org.overture.config.Settings; +import org.overture.ct.ctruntime.tests.util.TestSourceFinder; +import org.overture.ct.ctruntime.utils.CtHelper.CtTestData; + +@RunWith(value = Parameterized.class) +public class CtMultiFileNoReductionSlTestCase extends CtTestCaseBase +{ + @BeforeClass + public static void s() + { + System.out.println(); + } + + @AfterClass + public static void e() + { + System.out.println(); + } +// @Rule +// public TestRule benchmarkRun = new BenchmarkRule(); + + private static String TEST_NAME = "CT no reduction SL tests"; + private static final String ROOT = "src/test/resources/multi_no_reduction_sl_specs"; + + @Parameters(name = "{0}") + public static Collection getData() + { + Collection tests = TestSourceFinder.createTestMultiFileFile(Dialect.VDM_SL, TEST_NAME, ROOT, "", ""); + + return tests; + } + + public CtMultiFileNoReductionSlTestCase(String name, File file, File traceFolder, + CtTestData args) + { + super(file, traceFolder, args); + } + + @Override + public void setUp() throws Exception + { + Settings.dialect = Dialect.VDM_SL; + Settings.release = Release.VDM_10; + } + + @Override + protected String getPropertyId() + { + return "sl.multi.no"; + } +} diff --git a/core/combinatorialtesting/ctruntime/src/test/java/org/overture/ct/ctruntime/tests/CtNoReductionPpTestCase.java b/core/combinatorialtesting/ctruntime/src/test/java/org/overture/ct/ctruntime/tests/CtNoReductionPpTestCase.java new file mode 100644 index 0000000000..2f9753dc11 --- /dev/null +++ b/core/combinatorialtesting/ctruntime/src/test/java/org/overture/ct/ctruntime/tests/CtNoReductionPpTestCase.java @@ -0,0 +1,48 @@ +package org.overture.ct.ctruntime.tests; + +import java.io.File; +import java.util.Collection; + +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; +import org.overture.ast.lex.Dialect; +import org.overture.config.Release; +import org.overture.config.Settings; +import org.overture.ct.ctruntime.tests.util.TestSourceFinder; +import org.overture.ct.ctruntime.utils.CtHelper.CtTestData; + +@RunWith(value = Parameterized.class) +public class CtNoReductionPpTestCase extends CtTestCaseBase +{ + private static String TEST_NAME = "CT no reduction PP tests"; + private static final String ROOT = "src/test/resources/no_reduction_pp_specs"; + + @Parameters(name = "{0}") + public static Collection getData() + { + Collection tests = TestSourceFinder.createTestCompleteFile(Dialect.VDM_PP, TEST_NAME, ROOT, "", ""); + + return tests; + } + + public CtNoReductionPpTestCase(String name, File file, File traceFolder, + CtTestData args) + { + super(file, traceFolder, args); + } + + @Override + public void setUp() throws Exception + { + Settings.dialect = Dialect.VDM_PP; + Settings.release = Release.VDM_10; + } + + @Override + protected String getPropertyId() + { + return "pp.no"; + } + +} diff --git a/core/combinatorialtesting/ctruntime/src/test/java/org/overture/ct/ctruntime/tests/CtNoReductionTestCase.java b/core/combinatorialtesting/ctruntime/src/test/java/org/overture/ct/ctruntime/tests/CtNoReductionSlTestCase.java similarity index 62% rename from core/combinatorialtesting/ctruntime/src/test/java/org/overture/ct/ctruntime/tests/CtNoReductionTestCase.java rename to core/combinatorialtesting/ctruntime/src/test/java/org/overture/ct/ctruntime/tests/CtNoReductionSlTestCase.java index 1a22d3e47a..43692a6274 100644 --- a/core/combinatorialtesting/ctruntime/src/test/java/org/overture/ct/ctruntime/tests/CtNoReductionTestCase.java +++ b/core/combinatorialtesting/ctruntime/src/test/java/org/overture/ct/ctruntime/tests/CtNoReductionSlTestCase.java @@ -24,33 +24,61 @@ import java.io.File; import java.util.Collection; +import org.junit.AfterClass; +import org.junit.BeforeClass; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; import org.overture.ast.lex.Dialect; +import org.overture.config.Release; +import org.overture.config.Settings; import org.overture.ct.ctruntime.tests.util.TestSourceFinder; -import org.overture.test.framework.Properties; +import org.overture.ct.ctruntime.utils.CtHelper.CtTestData; @RunWith(value = Parameterized.class) -public class CtNoReductionTestCase extends CtTestCaseBase +public class CtNoReductionSlTestCase extends CtTestCaseBase { - private static String TEST_NAME = "CT tests"; + @BeforeClass + public static void s() + { + System.out.println(); + } + + @AfterClass + public static void e() + { + System.out.println(); + } +// @Rule +// public TestRule benchmarkRun = new BenchmarkRule(); + + private static String TEST_NAME = "CT no reduction SL tests"; private static final String ROOT = "src/test/resources/no_reduction_sl_specs"; @Parameters(name = "{0}") public static Collection getData() { - Properties.recordTestResults = false; - - Collection tests = TestSourceFinder.createTestCompleteFile(Dialect.VDM_PP, TEST_NAME, ROOT, "", ""); + Collection tests = TestSourceFinder.createTestCompleteFile(Dialect.VDM_SL, TEST_NAME, ROOT, "", ""); return tests; } - public CtNoReductionTestCase(String name, File file, File traceFolder, - String[] args) + public CtNoReductionSlTestCase(String name, File file, File traceFolder, + CtTestData args) { super(file, traceFolder, args); } + @Override + public void setUp() throws Exception + { + Settings.dialect = Dialect.VDM_SL; + Settings.release = Release.VDM_10; + } + + @Override + protected String getPropertyId() + { + return "sl.no"; + } } diff --git a/core/combinatorialtesting/ctruntime/src/test/java/org/overture/ct/ctruntime/tests/CtRandomReductionTestCase.java b/core/combinatorialtesting/ctruntime/src/test/java/org/overture/ct/ctruntime/tests/CtRandomReductionSlTestCase.java similarity index 87% rename from core/combinatorialtesting/ctruntime/src/test/java/org/overture/ct/ctruntime/tests/CtRandomReductionTestCase.java rename to core/combinatorialtesting/ctruntime/src/test/java/org/overture/ct/ctruntime/tests/CtRandomReductionSlTestCase.java index f1f60ffa4c..6d56c16b8b 100644 --- a/core/combinatorialtesting/ctruntime/src/test/java/org/overture/ct/ctruntime/tests/CtRandomReductionTestCase.java +++ b/core/combinatorialtesting/ctruntime/src/test/java/org/overture/ct/ctruntime/tests/CtRandomReductionSlTestCase.java @@ -29,14 +29,16 @@ import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; -import org.overture.ct.ctruntime.utils.CtHelper; +import org.overture.ast.lex.Dialect; +import org.overture.config.Release; +import org.overture.config.Settings; +import org.overture.ct.ctruntime.utils.CtHelper.CtTestData; import org.overture.ct.ctruntime.utils.TraceReductionInfo; import org.overture.interpreter.traces.TraceReductionType; import org.overture.interpreter.traces.util.Pair; -import org.overture.test.framework.Properties; @RunWith(value = Parameterized.class) -public class CtRandomReductionTestCase extends CtTestCaseBase +public class CtRandomReductionSlTestCase extends CtTestCaseBase { //The name of the test input folder private static final String TEST_INPUT_FOLDER = "random_reduction_sl_specs"; @@ -54,7 +56,6 @@ public class CtRandomReductionTestCase extends CtTestCaseBase @Parameters(name = "{0}") public static Collection getData() { - Properties.recordTestResults = false; List> testReductionInfo2 = new Vector>(); testReductionInfo2.add(new Pair("OpRepeatedTenTimes", new TraceReductionInfo(0.15F, TraceReductionType.RANDOM, SEED))); @@ -68,7 +69,7 @@ public static Collection getData() testReductionInfo2.add(new Pair("PaperCaseStudy", new TraceReductionInfo(0.01F, TraceReductionType.SHAPES_VARVALUES, SEED))); Collection tests = new Vector(); - CtHelper testHelper = new CtHelper(); + File root = new File(RESOURCES); @@ -82,20 +83,28 @@ public static Collection getData() traceName + " " + entry.second, specFile, traceFolder, - testHelper.buildArgs(TRACE_NAME, PORT, traceFolder, specFile, entry.second), + new CtTestData( TRACE_NAME, traceFolder, specFile, entry.second), entry.second }); } return tests; } - - public CtRandomReductionTestCase(String name, File file, File traceFolder, - String[] args, TraceReductionInfo reductionInfo) + + public CtRandomReductionSlTestCase(String name, File file, File traceFolder, + CtTestData args, TraceReductionInfo reductionInfo) { super(file, traceFolder, args); this.reductionInfo = reductionInfo; } + + @Override + public void setUp() throws Exception + { + Settings.dialect = Dialect.VDM_SL; + Settings.release = Release.VDM_10; + } + @Override protected File getResultFile(String filename) { @@ -120,4 +129,10 @@ private String consResultFileName(String filename, int index) + reductionInfo.toString().replace(',', '_').replace('.', '_') + filename.substring(index); } + + @Override + protected String getPropertyId() + { + return "sl.random"; + } } diff --git a/core/combinatorialtesting/ctruntime/src/test/java/org/overture/ct/ctruntime/tests/CtTestCaseBase.java b/core/combinatorialtesting/ctruntime/src/test/java/org/overture/ct/ctruntime/tests/CtTestCaseBase.java index f926d3c2d5..a620fb9d9c 100644 --- a/core/combinatorialtesting/ctruntime/src/test/java/org/overture/ct/ctruntime/tests/CtTestCaseBase.java +++ b/core/combinatorialtesting/ctruntime/src/test/java/org/overture/ct/ctruntime/tests/CtTestCaseBase.java @@ -36,10 +36,11 @@ import org.junit.Before; import org.junit.Test; import org.overture.ast.lex.Dialect; -import org.overture.config.Release; +import org.overture.ast.lex.LexLocation; import org.overture.config.Settings; import org.overture.ct.ctruntime.TraceRunnerMain; import org.overture.ct.ctruntime.utils.CtHelper; +import org.overture.ct.ctruntime.utils.CtHelper.CtTestData; import org.overture.ct.ctruntime.utils.Data; import org.overture.ct.ctruntime.utils.TraceResult; import org.overture.ct.ctruntime.utils.TraceResultReader; @@ -53,39 +54,46 @@ @SuppressWarnings("rawtypes") public abstract class CtTestCaseBase extends TestResourcesResultTestCase4 { + private static final String TESTS_CT_RUNTIME_PROPERTY_PREFIX = "tests.ctruntime.override."; + // The socket is used to communicate with the trace interpreter protected ServerSocket socket; protected static final int SOCKET_TIMEOUT = 0; - public static final int PORT = 8889; + private static final int FROM_PORT = 10000; + private static final int TO_PORT = 50000; // Used a fixed trace name for simplicity protected static final String TRACE_NAME = "T1"; public static final String TRACE_OUTPUT_FOLDER = "target/trace-output/"; - // protected CtTestHelper testHelper; - private String[] args; private File traceFolder; + private CtTestData testdata; + + public CtTestCaseBase() { super(); } - public CtTestCaseBase(File file, File traceFolder, String[] args) + public CtTestCaseBase(File file, File traceFolder, CtTestData args) { super(file); - this.args = args; + + this.testdata = args; this.traceFolder = traceFolder; } @Before - public void setUp() throws Exception + public void internalSetup() throws Exception { - Settings.dialect = Dialect.VDM_SL; - Settings.release = Release.VDM_10; + setUp(); + } + abstract public void setUp() throws Exception; + @After public void tearDown() throws Exception { @@ -108,56 +116,68 @@ public void test() throws Exception return; } - File actualResultsFile = computeActualResults(TRACE_NAME); - - if (Properties.recordTestResults) + try { - try - { - File resultFile = createResultFile(file.getAbsolutePath()); - resultFile.getParentFile().mkdirs(); + configureResultGeneration(); - // Overwrite result file - FileUtils.copyFile(actualResultsFile, resultFile); + File actualResultsFile = computeActualResults(TRACE_NAME); - } catch (Exception e) + if (Properties.recordTestResults) { - Assert.fail("The produced results could not be stored: " - + e.getMessage()); - } - } else - { - File resultFile = getResultFile(file.getAbsolutePath()); + try + { + File resultFile = createResultFile(file.getAbsolutePath()); + resultFile.getParentFile().mkdirs(); + + // Overwrite result file + FileUtils.copyFile(actualResultsFile, resultFile); + + } catch (Exception e) + { + Assert.fail("The produced results could not be stored: " + + e.getMessage()); + } + } else + { + File resultFile = getResultFile(file.getAbsolutePath()); - Assert.assertTrue("No result file found for test: " + file, resultFile.exists()); + TraceResultReader reader = new TraceResultReader(); + List actualResults = reader.read(actualResultsFile); - TraceResultReader reader = new TraceResultReader(); - List expectedResults = reader.read(resultFile); - List actualResults = reader.read(actualResultsFile); + Assert.assertTrue("No result file found for test: " + file + + "\n\n" + actualResults, resultFile.exists()); + List expectedResults = reader.read(resultFile); - Assert.assertTrue(expectedResults.size() == actualResults.size()); + Assert.assertTrue(expectedResults.size() == actualResults.size()); - int size = expectedResults.size(); + int size = expectedResults.size(); - for (int i = 0; i < size; i++) - { - TraceResult expected = expectedResults.get(i); - TraceResult actual = actualResults.get(i); - - Assert.assertTrue("Actual results differs from expected results for test: " - + file - + "\nExpected: " - + expectedResults - + "\n\nActual: " + actualResults, expected.equals(actual)); + for (int i = 0; i < size; i++) + { + TraceResult expected = expectedResults.get(i); + TraceResult actual = actualResults.get(i); + + Assert.assertTrue("Actual results differs from expected results for test: " + + file + + "\nExpected: " + + expectedResults + + "\n\nActual: " + actualResults, expected.equals(actual)); + } } + } finally + { + unconfigureResultGeneration(); } + } + @Override protected File createResultFile(String filename) { return new File(filename + ".result"); } + @Override protected File getResultFile(String filename) { return new File(filename + ".result"); @@ -167,7 +187,8 @@ public File computeActualResults(final String spec) throws IOException, XPathExpressionException, SAXException, ParserConfigurationException { - socket = new ServerSocket(PORT); + int port =findAvailablePort(FROM_PORT, TO_PORT); + socket = new ServerSocket(port); socket.setSoTimeout(SOCKET_TIMEOUT); final Data data = new Data(); @@ -175,7 +196,11 @@ public File computeActualResults(final String spec) throws IOException, String traceName = "T1"; - final File actualOutputFile = new File(traceFolder,"DEFAULT-" + traceName + ".xml"); + String actualOutputFileName = (Settings.dialect == Dialect.VDM_SL ? "DEFAULT-" + : "Entry-") + + traceName + ".xml"; + + final File actualOutputFile = new File(traceFolder, actualOutputFileName); CtHelper testHelper = new CtHelper(); Thread t = testHelper.consCtClientThread(socket, data); @@ -183,11 +208,17 @@ public File computeActualResults(final String spec) throws IOException, t.start(); TraceRunnerMain.USE_SYSTEM_EXIT = false; + + this.testdata.port = port; + + + String[] args = testHelper.buildArgs(Settings.dialect, Settings.release, testdata); + TraceRunnerMain.main(args); final String message = data.getMessage(); - Assert.assertTrue("Test did not succed", message.contains("status=\"completed\" progress=\"100\"")); + Assert.assertTrue("Test did not succed. Are you sure that it contains "+ (Settings.dialect==Dialect.VDM_SL?"'DEFAULT`T1'" : "'Entry`T1'"), message.contains("status=\"completed\" progress=\"100\"")); return actualOutputFile; } @@ -210,4 +241,62 @@ protected boolean assertEqualResults(Object expected, Object actual, { return false; } + + protected void configureResultGeneration() + { + LexLocation.absoluteToStringLocation = false; + if (System.getProperty(TESTS_CT_RUNTIME_PROPERTY_PREFIX + "all") != null + || getPropertyId() != null + && System.getProperty(TESTS_CT_RUNTIME_PROPERTY_PREFIX + + getPropertyId()) != null) + { + Properties.recordTestResults = true; + } + + } + + protected void unconfigureResultGeneration() + { + Properties.recordTestResults = false; + } + + protected abstract String getPropertyId(); + + + + public static int findAvailablePort(int fromPort, int toPort) + { + if (fromPort > toPort) + { + throw new IllegalArgumentException("startPortShouldBeLessThanOrEqualToEndPort"); + } + + int port = fromPort; + ServerSocket socket = null; + while (port <= toPort) + { + try + { + socket = new ServerSocket(port); + return port; + } catch (IOException e) + { + ++port; + } finally + { + if (socket != null) + { + try + { + socket.close(); + } catch (IOException e) + { + e.printStackTrace(); + } + } + } + } + + return -1; + } } diff --git a/core/combinatorialtesting/ctruntime/src/test/java/org/overture/ct/ctruntime/tests/util/TestSourceFinder.java b/core/combinatorialtesting/ctruntime/src/test/java/org/overture/ct/ctruntime/tests/util/TestSourceFinder.java index fa8cc22b80..1b95bc2593 100644 --- a/core/combinatorialtesting/ctruntime/src/test/java/org/overture/ct/ctruntime/tests/util/TestSourceFinder.java +++ b/core/combinatorialtesting/ctruntime/src/test/java/org/overture/ct/ctruntime/tests/util/TestSourceFinder.java @@ -34,11 +34,57 @@ import org.overture.ast.lex.Dialect; import org.overture.ct.ctruntime.tests.CtTestCaseBase; -import org.overture.ct.ctruntime.utils.CtHelper; +import org.overture.ct.ctruntime.utils.CtHelper.CtTestData; public class TestSourceFinder { + public static Collection createTestMultiFileFile(Dialect dialect, + String name, String testRootPath, String... extensions) + + { + File testRoot = getFile(testRootPath); + + // TestSuite suite = new TestSourceFinder(name); + Collection tests = new LinkedList(); + + if (testRoot != null && testRoot.exists()) + { + for (File file : testRoot.listFiles()) + { + if (file.isDirectory() && !file.getName().startsWith(".")) + { + //tests.addAll(createCompleteFile(dialect, name, file, testRoot, extensions)); + List specFiles = new Vector(); + for (File f : file.listFiles()) + { + if(isNotAcceptedFile(f, Arrays.asList(extensions))) + { + continue; + } + specFiles.add(f); + } + + if(!specFiles.isEmpty()) + { + String traceName = file.getName(); + if (traceName.contains(".")) + { + traceName = traceName.substring(0, traceName.lastIndexOf('.')); + } + + File traceFolder = new File((CtTestCaseBase.TRACE_OUTPUT_FOLDER + traceName).replace('/', File.separatorChar)); + tests.add(new Object[] { traceName, file, traceFolder, + new CtTestData("T1", traceFolder, specFiles, null) }); + } + + } + } + } + return tests; + + } + /** * Utility method to create a test suite from files * @@ -139,14 +185,14 @@ private static Collection createCompleteFile(Dialect dialect, } else { String traceName = file.getName(); - traceName = traceName.substring(0, traceName.length() - 6); + if (traceName.contains(".")) + { + traceName = traceName.substring(0, traceName.lastIndexOf('.')); + } File traceFolder = new File((CtTestCaseBase.TRACE_OUTPUT_FOLDER + traceName).replace('/', File.separatorChar)); - CtHelper testHelper = new CtHelper(); - - String[] args = testHelper.buildArgs("T1", CtTestCaseBase.PORT, traceFolder, file); - - tests.add(new Object[] { traceName, file, traceFolder, args }); + tests.add(new Object[] { traceName, file, traceFolder, + new CtTestData("T1", traceFolder, file, null) }); } return tests; diff --git a/core/combinatorialtesting/ctruntime/src/test/resources/multi_no_reduction_sl_specs/simple_2f.result b/core/combinatorialtesting/ctruntime/src/test/resources/multi_no_reduction_sl_specs/simple_2f.result new file mode 100644 index 0000000000..96cd32ecb8 --- /dev/null +++ b/core/combinatorialtesting/ctruntime/src/test/resources/multi_no_reduction_sl_specs/simple_2f.result @@ -0,0 +1,9 @@ + + + + op(mk_R(11)) + 12 + + + + diff --git a/core/combinatorialtesting/ctruntime/src/test/resources/multi_no_reduction_sl_specs/simple_2f/TestSL.vdmsl b/core/combinatorialtesting/ctruntime/src/test/resources/multi_no_reduction_sl_specs/simple_2f/TestSL.vdmsl new file mode 100644 index 0000000000..5d4951e082 --- /dev/null +++ b/core/combinatorialtesting/ctruntime/src/test/resources/multi_no_reduction_sl_specs/simple_2f/TestSL.vdmsl @@ -0,0 +1,3 @@ +types + R :: f:nat + inv t == t.f > 10; diff --git a/core/combinatorialtesting/ctruntime/src/test/resources/multi_no_reduction_sl_specs/simple_2f/TestSL2.vdmsl b/core/combinatorialtesting/ctruntime/src/test/resources/multi_no_reduction_sl_specs/simple_2f/TestSL2.vdmsl new file mode 100644 index 0000000000..9920ef42c5 --- /dev/null +++ b/core/combinatorialtesting/ctruntime/src/test/resources/multi_no_reduction_sl_specs/simple_2f/TestSL2.vdmsl @@ -0,0 +1,6 @@ +operations + op: R ==> nat + op(a) == return a.f + 1; + +traces + T1: op(mk_R(11)); diff --git a/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_pp_specs/DeadlockTest b/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_pp_specs/DeadlockTest new file mode 100644 index 0000000000..1d6daaa28a --- /dev/null +++ b/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_pp_specs/DeadlockTest @@ -0,0 +1,40 @@ +class Entry +instance variables + x:nat := 0; + +operations + public deadlock: () ==> () + deadlock() == skip; + + public runtime: () ==> real + runtime() == return 123/x; + + public runtime2: () ==> real + runtime2() == return runtime(); + + public go: () ==> () + go() == ( start(self); finished() ); + + finished: () ==> () + finished() == skip; + + get: () ==> nat + get() == return x; + + inc: () ==> () + inc() == x := x + 1; + +sync + per deadlock => #fin(deadlock) > 0; + per finished => x > 0; + +thread + deadlock(); + +traces + T1: get(); deadlock(); get(); + --T1: get(); runtime(); get(); + --T1: get(); go(); get(); + --T1: inc(){1,3}; get() + +end Entry \ No newline at end of file diff --git a/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_pp_specs/DeadlockTest.result b/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_pp_specs/DeadlockTest.result new file mode 100644 index 0000000000..1fb6caf871 --- /dev/null +++ b/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_pp_specs/DeadlockTest.result @@ -0,0 +1,9 @@ + + + + get(); deadlock(); get() + 0 ; DEADLOCK detected + + + + diff --git a/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_pp_specs/NestingLetsWithObjBind b/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_pp_specs/NestingLetsWithObjBind new file mode 100644 index 0000000000..05485cbbac --- /dev/null +++ b/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_pp_specs/NestingLetsWithObjBind @@ -0,0 +1,16 @@ +class Entry + +operations + +public op : Entry ==> () +op (c) == skip; + +traces + + T1: let x = new Entry() + in + let y in set {new Entry()} + in + x.op(y) + +end Entry \ No newline at end of file diff --git a/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_pp_specs/NestingLetsWithObjBind.result b/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_pp_specs/NestingLetsWithObjBind.result new file mode 100644 index 0000000000..057c681770 --- /dev/null +++ b/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_pp_specs/NestingLetsWithObjBind.result @@ -0,0 +1,9 @@ + + + + x.op(y) + () + + + + diff --git a/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_pp_specs/Simple_inv b/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_pp_specs/Simple_inv new file mode 100644 index 0000000000..d49a6f2c29 --- /dev/null +++ b/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_pp_specs/Simple_inv @@ -0,0 +1,13 @@ +class Entry +types + R :: a: nat + inv r == r.a < 10; + +operations + op: R ==> () + op(-) == skip; + +traces + T1: op(mk_R(1)); + +end Entry \ No newline at end of file diff --git a/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_pp_specs/Simple_inv.result b/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_pp_specs/Simple_inv.result new file mode 100644 index 0000000000..f714045cc4 --- /dev/null +++ b/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_pp_specs/Simple_inv.result @@ -0,0 +1,9 @@ + + + + op(mk_R(1)) + () + + + + diff --git a/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_pp_specs/XO b/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_pp_specs/XO new file mode 100644 index 0000000000..7debb0bb2f --- /dev/null +++ b/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_pp_specs/XO @@ -0,0 +1,166 @@ +-- +-- A simple model of a tic-tac-toe game (noughts and crosses) +-- + +class Entry +values + SIZE:nat1 = 3; -- The size of the board (3x3) + MAX:nat1 = SIZE * SIZE; -- The maximum number of moves + +types + Player = | ; -- Just two players + + Pos :: -- A position for a move + row : nat1 + col : nat1 + inv p == + p.row <= SIZE and p.col <= SIZE; -- Row/col must be on the board + + Game = map Pos to Player -- A game (who has moved where) + inv g == + forall p1, p2 : Player & -- No player is ever more than one move ahead + card dom (g :> {p1}) - card dom (g :> {p2}) in set {-1, 0, 1} + + +values + S:set of nat1 = {1, ..., SIZE}; + + winningLines = dunion -- Sets of Pos for winning lines + { + {{ mk_Pos(r, c) | c in set S } | r in set S }, -- All rows + {{ mk_Pos(r, c) | r in set S } | c in set S }, -- All columns + {{ mk_Pos(x, x) | x in set S }}, -- Diagnonal + {{ mk_Pos(x, SIZE-x+1) | x in set S }} -- Other diagonal + }; + + +functions + hasWon: Game * Player -> bool + hasWon(g, p) == + let moves = movesForPlayer(g, p) in + exists line in set winningLines & + line subset moves; + + + whoWon: Game -> Player + whoWon(g) == + iota p:Player & hasWon(g, p) + pre isWon(g); + + + isWon: Game -> bool + isWon(g) == + exists1 p:Player & hasWon(g, p); + + + isDraw: Game -> bool + isDraw(g) == + not isWon(g) and moveCountLeft(g) = 0; + + + isUnfinished: Game -> bool + isUnfinished(g) == + not isWon(g) and not isDraw(g); + + + movesSoFar: Game -> set of Pos + movesSoFar(g) == + dom g; + + + moveCountSoFar: Game -> nat + moveCountSoFar(g) == + card movesSoFar(g); + + + moveCountLeft: Game -> nat + moveCountLeft(g) == + MAX - moveCountSoFar(g); + + + movesForPlayer: Game * Player -> set of Pos + movesForPlayer(g, p) == + dom (g :> {p}); + + +values + PLAYERS = { p | p:Player }; -- The set of all Players + +types + Moves = seq of Pos -- A legal game play sequence + inv moves == + len moves = card elems moves and -- Has no duplicated moves + len moves > card PLAYERS * (SIZE - 1) and -- Has minimum moves to win + len moves <= MAX; -- Hasn't too many moves + + PlayOrder = seq1 of Player -- The order of play of the players + inv order == + len order = card elems order and -- No duplicates in the list + elems order = PLAYERS -- Order contains all players + + +instance variables + game : Game -- The game board, initialized by the play operation + +operations + move: Player * Pos ==> () + move(p, pos) == + game(pos) := p + pre pos not in set movesSoFar(game) and + moveCountLeft(game) > 0 + post game = game~ munion {pos |-> p} and + moveCountSoFar(game) = moveCountSoFar(game~) + 1; + + + play: PlayOrder * Moves ==> Player | | + play(playorder, moves) == + ( + dcl order:PlayOrder := playorder; -- hd order is always next to play + game := {|->}; + + for m in moves do + let player = hd order in + ( + move(player, m); + + if isWon(game) then + return whoWon(game) + elseif isDraw(game) then + return + else + order := tl order ^ [player] + ); + + return + ) + post if RESULT = then isDraw(game) + else if RESULT = then isUnfinished(game) + else RESULT = whoWon(game); + +-- Test data and supporting operations/traces + +values + OX = [, ]; + XO = [, ]; + XX = []; + +operations + test: PlayOrder * Moves ==> Player | | + test(playorder, moves) == + play(playorder, moves); + +traces + T1: + let ALLPOS = { mk_Pos(r, c) | r, c in set S } in -- All 3x3 = 9 positions + let m1 in set ALLPOS in -- 9 1st moves +-- let m2 in set ALLPOS \ {m1} in -- 72 1st-2nd pairs +-- let m3 in set ALLPOS \ {m1, m2} in -- 504 1st-2nd-3rd etc... +-- let m4 in set ALLPOS \ {m1, m2, m3} in -- 3024 +-- let m5 in set ALLPOS \ {m1, m2, m3, m4} in -- 15120 (minimum) +-- let m6 in set ALLPOS \ {m1, m2, m3, m4, m5} in -- 60480 +-- let m7 in set ALLPOS \ {m1, m2, m3, m4, m5, m6} in -- 181440 +-- let m8 in set ALLPOS \ {m1, m2, m3, m4, m5, m6, m7} in -- 362880 +-- let m9 in set ALLPOS \ {m1, m2, m3, m4, m5, m6, m7, m8} in -- 362880 + play(XO, [m1]); + +end Entry diff --git a/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_pp_specs/XO.result b/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_pp_specs/XO.result new file mode 100644 index 0000000000..2c456f5d51 --- /dev/null +++ b/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_pp_specs/XO.result @@ -0,0 +1,25 @@ + + + + play([&lt;CROSS&gt;, &lt;NOUGHT&gt;], [mk_Pos(1, 1)]) + Error 4060: Type invariant violated for Moves in 'Entry' at line 164:4 + play([&lt;CROSS&gt;, &lt;NOUGHT&gt;], [mk_Pos(1, 2)]) + Error 4060: Type invariant violated for Moves in 'Entry' at line 164:4 + play([&lt;CROSS&gt;, &lt;NOUGHT&gt;], [mk_Pos(1, 3)]) + Error 4060: Type invariant violated for Moves in 'Entry' at line 164:4 + play([&lt;CROSS&gt;, &lt;NOUGHT&gt;], [mk_Pos(2, 1)]) + Error 4060: Type invariant violated for Moves in 'Entry' at line 164:4 + play([&lt;CROSS&gt;, &lt;NOUGHT&gt;], [mk_Pos(2, 2)]) + Error 4060: Type invariant violated for Moves in 'Entry' at line 164:4 + play([&lt;CROSS&gt;, &lt;NOUGHT&gt;], [mk_Pos(2, 3)]) + Error 4060: Type invariant violated for Moves in 'Entry' at line 164:4 + play([&lt;CROSS&gt;, &lt;NOUGHT&gt;], [mk_Pos(3, 1)]) + Error 4060: Type invariant violated for Moves in 'Entry' at line 164:4 + play([&lt;CROSS&gt;, &lt;NOUGHT&gt;], [mk_Pos(3, 2)]) + Error 4060: Type invariant violated for Moves in 'Entry' at line 164:4 + play([&lt;CROSS&gt;, &lt;NOUGHT&gt;], [mk_Pos(3, 3)]) + Error 4060: Type invariant violated for Moves in 'Entry' at line 164:4 + + + + diff --git a/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_sl_specs/LetRec1 b/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_sl_specs/LetRec1 new file mode 100644 index 0000000000..dbe3644c8e --- /dev/null +++ b/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_sl_specs/LetRec1 @@ -0,0 +1,13 @@ +operations + +op : () ==> () +op () == + skip; + +traces + +T1: +let mk_(a,b) = mk_(1,2), + r = a+b +in + op(); diff --git a/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_sl_specs/LetRec1.result b/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_sl_specs/LetRec1.result new file mode 100644 index 0000000000..ea7768a6e4 --- /dev/null +++ b/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_sl_specs/LetRec1.result @@ -0,0 +1,9 @@ + + + + op() + () + + + + diff --git a/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_sl_specs/Simple_inv b/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_sl_specs/Simple_inv new file mode 100644 index 0000000000..e9b5d85cf2 --- /dev/null +++ b/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_sl_specs/Simple_inv @@ -0,0 +1,14 @@ +module DEFAULT +definitions +types + R :: a: nat + inv r == r.a < 10; + +operations + op: R ==> () + op(-) == skip; + +traces + T1: op(mk_R(1)); + +end DEFAULT \ No newline at end of file diff --git a/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_sl_specs/Simple_inv.result b/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_sl_specs/Simple_inv.result new file mode 100644 index 0000000000..e24af95e54 --- /dev/null +++ b/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_sl_specs/Simple_inv.result @@ -0,0 +1,9 @@ + + + + op(mk_R(1)) + () + + + + diff --git a/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_sl_specs/XO b/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_sl_specs/XO new file mode 100644 index 0000000000..7202393f9d --- /dev/null +++ b/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_sl_specs/XO @@ -0,0 +1,199 @@ +-- +-- A simple model of a tic-tac-toe game (noughts and crosses) +-- + +module XO +exports all +definitions +values + SIZE:nat1 = 3; -- The size of the board (3x3) + MAX:nat1 = SIZE * SIZE; -- The maximum number of moves + +types + Player = | ; -- Just two players + + Pos :: -- A position for a move + row : nat1 + col : nat1 + inv p == + p.row <= SIZE and p.col <= SIZE; -- Row/col must be on the board + + Game = map Pos to Player -- A game (who has moved where) + inv g == + forall p1, p2 : Player & -- No player is ever more than one move ahead + card dom (g :> {p1}) - card dom (g :> {p2}) in set {-1, 0, 1} + + +values + S:set of nat1 = {1, ..., SIZE}; + + winningLines = dunion -- Sets of Pos for winning lines + { + {{ mk_Pos(r, c) | c in set S } | r in set S }, -- All rows + {{ mk_Pos(r, c) | r in set S } | c in set S }, -- All columns + {{ mk_Pos(x, x) | x in set S }}, -- Diagnonal + {{ mk_Pos(x, SIZE-x+1) | x in set S }} -- Other diagonal + }; + + +functions + hasWon: Game * Player -> bool + hasWon(g, p) == + let moves = movesForPlayer(g, p) in + exists line in set winningLines & + line subset moves; + + + whoWon: Game -> Player + whoWon(g) == + iota p:Player & hasWon(g, p) + pre isWon(g); + + + isWon: Game -> bool + isWon(g) == + exists1 p:Player & hasWon(g, p); + + + isDraw: Game -> bool + isDraw(g) == + not isWon(g) and moveCountLeft(g) = 0; + + + isUnfinished: Game -> bool + isUnfinished(g) == + not isWon(g) and not isDraw(g); + + + movesSoFar: Game -> set of Pos + movesSoFar(g) == + dom g; + + + moveCountSoFar: Game -> nat + moveCountSoFar(g) == + card movesSoFar(g); + + + moveCountLeft: Game -> nat + moveCountLeft(g) == + MAX - moveCountSoFar(g); + + + movesForPlayer: Game * Player -> set of Pos + movesForPlayer(g, p) == + dom (g :> {p}); + + +values + PLAYERS = { p | p:Player }; -- The set of all Players + +types + Moves = seq of Pos -- A legal game play sequence + inv moves == + len moves = card elems moves and -- Has no duplicated moves + len moves > card PLAYERS * (SIZE - 1) and -- Has minimum moves to win + len moves <= MAX; -- Hasn't too many moves + + PlayOrder = seq1 of Player -- The order of play of the players + inv order == + len order = card elems order and -- No duplicates in the list + elems order = PLAYERS -- Order contains all players + + +state Sigma of + game : Game -- The game board, initialized by the play operation +end + + +operations + move: Player * Pos ==> () + move(p, pos) == + game(pos) := p + pre pos not in set movesSoFar(game) and + moveCountLeft(game) > 0 + post game = game~ munion {pos |-> p} and + moveCountSoFar(game) = moveCountSoFar(game~) + 1; + + + play: PlayOrder * Moves ==> Player | | + play(playorder, moves) == + ( + dcl order:PlayOrder := playorder; -- hd order is always next to play + game := {|->}; + + for m in moves do + let player = hd order in + ( + move(player, m); + + if isWon(game) then + return whoWon(game) + elseif isDraw(game) then + return + else + order := tl order ^ [player] + ); + + return + ) + post if RESULT = then isDraw(game) + else if RESULT = then isUnfinished(game) + else RESULT = whoWon(game); + +end XO + + +-- +-- A simple model of a tic-tac-toe game (noughts and crosses) +-- + +module DEFAULT +imports from XO + operations + play + types + Pos renamed Pos; + PlayOrder renamed PlayOrder; + Moves renamed Moves; + Player renamed Player + values + SIZE renamed SIZE + +exports all +definitions + +-- Test data and supporting operations/traces + +values + OX = [, ]; + XO = [, ]; + XX = []; + + --T1 = [mk_Pos(1,1), mk_Pos(1,2), mk_Pos(2,1), mk_Pos(1,3), mk_Pos(3,1)]; + T2 = [mk_Pos(1,1), mk_Pos(1,2), mk_Pos(1,3), mk_Pos(2,2), mk_Pos(3,1), mk_Pos(3,2)]; + E1 = [mk_Pos(1,1), mk_Pos(1,1), mk_Pos(1,2), mk_Pos(2,1), mk_Pos(1,3)]; + + S = {1, ..., SIZE} + +operations + test: PlayOrder * Moves ==> Player | | + test(playorder, moves) == + XO`play(playorder, moves); + +traces + T1: + let ALLPOS = { mk_Pos(r, c) | r, c in set S } in -- All 3x3 = 9 positions + let m1 in set ALLPOS in -- 9 1st moves +-- let m2 in set ALLPOS \ {m1} in -- 72 1st-2nd pairs +-- let m3 in set ALLPOS \ {m1, m2} in -- 504 1st-2nd-3rd etc... +-- let m4 in set ALLPOS \ {m1, m2, m3} in -- 3024 +-- let m5 in set ALLPOS \ {m1, m2, m3, m4} in -- 15120 (minimum) +-- let m6 in set ALLPOS \ {m1, m2, m3, m4, m5} in -- 60480 +-- let m7 in set ALLPOS \ {m1, m2, m3, m4, m5, m6} in -- 181440 +-- let m8 in set ALLPOS \ {m1, m2, m3, m4, m5, m6, m7} in -- 362880 +-- let m9 in set ALLPOS \ {m1, m2, m3, m4, m5, m6, m7, m8} in -- 362880 + XO`play(XO, [m1]); + +end DEFAULT + diff --git a/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_sl_specs/XO.result b/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_sl_specs/XO.result new file mode 100644 index 0000000000..a16fa9b461 --- /dev/null +++ b/core/combinatorialtesting/ctruntime/src/test/resources/no_reduction_sl_specs/XO.result @@ -0,0 +1,25 @@ + + + + XO`play([&lt;CROSS&gt;, &lt;NOUGHT&gt;], [mk_Pos(1, 1)]) + Error 4060: Type invariant violated for Moves in 'DEFAULT' at line 196:4 + XO`play([&lt;CROSS&gt;, &lt;NOUGHT&gt;], [mk_Pos(1, 2)]) + Error 4060: Type invariant violated for Moves in 'DEFAULT' at line 196:4 + XO`play([&lt;CROSS&gt;, &lt;NOUGHT&gt;], [mk_Pos(1, 3)]) + Error 4060: Type invariant violated for Moves in 'DEFAULT' at line 196:4 + XO`play([&lt;CROSS&gt;, &lt;NOUGHT&gt;], [mk_Pos(2, 1)]) + Error 4060: Type invariant violated for Moves in 'DEFAULT' at line 196:4 + XO`play([&lt;CROSS&gt;, &lt;NOUGHT&gt;], [mk_Pos(2, 2)]) + Error 4060: Type invariant violated for Moves in 'DEFAULT' at line 196:4 + XO`play([&lt;CROSS&gt;, &lt;NOUGHT&gt;], [mk_Pos(2, 3)]) + Error 4060: Type invariant violated for Moves in 'DEFAULT' at line 196:4 + XO`play([&lt;CROSS&gt;, &lt;NOUGHT&gt;], [mk_Pos(3, 1)]) + Error 4060: Type invariant violated for Moves in 'DEFAULT' at line 196:4 + XO`play([&lt;CROSS&gt;, &lt;NOUGHT&gt;], [mk_Pos(3, 2)]) + Error 4060: Type invariant violated for Moves in 'DEFAULT' at line 196:4 + XO`play([&lt;CROSS&gt;, &lt;NOUGHT&gt;], [mk_Pos(3, 3)]) + Error 4060: Type invariant violated for Moves in 'DEFAULT' at line 196:4 + + + + diff --git a/core/combinatorialtesting/ctruntime/src/test/resources/random_reduction_sl_specs/PaperCaseStudy-1_00%SHAPES_VARVALUES.vdmsl.result b/core/combinatorialtesting/ctruntime/src/test/resources/random_reduction_sl_specs/PaperCaseStudy-1_00%SHAPES_VARVALUES.vdmsl.result index f518e41002..7eb27d4e5c 100644 --- a/core/combinatorialtesting/ctruntime/src/test/resources/random_reduction_sl_specs/PaperCaseStudy-1_00%SHAPES_VARVALUES.vdmsl.result +++ b/core/combinatorialtesting/ctruntime/src/test/resources/random_reduction_sl_specs/PaperCaseStudy-1_00%SHAPES_VARVALUES.vdmsl.result @@ -13,21 +13,21 @@ () op2(3) () - op2(5) + op1(2, 3) () - op1(3, 1) + op2(5) () - op2(4) + op1(3, 1) () - op1(3, 2) + op2(4) () - op1(2, 3) + op1(3, 2) () - op1(2, 4) + op2(5) () - op2(6) + op1(2, 4) () - op2(5) + op2(6) () op1(3, 4) () diff --git a/core/combinatorialtesting/ctutils/pom.xml b/core/combinatorialtesting/ctutils/pom.xml index b54152f3d7..9cc9f4ef21 100644 --- a/core/combinatorialtesting/ctutils/pom.xml +++ b/core/combinatorialtesting/ctutils/pom.xml @@ -4,7 +4,7 @@ org.overturetool.core combinatorialtesting - 2.2.0 + 2.2.2 ../pom.xml diff --git a/core/combinatorialtesting/pom.xml b/core/combinatorialtesting/pom.xml index 441b01777a..5a07c129a3 100644 --- a/core/combinatorialtesting/pom.xml +++ b/core/combinatorialtesting/pom.xml @@ -4,7 +4,7 @@ core org.overturetool - 2.2.0 + 2.2.2 ../pom.xml diff --git a/core/commandline/pom.xml b/core/commandline/pom.xml index 431405e287..215e92ad17 100644 --- a/core/commandline/pom.xml +++ b/core/commandline/pom.xml @@ -4,7 +4,7 @@ org.overturetool core - 2.2.0 + 2.2.2 ../pom.xml diff --git a/core/guibuilder/README.md b/core/guibuilder/README.md index d3a378471b..f73d566490 100644 --- a/core/guibuilder/README.md +++ b/core/guibuilder/README.md @@ -2,20 +2,24 @@ - **Primary Contacts:** Luis Diogo Couto - **Status:** - Development + Maintenance ## Description This module integrates an external tool for prototyping GUIs for VDM models. - -This tool integrates entirely using the remote control features of the Overture -interpreter and a special control class called -"org.overture.guibuilder.GuiBuilderRemote". +The tool primarily uses the remote control features of the Overture interpreter +and in combination with a special control class called +`org.overture.guibuilder.GuiBuilderRemote`. In order to use the tool, a jar that provides the GUI Builder is necessary. That jar can be built by invoking `mvn assembly:single` on this module. Be sure to grab the one named `custom-dependencies`. +For more information about the original GUI Builder tool see: +Nunes, C., & Paiva, A. (2011, October). Automatic Generation of Graphical User +Interfaces From VDM++ Specifications. In ICSEA 2011, The Sixth International +Conference on Software Engineering Advances. + ## Known Issues: VDM-SL models are not supported diff --git a/core/guibuilder/pom.xml b/core/guibuilder/pom.xml index 940d01b563..ee8e36d670 100644 --- a/core/guibuilder/pom.xml +++ b/core/guibuilder/pom.xml @@ -4,7 +4,7 @@ org.overturetool core - 2.2.0 + 2.2.2 ../pom.xml diff --git a/core/guibuilder/src/main/java/org/overture/guibuilder/internal/Driver.java b/core/guibuilder/src/main/java/org/overture/guibuilder/internal/Driver.java index 4b1fee0edd..66c1f218c5 100644 --- a/core/guibuilder/src/main/java/org/overture/guibuilder/internal/Driver.java +++ b/core/guibuilder/src/main/java/org/overture/guibuilder/internal/Driver.java @@ -47,159 +47,9 @@ public static void printUsage() public static void main(String[] args) throws Exception { - // // NOTE: hardcoded for VDM++ ONLY - // final Dialect dialect = Dialect.VDM_PP; - // - // // command line arguments parsing - // - // OptionParser parser = new OptionParser("p:i:as"); - // OptionSet options = null; - // try { - // options = parser.parse(args); - // } catch (Exception e) { - // System.out.println("Error: " + e.getMessage()); printUsage(); return; - // } - // - // if(!options.has("p")) - // { printUsage(); return; } - // - // // list of files, or directory from which to extract the specification - // // List largs = (List) options.valuesOf("p"); - // final Vector files = GetFiles(largs, dialect); - // // if there is the i switch do not generate - // if ( options.has("i")) { - // ToolSettings.GENERATE = false; - // // largs = (List) options.valuesOf("i"); - // } - // final Vector xmlFiles = GetXMLFiles(largs); - // // if there is the 'a' switch generation mode is annotation only - // if(options.has("a")) { - // // ToolSettings.GENERATION_SETTINGS = GENERATION_MODE.ANNOTATIONS; - // } - // // if there is the 's' switch the xml description is saved - // if(options.has("s")) { - // ToolSettings.SAVE_XML = true; - // } - // - // //assuming the last directory name is the project name - // String path = null; - // path = files.get(0).getPath(); - // if ( path.contains("/") ) { // sanity checks - // path = path.substring(0, path.lastIndexOf("/")); - // if (path.contains("/")) - // path = path.substring(path.lastIndexOf("/")+1); - // } - // final String projectName = path; - // - // java.awt.EventQueue.invokeLater( new Runnable() { - // - // @Override - // public void run() { - // - // try { - // VdmjVdmInterpreterWrapper interpreter = new VdmjVdmInterpreterWrapper(dialect); - // interpreter.parseFilesAndTypeCheck(files); - // org.overture.guibuilder.internal.ir.IVdmClassReader reader = new - // org.overture.guibuilder.internal.ir.VdmjVdmClassReader(); - // reader.readFiles( files ); // we only care for VDM++ - // - // UiInterface ui = new UiInterface(interpreter); - // if ( ToolSettings.GENERATE ) { - // // Generation Mode - // if ( ToolSettings.SAVE_XML) { - // ui.buildAndRender(reader, projectName, files.get(0).getPath().substring(0, - // files.get(0).getPath().lastIndexOf("/") + 1)); - // } else { - // ui.buildAndRender(reader, projectName); - // } - // } else { - // ui.Render(reader, projectName, xmlFiles); - // } - // ui.setVisible(true); - // } catch (Exception e) { - // // TODO Auto-generated catch block - // e.printStackTrace(); - // } - // - // }} ); + } - // - // /** - // * Gets the list of xml files contained in a directory - // * @param largs Directory containing xml files. - // * @return - // */ - // private static Vector GetXMLFiles(List largs) { - // - // Vector filenames = new Vector(); - // if (largs != null) { - // for ( String s : largs ) { - // File dir = new File(s); - // - // if (dir.isDirectory()) { // directory - // // contents of directory - // for (File file: dir.listFiles(new FilenameFilter(){ - // // filter for xml files (checks if the filename contains ".xml" - // // FIXME: ugly - // @Override - // public boolean accept(File arg0, String arg1) { - // if ( arg1.contains(".xml") ) - // return true; - // return false; - // }})) - // { - // if(file.isFile()) { - // filenames.add(file); - // } - // } // end for - // } else { - // filenames.add(dir); - // } // end directory - // } - // - // } - // if (filenames.size() == 0) - // return null; - // - // return filenames; - // } - // - // - // /** - // * Static function for obtaining the files from a directory or a single file, - // * according to a given vdm dialect - // * @param names of files and/or directory path - // * @param dialect - // * @return - // */ - // private static Vector GetFiles(List largs, Dialect dialect) { - // - // Vector filenames = new Vector(); - // - // if(largs != null) { - // // arguments parsing - // for (Iterator i = largs.iterator(); i.hasNext();) - // { - // String arg = i.next(); - // File dir = new File(arg); - // - // if(dir.isDirectory()) - // { - // // contents of directory - // for (File file: dir.listFiles(dialect.getFilter())) - // { - // if(file.isFile()) { - // filenames.add(file); - // } - // } // end for - // } else { - // filenames.add(dir); - // } // end if (dir.isDirectory()) - // } // end for - // } - // - // return filenames; - // } + } diff --git a/core/guibuilder/src/main/java/org/overture/guibuilder/internal/InstanceWindowContainerBridge.java b/core/guibuilder/src/main/java/org/overture/guibuilder/internal/InstanceWindowContainerBridge.java index 67e6ac2a67..aa8ddf93d1 100644 --- a/core/guibuilder/src/main/java/org/overture/guibuilder/internal/InstanceWindowContainerBridge.java +++ b/core/guibuilder/src/main/java/org/overture/guibuilder/internal/InstanceWindowContainerBridge.java @@ -210,7 +210,7 @@ private void refreshVisibleContents() } // updates the value of labels - // FIXME: It's better to use a list with the methods... + // It's better to use a list with the methods... if (methodWidgetsVisible) { for (String id : idMap.keySet()) @@ -240,7 +240,7 @@ private void refreshVisibleContents() */ public void submitOK() { - // FIXME: Only one constructor is taken into account... + // Only one constructor is taken into account... String className = NamingPolicies.extractClassName(id); String instanceName = NamingPolicies.getInstanceName(className); diff --git a/core/guibuilder/src/main/java/org/overture/guibuilder/internal/SwiXMLGenerator.java b/core/guibuilder/src/main/java/org/overture/guibuilder/internal/SwiXMLGenerator.java index 0a6e002e18..48bce9771a 100644 --- a/core/guibuilder/src/main/java/org/overture/guibuilder/internal/SwiXMLGenerator.java +++ b/core/guibuilder/src/main/java/org/overture/guibuilder/internal/SwiXMLGenerator.java @@ -109,7 +109,7 @@ public void buildMainWindow(IVdmClassReader classReader, String title) root = frame; } - // FIXME: Generated window is very simple... + // Generated window is very simple... /** * Function to build the elements of a main window * @@ -177,7 +177,7 @@ public void buildInstanceWindowFor(VdmClass classDef) Frame rootFrame = objFactory.createFrame(); rootFrame.setSize("320,520"); - // FIXME: Get the name from the annotation + // Get the name from the annotation rootFrame.setTitle(classDef.getName()); // the root's id is based on the class's name rootFrame.setId(NamingPolicies.getObjectWindowId(classDef.getName())); // id for the window @@ -294,7 +294,7 @@ private void addAnnotationGuidedElements(Panel panel, VdmMethod def) Vector annotations = def.getAnnotations(); for (VdmAnnotation annotation : annotations) { - // FIXME: with a press annotation we just call addGenericElements() + // with a press annotation we just call addGenericElements() // @press if (annotation.getName().equals(NamingPolicies.PRESS_ANNOTATION)) { @@ -360,7 +360,7 @@ private void addGenericElements(Panel panel, VdmMethod def) */ private Panel createConstructorArgumentsPanel(VdmClass classDef) { - // FIXME: we only handle one constructor + // we only handle one constructor Panel panel = objFactory.createPanel(); panel.setId(NamingPolicies.getConstWidgetsContainerId(0)); for (IVdmDefinition vdmDef : classDef.getDefinitions()) diff --git a/core/guibuilder/src/main/java/org/overture/guibuilder/internal/UiInterface.java b/core/guibuilder/src/main/java/org/overture/guibuilder/internal/UiInterface.java index 968b641c3a..bd5ffd4261 100644 --- a/core/guibuilder/src/main/java/org/overture/guibuilder/internal/UiInterface.java +++ b/core/guibuilder/src/main/java/org/overture/guibuilder/internal/UiInterface.java @@ -83,7 +83,7 @@ public void renderFile(File file, String name) throws Exception containerTable.put(name, c); } else { - // FIXME: Find a better identifier than 'main' when main String is null + // Find a better identifier than 'main' when main String is null containerTable.put("main", c); } } @@ -107,7 +107,7 @@ private void renderInstanceWindow(File file, String name) throws Exception containerTable.put(name, c); } else { - // FIXME: Find a better identifier than 'main' when main String is null + // Find a better identifier than 'main' when main String is null containerTable.put("main", c); } } @@ -130,7 +130,7 @@ private void renderMainWindow(File file, String name) throws Exception containerTable.put(name, c); } else { - // FIXME: Find a better identifier than 'main' when main String is null + // Find a better identifier than 'main' when main String is null containerTable.put("main", c); } } @@ -335,7 +335,7 @@ public void buildAndRender(IVdmClassReader reader, String projectName, // checking if we have more than one class to use for (IVdmDefinition c : this.classList) { - // FIXME: this works as there is only one possible annotation for classes + // this works as there is only one possible annotation for classes if (c.hasAnnotations()) { --i; @@ -405,7 +405,7 @@ public void buildAndRender(IVdmClassReader reader, String projectName) // checking if we have more than one class to use for (IVdmDefinition c : this.classList) { - // FIXME: this works as there is only one possible annotation for classes + // this works as there is only one possible annotation for classes if (c.hasAnnotations()) { --i; diff --git a/core/guibuilder/src/main/java/org/overture/guibuilder/internal/VdmjVdmInterpreterWrapper.java b/core/guibuilder/src/main/java/org/overture/guibuilder/internal/VdmjVdmInterpreterWrapper.java index 478ff025a7..cfe971f0a3 100644 --- a/core/guibuilder/src/main/java/org/overture/guibuilder/internal/VdmjVdmInterpreterWrapper.java +++ b/core/guibuilder/src/main/java/org/overture/guibuilder/internal/VdmjVdmInterpreterWrapper.java @@ -57,7 +57,7 @@ public VdmjVdmInterpreterWrapper(Dialect dialect) throws Exception { // global VDMJ settings - Settings.usingCmdLine = true; // FIXME: not really sure what this is for... + Settings.usingCmdLine = true; Settings.usingDBGP = false; Settings.dialect = dialect; diff --git a/core/guibuilder/src/main/java/org/overture/guibuilder/internal/ir/AnnotationReader.java b/core/guibuilder/src/main/java/org/overture/guibuilder/internal/ir/AnnotationReader.java index 3d7d25db1b..182b6ffc08 100644 --- a/core/guibuilder/src/main/java/org/overture/guibuilder/internal/ir/AnnotationReader.java +++ b/core/guibuilder/src/main/java/org/overture/guibuilder/internal/ir/AnnotationReader.java @@ -90,7 +90,7 @@ public void readFiles(Vector files) } } - // FIXME: DIRTY, VERY DIRTY. A proper parser should be used for this. + // DIRTY, VERY DIRTY. A proper parser should be used for this. // This method only does simple line by line reading. /** * Reads a single plain text file containing a vdm++ specification @@ -121,7 +121,7 @@ private void readFile(File file) } // found a annotation - // FIXME: We don't take into account multiple annotations for a class or method + // We don't take into account multiple annotations for a class or method if (annotationPatern.matcher(strLine).lookingAt()) { String[] result = strLine.split("="); @@ -178,7 +178,7 @@ private void readFile(File file) } // lookinAt() else if (strLine.contains("public") || strLine.contains("private")) - { // FIXME: Redundant + { // Redundant String split[] = strLine.split(" "); if (split.length >= 2) { diff --git a/core/guibuilder/src/main/java/org/overture/guibuilder/internal/ir/VdmjVdmClassReader.java b/core/guibuilder/src/main/java/org/overture/guibuilder/internal/ir/VdmjVdmClassReader.java index 68f017f704..9de15d5538 100644 --- a/core/guibuilder/src/main/java/org/overture/guibuilder/internal/ir/VdmjVdmClassReader.java +++ b/core/guibuilder/src/main/java/org/overture/guibuilder/internal/ir/VdmjVdmClassReader.java @@ -170,14 +170,13 @@ private void readVdmjClass(SClassDefinition c, if (assistantFactory.createPDefinitionAssistant().isFunctionOrOperation(def)) { // now we check what sub class it is... - // FIXME: Better way of doing this ? if (def instanceof AExplicitOperationDefinition) { AExplicitOperationDefinition operation = (AExplicitOperationDefinition) def; - // FIXME: In terms of type only 'class types' are treated + // In terms of type only 'class types' are treated VdmType type = getType(((AOperationType) operation.getType()).getResult(), assistantFactory); newDefinition = new VdmMethod(operation.getName().getName(), operation.getIsConstructor(), type); - // FIXME: Temporary solution, just to check if there's a return + // Temporary solution, just to check if there's a return /* * if (!operation.type.result.equals("()")) newDefinition.setType( "" ); */// fetching the arguments @@ -203,7 +202,7 @@ private void readVdmjClass(SClassDefinition c, { AImplicitOperationDefinition operation = (AImplicitOperationDefinition) def; VdmType type = null; - // FIXME: In terms of type only 'class types' are treated + // In terms of type only 'class types' are treated type = getType(((AOperationType) operation.getType()).getResult(), assistantFactory); newDefinition = new VdmMethod(operation.getName().getName(), operation.getIsConstructor(), type); @@ -231,7 +230,7 @@ private void readVdmjClass(SClassDefinition c, { AExplicitFunctionDefinition function = (AExplicitFunctionDefinition) def; VdmType type = null; - // FIXME: In terms of type only 'class types' are treated + // In terms of type only 'class types' are treated type = getType(((AFunctionType) function.getType()).getResult(), assistantFactory); newDefinition = new VdmMethod(function.getName().getName(), false, type); // fetching the arguments @@ -259,7 +258,7 @@ private void readVdmjClass(SClassDefinition c, { AImplicitFunctionDefinition function = (AImplicitFunctionDefinition) def; VdmType type = null; - // FIXME: In terms of type only 'class types' are treated + // In terms of type only 'class types' are treated type = getType(((AFunctionType) function.getType()).getResult(), assistantFactory); newDefinition = new VdmMethod(function.getName().getName(), false, type); // fetching the arguments @@ -309,7 +308,7 @@ private void readVdmjClass(SClassDefinition c, } } - // FIXME we only have one annotation for classes, so we can get away with this, but + // we only have one annotation for classes, so we can get away with this, but // a sanity check is needed... if (!(ToolSettings.GENERATION_SETTINGS == ToolSettings.GENERATION_MODE.ANNOTATIONS && vdmClass.hasAnnotations())) { @@ -318,34 +317,8 @@ private void readVdmjClass(SClassDefinition c, } - // public static boolean isClass(PType type) - // { - // // FIXME - // if (type instanceof ANamedInvariantType) - // { - // ANamedInvariantType in = (ANamedInvariantType) type; - // if (in.getOpaque()) - // { - // return false; - // } - // return isClass(in.getType()); - // } else if (type instanceof AOptionalType) - // { - // AOptionalType opt = (AOptionalType) type; - // return isClass(opt.getType()); - // } else if (type instanceof AParameterType) - // { - // return true; - // } else if (type instanceof AUnionType) - // { - // AUnionType ut = (AUnionType) type; - // return AUnionTypeAssistantInterpreter.getClassType(ut) != null; - // } else if (type instanceof AUnknownType) - // { - // return true; - // } - // return false; - // } + + public static VdmType getType(PType type, ITypeCheckerAssistantFactory assistantFactory) // added parameter for the assistantFactory @@ -379,7 +352,7 @@ public Vector getClassNames() */ private String extractTypeName(PType type, int n) { - // FIXME: rewrite + // rewrite String ret = type.toString(); // System.out.println(ret); ret = ret.replaceAll("\\(", ""); diff --git a/core/interpreter/pom.xml b/core/interpreter/pom.xml index 1f45f312ee..71f845f80d 100644 --- a/core/interpreter/pom.xml +++ b/core/interpreter/pom.xml @@ -4,7 +4,7 @@ org.overturetool core - 2.2.0 + 2.2.2 ../pom.xml diff --git a/core/interpreter/src/main/java/org/overture/interpreter/scheduler/CTMainThread.java b/core/interpreter/src/main/java/org/overture/interpreter/scheduler/CTMainThread.java index cb35ec5426..dc1fc44113 100644 --- a/core/interpreter/src/main/java/org/overture/interpreter/scheduler/CTMainThread.java +++ b/core/interpreter/src/main/java/org/overture/interpreter/scheduler/CTMainThread.java @@ -157,6 +157,10 @@ public void body() } } catch (Throwable e) { + if (e instanceof ThreadDeath) + { + return; + } if (result.lastIndexOf(Verdict.FAILED) < 0) { if (!getExceptions().isEmpty()) @@ -172,13 +176,30 @@ public void body() } } + @Override + public synchronized void setSignal(Signal sig) + { + if (sig == Signal.DEADLOCKED) + { + if (result.lastIndexOf(Verdict.FAILED) < 0) + { + result.add("DEADLOCK detected"); + result.add(Verdict.FAILED); + } + } + super.setSignal(sig); + } + @Override protected void handleSignal(Signal sig, Context lctxt, ILexLocation location) { if (sig == Signal.DEADLOCKED) { - result.add("DEADLOCK detected"); - result.add(Verdict.FAILED); + if (result.lastIndexOf(Verdict.FAILED) < 0) + { + result.add("DEADLOCK detected"); + result.add(Verdict.FAILED); + } } super.handleSignal(sig, lctxt, location); diff --git a/core/interpreter/src/main/java/org/overture/interpreter/traces/AlternativeTraceNode.java b/core/interpreter/src/main/java/org/overture/interpreter/traces/AlternativeTraceNode.java index f4439b2740..333654ff83 100644 --- a/core/interpreter/src/main/java/org/overture/interpreter/traces/AlternativeTraceNode.java +++ b/core/interpreter/src/main/java/org/overture/interpreter/traces/AlternativeTraceNode.java @@ -58,10 +58,17 @@ public CallSequence get(int index) if(tmp instanceof IIterableTraceNode) { IIterableTraceNode in = (IIterableTraceNode) tmp; - return in.get(v.second); + + CallSequence callSeq = tmp.getVariables(); + callSeq.addAll(in.get(v.second)); + + return callSeq; }else { - return tmp.getTests().get(v.second); + CallSequence callSeq = tmp.getVariables(); + callSeq.addAll(tmp.getTests().get(v.second)); + + return callSeq; } } diff --git a/core/interpreter/src/main/java/org/overture/interpreter/traces/RepeatTraceNode.java b/core/interpreter/src/main/java/org/overture/interpreter/traces/RepeatTraceNode.java index e868eec524..2ab138ce8b 100644 --- a/core/interpreter/src/main/java/org/overture/interpreter/traces/RepeatTraceNode.java +++ b/core/interpreter/src/main/java/org/overture/interpreter/traces/RepeatTraceNode.java @@ -148,7 +148,6 @@ public int size() size++; } } - System.out.println(size); return size; } diff --git a/core/interpreter/src/main/java/org/overture/interpreter/traces/TraceVariableStatement.java b/core/interpreter/src/main/java/org/overture/interpreter/traces/TraceVariableStatement.java index 56ea2d705e..7a9457d167 100644 --- a/core/interpreter/src/main/java/org/overture/interpreter/traces/TraceVariableStatement.java +++ b/core/interpreter/src/main/java/org/overture/interpreter/traces/TraceVariableStatement.java @@ -38,7 +38,6 @@ import org.overture.interpreter.runtime.Context; import org.overture.interpreter.values.Value; import org.overture.interpreter.values.VoidValue; -import org.overture.typechecker.Environment; import org.overture.typechecker.FlatEnvironment; public class TraceVariableStatement extends PStmBase @@ -53,28 +52,11 @@ public TraceVariableStatement(TraceVariable var) this.var = var; } - public void typeCheck(Environment env, NameScope scope) + public void typeCheck(FlatEnvironment env, NameScope scope) { - FlatEnvironment flat = (FlatEnvironment) env; - flat.add(AstFactoryTC.newALocalDefinition(var.name.getLocation(), var.name, scope, var.type)); - // return var.type; + env.add(AstFactoryTC.newALocalDefinition(var.name.getLocation(), var.name, scope, var.type)); } - // @Override - // public Value eval(Context ctxt) - // { - // location.hit(); - // Value val = var.value; - // - // if (val.isType(ObjectValue.class)) - // { - // val = (Value)var.value.clone(); // To allow updates to objects - // } - // - // ctxt.put(var.name, val); - // return new VoidValue(); - // } - public static Value eval(TraceVariableStatement stmt, Context ctxt) { stmt.getLocation().hit(); @@ -89,13 +71,6 @@ public static Value eval(TraceVariableStatement stmt, Context ctxt) return new VoidValue(); } - // - // @Override - // public String kind() - // { - // return "trace variable"; - // } - // @Override public String toString() { @@ -105,28 +80,24 @@ public String toString() @Override public PStm clone() { - // TODO Auto-generated method stub return null; } @Override public PStm clone(Map oldToNewMap) { - // TODO Auto-generated method stub return null; } @Override public void apply(IAnalysis analysis) throws AnalysisException { - // TODO Auto-generated method stub } @Override public A apply(IAnswer caller) throws AnalysisException { - // TODO Auto-generated method stub return null; } @@ -134,7 +105,6 @@ public A apply(IAnswer caller) throws AnalysisException public void apply(IQuestion caller, Q question) throws AnalysisException { - // TODO Auto-generated method stub } @@ -142,15 +112,7 @@ public void apply(IQuestion caller, Q question) public A apply(IQuestionAnswer caller, Q question) throws AnalysisException { - // TODO Auto-generated method stub return null; } - // @Override - // public Type typeCheck(Environment env, NameScope scope) - // { - // FlatEnvironment flat = (FlatEnvironment)env; - // flat.add(new LocalDefinition(location, var.name, scope, var.type)); - // return var.type; - // } } diff --git a/core/interpreter/src/main/java/org/overture/interpreter/values/CPUValue.java b/core/interpreter/src/main/java/org/overture/interpreter/values/CPUValue.java index 47901f3568..8828617710 100644 --- a/core/interpreter/src/main/java/org/overture/interpreter/values/CPUValue.java +++ b/core/interpreter/src/main/java/org/overture/interpreter/values/CPUValue.java @@ -131,6 +131,8 @@ public boolean isVirtual() { return resource.isVirtual(); } + + transient static AClassType cpuType = null; public static void init(ResourceScheduler scheduler, IInterpreterAssistantFactory assistantFactory) @@ -138,8 +140,12 @@ public static void init(ResourceScheduler scheduler, try { CPUResource.init(); - SClassDefinition def = AstFactoryTC.newACpuClassDefinition(assistantFactory); - vCPU = new CPUValue((AClassType) assistantFactory.createSClassDefinitionAssistant().getType(def)); + if(cpuType==null) + { + SClassDefinition cpu = AstFactoryTC.newACpuClassDefinition(assistantFactory); + cpuType = (AClassType) assistantFactory.createSClassDefinitionAssistant().getType(cpu); + } + vCPU = new CPUValue(cpuType); vCPU.setup(scheduler, "vCPU"); } catch (Exception e) { diff --git a/core/modelcheckers/pom.xml b/core/modelcheckers/pom.xml index aae425b6a0..1213a0baf7 100644 --- a/core/modelcheckers/pom.xml +++ b/core/modelcheckers/pom.xml @@ -4,7 +4,7 @@ org.overturetool core - 2.2.0 + 2.2.2 ../pom.xml diff --git a/core/modelcheckers/probsolver/pom.xml b/core/modelcheckers/probsolver/pom.xml index b9ccc071df..6b8980f532 100644 --- a/core/modelcheckers/probsolver/pom.xml +++ b/core/modelcheckers/probsolver/pom.xml @@ -4,7 +4,7 @@ org.overturetool.core modelcheckers - 2.2.0 + 2.2.2 ../pom.xml diff --git a/core/modelcheckers/probsolverintegration/pom.xml b/core/modelcheckers/probsolverintegration/pom.xml index 10b76855cd..6d27874be3 100644 --- a/core/modelcheckers/probsolverintegration/pom.xml +++ b/core/modelcheckers/probsolverintegration/pom.xml @@ -4,7 +4,7 @@ org.overturetool.core modelcheckers - 2.2.0 + 2.2.2 ../pom.xml diff --git a/core/parser/pom.xml b/core/parser/pom.xml index 0554adf8df..aed18c08cd 100644 --- a/core/parser/pom.xml +++ b/core/parser/pom.xml @@ -4,7 +4,7 @@ org.overturetool core - 2.2.0 + 2.2.2 ../pom.xml diff --git a/core/pog/pom.xml b/core/pog/pom.xml index 7cedc805e4..c377954970 100644 --- a/core/pog/pom.xml +++ b/core/pog/pom.xml @@ -4,7 +4,7 @@ org.overturetool core - 2.2.0 + 2.2.2 ../pom.xml diff --git a/core/pom.xml b/core/pom.xml index f9927ea901..12d1dbd2eb 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -4,7 +4,7 @@ org.overturetool root - 2.2.0 + 2.2.2 ../pom.xml diff --git a/core/prettyprinting/npp/pom.xml b/core/prettyprinting/npp/pom.xml index cdd813ef26..f5af905ec1 100644 --- a/core/prettyprinting/npp/pom.xml +++ b/core/prettyprinting/npp/pom.xml @@ -4,7 +4,7 @@ org.overturetool.core prettyprinting - 2.2.0 + 2.2.2 ../pom.xml diff --git a/core/prettyprinting/pom.xml b/core/prettyprinting/pom.xml index ffff9fcff5..8d2beb21fe 100644 --- a/core/prettyprinting/pom.xml +++ b/core/prettyprinting/pom.xml @@ -4,7 +4,7 @@ org.overturetool core - 2.2.0 + 2.2.2 ../pom.xml diff --git a/core/prettyprinting/prettyprinter/pom.xml b/core/prettyprinting/prettyprinter/pom.xml index 7752505446..819e34ed88 100644 --- a/core/prettyprinting/prettyprinter/pom.xml +++ b/core/prettyprinting/prettyprinter/pom.xml @@ -4,7 +4,7 @@ org.overturetool.core prettyprinting - 2.2.0 + 2.2.2 ../pom.xml diff --git a/core/testframework/pom.xml b/core/testframework/pom.xml index 11d602ea4c..fcb6ad3770 100644 --- a/core/testframework/pom.xml +++ b/core/testframework/pom.xml @@ -4,7 +4,7 @@ org.overturetool core - 2.2.0 + 2.2.2 ../pom.xml diff --git a/core/testing/exsupport/pom.xml b/core/testing/exsupport/pom.xml index 53efc5bbd5..f859a3449a 100644 --- a/core/testing/exsupport/pom.xml +++ b/core/testing/exsupport/pom.xml @@ -4,7 +4,7 @@ org.overturetool.core testing - 2.2.0 + 2.2.2 ../pom.xml diff --git a/core/testing/extests/pom.xml b/core/testing/extests/pom.xml index e32b39e96f..b1691df297 100644 --- a/core/testing/extests/pom.xml +++ b/core/testing/extests/pom.xml @@ -4,7 +4,7 @@ org.overturetool.core testing - 2.2.0 + 2.2.2 ../pom.xml diff --git a/core/testing/framework/pom.xml b/core/testing/framework/pom.xml index 60233c5bd1..4799aad591 100644 --- a/core/testing/framework/pom.xml +++ b/core/testing/framework/pom.xml @@ -4,7 +4,7 @@ org.overturetool.core testing - 2.2.0 + 2.2.2 ../pom.xml diff --git a/core/testing/pom.xml b/core/testing/pom.xml index 62564bd026..fdcd45eeb4 100644 --- a/core/testing/pom.xml +++ b/core/testing/pom.xml @@ -4,7 +4,7 @@ org.overturetool core - 2.2.0 + 2.2.2 ../pom.xml diff --git a/core/testing/tests/pom.xml b/core/testing/tests/pom.xml index 917cab3348..d09890b45d 100644 --- a/core/testing/tests/pom.xml +++ b/core/testing/tests/pom.xml @@ -4,7 +4,7 @@ org.overturetool.core testing - 2.2.0 + 2.2.2 ../pom.xml diff --git a/core/typechecker/pom.xml b/core/typechecker/pom.xml index 8590187727..e1f25210bd 100644 --- a/core/typechecker/pom.xml +++ b/core/typechecker/pom.xml @@ -4,7 +4,7 @@ org.overturetool core - 2.2.0 + 2.2.2 ../pom.xml diff --git a/core/typechecker/src/main/java/org/overture/typechecker/assistant/definition/PDefinitionAssistantTC.java b/core/typechecker/src/main/java/org/overture/typechecker/assistant/definition/PDefinitionAssistantTC.java index 3bfc99e29e..512832f1fb 100644 --- a/core/typechecker/src/main/java/org/overture/typechecker/assistant/definition/PDefinitionAssistantTC.java +++ b/core/typechecker/src/main/java/org/overture/typechecker/assistant/definition/PDefinitionAssistantTC.java @@ -73,7 +73,7 @@ public boolean equals(PDefinition d, Object other) // Used for sets of definitio { try { - return d.apply(af.getDefinitionEqualityChecker(), other);// FIXME: should we handle exceptions like this + return d.apply(af.getDefinitionEqualityChecker(), other); } catch (AnalysisException e) { return false; @@ -132,10 +132,7 @@ public PDefinition findType(PDefinition d, ILexNameToken sought, { try { - return d.apply(af.getDefinitionFinder(), new DefinitionFinder.Newquestion(sought, fromModule));// FIXME: - // should we - // handle exceptions - // like this + return d.apply(af.getDefinitionFinder(), new DefinitionFinder.Newquestion(sought, fromModule)); } catch (AnalysisException e) { return null; @@ -148,8 +145,7 @@ public PDefinition findName(PDefinition d, ILexNameToken sought, try { - return d.apply(af.getNameFinder(), new NameFinder.Newquestion(sought, scope));// FIXME: should we handle - // exceptions like this + return d.apply(af.getNameFinder(), new NameFinder.Newquestion(sought, scope)); } catch (AnalysisException e) { return null; @@ -185,7 +181,7 @@ public void markUsed(PDefinition d) { try { - d.apply(af.getUsedMarker());// FIXME: should we handle exceptions like this + d.apply(af.getUsedMarker()); } catch (AnalysisException e) { @@ -196,7 +192,7 @@ public void unusedCheck(PDefinition d) { try { - d.apply(af.getUnusedChecker());// FIXME: should we handle exceptions like this + d.apply(af.getUnusedChecker()); } catch (AnalysisException e) { @@ -218,7 +214,7 @@ public List getDefinitions(PDefinition d) { try { - return d.apply(af.getDefinitionCollector());// FIXME: should we handle exceptions like this + return d.apply(af.getDefinitionCollector()); } catch (AnalysisException e) { return null; @@ -230,7 +226,7 @@ public PDefinition getSelfDefinition(PDefinition d) { try { - return d.apply(af.getSelfDefinitionFinder());// FIXME: should we handle exceptions like this + return d.apply(af.getSelfDefinitionFinder()); } catch (AnalysisException e) { return null; @@ -242,7 +238,7 @@ public LexNameList getVariableNames(PDefinition d) { try { - return d.apply(af.getVariableNameCollector());// FIXME: should we handle exceptions like this + return d.apply(af.getVariableNameCollector()); } catch (AnalysisException e) { return null; @@ -259,7 +255,7 @@ public PDefinition deref(PDefinition d) { try { - return d.apply(af.getDereferer());// FIXME: should we handle exceptions like this + return d.apply(af.getDereferer()); } catch (AnalysisException e) { return null; @@ -271,7 +267,7 @@ public boolean isCallableOperation(PDefinition d) { try { - return d.apply(af.getCallableOperationChecker());// FIXME: should we handle exceptions like this + return d.apply(af.getCallableOperationChecker()); } catch (AnalysisException e) { return false; @@ -283,7 +279,7 @@ public boolean isUsed(PDefinition d) { try { - return d.apply(af.getUsedChecker());// FIXME: should we handle exceptions like this + return d.apply(af.getUsedChecker()); } catch (AnalysisException e) { return false; @@ -295,7 +291,7 @@ public void implicitDefinitions(PDefinition d, Environment env) { try { - d.apply(af.getImplicitDefinitionFinder(), env);// FIXME: should we handle exceptions like this + d.apply(af.getImplicitDefinitionFinder(), env); } catch (AnalysisException e) { @@ -309,11 +305,7 @@ public void typeResolve(PDefinition d, { try { - d.apply(af.getDefinitionTypeResolver(), new DefinitionTypeResolver.NewQuestion(rootVisitor, question));// FIXME: - // should - // we - // handle exceptions - // like this + d.apply(af.getDefinitionTypeResolver(), new DefinitionTypeResolver.NewQuestion(rootVisitor, question)); } catch (AnalysisException e) { @@ -325,7 +317,7 @@ public PType getType(PDefinition d) { try { - return d.apply(af.getDefinitionTypeFinder());// FIXME: should we handle exceptions like this + return d.apply(af.getDefinitionTypeFinder()); } catch (AnalysisException e) { return null; @@ -337,7 +329,7 @@ public boolean isUpdatable(PDefinition d) { try { - return d.apply(af.getUpdatableChecker());// FIXME: should we handle exceptions like this + return d.apply(af.getUpdatableChecker()); } catch (AnalysisException e) { return false; @@ -348,7 +340,7 @@ public String kind(PDefinition d) { try { - return d.apply(af.getKindFinder());// FIXME: should we handle exceptions like this + return d.apply(af.getKindFinder()); } catch (AnalysisException e) { return null; @@ -360,7 +352,7 @@ public boolean isFunction(PDefinition d) { try { - return d.apply(af.getFunctionChecker());// FIXME: should we handle exceptions like this + return d.apply(af.getFunctionChecker()); } catch (AnalysisException e) { return false; @@ -371,7 +363,7 @@ public boolean isOperation(PDefinition d) { try { - return d.apply(af.getOperationChecker());// FIXME: should we handle exceptions like this + return d.apply(af.getOperationChecker()); } catch (AnalysisException e) { return false; diff --git a/core/typechecker/src/main/java/org/overture/typechecker/assistant/expression/PExpAssistantTC.java b/core/typechecker/src/main/java/org/overture/typechecker/assistant/expression/PExpAssistantTC.java index 784458ecb0..0252214415 100644 --- a/core/typechecker/src/main/java/org/overture/typechecker/assistant/expression/PExpAssistantTC.java +++ b/core/typechecker/src/main/java/org/overture/typechecker/assistant/expression/PExpAssistantTC.java @@ -45,7 +45,7 @@ public ILexNameToken getPreName(PExp expression) { try { - return expression.apply(af.getPreNameFinder());// FIXME: should we handle exceptions like this + return expression.apply(af.getPreNameFinder()); } catch (AnalysisException e) { return null; diff --git a/core/typechecker/src/main/java/org/overture/typechecker/assistant/module/PExportAssistantTC.java b/core/typechecker/src/main/java/org/overture/typechecker/assistant/module/PExportAssistantTC.java index 7e4a5f4173..415975f600 100644 --- a/core/typechecker/src/main/java/org/overture/typechecker/assistant/module/PExportAssistantTC.java +++ b/core/typechecker/src/main/java/org/overture/typechecker/assistant/module/PExportAssistantTC.java @@ -45,7 +45,7 @@ public Collection getDefinition(PExport exp, { try { - return exp.apply(af.getExportDefinitionFinder(), actualDefs);// FIXME: should we handle exceptions like this + return exp.apply(af.getExportDefinitionFinder(), actualDefs); } catch (AnalysisException e) { return null; @@ -57,7 +57,7 @@ public Collection getDefinition(PExport exp) { try { - return exp.apply(af.getExportDefinitionListFinder());// FIXME: should we handle exceptions like this + return exp.apply(af.getExportDefinitionListFinder()); } catch (AnalysisException e) { return null; diff --git a/core/typechecker/src/main/java/org/overture/typechecker/assistant/module/PImportAssistantTC.java b/core/typechecker/src/main/java/org/overture/typechecker/assistant/module/PImportAssistantTC.java index bbdae03cb7..df5b96912b 100644 --- a/core/typechecker/src/main/java/org/overture/typechecker/assistant/module/PImportAssistantTC.java +++ b/core/typechecker/src/main/java/org/overture/typechecker/assistant/module/PImportAssistantTC.java @@ -44,7 +44,7 @@ public List getDefinitions(PImport imp, AModuleModules from) { try { - return imp.apply(af.getImportDefinitionFinder(), from);// FIXME: should we handle exceptions like this + return imp.apply(af.getImportDefinitionFinder(), from); } catch (AnalysisException e) { return null; diff --git a/core/typechecker/src/main/java/org/overture/typechecker/assistant/statement/PStmAssistantTC.java b/core/typechecker/src/main/java/org/overture/typechecker/assistant/statement/PStmAssistantTC.java index f7cc04b21e..be986ca47e 100644 --- a/core/typechecker/src/main/java/org/overture/typechecker/assistant/statement/PStmAssistantTC.java +++ b/core/typechecker/src/main/java/org/overture/typechecker/assistant/statement/PStmAssistantTC.java @@ -41,7 +41,7 @@ public PTypeSet exitCheck(PStm statement) { try { - return statement.apply(af.getExitTypeCollector());// FIXME: should we handle exceptions like this + return statement.apply(af.getExitTypeCollector()); } catch (AnalysisException e) { return new PTypeSet(af); diff --git a/core/typechecker/src/main/java/org/overture/typechecker/assistant/type/PTypeAssistantTC.java b/core/typechecker/src/main/java/org/overture/typechecker/assistant/type/PTypeAssistantTC.java index f5d9de532b..15c4d96f09 100644 --- a/core/typechecker/src/main/java/org/overture/typechecker/assistant/type/PTypeAssistantTC.java +++ b/core/typechecker/src/main/java/org/overture/typechecker/assistant/type/PTypeAssistantTC.java @@ -71,7 +71,7 @@ public boolean isType(PType type, Class typeclass) { try { - return type.apply(af.getPTypeExtendedChecker(), typeclass);// FIXME: should we handle exceptions like this + return type.apply(af.getPTypeExtendedChecker(), typeclass); } catch (AnalysisException e) { return false; @@ -108,7 +108,7 @@ public boolean isUnion(PType type) { try { - return type.apply(af.getUnionBasisChecker());// FIXME: should we handle exceptions like this + return type.apply(af.getUnionBasisChecker()); } catch (AnalysisException e) { return false; @@ -119,7 +119,7 @@ public AUnionType getUnion(PType type) { try { - return type.apply(af.getUnionTypeFinder());// FIXME: should we handle exceptions like this + return type.apply(af.getUnionTypeFinder()); } catch (AnalysisException e) { return null; @@ -130,7 +130,7 @@ public boolean isFunction(PType type) { try { - return type.apply(af.getPTypeFunctionChecker());// FIXME: should we handle exceptions like this + return type.apply(af.getPTypeFunctionChecker()); } catch (AnalysisException e) { return false; @@ -141,7 +141,7 @@ public AFunctionType getFunction(PType type) { try { - return type.apply(af.getFunctionTypeFinder());// FIXME: should we handle exceptions like this + return type.apply(af.getFunctionTypeFinder()); } catch (AnalysisException e) { return null; @@ -165,7 +165,7 @@ public void unResolve(PType type) { try { - type.apply(af.getTypeUnresolver());// FIXME: should we handle exceptions like this + type.apply(af.getTypeUnresolver()); } catch (AnalysisException e) { diff --git a/core/typechecker/src/main/java/org/overture/typechecker/visitor/TypeCheckerDefinitionVisitor.java b/core/typechecker/src/main/java/org/overture/typechecker/visitor/TypeCheckerDefinitionVisitor.java index 7dd5535736..4eeed792d0 100644 --- a/core/typechecker/src/main/java/org/overture/typechecker/visitor/TypeCheckerDefinitionVisitor.java +++ b/core/typechecker/src/main/java/org/overture/typechecker/visitor/TypeCheckerDefinitionVisitor.java @@ -24,6 +24,7 @@ import java.util.Collections; import java.util.List; import java.util.Vector; +import java.util.Map.Entry; import org.overture.ast.analysis.AnalysisException; import org.overture.ast.analysis.intf.IQuestionAnswer; @@ -1265,7 +1266,7 @@ public PType caseAPerSyncDefinition(APerSyncDefinition node, Boolean isStatic = null; List definitions = question.assistantFactory.createPDefinitionAssistant().getDefinitions(classdef); - + for (PDefinition def : definitions) { if (def.getName() != null @@ -1539,18 +1540,7 @@ public PType caseALetDefBindingTraceDefinition( ALetDefBindingTraceDefinition node, TypeCheckInfo question) throws AnalysisException { - Environment local = question.env; - for (PDefinition d : node.getLocalDefs()) - { - question.assistantFactory.createPDefinitionAssistant().typeResolve(d, THIS, question); - d.apply(THIS, question); - local = new FlatCheckedEnvironment(question.assistantFactory, d, local, question.scope); - } - - node.getBody().apply(THIS, new TypeCheckInfo(question.assistantFactory, local, question.scope)); - local.unusedCheck(question.env); - - return null; + return typeCheckLet(node, node.getLocalDefs(), node.getBody(), question); } @Override @@ -1558,37 +1548,25 @@ public PType caseALetBeStBindingTraceDefinition( ALetBeStBindingTraceDefinition node, TypeCheckInfo question) throws AnalysisException { - node.setDef(AstFactory.newAMultiBindListDefinition(node.getBind().getLocation(), question.assistantFactory.createPMultipleBindAssistant().getMultipleBindList(node.getBind()))); - node.getDef().apply(THIS, question); - Environment local = new FlatCheckedEnvironment(question.assistantFactory, node.getDef(), question.env, question.scope); - - if (node.getStexp() != null - && !question.assistantFactory.createPTypeAssistant().isType(node.getStexp().apply(THIS, new TypeCheckInfo(question.assistantFactory, local, question.scope)), ABooleanBasicType.class)) - { - TypeCheckerErrors.report(3225, "Such that clause is not boolean", node.getStexp().getLocation(), node); - } - - node.getBody().apply(THIS, new TypeCheckInfo(question.assistantFactory, local, question.scope)); - local.unusedCheck(); - - return null; + Entry res = typecheckLetBeSt(node, node.getLocation(), node.getBind(), node.getStexp(), node.getBody(), question); + node.setDef(res.getValue()); + return res.getKey(); } @Override public PType caseARepeatTraceDefinition(ARepeatTraceDefinition node, TypeCheckInfo question) throws AnalysisException { - // Environment local = question.env; - node.getCore().apply(THIS, question); - if (node.getFrom() > node.getTo()) { TypeCheckerErrors.report(3277, "Trace repeat illegal values", node.getLocation(), node); } - return null; + // Environment local = question.env; + return node.getCore().apply(THIS, question); + } - + @Override public PType caseAConcurrentExpressionTraceCoreDefinition( AConcurrentExpressionTraceCoreDefinition node, @@ -1598,7 +1576,7 @@ public PType caseAConcurrentExpressionTraceCoreDefinition( { d.apply(THIS, question); } - + return null; } @@ -1623,8 +1601,8 @@ public PType caseAApplyExpressionTraceCoreDefinition( AApplyExpressionTraceCoreDefinition node, TypeCheckInfo question) throws AnalysisException { - node.getCallStatement().apply(THIS, question); - return null; + return node.getCallStatement().apply(THIS, question); + } } diff --git a/core/vdmjc/pom.xml b/core/vdmjc/pom.xml index c48235aef3..37deb29acd 100644 --- a/core/vdmjc/pom.xml +++ b/core/vdmjc/pom.xml @@ -4,7 +4,7 @@ core org.overturetool - 2.2.0 + 2.2.2 org.overturetool.core diff --git a/documentation/releasenotes/ReleaseNotes_2.2.2.md b/documentation/releasenotes/ReleaseNotes_2.2.2.md new file mode 100644 index 0000000000..5fd8b9cbdd --- /dev/null +++ b/documentation/releasenotes/ReleaseNotes_2.2.2.md @@ -0,0 +1,80 @@ +# Overture 2.2.0 Release Notes — 27 February 2015 + +## What's New? + +This is a hotfix release that fixes critical bugs in the Combinatorial Testing +plug-in. + +## System Requirements + +Overture is based on the Eclipse platform. To run it, you must have a Java runtime system installed, version 7 or later. + +## Download & Installation + +Documentation, including tutorials and a language manual, are bundled in the download package, and are also available from the [Overture website](http://www.overturetool.org/). + +Overture can be downloaded from GitHub at . + +The download file is a ZIP archive. To install the tool, unzip the file in a convenient location. The main executable is in the top level directory, called `Overture`. + +We will be making an exe-based installer available for Windows user at a future point. + + +### Upgrading: + +* ATTENTION: If you are using the ZIP archive to update and if your workspace was located inside the previous installation directory, DO NOT FORGET TO BACKUP the workspace or it will be lost when the old version is deleted. +* If you are upgrading with the ZIP archive: do not unzip the latest version on top of the oldest one. You will need to delete the previous version before continuing the installation. + + +### Uninstalling + +To uninstall Overture, remove the contents of the directory where you installed it. There are no other files stored on the system, apart from any workspace files you may have created. + +For Windows users, if the Overture installer was used previously, it is possible to uninstall via the uninstall shortcut created by the installer in the start programs or via the Uninstall menu in the Control Panel. + + +## Reporting Problems and Troubleshooting + +Please report bugs, problems, and other issues with the tool at . + +If you encounter a problem with the Overture IDE itself, please contact the Overture project and we will try to help. You can contact us at info@overturetool.org, or use [StackOverflow](http://stackoverflow.com/questions/tagged/vdm%2b%2b) — we monitor for questions using the `vdm`, `vdm++`, or `vdmrt` tags. + +If you encounter a problem with a VDM specification, please try to make a small example that illustrates the problem before you contact us. If you are sure the bug is not already known in the GitHub issues list, you can create a new bug report. + + +## Frequently Asked Questions + +* Who's behind Overture? +> Overture was written by the members of the Overture project, a group of industry and academic researchers interested in the use of VDM. + +* How is Overture licensed? +> Overture is open source. It is released under a GPLv3 license. + +* What can I do to help? +> If you are interested in helping you can drop a mail to info@overturetool.org. You are also very welcome to fork our code on GitHub and send us pull requests. + +* Where is Overture source code? +> Overture source code is hosted by GitHub, within the [overturetool](https://github.com/overturetool) organisation account. + + +## Other Resources and Links + +* [Overture Community site](http://www.overturetool.org) +* [VDM Tutorials](http://overturetool.org/documentation/tutorials.html) +* [VDM Examples](http://overturetool.org/download/examples/) +* [Wikipedia on VDM](http://en.wikipedia.org/wiki/Vienna_Development_Method) +* [Overture Developers Wiki on GitHub](https://github.com/overturetool/overture/wiki/) +* [The Old Overture Wiki for developers](http://wiki.overturetool.org) + + +## Bug fixes + +Please note that the interactive list is at + +* [#418 Problem with code generator update site](https://github.com/overturetool/overture/issues/418) +* [#416 Problem with patterns in traces](https://github.com/overturetool/overture/issues/416) +* [#415 Tic-tac-toe CT errors in 2.2.0](https://github.com/overturetool/overture/issues/415) +* [#414 Problems running Overture with JDK/JRE 8 on Windows](https://github.com/overturetool/overture/issues/414) +* [#413 Problem running the SmokkingPP examples](https://github.com/overturetool/overture/issues/413) +* [#376 Scoping for traces does not work correctly](https://github.com/overturetool/overture/issues/376) + diff --git a/documentation/releasenotes/ReleaseNotes_2.2.2_abbrev.md b/documentation/releasenotes/ReleaseNotes_2.2.2_abbrev.md new file mode 100644 index 0000000000..2dba409884 --- /dev/null +++ b/documentation/releasenotes/ReleaseNotes_2.2.2_abbrev.md @@ -0,0 +1,37 @@ +# Overture 2.2.0 Release Notes — 27 February 2015 + +## What's New? + +This is a hotfix release that fixes critical bugs in the Combinatorial Testing +plug-in. + +## Reporting Problems and Troubleshooting + +Please report bugs, problems, and other issues with the tool at . + +If you encounter a problem with the Overture IDE itself, please contact the Overture project and we will try to help. You can contact us at info@overturetool.org, or use [StackOverflow](http://stackoverflow.com/questions/tagged/vdm%2b%2b) — we monitor for questions using the `vdm`, `vdm++`, or `vdmrt` tags. + +If you encounter a problem with a VDM specification, please try to make a small example that illustrates the problem before you contact us. If you are sure the bug is not already known in the GitHub issues list, you can create a new bug report. + + +## Other Resources and Links + +* [Overture Community site](http://www.overturetool.org) +* [VDM Tutorials](http://overturetool.org/documentation/tutorials.html) +* [VDM Examples](http://overturetool.org/download/examples/) +* [Wikipedia on VDM](http://en.wikipedia.org/wiki/Vienna_Development_Method) +* [Overture Developers Wiki on GitHub](https://github.com/overturetool/overture/wiki/) +* [The Old Overture Wiki for developers](http://wiki.overturetool.org) + + +## Bug fixes + +Please note that the interactive list is at + +* [#418 Problem with code generator update site](https://github.com/overturetool/overture/issues/418) +* [#416 Problem with patterns in traces](https://github.com/overturetool/overture/issues/416) +* [#415 Tic-tac-toe CT errors in 2.2.0](https://github.com/overturetool/overture/issues/415) +* [#414 Problems running Overture with JDK/JRE 8 on Windows](https://github.com/overturetool/overture/issues/414) +* [#413 Problem running the SmokkingPP examples](https://github.com/overturetool/overture/issues/413) +* [#376 Scoping for traces does not work correctly](https://github.com/overturetool/overture/issues/376) + diff --git a/externals/documentation/pom.xml b/externals/documentation/pom.xml index bbcbfe42ad..97fa0b26d2 100644 --- a/externals/documentation/pom.xml +++ b/externals/documentation/pom.xml @@ -4,7 +4,7 @@ org.overturetool externals - 2.2.0 + 2.2.2 ../pom.xml diff --git a/externals/examples/pom.xml b/externals/examples/pom.xml index d003be304c..9da1424a57 100644 --- a/externals/examples/pom.xml +++ b/externals/examples/pom.xml @@ -4,7 +4,7 @@ org.overturetool externals - 2.2.0 + 2.2.2 ../pom.xml diff --git a/externals/pom.xml b/externals/pom.xml index fc226b68c7..f23978a0a9 100644 --- a/externals/pom.xml +++ b/externals/pom.xml @@ -4,7 +4,7 @@ org.overturetool root - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/builders/pom.xml b/ide/builders/pom.xml index e1ce40baf8..63fb61f2ce 100644 --- a/ide/builders/pom.xml +++ b/ide/builders/pom.xml @@ -5,7 +5,7 @@ org.overturetool ide - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/builders/vdmj/META-INF/MANIFEST.MF b/ide/builders/vdmj/META-INF/MANIFEST.MF index c12f809116..ab1b11ea4d 100644 --- a/ide/builders/vdmj/META-INF/MANIFEST.MF +++ b/ide/builders/vdmj/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-Vendor: Overture Bundle-ActivationPolicy: lazy -Bundle-Version: 2.2.0 +Bundle-Version: 2.2.2 Eclipse-BuddyPolicy: registered Eclipse-BundleShape: dir Bundle-Localization: plugin diff --git a/ide/builders/vdmj/pom.xml b/ide/builders/vdmj/pom.xml index 539080df77..f16b05858f 100644 --- a/ide/builders/vdmj/pom.xml +++ b/ide/builders/vdmj/pom.xml @@ -4,7 +4,7 @@ org.overturetool.ide org.overture.ide.builders - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/core/META-INF/MANIFEST.MF b/ide/core/META-INF/MANIFEST.MF index 211ca6cd82..5661135d34 100644 --- a/ide/core/META-INF/MANIFEST.MF +++ b/ide/core/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-Vendor: Overture Bundle-ActivationPolicy: lazy -Bundle-Version: 2.2.0 +Bundle-Version: 2.2.2 Eclipse-BuddyPolicy: registered Eclipse-BundleShape: dir Bundle-Localization: plugin diff --git a/ide/core/pom.xml b/ide/core/pom.xml index 81e8f99381..611ddbab99 100644 --- a/ide/core/pom.xml +++ b/ide/core/pom.xml @@ -5,7 +5,7 @@ org.overturetool ide - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/debug/META-INF/MANIFEST.MF b/ide/debug/META-INF/MANIFEST.MF index 3b38d8d8b5..20b83b6ec6 100644 --- a/ide/debug/META-INF/MANIFEST.MF +++ b/ide/debug/META-INF/MANIFEST.MF @@ -1,6 +1,6 @@ Manifest-Version: 1.0 Bundle-Vendor: Overture -Bundle-Version: 2.2.0 +Bundle-Version: 2.2.2 Eclipse-BuddyPolicy: registered Eclipse-BundleShape: dir Bundle-Localization: plugin diff --git a/ide/debug/pom.xml b/ide/debug/pom.xml index e0ae4c5926..d33ce6605d 100644 --- a/ide/debug/pom.xml +++ b/ide/debug/pom.xml @@ -5,7 +5,7 @@ org.overturetool ide - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/features/core/feature.xml b/ide/features/core/feature.xml index c74e2dd7f3..93f9693d66 100644 --- a/ide/features/core/feature.xml +++ b/ide/features/core/feature.xml @@ -2,7 +2,7 @@ diff --git a/ide/features/core/pom.xml b/ide/features/core/pom.xml index 82cd3e18cc..0fcdfe5b45 100644 --- a/ide/features/core/pom.xml +++ b/ide/features/core/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide features - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/features/pom.xml b/ide/features/pom.xml index a74a318d6a..8e78cd4009 100644 --- a/ide/features/pom.xml +++ b/ide/features/pom.xml @@ -5,7 +5,7 @@ org.overturetool ide - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/features/rcp/feature.xml b/ide/features/rcp/feature.xml index 3cfba31e35..9a5a333c3b 100644 --- a/ide/features/rcp/feature.xml +++ b/ide/features/rcp/feature.xml @@ -2,7 +2,7 @@ + version="2.2.2"> %description diff --git a/ide/features/rcp/pom.xml b/ide/features/rcp/pom.xml index 6fa6e17b4a..be9e2b65d4 100644 --- a/ide/features/rcp/pom.xml +++ b/ide/features/rcp/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide features - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/help/META-INF/MANIFEST.MF b/ide/help/META-INF/MANIFEST.MF index c457bb4632..7b0198faa3 100644 --- a/ide/help/META-INF/MANIFEST.MF +++ b/ide/help/META-INF/MANIFEST.MF @@ -1,6 +1,6 @@ Manifest-Version: 1.0 Bundle-Vendor: Overture -Bundle-Version: 2.2.0 +Bundle-Version: 2.2.2 Eclipse-BuddyPolicy: registered Eclipse-BundleShape: dir Bundle-Localization: plugin diff --git a/ide/help/pom.xml b/ide/help/pom.xml index 7ce8ac6772..af0a77c6fb 100644 --- a/ide/help/pom.xml +++ b/ide/help/pom.xml @@ -5,7 +5,7 @@ org.overturetool ide - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/parsers/pom.xml b/ide/parsers/pom.xml index 803f11f8e8..0bb7b6c976 100644 --- a/ide/parsers/pom.xml +++ b/ide/parsers/pom.xml @@ -5,7 +5,7 @@ org.overturetool ide - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/parsers/vdmj/META-INF/MANIFEST.MF b/ide/parsers/vdmj/META-INF/MANIFEST.MF index 01a5a4db0b..a4387d3d9c 100644 --- a/ide/parsers/vdmj/META-INF/MANIFEST.MF +++ b/ide/parsers/vdmj/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-Vendor: Overture Bundle-ActivationPolicy: lazy -Bundle-Version: 2.2.0 +Bundle-Version: 2.2.2 Eclipse-BuddyPolicy: registered Bundle-Localization: plugin Bundle-Name: org.overture.ide.parsers.vdmj diff --git a/ide/parsers/vdmj/pom.xml b/ide/parsers/vdmj/pom.xml index 0440451722..8367e3ce11 100644 --- a/ide/parsers/vdmj/pom.xml +++ b/ide/parsers/vdmj/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide org.overture.ide.parsers - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/platform/META-INF/MANIFEST.MF b/ide/platform/META-INF/MANIFEST.MF index e10a566c09..714967b0a4 100644 --- a/ide/platform/META-INF/MANIFEST.MF +++ b/ide/platform/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: org.overture.ide.platform Bundle-SymbolicName: org.overture.ide.platform;singleton:=true -Bundle-Version: 2.2.0 +Bundle-Version: 2.2.2 Bundle-Localization: plugin Require-Bundle: org.eclipse.core.runtime, org.eclipse.ui, diff --git a/ide/platform/pom.xml b/ide/platform/pom.xml index 5b757a2b89..e5b80cd368 100644 --- a/ide/platform/pom.xml +++ b/ide/platform/pom.xml @@ -5,7 +5,7 @@ org.overturetool ide - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/plugins/codegen/META-INF/MANIFEST.MF b/ide/plugins/codegen/META-INF/MANIFEST.MF index 7c9e8e14a9..fd5065243a 100644 --- a/ide/plugins/codegen/META-INF/MANIFEST.MF +++ b/ide/plugins/codegen/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-Vendor: Overture Bundle-ActivationPolicy: lazy -Bundle-Version: 2.2.0 +Bundle-Version: 2.2.2 Eclipse-BuddyPolicy: registered Bundle-Name: Code Generator Bundle-ManifestVersion: 2 diff --git a/ide/plugins/codegen/build.properties b/ide/plugins/codegen/build.properties index 4359f35676..22229cd04a 100644 --- a/ide/plugins/codegen/build.properties +++ b/ide/plugins/codegen/build.properties @@ -3,6 +3,7 @@ bin.includes = META-INF/,\ plugin.xml,\ .,\ textfiles/,\ + eclipsefiles/,\ icons/,\ jars/ diff --git a/ide/plugins/codegen/eclipsefiles/cg.classpath b/ide/plugins/codegen/eclipsefiles/cg.classpath new file mode 100644 index 0000000000..ea32e05f55 --- /dev/null +++ b/ide/plugins/codegen/eclipsefiles/cg.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/ide/plugins/codegen/eclipsefiles/cg.project b/ide/plugins/codegen/eclipsefiles/cg.project new file mode 100644 index 0000000000..68ffe98696 --- /dev/null +++ b/ide/plugins/codegen/eclipsefiles/cg.project @@ -0,0 +1,17 @@ + + + %s + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/ide/plugins/codegen/pom.xml b/ide/plugins/codegen/pom.xml index 7674efcdce..61638f7664 100644 --- a/ide/plugins/codegen/pom.xml +++ b/ide/plugins/codegen/pom.xml @@ -1,118 +1,176 @@ - 4.0.0 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + 4.0.0 - - org.overturetool.ide - org.overture.ide.plugins - 2.2.0 - ../pom.xml - + + org.overturetool.ide + org.overture.ide.plugins + 2.2.2 + ../pom.xml + - eclipse-plugin + eclipse-plugin - org.overturetool.ide.plugins - org.overture.ide.plugins.codegen - Code Generator Plugin - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-dependencies - process-sources - - copy - - - ${basedir}/jars - true - true - true - true - - - org.overturetool.core - codegen - ${project.version} - - - org.apache.velocity - velocity - 1.7 - - - commons-collections - commons-collections - 3.2.1 - - - commons-lang - commons-lang - 2.4 - - - jalopy - jalopy - 1.5rc3 - - - log4j - log4j - 1.2.8 - - - - - - - - org.apache.maven.plugins - maven-clean-plugin - - false - - - ${basedir}/jars - false - - - - - + org.overturetool.ide.plugins + org.overture.ide.plugins.codegen + Code Generator Plugin - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - org.apache.maven.plugins - maven-dependency-plugin - [1.0.0,) - - copy - - - - - false - - - - - - - - - - + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + process-sources + + copy + + + ${basedir}/jars + true + true + true + true + + + org.overturetool.core + codegen-runtime + ${project.version} + + + org.overturetool.core + codegen + ${project.version} + + + org.apache.velocity + velocity + 1.7 + + + commons-collections + commons-collections + 3.2.1 + + + commons-lang + commons-lang + 2.4 + + + jalopy + jalopy + 1.5rc3 + + + log4j + log4j + 1.2.8 + + + + + + copy + process-resources + + copy + + + + + org.overturetool.core + codegen-runtime + ${project.version} + jar + true + ${basedir}/target/runtime + codegen-runtime.jar + + + org.overturetool.core + codegen-runtime + ${project.version} + sources + jar + true + ${basedir}/target/runtime + codegen-runtime-sources.jar + + + + + + + + + maven-resources-plugin + + + copy-resources + process-classes + + copy-resources + + + ${project.build.outputDirectory} + + + ${basedir}/target/runtime + false + + + + + + + + + org.apache.maven.plugins + maven-clean-plugin + + false + + + ${basedir}/jars + false + + + + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.apache.maven.plugins + maven-dependency-plugin + [1.0.0,) + + copy + + + + + false + + + + + + + + + + diff --git a/ide/plugins/codegen/src/main/java/org/overture/ide/plugins/codegen/commands/Vdm2JavaCommand.java b/ide/plugins/codegen/src/main/java/org/overture/ide/plugins/codegen/commands/Vdm2JavaCommand.java index f31901985a..72f32135df 100644 --- a/ide/plugins/codegen/src/main/java/org/overture/ide/plugins/codegen/commands/Vdm2JavaCommand.java +++ b/ide/plugins/codegen/src/main/java/org/overture/ide/plugins/codegen/commands/Vdm2JavaCommand.java @@ -53,6 +53,7 @@ import org.overture.codegen.ir.IrNodeInfo; import org.overture.codegen.ir.VdmNodeInfo; import org.overture.codegen.utils.AnalysisExceptionCG; +import org.overture.codegen.utils.GeneralCodeGenUtils; import org.overture.codegen.utils.GeneralUtils; import org.overture.codegen.utils.GeneratedData; import org.overture.codegen.utils.GeneratedModule; @@ -196,9 +197,11 @@ protected IStatus run(IProgressMonitor monitor) outputUserSpecifiedSkippedClasses(classesToSkip); outputSkippedClasses(generatedData.getSkippedClasses()); + File javaOutputFolder = new File(outputFolder, PluginVdm2JavaUtil.CODEGEN_RUNTIME_SRC_FOLDER_NAME); + try { - vdm2java.generateJavaSourceFiles(outputFolder, generatedData.getClasses()); + vdm2java.generateJavaSourceFiles(javaOutputFolder, generatedData.getClasses()); } catch (Exception e) { CodeGenConsole.GetInstance().printErrorln("Problems saving the code generated Java source files to disk."); @@ -215,10 +218,53 @@ protected IStatus run(IProgressMonitor monitor) return Status.CANCEL_STATUS; } - outputUserspecifiedModules(outputFolder, generatedData.getClasses()); + File libFolder = new File(outputFolder, PluginVdm2JavaUtil.CODEGEN_RUNTIME_LIB_FOLDER_NAME); + try + { + PluginVdm2JavaUtil.copyCodeGenFile(PluginVdm2JavaUtil.CODEGEN_RUNTIME_BIN_FILE_NAME, libFolder); + outputRuntimeBinaries(libFolder); + } + catch(Exception e) + { + CodeGenConsole.GetInstance().printErrorln("Problems copying the Java code generator runtime library to " + outputFolder.getAbsolutePath()); + CodeGenConsole.GetInstance().printErrorln("Reason: " + e.getMessage()); + } + + try + { + PluginVdm2JavaUtil.copyCodeGenFile(PluginVdm2JavaUtil.CODEGEN_RUNTIME_SOURCES_FILE_NAME, libFolder); + outputRuntimeSources(libFolder); + } + catch(Exception e) + { + CodeGenConsole.GetInstance().printErrorln("Problems copying the Java code generator runtime library sources to " + outputFolder.getAbsolutePath()); + CodeGenConsole.GetInstance().printErrorln("Reason: " + e.getMessage()); + } + + try + { + PluginVdm2JavaUtil.copyCodeGenFile(PluginVdm2JavaUtil.ECLIPSE_RES_FILES_FOLDER_NAME + "/" + + PluginVdm2JavaUtil.ECLIPSE_PROJECT_TEMPLATE_FILE_NAME, PluginVdm2JavaUtil.ECLIPSE_PROJECT_FILE_NAME, outputFolder); + PluginVdm2JavaUtil.copyCodeGenFile(PluginVdm2JavaUtil.ECLIPSE_RES_FILES_FOLDER_NAME + "/" + + PluginVdm2JavaUtil.ECLIPSE_CLASSPATH_TEMPLATE_FILE_NAME, PluginVdm2JavaUtil.ECLIPSE_CLASSPATH_FILE_NAME, outputFolder); + + GeneralCodeGenUtils.replaceInFile(new File(outputFolder, PluginVdm2JavaUtil.ECLIPSE_PROJECT_FILE_NAME), "%s", project.getName()); + + CodeGenConsole.GetInstance().println("Generated Eclipse project with Java generated code.\n"); + + } catch (Exception e) + { + e.printStackTrace(); + CodeGenConsole.GetInstance().printErrorln("Problems generating the eclipse project with the generated Java code"); + CodeGenConsole.GetInstance().printErrorln("Reason: " + + e.getMessage()); + } + + outputUserspecifiedModules(javaOutputFolder, generatedData.getClasses()); // Quotes generation - outputQuotes(vdmProject, outputFolder, vdm2java, generatedData.getQuoteValues()); + outputQuotes(vdmProject, new File(javaOutputFolder, PluginVdm2JavaUtil.QUOTES_FOLDER), + vdm2java, generatedData.getQuoteValues()); // Renaming of variables shadowing other variables outputRenamings(generatedData.getAllRenamings()); @@ -322,6 +368,18 @@ private void outputRenamings(List allRenamings) CodeGenConsole.GetInstance().println(JavaCodeGenUtil.constructVarRenamingString(allRenamings));; } } + + private void outputRuntimeBinaries(File outputFolder) + { + File runtime = new File(outputFolder, PluginVdm2JavaUtil.CODEGEN_RUNTIME_BIN_FILE_NAME); + CodeGenConsole.GetInstance().println("Copied the Java code generator runtime library to " + runtime.getAbsolutePath() + "\n"); + } + + private void outputRuntimeSources(File outputFolder) + { + File runtime = new File(outputFolder, PluginVdm2JavaUtil.CODEGEN_RUNTIME_SOURCES_FILE_NAME); + CodeGenConsole.GetInstance().println("Copied the Java code generator runtime library sources to " + runtime.getAbsolutePath() + "\n"); + } private void outputUserspecifiedModules(File outputFolder, List userspecifiedClasses) @@ -348,7 +406,7 @@ private void outputUserspecifiedModules(File outputFolder, LocationAssistantCG locationAssistant = assistantManager.getLocationAssistant(); List unsupportedInIr = locationAssistant.getVdmNodeInfoLocationSorted(generatedModule.getUnsupportedInIr()); - CodeGenConsole.GetInstance().println("Following VDM constructs are not supported by the IR: "); + CodeGenConsole.GetInstance().println("Following VDM constructs are not supported by the code generator:"); for (VdmNodeInfo nodeInfo : unsupportedInIr) { @@ -362,7 +420,7 @@ private void outputUserspecifiedModules(File outputFolder, if(generatedModule.hasUnsupportedTargLangNodes()) { Set unsupportedInTargLang = generatedModule.getUnsupportedInTargLang(); - CodeGenConsole.GetInstance().println("Following constructs are not supported by the backend/target language:"); + CodeGenConsole.GetInstance().println("Following constructs are not supported by the code generator:"); for (IrNodeInfo nodeInfo : unsupportedInTargLang) { @@ -383,7 +441,7 @@ private void outputUserspecifiedModules(File outputFolder, if(!warnings.isEmpty()) { - CodeGenConsole.GetInstance().println("The following transformation warnings were found for class " + generatedModule.getName() + ":"); + CodeGenConsole.GetInstance().println("The following warnings were found for class " + generatedModule.getName() + ":"); for (IrNodeInfo nodeInfo : warnings) { @@ -402,15 +460,13 @@ private void outputQuotes(IVdmProject vdmProject, File outputFolder, { if (quotes != null && !quotes.isEmpty()) { - File quotesFolder = PluginVdm2JavaUtil.getQuotesFolder(vdmProject); - for(GeneratedModule q : quotes) { - vdm2java.generateJavaSourceFile(quotesFolder, q); + vdm2java.generateJavaSourceFile(outputFolder, q); } CodeGenConsole.GetInstance().println("Quotes generated to folder: " - + quotesFolder.getAbsolutePath()); + + outputFolder.getAbsolutePath()); CodeGenConsole.GetInstance().println(""); } } diff --git a/ide/plugins/codegen/src/main/java/org/overture/ide/plugins/codegen/util/PluginVdm2JavaUtil.java b/ide/plugins/codegen/src/main/java/org/overture/ide/plugins/codegen/util/PluginVdm2JavaUtil.java index aa2fefd940..3f0d4b0943 100644 --- a/ide/plugins/codegen/src/main/java/org/overture/ide/plugins/codegen/util/PluginVdm2JavaUtil.java +++ b/ide/plugins/codegen/src/main/java/org/overture/ide/plugins/codegen/util/PluginVdm2JavaUtil.java @@ -22,6 +22,10 @@ package org.overture.ide.plugins.codegen.util; import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -53,13 +57,24 @@ import org.overture.ide.core.resources.IVdmSourceUnit; import org.overture.ide.core.utility.FileUtility; import org.overture.ide.plugins.codegen.ICodeGenConstants; +import org.overture.ide.plugins.codegen.commands.Vdm2JavaCommand; public class PluginVdm2JavaUtil { - private static final String JAVA_FOLDER = "java"; - private static final String QUOTES_FOLDER = "quotes"; - private static final String UTILS_FOLDER = "utils"; + public static final String JAVA_FOLDER = "java"; + public static final String QUOTES_FOLDER = "quotes"; + public static final String UTILS_FOLDER = "utils"; + public static final String CODEGEN_RUNTIME_BIN_FILE_NAME = "codegen-runtime.jar"; + public static final String CODEGEN_RUNTIME_SOURCES_FILE_NAME = "codegen-runtime-sources.jar"; + public static final String ECLIPSE_CLASSPATH_TEMPLATE_FILE_NAME = "cg.classpath"; + public static final String ECLIPSE_PROJECT_TEMPLATE_FILE_NAME = "cg.project"; + public static final String ECLIPSE_CLASSPATH_FILE_NAME = ".classpath"; + public static final String ECLIPSE_PROJECT_FILE_NAME = ".project"; + public static final String ECLIPSE_RES_FILES_FOLDER_NAME = "eclipsefiles"; + public static final String CODEGEN_RUNTIME_SRC_FOLDER_NAME = "src"; + public static final String CODEGEN_RUNTIME_LIB_FOLDER_NAME = "lib"; + private PluginVdm2JavaUtil() { } @@ -241,6 +256,45 @@ private static File getFolder(File parent, String folder) return resultingFolder; } + public static void copyCodeGenFile(String inOutFileName, File outputFolder) throws IOException + { + copyCodeGenFile(inOutFileName, inOutFileName, outputFolder); + } + + public static void copyCodeGenFile(String inputFileName, String outputFileName, File outputFolder) throws IOException + { + InputStream input = Vdm2JavaCommand.class.getResourceAsStream('/' + inputFileName); + + if(input == null) + { + throw new IOException("Could not find resource: " + inputFileName); + } + + byte[] buffer = new byte[8 * 1024]; + + try { + File outputFile = new File(outputFolder, outputFileName); + + outputFile.getParentFile().mkdirs(); + if(!outputFile.exists()) + { + outputFile.createNewFile(); + } + + OutputStream output = new FileOutputStream(outputFile); + try { + int bytesRead; + while ((bytesRead = input.read(buffer)) != -1) { + output.write(buffer, 0, bytesRead); + } + } finally { + output.close(); + } + } finally { + input.close(); + } + } + public static List getClassesToSkip() { Preferences preferences = InstanceScope.INSTANCE.getNode(ICodeGenConstants.PLUGIN_ID); diff --git a/ide/plugins/combinatorialtesting/META-INF/MANIFEST.MF b/ide/plugins/combinatorialtesting/META-INF/MANIFEST.MF index e3309753e1..fe77506e7b 100644 --- a/ide/plugins/combinatorialtesting/META-INF/MANIFEST.MF +++ b/ide/plugins/combinatorialtesting/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-Vendor: Overture Bundle-ActivationPolicy: lazy -Bundle-Version: 2.2.0 +Bundle-Version: 2.2.2 Eclipse-BuddyPolicy: registered Eclipse-BundleShape: dir Bundle-Localization: plugin diff --git a/ide/plugins/combinatorialtesting/pom.xml b/ide/plugins/combinatorialtesting/pom.xml index 95451856ba..a7b743723a 100644 --- a/ide/plugins/combinatorialtesting/pom.xml +++ b/ide/plugins/combinatorialtesting/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide org.overture.ide.plugins - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/plugins/combinatorialtesting/src/main/java/org/overture/ide/plugins/combinatorialtesting/OvertureTracesPlugin.java b/ide/plugins/combinatorialtesting/src/main/java/org/overture/ide/plugins/combinatorialtesting/OvertureTracesPlugin.java index 4a1cf86c9e..18e408deec 100644 --- a/ide/plugins/combinatorialtesting/src/main/java/org/overture/ide/plugins/combinatorialtesting/OvertureTracesPlugin.java +++ b/ide/plugins/combinatorialtesting/src/main/java/org/overture/ide/plugins/combinatorialtesting/OvertureTracesPlugin.java @@ -27,6 +27,7 @@ import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; +import org.overture.ide.debug.core.IDebugConstants; /** * The activator class controls the plug-in life cycle @@ -151,6 +152,8 @@ public static void initializeDefaultMainPreferences(IPreferenceStore store) store.setDefault(ITracesConstants.TRACE_REDUCTION_TYPE, ITracesConstants.TRACE_REDUCTION_DEFAULT_TYPE); store.setDefault(ITracesConstants.TRACE_SEED, ITracesConstants.TRACE_FILTERING_DEFAULT_SEED); store.setDefault(ITracesConstants.TRACE_SUBSET_LIMITATION, ITracesConstants.TRACE_SUBSET_LIMITATION_DEFAULT); + store.setDefault(IDebugConstants.VDM_LAUNCH_CONFIG_VM_MEMORY_OPTION, ""); + } } diff --git a/ide/plugins/combinatorialtesting/src/main/java/org/overture/ide/plugins/combinatorialtesting/internal/TestEngineDelegate.java b/ide/plugins/combinatorialtesting/src/main/java/org/overture/ide/plugins/combinatorialtesting/internal/TestEngineDelegate.java index 3f7bade52a..cd87132606 100644 --- a/ide/plugins/combinatorialtesting/src/main/java/org/overture/ide/plugins/combinatorialtesting/internal/TestEngineDelegate.java +++ b/ide/plugins/combinatorialtesting/src/main/java/org/overture/ide/plugins/combinatorialtesting/internal/TestEngineDelegate.java @@ -38,6 +38,7 @@ import org.overture.combinatorialtesting.vdmj.server.common.Utils; import org.overture.ide.core.resources.IVdmProject; import org.overture.ide.core.resources.IVdmSourceUnit; +import org.overture.ide.debug.core.IDebugConstants; import org.overture.ide.debug.core.IDebugPreferenceConstants; import org.overture.ide.debug.core.VdmDebugPlugin; import org.overture.ide.debug.core.launching.VdmLaunchConfigurationDelegate; @@ -191,7 +192,22 @@ private List initializeLaunch(TraceExecutionSetup texe, private Collection getVmArguments( IPreferenceStore preferences) { - return new Vector(); + List options = new Vector(); + String opt = preferences.getString(IDebugConstants.VDM_LAUNCH_CONFIG_VM_MEMORY_OPTION); + if (opt.trim().length() != 0) + { + String[] opts = opt.split(" "); + for (String o : opts) + { + o = o.trim(); + if (o.startsWith("-")) + { + options.add(o); + } + } + } + + return options; } private synchronized int getSessionId() diff --git a/ide/plugins/combinatorialtesting/src/main/java/org/overture/ide/plugins/combinatorialtesting/internal/TraceTestEngine.java b/ide/plugins/combinatorialtesting/src/main/java/org/overture/ide/plugins/combinatorialtesting/internal/TraceTestEngine.java index 8baad12e69..ae6f8ab918 100644 --- a/ide/plugins/combinatorialtesting/src/main/java/org/overture/ide/plugins/combinatorialtesting/internal/TraceTestEngine.java +++ b/ide/plugins/combinatorialtesting/src/main/java/org/overture/ide/plugins/combinatorialtesting/internal/TraceTestEngine.java @@ -22,6 +22,7 @@ package org.overture.ide.plugins.combinatorialtesting.internal; import java.io.File; +import java.util.concurrent.TimeUnit; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; @@ -53,7 +54,7 @@ public void launch(final TraceExecutionSetup texe, @Override protected IStatus run(final IProgressMonitor monitor) { - monitor.beginTask("Executing trace: "+texe.traceName, 100); + monitor.beginTask("Executing trace: " + texe.traceName, 100); IPreferenceStore preferences = OvertureTracesPlugin.getDefault().getPreferenceStore(); if (!texe.coverageFolder.exists() @@ -75,6 +76,9 @@ protected IStatus run(final IProgressMonitor monitor) { port = 1213; } + + final long startTime = System.currentTimeMillis(); + conn = new ConnectionListener(port, new IClientMonitor() { int worked = 0; @@ -94,29 +98,43 @@ public void initialize(String module) public void progress(String traceName, Integer progress) { + long millis = System.currentTimeMillis() + - startTime; + + String elapsed = String.format("%d min, %d sec.", TimeUnit.MILLISECONDS.toMinutes(millis), TimeUnit.MILLISECONDS.toSeconds(millis) + - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis))); + out.println(texe.project.getName() + ":" - + traceName + " Worked " + progress + "%"); + + traceName + " Worked " + progress + + "%. Time elapsed: " + elapsed); - int tmp = progress-worked; + int tmp = progress - worked; if (worked == 0) { worked = progress; } else { - worked = progress ; + worked = progress; } if (tmp > 100) { - tmp= 100; + tmp = 100; } monitor.worked(tmp); } public void completed() { + long millis = System.currentTimeMillis() + - startTime; + + String elapsed = String.format("%d min, %d sec.", TimeUnit.MILLISECONDS.toMinutes(millis), TimeUnit.MILLISECONDS.toSeconds(millis) + - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis))); + out.println(texe.project.getName() - + " Completed execution"); + + " Completed execution. Time elapsed: " + + elapsed); monitor.done(); display.updateView(texe.project); diff --git a/ide/plugins/combinatorialtesting/src/main/java/org/overture/ide/plugins/combinatorialtesting/preferences/WorkbenchPreferencePageMain.java b/ide/plugins/combinatorialtesting/src/main/java/org/overture/ide/plugins/combinatorialtesting/preferences/WorkbenchPreferencePageMain.java index 282e170dad..39a913390e 100644 --- a/ide/plugins/combinatorialtesting/src/main/java/org/overture/ide/plugins/combinatorialtesting/preferences/WorkbenchPreferencePageMain.java +++ b/ide/plugins/combinatorialtesting/src/main/java/org/overture/ide/plugins/combinatorialtesting/preferences/WorkbenchPreferencePageMain.java @@ -29,8 +29,10 @@ import org.eclipse.jface.preference.FieldEditorPreferencePage; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.IntegerFieldEditor; +import org.eclipse.jface.preference.StringFieldEditor; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; +import org.overture.ide.debug.core.IDebugConstants; import org.overture.ide.plugins.combinatorialtesting.ITracesConstants; import org.overture.ide.plugins.combinatorialtesting.OvertureTracesPlugin; import org.overture.interpreter.traces.TraceReductionType; @@ -82,6 +84,8 @@ protected void createFieldEditors() IntegerFieldEditor subsetLimitation = new IntegerFieldEditor(ITracesConstants.TRACE_SUBSET_LIMITATION, "Subset limitation (%)", getFieldEditorParent()); subsetLimitation.setValidRange(1, 100); addField(subsetLimitation); + + addField(new StringFieldEditor(IDebugConstants.VDM_LAUNCH_CONFIG_VM_MEMORY_OPTION, "Additional VM arguments:", getFieldEditorParent())); } @Override diff --git a/ide/plugins/coverageeditor/META-INF/MANIFEST.MF b/ide/plugins/coverageeditor/META-INF/MANIFEST.MF index 5c6a28c8ca..a23aba0b6f 100644 --- a/ide/plugins/coverageeditor/META-INF/MANIFEST.MF +++ b/ide/plugins/coverageeditor/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-Vendor: Overture Bundle-ActivationPolicy: lazy -Bundle-Version: 2.2.0 +Bundle-Version: 2.2.2 Eclipse-BuddyPolicy: registered Bundle-Localization: plugin Bundle-Name: org.overture.ide.plugins.coverageeditor diff --git a/ide/plugins/coverageeditor/pom.xml b/ide/plugins/coverageeditor/pom.xml index b7332d448b..81fdc83175 100644 --- a/ide/plugins/coverageeditor/pom.xml +++ b/ide/plugins/coverageeditor/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide org.overture.ide.plugins - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/plugins/csk/META-INF/MANIFEST.MF b/ide/plugins/csk/META-INF/MANIFEST.MF index 240ec9e84f..a17e91e2a6 100644 --- a/ide/plugins/csk/META-INF/MANIFEST.MF +++ b/ide/plugins/csk/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-Vendor: Overture Bundle-ActivationPolicy: lazy -Bundle-Version: 2.2.0 +Bundle-Version: 2.2.2 Eclipse-BuddyPolicy: registered Bundle-Localization: plugin Bundle-Name: org.overture.ide.plugins.csk diff --git a/ide/plugins/csk/pom.xml b/ide/plugins/csk/pom.xml index a9c5d37899..47215b75cf 100644 --- a/ide/plugins/csk/pom.xml +++ b/ide/plugins/csk/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide org.overture.ide.plugins - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/plugins/developerutils/META-INF/MANIFEST.MF b/ide/plugins/developerutils/META-INF/MANIFEST.MF index 166415a628..b8f031d046 100644 --- a/ide/plugins/developerutils/META-INF/MANIFEST.MF +++ b/ide/plugins/developerutils/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-Vendor: Overture Bundle-ActivationPolicy: lazy -Bundle-Version: 2.2.0 +Bundle-Version: 2.2.2 Eclipse-BuddyPolicy: registered Bundle-Localization: plugin Bundle-Name: Developer Utilities for Overture diff --git a/ide/plugins/developerutils/pom.xml b/ide/plugins/developerutils/pom.xml index 70619e5eb7..80d94f4bc6 100644 --- a/ide/plugins/developerutils/pom.xml +++ b/ide/plugins/developerutils/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide org.overture.ide.plugins - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/plugins/externaleditor/META-INF/MANIFEST.MF b/ide/plugins/externaleditor/META-INF/MANIFEST.MF index d126cbbdea..4b42f397e0 100644 --- a/ide/plugins/externaleditor/META-INF/MANIFEST.MF +++ b/ide/plugins/externaleditor/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-Vendor: Overture Bundle-ActivationPolicy: lazy -Bundle-Version: 2.2.0 +Bundle-Version: 2.2.2 Eclipse-BuddyPolicy: registered Bundle-Localization: plugin Bundle-Name: org.overture.ide.plugins.externaleditor diff --git a/ide/plugins/externaleditor/pom.xml b/ide/plugins/externaleditor/pom.xml index a88325fab6..8bace15f06 100644 --- a/ide/plugins/externaleditor/pom.xml +++ b/ide/plugins/externaleditor/pom.xml @@ -4,7 +4,7 @@ org.overturetool.ide org.overture.ide.plugins - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/plugins/features/codegen/feature.xml b/ide/plugins/features/codegen/feature.xml index 6920f86697..40e0b95a1e 100644 --- a/ide/plugins/features/codegen/feature.xml +++ b/ide/plugins/features/codegen/feature.xml @@ -2,7 +2,7 @@ + version="2.2.2"> %description @@ -16,14 +16,6 @@ %agreement - - - - diff --git a/ide/plugins/features/codegen/pom.xml b/ide/plugins/features/codegen/pom.xml index e3ef079505..f518fe50a4 100644 --- a/ide/plugins/features/codegen/pom.xml +++ b/ide/plugins/features/codegen/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide.plugins org.overture.ide.plugins.features - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/plugins/features/combinatorialtesting/feature.xml b/ide/plugins/features/combinatorialtesting/feature.xml index 97713a6deb..2f678e6ca1 100644 --- a/ide/plugins/features/combinatorialtesting/feature.xml +++ b/ide/plugins/features/combinatorialtesting/feature.xml @@ -2,7 +2,7 @@ + version="2.2.2"> %description diff --git a/ide/plugins/features/combinatorialtesting/pom.xml b/ide/plugins/features/combinatorialtesting/pom.xml index ca04e636bd..96931aedaf 100644 --- a/ide/plugins/features/combinatorialtesting/pom.xml +++ b/ide/plugins/features/combinatorialtesting/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide.plugins org.overture.ide.plugins.features - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/plugins/features/coverageeditor/feature.xml b/ide/plugins/features/coverageeditor/feature.xml index 1cf1a47682..113422d83a 100644 --- a/ide/plugins/features/coverageeditor/feature.xml +++ b/ide/plugins/features/coverageeditor/feature.xml @@ -2,7 +2,7 @@ + version="2.2.2"> %description diff --git a/ide/plugins/features/coverageeditor/pom.xml b/ide/plugins/features/coverageeditor/pom.xml index 493c26a0fa..a3c0329a96 100644 --- a/ide/plugins/features/coverageeditor/pom.xml +++ b/ide/plugins/features/coverageeditor/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide.plugins org.overture.ide.plugins.features - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/plugins/features/csk/feature.xml b/ide/plugins/features/csk/feature.xml index 0c4995d896..2019088f6b 100644 --- a/ide/plugins/features/csk/feature.xml +++ b/ide/plugins/features/csk/feature.xml @@ -2,7 +2,7 @@ + version="2.2.2"> %description diff --git a/ide/plugins/features/csk/pom.xml b/ide/plugins/features/csk/pom.xml index 47b069db4d..8fa7b8eb7c 100644 --- a/ide/plugins/features/csk/pom.xml +++ b/ide/plugins/features/csk/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide.plugins org.overture.ide.plugins.features - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/plugins/features/developerutils/feature.xml b/ide/plugins/features/developerutils/feature.xml index 28edbaa4fd..3c12b3ecdb 100644 --- a/ide/plugins/features/developerutils/feature.xml +++ b/ide/plugins/features/developerutils/feature.xml @@ -2,7 +2,7 @@ + version="2.2.2"> %description diff --git a/ide/plugins/features/developerutils/pom.xml b/ide/plugins/features/developerutils/pom.xml index 69b642e0ab..20b3fc56aa 100644 --- a/ide/plugins/features/developerutils/pom.xml +++ b/ide/plugins/features/developerutils/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide.plugins org.overture.ide.plugins.features - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/plugins/features/guibuilder/feature.xml b/ide/plugins/features/guibuilder/feature.xml index 2cde159c71..23122ced4a 100644 --- a/ide/plugins/features/guibuilder/feature.xml +++ b/ide/plugins/features/guibuilder/feature.xml @@ -2,7 +2,7 @@ + version="2.2.2"> %description diff --git a/ide/plugins/features/guibuilder/pom.xml b/ide/plugins/features/guibuilder/pom.xml index e224cef4ab..a6b5e43c59 100644 --- a/ide/plugins/features/guibuilder/pom.xml +++ b/ide/plugins/features/guibuilder/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide.plugins org.overture.ide.plugins.features - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/plugins/features/latex/feature.xml b/ide/plugins/features/latex/feature.xml index a1310dde55..c70c4b83cd 100644 --- a/ide/plugins/features/latex/feature.xml +++ b/ide/plugins/features/latex/feature.xml @@ -2,7 +2,7 @@ + version="2.2.2"> %description diff --git a/ide/plugins/features/latex/pom.xml b/ide/plugins/features/latex/pom.xml index d7dbdd4344..4507e9e2c1 100644 --- a/ide/plugins/features/latex/pom.xml +++ b/ide/plugins/features/latex/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide.plugins org.overture.ide.plugins.features - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/plugins/features/pom.xml b/ide/plugins/features/pom.xml index 27d8d87a83..c8762f2d1d 100644 --- a/ide/plugins/features/pom.xml +++ b/ide/plugins/features/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide org.overture.ide.plugins - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/plugins/features/poviewer/feature.xml b/ide/plugins/features/poviewer/feature.xml index 02b3fb3704..b465b49670 100644 --- a/ide/plugins/features/poviewer/feature.xml +++ b/ide/plugins/features/poviewer/feature.xml @@ -2,7 +2,7 @@ + version="2.2.2"> %description diff --git a/ide/plugins/features/poviewer/pom.xml b/ide/plugins/features/poviewer/pom.xml index 9738461fb9..113e280eba 100644 --- a/ide/plugins/features/poviewer/pom.xml +++ b/ide/plugins/features/poviewer/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide.plugins org.overture.ide.plugins.features - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/plugins/features/probruntime/feature.xml b/ide/plugins/features/probruntime/feature.xml index 5166558510..2f2128226d 100644 --- a/ide/plugins/features/probruntime/feature.xml +++ b/ide/plugins/features/probruntime/feature.xml @@ -2,7 +2,7 @@ diff --git a/ide/plugins/features/probruntime/pom.xml b/ide/plugins/features/probruntime/pom.xml index 3e4c254e53..b907745d9e 100644 --- a/ide/plugins/features/probruntime/pom.xml +++ b/ide/plugins/features/probruntime/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide.plugins org.overture.ide.plugins.features - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/plugins/features/quickinterpreter/feature.xml b/ide/plugins/features/quickinterpreter/feature.xml index c08e8dbc2c..f4b39a3a93 100644 --- a/ide/plugins/features/quickinterpreter/feature.xml +++ b/ide/plugins/features/quickinterpreter/feature.xml @@ -2,7 +2,7 @@ + version="2.2.2"> %description diff --git a/ide/plugins/features/quickinterpreter/pom.xml b/ide/plugins/features/quickinterpreter/pom.xml index 11a0882c3b..e3e60a7505 100644 --- a/ide/plugins/features/quickinterpreter/pom.xml +++ b/ide/plugins/features/quickinterpreter/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide.plugins org.overture.ide.plugins.features - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/plugins/features/rttraceviewer/feature.xml b/ide/plugins/features/rttraceviewer/feature.xml index 34ac522c5b..4e86afc93f 100644 --- a/ide/plugins/features/rttraceviewer/feature.xml +++ b/ide/plugins/features/rttraceviewer/feature.xml @@ -2,7 +2,7 @@ + version="2.2.2"> %description diff --git a/ide/plugins/features/rttraceviewer/pom.xml b/ide/plugins/features/rttraceviewer/pom.xml index 01b2babb28..095f483d0a 100644 --- a/ide/plugins/features/rttraceviewer/pom.xml +++ b/ide/plugins/features/rttraceviewer/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide.plugins org.overture.ide.plugins.features - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/plugins/features/uml2/feature.xml b/ide/plugins/features/uml2/feature.xml index 7130c9ab10..09b2f8138c 100644 --- a/ide/plugins/features/uml2/feature.xml +++ b/ide/plugins/features/uml2/feature.xml @@ -2,7 +2,7 @@ + version="2.2.2"> %description diff --git a/ide/plugins/features/uml2/pom.xml b/ide/plugins/features/uml2/pom.xml index 3ad1774936..c8429130f1 100644 --- a/ide/plugins/features/uml2/pom.xml +++ b/ide/plugins/features/uml2/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide.plugins org.overture.ide.plugins.features - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/plugins/guibuilder/META-INF/MANIFEST.MF b/ide/plugins/guibuilder/META-INF/MANIFEST.MF index 4356205dc8..6ee88a6859 100644 --- a/ide/plugins/guibuilder/META-INF/MANIFEST.MF +++ b/ide/plugins/guibuilder/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-Vendor: Overture Bundle-ActivationPolicy: lazy -Bundle-Version: 2.2.0 +Bundle-Version: 2.2.2 Eclipse-BuddyPolicy: registered Eclipse-BundleShape: dir Bundle-Localization: plugin diff --git a/ide/plugins/guibuilder/pom.xml b/ide/plugins/guibuilder/pom.xml index 9854f8d072..d068eacca2 100644 --- a/ide/plugins/guibuilder/pom.xml +++ b/ide/plugins/guibuilder/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide org.overture.ide.plugins - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/plugins/latex/META-INF/MANIFEST.MF b/ide/plugins/latex/META-INF/MANIFEST.MF index dd45ccc9f1..7ea536f5ab 100644 --- a/ide/plugins/latex/META-INF/MANIFEST.MF +++ b/ide/plugins/latex/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-Vendor: Overture Bundle-ActivationPolicy: lazy -Bundle-Version: 2.2.0 +Bundle-Version: 2.2.2 Eclipse-BuddyPolicy: registered Bundle-Localization: plugin Bundle-Name: org.overture.ide.plugins.latex diff --git a/ide/plugins/latex/pom.xml b/ide/plugins/latex/pom.xml index 442294da65..ac6bc4155a 100644 --- a/ide/plugins/latex/pom.xml +++ b/ide/plugins/latex/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide org.overture.ide.plugins - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/plugins/pom.xml b/ide/plugins/pom.xml index f8c017ea84..6353a258e4 100644 --- a/ide/plugins/pom.xml +++ b/ide/plugins/pom.xml @@ -5,7 +5,7 @@ org.overturetool ide - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/plugins/poviewer/META-INF/MANIFEST.MF b/ide/plugins/poviewer/META-INF/MANIFEST.MF index 5197c95d7b..7c4c3d826b 100644 --- a/ide/plugins/poviewer/META-INF/MANIFEST.MF +++ b/ide/plugins/poviewer/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-Vendor: Overture Bundle-ActivationPolicy: lazy -Bundle-Version: 2.2.0 +Bundle-Version: 2.2.2 Eclipse-BuddyPolicy: registered Eclipse-BundleShape: dir Bundle-Localization: plugin diff --git a/ide/plugins/poviewer/pom.xml b/ide/plugins/poviewer/pom.xml index 78bc270f96..543903e2f6 100644 --- a/ide/plugins/poviewer/pom.xml +++ b/ide/plugins/poviewer/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide org.overture.ide.plugins - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/plugins/poviewer/src/main/java/org/overture/ide/plugins/poviewer/view/PoOverviewTableView.java b/ide/plugins/poviewer/src/main/java/org/overture/ide/plugins/poviewer/view/PoOverviewTableView.java index 6a68149dc9..e83989d3eb 100644 --- a/ide/plugins/poviewer/src/main/java/org/overture/ide/plugins/poviewer/view/PoOverviewTableView.java +++ b/ide/plugins/poviewer/src/main/java/org/overture/ide/plugins/poviewer/view/PoOverviewTableView.java @@ -241,13 +241,13 @@ public void run() { * The constructor. */ public PoOverviewTableView() { - VdmCore.addElementChangedListener(vdmlistner); +// VdmCore.addElementChangedListener(vdmlistner); } @Override public void dispose() { super.dispose(); - VdmCore.removeElementChangedListener(vdmlistner); + // VdmCore.removeElementChangedListener(vdmlistner); } /** diff --git a/ide/plugins/prob-runtime/core/META-INF/MANIFEST.MF b/ide/plugins/prob-runtime/core/META-INF/MANIFEST.MF index c4e96f9b98..23b5f360fc 100644 --- a/ide/plugins/prob-runtime/core/META-INF/MANIFEST.MF +++ b/ide/plugins/prob-runtime/core/META-INF/MANIFEST.MF @@ -1,6 +1,6 @@ Manifest-Version: 1.0 Bundle-Vendor: Overture -Bundle-Version: 2.2.0 +Bundle-Version: 2.2.2 Eclipse-BuddyPolicy: registered Eclipse-BundleShape: dir Bundle-Name: ProB Runtime diff --git a/ide/plugins/prob-runtime/core/pom.xml b/ide/plugins/prob-runtime/core/pom.xml index 786da511a6..bc2c45dc06 100644 --- a/ide/plugins/prob-runtime/core/pom.xml +++ b/ide/plugins/prob-runtime/core/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide.plugins org.overture.ide.plugins.probruntime - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/plugins/prob-runtime/linux.x86/META-INF/MANIFEST.MF b/ide/plugins/prob-runtime/linux.x86/META-INF/MANIFEST.MF index ad28517b21..45efc3bfc8 100644 --- a/ide/plugins/prob-runtime/linux.x86/META-INF/MANIFEST.MF +++ b/ide/plugins/prob-runtime/linux.x86/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Eclipse-BundleShape: dir Bundle-ManifestVersion: 2 Bundle-Name: org.overture.ide.plugins.probruntime Bundle-SymbolicName: org.overture.ide.plugins.probruntime.linux.x86;singleton:=true -Bundle-Version: 2.2.0 +Bundle-Version: 2.2.2 Fragment-Host: org.overture.ide.plugins.probruntime.core Bundle-RequiredExecutionEnvironment: JavaSE-1.7 diff --git a/ide/plugins/prob-runtime/linux.x86/pom.xml b/ide/plugins/prob-runtime/linux.x86/pom.xml index 366e190f73..ac985fda09 100644 --- a/ide/plugins/prob-runtime/linux.x86/pom.xml +++ b/ide/plugins/prob-runtime/linux.x86/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide.plugins org.overture.ide.plugins.probruntime - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/plugins/prob-runtime/linux.x86_64/META-INF/MANIFEST.MF b/ide/plugins/prob-runtime/linux.x86_64/META-INF/MANIFEST.MF index 3f66133322..264a9fdf94 100644 --- a/ide/plugins/prob-runtime/linux.x86_64/META-INF/MANIFEST.MF +++ b/ide/plugins/prob-runtime/linux.x86_64/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Eclipse-BundleShape: dir Bundle-ManifestVersion: 2 Bundle-Name: org.overture.ide.plugins.probruntime Bundle-SymbolicName: org.overture.ide.plugins.probruntime.linux.x86_64;singleton:=true -Bundle-Version: 2.2.0 +Bundle-Version: 2.2.2 Fragment-Host: org.overture.ide.plugins.probruntime.core Bundle-RequiredExecutionEnvironment: JavaSE-1.7 diff --git a/ide/plugins/prob-runtime/linux.x86_64/pom.xml b/ide/plugins/prob-runtime/linux.x86_64/pom.xml index 3b1562adf7..b66a0f5765 100644 --- a/ide/plugins/prob-runtime/linux.x86_64/pom.xml +++ b/ide/plugins/prob-runtime/linux.x86_64/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide.plugins org.overture.ide.plugins.probruntime - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/plugins/prob-runtime/macosx.x86_64/META-INF/MANIFEST.MF b/ide/plugins/prob-runtime/macosx.x86_64/META-INF/MANIFEST.MF index a7ff798191..20a5681fd1 100644 --- a/ide/plugins/prob-runtime/macosx.x86_64/META-INF/MANIFEST.MF +++ b/ide/plugins/prob-runtime/macosx.x86_64/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Eclipse-BundleShape: dir Bundle-ManifestVersion: 2 Bundle-Name: org.overture.ide.plugins.probruntime Bundle-SymbolicName: org.overture.ide.plugins.probruntime.macosx.x86_64;singleton:=true -Bundle-Version: 2.2.0 +Bundle-Version: 2.2.2 Fragment-Host: org.overture.ide.plugins.probruntime.core Bundle-RequiredExecutionEnvironment: JavaSE-1.7 diff --git a/ide/plugins/prob-runtime/macosx.x86_64/pom.xml b/ide/plugins/prob-runtime/macosx.x86_64/pom.xml index cc8cb494e2..ad477ea5b3 100644 --- a/ide/plugins/prob-runtime/macosx.x86_64/pom.xml +++ b/ide/plugins/prob-runtime/macosx.x86_64/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide.plugins org.overture.ide.plugins.probruntime - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/plugins/prob-runtime/pom.xml b/ide/plugins/prob-runtime/pom.xml index e54c634f9e..d98174d180 100644 --- a/ide/plugins/prob-runtime/pom.xml +++ b/ide/plugins/prob-runtime/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide org.overture.ide.plugins - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/plugins/prob-runtime/win32.win32/META-INF/MANIFEST.MF b/ide/plugins/prob-runtime/win32.win32/META-INF/MANIFEST.MF index dd20ea9400..c7cf64842d 100644 --- a/ide/plugins/prob-runtime/win32.win32/META-INF/MANIFEST.MF +++ b/ide/plugins/prob-runtime/win32.win32/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Eclipse-BundleShape: dir Bundle-ManifestVersion: 2 Bundle-Name: org.overture.ide.plugins.probruntime Bundle-SymbolicName: org.overture.ide.plugins.probruntime.win32.win32;singleton:=true -Bundle-Version: 2.2.0 +Bundle-Version: 2.2.2 Fragment-Host: org.overture.ide.plugins.probruntime.core Bundle-RequiredExecutionEnvironment: JavaSE-1.7 diff --git a/ide/plugins/prob-runtime/win32.win32/pom.xml b/ide/plugins/prob-runtime/win32.win32/pom.xml index d97cae74c8..70db2768ec 100644 --- a/ide/plugins/prob-runtime/win32.win32/pom.xml +++ b/ide/plugins/prob-runtime/win32.win32/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide.plugins org.overture.ide.plugins.probruntime - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/plugins/quickinterpreter/META-INF/MANIFEST.MF b/ide/plugins/quickinterpreter/META-INF/MANIFEST.MF index f5e0b4b19b..e8f6d61371 100644 --- a/ide/plugins/quickinterpreter/META-INF/MANIFEST.MF +++ b/ide/plugins/quickinterpreter/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-Vendor: Overture Bundle-ActivationPolicy: lazy -Bundle-Version: 2.2.0 +Bundle-Version: 2.2.2 Eclipse-BuddyPolicy: registered Bundle-Localization: plugin Bundle-Name: org.overture.ide.plugins.quickinterpreter diff --git a/ide/plugins/quickinterpreter/pom.xml b/ide/plugins/quickinterpreter/pom.xml index c339af22e3..38099b5e9a 100644 --- a/ide/plugins/quickinterpreter/pom.xml +++ b/ide/plugins/quickinterpreter/pom.xml @@ -4,7 +4,7 @@ org.overturetool.ide org.overture.ide.plugins - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/plugins/rttraceviewer/META-INF/MANIFEST.MF b/ide/plugins/rttraceviewer/META-INF/MANIFEST.MF index bc8db4875f..b95dd2874a 100644 --- a/ide/plugins/rttraceviewer/META-INF/MANIFEST.MF +++ b/ide/plugins/rttraceviewer/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-Vendor: Overture Bundle-ActivationPolicy: lazy -Bundle-Version: 2.2.0 +Bundle-Version: 2.2.2 Eclipse-BuddyPolicy: registered Bundle-Localization: plugin Bundle-Name: org.overture.ide.plugins.rttraceviewer diff --git a/ide/plugins/rttraceviewer/pom.xml b/ide/plugins/rttraceviewer/pom.xml index 39b18cc0df..2b3d43f302 100644 --- a/ide/plugins/rttraceviewer/pom.xml +++ b/ide/plugins/rttraceviewer/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide org.overture.ide.plugins - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/plugins/uml2.tests/META-INF/MANIFEST.MF b/ide/plugins/uml2.tests/META-INF/MANIFEST.MF index 7d4ade3ba7..cac406c981 100644 --- a/ide/plugins/uml2.tests/META-INF/MANIFEST.MF +++ b/ide/plugins/uml2.tests/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-Vendor: Overture Bundle-ActivationPolicy: lazy -Bundle-Version: 2.2.0 +Bundle-Version: 2.2.2 Eclipse-BuddyPolicy: registered Bundle-Localization: plugin Bundle-Name: org.overture.ide.plugins.uml2.tests diff --git a/ide/plugins/uml2.tests/pom.xml b/ide/plugins/uml2.tests/pom.xml index 7d4f5fbe16..627699af59 100644 --- a/ide/plugins/uml2.tests/pom.xml +++ b/ide/plugins/uml2.tests/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide org.overture.ide.plugins - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/plugins/uml2/META-INF/MANIFEST.MF b/ide/plugins/uml2/META-INF/MANIFEST.MF index f255e883b3..ef4d8c1414 100644 --- a/ide/plugins/uml2/META-INF/MANIFEST.MF +++ b/ide/plugins/uml2/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-Vendor: Overture Bundle-ActivationPolicy: lazy -Bundle-Version: 2.2.0 +Bundle-Version: 2.2.2 Eclipse-BuddyPolicy: registered Bundle-Name: UML2 Translator Bundle-ManifestVersion: 2 diff --git a/ide/plugins/uml2/pom.xml b/ide/plugins/uml2/pom.xml index 4c74cf5e71..35195c8701 100644 --- a/ide/plugins/uml2/pom.xml +++ b/ide/plugins/uml2/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide org.overture.ide.plugins - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/pom.xml b/ide/pom.xml index e2aacacafe..0cfb839f2f 100644 --- a/ide/pom.xml +++ b/ide/pom.xml @@ -5,12 +5,12 @@ org.overturetool root - 2.2.0 + 2.2.2 ../pom.xml - pom - ide +pom + ide Overture IDE Top-level Super POM for all IDE (Eclipse) artifacts. diff --git a/ide/product/overture.product b/ide/product/overture.product index 41c0c23303..e55e7e4943 100644 --- a/ide/product/overture.product +++ b/ide/product/overture.product @@ -1,7 +1,7 @@ - + diff --git a/ide/product/pom.xml b/ide/product/pom.xml index 4edbd0919e..fa3df286db 100644 --- a/ide/product/pom.xml +++ b/ide/product/pom.xml @@ -5,7 +5,7 @@ org.overturetool ide - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/product/src/main/resources/overture.p2.inf b/ide/product/src/main/resources/overture.p2.inf index daade359f5..ef19a53213 100644 --- a/ide/product/src/main/resources/overture.p2.inf +++ b/ide/product/src/main/resources/overture.p2.inf @@ -14,8 +14,10 @@ instructions.configure=\ remove(path:${installFolder}/epl-v10.html);\ remove(path:${installFolder}/notice.html);\ remove(path:${installFolder}/readme);\ - addRepository(type:0,name:Overture,enabled:true,location:http${#58}//overture.sourceforge.net/updates/release/);\ - addRepository(type:1,name:Overture,enabled:true,location:http${#58}//overture.sourceforge.net/updates/release/); + addRepository(type:0,name:Overture,enabled:false,location:http${#58}//dl.bintray.com/overturetool/overturetool/);\ + addRepository(type:1,name:Overture,enabled:false,location:http${#58}//dl.bintray.com/overturetool/overturetool/);\ + addRepository(type:0,name:Overture Development,enabled:true,location:http${#58}//dl.bintray.com/overturetool/overturetool-development/);\ + addRepository(type:1,name:Overture Development,enabled:true,location:http${#58}//dl.bintray.com/overturetool/overturetool-development/); instructions.configure.import=\ org.eclipse.equinox.p2.touchpoint.natives.chmod,\ org.eclipse.equinox.p2.touchpoint.natives.copy,\ diff --git a/ide/tests/pom.xml b/ide/tests/pom.xml index 14c3e4d53c..7409061785 100644 --- a/ide/tests/pom.xml +++ b/ide/tests/pom.xml @@ -5,7 +5,7 @@ org.overturetool ide - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/tests/ui/META-INF/MANIFEST.MF b/ide/tests/ui/META-INF/MANIFEST.MF index 1640e2237c..a8648cf0ac 100644 --- a/ide/tests/ui/META-INF/MANIFEST.MF +++ b/ide/tests/ui/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-Vendor: Overture Bundle-ActivationPolicy: lazy -Bundle-Version: 2.2.0 +Bundle-Version: 2.2.2 Eclipse-BuddyPolicy: registered Bundle-Localization: plugin Bundle-Name: org.overture.ide.tests.ui diff --git a/ide/tests/ui/pom.xml b/ide/tests/ui/pom.xml index c353df58c2..4a27a37c7a 100644 --- a/ide/tests/ui/pom.xml +++ b/ide/tests/ui/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide org.overture.ide.tests - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/ui/META-INF/MANIFEST.MF b/ide/ui/META-INF/MANIFEST.MF index 5df69021c8..d154a1e394 100644 --- a/ide/ui/META-INF/MANIFEST.MF +++ b/ide/ui/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-Vendor: Overture Bundle-ActivationPolicy: lazy -Bundle-Version: 2.2.0 +Bundle-Version: 2.2.2 Eclipse-BuddyPolicy: registered Bundle-Localization: plugin Bundle-Name: org.overture.ide.ui diff --git a/ide/ui/pom.xml b/ide/ui/pom.xml index 6c107a4910..3dde557224 100644 --- a/ide/ui/pom.xml +++ b/ide/ui/pom.xml @@ -5,7 +5,7 @@ org.overturetool ide - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/ui/src/main/java/org/overture/ide/ui/templates/SearchType.java b/ide/ui/src/main/java/org/overture/ide/ui/templates/SearchType.java new file mode 100644 index 0000000000..abeadc9386 --- /dev/null +++ b/ide/ui/src/main/java/org/overture/ide/ui/templates/SearchType.java @@ -0,0 +1,17 @@ +package org.overture.ide.ui.templates; + +public enum SearchType +{ +// Proposal, Field, Unknown, Type + Quote, + + New, + + Mk, + + CallParam, + + Dot, + + Types, +}; \ No newline at end of file diff --git a/ide/ui/src/main/java/org/overture/ide/ui/templates/VdmCompleteProcesser.java b/ide/ui/src/main/java/org/overture/ide/ui/templates/VdmCompleteProcesser.java index 3cfc4b4acb..e763926234 100644 --- a/ide/ui/src/main/java/org/overture/ide/ui/templates/VdmCompleteProcesser.java +++ b/ide/ui/src/main/java/org/overture/ide/ui/templates/VdmCompleteProcesser.java @@ -21,6 +21,7 @@ */ package org.overture.ide.ui.templates; +import java.util.Iterator; import java.util.List; import java.util.Vector; @@ -30,6 +31,7 @@ import org.eclipse.jface.text.contentassist.IContextInformation; import org.overture.ast.analysis.AnalysisException; import org.overture.ast.analysis.DepthFirstAnalysisAdaptor; +import org.overture.ast.assistant.definition.PAccessSpecifierAssistant; import org.overture.ast.definitions.AExplicitFunctionDefinition; import org.overture.ast.definitions.AExplicitOperationDefinition; import org.overture.ast.definitions.AImplicitFunctionDefinition; @@ -44,6 +46,7 @@ import org.overture.ast.expressions.PExp; import org.overture.ast.modules.AModuleModules; import org.overture.ast.node.INode; +import org.overture.ast.patterns.PPattern; import org.overture.ast.statements.PStm; import org.overture.ast.types.AFieldField; import org.overture.ast.types.AQuoteType; @@ -52,7 +55,6 @@ import org.overture.ide.ui.VdmUIPlugin; import org.overture.ide.ui.editor.core.VdmDocument; import org.overture.ide.ui.internal.viewsupport.VdmElementImageProvider; -import org.overture.ide.ui.templates.VdmContentAssistProcessor.VdmCompletionContext; import org.overture.ide.ui.utility.ast.AstLocationSearcher2; import org.overture.ide.ui.utility.ast.AstLocationSearcher2.TextReference; import org.overture.ide.ui.utility.ast.AstNameUtil; @@ -72,9 +74,29 @@ public void computeCompletionProposals(VdmCompletionContext info, // } else // { // completeFields(info, document, calculatedProposals, offset); - // } - completeFields(info, document, calculatedProposals, offset); - completeTypes(info, document, calculatedProposals, offset); + // completeFields(info, document, calculatedProposals, offset); + + switch (info.type) + { + case CallParam: + break; + case Dot: + break; + case Mk: + break; + case New: + completeNew(info, document, calculatedProposals, offset); + break; + case Quote: + completeQuotes(info, document, calculatedProposals, offset); + break; + case Types: + completeTypes(info, document, calculatedProposals, offset); + break; + default: + break; + + } List replacementDisplayString = new Vector(); for (ICompletionProposal proposal : calculatedProposals) @@ -96,31 +118,94 @@ public void computeCompletionProposals(VdmCompletionContext info, } } + private void completeQuotes(final VdmCompletionContext info, + VdmDocument document, final List proposals, + int offset) + { + for (INode def : getAst(document)) + { + completeQuotes(offset, proposals, info, def); + } + + } + + private void completeNew(final VdmCompletionContext info, + VdmDocument document, final List proposals, + final int offset) + { + for (INode container : getAst(document)) + { + try + { + container.apply(new DepthFirstAnalysisAdaptor() + { + @Override + public void caseAExplicitOperationDefinition( + AExplicitOperationDefinition node) + throws AnalysisException + { + + if (node.getIsConstructor() + && new PAccessSpecifierAssistant(null).isPublic(node.getAccess())) + { + String name = node.getName().getName(); + if (info.proposalPrefix.isEmpty() + || name.toLowerCase().startsWith(info.proposalPrefix.toLowerCase())) + { + IContextInformation infoComplete = new ContextInformation(name, name); + + String replacementString = name + "("; + + for (Iterator iterator = node.getParameterPatterns().iterator(); iterator.hasNext();) + { + PPattern pattern = iterator.next(); + + replacementString += pattern.toString(); + if (iterator.hasNext()) + replacementString += ", "; + + } + replacementString += ")"; + + proposals.add(new CompletionProposal(replacementString, offset + + info.offset, info.proposalPrefix.length(), replacementString.length(), imgProvider.getImageLabel(node, 0), replacementString, infoComplete, node.toString())); + } + } + } + }); + } catch (AnalysisException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + public void completeTypes(VdmCompletionContext info, VdmDocument document, List proposals, int offset) { - boolean modulesOnly = info.afterNew || info.isEmpty; - boolean recordTypesOnly = info.afterMk || info.isEmpty; - String typeName = info.field.toString(); + // boolean modulesOnly = info.afterNew || info.isEmpty; + // boolean recordTypesOnly = info.afterMk || info.isEmpty; + // String typeName = info.field.toString(); for (INode element : getAst(document)) { - if (modulesOnly) + if (info.type == SearchType.Types) { String name = AstNameUtil.getName(element); - if (name.startsWith(typeName) || name.length() == 0) + if (name.startsWith(info.proposalPrefix) || name.length() == 0) { IContextInformation ctxtInfo = new ContextInformation(name, name); //$NON-NLS-1$ proposals.add(new CompletionProposal(name, offset, 0, name.length(), imgProvider.getImageLabel(element, 0), name, ctxtInfo, name)); } } - addContainerTypes(element, recordTypesOnly, offset, proposals, info); + addContainerTypes(element, offset, proposals, info); } } - private void addContainerTypes(INode def, boolean recordTypesOnly, - final int offset, final List proposals, + private void addContainerTypes(INode def, final int offset, + final List proposals, final VdmCompletionContext info2) { if (def instanceof SClassDefinition) @@ -134,7 +219,9 @@ private void addContainerTypes(INode def, boolean recordTypesOnly, IContextInformation info = new ContextInformation(name, name); //$NON-NLS-1$ proposals.add(new CompletionProposal(name, offset, 0, name.length(), imgProvider.getImageLabel(element, 0), name, info, name)); } + } + completeQuotes(offset, proposals, info2, def); } else if (def instanceof AModuleModules) { AModuleModules m = (AModuleModules) def; @@ -151,67 +238,73 @@ private void addContainerTypes(INode def, boolean recordTypesOnly, String name = prefix + element.getName(); IContextInformation info = new ContextInformation(name, name); //$NON-NLS-1$ - if (name.toLowerCase().startsWith(info2.prefix.toString().toLowerCase())) + if (name.toLowerCase().startsWith(info2.proposalPrefix.toString().toLowerCase())) { proposals.add(new CompletionProposal(name, offset - - info2.prefix.length(), info2.prefix.length(), name.length(), imgProvider.getImageLabel(element, 0), name, info, name)); + - info2.proposalPrefix.length(), info2.proposalPrefix.length(), name.length(), imgProvider.getImageLabel(element, 0), name, info, element.toString())); } } } - try + completeQuotes(offset, proposals, info2, m); + } + + } + + private void completeQuotes(final int offset, + final List proposals, + final VdmCompletionContext info2, INode m) + { + try + { + m.apply(new DepthFirstAnalysisAdaptor() { - m.apply(new DepthFirstAnalysisAdaptor() + @Override + public void caseAQuoteLiteralExp(AQuoteLiteralExp node) + throws AnalysisException { - @Override - public void caseAQuoteLiteralExp(AQuoteLiteralExp node) - throws AnalysisException - { - populateQuotes(node, node.getValue().getValue(), node.toString()); - } + populateQuotes(node, node.getValue().getValue(), node.toString()); + } - @Override - public void caseAQuoteType(AQuoteType node) - throws AnalysisException - { - populateQuotes(node, node.getValue().getValue(), node.toString()); - } + @Override + public void caseAQuoteType(AQuoteType node) + throws AnalysisException + { + populateQuotes(node, node.getValue().getValue(), node.toString()); + } - void populateQuotes(INode node, String baseValue, - String name) + void populateQuotes(INode node, String baseValue, String name) + { + // if (!info2.prefix.toString().equals(baseValue)) { - // if (!info2.prefix.toString().equals(baseValue)) - { - IContextInformation info = new ContextInformation(name, name); //$NON-NLS-1$ + IContextInformation info = new ContextInformation(name, name); //$NON-NLS-1$ - int curOffset = offset - info2.prefix.length(); - int length = name.length(); - int replacementLength = info2.prefix.length(); + int curOffset = offset + info2.offset;// - info2.proposalPrefix.length(); + int length = name.length(); + int replacementLength = info2.proposalPrefix.length(); - if (info2.prefix.toString().equals(baseValue)) - { - // replacementLength+=1; - // length+=1; - curOffset = offset; - replacementLength = 0; - } + if (info2.proposalPrefix.toString().equals("<" + + baseValue + ">")) + { + // replacementLength+=1; + // length+=1; + curOffset = offset; + replacementLength = 0; + } - if (baseValue.toLowerCase().startsWith(info2.prefix.toString().toLowerCase())) - { - proposals.add(new CompletionProposal(name, curOffset, replacementLength, length, imgProvider.getImageLabel(node, 0), name, info, name)); - } + if (("<" + baseValue).toLowerCase().startsWith(info2.proposalPrefix.toString().toLowerCase())) + { + proposals.add(new CompletionProposal(name, curOffset, replacementLength, length, imgProvider.getImageLabel(node, 0), name, info, name)); } } - }); - } catch (AnalysisException e) - { - VdmUIPlugin.log("Completion error in " - + getClass().getSimpleName() - + "faild during quote search", e); - } + } + }); + } catch (AnalysisException e) + { + VdmUIPlugin.log("Completion error in " + getClass().getSimpleName() + + "faild during quote search", e); } - } public void completeFields(VdmCompletionContext info, VdmDocument document, @@ -240,7 +333,7 @@ public void completeFields(VdmCompletionContext info, VdmDocument document, for (AFieldField field : rt.getFields()) { - if (field.getTag().toLowerCase().startsWith(info.proposal.toString().toLowerCase())) + if (field.getTag().toLowerCase().startsWith(info.proposalPrefix.toString().toLowerCase())) { proposals.add(createProposal(field, offset, info)); } @@ -250,29 +343,29 @@ public void completeFields(VdmCompletionContext info, VdmDocument document, { // FIXME old code - if (info.fieldType.toString().trim().length() != 0) - { - completeFromType(info.fieldType.toString(), info.proposal.toString(), proposals, offset, ast); - } else - { - List possibleMatch = new Vector(); - for (INode node : getLocalFileAst(document)) - { - for (INode field : getFields(node)) - { - if (AstNameUtil.getName(field).equals(info.field.toString())) - { - // Ok match then complete it - completeFromType(getTypeName(field), info.proposal.toString(), proposals, offset, ast); - } else if (AstNameUtil.getName(field).startsWith(info.field.toString())) - { - possibleMatch.add(field); - } - - } - - } - } + // if (info.fieldType.toString().trim().length() != 0) + // { + // completeFromType(info.fieldType.toString(), info.proposalPrefix.toString(), proposals, offset, ast); + // } else + // { + // List possibleMatch = new Vector(); + // for (INode node : getLocalFileAst(document)) + // { + // for (INode field : getFields(node)) + // { + // if (AstNameUtil.getName(field).equals(info.field.toString())) + // { + // // Ok match then complete it + // completeFromType(getTypeName(field), info.proposalPrefix.toString(), proposals, offset, ast); + // } else if (AstNameUtil.getName(field).startsWith(info.field.toString())) + // { + // possibleMatch.add(field); + // } + // + // } + // + // } + // } } } catch (Exception e) { @@ -356,7 +449,8 @@ private ICompletionProposal createProposal(INode node, int offset, + name; } IContextInformation info2 = new ContextInformation(name, name); //$NON-NLS-1$ - return new CompletionProposal(name, offset - info.proposal.length(), info.proposal.length(), name.length(), imgProvider.getImageLabel(node, 0), name, info2, name); + return new CompletionProposal(name, offset + - info.proposalPrefix.length(), info.proposalPrefix.length(), name.length(), imgProvider.getImageLabel(node, 0), name, info2, node.toString()); } private INode getType(String typeName, List ast) @@ -463,7 +557,7 @@ private List getAst(VdmDocument document) { List ast = new Vector(); ast.addAll(document.getProject().getModel().getRootElementList()); - ast.addAll(document.getSourceUnit().getParseList()); + ast.addAll(document.getSourceUnit().getParseList());// maybe add broken parse tree return ast; } diff --git a/ide/ui/src/main/java/org/overture/ide/ui/templates/VdmCompletionContext.java b/ide/ui/src/main/java/org/overture/ide/ui/templates/VdmCompletionContext.java new file mode 100644 index 0000000000..2b56763551 --- /dev/null +++ b/ide/ui/src/main/java/org/overture/ide/ui/templates/VdmCompletionContext.java @@ -0,0 +1,107 @@ +package org.overture.ide.ui.templates; + +import java.util.Iterator; +import java.util.List; +import java.util.Vector; + +public class VdmCompletionContext +{ + // boolean isEmpty = false; + // // SearchType type = SearchType.Proposal; + // StringBuffer proposal = new StringBuffer(); + // StringBuffer field = new StringBuffer(); + // StringBuffer fieldType = new StringBuffer(); + // boolean afterNew = false; + // boolean afterMk = false; + // public StringBuffer prefix = new StringBuffer(); + + // new + private StringBuffer rawScan; + private StringBuffer processedScan; + public int offset; + SearchType type = SearchType.Types; + + public String proposalPrefix = ""; + + public List root = new Vector(); + + public VdmCompletionContext(StringBuffer rawScan) + { + this.rawScan = rawScan; + init(); + } + + private void init() + { + calcSearchType(); + + System.out.println("Computed completion context: "+toString()); + } + + private void calcSearchType() + { + int index = rawScan.toString().lastIndexOf("<"); + + if (index != -1) + { + // quote + processedScan = new StringBuffer(rawScan.subSequence(index, rawScan.length())); + proposalPrefix = processedScan.toString(); + offset = -(rawScan.length() - index); + type = SearchType.Quote; + return; + } + + index = rawScan.toString().indexOf("new"); + + if (index == 0) + { + // quote + processedScan = new StringBuffer(rawScan.subSequence(index + + "new".length(), rawScan.length())); + proposalPrefix = processedScan.toString().trim(); + + for (int i = index + "new".length(); i < rawScan.length(); i++) + { + if (Character.isJavaIdentifierStart(rawScan.charAt(i))) + { + offset = -(rawScan.length() - i); + break; + } + } + + type = SearchType.New; + return; + } + } + + @Override + public String toString() + { + return type + " - Root: '" + getQualifiedSource() + "' Proposal: '" + + proposalPrefix+"'" +" offset: "+offset; + } + + String getQualifiedSource() + { + String res = ""; + if (root != null && !root.isEmpty()) + { + for (Iterator itr = root.iterator(); itr.hasNext();) + { + res += itr.next(); + if (itr.hasNext()) + res += "."; + } + } + return res; + } + + // @Override + // public String toString() + // { + // return "Type: \"" + fieldType + "\" " + (afterMk ? "mk_" : "") + // + (afterNew ? "new " : "") + "\"" + // + (field.length() != 0 ? field + "." : "") + proposal + "\""; + // } +} \ No newline at end of file diff --git a/ide/ui/src/main/java/org/overture/ide/ui/templates/VdmContentAssistProcessor.java b/ide/ui/src/main/java/org/overture/ide/ui/templates/VdmContentAssistProcessor.java index 132edf99d2..6f748a1159 100644 --- a/ide/ui/src/main/java/org/overture/ide/ui/templates/VdmContentAssistProcessor.java +++ b/ide/ui/src/main/java/org/overture/ide/ui/templates/VdmContentAssistProcessor.java @@ -28,9 +28,10 @@ import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.contentassist.ICompletionProposal; +import org.overture.ast.lex.VDMToken; +import org.overture.ide.ui.VdmUIPlugin; import org.overture.ide.ui.editor.core.VdmDocument; import org.overture.ide.ui.internal.viewsupport.VdmElementImageProvider; -import org.overture.ide.ui.templates.VdmContentAssistProcessor.VdmCompletionContext.SearchType; public abstract class VdmContentAssistProcessor extends VdmTemplateAssistProcessor @@ -44,6 +45,9 @@ public boolean enableTemplate() return true; } + /** + * @param offset an offset within the document for which completions should be computed + */ public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) { @@ -72,181 +76,70 @@ public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, } if (modList.size() > 0) + { return (ICompletionProposal[]) modList.toArray(new ICompletionProposal[modList.size()]); + } return completionProposals; } - public static class VdmCompletionContext + VDMToken getToken(char c) { - enum SearchType - { - Proposal, Field, Unknown, Type - }; - - boolean isEmpty = false; - SearchType type = SearchType.Proposal; - StringBuffer proposal = new StringBuffer(); - StringBuffer field = new StringBuffer(); - StringBuffer fieldType = new StringBuffer(); - boolean afterNew = false; - boolean afterMk = false; - public StringBuffer prefix= new StringBuffer(); - - public void add(char c) + String name = "" + c; + for (VDMToken token : VDMToken.values()) { - switch (type) + if (token.toString() != null && token.toString().equals(name)) { - case Field: - field.append(c); - break; - case Proposal: - proposal.append(c); - break; - case Type: - fieldType.append(c); - break; - case Unknown: - break; - + return token; } - - if(Character.isJavaIdentifierPart(c)) -prefix.append(c); - } - - public void reverse() - { - proposal = proposal.reverse(); - field = field.reverse(); - // fieldType = fieldType.reverse(); - prefix =prefix.reverse(); - } - - @Override - public String toString() - { - return "Type: \"" + fieldType + "\" " + (afterMk ? "mk_" : "") - + (afterNew ? "new " : "") + "\"" - + (field.length() != 0 ? field + "." : "") + proposal - + "\""; } + return null; } private VdmCompletionContext computeVdmCompletionContext(IDocument doc, int documentOffset) { - // Use string buffer to collect characters - StringBuffer buf = new StringBuffer(); - char lastChar = '\0'; - VdmCompletionContext info = new VdmCompletionContext(); + StringBuffer scanned = new StringBuffer(); while (true) { try { - - // Read character backwards - char c = doc.getChar(--documentOffset); - - if (c == '.' && info.type == SearchType.Proposal) - { - info.type = SearchType.Field; - continue; - } - if (Character.isWhitespace(c) - && info.type == SearchType.Proposal) - { - // Ok maybe this is a field, lets try to search for it - info.field = info.proposal; - info.proposal = new StringBuffer(); - info.type = SearchType.Field; - // break; - } - - if (info.type == SearchType.Field && Character.isWhitespace(c)) + if(documentOffset-1==-1) { - info.type = SearchType.Type; - continue; + //EOF + break; } + // Read character backwards + char c = doc.getChar(--documentOffset); - if (info.type == SearchType.Type) + VDMToken token = null; + if ((token = getToken(c)) != null)// '`' == null { - if (Character.isWhitespace(c)) + if (!(token == VDMToken.LT || token == VDMToken.POINT/* . */|| token == VDMToken.BRA /* ( */)) { - continue; - } - buf.append(c); - // System.out.println("Buf: \""+buf+"\t\t\""+info.field+"\""); - if (buf.length() >= info.field.length() - && buf.substring(buf.length() - info.field.length()).equals(info.field.toString())) - { - StringBuffer tmp = new StringBuffer(buf).reverse(); - int index = tmp.indexOf("="); - int index2 = tmp.indexOf(":="); - int length = info.field.length() + 1; - if (index2 != -1 && index > index2) - { - index = index2; - - } - - if (index > 0 && length < index) - { - - String tmp2 = tmp.substring(length, index); - info.fieldType.append(tmp2); - } break; } - - } else - { - info.add(c); } - - if (c == '=' && lastChar == '=') + + scanned.append(c); + + if(c=='n' && scanned.length()>3&& scanned.substring(scanned.length()-4, scanned.length()).matches("\\swen")) { + break; } - lastChar = c; + } catch (BadLocationException e) { - + e.printStackTrace(); + VdmUIPlugin.log("completion failed", e); // Document start reached, no tag found - return info; - } - } - - if (buf.length() >= 3) - { - if (buf.substring(0, 3).equals("wen")) - { - info.afterNew = true; - } - if (buf.substring(0, 3).equals("_km")) - { - info.afterMk = true; + break; } } + return new VdmCompletionContext(scanned.reverse()); - info.reverse(); - - if (buf.length() >= 3 && info.field.length() >= 3 - && info.field.substring(0, 3).equals("mk_")) - { - info.afterMk = true; - info.field = info.field.delete(0, 3); - } - - if (info.field.toString().trim().length() == 0) - { - info.isEmpty = true; - } - - System.out.println(info); - - return info; } } diff --git a/ide/vdmpp/core/META-INF/MANIFEST.MF b/ide/vdmpp/core/META-INF/MANIFEST.MF index c2d2019455..051b1a39e1 100644 --- a/ide/vdmpp/core/META-INF/MANIFEST.MF +++ b/ide/vdmpp/core/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-Vendor: Overture Bundle-ActivationPolicy: lazy -Bundle-Version: 2.2.0 +Bundle-Version: 2.2.2 Eclipse-BuddyPolicy: registered Bundle-Localization: plugin Bundle-Name: org.overture.ide.vdmpp.core diff --git a/ide/vdmpp/core/pom.xml b/ide/vdmpp/core/pom.xml index 1d191d8d54..8b57f42923 100644 --- a/ide/vdmpp/core/pom.xml +++ b/ide/vdmpp/core/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide org.overture.ide.vdmpp - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/vdmpp/debug/META-INF/MANIFEST.MF b/ide/vdmpp/debug/META-INF/MANIFEST.MF index 9e4c9fe9ff..ba09194c80 100644 --- a/ide/vdmpp/debug/META-INF/MANIFEST.MF +++ b/ide/vdmpp/debug/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-Vendor: Overture Bundle-ActivationPolicy: lazy -Bundle-Version: 2.2.0 +Bundle-Version: 2.2.2 Eclipse-BuddyPolicy: registered Bundle-Localization: plugin Bundle-Name: org.overture.ide.vdmpp.debug diff --git a/ide/vdmpp/debug/pom.xml b/ide/vdmpp/debug/pom.xml index 79719db672..30f2a142b4 100644 --- a/ide/vdmpp/debug/pom.xml +++ b/ide/vdmpp/debug/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide org.overture.ide.vdmpp - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/vdmpp/pom.xml b/ide/vdmpp/pom.xml index e82079e959..9553e58f09 100644 --- a/ide/vdmpp/pom.xml +++ b/ide/vdmpp/pom.xml @@ -4,7 +4,7 @@ org.overturetool ide - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/vdmpp/ui/META-INF/MANIFEST.MF b/ide/vdmpp/ui/META-INF/MANIFEST.MF index 89bc6d57e5..696332288b 100644 --- a/ide/vdmpp/ui/META-INF/MANIFEST.MF +++ b/ide/vdmpp/ui/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-Vendor: Overture Bundle-ActivationPolicy: lazy -Bundle-Version: 2.2.0 +Bundle-Version: 2.2.2 Eclipse-BuddyPolicy: registered Bundle-Localization: plugin Bundle-Name: org.overture.ide.vdmpp.ui diff --git a/ide/vdmpp/ui/pom.xml b/ide/vdmpp/ui/pom.xml index 6e0b52b1d3..c3d713876f 100644 --- a/ide/vdmpp/ui/pom.xml +++ b/ide/vdmpp/ui/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide org.overture.ide.vdmpp - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/vdmrt/core/META-INF/MANIFEST.MF b/ide/vdmrt/core/META-INF/MANIFEST.MF index 2415c56685..aaf80d16df 100644 --- a/ide/vdmrt/core/META-INF/MANIFEST.MF +++ b/ide/vdmrt/core/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-Vendor: Overture Bundle-ActivationPolicy: lazy -Bundle-Version: 2.2.0 +Bundle-Version: 2.2.2 Eclipse-BuddyPolicy: registered Bundle-Localization: plugin Bundle-Name: org.overture.ide.vdmrt.core diff --git a/ide/vdmrt/core/pom.xml b/ide/vdmrt/core/pom.xml index 5db43d8d73..bcf105d9c8 100644 --- a/ide/vdmrt/core/pom.xml +++ b/ide/vdmrt/core/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide org.overture.ide.vdmrt - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/vdmrt/debug/META-INF/MANIFEST.MF b/ide/vdmrt/debug/META-INF/MANIFEST.MF index f4ac81067a..5b91408079 100644 --- a/ide/vdmrt/debug/META-INF/MANIFEST.MF +++ b/ide/vdmrt/debug/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-Vendor: Overture Bundle-ActivationPolicy: lazy -Bundle-Version: 2.2.0 +Bundle-Version: 2.2.2 Eclipse-BuddyPolicy: registered Bundle-Localization: plugin Bundle-Name: org.overture.ide.vdmrt.debug diff --git a/ide/vdmrt/debug/pom.xml b/ide/vdmrt/debug/pom.xml index 4aee909426..5195945841 100644 --- a/ide/vdmrt/debug/pom.xml +++ b/ide/vdmrt/debug/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide org.overture.ide.vdmrt - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/vdmrt/pom.xml b/ide/vdmrt/pom.xml index 4bba612e6b..257f139117 100644 --- a/ide/vdmrt/pom.xml +++ b/ide/vdmrt/pom.xml @@ -5,7 +5,7 @@ org.overturetool ide - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/vdmrt/ui/META-INF/MANIFEST.MF b/ide/vdmrt/ui/META-INF/MANIFEST.MF index 3ed643b291..9ac4c3e7e7 100644 --- a/ide/vdmrt/ui/META-INF/MANIFEST.MF +++ b/ide/vdmrt/ui/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-Vendor: Overture Bundle-ActivationPolicy: lazy -Bundle-Version: 2.2.0 +Bundle-Version: 2.2.2 Eclipse-BuddyPolicy: registered Bundle-Localization: plugin Bundle-Name: org.overture.ide.vdmrt.ui diff --git a/ide/vdmrt/ui/pom.xml b/ide/vdmrt/ui/pom.xml index fad2311756..1032205d34 100644 --- a/ide/vdmrt/ui/pom.xml +++ b/ide/vdmrt/ui/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide org.overture.ide.vdmrt - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/vdmsl/core/META-INF/MANIFEST.MF b/ide/vdmsl/core/META-INF/MANIFEST.MF index c4f57c6ac2..f6878bd5ea 100644 --- a/ide/vdmsl/core/META-INF/MANIFEST.MF +++ b/ide/vdmsl/core/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-Vendor: Overture Bundle-ActivationPolicy: lazy -Bundle-Version: 2.2.0 +Bundle-Version: 2.2.2 Eclipse-BuddyPolicy: registered Bundle-Localization: plugin Bundle-Name: org.overture.ide.vdmsl.core diff --git a/ide/vdmsl/core/pom.xml b/ide/vdmsl/core/pom.xml index 15203a7d1d..be6b30be86 100644 --- a/ide/vdmsl/core/pom.xml +++ b/ide/vdmsl/core/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide org.overture.ide.vdmsl - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/vdmsl/debug/META-INF/MANIFEST.MF b/ide/vdmsl/debug/META-INF/MANIFEST.MF index 1ce7984234..ef536928c3 100644 --- a/ide/vdmsl/debug/META-INF/MANIFEST.MF +++ b/ide/vdmsl/debug/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-Vendor: Overture Bundle-ActivationPolicy: lazy -Bundle-Version: 2.2.0 +Bundle-Version: 2.2.2 Eclipse-BuddyPolicy: registered Bundle-Localization: plugin Bundle-Name: org.overture.ide.vdmsl.debug diff --git a/ide/vdmsl/debug/pom.xml b/ide/vdmsl/debug/pom.xml index df327e4577..692669c612 100644 --- a/ide/vdmsl/debug/pom.xml +++ b/ide/vdmsl/debug/pom.xml @@ -4,7 +4,7 @@ org.overturetool.ide org.overture.ide.vdmsl - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/vdmsl/pom.xml b/ide/vdmsl/pom.xml index 86ac8b0662..e440893681 100644 --- a/ide/vdmsl/pom.xml +++ b/ide/vdmsl/pom.xml @@ -5,7 +5,7 @@ org.overturetool ide - 2.2.0 + 2.2.2 ../pom.xml diff --git a/ide/vdmsl/ui/META-INF/MANIFEST.MF b/ide/vdmsl/ui/META-INF/MANIFEST.MF index 625618d583..ea3b5ddb8d 100644 --- a/ide/vdmsl/ui/META-INF/MANIFEST.MF +++ b/ide/vdmsl/ui/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-Vendor: Overture Bundle-ActivationPolicy: lazy -Bundle-Version: 2.2.0 +Bundle-Version: 2.2.2 Eclipse-BuddyPolicy: registered Bundle-Localization: plugin Bundle-Name: org.overture.ide.vdmsl.ui diff --git a/ide/vdmsl/ui/pom.xml b/ide/vdmsl/ui/pom.xml index 4a61a4b362..3c9208fdb3 100644 --- a/ide/vdmsl/ui/pom.xml +++ b/ide/vdmsl/ui/pom.xml @@ -5,7 +5,7 @@ org.overturetool.ide org.overture.ide.vdmsl - 2.2.0 + 2.2.2 ../pom.xml diff --git a/pom.xml b/pom.xml index 53571ae0cf..06337f2cf6 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ org.overturetool root - 2.2.0 + 2.2.2 The Overture Tool Platform root @@ -302,7 +302,7 @@ git@github.com:overturetool/overture.git scm:git:git://github.com/overturetool/overture.git scm:git:git@github.com:overturetool/overture.git - Release/2.2.0 + Release/2.2.2