json-as 1.2.3 → 1.2.5
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/.claude/settings.local.json +9 -0
- package/ARCHITECTURE.md +320 -0
- package/CONTRIBUTING.md +238 -0
- package/LICENSE +2 -2
- package/README.md +34 -2
- package/TODO +1 -0
- package/assembly/custom/chars.ts +9 -0
- package/assembly/deserialize/simd/string.ts +6 -41
- package/assembly/deserialize/simple/set.ts +169 -0
- package/assembly/deserialize/simple/staticarray/array.ts +37 -0
- package/assembly/deserialize/simple/staticarray/bool.ts +39 -0
- package/assembly/deserialize/simple/staticarray/float.ts +44 -0
- package/assembly/deserialize/simple/staticarray/integer.ts +44 -0
- package/assembly/deserialize/simple/staticarray/string.ts +45 -0
- package/assembly/deserialize/simple/staticarray/struct.ts +47 -0
- package/assembly/deserialize/simple/staticarray.ts +28 -0
- package/assembly/deserialize/swar/string.ts +6 -5
- package/assembly/index.ts +337 -143
- package/assembly/serialize/simd/string.ts +14 -17
- package/assembly/serialize/simple/set.ts +34 -0
- package/assembly/serialize/simple/staticarray.ts +30 -0
- package/assembly/serialize/swar/string.ts +50 -36
- package/assembly/test.ts +20 -38
- package/assembly/util/swar.ts +2 -2
- package/eslint.config.js +77 -0
- package/lib/as-bs.ts +143 -50
- package/package.json +18 -5
- package/transform/lib/builder.d.ts +87 -0
- package/transform/lib/builder.d.ts.map +1 -0
- package/transform/lib/builder.js +169 -169
- package/transform/lib/builder.js.map +1 -1
- package/transform/lib/index.d.ts +32 -0
- package/transform/lib/index.d.ts.map +1 -0
- package/transform/lib/index.js +40 -18
- package/transform/lib/index.js.map +1 -1
- package/transform/lib/linkers/alias.d.ts +12 -0
- package/transform/lib/linkers/alias.d.ts.map +1 -0
- package/transform/lib/linkers/alias.js +1 -1
- package/transform/lib/linkers/alias.js.map +1 -1
- package/transform/lib/linkers/custom.d.ts +10 -0
- package/transform/lib/linkers/custom.d.ts.map +1 -0
- package/transform/lib/linkers/imports.d.ts +3 -0
- package/transform/lib/linkers/imports.d.ts.map +1 -0
- package/transform/lib/linkers/imports.js +1 -1
- package/transform/lib/linkers/imports.js.map +1 -1
- package/transform/lib/types.d.ts +66 -0
- package/transform/lib/types.d.ts.map +1 -0
- package/transform/lib/types.js +6 -5
- package/transform/lib/types.js.map +1 -1
- package/transform/lib/util.d.ts +18 -0
- package/transform/lib/util.d.ts.map +1 -0
- package/transform/lib/util.js +4 -4
- package/transform/lib/util.js.map +1 -1
- package/transform/lib/visitor.d.ts +84 -0
- package/transform/lib/visitor.d.ts.map +1 -0
- package/transform/lib/visitor.js +76 -76
- package/transform/lib/visitor.js.map +1 -1
- package/transform/tsconfig.json +29 -2
- package/assembly/serialize/swar/number.ts +0 -0
- package/assembly/test.mask.ts +0 -87
- package/transform/lib/linkers/classes.js +0 -36
- package/transform/lib/linkers/classes.js.map +0 -1
package/assembly/test.mask.ts
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
function v64x4_should_escape(x: u64): u64 {
|
|
2
|
-
console.log("input: " + mask_to_string(x));
|
|
3
|
-
const non_ascii_lanes = (x & 0x8000_8000_8000_8000) >> 8;
|
|
4
|
-
const hi = x & 0xff00_ff00_ff00_ff00;
|
|
5
|
-
const lo = x & 0x00ff_00ff_00ff_00ff;
|
|
6
|
-
const is_cp_or_surrogate = (x & 0x8080_8080_8080_8080)
|
|
7
|
-
x &= 0x00ff_00ff_00ff_00ff;
|
|
8
|
-
const is_ascii = 0x0080_0080_0080_0080 & ~x; // lane remains 0x80 if ascii
|
|
9
|
-
const lt32 = (x - 0x0020_0020_0020_0020);
|
|
10
|
-
const sub34 = x ^ 0x0022_0022_0022_0022;
|
|
11
|
-
const eq34 = (sub34 - 0x0001_0001_0001_0001);
|
|
12
|
-
const sub92 = x ^ 0x005C_005C_005C_005C;
|
|
13
|
-
const eq92 = (sub92 - 0x0001_0001_0001_0001);
|
|
14
|
-
console.log("low: " + mask_to_string(lo));
|
|
15
|
-
console.log("high: " + mask_to_string(hi));
|
|
16
|
-
console.log("is_cp_or_sur: " + mask_to_string(is_cp_or_surrogate));
|
|
17
|
-
console.log("is_non_ascii: " + mask_to_string(non_ascii_lanes));
|
|
18
|
-
console.log("is_ascii: " + mask_to_string(is_ascii));
|
|
19
|
-
console.log("lt32: " + mask_to_string(lt32));
|
|
20
|
-
console.log("sub34: " + mask_to_string(sub34));
|
|
21
|
-
console.log("eq34: " + mask_to_string(eq34));
|
|
22
|
-
console.log("eq92: " + mask_to_string(eq92));
|
|
23
|
-
console.log("pre: " + mask_to_string((lt32 | eq34 | eq92) & is_ascii));
|
|
24
|
-
console.log("out: " + mask_to_string(((lt32 | eq34 | eq92) & is_ascii) & ~is_cp_or_surrogate));
|
|
25
|
-
console.log("out: " + mask_to_string((lt32 | eq34 | eq92) & is_ascii));
|
|
26
|
-
return ((lt32 | eq34 | eq92) & is_ascii) & ~non_ascii_lanes
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function mask_to_string(mask: u64): string {
|
|
30
|
-
let result = "0x";
|
|
31
|
-
for (let i = 7; i >= 0; i--) {
|
|
32
|
-
const byte = u8((mask >> (i * 8)) & 0xFF);
|
|
33
|
-
const hi = (byte >> 4) & 0xF;
|
|
34
|
-
const lo = byte & 0xF;
|
|
35
|
-
result += String.fromCharCode(hi < 10 ? 48 + hi : 55 + hi);
|
|
36
|
-
result += String.fromCharCode(lo < 10 ? 48 + lo : 55 + lo);
|
|
37
|
-
result += " ";
|
|
38
|
-
}
|
|
39
|
-
return result;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function test_mask(input: string, expected_mask: u64, description: string): void {
|
|
43
|
-
const i = load<u64>(changetype<usize>(input));
|
|
44
|
-
const mask = v64x4_should_escape(i);
|
|
45
|
-
const pass = mask == expected_mask;
|
|
46
|
-
console.log((pass ? "✓ " : "✗ ") + description);
|
|
47
|
-
console.log(" Input: " + mask_to_string(i));
|
|
48
|
-
console.log(" Expected: " + mask_to_string(expected_mask));
|
|
49
|
-
console.log(" Got: " + mask_to_string(mask));
|
|
50
|
-
if (!pass) process.exit(1);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// ------------------------
|
|
54
|
-
// 1. Plain ASCII text
|
|
55
|
-
// ------------------------
|
|
56
|
-
console.log("=== Plain ASCII text ===");
|
|
57
|
-
test_mask("Abcz", 0x0, "Letters 'A','b','c','z'");
|
|
58
|
-
test_mask("0129", 0x0, "Numbers '0'-'9'");
|
|
59
|
-
test_mask(" !#~", 0x0, "Safe symbols");
|
|
60
|
-
|
|
61
|
-
// ------------------------
|
|
62
|
-
// 2. Quote and Backslash
|
|
63
|
-
// ------------------------
|
|
64
|
-
console.log("=== Quote and Backslash ===");
|
|
65
|
-
test_mask("\"\\" + "AA", 0x0000000000800080, "Quote + backslash lanes 0 and 1");
|
|
66
|
-
test_mask("A\"\\" + "A", 0x0000008000800000, "Quote lane1, backslash lane2");
|
|
67
|
-
|
|
68
|
-
// ------------------------
|
|
69
|
-
// 3. Control Codes
|
|
70
|
-
// ------------------------
|
|
71
|
-
console.log("=== Control Codes ===");
|
|
72
|
-
test_mask("\0\n\u001F\u001B", 0x0080008000800080, "Control codes 0,10,31,27");
|
|
73
|
-
test_mask("\t\n\r\u0010", 0x0080008000800080, "Control codes 9,10,13,16");
|
|
74
|
-
|
|
75
|
-
// ------------------------
|
|
76
|
-
// 4. Surrogate / Codepoint
|
|
77
|
-
// ------------------------
|
|
78
|
-
console.log("=== Surrogate / Codepoint ===");
|
|
79
|
-
test_mask("\uD83D\uDE00\uD83D\uDE00", 0x0000000000000000, "Surrogates lane0/1 and 2/3");
|
|
80
|
-
test_mask("A\uD83D\uDE00B", 0x0000000000000000, "ASCII lane0/3, surrogate lane1/2");
|
|
81
|
-
|
|
82
|
-
// ------------------------
|
|
83
|
-
// 5. Mixed ASCII + Unicode
|
|
84
|
-
// ------------------------
|
|
85
|
-
console.log("=== Mixed ASCII + Unicode ===");
|
|
86
|
-
test_mask("A©漢🚀", 0x0000000000000000, "Mixed ASCII + codepoints");
|
|
87
|
-
test_mask("\"\uD83D\\B", 0x0000008000000080, "Quote lane0, surrogate lane1, backslash lane2, ASCII lane3");
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Visitor } from "../visitor.js";
|
|
2
|
-
import { getImports } from "./imports.js";
|
|
3
|
-
export function getImportedClass(name, source, parser) {
|
|
4
|
-
for (const stmt of getImports(source)) {
|
|
5
|
-
const externalSource = parser.sources.filter((src) => src.internalPath != source.internalPath).find((src) => src.internalPath == stmt.internalPath);
|
|
6
|
-
if (!externalSource)
|
|
7
|
-
continue;
|
|
8
|
-
const classDeclaration = ClassGetter.getClass(name, externalSource);
|
|
9
|
-
if (!classDeclaration)
|
|
10
|
-
continue;
|
|
11
|
-
if (!(classDeclaration.flags & 2))
|
|
12
|
-
continue;
|
|
13
|
-
return classDeclaration;
|
|
14
|
-
}
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
class ClassGetter extends Visitor {
|
|
18
|
-
static SN = new ClassGetter();
|
|
19
|
-
classes = [];
|
|
20
|
-
visitClassDeclaration(node) {
|
|
21
|
-
this.classes.push(node);
|
|
22
|
-
}
|
|
23
|
-
static getClass(name, source) {
|
|
24
|
-
return ClassGetter.getClasses(source).find((c) => c.name.text == name) || null;
|
|
25
|
-
}
|
|
26
|
-
static getClasses(source) {
|
|
27
|
-
return source.statements.filter((stmt) => stmt.kind == 51);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
export function getClasses(source) {
|
|
31
|
-
return ClassGetter.getClasses(source);
|
|
32
|
-
}
|
|
33
|
-
export function getClass(name, source) {
|
|
34
|
-
return ClassGetter.getClass(name, source);
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=classes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"classes.js","sourceRoot":"","sources":["../../src/linkers/classes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,e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