@bablr/bablr-vm 0.22.1 → 0.23.1

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/facades.js CHANGED
@@ -1,3 +1,37 @@
1
+ import * as Tags from '@bablr/agast-helpers/tags';
2
+ import { buildGapTag, buildProperty } from '@bablr/agast-helpers/builders';
1
3
  import { buildFacadeLayer } from '@bablr/agast-vm-helpers/facades';
4
+ import { buildNode, getTags } from '@bablr/agast-helpers/path';
5
+ import { Property } from '@bablr/agast-helpers/symbols';
2
6
 
3
7
  export const { facades, actuals } = buildFacadeLayer();
8
+
9
+ export const buildFacadeNode = (node) => {
10
+ let facadeTags = Tags.fromValues([]);
11
+
12
+ for (let tag of Tags.traverse(getTags(node))) {
13
+ if (tag.type === Property) {
14
+ let property = tag;
15
+ let { reference, bindings, node, tags } = property;
16
+
17
+ let property_ = property;
18
+
19
+ if (!reference.flags.intrinsic) {
20
+ let gapNode = buildNode(buildGapTag());
21
+ if (!reference.flags.hasGap) {
22
+ actuals.set(gapNode, node);
23
+ }
24
+
25
+ let tags_ = Tags.fromValues([tags[0], tags[1], gapNode]);
26
+
27
+ property_ = buildProperty(tags_);
28
+ }
29
+
30
+ facadeTags = Tags.push(facadeTags, property_);
31
+ } else {
32
+ facadeTags = Tags.push(facadeTags, tag);
33
+ }
34
+ }
35
+
36
+ return buildNode(facadeTags);
37
+ };