@fraczak/k 6.1.2 → 6.1.3
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/DOCS/BIG_PICTURE.md +10 -10
- package/DOCS/DIVERGENCE_DETECTION.md +1 -1
- package/DOCS/TYPE_DERIVATION.md +12 -12
- package/DOCS/book/01-introduction.md +2 -2
- package/DOCS/book/02-syntax-and-values.md +8 -8
- package/DOCS/book/03-types-as-finite-automata.md +2 -2
- package/DOCS/book/04-partial-functions-and-composition.md +2 -2
- package/DOCS/book/05-typing-filters-and-normalization.md +3 -3
- package/DOCS/book/06-values-in-memory.md +3 -3
- package/DOCS/book/07-the-partial-function-abi.md +1 -1
- package/DOCS/book/08-operational-semantics-and-execution.md +1 -1
- package/DOCS/book/09-compiler-architecture.md +2 -2
- package/DOCS/book/appendix-b-incorporating-external-predefined-types-and-functions.md +1 -0
- package/README.md +7 -8
- package/a.k +138 -0
- package/a.klib +1 -0
- package/codecs/BINARY_FORMAT.md +1 -1
- package/codecs/POLYMORPHIC_BINARY_FORMAT.md +1 -1
- package/codes.mjs +14 -33
- package/export.mjs +3 -3
- package/ieee.klib +1 -1
- package/nak.klib +1 -0
- package/nak2.klib +1 -0
- package/nat.k +10 -0
- package/nat2.k +9 -0
- package/object.mjs +20 -7
- package/package.json +2 -1
- package/scripts/benchmark-idempotency.mjs +72 -0
- package/test-k-object.mjs +19 -0
package/codecs/BINARY_FORMAT.md
CHANGED
|
@@ -9,7 +9,7 @@ in [`POLYMORPHIC_BINARY_FORMAT.md`](./POLYMORPHIC_BINARY_FORMAT.md):
|
|
|
9
9
|
encode($pattern_value : $pattern) encode(value : decoded_pattern)
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
## Purpose
|
|
12
|
+
## Purpose of This File
|
|
13
13
|
|
|
14
14
|
This file records constraints for any future optimized container layered above
|
|
15
15
|
the canonical stream.
|
|
@@ -288,7 +288,7 @@ Decoding the stream yields `Value(pattern, tree)`. Encoding a runtime `Value`
|
|
|
288
288
|
uses its carried pattern by default, or an explicit caller-supplied pattern when
|
|
289
289
|
one is provided.
|
|
290
290
|
|
|
291
|
-
## Out
|
|
291
|
+
## Out of Scope for the Base Codec
|
|
292
292
|
|
|
293
293
|
The following are intentionally outside the primitive codec:
|
|
294
294
|
|
package/codes.mjs
CHANGED
|
@@ -248,43 +248,24 @@ function finalizeIncremental(newCodes) {
|
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
-
const
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
}
|
|
257
|
-
}
|
|
251
|
+
const reachableCodes = {};
|
|
252
|
+
const queue = Object.keys(resolvedCodes);
|
|
253
|
+
while (queue.length > 0) {
|
|
254
|
+
const name = queue.shift();
|
|
255
|
+
if (reachableCodes[name]) continue;
|
|
258
256
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
257
|
+
const code = resolvedCodes[name] || theRepository.codes[name];
|
|
258
|
+
if (code == null) {
|
|
259
|
+
throw new Error(`Type references undefined type: ${name}`);
|
|
260
|
+
}
|
|
261
|
+
reachableCodes[name] = code;
|
|
262
262
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
globalNames[name] = hash(globalDef);
|
|
263
|
+
for (const dest of Object.values(code[code.code] || {})) {
|
|
264
|
+
if (!reachableCodes[dest]) queue.push(dest);
|
|
265
|
+
}
|
|
267
266
|
}
|
|
268
267
|
|
|
269
|
-
|
|
270
|
-
result[globalNames[name]] = normalizedCodes[name];
|
|
271
|
-
return result;
|
|
272
|
-
}, {});
|
|
273
|
-
|
|
274
|
-
const extendedRepresentatives = Object.keys(representatives).reduce((result, name) => {
|
|
275
|
-
result[name] = globalNames[representatives[name]] || representatives[name] || name;
|
|
276
|
-
return result;
|
|
277
|
-
}, {});
|
|
278
|
-
|
|
279
|
-
Object.values(globalNames).forEach((name) => {
|
|
280
|
-
extendedRepresentatives[name] = name;
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
const normalizedGlobalCodes = normalizeAll(globalCodes, extendedRepresentatives);
|
|
284
|
-
return {
|
|
285
|
-
codes: normalizedGlobalCodes,
|
|
286
|
-
representatives: extendedRepresentatives
|
|
287
|
-
};
|
|
268
|
+
return finalize(reachableCodes);
|
|
288
269
|
}
|
|
289
270
|
|
|
290
271
|
function register(newCodes) {
|
package/export.mjs
CHANGED
|
@@ -87,13 +87,13 @@ function theID(alias, rel, scc, name) {
|
|
|
87
87
|
break;
|
|
88
88
|
case "ref": {
|
|
89
89
|
const n = rel.ref;
|
|
90
|
-
if (
|
|
91
|
-
newRel.ref = alias[n];
|
|
92
|
-
} else if (auxNames[n] != undefined) {
|
|
90
|
+
if (auxNames[n] != undefined) {
|
|
93
91
|
newRel.ref = auxNames[n];
|
|
94
92
|
} else if (sccNames.has(n)) {
|
|
95
93
|
auxNames[n] = `X${Object.keys(auxNames).length}`;
|
|
96
94
|
newRel.ref = auxNames[n];
|
|
95
|
+
} else if (alias[n] != undefined) {
|
|
96
|
+
newRel.ref = alias[n];
|
|
97
97
|
};
|
|
98
98
|
}; break;
|
|
99
99
|
default:
|