@fraczak/k 6.10.6 → 7.0.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/CHANGELOG.md +55 -0
- package/CLAUDE.md +1 -1
- package/DOCS/BIG_PICTURE.md +156 -172
- package/DOCS/BINARY_CODEC_STATUS_AND_TODO.md +3 -3
- package/DOCS/CODEC_ARCHITECTURE.md +2 -2
- package/DOCS/DICTIONARY.md +243 -250
- package/DOCS/DIVERGENCE_DETECTION.md +0 -1
- package/DOCS/FILE_FORMATS.md +5 -5
- package/DOCS/KIR_SPECIALIZATION_DESIGN.md +1 -1
- package/DOCS/OBJECT_FILE_AND_PATTERN.md +12 -12
- package/DOCS/PATTERNS.md +17 -17
- package/DOCS/PATTERNS_AND_TYPED_VALUES.md +1 -1
- package/DOCS/REPL.md +9 -19
- package/DOCS/TYPE_DERIVATION.md +2 -8
- package/DOCS/WEB_REPL_REQUIREMENTS.md +8 -8
- package/DOCS/book/01-introduction.md +8 -11
- package/DOCS/book/02-syntax-and-values.md +19 -20
- package/DOCS/book/03-types-as-finite-automata.md +42 -43
- package/DOCS/book/04-partial-functions-and-composition.md +2 -3
- package/DOCS/book/05-typing-filters-and-normalization.md +44 -46
- package/DOCS/book/06-values-in-memory.md +10 -10
- package/DOCS/book/08-operational-semantics-and-execution.md +21 -26
- package/DOCS/book/09-compiler-architecture.md +11 -11
- package/DOCS/book/10-from-ast-to-intermediate-representation.md +6 -7
- package/DOCS/book/14-canonical-serialization.md +2 -2
- package/DOCS/book/appendix-b-incorporating-external-predefined-types-and-functions.md +17 -17
- package/DOCS/book.md +5 -5
- package/Examples/arithmetics.k +49 -153
- package/Examples/bnat.k +13 -13
- package/Examples/byte.k +2 -50
- package/Examples/ieee.k +408 -423
- package/Examples/karatsuba-mult.k +30 -34
- package/Examples/nat.k +5 -6
- package/README.md +54 -49
- package/TODO.md +13 -18
- package/backend-api.mjs +9 -1
- package/backends/llvm/scripts/run-tests.mjs +5 -0
- package/backends/llvm/src/kvm2llvm.mjs +2 -1
- package/backends/llvm/src/llvm.mjs +18 -25
- package/backends/llvm/tests/integration.sh +2 -2
- package/backends/llvm/tests/test-llvm.mjs +3 -3
- package/backends/llvm/tests/test-open-product-misalignment.mjs +140 -0
- package/backends/wasm/demo_ieee.mjs +2 -3
- package/backends/wasm/runtime.wat +157 -5
- package/backends/wasm/src/kvm2wasm.mjs +57 -34
- package/backends/wasm/src/wasm.mjs +38 -17
- package/backends/wasm/tests/perf-support.mjs +4 -4
- package/backends/wasm/tests/test-wasm.mjs +13 -14
- package/browser/vfs-data.mjs +12 -12
- package/codecs/BINARY_FORMAT.md +4 -4
- package/codecs/POLYMORPHIC_BINARY_FORMAT.md +4 -4
- package/codecs/README.md +6 -6
- package/codecs/ieee.mjs +15 -11
- package/codecs/int.mjs +9 -5
- package/codecs/string-codec.mjs +46 -47
- package/core.k +123 -95
- package/kir.mjs +213 -17
- package/object.mjs +0 -7
- package/package.json +5 -2
- package/parser.jison +2 -41
- package/parser.mjs +55 -95
- package/pretty.mjs +11 -4
- package/repl.mjs +8 -63
- package/scripts/build-repl-html.mjs +8 -38
- package/tests/code-derivation/blowup.mjs +2 -4
- package/tests/code-derivation/bnat.mjs +2 -3
- package/tests/code-derivation/dot.mjs +5 -11
- package/tests/code-derivation/nat.mjs +2 -2
- package/tests/code-derivation/not-not.mjs +6 -6
- package/tests/code-derivation/pattern-envelope.mjs +4 -6
- package/tests/code-derivation/product.mjs +3 -6
- package/tests/code-derivation/rlz.mjs +4 -5
- package/tests/test-codecs.mjs +1 -1
- package/tests/test-fingerprint.mjs +36 -41
- package/tests/test-hash-normalization.mjs +4 -6
- package/tests/test-ieee-arithmetic.mjs +6 -7
- package/tests/test-k-object.mjs +11 -15
- package/tests/test-kir.mjs +0 -1
- package/tests/test-kvm-polymorphic.mjs +1 -2
- package/tests/test-kvm.mjs +8 -11
- package/tests/test-repl-html.mjs +20 -2
- package/tests/test-repl.mjs +48 -53
- package/tests/test.mjs +2 -3
|
@@ -194,7 +194,7 @@ console.log("==> Running Product Operations Integration Tests");
|
|
|
194
194
|
for (let i = 0; i < N; i++) {
|
|
195
195
|
const offsetVal = 8 + 4 * N + 4 * i;
|
|
196
196
|
const val = fieldsMap[keys[i]];
|
|
197
|
-
view.setUint32(ptr + 8 + 4 * i,
|
|
197
|
+
view.setUint32(ptr + 8 + 4 * i, getTagId(keys[i]), true);
|
|
198
198
|
view.setUint32(ptr + offsetVal, val, true);
|
|
199
199
|
}
|
|
200
200
|
return ptr;
|
|
@@ -215,8 +215,8 @@ console.log("==> Running Product Operations Integration Tests");
|
|
|
215
215
|
const view = new DataView(exports.memory.buffer);
|
|
216
216
|
assert.equal(view.getUint32(ptrOut, true), 24, "Product total size should be 24");
|
|
217
217
|
assert.equal(view.getUint32(ptrOut + 4, true), 2, "Product field count should be 2");
|
|
218
|
-
assert.equal(view.getUint32(ptrOut + 8, true),
|
|
219
|
-
assert.equal(view.getUint32(ptrOut + 12, true),
|
|
218
|
+
assert.equal(view.getUint32(ptrOut + 8, true), getTagId("x"), "TagId of first field (x)");
|
|
219
|
+
assert.equal(view.getUint32(ptrOut + 12, true), getTagId("y"), "TagId of second field (y)");
|
|
220
220
|
|
|
221
221
|
// The first field value should be the projection of x from ptrIn (101)
|
|
222
222
|
const valXPtr = view.getUint32(ptrOut + 16, true);
|
|
@@ -443,12 +443,12 @@ console.log("==> Running End-to-End Peano Addition & Serialization Tests");
|
|
|
443
443
|
const runtimeWat = fs.readFileSync("runtime.wat", "utf8");
|
|
444
444
|
|
|
445
445
|
const script = `
|
|
446
|
-
|
|
447
|
-
0 = {} | 0
|
|
448
|
-
inc = | +1
|
|
449
|
-
dec =
|
|
450
|
-
add =
|
|
451
|
-
{ . x dec x, . y inc y } add,
|
|
446
|
+
nat = ?< {} 0, nat +1 >;
|
|
447
|
+
0 = {} | 0 nat;
|
|
448
|
+
inc = | +1 nat;
|
|
449
|
+
dec = nat / +1;
|
|
450
|
+
add = ?{ nat x, nat y } = X <
|
|
451
|
+
{ . x dec x, . y inc y } ?X add,
|
|
452
452
|
. y
|
|
453
453
|
>;
|
|
454
454
|
()
|
|
@@ -483,8 +483,7 @@ console.log("==> Running End-to-End Peano Addition & Serialization Tests");
|
|
|
483
483
|
|
|
484
484
|
for (let i = 0; i < N; i++) {
|
|
485
485
|
const edge = patternNode.edges[i];
|
|
486
|
-
const
|
|
487
|
-
const childPtr = view.getUint32(ptr + offsetVal, true);
|
|
486
|
+
const childPtr = view.getUint32(ptr + 8 + 4 * N + 4 * i, true);
|
|
488
487
|
productObj[edge.label] = readArenaValue(childPtr, pattern, edge.target);
|
|
489
488
|
}
|
|
490
489
|
return Value.product(productObj, pattern);
|
|
@@ -530,7 +529,7 @@ console.log("==> Running End-to-End Peano Addition & Serialization Tests");
|
|
|
530
529
|
|
|
531
530
|
for (let i = 0; i < N; i++) {
|
|
532
531
|
const offsetVal = 8 + 4 * N + 4 * i;
|
|
533
|
-
view.setUint32(ptr + 8 + 4 * i,
|
|
532
|
+
view.setUint32(ptr + 8 + 4 * i, getTagId(keys[i]), true);
|
|
534
533
|
view.setUint32(ptr + offsetVal, childPtrs[i], true);
|
|
535
534
|
}
|
|
536
535
|
return ptr;
|
|
@@ -580,8 +579,8 @@ console.log("==> Running End-to-End Peano Addition & Serialization Tests");
|
|
|
580
579
|
const view = new DataView(exports.memory.buffer);
|
|
581
580
|
view.setUint32(ptr, 24, true);
|
|
582
581
|
view.setUint32(ptr + 4, 2, true);
|
|
583
|
-
view.setUint32(ptr + 8,
|
|
584
|
-
view.setUint32(ptr + 12,
|
|
582
|
+
view.setUint32(ptr + 8, getTagId("x"), true);
|
|
583
|
+
view.setUint32(ptr + 12, getTagId("y"), true);
|
|
585
584
|
view.setUint32(ptr + 16, xPtr, true);
|
|
586
585
|
view.setUint32(ptr + 20, yPtr, true);
|
|
587
586
|
return ptr;
|