occam-verify-cli 1.0.695 → 1.0.702

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.
Files changed (91) hide show
  1. package/lib/action/verify.js +3 -2
  2. package/lib/context/ephemeral.js +14 -5
  3. package/lib/context.js +9 -1
  4. package/lib/element/assertion/contained.js +6 -9
  5. package/lib/element/assertion/defined.js +6 -8
  6. package/lib/element/assertion/property.js +11 -5
  7. package/lib/element/assertion/satisfies.js +9 -3
  8. package/lib/element/assertion/subproof.js +4 -5
  9. package/lib/element/assertion/type.js +12 -7
  10. package/lib/element/assumption.js +22 -4
  11. package/lib/element/combinator.js +6 -6
  12. package/lib/element/conclusion.js +5 -5
  13. package/lib/element/constructor.js +9 -4
  14. package/lib/element/deduction.js +5 -5
  15. package/lib/element/equality.js +26 -1
  16. package/lib/element/frame.js +14 -7
  17. package/lib/element/hypothesis.js +13 -6
  18. package/lib/element/judgement.js +69 -3
  19. package/lib/element/label.js +27 -22
  20. package/lib/element/metaType.js +1 -1
  21. package/lib/element/metavariable.js +4 -4
  22. package/lib/element/parameter.js +7 -7
  23. package/lib/element/procedureCall.js +7 -7
  24. package/lib/element/procedureReference.js +7 -6
  25. package/lib/element/proofAssertion/premise.js +6 -7
  26. package/lib/element/proofAssertion/supposition.js +6 -7
  27. package/lib/element/property.js +12 -4
  28. package/lib/element/propertyRelation.js +28 -6
  29. package/lib/element/reference.js +10 -6
  30. package/lib/element/rule.js +26 -16
  31. package/lib/element/signature.js +59 -19
  32. package/lib/element/statement.js +4 -2
  33. package/lib/element/substitution/frame.js +16 -7
  34. package/lib/element/substitution/reference.js +17 -8
  35. package/lib/element/substitution/statement.js +17 -8
  36. package/lib/element/substitution/term.js +17 -8
  37. package/lib/element/term.js +4 -2
  38. package/lib/element/topLevelAssertion.js +28 -17
  39. package/lib/element/topLevelMetaAssertion.js +7 -8
  40. package/lib/element/type.js +16 -9
  41. package/lib/element/typePrefix.js +13 -6
  42. package/lib/element/variable.js +8 -11
  43. package/lib/process/instantiate.js +75 -11
  44. package/lib/utilities/element.js +101 -7
  45. package/lib/utilities/json.js +15 -1
  46. package/package.json +4 -4
  47. package/src/action/verify.js +3 -1
  48. package/src/context/ephemeral.js +19 -4
  49. package/src/context.js +15 -1
  50. package/src/element/assertion/contained.js +8 -25
  51. package/src/element/assertion/defined.js +7 -14
  52. package/src/element/assertion/property.js +16 -5
  53. package/src/element/assertion/satisfies.js +14 -3
  54. package/src/element/assertion/subproof.js +3 -5
  55. package/src/element/assertion/type.js +16 -8
  56. package/src/element/assumption.js +37 -3
  57. package/src/element/combinator.js +6 -13
  58. package/src/element/conclusion.js +5 -7
  59. package/src/element/constructor.js +13 -6
  60. package/src/element/deduction.js +7 -9
  61. package/src/element/equality.js +43 -0
  62. package/src/element/frame.js +21 -12
  63. package/src/element/hypothesis.js +19 -7
  64. package/src/element/judgement.js +45 -0
  65. package/src/element/label.js +35 -26
  66. package/src/element/metaType.js +1 -1
  67. package/src/element/metavariable.js +3 -6
  68. package/src/element/parameter.js +9 -12
  69. package/src/element/procedureCall.js +9 -12
  70. package/src/element/procedureReference.js +8 -8
  71. package/src/element/proofAssertion/premise.js +8 -14
  72. package/src/element/proofAssertion/supposition.js +6 -12
  73. package/src/element/property.js +20 -6
  74. package/src/element/propertyRelation.js +43 -6
  75. package/src/element/reference.js +16 -9
  76. package/src/element/rule.js +41 -24
  77. package/src/element/signature.js +87 -22
  78. package/src/element/statement.js +5 -2
  79. package/src/element/substitution/frame.js +26 -9
  80. package/src/element/substitution/reference.js +29 -11
  81. package/src/element/substitution/statement.js +27 -10
  82. package/src/element/substitution/term.js +27 -10
  83. package/src/element/term.js +5 -2
  84. package/src/element/topLevelAssertion.js +44 -25
  85. package/src/element/topLevelMetaAssertion.js +7 -8
  86. package/src/element/type.js +30 -19
  87. package/src/element/typePrefix.js +19 -7
  88. package/src/element/variable.js +9 -22
  89. package/src/process/instantiate.js +60 -10
  90. package/src/utilities/element.js +105 -10
  91. package/src/utilities/json.js +13 -1
