diff options
author | ArenBabikian <aren.babikian@mail.mcgill.ca> | 2019-10-25 04:15:39 -0400 |
---|---|---|
committer | ArenBabikian <aren.babikian@mail.mcgill.ca> | 2019-10-25 04:15:39 -0400 |
commit | 25a4b1b53add70e268c3083682f8a3508c618ec2 (patch) | |
tree | 6d46e62be49cfe6c5640e2e9af80aae90da6a212 /Solvers/Alloy-Solver2/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/unused/oldTypes | |
parent | mid-measurement push (diff) | |
download | VIATRA-Generator-25a4b1b53add70e268c3083682f8a3508c618ec2.tar.gz VIATRA-Generator-25a4b1b53add70e268c3083682f8a3508c618ec2.tar.zst VIATRA-Generator-25a4b1b53add70e268c3083682f8a3508c618ec2.zip |
VAMPIRE: post-submission push
Diffstat (limited to 'Solvers/Alloy-Solver2/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/unused/oldTypes')
-rw-r--r-- | Solvers/Alloy-Solver2/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/unused/oldTypes | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/Solvers/Alloy-Solver2/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/unused/oldTypes b/Solvers/Alloy-Solver2/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/unused/oldTypes new file mode 100644 index 00000000..f5f5a9b6 --- /dev/null +++ b/Solvers/Alloy-Solver2/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/unused/oldTypes | |||
@@ -0,0 +1,74 @@ | |||
1 | /*def dispatch boolean hasDeclaredElement(TypeDefinition type) { return false; } | ||
2 | def dispatch boolean hasDeclaredElement(TypeDeclaration type) { | ||
3 | if(type.isAbstract) { | ||
4 | type.subtypes.exists[it.hasDeclaredElement] | ||
5 | } else return true; | ||
6 | } | ||
7 | |||
8 | def dispatch List<TypeDefinition> allEnumSubtypes(TypeDefinition type) { return #[type] } | ||
9 | def dispatch List<TypeDefinition> allEnumSubtypes(TypeDeclaration type) { | ||
10 | return type.subtypes.map[it.allEnumSubtypes].flatten.toList | ||
11 | } | ||
12 | |||
13 | def protected transformTypes(List<Type> types, Logic2AlloyLanguageMapperTrace trace) { | ||
14 | val Map<TypeDeclaration,ALSSignatureDeclaration> signatureTrace = new HashMap; | ||
15 | |||
16 | // Creating the root type | ||
17 | val objectType = createALSSignatureDeclaration => [ name=#["util","object"].toID it.abstract = true ] | ||
18 | trace.objectSupperClass = objectType | ||
19 | trace.specification.typeDeclarations += objectType | ||
20 | |||
21 | // Creating the images of the types | ||
22 | for(type : types) { | ||
23 | if(type instanceof TypeDefinition) { | ||
24 | if(type.elements.empty) { | ||
25 | trace.type2ALSType.put(type,#[]); | ||
26 | } else { | ||
27 | val e = createALSEnumDeclaration => [ | ||
28 | it.name = type.name.toID | ||
29 | it.literal += type.elements.map[transformDefinedElement(trace)] | ||
30 | ] | ||
31 | trace.type2ALSType.put(type,#[e]) | ||
32 | trace.specification.typeDeclarations += e | ||
33 | } | ||
34 | } | ||
35 | else if(type instanceof TypeDeclaration) { | ||
36 | if(hasDeclaredElement(type)) { | ||
37 | val s = createALSSignatureDeclaration => [ | ||
38 | name=type.name.toID | ||
39 | it.abstract = type.isIsAbstract | ||
40 | ] | ||
41 | trace.type2ALSType.put(type,new LinkedList=>[add(s)]) | ||
42 | signatureTrace.put(type, s) | ||
43 | trace.specification.typeDeclarations += s | ||
44 | } | ||
45 | else { | ||
46 | signatureTrace.put(type, null) | ||
47 | trace.type2ALSType.put(type,new LinkedList);// empty | ||
48 | } | ||
49 | } | ||
50 | else throw new IllegalArgumentException('''Unknown type «type.class.name»''') | ||
51 | } | ||
52 | |||
53 | |||
54 | for(type: types.filter(TypeDeclaration)) { | ||
55 | // Adding inheritance | ||
56 | val s = type.lookup(signatureTrace) | ||
57 | if(s!=null) { | ||
58 | for(supertype : type.supertypes) { | ||
59 | s.supertype += (supertype as TypeDeclaration).lookup(signatureTrace) | ||
60 | } | ||
61 | if(type.supertypes.empty) { | ||
62 | s.supertype += objectType | ||
63 | } | ||
64 | } | ||
65 | // Adding enum subtypes | ||
66 | type.lookup(trace.type2ALSType)+=type.allEnumSubtypes.map[it.lookup(trace.type2ALSType)].flatten | ||
67 | } | ||
68 | } | ||
69 | |||
70 | def protected transformDefinedElement(DefinedElement element, Logic2AlloyLanguageMapperTrace trace) { | ||
71 | val result = createALSEnumLiteral => [name = element.name.toID] | ||
72 | trace.definedElement2EnumProperty.put(element,result) | ||
73 | return result | ||
74 | }*/ \ No newline at end of file | ||