occam-verify-cli 1.0.318 → 1.0.325
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/context/file.js +108 -126
- package/lib/context/local.js +21 -8
- package/lib/context/release.js +58 -7
- package/lib/dom/assertion/type.js +3 -3
- package/lib/dom/declaration/complexType.js +125 -101
- package/lib/dom/declaration/constructor.js +5 -5
- package/lib/dom/declaration/metavariable.js +3 -3
- package/lib/dom/declaration/simpleType.js +58 -52
- package/lib/dom/declaration/typePrefix.js +18 -7
- package/lib/dom/declaration/variable.js +5 -5
- package/lib/dom/metavariable.js +3 -3
- package/lib/dom/property.js +4 -4
- package/lib/dom/topLevelAssertion.js +1 -43
- package/lib/dom/type.js +107 -21
- package/lib/dom/variable.js +4 -4
- package/lib/node/declaration/complexType.js +22 -1
- package/lib/node/declaration/simpleType.js +22 -1
- package/lib/node/type.js +35 -9
- package/lib/unifier/metavariable.js +2 -2
- package/lib/unifier/statementWithCombinator.js +3 -3
- package/lib/unifier/termWithConstructor.js +2 -2
- package/lib/utilities/json.js +8 -6
- package/lib/utilities/node.js +4 -4
- package/lib/utilities/type.js +10 -5
- package/lib/verifier/combinator.js +2 -2
- package/lib/verifier/constructor.js +3 -3
- package/package.json +1 -1
- package/src/context/file.js +137 -171
- package/src/context/local.js +7 -3
- package/src/context/release.js +54 -8
- package/src/dom/assertion/type.js +3 -3
- package/src/dom/declaration/complexType.js +159 -132
- package/src/dom/declaration/constructor.js +6 -6
- package/src/dom/declaration/metavariable.js +3 -3
- package/src/dom/declaration/simpleType.js +74 -68
- package/src/dom/declaration/typePrefix.js +24 -6
- package/src/dom/declaration/variable.js +6 -6
- package/src/dom/metavariable.js +2 -2
- package/src/dom/property.js +1 -1
- package/src/dom/topLevelAssertion.js +3 -15
- package/src/dom/type.js +132 -22
- package/src/dom/variable.js +4 -4
- package/src/node/declaration/complexType.js +21 -0
- package/src/node/declaration/simpleType.js +21 -0
- package/src/node/type.js +42 -9
- package/src/unifier/metavariable.js +2 -2
- package/src/unifier/statementWithCombinator.js +2 -2
- package/src/unifier/termWithConstructor.js +2 -2
- package/src/utilities/json.js +18 -10
- package/src/utilities/node.js +6 -3
- package/src/utilities/type.js +12 -5
- package/src/verifier/combinator.js +2 -2
- package/src/verifier/constructor.js +3 -3
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
import dom from "../../dom";
|
|
4
4
|
|
|
5
|
-
import { objectType } from "../type";
|
|
6
5
|
import { domAssigned } from "../../dom";
|
|
7
|
-
import {
|
|
6
|
+
import { stringFromTypeNameTypePrefixNameAndSuperTypes } from "../../utilities/type";
|
|
8
7
|
|
|
9
8
|
export default domAssigned(class SimpleTypeDeclaration {
|
|
10
|
-
constructor(context, node, string, type) {
|
|
9
|
+
constructor(context, node, string, type, prefixed) {
|
|
11
10
|
this.context = context;
|
|
12
11
|
this.node = node;
|
|
13
12
|
this.string = string;
|
|
14
13
|
this.type = type;
|
|
14
|
+
this.prefixed = prefixed;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
getContext() {
|
|
@@ -30,6 +30,10 @@ export default domAssigned(class SimpleTypeDeclaration {
|
|
|
30
30
|
return this.type;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
isPrefixed() {
|
|
34
|
+
return this.prefixed;
|
|
35
|
+
}
|
|
36
|
+
|
|
33
37
|
verify() {
|
|
34
38
|
let verifies = false;
|
|
35
39
|
|
|
@@ -37,15 +41,30 @@ export default domAssigned(class SimpleTypeDeclaration {
|
|
|
37
41
|
|
|
38
42
|
this.context.trace(`Verifying the '${simpleTypeDeclarationString}' simple type declaration...`, this.node);
|
|
39
43
|
|
|
40
|
-
|
|
44
|
+
if (this.prefixed) {
|
|
45
|
+
const typeString = this.type.getString();
|
|
41
46
|
|
|
42
|
-
|
|
43
|
-
|
|
47
|
+
this.context.trace(`The '${typeString}' type is prefixed.`);
|
|
48
|
+
} else {
|
|
49
|
+
const typeVerifies = this.verifyType();
|
|
50
|
+
|
|
51
|
+
if (typeVerifies) {
|
|
52
|
+
const superTypesVerify = this.verifySuperTypes();
|
|
53
|
+
|
|
54
|
+
if (superTypesVerify) {
|
|
55
|
+
const typePrefix = this.context.getTypePrefix();
|
|
56
|
+
|
|
57
|
+
if (typePrefix !== null) {
|
|
58
|
+
const typePrefixName = typePrefix.getName(),
|
|
59
|
+
prefixName = typePrefixName; ///
|
|
60
|
+
|
|
61
|
+
this.type.setPrefixName(prefixName);
|
|
62
|
+
}
|
|
44
63
|
|
|
45
|
-
|
|
46
|
-
this.context.addType(this.type);
|
|
64
|
+
this.context.addType(this.type);
|
|
47
65
|
|
|
48
|
-
|
|
66
|
+
verifies = true;
|
|
67
|
+
}
|
|
49
68
|
}
|
|
50
69
|
}
|
|
51
70
|
|
|
@@ -64,16 +83,25 @@ export default domAssigned(class SimpleTypeDeclaration {
|
|
|
64
83
|
this.context.trace(`Verifying the '${typeString}' simple type...`, this.node);
|
|
65
84
|
|
|
66
85
|
const typeName = this.type.getName(),
|
|
67
|
-
|
|
86
|
+
includeRelease = true,
|
|
87
|
+
includeDependencies = false,
|
|
88
|
+
typePresent = this.context.isTypePresentByTypeName(typeName, includeRelease, includeDependencies);
|
|
68
89
|
|
|
69
90
|
if (typePresent) {
|
|
70
|
-
this.context.
|
|
91
|
+
this.context.trace(`The '${typeString}' type is already present.`, this.node);
|
|
71
92
|
} else {
|
|
72
|
-
|
|
93
|
+
const prefixedTypeName = typeName, ///
|
|
94
|
+
typePresent = this.context.isTypePresentByPrefixedTypeName(prefixedTypeName);
|
|
95
|
+
|
|
96
|
+
if (typePresent) {
|
|
97
|
+
this.context.trace(`The '${typeString}' type is already present.`, this.node);
|
|
98
|
+
} else {
|
|
99
|
+
typeVerifies = true;
|
|
100
|
+
}
|
|
73
101
|
}
|
|
74
102
|
|
|
75
103
|
if (typeVerifies) {
|
|
76
|
-
this.context.
|
|
104
|
+
this.context.trace(`...verified the '${typeString}' simple type.`, this.node);
|
|
77
105
|
}
|
|
78
106
|
|
|
79
107
|
return typeVerifies;
|
|
@@ -86,11 +114,24 @@ export default domAssigned(class SimpleTypeDeclaration {
|
|
|
86
114
|
|
|
87
115
|
this.context.trace(`Verifying the '${superTypeString}' super-type...`, this.node);
|
|
88
116
|
|
|
89
|
-
const
|
|
90
|
-
|
|
117
|
+
const nominalTypeName = superType.getNominalTypeName(),
|
|
118
|
+
typeName = nominalTypeName, ///
|
|
119
|
+
typeNameMatches = this.type.matchTypeName(typeName);
|
|
120
|
+
|
|
121
|
+
if (typeNameMatches) {
|
|
122
|
+
this.context.trace(`The super-type's name matches the ${typeName}' simple type's name.`, this.node);
|
|
123
|
+
} else {
|
|
124
|
+
const oldSuperType = superType;
|
|
125
|
+
|
|
126
|
+
superType = this.context.findTypeByNominalTypeName(nominalTypeName);
|
|
127
|
+
|
|
128
|
+
const superTypePresent = (superType !== null);
|
|
91
129
|
|
|
92
|
-
|
|
93
|
-
|
|
130
|
+
if (superTypePresent) {
|
|
131
|
+
this.type.replaceSuperType(oldSuperType, newSuperType);
|
|
132
|
+
|
|
133
|
+
superTypeVerifies = true;
|
|
134
|
+
}
|
|
94
135
|
}
|
|
95
136
|
|
|
96
137
|
if (superTypeVerifies) {
|
|
@@ -101,69 +142,32 @@ export default domAssigned(class SimpleTypeDeclaration {
|
|
|
101
142
|
}
|
|
102
143
|
|
|
103
144
|
verifySuperTypes() {
|
|
104
|
-
let superTypesVerify
|
|
145
|
+
let superTypesVerify;
|
|
105
146
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
let superTypes;
|
|
109
|
-
|
|
110
|
-
superTypes = this.type.getSuperTypes();
|
|
111
|
-
|
|
112
|
-
const superTypesLength = superTypes.length;
|
|
113
|
-
|
|
114
|
-
if (superTypesLength === 0) {
|
|
115
|
-
const superType = objectType; ///
|
|
147
|
+
const typeString = this.type.getString();
|
|
116
148
|
|
|
117
|
-
|
|
118
|
-
}
|
|
149
|
+
this.context.trace(`Verifying the '${typeString}' simple type's super-types...`, this.node);
|
|
119
150
|
|
|
120
|
-
const
|
|
121
|
-
typeBasic = this.type.isBasic(),
|
|
122
|
-
typeString = this.type.getString();
|
|
151
|
+
const typeBasic = this.type.isBasic();
|
|
123
152
|
|
|
124
153
|
if (typeBasic) {
|
|
125
154
|
superTypesVerify = true;
|
|
126
155
|
|
|
127
156
|
this.context.trace(`The '${typeString}' simple type is basic.`, this.node)
|
|
128
157
|
} else {
|
|
129
|
-
const
|
|
130
|
-
const superTypeName = superType.getName();
|
|
131
|
-
|
|
132
|
-
return superTypeName;
|
|
133
|
-
}),
|
|
134
|
-
superTypeNamesIncludesTypeName = superTypeNames.includes(typeName);
|
|
135
|
-
|
|
136
|
-
if (superTypeNamesIncludesTypeName) {
|
|
137
|
-
this.context.trace(`The '${typeName}' simple type cannot be a super-type `, this.node);
|
|
138
|
-
} else {
|
|
139
|
-
superTypesVerify = superTypes.every((superType) => {
|
|
140
|
-
const superTypeVerifies = this.verifySuperType(superType);
|
|
158
|
+
const superTypes = this.type.getSuperTypes();
|
|
141
159
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
if (superTypesVerify) {
|
|
148
|
-
superTypes = superTypes.map((superType) => {
|
|
149
|
-
const superTypeName = superType.getName();
|
|
150
|
-
|
|
151
|
-
superType = this.context.findTypeByTypeName(superTypeName);
|
|
152
|
-
|
|
153
|
-
return superType;
|
|
154
|
-
});
|
|
160
|
+
superTypesVerify = superTypes.every((superType) => {
|
|
161
|
+
const superTypeVerifies = this.verifySuperType(superType);
|
|
155
162
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
this.type.setString(string);
|
|
159
|
-
|
|
160
|
-
this.type.setSuperTypes(superTypes);
|
|
163
|
+
if (superTypeVerifies) {
|
|
164
|
+
return true;
|
|
161
165
|
}
|
|
162
|
-
}
|
|
166
|
+
});
|
|
163
167
|
}
|
|
164
168
|
|
|
165
169
|
if (superTypesVerify) {
|
|
166
|
-
this.context.debug(`...verified the super-types.`, this.node);
|
|
170
|
+
this.context.debug(`...verified the '${typeString}' simple type's super-types.`, this.node);
|
|
167
171
|
}
|
|
168
172
|
|
|
169
173
|
return superTypesVerify;
|
|
@@ -173,12 +177,14 @@ export default domAssigned(class SimpleTypeDeclaration {
|
|
|
173
177
|
|
|
174
178
|
static fromSimpleTypeDeclarationNode(simpleTypeDeclarationNode, context) {
|
|
175
179
|
const { Type } = dom,
|
|
176
|
-
node = simpleTypeDeclarationNode, ///
|
|
177
180
|
type = Type.fromSimpleTypeDeclarationNode(simpleTypeDeclarationNode, context),
|
|
181
|
+
node = simpleTypeDeclarationNode, ///
|
|
182
|
+
prefixed = simpleTypeDeclarationNode.isPrefixed(),
|
|
183
|
+
typePrefixName = simpleTypeDeclarationNode.getTypePrefixName(),
|
|
178
184
|
typeName = type.getName(),
|
|
179
185
|
superTypes = type.getSuperTypes(),
|
|
180
|
-
string =
|
|
181
|
-
simpleTypeDeclaration = new SimpleTypeDeclaration(context, node, string, type);
|
|
186
|
+
string = stringFromTypeNameTypePrefixNameAndSuperTypes(typeName, typePrefixName, superTypes),
|
|
187
|
+
simpleTypeDeclaration = new SimpleTypeDeclaration(context, node, string, type, prefixed);
|
|
182
188
|
|
|
183
189
|
return simpleTypeDeclaration;
|
|
184
190
|
}
|
|
@@ -35,10 +35,21 @@ export default domAssigned(class TypePrefixDeclaration {
|
|
|
35
35
|
|
|
36
36
|
this.context.trace(`Verifying the '${typePrefixDeclarationString}' type prefix declaration...`, this.node);
|
|
37
37
|
|
|
38
|
-
const
|
|
38
|
+
const includeRelease = true,
|
|
39
|
+
includeDependencies = false,
|
|
40
|
+
types = this.context.getTypes(includeRelease, includeDependencies),
|
|
41
|
+
typesLength = types.length;
|
|
39
42
|
|
|
40
|
-
if (
|
|
41
|
-
|
|
43
|
+
if (typesLength > 0) {
|
|
44
|
+
this.context.debug(`Cannot verify the '${typePrefixDeclarationString}' type prefix declaration because types have already been declared.`, this.node);
|
|
45
|
+
} else {
|
|
46
|
+
const typePrefixVerifies = this.verifyTypePrefix();
|
|
47
|
+
|
|
48
|
+
if (typePrefixVerifies) {
|
|
49
|
+
this.context.addTypePrefix(this.typePrefix);
|
|
50
|
+
|
|
51
|
+
verifies = true;
|
|
52
|
+
}
|
|
42
53
|
}
|
|
43
54
|
|
|
44
55
|
if (verifies) {
|
|
@@ -58,16 +69,23 @@ export default domAssigned(class TypePrefixDeclaration {
|
|
|
58
69
|
const typePrefix = this.context.getTypePrefix();
|
|
59
70
|
|
|
60
71
|
if (typePrefix !== null) {
|
|
61
|
-
this.context.
|
|
72
|
+
this.context.trace(`The package already has a '${typePrefixString}' type prefix.`, this.node);
|
|
62
73
|
} else {
|
|
63
74
|
|
|
64
75
|
const typePrefixName = this.typePrefix.getName(),
|
|
65
76
|
typePrefixPresent = this.context.isTypePrefixPresentByTypePrefixName(typePrefixName);
|
|
66
77
|
|
|
67
78
|
if (typePrefixPresent) {
|
|
68
|
-
this.context.
|
|
79
|
+
this.context.trace(`The '${typePrefixString}' type prefix is already present.`, this.node);
|
|
69
80
|
} else {
|
|
70
|
-
|
|
81
|
+
const nominalTypeName = typePrefixName, ///
|
|
82
|
+
typePresent = this.context.isTypePresentByNominalTypeName(nominalTypeName);
|
|
83
|
+
|
|
84
|
+
if (typePresent) {
|
|
85
|
+
this.context.trace(`The '${typePrefixString}' type is already present.`, this.node);
|
|
86
|
+
} else {
|
|
87
|
+
typePrefixVerifies = true;
|
|
88
|
+
}
|
|
71
89
|
}
|
|
72
90
|
}
|
|
73
91
|
|
|
@@ -84,22 +84,22 @@ export default domAssigned(class VariableDeclaration {
|
|
|
84
84
|
|
|
85
85
|
type = this.variable.getType();
|
|
86
86
|
|
|
87
|
-
const
|
|
88
|
-
typeString = type.getString();
|
|
87
|
+
const typeString = type.getString();
|
|
89
88
|
|
|
90
89
|
this.context.trace(`Verifying the '${typeString}' type...`, this.node);
|
|
91
90
|
|
|
92
|
-
const
|
|
93
|
-
provisional = type.isProvisional(includeSupertypes);
|
|
91
|
+
const nominalTypeName = type.getNominalTypeName();
|
|
94
92
|
|
|
95
|
-
type = this.context.
|
|
93
|
+
type = this.context.findTypeByNominalTypeName(nominalTypeName);
|
|
96
94
|
|
|
97
95
|
const typePresent = (type !== null)
|
|
98
96
|
|
|
99
97
|
if (!typePresent) {
|
|
100
98
|
this.context.debug(`The '${typeString}' type is not present.`, this.node);
|
|
101
99
|
} else {
|
|
102
|
-
const
|
|
100
|
+
const includeSupertypes = false,
|
|
101
|
+
provisional = type.isProvisional(includeSupertypes),
|
|
102
|
+
provisionalMatches = type.matchProvisional(provisional);
|
|
103
103
|
|
|
104
104
|
if (!provisionalMatches) {
|
|
105
105
|
provisional ?
|
package/src/dom/metavariable.js
CHANGED
|
@@ -529,9 +529,9 @@ function typeFromMetavariableDeclarationNode(metavariableDeclarationNode, contex
|
|
|
529
529
|
const typeNode = metavariableDeclarationNode.getTypeNode();
|
|
530
530
|
|
|
531
531
|
if (typeNode !== null) {
|
|
532
|
-
const
|
|
532
|
+
const nominalTypeName = typeNode.getNominalTypeName();
|
|
533
533
|
|
|
534
|
-
type = context.
|
|
534
|
+
type = context.findTypeByNominalTypeName(nominalTypeName);
|
|
535
535
|
}
|
|
536
536
|
|
|
537
537
|
return type;
|
package/src/dom/property.js
CHANGED
|
@@ -28,7 +28,7 @@ export default domAssigned(class Property {
|
|
|
28
28
|
this.type = type;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
matchNominalTypeName(nominalTypeName) { return this.type.matchNominalTypeName(nominalTypeName); }
|
|
32
32
|
|
|
33
33
|
matchPropertyName(propertyName) {
|
|
34
34
|
const propertyNameMatches = (this.name === propertyName);
|
|
@@ -68,21 +68,9 @@ export default class TopLevelAssertion {
|
|
|
68
68
|
return this.hypotheses;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
setLabels(labels) { this.labels = labels; }
|
|
76
|
-
|
|
77
|
-
setSuppositions(suppositions) { this.suppositions = suppositions; }
|
|
78
|
-
|
|
79
|
-
setDeduction(deduction) { this.deduction = deduction; }
|
|
80
|
-
|
|
81
|
-
setProof(proof) { this.proof = proof; }
|
|
82
|
-
|
|
83
|
-
setSignature(signature) { this.signature = signature; }
|
|
84
|
-
|
|
85
|
-
setHypotheses(hypotheses) { this.hypotheses = hypotheses; }
|
|
71
|
+
setHypotheses(hypotheses) {
|
|
72
|
+
this.hypotheses = hypotheses;
|
|
73
|
+
}
|
|
86
74
|
|
|
87
75
|
getStatement() { return this.deduction.getStatement(); }
|
|
88
76
|
|
package/src/dom/type.js
CHANGED
|
@@ -7,15 +7,16 @@ import dom from "../dom";
|
|
|
7
7
|
import { domAssigned } from "../dom";
|
|
8
8
|
import { OBJECT_TYPE_NAME } from "../constants";
|
|
9
9
|
import { typeFromTypeNode } from "../utilities/node";
|
|
10
|
-
import {
|
|
10
|
+
import { stringFromTypeNameTypePrefixNameAndSuperTypes } from "../utilities/type";
|
|
11
11
|
import { superTypesFromJSON, propertiesFromJSON, superTypesToSuperTypesJSON, propertiesToPropertiesJSON } from "../utilities/json";
|
|
12
12
|
|
|
13
13
|
const { push, first } = arrayUtilities;
|
|
14
14
|
|
|
15
15
|
class Type {
|
|
16
|
-
constructor(string, name, superTypes, properties, provisional) {
|
|
16
|
+
constructor(string, name, prefixName, superTypes, properties, provisional) {
|
|
17
17
|
this.string = string;
|
|
18
18
|
this.name = name;
|
|
19
|
+
this.prefixName = prefixName;
|
|
19
20
|
this.superTypes = superTypes;
|
|
20
21
|
this.properties = properties;
|
|
21
22
|
this.provisional = provisional;
|
|
@@ -29,6 +30,10 @@ class Type {
|
|
|
29
30
|
return this.name;
|
|
30
31
|
}
|
|
31
32
|
|
|
33
|
+
getPrefixName() {
|
|
34
|
+
return this.prefixName;
|
|
35
|
+
}
|
|
36
|
+
|
|
32
37
|
getSuperTypes() {
|
|
33
38
|
return this.superTypes;
|
|
34
39
|
}
|
|
@@ -67,14 +72,14 @@ class Type {
|
|
|
67
72
|
return provisional;
|
|
68
73
|
}
|
|
69
74
|
|
|
70
|
-
setString(string) {
|
|
71
|
-
this.string = string;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
75
|
setName(name) {
|
|
75
76
|
this.name = name;
|
|
76
77
|
}
|
|
77
78
|
|
|
79
|
+
setPrefixName(prefixName) {
|
|
80
|
+
this.prefixName = prefixName;
|
|
81
|
+
}
|
|
82
|
+
|
|
78
83
|
setSuperTypes(superTypes) {
|
|
79
84
|
this.superTypes = superTypes;
|
|
80
85
|
}
|
|
@@ -87,6 +92,41 @@ class Type {
|
|
|
87
92
|
this.provisional = provisional;
|
|
88
93
|
}
|
|
89
94
|
|
|
95
|
+
replaceSuperType(oldSuperType, newSuperType) {
|
|
96
|
+
const index = this.superTypes.indexOf(oldSuperType),
|
|
97
|
+
start = index,
|
|
98
|
+
deleteCount = 1;
|
|
99
|
+
|
|
100
|
+
this.superTypes.splice(start, deleteCount, newSuperType);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
isPrefixed() {
|
|
104
|
+
const prefixed = (this.prefixName !== null);
|
|
105
|
+
|
|
106
|
+
return prefixed;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
getPrefixedName() {
|
|
110
|
+
let prefixedName = null;
|
|
111
|
+
|
|
112
|
+
const prefixed = this.isPrefixed();
|
|
113
|
+
|
|
114
|
+
if (prefixed) {
|
|
115
|
+
prefixedName = `${this.prefixName}${this.name}`;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return prefixedName;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
getNominalTypeName() {
|
|
122
|
+
const prefixed = this.isPrefixed(),
|
|
123
|
+
nominalTypeName = prefixed ?
|
|
124
|
+
`${this.prefixName}${this.name}` :
|
|
125
|
+
this.name;
|
|
126
|
+
|
|
127
|
+
return nominalTypeName;
|
|
128
|
+
}
|
|
129
|
+
|
|
90
130
|
isBasic() {
|
|
91
131
|
let basic = false;
|
|
92
132
|
|
|
@@ -183,7 +223,8 @@ class Type {
|
|
|
183
223
|
}
|
|
184
224
|
|
|
185
225
|
matchTypeName(typeName) {
|
|
186
|
-
const
|
|
226
|
+
const name = this.getName(),
|
|
227
|
+
typeNameMatches = (name === typeName);
|
|
187
228
|
|
|
188
229
|
return typeNameMatches;
|
|
189
230
|
}
|
|
@@ -202,6 +243,42 @@ class Type {
|
|
|
202
243
|
return provisionalMatches;
|
|
203
244
|
}
|
|
204
245
|
|
|
246
|
+
matchPrefixedTypeName(prefixedTypeName) {
|
|
247
|
+
let prefixedTypeNameMatches = false;
|
|
248
|
+
|
|
249
|
+
const prefixed = this.isPrefixed();
|
|
250
|
+
|
|
251
|
+
if (prefixed) {
|
|
252
|
+
const prefixedName = this.getPrefixedName();
|
|
253
|
+
|
|
254
|
+
prefixedTypeNameMatches = (prefixedTypeName === prefixedName);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
return prefixedTypeNameMatches;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
matchNominalTypeName(nominalTypeName) {
|
|
261
|
+
let nominalTypeNameMatches = false;
|
|
262
|
+
|
|
263
|
+
if (!nominalTypeNameMatches) {
|
|
264
|
+
const name = this.getName();
|
|
265
|
+
|
|
266
|
+
nominalTypeNameMatches = (nominalTypeName === name);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
if (!nominalTypeNameMatches) {
|
|
270
|
+
const prefixed = this.isPrefixed();
|
|
271
|
+
|
|
272
|
+
if (prefixed) {
|
|
273
|
+
const prefixedName = this.getPrefixedName();
|
|
274
|
+
|
|
275
|
+
nominalTypeNameMatches = (nominalTypeName === prefixedName);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
return nominalTypeNameMatches;
|
|
280
|
+
}
|
|
281
|
+
|
|
205
282
|
toJSON() {
|
|
206
283
|
const propertiesJSON = propertiesToPropertiesJSON(this.properties),
|
|
207
284
|
superTypesJSON = superTypesToSuperTypesJSON(this.superTypes),
|
|
@@ -209,8 +286,10 @@ class Type {
|
|
|
209
286
|
properties = propertiesJSON, ///
|
|
210
287
|
superTypes = superTypesJSON, ///
|
|
211
288
|
name = this.name,
|
|
289
|
+
prefixName = this.prefixName,
|
|
212
290
|
json = {
|
|
213
291
|
name,
|
|
292
|
+
prefixName,
|
|
214
293
|
superTypes,
|
|
215
294
|
properties,
|
|
216
295
|
provisional
|
|
@@ -222,12 +301,13 @@ class Type {
|
|
|
222
301
|
static name = "Type";
|
|
223
302
|
|
|
224
303
|
static fromJSON(json, context) {
|
|
225
|
-
const { name, provisional } = json,
|
|
304
|
+
const { name, prefixName, provisional } = json,
|
|
226
305
|
properties = propertiesFromJSON(json, context),
|
|
227
306
|
superTypes = superTypesFromJSON(json, context),
|
|
228
307
|
typeName = name, ///
|
|
229
|
-
|
|
230
|
-
|
|
308
|
+
typePrefixName = null,
|
|
309
|
+
string = stringFromTypeNameTypePrefixNameAndSuperTypes(typeName, typePrefixName, superTypes),
|
|
310
|
+
type = new Type(string, name, prefixName, superTypes, properties, provisional);
|
|
231
311
|
|
|
232
312
|
return type;
|
|
233
313
|
}
|
|
@@ -238,6 +318,15 @@ class Type {
|
|
|
238
318
|
return type;
|
|
239
319
|
}
|
|
240
320
|
|
|
321
|
+
static fromSuperTypeNode(superTypeNode, context) {
|
|
322
|
+
context = null; ///
|
|
323
|
+
|
|
324
|
+
const typeNode = superTypeNode, ///
|
|
325
|
+
type = typeFromTypeNode(typeNode, context);
|
|
326
|
+
|
|
327
|
+
return type;
|
|
328
|
+
}
|
|
329
|
+
|
|
241
330
|
static fromTypeAssertionNode(typeAssertionNode, context) {
|
|
242
331
|
const typeNode = typeAssertionNode.getTypeNode(),
|
|
243
332
|
type = typeFromTypeNode(typeNode, context);
|
|
@@ -247,15 +336,17 @@ class Type {
|
|
|
247
336
|
|
|
248
337
|
static fromTypeAndProvisional(type, provisional) {
|
|
249
338
|
const name = type.getName(),
|
|
339
|
+
prefixName = type.getPrefixName(),
|
|
250
340
|
superType = type, ///
|
|
251
341
|
typeName = name, ///
|
|
342
|
+
typePrefixName = prefixName, ///
|
|
252
343
|
superTypes = [
|
|
253
344
|
superType
|
|
254
345
|
],
|
|
255
|
-
string =
|
|
346
|
+
string = stringFromTypeNameTypePrefixNameAndSuperTypes(typeName, typePrefixName, superTypes),
|
|
256
347
|
properties = type.getProperties();
|
|
257
348
|
|
|
258
|
-
type = new Type(string, name, superTypes, properties, provisional); ///
|
|
349
|
+
type = new Type(string, name, prefixName, superTypes, properties, provisional); ///
|
|
259
350
|
|
|
260
351
|
return type;
|
|
261
352
|
}
|
|
@@ -271,10 +362,12 @@ class Type {
|
|
|
271
362
|
const properties = [],
|
|
272
363
|
provisional = simpleTypeDeclarationNode.isProvisional(),
|
|
273
364
|
typeName = simpleTypeDeclarationNode.getTypeName(),
|
|
365
|
+
typePrefixName = simpleTypeDeclarationNode.getTypePrefixName(),
|
|
274
366
|
name = typeName, ///
|
|
367
|
+
prefixName = typePrefixName, ///
|
|
275
368
|
superTypes = superTypesFromSimpleTypeDeclarationNode(simpleTypeDeclarationNode, context),
|
|
276
|
-
string =
|
|
277
|
-
type = new Type(string, name, superTypes, properties, provisional);
|
|
369
|
+
string = stringFromTypeNameTypePrefixNameAndSuperTypes(typeName, typePrefixName, superTypes),
|
|
370
|
+
type = new Type(string, name, prefixName, superTypes, properties, provisional);
|
|
278
371
|
|
|
279
372
|
return type;
|
|
280
373
|
}
|
|
@@ -282,11 +375,13 @@ class Type {
|
|
|
282
375
|
static fromComplexTypeDeclarationNode(complexTypeDeclarationNode, context) {
|
|
283
376
|
const provisional = complexTypeDeclarationNode.isProvisional(),
|
|
284
377
|
typeName = complexTypeDeclarationNode.getTypeName(),
|
|
285
|
-
|
|
378
|
+
typePrefixName = complexTypeDeclarationNode.getTypePrefixName(),
|
|
379
|
+
name = typeName, ///
|
|
380
|
+
prefixName = typePrefixName, ///
|
|
286
381
|
superTypes = superTypesFromComplexTypeDeclarationNode(complexTypeDeclarationNode, context),
|
|
287
382
|
properties = propertiesFromComplexTypeDeclarationNode(complexTypeDeclarationNode, context),
|
|
288
|
-
string =
|
|
289
|
-
type = new Type(string, name, superTypes, properties, provisional);
|
|
383
|
+
string = stringFromTypeNameTypePrefixNameAndSuperTypes(typeName, typePrefixName, superTypes),
|
|
384
|
+
type = new Type(string, name, prefixName, superTypes, properties, provisional);
|
|
290
385
|
|
|
291
386
|
return type;
|
|
292
387
|
}
|
|
@@ -315,10 +410,17 @@ export default domAssigned(Type);
|
|
|
315
410
|
function superTypesFromSimpleTypeDeclarationNode(simpleTypeDeclarationNode, context) {
|
|
316
411
|
const superTypeNodes = simpleTypeDeclarationNode.getSuperTypeNodes(),
|
|
317
412
|
superTypes = superTypeNodes.map((superTypeNode) => {
|
|
318
|
-
const superType = Type.
|
|
413
|
+
const superType = Type.fromSuperTypeNode(superTypeNode, context);
|
|
319
414
|
|
|
320
415
|
return superType;
|
|
321
|
-
})
|
|
416
|
+
}),
|
|
417
|
+
superTypesLength = superTypes.length;
|
|
418
|
+
|
|
419
|
+
if (superTypesLength === 0) {
|
|
420
|
+
const superType = objectType; ///
|
|
421
|
+
|
|
422
|
+
superTypes.push(superType);
|
|
423
|
+
}
|
|
322
424
|
|
|
323
425
|
return superTypes;
|
|
324
426
|
}
|
|
@@ -326,10 +428,17 @@ function superTypesFromSimpleTypeDeclarationNode(simpleTypeDeclarationNode, cont
|
|
|
326
428
|
function superTypesFromComplexTypeDeclarationNode(complexTypeDeclarationNode, context) {
|
|
327
429
|
const superTypeNodes = complexTypeDeclarationNode.getSuperTypeNodes(),
|
|
328
430
|
superTypes = superTypeNodes.map((superTypeNode) => {
|
|
329
|
-
const superType = Type.
|
|
431
|
+
const superType = Type.fromSuperTypeNode(superTypeNode, context);
|
|
330
432
|
|
|
331
433
|
return superType;
|
|
332
|
-
})
|
|
434
|
+
}),
|
|
435
|
+
superTypesLength = superTypes.length;
|
|
436
|
+
|
|
437
|
+
if (superTypesLength === 0) {
|
|
438
|
+
const superType = objectType; ///
|
|
439
|
+
|
|
440
|
+
superTypes.push(superType);
|
|
441
|
+
}
|
|
333
442
|
|
|
334
443
|
return superTypes;
|
|
335
444
|
}
|
|
@@ -350,10 +459,11 @@ class ObjectType extends Type {
|
|
|
350
459
|
static fromNothing() {
|
|
351
460
|
const name = OBJECT_TYPE_NAME,
|
|
352
461
|
string = name, ///
|
|
462
|
+
prefixName = null,
|
|
353
463
|
superTypes = [],
|
|
354
464
|
properties = [],
|
|
355
465
|
provisional = false,
|
|
356
|
-
objectType = new ObjectType(string, name, superTypes, properties, provisional);
|
|
466
|
+
objectType = new ObjectType(string, name, prefixName, superTypes, properties, provisional);
|
|
357
467
|
|
|
358
468
|
return objectType;
|
|
359
469
|
}
|
package/src/dom/variable.js
CHANGED
|
@@ -92,12 +92,12 @@ export default domAssigned(class Variable {
|
|
|
92
92
|
verifyType(context) {
|
|
93
93
|
let typeVerifies = false;
|
|
94
94
|
|
|
95
|
-
const
|
|
96
|
-
typeString = this.type.getString();
|
|
95
|
+
const typeString = this.type.getString();
|
|
97
96
|
|
|
98
97
|
context.trace(`Verifying the '${typeString}' type...`);
|
|
99
98
|
|
|
100
|
-
const
|
|
99
|
+
const prefixedTypeName = this.type.getPrefixedName(),
|
|
100
|
+
type = context.findTypeByPrefixedTypeName(prefixedTypeName);
|
|
101
101
|
|
|
102
102
|
if (type === null) {
|
|
103
103
|
context.debug(`The '${typeString}' type is not present.`);
|
|
@@ -217,7 +217,7 @@ export default domAssigned(class Variable {
|
|
|
217
217
|
const { Variable } = dom,
|
|
218
218
|
provisional = variableDeclarationNode.isProvisional(),
|
|
219
219
|
typeNode = variableDeclarationNode.getTypeNode(),
|
|
220
|
-
type = typeFromTypeNode(typeNode);
|
|
220
|
+
type = typeFromTypeNode(typeNode, context);
|
|
221
221
|
|
|
222
222
|
type.setProvisional(provisional);
|
|
223
223
|
|