occam-verify-cli 1.0.682 → 1.0.685
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/action/verify.js +25 -20
- package/lib/context/ephemeral.js +2 -2
- package/lib/context/file/nominal.js +3 -3
- package/lib/element/assertion/contained.js +8 -4
- package/lib/element/assertion/defined.js +7 -4
- package/lib/element/assertion/type.js +3 -3
- package/lib/element/assumption.js +2 -8
- package/lib/element/constructor.js +4 -3
- package/lib/element/frame.js +7 -8
- package/lib/element/hypothesis.js +3 -2
- package/lib/element/metaType.js +4 -2
- package/lib/element/metavariable.js +2 -2
- package/lib/element/parameter.js +6 -3
- package/lib/element/procedureCall.js +5 -4
- package/lib/element/procedureReference.js +4 -2
- package/lib/element/property.js +4 -2
- package/lib/element/reference.js +3 -3
- package/lib/element/rule.js +3 -2
- package/lib/element/substitution/frame.js +19 -1
- package/lib/element/substitution/reference.js +19 -1
- package/lib/element/substitution/statement.js +12 -6
- package/lib/element/substitution/term.js +19 -1
- package/lib/element/type.js +4 -4
- package/lib/element/typePrefix.js +4 -2
- package/lib/element/variable.js +5 -3
- package/lib/utilities/json.js +54 -41
- package/package.json +2 -2
- package/src/action/verify.js +17 -6
- package/src/context/ephemeral.js +2 -2
- package/src/context/file/nominal.js +2 -2
- package/src/element/assertion/contained.js +14 -3
- package/src/element/assertion/defined.js +11 -3
- package/src/element/assertion/type.js +2 -2
- package/src/element/assumption.js +1 -12
- package/src/element/constructor.js +3 -1
- package/src/element/frame.js +11 -11
- package/src/element/hypothesis.js +2 -0
- package/src/element/metaType.js +5 -1
- package/src/element/metavariable.js +3 -3
- package/src/element/parameter.js +9 -2
- package/src/element/procedureCall.js +7 -4
- package/src/element/procedureReference.js +5 -1
- package/src/element/property.js +7 -2
- package/src/element/reference.js +3 -2
- package/src/element/rule.js +2 -0
- package/src/element/substitution/frame.js +30 -0
- package/src/element/substitution/reference.js +29 -0
- package/src/element/substitution/statement.js +19 -9
- package/src/element/substitution/term.js +30 -0
- package/src/element/type.js +11 -7
- package/src/element/typePrefix.js +5 -1
- package/src/element/variable.js +9 -3
- package/src/utilities/json.js +52 -54
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import Assertion from "../assertion";
|
|
4
4
|
|
|
5
5
|
import { define } from "../../elements";
|
|
6
|
+
import { termToTermJSON, frameToFrameJSON, negatedToNegatedJSON, statementToStatementJSON } from "../../utilities/json";
|
|
6
7
|
import { termFromTermAndSubstitutions, frameFromFrameAndSubstitutions, statementFromStatementAndSubstitutions } from "../../utilities/substitutions";
|
|
7
8
|
|
|
8
9
|
export default define(class ContainedAssertion extends Assertion {
|
|
@@ -237,13 +238,23 @@ export default define(class ContainedAssertion extends Assertion {
|
|
|
237
238
|
}
|
|
238
239
|
|
|
239
240
|
toJSON() {
|
|
240
|
-
debugger
|
|
241
|
-
|
|
242
241
|
const { name } = this.constructor,
|
|
242
|
+
termJSON = termToTermJSON(this.term),
|
|
243
|
+
frameJSON = frameToFrameJSON(this.frame),
|
|
244
|
+
negatedJSON = negatedToNegatedJSON(this.negated),
|
|
245
|
+
statementJSON = statementToStatementJSON(this.statement),
|
|
246
|
+
term = termJSON, ///
|
|
247
|
+
frame = frameJSON, ///
|
|
248
|
+
negated = negatedJSON, ///
|
|
249
|
+
statement = statementJSON, ///
|
|
243
250
|
string = this.getString(),
|
|
244
251
|
json = {
|
|
245
252
|
name,
|
|
246
|
-
string
|
|
253
|
+
string,
|
|
254
|
+
term,
|
|
255
|
+
frame,
|
|
256
|
+
negated,
|
|
257
|
+
statement
|
|
247
258
|
};
|
|
248
259
|
|
|
249
260
|
return json;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import Assertion from "../assertion";
|
|
4
4
|
|
|
5
5
|
import { define } from "../../elements";
|
|
6
|
+
import { termToTermJSON, frameToFrameJSON, negatedToNegatedJSON } from "../../utilities/json";
|
|
6
7
|
import { termFromTermAndSubstitutions, frameFromFrameAndSubstitutions } from "../../utilities/substitutions";
|
|
7
8
|
|
|
8
9
|
export default define(class DefinedAssertion extends Assertion {
|
|
@@ -206,13 +207,20 @@ export default define(class DefinedAssertion extends Assertion {
|
|
|
206
207
|
}
|
|
207
208
|
|
|
208
209
|
toJSON() {
|
|
209
|
-
debugger
|
|
210
|
-
|
|
211
210
|
const { name } = this.constructor,
|
|
211
|
+
termJSON = termToTermJSON(this.term),
|
|
212
|
+
frameJSON = frameToFrameJSON(this.frame),
|
|
213
|
+
negatedJSON = negatedToNegatedJSON(this.negated),
|
|
214
|
+
term = termJSON, ///
|
|
215
|
+
frame = frameJSON, ///
|
|
216
|
+
negated = negatedJSON, ///
|
|
212
217
|
string = this.getString(),
|
|
213
218
|
json = {
|
|
214
219
|
name,
|
|
215
|
-
string
|
|
220
|
+
string,
|
|
221
|
+
term,
|
|
222
|
+
frame,
|
|
223
|
+
negated
|
|
216
224
|
};
|
|
217
225
|
|
|
218
226
|
return json;
|
|
@@ -319,18 +319,7 @@ export default define(class Assumption extends Element {
|
|
|
319
319
|
}
|
|
320
320
|
|
|
321
321
|
toJSON() {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
const simple = this.isSimple();
|
|
325
|
-
|
|
326
|
-
if (simple) {
|
|
327
|
-
const reference = this, ///
|
|
328
|
-
referenceJSON = referenceToReferenceJSON(reference);
|
|
329
|
-
|
|
330
|
-
json = referenceJSON; ///
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
return json;
|
|
322
|
+
debugger
|
|
334
323
|
}
|
|
335
324
|
|
|
336
325
|
static name = "Assumption";
|
|
@@ -114,9 +114,11 @@ export default define(class Constructor extends Element {
|
|
|
114
114
|
|
|
115
115
|
toJSON() {
|
|
116
116
|
const termJSON = termToTermJSON(this.term),
|
|
117
|
+
string = this.getString(),
|
|
117
118
|
term = termJSON, ///
|
|
118
119
|
json = {
|
|
119
|
-
term
|
|
120
|
+
term,
|
|
121
|
+
string
|
|
120
122
|
};
|
|
121
123
|
|
|
122
124
|
return json;
|
package/src/element/frame.js
CHANGED
|
@@ -4,8 +4,8 @@ import { Element } from "occam-languages";
|
|
|
4
4
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
6
|
import { FRAME_META_TYPE_NAME } from "../metaTypeNames";
|
|
7
|
-
import { findMetaTypeByMetaTypeName } from "../metaTypes";
|
|
8
7
|
import { assumptionsStringFromAssumptions } from "../utilities/string";
|
|
8
|
+
import { assumptionsToAssumptionsJSON, metavariableToMetavariableJSON } from "../utilities/json";
|
|
9
9
|
|
|
10
10
|
export default define(class Frame extends Element {
|
|
11
11
|
constructor(context, string, node, assumptions, metavairable) {
|
|
@@ -346,16 +346,16 @@ export default define(class Frame extends Element {
|
|
|
346
346
|
}
|
|
347
347
|
|
|
348
348
|
toJSON() {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
349
|
+
const metavariableJSON = metavariableToMetavariableJSON(this.metavariable),
|
|
350
|
+
assumptionsJSON = assumptionsToAssumptionsJSON(this.assumptions),
|
|
351
|
+
metavariable = metavariableJSON, ///
|
|
352
|
+
assumptions = assumptionsJSON, ///
|
|
353
|
+
string = this.getString(),
|
|
354
|
+
json = {
|
|
355
|
+
string,
|
|
356
|
+
assumptions,
|
|
357
|
+
metavariable
|
|
358
|
+
};
|
|
359
359
|
|
|
360
360
|
return json;
|
|
361
361
|
}
|
package/src/element/metaType.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { Element } from "occam-languages";
|
|
4
4
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
|
+
import { nameToNameJSON } from "../utilities/json";
|
|
6
7
|
|
|
7
8
|
export default define(class MetaType extends Element {
|
|
8
9
|
constructor(context, string, node, name) {
|
|
@@ -35,8 +36,11 @@ export default define(class MetaType extends Element {
|
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
toJSON() {
|
|
38
|
-
const
|
|
39
|
+
const nameJSON = nameToNameJSON(this.name),
|
|
40
|
+
string = this.getString(),
|
|
41
|
+
name = nameJSON, ///
|
|
39
42
|
json = {
|
|
43
|
+
string,
|
|
40
44
|
name
|
|
41
45
|
};
|
|
42
46
|
|
|
@@ -438,13 +438,13 @@ export default define(class Metavariable extends Element {
|
|
|
438
438
|
}
|
|
439
439
|
|
|
440
440
|
toJSON() {
|
|
441
|
-
const
|
|
442
|
-
typeJSON = typeToTypeJSON(this.type),
|
|
441
|
+
const typeJSON = typeToTypeJSON(this.type),
|
|
443
442
|
nameJSON = nameToNameJSON(this.name),
|
|
443
|
+
metaTypeJSON = metaTypeToMetaTypeJSON(this.metaType),
|
|
444
|
+
name = nameJSON, ///
|
|
444
445
|
type = typeJSON, ///
|
|
445
446
|
metaType = metaTypeJSON, ///
|
|
446
447
|
string = this.getString(), ///
|
|
447
|
-
name = this.name,
|
|
448
448
|
json = {
|
|
449
449
|
string,
|
|
450
450
|
name,
|
package/src/element/parameter.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { Element } from "occam-languages";
|
|
4
4
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
|
+
import { nameToNameJSON, identifierToIdentifierJSON } from "../utilities/json";
|
|
6
7
|
|
|
7
8
|
export default define(class Parameter extends Element {
|
|
8
9
|
constructor(context, string, node, name, identifier) {
|
|
@@ -47,9 +48,15 @@ export default define(class Parameter extends Element {
|
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
toJSON() {
|
|
50
|
-
const
|
|
51
|
+
const nameJSON = nameToNameJSON(this.name),
|
|
52
|
+
identifierJSON = identifierToIdentifierJSON(this.identifier),
|
|
53
|
+
name = nameJSON, ///
|
|
54
|
+
identifier = identifierJSON, ///
|
|
55
|
+
string = this.getString(),
|
|
51
56
|
json = {
|
|
52
|
-
|
|
57
|
+
string,
|
|
58
|
+
name,
|
|
59
|
+
identifier
|
|
53
60
|
};
|
|
54
61
|
|
|
55
62
|
return json;
|
|
@@ -4,7 +4,7 @@ import { Element } from "occam-languages";
|
|
|
4
4
|
import { termsUtilities } from "occam-furtle";
|
|
5
5
|
|
|
6
6
|
import { define } from "../elements";
|
|
7
|
-
import {
|
|
7
|
+
import { parametersToParametersJSON, procedureReferenceToProcedureReferenceJSON } from "../utilities/json";
|
|
8
8
|
|
|
9
9
|
const { termsFromPrimitives } = termsUtilities;
|
|
10
10
|
|
|
@@ -113,11 +113,14 @@ export default define(class ProcedureCall extends Element {
|
|
|
113
113
|
|
|
114
114
|
toJSON() {
|
|
115
115
|
const parametersJSON = parametersToParametersJSON(this.parameters),
|
|
116
|
-
|
|
116
|
+
procedureReferenceJSON = procedureReferenceToProcedureReferenceJSON(this.procedureReference),
|
|
117
117
|
parameters = parametersJSON, ///
|
|
118
|
+
procedureReference = procedureReferenceJSON, ///
|
|
119
|
+
string = this.getString(),
|
|
118
120
|
json = {
|
|
119
|
-
|
|
120
|
-
parameters
|
|
121
|
+
string,
|
|
122
|
+
parameters,
|
|
123
|
+
procedureReference
|
|
121
124
|
};
|
|
122
125
|
|
|
123
126
|
return json;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { Element } from "occam-languages";
|
|
4
4
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
|
+
import {nameToNameJSON} from "../utilities/json";
|
|
6
7
|
|
|
7
8
|
export default define(class ProcedureReference extends Element {
|
|
8
9
|
constructor(context, string, node, name) {
|
|
@@ -28,8 +29,11 @@ export default define(class ProcedureReference extends Element {
|
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
toJSON() {
|
|
31
|
-
const
|
|
32
|
+
const nameJSON = nameToNameJSON(this.name),
|
|
33
|
+
name = nameJSON, ///
|
|
34
|
+
string = this.getString(),
|
|
32
35
|
json = {
|
|
36
|
+
string,
|
|
33
37
|
name
|
|
34
38
|
};
|
|
35
39
|
|
package/src/element/property.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { Element } from "occam-languages";
|
|
4
4
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
|
+
import {nameToNameJSON} from "../utilities/json";
|
|
6
7
|
|
|
7
8
|
export default define(class Property extends Element {
|
|
8
9
|
constructor(context, string, node, name, nominalTypeName) {
|
|
@@ -40,9 +41,13 @@ export default define(class Property extends Element {
|
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
toJSON() {
|
|
43
|
-
const
|
|
44
|
-
|
|
44
|
+
const nominalTypeNameJSON = nameToNameJSON(this.nominalTypeName),
|
|
45
|
+
nameJSON = nameToNameJSON(this.name),
|
|
46
|
+
nominalTypeName = nominalTypeNameJSON, ///
|
|
47
|
+
name = nameJSON, ///
|
|
48
|
+
string = this.getString(),
|
|
45
49
|
json = {
|
|
50
|
+
string,
|
|
46
51
|
name,
|
|
47
52
|
nominalTypeName
|
|
48
53
|
};
|
package/src/element/reference.js
CHANGED
|
@@ -5,9 +5,8 @@ import { Element } from "occam-languages";
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
6
|
import { attempt } from "../utilities/context";
|
|
7
7
|
import { REFERENCE_META_TYPE_NAME } from "../metaTypeNames";
|
|
8
|
-
import { findMetaTypeByMetaTypeName } from "../metaTypes";
|
|
9
8
|
import { unifyMetavariableIntrinsically } from "../process/unify";
|
|
10
|
-
import {
|
|
9
|
+
import { metavariableToMetavariableJSON } from "../utilities/json";
|
|
11
10
|
|
|
12
11
|
export default define(class Reference extends Element {
|
|
13
12
|
constructor(context, string, node, metavariable) {
|
|
@@ -294,7 +293,9 @@ export default define(class Reference extends Element {
|
|
|
294
293
|
toJSON() {
|
|
295
294
|
const metavariableJSON = metavariableToMetavariableJSON(this.metavariable),
|
|
296
295
|
metavariable = metavariableJSON, ///
|
|
296
|
+
string = this.getString(),
|
|
297
297
|
json = {
|
|
298
|
+
string,
|
|
298
299
|
metavariable
|
|
299
300
|
};
|
|
300
301
|
|
package/src/element/rule.js
CHANGED
|
@@ -4,6 +4,7 @@ import Substitution from "../substitution";
|
|
|
4
4
|
|
|
5
5
|
import { define } from "../../elements";
|
|
6
6
|
import { literally } from "../../utilities/context";
|
|
7
|
+
import { frameToFrameJSON } from "../../utilities/json";
|
|
7
8
|
import { instantiateFrameSubstitution } from "../../process/instantiate";
|
|
8
9
|
import { frameSubstitutionStringFromFrameAndMetavariable } from "../../utilities/string";
|
|
9
10
|
import { frameSubstitutionFromStatementNode, frameSubstitutionFromFrameSubstitutionNode } from "../../utilities/element";
|
|
@@ -170,8 +171,37 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
170
171
|
return replacementFrameValidates;
|
|
171
172
|
}
|
|
172
173
|
|
|
174
|
+
toJSON() {
|
|
175
|
+
const { name } = this.constructor,
|
|
176
|
+
targetFrameJSON = frameToFrameJSON(this.targetFrame),
|
|
177
|
+
replacementFrameJSON = frameToFrameJSON(this.replacementFrame),
|
|
178
|
+
targetFrame = targetFrameJSON, ///
|
|
179
|
+
replacementFrame = replacementFrameJSON, ///
|
|
180
|
+
string = this.getString(),
|
|
181
|
+
json = {
|
|
182
|
+
name,
|
|
183
|
+
string,
|
|
184
|
+
targetFrame,
|
|
185
|
+
replacementFrame
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
return json;
|
|
189
|
+
}
|
|
190
|
+
|
|
173
191
|
static name = "FrameSubstitution";
|
|
174
192
|
|
|
193
|
+
static fromJSON(json, context) {
|
|
194
|
+
let frameSubstitutionn = null;
|
|
195
|
+
|
|
196
|
+
const { name } = json;
|
|
197
|
+
|
|
198
|
+
if (this.name === name) {
|
|
199
|
+
debugger
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return frameSubstitutionn;
|
|
203
|
+
}
|
|
204
|
+
|
|
175
205
|
static fromStatement(statement, context) {
|
|
176
206
|
const statementNode = statement.getNode(),
|
|
177
207
|
frameSubstitution = frameSubstitutionFromStatementNode(statementNode, context);
|
|
@@ -4,6 +4,7 @@ import Substitution from "../substitution";
|
|
|
4
4
|
|
|
5
5
|
import { define } from "../../elements";
|
|
6
6
|
import { literally } from "../../utilities/context";
|
|
7
|
+
import { statementToStatementJSON } from "../../utilities/json";
|
|
7
8
|
import { instantiateReferenceSubstitution } from "../../process/instantiate";
|
|
8
9
|
import { referenceSubstitutionFromReferenceSubstitutionNode } from "../../utilities/element";
|
|
9
10
|
import { referenceSubstitutionStringFromReferenceAndMetavariable } from "../../utilities/string";
|
|
@@ -164,6 +165,34 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
164
165
|
return replacementReferenceValidates;
|
|
165
166
|
}
|
|
166
167
|
|
|
168
|
+
toJSON() {
|
|
169
|
+
const { name } = this.constructor,
|
|
170
|
+
targetStatementJSON = statementToStatementJSON(this.targetStatement),
|
|
171
|
+
replacementStatementJSON = statementToStatementJSON(this.replacementStatement),
|
|
172
|
+
targetStatement = targetStatementJSON, ///
|
|
173
|
+
replacementStatement = replacementStatementJSON, ///
|
|
174
|
+
string = this.getString(),
|
|
175
|
+
json = {
|
|
176
|
+
name,
|
|
177
|
+
string,
|
|
178
|
+
targetStatement,
|
|
179
|
+
replacementStatement
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
return json;
|
|
183
|
+
}
|
|
184
|
+
static fromJSON(json, context) {
|
|
185
|
+
let referenceSubstitutionn = null;
|
|
186
|
+
|
|
187
|
+
const { name } = json;
|
|
188
|
+
|
|
189
|
+
if (this.name === name) {
|
|
190
|
+
debugger
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return referenceSubstitutionn;
|
|
194
|
+
}
|
|
195
|
+
|
|
167
196
|
static name = "ReferenceSubstitution";
|
|
168
197
|
|
|
169
198
|
static fromReferenceAndMetavariable(reference, metavariable, context) {
|
|
@@ -4,11 +4,11 @@ import Substitution from "../substitution";
|
|
|
4
4
|
|
|
5
5
|
import { define } from "../../elements";
|
|
6
6
|
import { unifySubstitution } from "../../process/unify";
|
|
7
|
+
import { statementToStatementJSON } from "../../utilities/json";
|
|
7
8
|
import { stripBracketsFromStatement } from "../../utilities/brackets";
|
|
8
9
|
import { instantiateStatementSubstitution } from "../../process/instantiate";
|
|
9
10
|
import { liminally, literally, synthetically } from "../../utilities/context";
|
|
10
11
|
import { statementSubstitutionFromStatementSubstitutionNode } from "../../utilities/element";
|
|
11
|
-
import { statementToStatementJSON, metavariableToMetavariableJSON } from "../../utilities/json";
|
|
12
12
|
import { statementSubstitutionStringFromStatementAndMetavariable, statementSubstitutionStringFromStatementMetavariableAndSubstitution } from "../../utilities/string";
|
|
13
13
|
|
|
14
14
|
export default define(class StatementSubstitution extends Substitution {
|
|
@@ -321,15 +321,17 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
321
321
|
}
|
|
322
322
|
|
|
323
323
|
toJSON() {
|
|
324
|
-
const
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
324
|
+
const { name } = this.constructor,
|
|
325
|
+
targetStatementJSON = statementToStatementJSON(this.targetStatement),
|
|
326
|
+
replacementStatementJSON = statementToStatementJSON(this.replacementStatement),
|
|
327
|
+
targetStatement = targetStatementJSON, ///
|
|
328
|
+
replacementStatement = replacementStatementJSON, ///
|
|
329
|
+
string = this.getString(),
|
|
329
330
|
json = {
|
|
331
|
+
name,
|
|
330
332
|
string,
|
|
331
|
-
|
|
332
|
-
|
|
333
|
+
targetStatement,
|
|
334
|
+
replacementStatement
|
|
333
335
|
};
|
|
334
336
|
|
|
335
337
|
return json;
|
|
@@ -338,7 +340,15 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
338
340
|
static name = "StatementSubstitution";
|
|
339
341
|
|
|
340
342
|
static fromJSON(json, context) {
|
|
341
|
-
|
|
343
|
+
let statementSubstitutionn = null;
|
|
344
|
+
|
|
345
|
+
const { name } = json;
|
|
346
|
+
|
|
347
|
+
if (this.name === name) {
|
|
348
|
+
debugger
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
return statementSubstitutionn;
|
|
342
352
|
}
|
|
343
353
|
|
|
344
354
|
static fromStatementAndMetavariable(statement, metavariable, context) {
|
|
@@ -4,6 +4,7 @@ import Substitution from "../substitution";
|
|
|
4
4
|
|
|
5
5
|
import { define } from "../../elements";
|
|
6
6
|
import { literally } from "../../utilities/context";
|
|
7
|
+
import { termToTermJSON } from "../../utilities/json";
|
|
7
8
|
import { stripBracketsFromTerm } from "../../utilities/brackets";
|
|
8
9
|
import { instantiateTermSubstitution } from "../../process/instantiate";
|
|
9
10
|
import { termSubstitutionStringFromTermAndVariable } from "../../utilities/string";
|
|
@@ -179,8 +180,37 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
179
180
|
return replacementTermValidates;
|
|
180
181
|
}
|
|
181
182
|
|
|
183
|
+
toJSON() {
|
|
184
|
+
const { name } = this.constructor,
|
|
185
|
+
targetTermJSON = termToTermJSON(this.targetTerm),
|
|
186
|
+
replacementTermJSON = termToTermJSON(this.replacementTerm),
|
|
187
|
+
targetTerm = targetTermJSON, ///
|
|
188
|
+
replacementTerm = replacementTermJSON, ///
|
|
189
|
+
string = this.getString(),
|
|
190
|
+
json = {
|
|
191
|
+
name,
|
|
192
|
+
string,
|
|
193
|
+
targetTerm,
|
|
194
|
+
replacementTerm
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
return json;
|
|
198
|
+
}
|
|
199
|
+
|
|
182
200
|
static name = "TermSubstitution";
|
|
183
201
|
|
|
202
|
+
static fromJSON(json, context) {
|
|
203
|
+
let termSubstitutionn = null;
|
|
204
|
+
|
|
205
|
+
const { name } = json;
|
|
206
|
+
|
|
207
|
+
if (this.name === name) {
|
|
208
|
+
debugger
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return termSubstitutionn;
|
|
212
|
+
}
|
|
213
|
+
|
|
184
214
|
static fromStatement(statement, context) {
|
|
185
215
|
const statementNode = statement.getNode(),
|
|
186
216
|
termSubstitution = termSubstitutionFromStatementNode(statementNode, context);
|
package/src/element/type.js
CHANGED
|
@@ -5,8 +5,7 @@ import { arrayUtilities } from "necessary";
|
|
|
5
5
|
|
|
6
6
|
import { define } from "../elements";
|
|
7
7
|
import { baseTypeFromNothing } from "../utilities/type";
|
|
8
|
-
import {
|
|
9
|
-
import { superTypesFromJSON, propertiesFromJSON, superTypesToSuperTypesJSON, propertiesToPropertiesJSON } from "../utilities/json";
|
|
8
|
+
import { nameToNameJSON, superTypesToSuperTypesJSON, propertiesToPropertiesJSON, provisionalToProvisionalJSON } from "../utilities/json";
|
|
10
9
|
|
|
11
10
|
const { push, first } = arrayUtilities;
|
|
12
11
|
|
|
@@ -293,18 +292,23 @@ export default define(class Type extends Element {
|
|
|
293
292
|
}
|
|
294
293
|
|
|
295
294
|
toJSON() {
|
|
296
|
-
const
|
|
295
|
+
const nameJSON = nameToNameJSON(this.name),
|
|
296
|
+
prefixNameJSON = nameToNameJSON(this.prefixName),
|
|
297
|
+
propertiesJSON = propertiesToPropertiesJSON(this.properties),
|
|
297
298
|
superTypesJSON = superTypesToSuperTypesJSON(this.superTypes),
|
|
298
|
-
|
|
299
|
+
provisionalJSON = provisionalToProvisionalJSON(this.provisional),
|
|
300
|
+
name = nameJSON, ///
|
|
301
|
+
prefixName = prefixNameJSON, ///
|
|
299
302
|
properties = propertiesJSON, ///
|
|
300
303
|
superTypes = superTypesJSON, ///
|
|
301
|
-
|
|
302
|
-
|
|
304
|
+
provisional = provisionalJSON, ///
|
|
305
|
+
string = this.getString(),
|
|
303
306
|
json = {
|
|
307
|
+
string,
|
|
304
308
|
name,
|
|
305
309
|
prefixName,
|
|
306
|
-
superTypes,
|
|
307
310
|
properties,
|
|
311
|
+
superTypes,
|
|
308
312
|
provisional
|
|
309
313
|
};
|
|
310
314
|
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { Element } from "occam-languages";
|
|
4
4
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
|
+
import {nameToNameJSON} from "../utilities/json";
|
|
6
7
|
|
|
7
8
|
export default define(class TypePrefix extends Element {
|
|
8
9
|
constructor(context, string, node, name) {
|
|
@@ -29,8 +30,11 @@ export default define(class TypePrefix extends Element {
|
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
toJSON() {
|
|
32
|
-
const
|
|
33
|
+
const nameJSON = nameToNameJSON(this.name),
|
|
34
|
+
name = nameJSON, ///
|
|
35
|
+
string = this.getString(),
|
|
33
36
|
json = {
|
|
37
|
+
string,
|
|
34
38
|
name
|
|
35
39
|
};
|
|
36
40
|
|
package/src/element/variable.js
CHANGED
|
@@ -5,7 +5,7 @@ import { Element } from "occam-languages";
|
|
|
5
5
|
import elements from "../elements";
|
|
6
6
|
|
|
7
7
|
import { define } from "../elements";
|
|
8
|
-
import { typeToTypeJSON } from "../utilities/json";
|
|
8
|
+
import { typeToTypeJSON, identifierToIdentifierJSON, propertyRelationsToPropertyRelationsJSON } from "../utilities/json";
|
|
9
9
|
|
|
10
10
|
export default define(class Variable extends Element {
|
|
11
11
|
constructor(context, string, node, type, identifier, propertyRelations) {
|
|
@@ -189,11 +189,17 @@ export default define(class Variable extends Element {
|
|
|
189
189
|
|
|
190
190
|
toJSON() {
|
|
191
191
|
const typeJSON = typeToTypeJSON(this.type),
|
|
192
|
-
|
|
192
|
+
identifierJSON = identifierToIdentifierJSON(this.identifier),
|
|
193
|
+
propertyRelationsJSON = propertyRelationsToPropertyRelationsJSON(this.propertyRelations),
|
|
193
194
|
type = typeJSON, ///
|
|
195
|
+
identifier = identifierJSON, ///
|
|
196
|
+
propertyRelations = propertyRelationsJSON, ///
|
|
197
|
+
string = this.getString(), ///
|
|
194
198
|
json = {
|
|
199
|
+
string,
|
|
195
200
|
type,
|
|
196
|
-
|
|
201
|
+
identifier,
|
|
202
|
+
propertyRelations
|
|
197
203
|
};
|
|
198
204
|
|
|
199
205
|
return json;
|