@@ -350,8 +350,11 @@ export default define(class Statement extends Element {
350
350
  const statement = literally((context) => {
351
351
  const { string } = json,
352
352
  statementNode = instantiateStatement(string, context),
353
- node = statementNode, ///
354
- statement = new Statement(context, string, node);
353
+ node = statementNode; ///
354
+
355
+ context = null;
356
+
357
+ const statement = new Statement(context, string, node);
355
358
 
356
359
  return statement;
357
360
  }, context);
@@ -4,7 +4,6 @@ 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";
8
7
  import { instantiateFrameSubstitution } from "../../process/instantiate";
9
8
  import { frameSubstitutionStringFromFrameAndMetavariable } from "../../utilities/string";
10
9
  import { frameSubstitutionFromStatementNode, frameSubstitutionFromFrameSubstitutionNode } from "../../utilities/element";
@@ -173,16 +172,10 @@ export default define(class FrameSubstitution extends Substitution {
173
172
 
174
173
  toJSON() {
175
174
  const { name } = this.constructor,
176
- targetFrameJSON = frameToFrameJSON(this.targetFrame),
177
- replacementFrameJSON = frameToFrameJSON(this.replacementFrame),
178
- targetFrame = targetFrameJSON, ///
179
- replacementFrame = replacementFrameJSON, ///
180
175
  string = this.getString(),
181
176
  json = {
182
177
  name,
183
- string,
184
- targetFrame,
185
- replacementFrame
178
+ string
186
179
  };
187
180
 
188
181
  return json;
@@ -196,7 +189,17 @@ export default define(class FrameSubstitution extends Substitution {
196
189
  const { name } = json;
197
190
 
198
191
  if (this.name === name) {
199
- debugger
192
+ literally((context) => {
193
+ const { string } = json,
194
+ frameSubstitutionNode = instantiateFrameSubstitution(string, context),
195
+ node = frameSubstitutionNode, ///
196
+ targetFrame = targetFrameFromFrameSubstitutionNode(frameSubstitutionNode, context),
197
+ replacementFrame = replacementFrameFromFrameSubstitutionNode(frameSubstitutionNode, context);
198
+
199
+ context = null;
200
+
201
+ frameSubstitutionn = new FrameSubstitution(context, string, node, targetFrame, replacementFrame);
202
+ }, context);
200
203
  }
201
204
 
202
205
  return frameSubstitutionn;
@@ -220,3 +223,17 @@ export default define(class FrameSubstitution extends Substitution {
220
223
  }, context);
221
224
  }
222
225
  });
226
+
227
+ function targetFrameFromFrameSubstitutionNode(frameSubstitutionNode, context) {
228
+ const targetFrameNode = frameSubstitutionNode.getTargetFrameNode(),
229
+ targetFrame = context.findFrameByFrameNode(targetFrameNode);
230
+
231
+ return targetFrame;
232
+ }
233
+
234
+ function replacementFrameFromFrameSubstitutionNode(frameSubstitutionNode, context) {
235
+ const replacementFrameNode = frameSubstitutionNode.getReplacementFrameNode(),
236
+ replacementFrame = context.findFrameByFrameNode(replacementFrameNode);
237
+
238
+ return replacementFrame;
239
+ }
@@ -4,7 +4,6 @@ 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";
8
7
  import { instantiateReferenceSubstitution } from "../../process/instantiate";
9
8
  import { referenceSubstitutionFromReferenceSubstitutionNode } from "../../utilities/element";
10
9
  import { referenceSubstitutionStringFromReferenceAndMetavariable } from "../../utilities/string";
@@ -167,34 +166,39 @@ export default define(class ReferenceSubstitution extends Substitution {
167
166
 
168
167
  toJSON() {
169
168
  const { name } = this.constructor,
170
- targetStatementJSON = statementToStatementJSON(this.targetStatement),
171
- replacementStatementJSON = statementToStatementJSON(this.replacementStatement),
172
- targetStatement = targetStatementJSON, ///
173
- replacementStatement = replacementStatementJSON, ///
174
169
  string = this.getString(),
175
170
  json = {
176
171
  name,
177
- string,
178
- targetStatement,
179
- replacementStatement
172
+ string
180
173
  };
181
174
 
182
175
  return json;
183
176
  }
177
+
178
+ static name = "ReferenceSubstitution";
179
+
184
180
  static fromJSON(json, context) {
185
181
  let referenceSubstitutionn = null;
186
182
 
187
183
  const { name } = json;
188
184
 
189
185
  if (this.name === name) {
190
- debugger
186
+ literally((context) => {
187
+ const { string } = json,
188
+ referenceSubstitutionNode = instantiateReferenceSubstitution(string, context),
189
+ node = referenceSubstitutionNode, ///
190
+ targetReference = targetReferenceFromReferenceSubstitutionNode(referenceSubstitutionNode, context),
191
+ replacementReference = replacementReferenceFromReferenceSubstitutionNode(referenceSubstitutionNode, context);
192
+
193
+ context = null;
194
+
195
+ referenceSubstitutionn = new ReferenceSubstitution(context, string, node, targetReference, replacementReference);
196
+ }, context);
191
197
  }
192
198
 
193
199
  return referenceSubstitutionn;
194
200
  }
195
201
 
196
- static name = "ReferenceSubstitution";
197
-
198
202
  static fromReferenceAndMetavariable(reference, metavariable, context) {
199
203
  return literally((context) => {
200
204
  const referenceSubstitutionString = referenceSubstitutionStringFromReferenceAndMetavariable(reference, metavariable),
@@ -206,3 +210,17 @@ export default define(class ReferenceSubstitution extends Substitution {
206
210
  }, context);
207
211
  }
208
212
  });
213
+
214
+ function targetReferenceFromReferenceSubstitutionNode(frameSubstitutionNode, context) {
215
+ const targetReferenceNode = frameSubstitutionNode.getTargetReferenceNode(),
216
+ targetReference = context.findReferenceByReferenceNode(targetReferenceNode);
217
+
218
+ return targetReference;
219
+ }
220
+
221
+ function replacementReferenceFromReferenceSubstitutionNode(frameSubstitutionNode, context) {
222
+ const replacementReferenceNode = frameSubstitutionNode.getReplacementReferenceNode(),
223
+ replacementReference = context.findReferenceByReferenceNode(replacementReferenceNode);
224
+
225
+ return replacementReference;
226
+ }
@@ -4,11 +4,10 @@ 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";
8
7
  import { stripBracketsFromStatement } from "../../utilities/brackets";
9
- import { instantiateStatementSubstitution } from "../../process/instantiate";
10
8
  import { liminally, literally, synthetically } from "../../utilities/context";
11
9
  import { statementSubstitutionFromStatementSubstitutionNode } from "../../utilities/element";
10
+ import { instantiateReferenceSubstitution, instantiateStatementSubstitution } from "../../process/instantiate";
12
11
  import { statementSubstitutionStringFromStatementAndMetavariable, statementSubstitutionStringFromStatementMetavariableAndSubstitution } from "../../utilities/string";
13
12
 
14
13
  export default define(class StatementSubstitution extends Substitution {
@@ -322,16 +321,10 @@ export default define(class StatementSubstitution extends Substitution {
322
321
 
323
322
  toJSON() {
324
323
  const { name } = this.constructor,
325
- targetStatementJSON = statementToStatementJSON(this.targetStatement),
326
- replacementStatementJSON = statementToStatementJSON(this.replacementStatement),
327
- targetStatement = targetStatementJSON, ///
328
- replacementStatement = replacementStatementJSON, ///
329
324
  string = this.getString(),
330
325
  json = {
331
326
  name,
332
- string,
333
- targetStatement,
334
- replacementStatement
327
+ string
335
328
  };
336
329
 
337
330
  return json;
@@ -345,7 +338,17 @@ export default define(class StatementSubstitution extends Substitution {
345
338
  const { name } = json;
346
339
 
347
340
  if (this.name === name) {
348
- debugger
341
+ literally((context) => {
342
+ const { string } = json,
343
+ referenceSubstitutionNode = instantiateReferenceSubstitution(string, context),
344
+ node = referenceSubstitutionNode, ///
345
+ targetStatement = targetStatementFromReferenceSubstitutionNode(referenceSubstitutionNode, context),
346
+ replacementStatement = replacementStatementFromReferenceSubstitutionNode(referenceSubstitutionNode, context);
347
+
348
+ context = null;
349
+
350
+ statementSubstitutionn = new StatementSubstitution(context, string, node, targetStatement, replacementStatement);
351
+ }, context);
349
352
  }
350
353
 
351
354
  return statementSubstitutionn;
@@ -377,3 +380,17 @@ export default define(class StatementSubstitution extends Substitution {
377
380
  }, context);
378
381
  }
379
382
  });
383
+
384
+ function targetStatementFromReferenceSubstitutionNode(frameSubstitutionNode, context) {
385
+ const targetStatementNode = frameSubstitutionNode.getTargetReferenceNode(),
386
+ targetStatement = context.findReferenceByReferenceNode(targetStatementNode);
387
+
388
+ return targetStatement;
389
+ }
390
+
391
+ function replacementStatementFromReferenceSubstitutionNode(frameSubstitutionNode, context) {
392
+ const replacementStatementNode = frameSubstitutionNode.getReplacementReferenceNode(),
393
+ replacementStatement = context.findReferenceByReferenceNode(replacementStatementNode);
394
+
395
+ return replacementStatement;
396
+ }
@@ -4,10 +4,9 @@ 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";
8
7
  import { stripBracketsFromTerm } from "../../utilities/brackets";
9
- import { instantiateTermSubstitution } from "../../process/instantiate";
10
8
  import { termSubstitutionStringFromTermAndVariable } from "../../utilities/string";
9
+ import { instantiateFrameSubstitution, instantiateTermSubstitution } from "../../process/instantiate";
11
10
  import { termSubstitutionFromStatementNode, termSubstitutionFromTermSubstitutionNode } from "../../utilities/element";
12
11
 
13
12
  export default define(class TermSubstitution extends Substitution {
@@ -182,16 +181,10 @@ export default define(class TermSubstitution extends Substitution {
182
181
 
183
182
  toJSON() {
184
183
  const { name } = this.constructor,
185
- targetTermJSON = termToTermJSON(this.targetTerm),
186
- replacementTermJSON = termToTermJSON(this.replacementTerm),
187
- targetTerm = targetTermJSON, ///
188
- replacementTerm = replacementTermJSON, ///
189
184
  string = this.getString(),
190
185
  json = {
191
186
  name,
192
- string,
193
- targetTerm,
194
- replacementTerm
187
+ string
195
188
  };
196
189
 
197
190
  return json;
@@ -205,7 +198,17 @@ export default define(class TermSubstitution extends Substitution {
205
198
  const { name } = json;
206
199
 
207
200
  if (this.name === name) {
208
- debugger
201
+ literally((context) => {
202
+ const { string } = json,
203
+ frameSubstitutionNode = instantiateFrameSubstitution(string, context),
204
+ node = frameSubstitutionNode, ///
205
+ targetTerm = targetTermFromFrameSubstitutionNode(frameSubstitutionNode, context),
206
+ replacementTerm = replacementTermFromFrameSubstitutionNode(frameSubstitutionNode, context);
207
+
208
+ context = null;
209
+
210
+ termSubstitutionn = new TermSubstitution(context, string, node, targetTerm, replacementTerm);
211
+ }, context);
209
212
  }
210
213
 
211
214
  return termSubstitutionn;
@@ -231,3 +234,17 @@ export default define(class TermSubstitution extends Substitution {
231
234
  }, context);
232
235
  }
233
236
  });
237
+
238
+ function targetTermFromFrameSubstitutionNode(frameSubstitutionNode, context) {
239
+ const targetTermNode = frameSubstitutionNode.getTargetFrameNode(),
240
+ targetTerm = context.findFrameByFrameNode(targetTermNode);
241
+
242
+ return targetTerm;
243
+ }
244
+
245
+ function replacementTermFromFrameSubstitutionNode(frameSubstitutionNode, context) {
246
+ const replacementTermNode = frameSubstitutionNode.getReplacementFrameNode(),
247
+ replacementTerm = context.findFrameByFrameNode(replacementTermNode);
248
+
249
+ return replacementTerm;
250
+ }
@@ -241,8 +241,11 @@ export default define(class Term extends Element {
241
241
  const { string } = json,
242
242
  termNode = instantiateTerm(string, context),
243
243
  node = termNode, ///
244
- type = typeFromJSON(json, context),
245
- term = new Term(context, string, node, type);
244
+ type = typeFromJSON(json, context);
245
+
246
+ context = null;
247
+
248
+ const term = new Term(context, string, node, type);
246
249
 
247
250
  return term;
248
251
  }, context);
@@ -5,6 +5,7 @@ import { arrayUtilities } from "necessary";
5
5
  import { asynchronousUtilities } from "occam-languages";
6
6
 
7
7
  import { asyncScope } from "../utilities/context";
8
+ import { topLevelAssertionStringFromLabelsSuppositionsAndDeduction } from "../utilities/string";
8
9
  import { labelsFromJSON,
9
10
  deductionFromJSON,
10
11
  signatureFromJSON,
@@ -122,30 +123,6 @@ export default class TopLevelAssertion extends Element {
122
123
  return correlatesToHypotheses;
123
124
  }
124
125
 
125
- verifyLabels() {
126
- let labelsVerify;
127
-
128
- const context = this.getContext(),
129
- topLevelAssertionString = this.getString();
130
-
131
- context.trace(`Verifying the '${topLevelAssertionString}' top level assertion's labels...`);
132
-
133
- labelsVerify = this.labels.every((label) => {
134
- const nameOnly = true,
135
- labelVerifies = label.verify(nameOnly);
136
-
137
- if (labelVerifies) {
138
- return true;
139
- }
140
- });
141
-
142
- if (labelsVerify) {
143
- context.debug(`...verified the '${topLevelAssertionString}' top level assertion's labels.`);
144
- }
145
-
146
- return labelsVerify;
147
- }
148
-
149
126
  unifyStatementWithDeduction(statement, context) {
150
127
  let statementUnifiesWithDeduction = false;
151
128
 
@@ -203,6 +180,47 @@ export default class TopLevelAssertion extends Element {
203
180
  return verifies;
204
181
  }
205
182
 
183
+ verifyLabels() {
184
+ let labelsVerify;
185
+
186
+ const context = this.getContext(),
187
+ topLevelAssertionString = this.getString(); ///
188
+
189
+ context.trace(`Verifying the '${topLevelAssertionString}' top level assertion's labels...`);
190
+
191
+ labelsVerify = this.labels.every((label) => {
192
+ const labelVerifies = this.verifyLabel(label);
193
+
194
+ if (labelVerifies) {
195
+ return true;
196
+ }
197
+ });
198
+
199
+ if (labelsVerify) {
200
+ context.debug(`...verified the '${topLevelAssertionString}' top level assertion's labels.`);
201
+ }
202
+
203
+ return labelsVerify;
204
+ }
205
+
206
+ verifyLabel(label) {
207
+ let labelVerifies;
208
+
209
+ const context = this.getContext(),
210
+ labelString = label.getString(),
211
+ topLevelAssertionString = this.getString(); ///
212
+
213
+ context.trace(`Verifying the '${topLevelAssertionString}' top level assertion's '${labelString}' label...`);
214
+
215
+ labelVerifies = label.verify();
216
+
217
+ if (labelVerifies) {
218
+ context.debug(`...verified the '${topLevelAssertionString}' top level assertion's '${labelString}' label.`);
219
+ }
220
+
221
+ return labelVerifies;
222
+ }
223
+
206
224
  async verifyProof(context) {
207
225
  let proofVerifies;
208
226
 
@@ -375,9 +393,10 @@ export default class TopLevelAssertion extends Element {
375
393
  suppositions = suppositionsFromJSON(json, context),
376
394
  signature = signatureFromJSON(json, context),
377
395
  hypotheses = hypothesesFromJSON(json, context),
396
+ topLevelAssertionString = topLevelAssertionStringFromLabelsSuppositionsAndDeduction(labels, suppositions, deduction),
378
397
  node = null,
379
398
  proof = null,
380
- string = stringFromLabelsSuppositionsAndDeduction(labels, suppositions, deduction),
399
+ string = topLevelAssertionString, ///
381
400
  topLevelAssertion = new Class(context, string, node, labels, suppositions, deduction, proof, signature, hypotheses);
382
401
 
383
402
  return topLevelAssertion;
@@ -92,16 +92,15 @@ export default class TopLevelMetaAssertion extends Element {
92
92
  let labelVerifies;
93
93
 
94
94
  const context = this.getContext(),
95
- topLevelMetaAssertionString = this.getString(); ///
96
-
97
- context.trace(`Verifiesing the '${topLevelMetaAssertionString}' top level meta assertion's label...`);
95
+ topLevelMetaAssertionString = this.getString(), ///
96
+ labelString = this.label.getString();
98
97
 
99
- const nameOnly = true;
98
+ context.trace(`Verifying the '${topLevelMetaAssertionString}' top level meta-assertion's '${labelString}' label...`);
100
99
 
101
- labelVerifies = this.label.verify(nameOnly);
100
+ labelVerifies = this.label.verify();
102
101
 
103
102
  if (labelVerifies) {
104
- context.debug(`...verified the '${topLevelMetaAssertionString}' top level meta assertion's label.`);
103
+ context.debug(`...verified the '${topLevelMetaAssertionString}' top level meta-assertion's '${labelString}' label.`);
105
104
  }
106
105
 
107
106
  return labelVerifies;
@@ -115,14 +114,14 @@ export default class TopLevelMetaAssertion extends Element {
115
114
  } else {
116
115
  const topLevelMetaAssertionString = this.getString(); ///
117
116
 
118
- context.trace(`Verifying the '${topLevelMetaAssertionString}' top meta level assertion's proof...`);
117
+ context.trace(`Verifying the '${topLevelMetaAssertionString}' top level meta-assertion's proof...`);
119
118
 
120
119
  const statement = this.deduction.getStatement();
121
120
 
122
121
  proofVerifies = this.proof.verify(statement, context);
123
122
 
124
123
  if (proofVerifies) {
125
- context.debug(`...verified the '${topLevelMetaAssertionString}' top meta level assertion's proof.`);
124
+ context.debug(`...verified the '${topLevelMetaAssertionString}' top level meta-assertion's proof.`);
126
125
  }
127
126
  }
128
127
 
@@ -4,8 +4,11 @@ import { Element } from "occam-languages";
4
4
  import { arrayUtilities } from "necessary";
5
5
 
6
6
  import { define } from "../elements";
7
+ import { literally } from "../utilities/context";
8
+ import { instantiateType } from "../process/instantiate";
7
9
  import { baseTypeFromNothing } from "../utilities/type";
8
- import { nameToNameJSON, superTypesToSuperTypesJSON, propertiesToPropertiesJSON, provisionalToProvisionalJSON } from "../utilities/json";
10
+ import { superTypesFromJSON, superTypesToSuperTypesJSON } from "../utilities/json";
11
+ import { nameFromTypeNode, prefixNameFromTypeNode, propertiesFromTypeNode, provisionalFromTypeNode } from "../utilities/element";
9
12
 
10
13
  const { push, first } = arrayUtilities;
11
14
 
@@ -292,24 +295,12 @@ export default define(class Type extends Element {
292
295
  }
293
296
 
294
297
  toJSON() {
295
- const nameJSON = nameToNameJSON(this.name),
296
- prefixNameJSON = nameToNameJSON(this.prefixName),
297
- propertiesJSON = propertiesToPropertiesJSON(this.properties),
298
- superTypesJSON = superTypesToSuperTypesJSON(this.superTypes),
299
- provisionalJSON = provisionalToProvisionalJSON(this.provisional),
300
- name = nameJSON, ///
301
- prefixName = prefixNameJSON, ///
302
- properties = propertiesJSON, ///
303
- superTypes = superTypesJSON, ///
304
- provisional = provisionalJSON, ///
298
+ const superTypesJSON = superTypesToSuperTypesJSON(this.superTypes),
299
+ superTypes = superTypesJSON,
305
300
  string = this.getString(),
306
301
  json = {
307
302
  string,
308
- name,
309
- prefixName,
310
- properties,
311
- superTypes,
312
- provisional
303
+ superTypes
313
304
  };
314
305
 
315
306
  return json;
@@ -318,7 +309,24 @@ export default define(class Type extends Element {
318
309
  static name = "Type";
319
310
 
320
311
  static fromJSON(json, context) {
321
- debugger
312
+ const type = literally((context) => {
313
+ const { string } = json,
314
+ typeNode = instantiateType(string, context),
315
+ node = typeNode, ///
316
+ name = nameFromTypeNode(typeNode, context),
317
+ prefixName = prefixNameFromTypeNode(typeNode, context),
318
+ superTypes = superTypesFromJSON(json, context),
319
+ properties = propertiesFromTypeNode(typeNode, context),
320
+ provisional = provisionalFromTypeNode(typeNode, context);
321
+
322
+ context = null; ///
323
+
324
+ const type = new Type(context, string, node, name, prefixName, superTypes, properties, provisional);
325
+
326
+ return type;
327
+ }, context);
328
+
329
+ return type;
322
330
  }
323
331
 
324
332
  static fromName(name, context) {
@@ -327,8 +335,11 @@ export default define(class Type extends Element {
327
335
  prefixName = null,
328
336
  superTypes = [],
329
337
  properties = [],
330
- provisional = false,
331
- type = new Type(context, string, node, name, prefixName, superTypes, properties, provisional);
338
+ provisional = false;
339
+
340
+ context = null;
341
+
342
+ const type = new Type(context, string, node, name, prefixName, superTypes, properties, provisional);
332
343
 
333
344
  return type;
334
345
  }
@@ -3,7 +3,9 @@
3
3
  import { Element } from "occam-languages";
4
4
 
5
5
  import { define } from "../elements";
6
- import {nameToNameJSON} from "../utilities/json";
6
+ import { literally } from "../utilities/context";
7
+ import { instantiateTypePrefix } from "../process/instantiate";
8
+ import { nameFromTypePrefixNode } from "../utilities/element";
7
9
 
8
10
  export default define(class TypePrefix extends Element {
9
11
  constructor(context, string, node, name) {
@@ -30,12 +32,9 @@ export default define(class TypePrefix extends Element {
30
32
  }
31
33
 
32
34
  toJSON() {
33
- const nameJSON = nameToNameJSON(this.name),
34
- name = nameJSON, ///
35
- string = this.getString(),
35
+ const string = this.getString(),
36
36
  json = {
37
- string,
38
- name
37
+ string
39
38
  };
40
39
 
41
40
  return json;
@@ -44,6 +43,19 @@ export default define(class TypePrefix extends Element {
44
43
  static name = "TypePrefix";
45
44
 
46
45
  static fromJSON(json, context) {
47
- debugger
46
+ const typePrefix = literally((context) => {
47
+ const { string } = json,
48
+ typePrefixNode = instantiateTypePrefix(string, context),
49
+ node = typePrefixNode, ///
50
+ name = nameFromTypePrefixNode(typePrefixNode, context);
51
+
52
+ context = null; ///
53
+
54
+ const typePrefix = new TypePrefix(context, string, node, name);
55
+
56
+ return typePrefix;
57
+ }, context);
58
+
59
+ return typePrefix;
48
60
  }
49
61
  });
@@ -7,20 +7,15 @@ import elements from "../elements";
7
7
  import { define } from "../elements";
8
8
  import { literally } from "../utilities/context";
9
9
  import { instantiateVariable } from "../process/instantiate";
10
- import { typeFromJSON,
11
- typeToTypeJSON,
12
- identifierFromJSON,
13
- propertyRelationsFromJSON,
14
- identifierToIdentifierJSON,
15
- propertyRelationsToPropertyRelationsJSON } from "../utilities/json";
10
+ import { identifierFromVarialbeNode } from "../utilities/element";
11
+ import { typeFromJSON, typeToTypeJSON } from "../utilities/json";
16
12
 
17
13
  export default define(class Variable extends Element {
18
- constructor(context, string, node, type, identifier, propertyRelations) {
14
+ constructor(context, string, node, type, identifier) {
19
15
  super(context, string, node);
20
16
 
21
17
  this.type = type;
22
18
  this.identifier = identifier;
23
- this.propertyRelations = propertyRelations;
24
19
  }
25
20
 
26
21
  getIdentifier() {
@@ -31,10 +26,6 @@ export default define(class Variable extends Element {
31
26
  return this.type;
32
27
  }
33
28
 
34
- getPropertyRelations() {
35
- return this.propertyRelations;
36
- }
37
-
38
29
  setType(type) {
39
30
  this.type = type;
40
31
  }
@@ -196,17 +187,11 @@ export default define(class Variable extends Element {
196
187
 
197
188
  toJSON() {
198
189
  const typeJSON = typeToTypeJSON(this.type),
199
- identifierJSON = identifierToIdentifierJSON(this.identifier),
200
- propertyRelationsJSON = propertyRelationsToPropertyRelationsJSON(this.propertyRelations),
201
190
  type = typeJSON, ///
202
- identifier = identifierJSON, ///
203
- propertyRelations = propertyRelationsJSON, ///
204
191
  string = this.getString(), ///
205
192
  json = {
206
193
  string,
207
- type,
208
- identifier,
209
- propertyRelations
194
+ type
210
195
  };
211
196
 
212
197
  return json;
@@ -220,9 +205,11 @@ export default define(class Variable extends Element {
220
205
  variableNode = instantiateVariable(string, context),
221
206
  node = variableNode, ///
222
207
  type = typeFromJSON(json, context),
223
- identifier = identifierFromJSON(json, context),
224
- propertyRelations = propertyRelationsFromJSON(json, context),
225
- variable = new Variable(context, string, node, type, identifier, propertyRelations);
208
+ identifier = identifierFromVarialbeNode(variableNode, context);
209
+
210
+ context = null;
211
+
212
+ const variable = new Variable(context, string, node, type, identifier);
226
213
 
227
214
  return variable;
228
215
  }, context);