json-as 1.3.0 → 1.3.2
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 +400 -0
- package/README.md +137 -32
- package/assembly/deserialize/index/arbitrary.ts +1 -1
- package/assembly/deserialize/index/array.ts +6 -1
- package/assembly/deserialize/index/float.ts +1 -1
- package/assembly/deserialize/index/integer.ts +1 -1
- package/assembly/deserialize/index/typedarray.ts +14 -0
- package/assembly/deserialize/index/unsigned.ts +1 -1
- package/assembly/deserialize/simd/string.ts +20 -16
- package/assembly/deserialize/simple/arbitrary.ts +1 -1
- package/assembly/deserialize/simple/array/generic.ts +42 -0
- package/assembly/deserialize/simple/array.ts +8 -1
- package/assembly/deserialize/{float.ts → simple/float.ts} +22 -2
- package/assembly/deserialize/{integer.ts → simple/integer.ts} +3 -2
- package/assembly/deserialize/simple/map.ts +60 -12
- package/assembly/deserialize/simple/object.ts +1 -1
- package/assembly/deserialize/simple/set.ts +119 -134
- package/assembly/deserialize/simple/staticarray.ts +12 -1
- package/assembly/deserialize/simple/string.ts +93 -2
- package/assembly/deserialize/simple/struct.ts +7 -157
- package/assembly/deserialize/simple/typedarray.ts +1 -1
- package/assembly/deserialize/{unsigned.ts → simple/unsigned.ts} +3 -2
- package/assembly/deserialize/swar/array/array.ts +42 -7
- package/assembly/deserialize/swar/array/bool.ts +5 -2
- package/assembly/deserialize/swar/array/float.ts +7 -3
- package/assembly/deserialize/swar/array/generic.ts +40 -0
- package/assembly/deserialize/swar/array/integer.ts +7 -4
- package/assembly/deserialize/swar/array/object.ts +20 -4
- package/assembly/deserialize/swar/array/shared.ts +18 -4
- package/assembly/deserialize/swar/array/string.ts +5 -2
- package/assembly/deserialize/swar/array/struct.ts +20 -4
- package/assembly/deserialize/swar/array.ts +56 -2
- package/assembly/deserialize/swar/string.ts +245 -370
- package/assembly/index.ts +207 -194
- package/assembly/serialize/index/arbitrary.ts +8 -3
- package/assembly/serialize/index/float.ts +1 -1
- package/assembly/serialize/index/object.ts +1 -5
- package/assembly/serialize/index/typedarray.ts +65 -0
- package/assembly/serialize/simd/string.ts +7 -16
- package/assembly/serialize/simple/arbitrary.ts +9 -3
- package/assembly/serialize/simple/array.ts +17 -6
- package/assembly/serialize/simple/float.ts +18 -4
- package/assembly/serialize/simple/map.ts +10 -27
- package/assembly/serialize/simple/object.ts +1 -5
- package/assembly/serialize/simple/set.ts +3 -4
- package/assembly/serialize/simple/staticarray.ts +4 -3
- package/assembly/serialize/simple/string.ts +3 -11
- package/assembly/serialize/simple/typedarray.ts +9 -7
- package/assembly/serialize/swar/string.ts +3 -12
- package/assembly/tsconfig.json +3 -2
- package/assembly/util/dragonbox-cache.ts +1322 -0
- package/assembly/util/dragonbox.ts +596 -0
- package/assembly/util/swar.ts +49 -0
- package/lib/as-bs.ts +92 -70
- package/package.json +35 -10
- package/transform/lib/index.d.ts +1 -0
- package/transform/lib/index.d.ts.map +1 -1
- package/transform/lib/index.js +559 -221
- package/transform/lib/index.js.map +1 -1
- package/transform/lib/linkers/custom.d.ts.map +1 -1
- package/transform/lib/linkers/custom.js +7 -3
- package/transform/lib/linkers/custom.js.map +1 -1
- package/transform/lib/types.d.ts +2 -0
- package/transform/lib/types.d.ts.map +1 -1
- package/transform/lib/types.js +13 -0
- package/transform/lib/types.js.map +1 -1
- package/.as-test/coverage/naive/coverage.arbitrary.spec.ts.log.json +0 -5628
- package/.as-test/coverage/naive/coverage.array.spec.ts.log.json +0 -5187
- package/.as-test/coverage/naive/coverage.bool.spec.ts.log.json +0 -5187
- package/.as-test/coverage/naive/coverage.box.spec.ts.log.json +0 -5187
- package/.as-test/coverage/naive/coverage.custom.spec.ts.log.json +0 -5187
- package/.as-test/coverage/naive/coverage.date.spec.ts.log.json +0 -5187
- package/.as-test/coverage/naive/coverage.enum.spec.ts.log.json +0 -5187
- package/.as-test/coverage/naive/coverage.float.spec.ts.log.json +0 -5187
- package/.as-test/coverage/naive/coverage.generics.spec.ts.log.json +0 -5187
- package/.as-test/coverage/naive/coverage.hierarchy.spec.ts.log.json +0 -5187
- package/.as-test/coverage/naive/coverage.integer.spec.ts.log.json +0 -5187
- package/.as-test/coverage/naive/coverage.map.spec.ts.log.json +0 -5187
- package/.as-test/coverage/naive/coverage.namespace.spec.ts.log.json +0 -5187
- package/.as-test/coverage/naive/coverage.null.spec.ts.log.json +0 -5187
- package/.as-test/coverage/naive/coverage.raw.spec.ts.log.json +0 -5187
- package/.as-test/coverage/naive/coverage.resolving.spec.ts.log.json +0 -5628
- package/.as-test/coverage/naive/coverage.set.spec.ts.log.json +0 -5187
- package/.as-test/coverage/naive/coverage.staticarray.spec.ts.log.json +0 -5187
- package/.as-test/coverage/naive/coverage.string.spec.ts.log.json +0 -5187
- package/.as-test/coverage/naive/coverage.struct.spec.ts.log.json +0 -5187
- package/.as-test/coverage/naive/coverage.types.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.arbitrary.spec.ts.log.json +0 -5628
- package/.as-test/coverage/simd/coverage.array.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.bool.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.box.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.custom.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.date.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.enum.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.float.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.generics.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.hierarchy.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.integer.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.map.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.namespace.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.null.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.raw.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.resolving.spec.ts.log.json +0 -5628
- package/.as-test/coverage/simd/coverage.set.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.staticarray.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.string.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.struct.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.types.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.arbitrary.spec.ts.log.json +0 -5628
- package/.as-test/coverage/swar/coverage.array.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.bool.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.box.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.custom.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.date.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.enum.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.float.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.generics.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.hierarchy.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.integer.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.map.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.namespace.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.null.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.raw.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.resolving.spec.ts.log.json +0 -5628
- package/.as-test/coverage/swar/coverage.set.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.staticarray.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.string.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.struct.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.types.spec.ts.log.json +0 -5187
- package/.as-test/logs/naive/run.arbitrary.spec.ts.log.json +0 -943
- package/.as-test/logs/naive/run.array.spec.ts.log.json +0 -1053
- package/.as-test/logs/naive/run.bool.spec.ts.log.json +0 -257
- package/.as-test/logs/naive/run.box.spec.ts.log.json +0 -353
- package/.as-test/logs/naive/run.custom.spec.ts.log.json +0 -309
- package/.as-test/logs/naive/run.date.spec.ts.log.json +0 -397
- package/.as-test/logs/naive/run.enum.spec.ts.log.json +0 -343
- package/.as-test/logs/naive/run.float.spec.ts.log.json +0 -453
- package/.as-test/logs/naive/run.generics.spec.ts.log.json +0 -393
- package/.as-test/logs/naive/run.hierarchy.spec.ts.log.json +0 -325
- package/.as-test/logs/naive/run.integer.spec.ts.log.json +0 -373
- package/.as-test/logs/naive/run.map.spec.ts.log.json +0 -247
- package/.as-test/logs/naive/run.namespace.spec.ts.log.json +0 -361
- package/.as-test/logs/naive/run.null.spec.ts.log.json +0 -273
- package/.as-test/logs/naive/run.raw.spec.ts.log.json +0 -309
- package/.as-test/logs/naive/run.resolving.spec.ts.log.json +0 -273
- package/.as-test/logs/naive/run.set.spec.ts.log.json +0 -733
- package/.as-test/logs/naive/run.staticarray.spec.ts.log.json +0 -931
- package/.as-test/logs/naive/run.string.spec.ts.log.json +0 -2289
- package/.as-test/logs/naive/run.struct.spec.ts.log.json +0 -523
- package/.as-test/logs/naive/run.types.spec.ts.log.json +0 -273
- package/.as-test/logs/naive/test.arbitrary.spec.ts.log.json +0 -943
- package/.as-test/logs/naive/test.array.spec.ts.log.json +0 -1053
- package/.as-test/logs/naive/test.bool.spec.ts.log.json +0 -257
- package/.as-test/logs/naive/test.box.spec.ts.log.json +0 -353
- package/.as-test/logs/naive/test.custom.spec.ts.log.json +0 -309
- package/.as-test/logs/naive/test.date.spec.ts.log.json +0 -397
- package/.as-test/logs/naive/test.enum.spec.ts.log.json +0 -343
- package/.as-test/logs/naive/test.float.spec.ts.log.json +0 -453
- package/.as-test/logs/naive/test.generics.spec.ts.log.json +0 -393
- package/.as-test/logs/naive/test.hierarchy.spec.ts.log.json +0 -325
- package/.as-test/logs/naive/test.integer.spec.ts.log.json +0 -373
- package/.as-test/logs/naive/test.log.json +0 -2289
- package/.as-test/logs/naive/test.map.spec.ts.log.json +0 -247
- package/.as-test/logs/naive/test.namespace.spec.ts.log.json +0 -361
- package/.as-test/logs/naive/test.null.spec.ts.log.json +0 -273
- package/.as-test/logs/naive/test.raw.spec.ts.log.json +0 -309
- package/.as-test/logs/naive/test.resolving.spec.ts.log.json +0 -273
- package/.as-test/logs/naive/test.set.spec.ts.log.json +0 -733
- package/.as-test/logs/naive/test.staticarray.spec.ts.log.json +0 -931
- package/.as-test/logs/naive/test.string.spec.ts.log.json +0 -2345
- package/.as-test/logs/naive/test.struct.spec.ts.log.json +0 -523
- package/.as-test/logs/naive/test.types.spec.ts.log.json +0 -273
- package/.as-test/logs/simd/run.arbitrary.spec.ts.log.json +0 -943
- package/.as-test/logs/simd/run.array.spec.ts.log.json +0 -1053
- package/.as-test/logs/simd/run.bool.spec.ts.log.json +0 -257
- package/.as-test/logs/simd/run.box.spec.ts.log.json +0 -353
- package/.as-test/logs/simd/run.custom.spec.ts.log.json +0 -309
- package/.as-test/logs/simd/run.date.spec.ts.log.json +0 -397
- package/.as-test/logs/simd/run.enum.spec.ts.log.json +0 -343
- package/.as-test/logs/simd/run.float.spec.ts.log.json +0 -453
- package/.as-test/logs/simd/run.generics.spec.ts.log.json +0 -393
- package/.as-test/logs/simd/run.hierarchy.spec.ts.log.json +0 -325
- package/.as-test/logs/simd/run.integer.spec.ts.log.json +0 -373
- package/.as-test/logs/simd/run.map.spec.ts.log.json +0 -247
- package/.as-test/logs/simd/run.namespace.spec.ts.log.json +0 -361
- package/.as-test/logs/simd/run.null.spec.ts.log.json +0 -273
- package/.as-test/logs/simd/run.raw.spec.ts.log.json +0 -309
- package/.as-test/logs/simd/run.resolving.spec.ts.log.json +0 -273
- package/.as-test/logs/simd/run.set.spec.ts.log.json +0 -733
- package/.as-test/logs/simd/run.staticarray.spec.ts.log.json +0 -931
- package/.as-test/logs/simd/run.string.spec.ts.log.json +0 -2289
- package/.as-test/logs/simd/run.struct.spec.ts.log.json +0 -523
- package/.as-test/logs/simd/run.types.spec.ts.log.json +0 -273
- package/.as-test/logs/simd/test.arbitrary.spec.ts.log.json +0 -943
- package/.as-test/logs/simd/test.array.spec.ts.log.json +0 -1053
- package/.as-test/logs/simd/test.bool.spec.ts.log.json +0 -257
- package/.as-test/logs/simd/test.box.spec.ts.log.json +0 -353
- package/.as-test/logs/simd/test.custom.spec.ts.log.json +0 -309
- package/.as-test/logs/simd/test.date.spec.ts.log.json +0 -397
- package/.as-test/logs/simd/test.enum.spec.ts.log.json +0 -343
- package/.as-test/logs/simd/test.float.spec.ts.log.json +0 -453
- package/.as-test/logs/simd/test.generics.spec.ts.log.json +0 -393
- package/.as-test/logs/simd/test.hierarchy.spec.ts.log.json +0 -325
- package/.as-test/logs/simd/test.integer.spec.ts.log.json +0 -373
- package/.as-test/logs/simd/test.log.json +0 -11371
- package/.as-test/logs/simd/test.map.spec.ts.log.json +0 -247
- package/.as-test/logs/simd/test.namespace.spec.ts.log.json +0 -361
- package/.as-test/logs/simd/test.null.spec.ts.log.json +0 -273
- package/.as-test/logs/simd/test.raw.spec.ts.log.json +0 -309
- package/.as-test/logs/simd/test.resolving.spec.ts.log.json +0 -273
- package/.as-test/logs/simd/test.set.spec.ts.log.json +0 -733
- package/.as-test/logs/simd/test.staticarray.spec.ts.log.json +0 -931
- package/.as-test/logs/simd/test.string.spec.ts.log.json +0 -2345
- package/.as-test/logs/simd/test.struct.spec.ts.log.json +0 -523
- package/.as-test/logs/simd/test.types.spec.ts.log.json +0 -273
- package/.as-test/logs/swar/run.arbitrary.spec.ts.log.json +0 -943
- package/.as-test/logs/swar/run.array.spec.ts.log.json +0 -1053
- package/.as-test/logs/swar/run.bool.spec.ts.log.json +0 -257
- package/.as-test/logs/swar/run.box.spec.ts.log.json +0 -353
- package/.as-test/logs/swar/run.custom.spec.ts.log.json +0 -309
- package/.as-test/logs/swar/run.date.spec.ts.log.json +0 -397
- package/.as-test/logs/swar/run.enum.spec.ts.log.json +0 -343
- package/.as-test/logs/swar/run.float.spec.ts.log.json +0 -453
- package/.as-test/logs/swar/run.generics.spec.ts.log.json +0 -393
- package/.as-test/logs/swar/run.hierarchy.spec.ts.log.json +0 -325
- package/.as-test/logs/swar/run.integer.spec.ts.log.json +0 -373
- package/.as-test/logs/swar/run.map.spec.ts.log.json +0 -247
- package/.as-test/logs/swar/run.namespace.spec.ts.log.json +0 -361
- package/.as-test/logs/swar/run.null.spec.ts.log.json +0 -273
- package/.as-test/logs/swar/run.raw.spec.ts.log.json +0 -309
- package/.as-test/logs/swar/run.resolving.spec.ts.log.json +0 -273
- package/.as-test/logs/swar/run.set.spec.ts.log.json +0 -733
- package/.as-test/logs/swar/run.staticarray.spec.ts.log.json +0 -931
- package/.as-test/logs/swar/run.string.spec.ts.log.json +0 -2289
- package/.as-test/logs/swar/run.struct.spec.ts.log.json +0 -523
- package/.as-test/logs/swar/run.types.spec.ts.log.json +0 -273
- package/.as-test/logs/swar/test.arbitrary.spec.ts.log.json +0 -943
- package/.as-test/logs/swar/test.array.spec.ts.log.json +0 -1053
- package/.as-test/logs/swar/test.bool.spec.ts.log.json +0 -257
- package/.as-test/logs/swar/test.box.spec.ts.log.json +0 -353
- package/.as-test/logs/swar/test.custom.spec.ts.log.json +0 -309
- package/.as-test/logs/swar/test.date.spec.ts.log.json +0 -397
- package/.as-test/logs/swar/test.enum.spec.ts.log.json +0 -343
- package/.as-test/logs/swar/test.float.spec.ts.log.json +0 -453
- package/.as-test/logs/swar/test.generics.spec.ts.log.json +0 -393
- package/.as-test/logs/swar/test.hierarchy.spec.ts.log.json +0 -325
- package/.as-test/logs/swar/test.integer.spec.ts.log.json +0 -373
- package/.as-test/logs/swar/test.log.json +0 -11371
- package/.as-test/logs/swar/test.map.spec.ts.log.json +0 -247
- package/.as-test/logs/swar/test.namespace.spec.ts.log.json +0 -361
- package/.as-test/logs/swar/test.null.spec.ts.log.json +0 -273
- package/.as-test/logs/swar/test.raw.spec.ts.log.json +0 -309
- package/.as-test/logs/swar/test.resolving.spec.ts.log.json +0 -273
- package/.as-test/logs/swar/test.set.spec.ts.log.json +0 -733
- package/.as-test/logs/swar/test.staticarray.spec.ts.log.json +0 -931
- package/.as-test/logs/swar/test.string.spec.ts.log.json +0 -2345
- package/.as-test/logs/swar/test.struct.spec.ts.log.json +0 -523
- package/.as-test/logs/swar/test.types.spec.ts.log.json +0 -273
- package/.as-test/logs/test.arbitrary.spec.ts.log.json +0 -943
- package/.as-test/logs/test.array.spec.ts.log.json +0 -1053
- package/.as-test/logs/test.bool.spec.ts.log.json +0 -257
- package/.as-test/logs/test.box.spec.ts.log.json +0 -353
- package/.as-test/logs/test.custom.spec.ts.log.json +0 -309
- package/.as-test/logs/test.date.spec.ts.log.json +0 -397
- package/.as-test/logs/test.enum.spec.ts.log.json +0 -343
- package/.as-test/logs/test.float.spec.ts.log.json +0 -453
- package/.as-test/logs/test.generics.spec.ts.log.json +0 -393
- package/.as-test/logs/test.hierarchy.spec.ts.log.json +0 -325
- package/.as-test/logs/test.integer.spec.ts.log.json +0 -373
- package/.as-test/logs/test.log.json +0 -11371
- package/.as-test/logs/test.map.spec.ts.log.json +0 -247
- package/.as-test/logs/test.namespace.spec.ts.log.json +0 -361
- package/.as-test/logs/test.null.spec.ts.log.json +0 -273
- package/.as-test/logs/test.raw.spec.ts.log.json +0 -309
- package/.as-test/logs/test.resolving.spec.ts.log.json +0 -273
- package/.as-test/logs/test.set.spec.ts.log.json +0 -733
- package/.as-test/logs/test.staticarray.spec.ts.log.json +0 -931
- package/.as-test/logs/test.string.spec.ts.log.json +0 -2289
- package/.as-test/logs/test.struct.spec.ts.log.json +0 -523
- package/.as-test/logs/test.types.spec.ts.log.json +0 -273
- package/.as-test/runners/default.bindings.js +0 -68
- package/.as-test/runners/default.wasi.js +0 -38
- package/ARCHITECTURE.md +0 -323
- package/CONTRIBUTING.md +0 -244
- package/TODO +0 -1
- package/as-test.config.json +0 -40
- package/assembly/test.ts +0 -24
- package/eslint.config.js +0 -68
- package/lib/tsconfig.json +0 -8
- package/test.ts +0 -99
- package/tools/assemblyscript-eslint-local.js +0 -6
- package/tools/assemblyscript-eslint.js +0 -53
- package/tools/assemblyscript-prettier-plugin.js +0 -33
- package/tools/replacer.js +0 -63
- package/transform/tsconfig.json +0 -35
package/ARCHITECTURE.md
DELETED
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
# Architecture
|
|
2
|
-
|
|
3
|
-
This document describes the architecture of json-as, a high-performance JSON serialization library for AssemblyScript.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
json-as uses a two-tier architecture:
|
|
8
|
-
|
|
9
|
-
1. **Compile-time Transform**: A TypeScript-based AST transformer that generates optimized serialization/deserialization code
|
|
10
|
-
2. **Runtime Library**: AssemblyScript implementations for JSON processing with multiple optimization levels
|
|
11
|
-
|
|
12
|
-
```
|
|
13
|
-
┌─────────────────────────────────────────────────────────────────┐
|
|
14
|
-
│ Compile Time │
|
|
15
|
-
│ ┌─────────────┐ ┌──────────────┐ ┌──────────────────┐ │
|
|
16
|
-
│ │ Source Code │ -> │ Transform │ -> │ Generated Code │ │
|
|
17
|
-
│ │ with @json │ │ (TypeScript) │ │ __SERIALIZE etc │ │
|
|
18
|
-
│ └─────────────┘ └──────────────┘ └──────────────────┘ │
|
|
19
|
-
└─────────────────────────────────────────────────────────────────┘
|
|
20
|
-
│
|
|
21
|
-
V
|
|
22
|
-
┌─────────────────────────────────────────────────────────────────┐
|
|
23
|
-
│ Runtime │
|
|
24
|
-
│ ┌──────────────────────────────────────────────────────────┐ │
|
|
25
|
-
│ │ JSON Namespace │ │
|
|
26
|
-
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────────┐ │ │
|
|
27
|
-
│ │ │ stringify │ │ parse │ │ Dynamic Types │ │ │
|
|
28
|
-
│ │ └──────┬──────┘ └──────┬──────┘ │ Value, Obj, │ │ │
|
|
29
|
-
│ │ │ │ │ Box, Raw │ │ │
|
|
30
|
-
│ │ V V └─────────────────┘ │ │
|
|
31
|
-
│ │ ┌───────────────────────────────────────────────────┐ │ │
|
|
32
|
-
│ │ │ Optimization Modes │ │ │
|
|
33
|
-
│ │ │ ┌───────┐ ┌────────┐ ┌────────┐ │ │ │
|
|
34
|
-
│ │ │ │ NAIVE │ │ SWAR │ │ SIMD │ │ │ │
|
|
35
|
-
│ │ │ └───────┘ └────────┘ └────────┘ │ │ │
|
|
36
|
-
│ │ └───────────────────────────────────────────────────┘ │ │
|
|
37
|
-
│ └──────────────────────────────────────────────────────────┘ │
|
|
38
|
-
│ │ │
|
|
39
|
-
│ V │
|
|
40
|
-
│ ┌──────────────────────────────────────────────────────────┐ │
|
|
41
|
-
│ │ Memory Allocator (bs namespace) │ │
|
|
42
|
-
│ │ - Dynamic buffer management │ │
|
|
43
|
-
│ │ - EMA-based adaptive sizing │ │
|
|
44
|
-
│ │ - Optional string caching (sc namespace) │ │
|
|
45
|
-
│ └──────────────────────────────────────────────────────────┘ │
|
|
46
|
-
└─────────────────────────────────────────────────────────────────┘
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
## Transform System
|
|
50
|
-
|
|
51
|
-
The transform (`transform/src/`) is an AssemblyScript compiler plugin that runs during compilation.
|
|
52
|
-
|
|
53
|
-
### How It Works
|
|
54
|
-
|
|
55
|
-
1. **Discovery**: Scans source files for classes decorated with `@json` or `@serializable`
|
|
56
|
-
2. **Schema Building**: Creates a schema for each decorated class including:
|
|
57
|
-
- Field names and types
|
|
58
|
-
- Decorator metadata (@alias, @omit, @omitnull, @omitif)
|
|
59
|
-
- Inheritance relationships
|
|
60
|
-
- Type dependencies
|
|
61
|
-
3. **Code Generation**: Generates methods for each class:
|
|
62
|
-
- `__SERIALIZE(ptr: usize): void` - Writes JSON to the buffer
|
|
63
|
-
- `__DESERIALIZE<T>(srcStart, srcEnd, out): usize` - Parses JSON into `out` and returns the advanced source pointer
|
|
64
|
-
|
|
65
|
-
### Key Files
|
|
66
|
-
|
|
67
|
-
- `transform/src/index.ts` - Main transform entry point (JSONTransform class)
|
|
68
|
-
- `transform/src/visitor.ts` - AST visitor for traversing source code
|
|
69
|
-
- `transform/src/builder.ts` - AST builder for code generation
|
|
70
|
-
- `transform/src/types.ts` - Type definitions (Property, Schema, Src)
|
|
71
|
-
|
|
72
|
-
### Generated Code Example
|
|
73
|
-
|
|
74
|
-
For this class:
|
|
75
|
-
```typescript
|
|
76
|
-
@json
|
|
77
|
-
class Player {
|
|
78
|
-
name: string = "";
|
|
79
|
-
score: i32 = 0;
|
|
80
|
-
}
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
The transform generates:
|
|
84
|
-
```typescript
|
|
85
|
-
__SERIALIZE(ptr: usize): void {
|
|
86
|
-
store<u16>(bs.offset, 123); // {
|
|
87
|
-
bs.offset += 2;
|
|
88
|
-
// ... "name": serialize string ...
|
|
89
|
-
// ... "score": serialize integer ...
|
|
90
|
-
store<u16>(bs.offset, 125); // }
|
|
91
|
-
bs.offset += 2;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
__DESERIALIZE<T>(srcStart: usize, srcEnd: usize, out: T): usize {
|
|
95
|
-
// Key matching and value parsing logic
|
|
96
|
-
// Uses switch statements on key length for efficiency
|
|
97
|
-
return srcStart;
|
|
98
|
-
}
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
## Optimization Modes
|
|
102
|
-
|
|
103
|
-
json-as provides three optimization levels, selected via the `JSON_MODE` environment variable:
|
|
104
|
-
|
|
105
|
-
### NAIVE Mode
|
|
106
|
-
|
|
107
|
-
The baseline implementation with character-by-character processing.
|
|
108
|
-
|
|
109
|
-
- **Best for**: Debugging, compatibility testing
|
|
110
|
-
- **Performance**: Slowest but most readable
|
|
111
|
-
- **String escaping**: Checks each character individually
|
|
112
|
-
|
|
113
|
-
### SWAR Mode (Default)
|
|
114
|
-
|
|
115
|
-
Single Instruction, Multiple Data processing at the word level.
|
|
116
|
-
|
|
117
|
-
- **Best for**: General use, good balance of speed and compatibility
|
|
118
|
-
- **Performance**: Processes 4 characters at once
|
|
119
|
-
- **String escaping**: Uses bit manipulation to detect escape characters in parallel:
|
|
120
|
-
```
|
|
121
|
-
// Check if any byte in a 64-bit word needs escaping
|
|
122
|
-
const hasEscape = (word ^ 0x2222...) - 0x0101... & 0x8080...
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
### SIMD Mode
|
|
126
|
-
|
|
127
|
-
Uses WebAssembly SIMD instructions for 128-bit parallel processing.
|
|
128
|
-
|
|
129
|
-
- **Best for**: Maximum performance when SIMD is available
|
|
130
|
-
- **Performance**: Processes 8 characters at once
|
|
131
|
-
- **Requirement**: `--enable simd` flag during compilation
|
|
132
|
-
- **String escaping**: Uses `v128` operations for parallel character checking
|
|
133
|
-
|
|
134
|
-
## Buffer System
|
|
135
|
-
|
|
136
|
-
Located in `lib/as-bs.ts`, the buffer system (`bs` namespace) manages memory for serialization output.
|
|
137
|
-
|
|
138
|
-
### Key Features
|
|
139
|
-
|
|
140
|
-
1. **Dynamic Growth**: Buffer grows as needed during serialization
|
|
141
|
-
2. **Adaptive Sizing**: Uses exponential moving average (EMA) to track typical output sizes
|
|
142
|
-
3. **Automatic Shrinking**: Periodically shrinks if buffer is oversized for typical usage
|
|
143
|
-
|
|
144
|
-
### Memory Layout
|
|
145
|
-
|
|
146
|
-
```
|
|
147
|
-
┌───────────────────────────────────────────┐
|
|
148
|
-
│ ArrayBuffer │
|
|
149
|
-
│ ┌───────────────────┬─────────────────┐ │
|
|
150
|
-
│ │ Written Data │ Free Space │ │
|
|
151
|
-
│ └───────────────────┴─────────────────┘ │
|
|
152
|
-
│ ^ buffer ^ offset │
|
|
153
|
-
└───────────────────────────────────────────┘
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
### Key Functions
|
|
157
|
-
|
|
158
|
-
- `proposeSize(size)` - Ensure buffer can hold additional bytes
|
|
159
|
-
- `ensureSize(size)` - Grow buffer if necessary
|
|
160
|
-
- `out<T>()` - Copy buffer contents to new string, reset for next use
|
|
161
|
-
- `resize(size)` - Explicitly resize buffer
|
|
162
|
-
|
|
163
|
-
### String Caching (`sc` namespace)
|
|
164
|
-
|
|
165
|
-
Optional feature enabled via `JSON_CACHE=1` for repeated string serialization.
|
|
166
|
-
|
|
167
|
-
```
|
|
168
|
-
┌───────────────────────────────────────────────────────────────┐
|
|
169
|
-
│ Cache Structure │
|
|
170
|
-
│ ┌─────────────────────────────────────────────────────────┐ │
|
|
171
|
-
│ │ Entry Table (4096 slots) │ │
|
|
172
|
-
│ │ ┌────────┬────────┬────────┬────────┐ │ │
|
|
173
|
-
│ │ │ Entry 0│ Entry 1│ ... │Entry N │ │ │
|
|
174
|
-
│ │ │key,ptr,│key,ptr,│ │key,ptr,│ │ │
|
|
175
|
-
│ │ │ len │ len │ │ len │ │ │
|
|
176
|
-
│ │ └────────┴────────┴────────┴────────┘ │ │
|
|
177
|
-
│ └─────────────────────────────────────────────────────────┘ │
|
|
178
|
-
│ ┌─────────────────────────────────────────────────────────┐ │
|
|
179
|
-
│ │ Arena (1MB circular buffer) │ │
|
|
180
|
-
│ │ ┌──────────────────────────────────────────────────┐ │ │
|
|
181
|
-
│ │ │ Cached serialized string data... │ │ │
|
|
182
|
-
│ │ └──────────────────────────────────────────────────┘ │ │
|
|
183
|
-
│ │ ^ │ │
|
|
184
|
-
│ │ arenaPtr │ │
|
|
185
|
-
│ └─────────────────────────────────────────────────────────┘ │
|
|
186
|
-
└───────────────────────────────────────────────────────────────┘
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
## Type System
|
|
190
|
-
|
|
191
|
-
### Static Types
|
|
192
|
-
|
|
193
|
-
Regular AssemblyScript types handled directly:
|
|
194
|
-
- Primitives: `i8`, `i16`, `i32`, `i64`, `u8`, `u16`, `u32`, `u64`, `f32`, `f64`, `bool`
|
|
195
|
-
- Strings: `string`
|
|
196
|
-
- Collections: `Array<T>`, `StaticArray<T>`, `Map<K, V>`
|
|
197
|
-
- Classes decorated with `@json`
|
|
198
|
-
|
|
199
|
-
### Dynamic Types
|
|
200
|
-
|
|
201
|
-
For runtime type flexibility:
|
|
202
|
-
|
|
203
|
-
- **`JSON.Value`**: Can hold any JSON type
|
|
204
|
-
```typescript
|
|
205
|
-
const v = JSON.Value.from<i32>(42);
|
|
206
|
-
v.set<string>("hello"); // Can change type
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
- **`JSON.Obj`**: Dynamic object with string keys
|
|
210
|
-
```typescript
|
|
211
|
-
const obj = new JSON.Obj();
|
|
212
|
-
obj.set("key", 123);
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
- **`JSON.Box<T>`**: Nullable wrapper for primitives
|
|
216
|
-
```typescript
|
|
217
|
-
let maybeInt: JSON.Box<i32> | null = null;
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
- **`JSON.Raw`**: Pre-formatted JSON string (no re-serialization)
|
|
221
|
-
```typescript
|
|
222
|
-
map.set("data", new JSON.Raw('{"already":"json"}'));
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
## Serialization Flow
|
|
226
|
-
|
|
227
|
-
```
|
|
228
|
-
JSON.stringify<T>(data)
|
|
229
|
-
│
|
|
230
|
-
V
|
|
231
|
-
┌───────────────────┐
|
|
232
|
-
│ Type Dispatch │
|
|
233
|
-
│ (compile-time) │
|
|
234
|
-
└─────────┬─────────┘
|
|
235
|
-
│
|
|
236
|
-
┌─────┴─────┬─────────────┬──────────────┐
|
|
237
|
-
V V V V
|
|
238
|
-
┌───────┐ ┌────────┐ ┌──────────┐ ┌──────────┐
|
|
239
|
-
│Boolean│ │Integer │ │ String │ │ Struct │
|
|
240
|
-
│ Float │ │ │ │ │ │ (@json) │
|
|
241
|
-
└───┬───┘ └────┬───┘ └────┬─────┘ └────┬─────┘
|
|
242
|
-
│ │ │ │
|
|
243
|
-
│ │ │ │
|
|
244
|
-
└───────────┴─────┬──────┴──────────────┘
|
|
245
|
-
V
|
|
246
|
-
┌───────────────┐
|
|
247
|
-
│ Buffer System │
|
|
248
|
-
└───────┬───────┘
|
|
249
|
-
V
|
|
250
|
-
┌───────────────┐
|
|
251
|
-
│ Heap │
|
|
252
|
-
└───────┬───────┘
|
|
253
|
-
V
|
|
254
|
-
String
|
|
255
|
-
```
|
|
256
|
-
|
|
257
|
-
## Deserialization Flow
|
|
258
|
-
|
|
259
|
-
```
|
|
260
|
-
JSON.parse<T>(jsonString)
|
|
261
|
-
│
|
|
262
|
-
V
|
|
263
|
-
┌───────────────────┐
|
|
264
|
-
│ Type Dispatch │
|
|
265
|
-
│ (compile-time) │
|
|
266
|
-
└─────────┬─────────┘
|
|
267
|
-
│
|
|
268
|
-
┌─────┴─────┬─────────────┬──────────────┐
|
|
269
|
-
V V V V
|
|
270
|
-
┌───────┐ ┌────────┐ ┌──────────┐ ┌──────────┐
|
|
271
|
-
│Boolean│ │Integer │ │ String │ │ Struct │
|
|
272
|
-
└───┬───┘ └────┬───┘ └────┬─────┘ └────┬─────┘
|
|
273
|
-
│ │ │ │
|
|
274
|
-
└───────────┴─────┬──────┴──────────────┘
|
|
275
|
-
│
|
|
276
|
-
V
|
|
277
|
-
T
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
### Struct Deserialization
|
|
281
|
-
|
|
282
|
-
For `@json` decorated classes, the generated `__DESERIALIZE` method:
|
|
283
|
-
|
|
284
|
-
1. Scans for opening `{`
|
|
285
|
-
2. Iterates through key-value pairs
|
|
286
|
-
3. Uses switch on key length for fast dispatch
|
|
287
|
-
4. Compares key bytes directly (often as `u32` or `u64` for short keys)
|
|
288
|
-
5. Deserializes value to appropriate type
|
|
289
|
-
6. Stores in output object at correct offset
|
|
290
|
-
7. Returns the updated source pointer after the parsed value
|
|
291
|
-
|
|
292
|
-
## Environment Variables
|
|
293
|
-
|
|
294
|
-
| Variable | Default | Description |
|
|
295
|
-
|----------|---------|-------------|
|
|
296
|
-
| `JSON_MODE` | SWAR | Optimization mode: NAIVE, SWAR, SIMD |
|
|
297
|
-
| `JSON_USE_FAST_PATH` | 0 | When set to `1`, emit the fast struct `__DESERIALIZE` body and helper; otherwise emit only the slow path |
|
|
298
|
-
| `JSON_DEBUG` | 0 | Debug level 0-3 (prints generated code) |
|
|
299
|
-
| `JSON_WRITE` | "" | Comma-separated files to output after transform |
|
|
300
|
-
| `JSON_CACHE` | 0 | Enable string caching (set to 1) |
|
|
301
|
-
| `JSON_STRICT` | false | Enable strict JSON validation |
|
|
302
|
-
|
|
303
|
-
## Performance Considerations
|
|
304
|
-
|
|
305
|
-
### Serialization
|
|
306
|
-
|
|
307
|
-
- Pre-computes static key bytes at compile time
|
|
308
|
-
- Uses direct memory stores for known strings
|
|
309
|
-
- SIMD/SWAR for escape character detection
|
|
310
|
-
- Optional caching for repeated strings
|
|
311
|
-
|
|
312
|
-
### Deserialization
|
|
313
|
-
|
|
314
|
-
- Groups fields by key length for switch optimization
|
|
315
|
-
- Uses direct memory loads for key comparison
|
|
316
|
-
- Avoids string allocation during key matching
|
|
317
|
-
- Tracks depth for nested structures
|
|
318
|
-
|
|
319
|
-
### Memory
|
|
320
|
-
|
|
321
|
-
- Single reusable buffer reduces allocations
|
|
322
|
-
- EMA-based sizing prevents memory waste
|
|
323
|
-
- Circular arena for cache prevents unbounded growth
|
package/CONTRIBUTING.md
DELETED
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
# Contributing to json-as
|
|
2
|
-
|
|
3
|
-
Thank you for your interest in contributing to json-as! This document provides guidelines and instructions for contributing.
|
|
4
|
-
|
|
5
|
-
## Table of Contents
|
|
6
|
-
|
|
7
|
-
- [Getting Started](#getting-started)
|
|
8
|
-
- [Development Setup](#development-setup)
|
|
9
|
-
- [Project Structure](#project-structure)
|
|
10
|
-
- [Making Changes](#making-changes)
|
|
11
|
-
- [Testing](#testing)
|
|
12
|
-
- [Code Style](#code-style)
|
|
13
|
-
- [Pull Request Process](#pull-request-process)
|
|
14
|
-
- [Reporting Issues](#reporting-issues)
|
|
15
|
-
|
|
16
|
-
## Getting Started
|
|
17
|
-
|
|
18
|
-
1. Fork the repository on GitHub
|
|
19
|
-
2. Clone your fork locally:
|
|
20
|
-
```bash
|
|
21
|
-
git clone https://github.com/YOUR_USERNAME/json-as.git
|
|
22
|
-
cd json-as
|
|
23
|
-
```
|
|
24
|
-
3. Add the upstream remote:
|
|
25
|
-
```bash
|
|
26
|
-
git remote add upstream https://github.com/JairusSW/json-as.git
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## Development Setup
|
|
30
|
-
|
|
31
|
-
### Prerequisites
|
|
32
|
-
|
|
33
|
-
- Node.js 18+ or Bun
|
|
34
|
-
- Wasmtime (for running tests)
|
|
35
|
-
|
|
36
|
-
### Install Dependencies
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
npm install
|
|
40
|
-
# or
|
|
41
|
-
bun install
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
### Build the Transform
|
|
45
|
-
|
|
46
|
-
The transform is written in TypeScript and needs to be compiled:
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
npm run build:transform
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
### Running Tests
|
|
53
|
-
|
|
54
|
-
Run the full test suite across all modes (NAIVE, SWAR, SIMD):
|
|
55
|
-
|
|
56
|
-
```bash
|
|
57
|
-
npm test
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
Run a specific test file:
|
|
61
|
-
|
|
62
|
-
```bash
|
|
63
|
-
npm test string # Runs string.spec.ts
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
### Running Benchmarks
|
|
67
|
-
|
|
68
|
-
AssemblyScript benchmarks:
|
|
69
|
-
```bash
|
|
70
|
-
npm run bench:as
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
JavaScript comparison benchmarks:
|
|
74
|
-
```bash
|
|
75
|
-
npm run bench:js
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
## Project Structure
|
|
79
|
-
|
|
80
|
-
```
|
|
81
|
-
json-as/
|
|
82
|
-
├── .as-test/ # As-test configuration and runners
|
|
83
|
-
├── assembly/ # AssemblyScript runtime implementation
|
|
84
|
-
│ ├── index.ts # Main entry point (JSON namespace)
|
|
85
|
-
│ ├── serialize/ # Serialization implementations
|
|
86
|
-
│ │ ├── index/ # Indexer of all methods
|
|
87
|
-
│ │ ├── simple/ # Naive implementation
|
|
88
|
-
│ │ ├── swar/ # SWAR-optimized
|
|
89
|
-
│ │ └── simd/ # SIMD-optimized
|
|
90
|
-
│ ├── deserialize/ # Deserialization implementations
|
|
91
|
-
│ │ ├── index/ # Indexer of all methods
|
|
92
|
-
│ │ ├── simple/ # Naive implementation
|
|
93
|
-
│ │ ├── swar/ # SWAR-optimized
|
|
94
|
-
│ │ └── simd/ # SIMD-optimized
|
|
95
|
-
│ ├── util/ # Utility functions
|
|
96
|
-
│ ├── custom/ # Constants and character codes
|
|
97
|
-
│ └── __tests__/ # Test files
|
|
98
|
-
├── transform/ # TypeScript compiler transform
|
|
99
|
-
│ └── src/ # Transform source code
|
|
100
|
-
├── lib/ # Shared utilities (buffer system)
|
|
101
|
-
├── bench/ # Benchmark suite
|
|
102
|
-
└── .github/ # CI/CD workflows
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
## Making Changes
|
|
106
|
-
|
|
107
|
-
### Branching Strategy
|
|
108
|
-
|
|
109
|
-
1. Create a feature branch from `main`:
|
|
110
|
-
```bash
|
|
111
|
-
git checkout -b feature/your-feature-name
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
2. Make your changes with clear, atomic commits
|
|
115
|
-
|
|
116
|
-
3. Keep your branch up to date:
|
|
117
|
-
```bash
|
|
118
|
-
git fetch upstream
|
|
119
|
-
git rebase upstream/main
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
### Commit Messages
|
|
123
|
-
|
|
124
|
-
Use clear, descriptive commit messages:
|
|
125
|
-
|
|
126
|
-
- `feat: add support for BigInt serialization`
|
|
127
|
-
- `fix: handle escaped unicode in strings`
|
|
128
|
-
- `perf: optimize SIMD string escaping`
|
|
129
|
-
- `docs: update README examples`
|
|
130
|
-
- `test: add edge case tests for nested arrays`
|
|
131
|
-
- `chore: update dependencies`
|
|
132
|
-
|
|
133
|
-
## Testing
|
|
134
|
-
|
|
135
|
-
### Writing Tests
|
|
136
|
-
|
|
137
|
-
Tests are located in `assembly/__tests__/`. Each test file follows the pattern `*.spec.ts`.
|
|
138
|
-
|
|
139
|
-
Example test structure:
|
|
140
|
-
|
|
141
|
-
```typescript
|
|
142
|
-
import { JSON } from "..";
|
|
143
|
-
|
|
144
|
-
describe("Feature Name", () => {
|
|
145
|
-
test("should serialize correctly", () => {
|
|
146
|
-
const result = JSON.stringify<string>("hello");
|
|
147
|
-
expect(result).toBe('"hello"');
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
test("should deserialize correctly", () => {
|
|
151
|
-
const result = JSON.parse<string>('"hello"');
|
|
152
|
-
expect(result).toBe("hello");
|
|
153
|
-
});
|
|
154
|
-
});
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
### Test Coverage
|
|
158
|
-
|
|
159
|
-
Ensure your changes include tests for:
|
|
160
|
-
- Happy path scenarios
|
|
161
|
-
- Edge cases
|
|
162
|
-
- Error conditions
|
|
163
|
-
- All three modes (NAIVE, SWAR, SIMD) if applicable
|
|
164
|
-
|
|
165
|
-
## Code Style
|
|
166
|
-
|
|
167
|
-
### Formatting
|
|
168
|
-
|
|
169
|
-
The project uses Prettier for formatting:
|
|
170
|
-
|
|
171
|
-
```bash
|
|
172
|
-
npm run format
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
### AssemblyScript Guidelines
|
|
176
|
-
|
|
177
|
-
- Use `@inline` decorator for small, frequently-called functions
|
|
178
|
-
- Prefer `store<T>` and `load<T>` for direct memory operations
|
|
179
|
-
- Use typed arrays and explicit types
|
|
180
|
-
- Add `// @ts-ignore` comments with explanations when necessary
|
|
181
|
-
|
|
182
|
-
### TypeScript Guidelines (Transform)
|
|
183
|
-
|
|
184
|
-
- Use strict TypeScript settings
|
|
185
|
-
- Document complex logic with comments
|
|
186
|
-
- Keep functions focused and small
|
|
187
|
-
|
|
188
|
-
## Pull Request Process
|
|
189
|
-
|
|
190
|
-
1. **Before submitting:**
|
|
191
|
-
- Run the full test suite: `npm test`
|
|
192
|
-
- Run the formatter: `npm run format`
|
|
193
|
-
- Ensure your branch is up to date with `main`
|
|
194
|
-
|
|
195
|
-
2. **PR Description:**
|
|
196
|
-
- Clearly describe the changes
|
|
197
|
-
- Reference any related issues
|
|
198
|
-
- Include before/after benchmarks for performance changes
|
|
199
|
-
|
|
200
|
-
3. **Review Process:**
|
|
201
|
-
- PRs require at least one approval
|
|
202
|
-
- Address review feedback promptly
|
|
203
|
-
- Keep the PR focused on a single concern
|
|
204
|
-
|
|
205
|
-
4. **After Merge:**
|
|
206
|
-
- Delete your feature branch
|
|
207
|
-
- Update any related issues
|
|
208
|
-
|
|
209
|
-
## Reporting Issues
|
|
210
|
-
|
|
211
|
-
### Bug Reports
|
|
212
|
-
|
|
213
|
-
Include:
|
|
214
|
-
- json-as version
|
|
215
|
-
- AssemblyScript version
|
|
216
|
-
- Minimal reproduction case
|
|
217
|
-
- Expected vs actual behavior
|
|
218
|
-
- Error messages (if any)
|
|
219
|
-
|
|
220
|
-
### Feature Requests
|
|
221
|
-
|
|
222
|
-
Include:
|
|
223
|
-
- Use case description
|
|
224
|
-
- Proposed API (if applicable)
|
|
225
|
-
- Alternatives considered
|
|
226
|
-
|
|
227
|
-
## Performance Contributions
|
|
228
|
-
|
|
229
|
-
If your change affects performance:
|
|
230
|
-
|
|
231
|
-
1. Run benchmarks before and after
|
|
232
|
-
2. Include benchmark results in the PR
|
|
233
|
-
3. Test across all three modes (NAIVE, SWAR, SIMD)
|
|
234
|
-
4. Consider memory usage implications
|
|
235
|
-
|
|
236
|
-
## Questions?
|
|
237
|
-
|
|
238
|
-
- Open a GitHub Discussion for general questions
|
|
239
|
-
- Join the [AssemblyScript Discord](https://discord.gg/assemblyscript)
|
|
240
|
-
- Email the maintainer at [me@jairus.dev](mailto:me@jairus.dev)
|
|
241
|
-
|
|
242
|
-
## License
|
|
243
|
-
|
|
244
|
-
By contributing, you agree that your contributions will be licensed under the MIT License.
|
package/TODO
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
get staticarrays working within classes
|
package/as-test.config.json
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "./node_modules/as-test/as-test.config.schema.json",
|
|
3
|
-
"input": ["./assembly/__tests__/*.spec.ts"],
|
|
4
|
-
"outDir": "./.as-test/build",
|
|
5
|
-
"logs": "./.as-test/logs",
|
|
6
|
-
"coverageDir": "./.as-test/coverage",
|
|
7
|
-
"snapshotDir": "./.as-test/snapshots",
|
|
8
|
-
"config": "none",
|
|
9
|
-
"coverage": true,
|
|
10
|
-
"buildOptions": {
|
|
11
|
-
"args": ["--transform ./transform", "--debug"],
|
|
12
|
-
"target": "wasi"
|
|
13
|
-
},
|
|
14
|
-
"runOptions": {
|
|
15
|
-
"runtime": {
|
|
16
|
-
"cmd": "wasmtime <file>"
|
|
17
|
-
},
|
|
18
|
-
"reporter": "default"
|
|
19
|
-
},
|
|
20
|
-
"modes": {
|
|
21
|
-
"naive": {
|
|
22
|
-
"env": {
|
|
23
|
-
"JSON_MODE": "NAIVE"
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
"swar": {
|
|
27
|
-
"env": {
|
|
28
|
-
"JSON_MODE": "SWAR"
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
"simd": {
|
|
32
|
-
"env": {
|
|
33
|
-
"JSON_MODE": "SIMD"
|
|
34
|
-
},
|
|
35
|
-
"buildOptions": {
|
|
36
|
-
"args": ["--enable simd"]
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
package/assembly/test.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
function get_mask_chars(src: string, mask: u64): void {
|
|
2
|
-
const srcPtr = changetype<usize>(src);
|
|
3
|
-
while (mask != 0) {
|
|
4
|
-
const laneIdx = usize(ctz(mask) >> 3);
|
|
5
|
-
mask &= ~(0xffff << (laneIdx << 3));
|
|
6
|
-
// mask &= mask - 1;
|
|
7
|
-
console.log("Lane: " + laneIdx.toString());
|
|
8
|
-
const srcIdx = srcPtr + laneIdx;
|
|
9
|
-
const chunk = load<u32>(srcIdx);
|
|
10
|
-
const code = <u16>(chunk >> 16);
|
|
11
|
-
|
|
12
|
-
console.log("Chunk: " + String.fromCharCode(chunk & 0xffff) + String.fromCharCode(chunk >> 16));
|
|
13
|
-
console.log("Code: " + String.fromCharCode(load<u16>(srcIdx)));
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function backslash_or_quote_mask(block: u64): u64 {
|
|
18
|
-
const b = block ^ 0x005c_005c_005c_005c;
|
|
19
|
-
const q = block ^ 0x0022_0022_0022_0022;
|
|
20
|
-
return (((q - 0x0001_0001_0001_0001) & ~q) | ((b - 0x0001_0001_0001_0001) & ~b)) & 0x0080_0080_0080_0080;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const input = '\\"a"';
|
|
24
|
-
get_mask_chars(input, backslash_or_quote_mask(load<u64>(changetype<usize>(input))));
|