diff --git a/.prettierrc.json b/.prettierrc.json index c5bc56e..ee7eae4 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -2,5 +2,6 @@ "pluginSearchDirs": ["node_modules"], "plugins": ["assemblyscript-prettier"], "singleQuote": false, - "printWidth": 65536 + "printWidth": 65536, + "tabWidth": 2 } diff --git a/assembly/__benches__/misc.bench.ts b/assembly/__benches__/misc.bench.ts index a78ab36..ce88b21 100644 --- a/assembly/__benches__/misc.bench.ts +++ b/assembly/__benches__/misc.bench.ts @@ -1,82 +1,19 @@ -import { deserializeString_SIMD } from "../deserialize/simd/string"; -import { serializeString_SIMD } from "../serialize/simd/string"; -import { bench } from "as-bench/assembly/index"; -import { serialize_simple } from "../serialize/simple"; +import { bench } from "as-bench/assembly/bench"; import { bs } from "as-bs"; +import { deserializeString_SIMD } from "../deserialize/simd/string"; +import { deserializeString } from "../deserialize/simple/string"; +import { bytes } from "../util/bytes"; const str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()\\\"\t\r\f\n\u0000'; const str2 = '"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()\\\\\\"\\t\\r\\f\\n\\u0000"'; - -// bench("Serialize String (Simple)", () => { -// serializeString(str); -// }); - -// bench("Serialize String (BS)", () => { -// serializeString_BS(str); -// bs.reset(); -// }); - -@json -class Vec3 { - x: i32 = 1; - y: i32 = 2; - z: i32 = 3; - - __SERIALIZE(ptr: usize = 0): string { - if (ptr == 0) ptr = changetype(this); - let out = `{"x":${load(ptr, offsetof("x")).toString()},"y":${load(ptr, offsetof("y")).toString()},"z":${load(ptr, offsetof("z")).toString()},`; - store(changetype(out) + ((out.length - 1) << 1), 125); - return out; - } - - __SERIALIZE_BS(ptr: usize = 0): void { - ptr = ptr || changetype(this); - bs.ensureSize(128); - store(bs.offset, 9570664606466171); - store(bs.offset, 58, 8); - bs.offset += 10; - - serialize_simple(load(ptr, offsetof("x"))); - - store(bs.offset, 9570668901433388); - store(bs.offset, 58, 8); - bs.offset += 10; - - serialize_simple(load(ptr, offsetof("y"))); - - store(bs.offset, 9570673196400684); - store(bs.offset, 58, 8); - bs.offset += 10; - - serialize_simple(load(ptr, offsetof("z"))); - - store(bs.offset, 125); - bs.offset += 2; - } -} - -const vec: Vec3 = { - x: 1, - y: 2, - z: 3 -} - -bench("Serialize Object (New)", () => { - vec.__SERIALIZE_BS(changetype(vec)); - bs.out(); +const srcStart = changetype(str); +const srcEnd = srcStart + bytes(str); +bs.ensureSize(2048); +bench("Deserialize String (Simple)", () => { + deserializeString(str2); }); - -// bench("Serialize Object (Old)", () => { -// vec.__SERIALIZE(changetype(vec)); -// }); -// } - -// const out = new ArrayBuffer(256); -// bench("Serialize String (SIMD)", () => { -// // ~5.07GB/s -// serializeString_SIMD(str, changetype(out)); -// }); - // bench("Deserialize String (SIMD)", () => { -// // ~4.03GB/s -// deserializeString_SIMD(str2, changetype(out)); +// (str2, bs.buffer); // }); +bench("Deserialize String (SIMD)", () => { + deserializeString_SIMD(str2, srcStart, srcEnd, __new(158, idof())); +}); \ No newline at end of file diff --git a/assembly/deserialize/simd/string.ts b/assembly/deserialize/simd/string.ts index b9da861..f564a66 100644 --- a/assembly/deserialize/simd/string.ts +++ b/assembly/deserialize/simd/string.ts @@ -1,4 +1,3 @@ -import { OBJECT, TOTAL_OVERHEAD } from "rt/common"; import { BACK_SLASH } from "../../custom/chars"; import { DESERIALIZE_ESCAPE_TABLE, ESCAPE_HEX_TABLE } from "../../globals/tables"; @@ -12,11 +11,11 @@ const SPLAT_92 = i16x8.splat(92); /* \ */ */ // todo: optimize and stuff. it works, its not pretty. ideally, i'd like this to be (nearly) branchless // @ts-ignore: Decorator -@inline export function deserializeString_SIMD(src: string, dst: usize): usize { - let src_ptr = changetype(src) + 2; +@inline export function deserializeString_SIMD(src: string, srcStart: usize, srcEnd: usize, dst: usize): usize { + let src_ptr = srcStart + 2; let dst_ptr = changetype(dst); - const src_end = src_ptr + changetype(changetype(src) - TOTAL_OVERHEAD).rtSize - 4; + const src_end = srcEnd - 2; const src_end_15 = src_end - 15; while (src_ptr < src_end_15) { diff --git a/assembly/deserialize/simple/arbitrary.ts b/assembly/deserialize/simple/arbitrary.ts index c955585..d3ee2f5 100644 --- a/assembly/deserialize/simple/arbitrary.ts +++ b/assembly/deserialize/simple/arbitrary.ts @@ -15,6 +15,7 @@ import { deserializeString } from "./string"; if (firstChar > 47 && firstChar < 58) return JSON.Value.from(data.includes(".") ? deserializeInteger(data) : deserializeFloat(data)); if (firstChar == 45) return JSON.Value.from(data.includes(".") ? deserializeInteger(data) : deserializeFloat(data)); if (firstChar == 91) { + // array } if (firstChar == 116 || firstChar == 102) return JSON.Value.from(deserializeBoolean(data)); diff --git a/assembly/deserialize/simple/array/float.ts b/assembly/deserialize/simple/array/float.ts index 60d275d..650c989 100644 --- a/assembly/deserialize/simple/array/float.ts +++ b/assembly/deserialize/simple/array/float.ts @@ -1,4 +1,4 @@ -import { isSpace } from "util/string"; +import { isSpace } from "../../../util"; import { unsafeCharCodeAt } from "../../../custom/util"; import { COMMA, BRACKET_RIGHT } from "../../../custom/chars"; import { deserializeFloat } from "../float"; diff --git a/assembly/deserialize/simple/array/integer.ts b/assembly/deserialize/simple/array/integer.ts index c448dff..f9dbff7 100644 --- a/assembly/deserialize/simple/array/integer.ts +++ b/assembly/deserialize/simple/array/integer.ts @@ -1,4 +1,4 @@ -import { isSpace } from "util/string"; +import { isSpace } from "../../../util"; import { unsafeCharCodeAt } from "../../../custom/util"; import { COMMA, BRACKET_RIGHT } from "../../../custom/chars"; import { deserializeInteger } from "../integer"; diff --git a/assembly/deserialize/simple/bool.ts b/assembly/deserialize/simple/bool.ts index d2aa146..84938a8 100644 --- a/assembly/deserialize/simple/bool.ts +++ b/assembly/deserialize/simple/bool.ts @@ -16,3 +16,12 @@ import { unsafeCharCodeAt } from "../../custom/util"; else if (len == 5 && firstChar == CHAR_F && load(ptr, 2) == 28429466576093281) return false; return false; //ERROR(`Expected to find boolean, but found "${data.slice(0, 100)}" instead!`); } + +// @ts-ignore: Decorator valid here +@inline export function deserializeBoolean_NEW(srcStart: usize, srcEnd: usize): boolean { + const srcSize = srcEnd - srcStart; + const firstChar = load(srcStart); + if (srcSize == 4 && firstChar == CHAR_T && load(srcStart) == 28429475166421108) return true; + else if (srcSize == 5 && firstChar == CHAR_F && load(srcSize, 2) == 28429466576093281) return false; + return false; //ERROR(`Expected to find boolean, but found "${data.slice(0, 100)}" instead!`); +} diff --git a/assembly/deserialize/simple/float.ts b/assembly/deserialize/simple/float.ts index 6d0b60c..05d2876 100644 --- a/assembly/deserialize/simple/float.ts +++ b/assembly/deserialize/simple/float.ts @@ -7,3 +7,9 @@ // @ts-ignore return f32.parse(data); } + +// @ts-ignore: Decorator valid here +@inline export function deserializeFloat_NEW(srcStart: usize, srcEnd: usize): T { + // todo: actually implement this + return 3.14 +} diff --git a/assembly/deserialize/simple/integer.ts b/assembly/deserialize/simple/integer.ts index c4ef3fa..e1f74eb 100644 --- a/assembly/deserialize/simple/integer.ts +++ b/assembly/deserialize/simple/integer.ts @@ -1,7 +1,13 @@ import { snip_fast } from "../../custom/util"; +import { strToInt } from "../../util/strToInt"; // @ts-ignore: Decorator valid here @inline export function deserializeInteger(data: string): T { // @ts-ignore return snip_fast(data); } + +// @ts-ignore: Decorator valid here +@inline export function deserializeInteger_NEW(srcStart: usize, srcEnd: usize): T { + return strToInt(srcStart, srcEnd); +} diff --git a/assembly/deserialize/simple/map.ts b/assembly/deserialize/simple/map.ts index 5cdea26..025b786 100644 --- a/assembly/deserialize/simple/map.ts +++ b/assembly/deserialize/simple/map.ts @@ -4,7 +4,7 @@ import { CHAR_A, BACK_SLASH, COLON, COMMA, CHAR_E, CHAR_F, CHAR_L, BRACE_LEFT, B import { deserializeBoolean } from "./bool"; import { JSON } from "../.."; import { deserializeString } from "./string"; -import { isSpace } from "util/string"; +import { isSpace } from "../../util"; import { deserializeInteger } from "./integer"; import { deserializeFloat } from "./float"; diff --git a/assembly/deserialize/simple/object.ts b/assembly/deserialize/simple/object.ts index bbfe301..653ecc6 100644 --- a/assembly/deserialize/simple/object.ts +++ b/assembly/deserialize/simple/object.ts @@ -1,6 +1,6 @@ import { unsafeCharCodeAt } from "../../custom/util"; -import { CHAR_A, BACK_SLASH, COMMA, CHAR_E, CHAR_F, CHAR_L, BRACE_LEFT, BRACKET_LEFT, CHAR_N, QUOTE, CHAR_R, BRACE_RIGHT, BRACKET_RIGHT, CHAR_S, CHAR_T, CHAR_U } from "../../custom/chars"; -import { isSpace } from "util/string"; +import { CHAR_A, BACK_SLASH, COMMA, CHAR_E, CHAR_F, CHAR_L, BRACE_LEFT, BRACKET_LEFT, CHAR_N, QUOTE, CHAR_R, BRACE_RIGHT, BRACKET_RIGHT, CHAR_S, CHAR_T, CHAR_U, COLON } from "../../custom/chars"; +import { isSpace } from "../../util"; export function deserializeObject(data: string): T { const schema: nonnull = changetype>(__new(offsetof>(), idof>())); @@ -103,3 +103,124 @@ export function deserializeObject(data: string): T { } return schema; } + +export function deserializeObject_NEW(srcStart: usize, srcEnd: usize): T { + console.log("Data: " + str(srcStart, srcEnd)); + const schema: nonnull = changetype>(__new(offsetof>(), idof>())); + + const srcPtr = srcStart; + + let keyStart: usize = 0; + let keyEnd: usize = 0; + let isKey = false; + let depth = 0; + let lastIndex = 0; + + // while (srcStart < srcEnd && isSpace(load(srcStart))) srcStart += 2; + // while (srcEnd > srcStart && isSpace(load(srcEnd))) srcEnd -= 2; + + while (srcStart < srcEnd) { + let code = load(srcStart);// while (isSpace(code)) code = load(srcStart += 2); + if (keyStart == 0) { + if (code == QUOTE && load(srcStart - 2) !== BACK_SLASH) { + if (isKey) { + keyStart = lastIndex; + keyEnd = srcStart; + console.log("Key: " + str(lastIndex, srcStart)); + while (isSpace(code = load(srcStart += 2))) { /* empty */ } + if (code !== COLON) + throw new Error( + "Expected ':' after key at position " + (srcStart - srcPtr).toString(), + ); + isKey = false; + } else { + isKey = true; // i don't like this + lastIndex = srcStart + 2; + } + } + // isKey = !isKey; + srcStart += 2; + } else { + if (code == QUOTE) { + lastIndex = srcStart; + srcStart += 2; + while (srcStart < srcEnd) { + const code = load(srcStart); + if (code == QUOTE && load(srcStart - 2) !== BACK_SLASH) { + while (isSpace(load(srcStart += 2))) { /* empty */ } + console.log("Value (string): " + str(lastIndex, srcStart)); + // @ts-ignore: exists + schema.__DESERIALIZE(keyStart, keyEnd, lastIndex, srcStart); + keyStart = 0; + break; + } + srcStart += 2; + } + } else if (code - 48 <= 9 || code == 45) { + lastIndex = srcStart; + srcStart += 2; + while (srcStart < srcEnd) { + const code = load(srcStart); + if (code == COMMA || code == BRACE_RIGHT || isSpace(code)) { + // @ts-ignore: exists + schema.__DESERIALIZE(keyStart, keyEnd, lastIndex, srcStart); + console.log("Value (number): " + str(lastIndex, srcStart)); + while (isSpace(load(srcStart += 2))) { /* empty */ } + keyStart = 0; + break; + } + srcStart += 2; + } + } else if (code == BRACE_LEFT) { + lastIndex = srcStart; + depth++; + srcStart += 2; + while (srcStart < srcEnd) { + const code = load(srcStart); + if (((code ^ BRACE_RIGHT) | (code ^ BRACKET_RIGHT)) == 32) { + if (--depth == 0) { + // @ts-ignore: exists + schema.__DESERIALIZE(keyStart, keyEnd, lastIndex, srcStart); + console.log("Value (object): " + str(lastIndex, srcStart)); + keyStart = 0; + while (isSpace(load(srcStart += 2))) { /* empty */ } + break; + } + } else if (((code ^ BRACE_LEFT) | (code ^ BRACKET_LEFT)) == 220) depth++; + srcStart += 2; + } + } else if (code == CHAR_T) { + if (load(srcStart) == 28429475166421108) { + // @ts-ignore: exists + schema.__DESERIALIZE(keyStart, keyEnd, srcStart, srcStart += 8); + console.log("Value (bool): " + str(srcStart - 8, srcStart)); + while (isSpace(load(srcStart += 2))) { /* empty */ } + keyStart = 0; + } + } else if (code == CHAR_F) { + if (load(srcStart, 2) == 28429466576093281) { + // @ts-ignore: exists + schema.__DESERIALIZE(keyStart, keyEnd, srcStart, srcStart += 10); + console.log("Value (bool): " + str(srcStart - 10, srcStart)); + while (isSpace(load(srcStart += 2))) { /* empty */ } + keyStart = 0; + } + } else if (code == CHAR_N) { + if (load(srcStart) == 30399761348886638) { + // @ts-ignore: exists + schema.__DESERIALIZE(keyStart, keyEnd, srcStart, srcStart += 8); + console.log("Value (null): " + str(srcStart - 8, srcStart)); + while (isSpace(load(srcStart += 2))) { /* empty */ } + } + } + } + } + return schema; +} + +function str(start: usize, end: usize): string { + const size = end - start; + const out = __new(size, idof()); + memory.copy(out, start, size); + return changetype(out); +} \ No newline at end of file diff --git a/assembly/deserialize/simple/string.ts b/assembly/deserialize/simple/string.ts index 460c787..eed31b8 100644 --- a/assembly/deserialize/simple/string.ts +++ b/assembly/deserialize/simple/string.ts @@ -1,6 +1,8 @@ import { CHAR_B, BACK_SLASH, BACKSPACE, CARRIAGE_RETURN, CHAR_F, FORM_FEED, CHAR_N, NEW_LINE, QUOTE, CHAR_R, CHAR_T, TAB, CHAR_U } from "../../custom/chars"; import { Sink } from "../../custom/sink"; import { unsafeCharCodeAt } from "../../custom/util"; +import { DESERIALIZE_ESCAPE_TABLE, ESCAPE_HEX_TABLE } from "../../globals/tables"; +import { bytes } from "../../util/bytes"; // @ts-ignore: Decorator valid here @inline export function deserializeString(data: string, start: i32 = 0, end: i32 = 0): string { @@ -66,3 +68,51 @@ import { unsafeCharCodeAt } from "../../custom/util"; } return result.toString(); } + +// @ts-ignore: Decorator valid here +@inline export function deserializeString_NEW(srcStart: usize, srcEnd: usize, dst: usize): string { + // const srcSize = srcEnd - srcStart; + // const dstSize = bytes(dst); + + let dstPtr = dst; + + let lastPtr = srcStart; + while (srcStart < srcEnd) { + let code = load(srcStart); + if (code == BACK_SLASH) { + code = load(DESERIALIZE_ESCAPE_TABLE + load(srcStart, 2)); + if (code == 117 && load(srcStart, 4) == 3145776) { + const block = load(srcStart, 8); + const codeA = block & 0xffff; + const codeB = (block >> 16) & 0xffff; + const escapedA = load(ESCAPE_HEX_TABLE + codeA); + const escapedB = load(ESCAPE_HEX_TABLE + codeB); + const escaped = (escapedA << 4) + escapedB; + const remBytes = srcStart - lastPtr; + memory.copy(dstPtr, lastPtr, remBytes); + dstPtr += remBytes; + store(dst, escaped); + dstPtr += 2; + srcStart += 12; + lastPtr = srcStart; + } else { + const remBytes = srcStart - lastPtr; + memory.copy(dstPtr, lastPtr, remBytes); + dstPtr += remBytes; + store(dstPtr, code); + dstPtr += 2; + srcStart += 4; + lastPtr = srcStart; + } + } else { + srcStart += 2; + } + } + + const remBytes = srcEnd - lastPtr; + memory.copy(dstPtr, lastPtr, remBytes); + dstPtr += remBytes; + + if (lastPtr != srcStart) dst = __renew(dst, dstPtr - dst); + return changetype(dst); +} \ No newline at end of file diff --git a/assembly/index.ts b/assembly/index.ts index 672bb3d..728165d 100644 --- a/assembly/index.ts +++ b/assembly/index.ts @@ -2,14 +2,14 @@ import { serializeString } from "./serialize/simple/string"; import { serializeArray } from "./serialize/simple/array"; import { serializeMap } from "./serialize/simple/map"; -import { deserializeBoolean } from "./deserialize/simple/bool"; +import { deserializeBoolean, deserializeBoolean_NEW } from "./deserialize/simple/bool"; import { deserializeArray } from "./deserialize/simple/array"; -import { deserializeFloat } from "./deserialize/simple/float"; +import { deserializeFloat, deserializeFloat_NEW } from "./deserialize/simple/float"; import { deserializeObject } from "./deserialize/simple/object"; import { deserializeMap } from "./deserialize/simple/map"; import { deserializeDate } from "./deserialize/simple/date"; -import { deserializeInteger } from "./deserialize/simple/integer"; -import { deserializeString } from "./deserialize/simple/string"; +import { deserializeInteger, deserializeInteger_NEW } from "./deserialize/simple/integer"; +import { deserializeString, deserializeString_NEW } from "./deserialize/simple/string"; import { serializeArbitrary } from "./serialize/simple/arbitrary"; import { Sink } from "./custom/sink"; @@ -95,10 +95,6 @@ export namespace JSON { serializeString(changetype(data)); return bs.shrinkTo(); // @ts-ignore: Supplied by transform - } else if (isDefined(data.__SERIALIZE)) { - // @ts-ignore - return data.__SERIALIZE(changetype(data)); - // @ts-ignore: Supplied by transform } else if (isDefined(data.__SERIALIZE_BS) && isDefined(data.__ALLOCATE)) { // @ts-ignore data.__ALLOCATE(); @@ -342,8 +338,7 @@ export namespace JSON { } } - // @ts-ignore: Decorator valid here - @inline function serialize_simple(src: T, staticSize: bool = false): void { + function __serialize(src: T, staticSize: bool = false): void { if (isBoolean()) { serializeBool(src as bool, staticSize); } else if (isInteger()) { @@ -378,4 +373,19 @@ export namespace JSON { ERROR(`Could not serialize src of type ${nameof()}. Make sure to add the correct decorators to classes.`); } } + export function __deserialize(srcStart: usize, srcEnd: usize, dst: usize = 0): T { + if (isBoolean()) { + // @ts-ignore: type + return deserializeBoolean_NEW(srcStart, srcEnd); + } else if (isInteger()) { + return deserializeInteger_NEW(srcStart, srcEnd); + } else if (isFloat()) { + return deserializeFloat_NEW(srcStart, srcEnd); + } else if (isString()) { + // @ts-ignore: type + return deserializeString_NEW(srcStart, srcEnd, dst); + } else { + ERROR("lol") + } + } } diff --git a/assembly/serialize/simple/array.ts b/assembly/serialize/simple/array.ts index 0252ebc..cd449af 100644 --- a/assembly/serialize/simple/array.ts +++ b/assembly/serialize/simple/array.ts @@ -23,7 +23,7 @@ export function serializeArray(src: T, staticSize: bool = false while (srcPtr < srcEnd) { const block = load>(srcPtr); - JSON.serialize_simple>(block); + JSON.__serialize>(block); if (!staticSize) bs.ensureSize(2); store(bs.offset, COMMA); bs.offset += 2; @@ -31,7 +31,7 @@ export function serializeArray(src: T, staticSize: bool = false } const lastBlock = load>(srcPtr); - JSON.serialize_simple>(lastBlock); + JSON.__serialize>(lastBlock); if (!staticSize) bs.ensureSize(2); store(bs.offset, BRACKET_RIGHT); bs.offset += 2; diff --git a/assembly/serialize/simple/map.ts b/assembly/serialize/simple/map.ts index 736282a..6f19829 100644 --- a/assembly/serialize/simple/map.ts +++ b/assembly/serialize/simple/map.ts @@ -21,21 +21,21 @@ export function serializeMap>(src: T, staticSize: bool = bs.offset += 2; for (let i = 0; i < srcEnd; i++) { - serialize_simple(unchecked(keys[i])); + __serialize(unchecked(keys[i])); if (!staticSize) bs.ensureSize(2); store(bs.offset, COLON); bs.offset += 2; - serialize_simple(unchecked(values[i])); + __serialize(unchecked(values[i])); if (!staticSize) bs.ensureSize(2); store(bs.offset, COMMA); bs.offset += 2; } - serialize_simple(unchecked(keys[srcEnd])); + __serialize(unchecked(keys[srcEnd])); if (!staticSize) bs.ensureSize(2); store(bs.offset, COLON); bs.offset += 2; - serialize_simple(unchecked(values[srcEnd])); + __serialize(unchecked(values[srcEnd])); if (!staticSize) bs.ensureSize(2); store(bs.offset, BRACE_RIGHT); bs.offset += 2; diff --git a/assembly/test.ts b/assembly/test.ts index e7b518a..915839e 100644 --- a/assembly/test.ts +++ b/assembly/test.ts @@ -1,33 +1,13 @@ -import { bs } from "as-bs"; import { JSON } from "."; -@json -class ItemPluginsBasket { - @alias("catalog_id") - catalogId!: string; - @alias("catalog_item_id") - catalogItemId!: string; - @alias("outlet_id") - outletId!: string; -} - -@json -class ItemPlugins { - @omitnull() - basket!: ItemPluginsBasket | null; -} - -@json -class Item { - id!: string; - @omitnull() - plugins!: ItemPlugins | null; -} +import { bytes } from "./util/bytes"; +import { deserializeObject_NEW } from "./deserialize/simple/object"; @json class Vec3 { x: i8 = 1; y: i8 = 2; z: i8 = 3; + xyx: i8 = 0 } const vec: Vec3 = { @@ -35,21 +15,16 @@ const vec: Vec3 = { y: 2, z: 3 } +// const serialized = JSON.stringify(vec); +// const ss = '{ "x":1,"y":2,"z":3}' +// const s = changetype(ss); +// console.log("Serialized: " + serialized); +// const deserialized = deserializeObject_NEW(s, s + bytes(ss)) +// console.log("Deserialized: " + JSON.stringify(deserialized)); -const item: Item = { - id: "1", - plugins: { - basket: { - catalogId: "1", - catalogItemId: "2", - outletId: "3" - } - } -}; - -function foo(): void {} - -// bs.ensureSize(2048); -console.log(JSON.stringify(vec)); -// bs.ensureSize(2048); -console.log(JSON.stringify(item)); \ No newline at end of file +// function str(start: usize, end: usize): string { +// const size = end - start; +// const out = __new(size, idof()); +// memory.copy(out, start, size); +// return changetype(out); +// } \ No newline at end of file diff --git a/assembly/util/index.ts b/assembly/util/index.ts new file mode 100644 index 0000000..0eaefb8 --- /dev/null +++ b/assembly/util/index.ts @@ -0,0 +1,5 @@ +export * from "./isSpace"; +export * from "./strToInt"; +export * from "./concat"; +export * from "./bytes"; +export * from "./nextPowerOf2"; \ No newline at end of file diff --git a/assembly/util/isSpace.ts b/assembly/util/isSpace.ts new file mode 100644 index 0000000..5addc39 --- /dev/null +++ b/assembly/util/isSpace.ts @@ -0,0 +1,4 @@ +// @ts-ignore +@inline export function isSpace(code: u16): boolean { + return (code == 0x20) || (code - 9 <= 4); +} \ No newline at end of file diff --git a/assembly/util/strToInt.ts b/assembly/util/strToInt.ts new file mode 100644 index 0000000..0c68dd4 --- /dev/null +++ b/assembly/util/strToInt.ts @@ -0,0 +1,35 @@ +/** + * Strtol optimized for JSON integers + * @param str + * @returns + */ +// @ts-ignore: Decorator valid here +@inline export function strToInt(srcStart: usize, srcEnd: usize): T { + // @ts-ignore: type + let val: T = 0; + if (isSigned()) { + if (load(srcStart) == 45) { + srcStart += 2; + while (srcStart < srcEnd) { + // @ts-ignore: type + val = (val * 10 + (load(srcStart) - 48)) as T; + srcStart += 2; + } + return -val as T; + } else { + while (srcStart < srcEnd) { + // @ts-ignore: type + val = (val * 10 + (load(srcStart) - 48)) as T; + srcStart += 2; + } + return val as T; + } + } else { + while (srcStart < srcEnd) { + // @ts-ignore: type + val = (val * 10 + (load(changetype(str) + start) - 48)) as T; + srcStart += 2; + } + return val as T; + } +} \ No newline at end of file diff --git a/package.json b/package.json index 227ff29..745f8bc 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "@as-tral/cli": "^3.0.2", "@assemblyscript/wasi-shim": "^0.1.0", "@types/node": "latest", + "as-bench": "^0.0.0-alpha", "as-console": "^7.0.0", "assemblyscript": "^0.27.31", "assemblyscript-prettier": "^3.0.1", diff --git a/transform/lib/index.js b/transform/lib/index.js index 8b5d726..ccc83c2 100644 --- a/transform/lib/index.js +++ b/transform/lib/index.js @@ -124,7 +124,7 @@ class JSONTransform extends Visitor { let SERIALIZE = "@inline __SERIALIZE(ptr: usize = changetype(this)): string {\n"; let SERIALIZE_BS = "__SERIALIZE_BS(ptr: usize, staticSize: bool): void {\n"; let INITIALIZE = "@inline __INITIALIZE(): this {\n"; - let DESERIALIZE = "__DESERIALIZE(data: string, key_start: i32, key_end: i32, value_start: i32, value_end: i32): boolean {\n const len = key_end - key_start;\n"; + let DESERIALIZE = "__DESERIALIZE(keyStart: usize, keyEnd: usize, valStart: usize, valEnd: usize): void {\n"; let ALLOCATE = "@inline __ALLOCATE(): void {\n"; indent = " "; if (this.schema.static == false) { @@ -149,7 +149,7 @@ class JSONTransform extends Visitor { const keyPart = (isFirst ? "{" : ",") + aliasName + ":"; this.schema.byteSize += keyPart.length << 1; SERIALIZE_BS += this.getStores(keyPart).map(v => indent + v + "\n").join(""); - SERIALIZE_BS += indent + `JSON.serialize_simple<${member.type}>(load<${member.type}>(ptr, offsetof("${realName}")), ${isPrimitive(member.type)});\n`; + SERIALIZE_BS += indent + `JSON.__serialize<${member.type}>(load<${member.type}>(ptr, offsetof("${realName}")), ${isPrimitive(member.type)});\n`; if (isFirst) isFirst = false; } @@ -157,7 +157,7 @@ class JSONTransform extends Visitor { const keyPart = (isFirst ? "" : ",") + aliasName + ":"; this.schema.byteSize += keyPart.length << 1; SERIALIZE_BS += this.getStores(keyPart).map(v => indent + v + "\n").join(""); - SERIALIZE_BS += indent + `JSON.serialize_simple<${member.type}>(load<${member.type}>(ptr, offsetof("${realName}")), staticSize);\n`; + SERIALIZE_BS += indent + `JSON.__serialize<${member.type}>(load<${member.type}>(ptr, offsetof("${realName}")), staticSize);\n`; if (isFirst) isFirst = false; } @@ -168,7 +168,7 @@ class JSONTransform extends Visitor { const keyPart = aliasName + ":"; this.schema.byteSize += keyPart.length << 1; SERIALIZE_BS += this.getStores(keyPart).map(v => indent + v + "\n").join(""); - SERIALIZE_BS += indent + `JSON.serialize_simple<${member.type}>(load<${member.type}>(ptr, offsetof("${realName}")), staticSize);\n`; + SERIALIZE_BS += indent + `JSON.__serialize<${member.type}>(load<${member.type}>(ptr, offsetof("${realName}")), staticSize);\n`; if (!isLast) { this.schema.byteSize += 2; SERIALIZE_BS += indent + `store(bs.offset, 44, 0); // ,\n`; @@ -182,7 +182,7 @@ class JSONTransform extends Visitor { SERIALIZE_BS += indent + `if (${toString}) !== 0) {\n`; indentInc(); SERIALIZE_BS += this.getStores(aliasName + ":").map(v => indent + v + "\n").join(""); - SERIALIZE_BS += indent + `JSON.serialize_simple<${member.type}>(load<${member.type}>(ptr, offsetof("${realName}")), staticSize);\n`; + SERIALIZE_BS += indent + `JSON.__serialize<${member.type}>(load<${member.type}>(ptr, offsetof("${realName}")), staticSize);\n`; if (!isLast) { this.schema.byteSize += 2; SERIALIZE_BS += indent + `store(bs.offset, 44, 0); // ,\n`; @@ -193,6 +193,124 @@ class JSONTransform extends Visitor { } } } + const sortedMembers = []; + let len = -1; + this.schema.members + .slice() + .sort((a, b) => (a.alias?.length || a.name.length) - (b.alias?.length || b.name.length)) + .forEach((member) => { + const _nameLength = member.alias?.length || member.name.length; + if (_nameLength === len) { + sortedMembers[sortedMembers.length - 1].push(member); + } + else { + sortedMembers.push([member]); + len = _nameLength; + } + }); + const groups = sortedMembers.length; + if (groups != 1) { + DESERIALIZE += " switch (keyEnd - keyStart) {\n"; + indent = " "; + } + else { + indent = " "; + } + for (const memberGroup of sortedMembers) { + const firstMemberLen = (memberGroup[0].alias || memberGroup[0].name).length << 1; + if (firstMemberLen == 2) { + if (groups != 1) { + DESERIALIZE += indent + "case 2: {\n"; + indentInc(); + } + if (memberGroup.length == 1) { + const member = memberGroup[0]; + const memberName = member.alias || member.name; + DESERIALIZE += indent + `if (load(keyStart) == ${memberName.charCodeAt(0)}) this.${member.name} = JSON.__deserialize<${member.type}>(valStart, valEnd);\n`; + if (groups != 1) + DESERIALIZE += indent + "break;\n"; + break; + } + DESERIALIZE += indent + "switch (load(keyStart)) {\n"; + for (const member of memberGroup) { + const memberName = member.alias || member.name; + DESERIALIZE += indent + ` case ${memberName.charCodeAt(0)}: { // ${memberName}\n`; + DESERIALIZE += indent + ` this.${member.name} = JSON.__deserialize<${member.type}>(valStart, valEnd);\n`; + DESERIALIZE += indent + " break;\n"; + DESERIALIZE += indent + " }\n"; + } + DESERIALIZE += indent + "}\n"; + if (groups != 1) { + indentDec(); + DESERIALIZE += indent + "}\n"; + } + } + else if (firstMemberLen == 4) { + if (groups != 1) { + DESERIALIZE += indent + "case 4: {\n"; + indentInc(); + } + DESERIALIZE += indent + "switch (load(keyStart)) {\n"; + for (const member of memberGroup) { + const memberName = member.alias || member.name; + DESERIALIZE += indent + ` case ${memberName.charCodeAt(0)}: { // ${memberName}\n`; + DESERIALIZE += indent + ` this.${member.name} = JSON.__deserialize<${member.type}>(valStart, valEnd);\n`; + DESERIALIZE += indent + " break;\n"; + DESERIALIZE += indent + " }\n"; + } + DESERIALIZE += indent + "}\n"; + if (groups != 1) { + indentDec(); + DESERIALIZE += indent + "}\n"; + } + } + else if (firstMemberLen == 6) { + if (groups != 1) { + DESERIALIZE += indent + "case 6: {\n"; + indentInc(); + } + DESERIALIZE += indent + "switch ((load(keyStart, 2) << 3) | load(keyStart)) {\n"; + for (const member of memberGroup) { + const memberName = member.alias || member.name; + DESERIALIZE += indent + ` case ${strToNum(memberName)[1]}: { // ${memberName}\n`; + DESERIALIZE += indent + ` this.${member.name} = JSON.__deserialize<${member.type}>(valStart, valEnd);\n`; + DESERIALIZE += indent + " break;\n"; + DESERIALIZE += indent + " }\n"; + } + DESERIALIZE += indent + "}\n"; + if (groups != 1) { + indentDec(); + DESERIALIZE += indent + "}\n"; + } + } + else if (memberGroup.length > 1) { + if (groups != 1) { + DESERIALIZE += indent + "case " + firstMemberLen + ": {\n"; + indentInc(); + } + DESERIALIZE += indent + "switch (load(keyStart)) {\n"; + for (const member of memberGroup) { + const memberName = member.alias || member.name; + DESERIALIZE += indent + ` case ${memberName.charCodeAt(0)}: { // ${memberName}\n`; + DESERIALIZE += indent + ` this.${member.name} = JSON.__deserialize<${member.type}>(valStart, valEnd);\n`; + DESERIALIZE += indent + " break;\n"; + DESERIALIZE += indent + " }\n"; + } + DESERIALIZE += indent + "}\n"; + if (groups != 1) { + indentDec(); + DESERIALIZE += indent + "}\n"; + } + } + } + if (groups != 1) { + DESERIALIZE += " } \n"; + DESERIALIZE += "} "; + } + else { + DESERIALIZE += "} "; + } + indent = " "; this.schema.byteSize += 2; SERIALIZE_BS += indent + "store(bs.offset, 125, 0); // }\n"; SERIALIZE_BS += indent + "bs.offset += 2;\n"; @@ -208,6 +326,7 @@ class JSONTransform extends Visitor { if (process.env["JSON_DEBUG"]) { console.log(SERIALIZE); console.log(SERIALIZE_BS); + console.log(DESERIALIZE); console.log(ALLOCATE); } const SERIALIZE_METHOD = SimpleParser.parseClassMember(SERIALIZE, node); @@ -225,7 +344,7 @@ class JSONTransform extends Visitor { let SERIALIZE_RAW_EMPTY = '@inline __SERIALIZE(ptr: usize = changetype(this)): string {\n return "{}";\n}'; let SERIALIZE_BS_EMPTY = "@inline __SERIALIZE_BS(ptr: usize, staticSize: bool): void {\n store(bs.offset, 8192123);\n bs.offset += 4;\n}"; let INITIALIZE_EMPTY = "@inline __INITIALIZE(): this {\n return this;\n}"; - let DESERIALIZE_EMPTY = "@inline __DESERIALIZE(data: string, key_start: i32, key_end: i32, value_start: i32, value_end: i32): boolean {\n return false;\n}"; + let DESERIALIZE_EMPTY = "@inline __DESERIALIZE(keyStart: usize, keyEnd: usize, valStart: usize, valEnd: usize): void {\n return false;\n}"; let ALLOCATE_EMPTY = "@inline __ALLOCATE(): void {\n bs.ensureSize(4);\n}"; if (process.env["JSON_DEBUG"]) { console.log(SERIALIZE_RAW_EMPTY); diff --git a/transform/lib/index.js.map b/transform/lib/index.js.map index 513472f..636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;QACnD,OAAO,CAAC,CAAC;AAChB,CAAC;AAED,SAAS,YAAY,CAAC,MAAc;IAClC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC;AACpD,CAAC"} \ No newline at end of file diff --git a/transform/lib/index.old.js b/transform/lib/index.old.js new file mode 100644 index 0000000..241978a --- /dev/null +++ b/transform/lib/index.old.js @@ -0,0 +1,531 @@ +import { FieldDeclaration, IdentifierExpression, StringLiteralExpression, IntegerLiteralExpression, FloatLiteralExpression, NullExpression, TrueExpression, FalseExpression, } from "assemblyscript/dist/assemblyscript.js"; +import { toString, isStdlib } from "visitor-as/dist/utils.js"; +import { BaseVisitor, SimpleParser } from "visitor-as/dist/index.js"; +import { Transform } from "assemblyscript/dist/transform.js"; +class JSONTransform extends BaseVisitor { + schemasList = []; + currentClass; + sources = new Set(); + visitMethodDeclaration() { } + visitClassDeclaration(node) { + if (!node.decorators?.length) + return; + let found = false; + for (const decorator of node.decorators) { + const name = decorator.name.text; + if (name === "json" || name === "serializable") { + found = true; + break; + } + } + if (!found) + return; + const schema = new SchemaData(); + schema.node = node; + schema.name = node.name.text; + const members = [ + ...node.members.filter((v) => v.kind === 54), + ]; + if (node.extendsType) { + schema.parent = this.schemasList.find((v) => v.name == node.extendsType?.name.identifier.text); + if (schema.parent?.members) { + for (let i = schema.parent.members.length - 1; i >= 0; i--) { + const replace = schema.members.find((v) => v.name == schema.parent?.members[i]?.name); + if (!replace) { + members.unshift(schema.parent?.members[i].node); + } + } + } + } + if (!members.length) { + let SERIALIZE_RAW_EMPTY = '__SERIALIZE(): string {\n return "{}";\n}'; + let INITIALIZE_EMPTY = "__INITIALIZE(): this {\n return this;\n}"; + let DESERIALIZE_EMPTY = "__DESERIALIZE(data: string, key_start: i32, key_end: i32, value_start: i32, value_end: i32): boolean {\n return false;\n}"; + if (process.env["JSON_DEBUG"]) { + console.log(SERIALIZE_RAW_EMPTY); + console.log(INITIALIZE_EMPTY); + console.log(DESERIALIZE_EMPTY); + } + const SERIALIZE_RAW_METHOD_EMPTY = SimpleParser.parseClassMember(SERIALIZE_RAW_EMPTY, node); + const INITIALIZE_METHOD_EMPTY = SimpleParser.parseClassMember(INITIALIZE_EMPTY, node); + const DESERIALIZE_METHOD_EMPTY = SimpleParser.parseClassMember(DESERIALIZE_EMPTY, node); + if (!node.members.find((v) => v.name.text == "__SERIALIZE")) + node.members.push(SERIALIZE_RAW_METHOD_EMPTY); + if (!node.members.find((v) => v.name.text == "__INITIALIZE")) + node.members.push(INITIALIZE_METHOD_EMPTY); + if (!node.members.find((v) => v.name.text == "__DESERIALIZE")) + node.members.push(DESERIALIZE_METHOD_EMPTY); + this.schemasList.push(schema); + } + for (const member of members) { + const name = member.name; + if (!(member instanceof FieldDeclaration)) + continue; + if (!member.type) { + throw new Error("Fields must be strongly typed! Found " + + toString(member) + + " at " + + node.range.source.normalizedPath); + } + const type = toString(member.type); + if (type.startsWith("(") && type.includes("=>")) + continue; + const value = member.initializer ? toString(member.initializer) : null; + if (member.flags == 32) + continue; + if (member.flags === 512) + continue; + if (member.flags === 1024) + continue; + const mem = new Property(); + mem.name = name.text; + mem.type = type; + mem.value = value; + mem.node = member; + if (type.includes("JSON.Raw")) { + mem.flags.set(PropertyFlags.JSON_Raw, []); + } + if (member.type.isNullable) { + mem.flags.set(PropertyFlags.Null, []); + } + if (member.decorators) { + for (const decorator of member.decorators) { + const decoratorName = decorator.name.text; + const args = getArgs(decorator.args); + switch (decoratorName) { + case "alias": { + if (!args.length) + throw new Error("Expected 1 argument but got zero at @alias in " + + node.range.source.normalizedPath); + mem.alias = args[0]; + mem.flags.set(PropertyFlags.Alias, args); + break; + } + case "omit": { + mem.flags.set(PropertyFlags.Omit, args); + break; + } + case "omitif": { + if (!decorator.args?.length) + throw new Error("Expected 1 argument but got zero at @omitif in " + + node.range.source.normalizedPath); + mem.flags.set(PropertyFlags.OmitIf, args); + break; + } + case "omitnull": { + mem.flags.set(PropertyFlags.OmitNull, args); + break; + } + } + } + } + mem.generate(false); + if (this.schemasList.find((v) => v.name == type)) { + mem.initialize = + "this." + + name.text + + " = changetype>(__new(offsetof>(), idof>()));\n changetype>(this." + + name.text + + ").__INITIALIZE()"; + } + else if (mem.value) { + mem.initialize = "this." + name.text + " = " + mem.value; + } + else if (type === "Map") { + mem.initialize = "this." + name.text + " = new " + mem.type + "()"; + } + else if (type === "string") { + mem.initialize = "this." + name.text + ' = ""'; + } + else if (type === "Array") { + mem.initialize = + "this." + name.text + " = instantiate<" + mem.type + ">()"; + } + else if (type === "bool" || type === "boolean") { + mem.initialize = "this." + name.text + " = false"; + } + else if (type === "JSON.Raw") { + mem.initialize = "this." + name.text + ' = ""'; + } + else if (type === "u8" || + type === "u16" || + type === "u32" || + type === "u64" || + type === "i8" || + type === "i16" || + type === "i32" || + type === "i64") { + mem.initialize = "this." + name.text + " = 0"; + } + else if (type === "f32" || type === "f64") { + mem.initialize = "this." + name.text + " = 0.0"; + } + schema.members.push(mem); + } + let SERIALIZE_RAW = "__SERIALIZE(): string {\n let out = `{"; + let SERIALIZE_PRETTY = "__SERIALIZE_PRETTY(): string {\n let out = `{"; + let INITIALIZE = "__INITIALIZE(): this {\n"; + let DESERIALIZE = "__DESERIALIZE(data: string, key_start: i32, key_end: i32, value_start: i32, value_end: i32): boolean {\n const len = key_end - key_start;\n"; + let indent = " "; + if (!schema.members.length) + return; + found = false; + if (schema.members[0]?.flags.has(PropertyFlags.OmitNull) || + schema.members[0]?.flags.has(PropertyFlags.OmitIf)) { + SERIALIZE_RAW += schema.members[0]?.serialize; + SERIALIZE_PRETTY += "\\n" + schema.members[0]?.serialize; + } + else { + SERIALIZE_RAW += schema.members[0]?.serialize + ","; + SERIALIZE_PRETTY += "\\n" + schema.members[0]?.serialize + ",\\n"; + found = true; + } + if (schema.members[0]?.initialize) + INITIALIZE += " " + schema.members[0]?.initialize + ";\n"; + for (let i = 1; i < schema.members.length; i++) { + const member = schema.members[i]; + if (member.initialize) + INITIALIZE += " " + member.initialize + ";\n"; + if (member.flags.has(PropertyFlags.OmitNull) || + member.flags.has(PropertyFlags.OmitIf)) { + SERIALIZE_RAW += member.serialize; + SERIALIZE_PRETTY += member.serialize; + } + else { + SERIALIZE_RAW += member.serialize + ","; + SERIALIZE_PRETTY += indent + member.serialize + ",\\n"; + found = true; + } + } + if (found) { + SERIALIZE_RAW += + "`;\n store(changetype(out) + ((out.length - 1) << 1), 125);\n return out;\n}"; + SERIALIZE_PRETTY += + "`;\n store(changetype(out) + ((out.length - 2) << 1), 8192010);\n return out;\n}"; + } + else { + SERIALIZE_RAW += "}`;\n return out;\n}"; + SERIALIZE_PRETTY += "}`;\n return out;\n}"; + } + INITIALIZE += " return this;\n}"; + const sortedMembers = []; + const _sorted = schema.members.sort((a, b) => (a.alias?.length || a.name.length) - (b.alias?.length || b.name.length)); + let len = -1; + let offset = -1; + for (let i = 0; i < _sorted.length; i++) { + const member = _sorted[i]; + const _name = member.alias || member.name; + if (_name.length === len) { + sortedMembers[offset]?.push(member); + } + else { + sortedMembers.push([member]); + len = _name.length; + offset++; + } + } + let first = true; + for (const memberSet of sortedMembers) { + const firstMember = memberSet[0]; + const _name = encodeKey(firstMember.alias || firstMember.name); + if (_name.length === 1) { + if (first) { + DESERIALIZE += + " if (1 === len) {\n switch (load(changetype(data) + (key_start << 1))) {\n"; + first = false; + } + else { + DESERIALIZE += + "else if (1 === len) {\n switch (load(changetype(data) + (key_start << 1))) {\n"; + } + } + else if (_name.length === 2) { + if (first) { + DESERIALIZE += + " if (2 === len) {\n switch (load(changetype(data) + (key_start << 1))) {\n"; + first = false; + } + else { + DESERIALIZE += + "else if (2 === len) {\n switch (load(changetype(data) + (key_start << 1))) {\n"; + } + } + else if (_name.length === 4) { + if (first) { + DESERIALIZE += + " if (4 === len) {\n const code = load(changetype(data) + (key_start << 1));\n"; + first = false; + } + else { + DESERIALIZE += + "else if (4 === len) {\n const code = load(changetype(data) + (key_start << 1));\n"; + } + } + else { + if (first) { + DESERIALIZE += " if (" + _name.length + " === len) {\n"; + first = false; + } + else { + DESERIALIZE += "else if (" + _name.length + " === len) {\n"; + } + } + let f = true; + for (let i = 0; i < memberSet.length; i++) { + const member = memberSet[i]; + if (!member.deserialize) + continue; + const _name = encodeKey(member.alias || member.name); + if (_name.length === 1) { + DESERIALIZE += ` case ${_name.charCodeAt(0)}: { /* ${_name} */\n ${member.deserialize}\n return true;\n }\n`; + } + else if (_name.length === 2) { + DESERIALIZE += ` case ${charCodeAt32(_name, 0)}: { /* ${_name} */\n ${member.deserialize}\n return true;\n }\n`; + } + else if (_name.length === 4) { + if (f) { + f = false; + DESERIALIZE += ` if (${charCodeAt64(_name, 0)} === code) { /* ${_name} */\n ${member.deserialize}\n return true;\n }\n`; + } + else { + DESERIALIZE = + DESERIALIZE.slice(0, DESERIALIZE.length - 1) + + `else if (${charCodeAt64(_name, 0)} === code) {\n ${member.deserialize}\n return true;\n }\n`; + } + } + else { + if (f) { + f = false; + DESERIALIZE += ` if (0 === memory.compare(changetype("${escapeQuote(escapeSlash(_name))}"), changetype(data) + (key_start << 1), ${_name.length << 1})) { /* ${_name} */\n ${member.deserialize}\n return true;\n }\n`; + } + else { + DESERIALIZE = + DESERIALIZE.slice(0, DESERIALIZE.length - 1) + + ` else if (0 === memory.compare(changetype("${escapeQuote(escapeSlash(_name))}"), changetype(data) + (key_start << 1), ${_name.length << 1})) { /* ${_name} */\n ${member.deserialize}\n return true;\n }\n`; + } + } + } + if (_name.length < 3) { + DESERIALIZE += ` default: {\n return false;\n }\n }\n`; + } + else if (_name.length == 4) { + DESERIALIZE = + DESERIALIZE.slice(0, DESERIALIZE.length - 1) + + ` else {\n return false;\n }\n`; + } + else { + DESERIALIZE = + DESERIALIZE.slice(0, DESERIALIZE.length - 1) + + ` else {\n return false;\n }\n`; + } + DESERIALIZE += " } "; + } + DESERIALIZE += "\n return false;\n}"; + if (process.env["JSON_DEBUG"]) { + console.log(SERIALIZE_RAW); + console.log(INITIALIZE); + console.log(DESERIALIZE); + } + const SERIALIZE_RAW_METHOD = SimpleParser.parseClassMember(SERIALIZE_RAW, node); + const DESERIALIZE_SAFE = DESERIALIZE.replaceAll("__DESERIALIZE", "__DESERIALIZE_SAFE"); + const INITIALIZE_METHOD = SimpleParser.parseClassMember(INITIALIZE, node); + const DESERIALIZE_METHOD = SimpleParser.parseClassMember(DESERIALIZE, node); + const DESERIALIZE_SAFE_METHOD = SimpleParser.parseClassMember(DESERIALIZE_SAFE, node); + if (!node.members.find((v) => v.name.text == "__SERIALIZE")) + node.members.push(SERIALIZE_RAW_METHOD); + if (!node.members.find((v) => v.name.text == "__INITIALIZE")) + node.members.push(INITIALIZE_METHOD); + if (!node.members.find((v) => v.name.text == "__DESERIALIZE")) + node.members.push(DESERIALIZE_METHOD); + if (!node.members.find((v) => v.name.text == "__DESERIALIZE_SAFE")) + node.members.push(DESERIALIZE_SAFE_METHOD); + this.schemasList.push(schema); + } + visitSource(node) { + super.visitSource(node); + if (!this.sources.has(node)) { + return; + } + } +} +export default class Transformer extends Transform { + afterParse(parser) { + const transformer = new JSONTransform(); + const sources = parser.sources + .filter((source) => !isStdlib(source)) + .sort((_a, _b) => { + const a = _a.internalPath; + const b = _b.internalPath; + if (a[0] === "~" && b[0] !== "~") { + return -1; + } + else if (a[0] !== "~" && b[0] === "~") { + return 1; + } + else { + return 0; + } + }); + for (const source of sources) { + if (!isStdlib(source)) { + transformer.visit(source); + } + } + const schemas = transformer.schemasList; + for (const schema of schemas) { + if (schema.parent) { + const parent = schemas.find((v) => v.name === schema.parent?.name); + if (!parent) + throw new Error(`Class ${schema.name} extends its parent class ${schema.parent}, but ${schema.parent} does not include a @json or @serializable decorator! Add the decorator and rebuild.`); + } + } + } +} +var PropertyFlags; +(function (PropertyFlags) { + PropertyFlags[PropertyFlags["Null"] = 0] = "Null"; + PropertyFlags[PropertyFlags["Omit"] = 1] = "Omit"; + PropertyFlags[PropertyFlags["OmitNull"] = 2] = "OmitNull"; + PropertyFlags[PropertyFlags["OmitIf"] = 3] = "OmitIf"; + PropertyFlags[PropertyFlags["Alias"] = 4] = "Alias"; + PropertyFlags[PropertyFlags["JSON_Raw"] = 5] = "JSON_Raw"; +})(PropertyFlags || (PropertyFlags = {})); +class Property { + name = ""; + alias = null; + type = ""; + value = null; + flags = new Map(); + serialize = null; + deserialize = null; + initialize = null; + node; + right_s = ""; + right_d = ""; + generate(safe) { + const name = this.name; + const escapedName = escapeString(JSON.stringify(this.alias || this.name)); + const type = this.type; + if (this.flags.has(PropertyFlags.Omit)) + return; + if (this.flags.has(PropertyFlags.JSON_Raw)) { + if (this.flags.has(PropertyFlags.Null)) { + this.right_s = "(this." + name + " || \"null\")"; + this.right_d = "value_start === value_end - 4 && 30399761348886638 === load(changetype(data) + (value_start << 1)) ? null : data.substring(value_start, value_end)"; + } + else { + this.right_s = "this." + name; + this.right_d = "data.substring(value_start, value_end);"; + } + } + else { + this.right_s = "__SERIALIZE<" + type + ">(this." + name + ")"; + this.right_d = + (safe ? "__DESERIALIZE_SAFE" : "__DESERIALIZE") + "<" + type + ">(data.substring(value_start, value_end))"; + } + if (this.flags.has(PropertyFlags.OmitIf)) { + const condition = this.flags.get(PropertyFlags.OmitIf)[0]; + if (!condition) + throw new Error("Could not find condition when using decorator @omitif! Provide at least one condition"); + this.serialize = + "${" + + condition + + ' ? "" : \'' + + escapedName + + ":' + " + + this.right_s + + ' + ","}'; + this.deserialize = "this." + name + " = " + this.right_d + ";"; + } + else if (this.flags.has(PropertyFlags.OmitNull)) { + this.serialize = + "${changetype(this." + + name + + ") == 0" + + ' ? "" : \'' + + escapedName + + ":' + " + + this.right_s + + ' + ","}'; + this.deserialize = "this." + name + " = " + this.right_d + ";"; + } + else { + this.serialize = escapedName + ":${" + this.right_s + "}"; + this.deserialize = "this." + name + " = " + this.right_d + ";"; + } + } +} +class SchemaData { + name = ""; + members = []; + parent = null; + node; +} +function charCodeAt32(data, offset) { + return (data.charCodeAt(offset + 1) << 16) | data.charCodeAt(offset); +} +function charCodeAt64(data, offset) { + if (offset + 3 >= data.length) { + throw new Error("The string must have at least 4 characters from the specified offset."); + } + const firstCharCode = BigInt(data.charCodeAt(offset)); + const secondCharCode = BigInt(data.charCodeAt(offset + 1)); + const thirdCharCode = BigInt(data.charCodeAt(offset + 2)); + const fourthCharCode = BigInt(data.charCodeAt(offset + 3)); + const u64Value = (fourthCharCode << 48n) | + (thirdCharCode << 32n) | + (secondCharCode << 16n) | + firstCharCode; + return u64Value; +} +function encodeKey(key) { + const data = JSON.stringify(key); + return data.slice(1, data.length - 1); +} +function escapeString(data) { + return data.replace(/\\/g, "\\\\").replace(/\`/g, "\\`"); +} +function escapeSlash(data) { + return data.replace(/\\/g, "\\\\").replace(/\`/g, "\\`"); +} +function escapeQuote(data) { + return data.replace(/\"/g, '\\"'); +} +function getArgs(args) { + if (!args) + return []; + let out = []; + for (const arg of args) { + if (arg instanceof StringLiteralExpression) { + out.push(arg.value); + } + else if (arg instanceof IntegerLiteralExpression) { + out.push(i64_to_string(arg.value)); + } + else if (arg instanceof FloatLiteralExpression) { + out.push(arg.value.toString()); + } + else if (arg instanceof NullExpression) { + out.push(arg.text); + } + else if (arg instanceof TrueExpression) { + out.push(arg.text); + } + else if (arg instanceof FalseExpression) { + out.push(arg.text); + } + else if (arg instanceof IdentifierExpression) { + out.push(arg.text); + } + } + return out; +} +//# sourceMappingURL=index.old.js.map \ No newline at end of file diff --git a/transform/lib/index.old.js.map b/transform/lib/index.old.js.map new file mode 100644 index 0000000..7b6e035 --- /dev/null +++ b/transform/lib/index.old.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.old.js","sourceRoot":"","sources":["../src/index.old.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,gBAAgB,EAChB,oBAAoB,EAMpB,uBAAuB,EACvB,wBAAwB,EACxB,sBAAsB,EACtB,cAAc,EACd,cAAc,EACd,eAAe,GAChB,MAAM,uCAAuC,CAAC;AA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ACzC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACrB,CAAC;aAAM,IAAI,GAAG,YAAY,eAAe,EAAE,CAAC;YAC1C,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACrB,CAAC;aAAM,IAAI,GAAG,YAAY,oBAAoB,EAAE,CAAC;YAC/C,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACrB,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"} \ No newline at end of file diff --git a/transform/src/index.old.ts b/transform/src/index.old.ts new file mode 100644 index 0000000..9b54d54 --- /dev/null +++ b/transform/src/index.old.ts @@ -0,0 +1,617 @@ +import { + ClassDeclaration, + FieldDeclaration, + IdentifierExpression, + Parser, + Source, + NodeKind, + Expression, + CommonFlags, + StringLiteralExpression, + IntegerLiteralExpression, + FloatLiteralExpression, + NullExpression, + TrueExpression, + FalseExpression, + } from "assemblyscript/dist/assemblyscript.js"; + + import { toString, isStdlib } from "visitor-as/dist/utils.js"; + import { BaseVisitor, SimpleParser } from "visitor-as/dist/index.js"; + import { Transform } from "assemblyscript/dist/transform.js"; + + class JSONTransform extends BaseVisitor { + public schemasList: SchemaData[] = []; + public currentClass!: SchemaData; + public sources = new Set(); + + visitMethodDeclaration(): void { } + visitClassDeclaration(node: ClassDeclaration): void { + if (!node.decorators?.length) return; + + let found = false; + for (const decorator of node.decorators) { + const name = (decorator.name).text; + if (name === "json" || name === "serializable") { + found = true; + break; + } + } + if (!found) return; + + const schema = new SchemaData(); + schema.node = node; + schema.name = node.name.text; + + const members = [ + ...node.members.filter((v) => v.kind === NodeKind.FieldDeclaration), + ]; + + if (node.extendsType) { + schema.parent = this.schemasList.find( + (v) => v.name == node.extendsType?.name.identifier.text, + ) as SchemaData | null; + + if (schema.parent?.members) { + for (let i = schema.parent.members.length - 1; i >= 0; i--) { + const replace = schema.members.find( + (v) => v.name == schema.parent?.members[i]?.name, + ); + if (!replace) { + members.unshift(schema.parent?.members[i]!.node); + } + } + } + } + + if (!members.length) { + let SERIALIZE_RAW_EMPTY = '__SERIALIZE(): string {\n return "{}";\n}'; + //let SERIALIZE_PRETTY_EMPTY = "__SERIALIZE_PRETTY(): string {\n return \"{}\";\n}"; + + let INITIALIZE_EMPTY = "__INITIALIZE(): this {\n return this;\n}"; + + let DESERIALIZE_EMPTY = + "__DESERIALIZE(data: string, key_start: i32, key_end: i32, value_start: i32, value_end: i32): boolean {\n return false;\n}"; + + if (process.env["JSON_DEBUG"]) { + console.log(SERIALIZE_RAW_EMPTY); + //console.log(SERIALIZE_PRETTY_EMPTY); + console.log(INITIALIZE_EMPTY); + console.log(DESERIALIZE_EMPTY); + } + + const SERIALIZE_RAW_METHOD_EMPTY = SimpleParser.parseClassMember( + SERIALIZE_RAW_EMPTY, + node, + ); + //const SERIALIZE_PRETTY_METHOD = SimpleParser.parseClassMember(SERIALIZE_PRETTY, node); + const INITIALIZE_METHOD_EMPTY = SimpleParser.parseClassMember( + INITIALIZE_EMPTY, + node, + ); + const DESERIALIZE_METHOD_EMPTY = SimpleParser.parseClassMember( + DESERIALIZE_EMPTY, + node, + ); + + if (!node.members.find((v) => v.name.text == "__SERIALIZE")) + node.members.push(SERIALIZE_RAW_METHOD_EMPTY); + if (!node.members.find((v) => v.name.text == "__INITIALIZE")) + node.members.push(INITIALIZE_METHOD_EMPTY); + if (!node.members.find((v) => v.name.text == "__DESERIALIZE")) + node.members.push(DESERIALIZE_METHOD_EMPTY); + + this.schemasList.push(schema); + } + + for (const member of members) { + const name = member.name; + if (!(member instanceof FieldDeclaration)) continue; + if (!member.type) { + throw new Error( + "Fields must be strongly typed! Found " + + toString(member) + + " at " + + node.range.source.normalizedPath, + ); + } + const type = toString(member.type!); + if (type.startsWith("(") && type.includes("=>")) continue; + const value = member.initializer ? toString(member.initializer!) : null; + + if (member.flags == CommonFlags.Static) continue; + if (member.flags === CommonFlags.Private) continue; + if (member.flags === CommonFlags.Protected) continue; + + const mem = new Property(); + mem.name = name.text; + mem.type = type; + mem.value = value; + mem.node = member; + + if (type.includes("JSON.Raw")) { + mem.flags.set(PropertyFlags.JSON_Raw, []); + } + + if (member.type.isNullable) { + mem.flags.set(PropertyFlags.Null, []); + } + + if (member.decorators) { + for (const decorator of member.decorators) { + const decoratorName = (decorator.name as IdentifierExpression).text; + + const args = getArgs(decorator.args); + + switch (decoratorName) { + case "alias": { + if (!args.length) + throw new Error( + "Expected 1 argument but got zero at @alias in " + + node.range.source.normalizedPath, + ); + mem.alias = args[0]!; + mem.flags.set(PropertyFlags.Alias, args); + break; + } + case "omit": { + mem.flags.set(PropertyFlags.Omit, args); + break; + } + case "omitif": { + if (!decorator.args?.length) + throw new Error( + "Expected 1 argument but got zero at @omitif in " + + node.range.source.normalizedPath, + ); + mem.flags.set(PropertyFlags.OmitIf, args); + break; + } + case "omitnull": { + mem.flags.set(PropertyFlags.OmitNull, args); + break; + } + } + } + } + + mem.generate(false); + + if (this.schemasList.find((v) => v.name == type)) { + mem.initialize = + "this." + + name.text + + " = changetype>(__new(offsetof>(), idof>()));\n changetype>(this." + + name.text + + ").__INITIALIZE()"; + } else if (mem.value) { + mem.initialize = "this." + name.text + " = " + mem.value; + } else if (type === "Map") { + mem.initialize = "this." + name.text + " = new " + mem.type + "()"; + } else if (type === "string") { + mem.initialize = "this." + name.text + ' = ""'; + } else if (type === "Array") { + mem.initialize = + "this." + name.text + " = instantiate<" + mem.type + ">()"; + } else if (type === "bool" || type === "boolean") { + mem.initialize = "this." + name.text + " = false"; + } else if (type === "JSON.Raw") { + mem.initialize = "this." + name.text + ' = ""'; + } else if ( + type === "u8" || + type === "u16" || + type === "u32" || + type === "u64" || + type === "i8" || + type === "i16" || + type === "i32" || + type === "i64" + ) { + mem.initialize = "this." + name.text + " = 0"; + } else if (type === "f32" || type === "f64") { + mem.initialize = "this." + name.text + " = 0.0"; + } + + schema.members.push(mem); + } + + let SERIALIZE_RAW = "__SERIALIZE(): string {\n let out = `{"; + let SERIALIZE_PRETTY = "__SERIALIZE_PRETTY(): string {\n let out = `{"; + + let INITIALIZE = "__INITIALIZE(): this {\n"; + + let DESERIALIZE = + "__DESERIALIZE(data: string, key_start: i32, key_end: i32, value_start: i32, value_end: i32): boolean {\n const len = key_end - key_start;\n"; + let indent = " "; + + if (!schema.members.length) return; + + found = false; + + if ( + schema.members[0]?.flags.has(PropertyFlags.OmitNull) || + schema.members[0]?.flags.has(PropertyFlags.OmitIf) + ) { + SERIALIZE_RAW += schema.members[0]?.serialize; + SERIALIZE_PRETTY += "\\n" + schema.members[0]?.serialize; + } else { + SERIALIZE_RAW += schema.members[0]?.serialize + ","; + SERIALIZE_PRETTY += "\\n" + schema.members[0]?.serialize + ",\\n"; + found = true; + } + + if (schema.members[0]?.initialize) + INITIALIZE += " " + schema.members[0]?.initialize + ";\n"; + + for (let i = 1; i < schema.members.length; i++) { + const member = schema.members[i]!; + if (member.initialize) INITIALIZE += " " + member.initialize + ";\n"; + if ( + member.flags.has(PropertyFlags.OmitNull) || + member.flags.has(PropertyFlags.OmitIf) + ) { + SERIALIZE_RAW += member.serialize; + SERIALIZE_PRETTY += member.serialize; + } else { + SERIALIZE_RAW += member.serialize + ","; + SERIALIZE_PRETTY += indent + member.serialize + ",\\n"; + found = true; + } + } + + if (found) { + SERIALIZE_RAW += + "`;\n store(changetype(out) + ((out.length - 1) << 1), 125);\n return out;\n}"; + SERIALIZE_PRETTY += + "`;\n store(changetype(out) + ((out.length - 2) << 1), 8192010);\n return out;\n}"; + } else { + SERIALIZE_RAW += "}`;\n return out;\n}"; + SERIALIZE_PRETTY += "}`;\n return out;\n}"; + } + + INITIALIZE += " return this;\n}"; + + const sortedMembers: Property[][] = []; + const _sorted = schema.members.sort( + (a, b) => (a.alias?.length! || a.name.length) - (b.alias?.length! || b.name.length), + ); + let len = -1; + let offset = -1; + for (let i = 0; i < _sorted.length; i++) { + const member = _sorted[i]!; + const _name = member.alias || member.name; + if (_name.length === len) { + sortedMembers[offset]?.push(member); + } else { + sortedMembers.push([member]); + len = _name.length; + offset++; + } + } + + let first = true; + for (const memberSet of sortedMembers) { + const firstMember = memberSet[0]!; + const _name = encodeKey(firstMember.alias || firstMember.name); + if (_name.length === 1) { + if (first) { + DESERIALIZE += + " if (1 === len) {\n switch (load(changetype(data) + (key_start << 1))) {\n"; + first = false; + } else { + DESERIALIZE += + "else if (1 === len) {\n switch (load(changetype(data) + (key_start << 1))) {\n"; + } + } else if (_name.length === 2) { + if (first) { + DESERIALIZE += + " if (2 === len) {\n switch (load(changetype(data) + (key_start << 1))) {\n"; + first = false; + } else { + DESERIALIZE += + "else if (2 === len) {\n switch (load(changetype(data) + (key_start << 1))) {\n"; + } + } else if (_name.length === 4) { + if (first) { + DESERIALIZE += + " if (4 === len) {\n const code = load(changetype(data) + (key_start << 1));\n"; + first = false; + } else { + DESERIALIZE += + "else if (4 === len) {\n const code = load(changetype(data) + (key_start << 1));\n"; + } + } else { + if (first) { + DESERIALIZE += " if (" + _name.length + " === len) {\n"; + first = false; + } else { + DESERIALIZE += "else if (" + _name.length + " === len) {\n"; + } + } + let f = true; + for (let i = 0; i < memberSet.length; i++) { + const member = memberSet[i]!; + if (!member.deserialize) continue; + const _name = encodeKey(member.alias || member.name); + if (_name.length === 1) { + DESERIALIZE += ` case ${_name.charCodeAt(0)}: { /* ${_name} */\n ${member.deserialize}\n return true;\n }\n`; + } else if (_name.length === 2) { + DESERIALIZE += ` case ${charCodeAt32(_name, 0)}: { /* ${_name} */\n ${member.deserialize}\n return true;\n }\n`; + } else if (_name.length === 4) { + if (f) { + f = false; + DESERIALIZE += ` if (${charCodeAt64(_name, 0)} === code) { /* ${_name} */\n ${member.deserialize}\n return true;\n }\n`; + } else { + DESERIALIZE = + DESERIALIZE.slice(0, DESERIALIZE.length - 1) + + `else if (${charCodeAt64(_name, 0)} === code) {\n ${member.deserialize}\n return true;\n }\n`; + } + } else { + if (f) { + f = false; + DESERIALIZE += ` if (0 === memory.compare(changetype("${escapeQuote(escapeSlash(_name))}"), changetype(data) + (key_start << 1), ${_name.length << 1})) { /* ${_name} */\n ${member.deserialize}\n return true;\n }\n`; + } else { + DESERIALIZE = + DESERIALIZE.slice(0, DESERIALIZE.length - 1) + + ` else if (0 === memory.compare(changetype("${escapeQuote(escapeSlash(_name))}"), changetype(data) + (key_start << 1), ${_name.length << 1})) { /* ${_name} */\n ${member.deserialize}\n return true;\n }\n`; + } + } + } + if (_name.length < 3) { + DESERIALIZE += ` default: {\n return false;\n }\n }\n`; + } else if (_name.length == 4) { + DESERIALIZE = + DESERIALIZE.slice(0, DESERIALIZE.length - 1) + + ` else {\n return false;\n }\n`; + } else { + DESERIALIZE = + DESERIALIZE.slice(0, DESERIALIZE.length - 1) + + ` else {\n return false;\n }\n`; + } + DESERIALIZE += " } "; + } + + DESERIALIZE += "\n return false;\n}"; + + //console.log(sortedMembers); + + if (process.env["JSON_DEBUG"]) { + console.log(SERIALIZE_RAW); + //console.log(SERIALIZE_PRETTY); + console.log(INITIALIZE); + console.log(DESERIALIZE); + } + + const SERIALIZE_RAW_METHOD = SimpleParser.parseClassMember( + SERIALIZE_RAW, + node, + ); + + const DESERIALIZE_SAFE = DESERIALIZE.replaceAll("__DESERIALIZE", "__DESERIALIZE_SAFE") + //const SERIALIZE_PRETTY_METHOD = SimpleParser.parseClassMember(SERIALIZE_PRETTY, node); + const INITIALIZE_METHOD = SimpleParser.parseClassMember(INITIALIZE, node); + const DESERIALIZE_METHOD = SimpleParser.parseClassMember(DESERIALIZE, node); + const DESERIALIZE_SAFE_METHOD = SimpleParser.parseClassMember(DESERIALIZE_SAFE, node); + + if (!node.members.find((v) => v.name.text == "__SERIALIZE")) + node.members.push(SERIALIZE_RAW_METHOD); + if (!node.members.find((v) => v.name.text == "__INITIALIZE")) + node.members.push(INITIALIZE_METHOD); + if (!node.members.find((v) => v.name.text == "__DESERIALIZE")) + node.members.push(DESERIALIZE_METHOD); + if (!node.members.find((v) => v.name.text == "__DESERIALIZE_SAFE")) + node.members.push(DESERIALIZE_SAFE_METHOD); + + this.schemasList.push(schema); + } + visitSource(node: Source): void { + super.visitSource(node); + + // Only add the import statement to sources that have JSON decorated classes. + if (!this.sources.has(node)) { + return; + } + } + } + + export default class Transformer extends Transform { + // Trigger the transform after parse. + afterParse(parser: Parser): void { + // Create new transform + const transformer = new JSONTransform(); + + // Sort the sources so that user scripts are visited last + const sources = parser.sources + .filter((source) => !isStdlib(source)) + .sort((_a, _b) => { + const a = _a.internalPath; + const b = _b.internalPath; + if (a[0] === "~" && b[0] !== "~") { + return -1; + } else if (a[0] !== "~" && b[0] === "~") { + return 1; + } else { + return 0; + } + }); + + // Loop over every source + for (const source of sources) { + // Ignore all lib and std. Visit everything else. + if (!isStdlib(source)) { + transformer.visit(source); + } + } + // Check that every parent and child class is hooked up correctly + const schemas = transformer.schemasList; + for (const schema of schemas) { + if (schema.parent) { + const parent = schemas.find((v) => v.name === schema.parent?.name); + if (!parent) + throw new Error( + `Class ${schema.name} extends its parent class ${schema.parent}, but ${schema.parent} does not include a @json or @serializable decorator! Add the decorator and rebuild.`, + ); + } + } + } + } + + enum PropertyFlags { + Null, + Omit, + OmitNull, + OmitIf, + Alias, + JSON_Raw, + } + + class Property { + public name: string = ""; + public alias: string | null = null; + public type: string = ""; + public value: string | null = null; + public flags: Map = new Map< + PropertyFlags, + string[] + >(); + + public serialize: string | null = null; + public deserialize: string | null = null; + public initialize: string | null = null; + + public node!: FieldDeclaration; + + private right_s: string = ""; + private right_d: string = ""; + + public generate(safe: boolean): void { + const name = this.name; + const escapedName = escapeString(JSON.stringify(this.alias || this.name)); + const type = this.type; + if (this.flags.has(PropertyFlags.Omit)) return; + + if (this.flags.has(PropertyFlags.JSON_Raw)) { + if (this.flags.has(PropertyFlags.Null)) { + this.right_s = "(this." + name + " || \"null\")"; + this.right_d = "value_start === value_end - 4 && 30399761348886638 === load(changetype(data) + (value_start << 1)) ? null : data.substring(value_start, value_end)"; + } else { + this.right_s = "this." + name; + this.right_d = "data.substring(value_start, value_end);"; + } + } else { + this.right_s = "__SERIALIZE<" + type + ">(this." + name + ")"; + this.right_d = + (safe ? "__DESERIALIZE_SAFE" : "__DESERIALIZE") + "<" + type + ">(data.substring(value_start, value_end))"; + } + + if (this.flags.has(PropertyFlags.OmitIf)) { + const condition = this.flags.get(PropertyFlags.OmitIf)![0]; + if (!condition) + throw new Error( + "Could not find condition when using decorator @omitif! Provide at least one condition", + ); + this.serialize = + "${" + + condition + + ' ? "" : \'' + + escapedName + + ":' + " + + this.right_s + + ' + ","}'; + this.deserialize = "this." + name + " = " + this.right_d + ";"; + } else if (this.flags.has(PropertyFlags.OmitNull)) { + this.serialize = + "${changetype(this." + + name + + ") == 0" + + ' ? "" : \'' + + escapedName + + ":' + " + + this.right_s + + ' + ","}'; + this.deserialize = "this." + name + " = " + this.right_d + ";"; + } else { + this.serialize = escapedName + ":${" + this.right_s + "}"; + this.deserialize = "this." + name + " = " + this.right_d + ";"; + } + } + } + + class SchemaData { + public name: string = ""; + public members: Property[] = []; + public parent: SchemaData | null = null; + public node!: ClassDeclaration; + } + + function charCodeAt32(data: string, offset: number): number { + return (data.charCodeAt(offset + 1) << 16) | data.charCodeAt(offset); + } + + function charCodeAt64(data: string, offset: number): bigint { + if (offset + 3 >= data.length) { + throw new Error( + "The string must have at least 4 characters from the specified offset.", + ); + } + + const firstCharCode = BigInt(data.charCodeAt(offset)); + const secondCharCode = BigInt(data.charCodeAt(offset + 1)); + const thirdCharCode = BigInt(data.charCodeAt(offset + 2)); + const fourthCharCode = BigInt(data.charCodeAt(offset + 3)); + + const u64Value = + (fourthCharCode << 48n) | + (thirdCharCode << 32n) | + (secondCharCode << 16n) | + firstCharCode; + + return u64Value; + } + + function encodeKey(key: string): string { + const data = JSON.stringify(key); + return data.slice(1, data.length - 1); + } + + function escapeString(data: string): string { + return data.replace(/\\/g, "\\\\").replace(/\`/g, "\\`"); + } + + function escapeSlash(data: string): string { + return data.replace(/\\/g, "\\\\").replace(/\`/g, "\\`"); + } + + function escapeQuote(data: string): string { + return data.replace(/\"/g, '\\"'); + } + + function getArgs(args: Expression[] | null): string[] { + if (!args) return []; + let out: string[] = []; + for (const arg of args) { + if (arg instanceof StringLiteralExpression) { + out.push(arg.value); + } else if (arg instanceof IntegerLiteralExpression) { + out.push(i64_to_string(arg.value)); + } else if (arg instanceof FloatLiteralExpression) { + out.push(arg.value.toString()); + } else if (arg instanceof NullExpression) { + out.push(arg.text); + } else if (arg instanceof TrueExpression) { + out.push(arg.text); + } else if (arg instanceof FalseExpression) { + out.push(arg.text); + } else if (arg instanceof IdentifierExpression) { + out.push(arg.text); + } + } + return out; + } \ No newline at end of file diff --git a/transform/src/index.ts b/transform/src/index.ts index a22bca9..f266739 100644 --- a/transform/src/index.ts +++ b/transform/src/index.ts @@ -6,6 +6,7 @@ import * as path from "path"; import { fileURLToPath } from "url"; import { Property, PropertyFlags, Schema } from "./types.js"; import { getClasses, getImportedClass } from "./linker.js"; +import { deserialize } from "v8"; let indent = " "; @@ -142,7 +143,7 @@ class JSONTransform extends Visitor { let SERIALIZE = "@inline __SERIALIZE(ptr: usize = changetype(this)): string {\n"; let SERIALIZE_BS = "__SERIALIZE_BS(ptr: usize, staticSize: bool): void {\n"; let INITIALIZE = "@inline __INITIALIZE(): this {\n"; - let DESERIALIZE = "__DESERIALIZE(data: string, key_start: i32, key_end: i32, value_start: i32, value_end: i32): boolean {\n const len = key_end - key_start;\n"; + let DESERIALIZE = "__DESERIALIZE(keyStart: usize, keyEnd: usize, valStart: usize, valEnd: usize): void {\n"; let ALLOCATE = "@inline __ALLOCATE(): void {\n"; indent = " "; @@ -171,13 +172,13 @@ class JSONTransform extends Visitor { const keyPart = (isFirst ? "{" : ",") + aliasName + ":"; this.schema.byteSize += keyPart.length << 1; SERIALIZE_BS += this.getStores(keyPart).map(v => indent + v + "\n").join(""); - SERIALIZE_BS += indent + `JSON.serialize_simple<${member.type}>(load<${member.type}>(ptr, offsetof("${realName}")), ${isPrimitive(member.type)});\n`; + SERIALIZE_BS += indent + `JSON.__serialize<${member.type}>(load<${member.type}>(ptr, offsetof("${realName}")), ${isPrimitive(member.type)});\n`; if (isFirst) isFirst = false; } else if (isRegular && !isPure) { const keyPart = (isFirst ? "" : ",") + aliasName + ":"; this.schema.byteSize += keyPart.length << 1; SERIALIZE_BS += this.getStores(keyPart).map(v => indent + v + "\n").join(""); - SERIALIZE_BS += indent + `JSON.serialize_simple<${member.type}>(load<${member.type}>(ptr, offsetof("${realName}")), staticSize);\n`; + SERIALIZE_BS += indent + `JSON.__serialize<${member.type}>(load<${member.type}>(ptr, offsetof("${realName}")), staticSize);\n`; if (isFirst) isFirst = false; } else { if (member.flags.has(PropertyFlags.OmitNull)) { @@ -186,7 +187,7 @@ class JSONTransform extends Visitor { const keyPart = aliasName + ":"; this.schema.byteSize += keyPart.length << 1; SERIALIZE_BS += this.getStores(keyPart).map(v => indent + v + "\n").join(""); - SERIALIZE_BS += indent + `JSON.serialize_simple<${member.type}>(load<${member.type}>(ptr, offsetof("${realName}")), staticSize);\n`; + SERIALIZE_BS += indent + `JSON.__serialize<${member.type}>(load<${member.type}>(ptr, offsetof("${realName}")), staticSize);\n`; if (!isLast) { this.schema.byteSize += 2; @@ -201,7 +202,7 @@ class JSONTransform extends Visitor { SERIALIZE_BS += indent + `if (${toString}) !== 0) {\n`; indentInc(); SERIALIZE_BS += this.getStores(aliasName + ":").map(v => indent + v + "\n").join(""); - SERIALIZE_BS += indent + `JSON.serialize_simple<${member.type}>(load<${member.type}>(ptr, offsetof("${realName}")), staticSize);\n`; + SERIALIZE_BS += indent + `JSON.__serialize<${member.type}>(load<${member.type}>(ptr, offsetof("${realName}")), staticSize);\n`; if (!isLast) { this.schema.byteSize += 2; @@ -215,6 +216,121 @@ class JSONTransform extends Visitor { } } + const sortedMembers: Property[][] = []; + + let len = -1; + this.schema.members + .slice() + .sort((a, b) => (a.alias?.length || a.name.length) - (b.alias?.length || b.name.length)) + .forEach((member) => { + const _nameLength = member.alias?.length || member.name.length; + if (_nameLength === len) { + sortedMembers[sortedMembers.length - 1].push(member); + } else { + sortedMembers.push([member]); + len = _nameLength; + } + }); + + const groups = sortedMembers.length; + if (groups != 1) { + DESERIALIZE += " switch (keyEnd - keyStart) {\n"; + indent = " "; + } else { + indent = " "; + } + for (const memberGroup of sortedMembers) { + const firstMemberLen = (memberGroup[0].alias || memberGroup[0].name).length << 1; + if (firstMemberLen == 2) { + if (groups != 1) { + DESERIALIZE += indent + "case 2: {\n"; + indentInc(); + } + if (memberGroup.length == 1) { + const member = memberGroup[0]; + const memberName = member.alias || member.name; + DESERIALIZE += indent + `if (load(keyStart) == ${memberName.charCodeAt(0)}) this.${member.name} = JSON.__deserialize<${member.type}>(valStart, valEnd);\n`; + if (groups != 1) DESERIALIZE += indent + "break;\n"; + break; + } + DESERIALIZE += indent + "switch (load(keyStart)) {\n"; + for (const member of memberGroup) { + const memberName = member.alias || member.name; + DESERIALIZE += indent + ` case ${memberName.charCodeAt(0)}: { // ${memberName}\n`; + DESERIALIZE += indent + ` this.${member.name} = JSON.__deserialize<${member.type}>(valStart, valEnd);\n`; + DESERIALIZE += indent + " break;\n"; + DESERIALIZE += indent + " }\n"; + } + DESERIALIZE += indent + "}\n" + if (groups != 1) { + indentDec(); + DESERIALIZE += indent + "}\n" + } + } else if (firstMemberLen == 4) { + if (groups != 1) { + DESERIALIZE += indent + "case 4: {\n"; + indentInc(); + } + DESERIALIZE += indent + "switch (load(keyStart)) {\n"; + for (const member of memberGroup) { + const memberName = member.alias || member.name; + DESERIALIZE += indent + ` case ${memberName.charCodeAt(0)}: { // ${memberName}\n`; + DESERIALIZE += indent + ` this.${member.name} = JSON.__deserialize<${member.type}>(valStart, valEnd);\n`; + DESERIALIZE += indent + " break;\n"; + DESERIALIZE += indent + " }\n"; + } + DESERIALIZE += indent + "}\n" + if (groups != 1) { + indentDec(); + DESERIALIZE += indent + "}\n" + } + } else if (firstMemberLen == 6) { + if (groups != 1) { + DESERIALIZE += indent + "case 6: {\n"; + indentInc(); + } + DESERIALIZE += indent + "switch ((load(keyStart, 2) << 3) | load(keyStart)) {\n"; + for (const member of memberGroup) { + const memberName = member.alias || member.name; + DESERIALIZE += indent + ` case ${}: { // ${memberName}\n`; + DESERIALIZE += indent + ` this.${member.name} = JSON.__deserialize<${member.type}>(valStart, valEnd);\n`; + DESERIALIZE += indent + " break;\n"; + DESERIALIZE += indent + " }\n"; + } + DESERIALIZE += indent + "}\n" + if (groups != 1) { + indentDec(); + DESERIALIZE += indent + "}\n" + } + } else if (memberGroup.length > 1) { + if (groups != 1) { + DESERIALIZE += indent + "case " + firstMemberLen + ": {\n"; + indentInc(); + } + DESERIALIZE += indent + "switch (load(keyStart)) {\n"; + for (const member of memberGroup) { + const memberName = member.alias || member.name; + DESERIALIZE += indent + ` case ${memberName.charCodeAt(0)}: { // ${memberName}\n`; + DESERIALIZE += indent + ` this.${member.name} = JSON.__deserialize<${member.type}>(valStart, valEnd);\n`; + DESERIALIZE += indent + " break;\n"; + DESERIALIZE += indent + " }\n"; + } + DESERIALIZE += indent + "}\n" + if (groups != 1) { + indentDec(); + DESERIALIZE += indent + "}\n" + } + } + } + if (groups != 1) { + DESERIALIZE += " } \n"; + DESERIALIZE += "} "; + } else { + DESERIALIZE += "} "; + } + + indent = " "; + this.schema.byteSize += 2; SERIALIZE_BS += indent + "store(bs.offset, 125, 0); // }\n"; SERIALIZE_BS += indent + "bs.offset += 2;\n"; @@ -234,7 +350,7 @@ class JSONTransform extends Visitor { console.log(SERIALIZE); console.log(SERIALIZE_BS); // console.log(INITIALIZE); - // console.log(DESERIALIZE); + console.log(DESERIALIZE); console.log(ALLOCATE); } @@ -255,7 +371,7 @@ class JSONTransform extends Visitor { let SERIALIZE_RAW_EMPTY = '@inline __SERIALIZE(ptr: usize = changetype(this)): string {\n return "{}";\n}'; let SERIALIZE_BS_EMPTY = "@inline __SERIALIZE_BS(ptr: usize, staticSize: bool): void {\n store(bs.offset, 8192123);\n bs.offset += 4;\n}"; let INITIALIZE_EMPTY = "@inline __INITIALIZE(): this {\n return this;\n}"; - let DESERIALIZE_EMPTY = "@inline __DESERIALIZE(data: string, key_start: i32, key_end: i32, value_start: i32, value_end: i32): boolean {\n return false;\n}"; + let DESERIALIZE_EMPTY = "@inline __DESERIALIZE(keyStart: usize, keyEnd: usize, valStart: usize, valEnd: usize): void {\n return false;\n}"; let ALLOCATE_EMPTY = "@inline __ALLOCATE(): void {\n bs.ensureSize(4);\n}"; if (process.env["JSON_DEBUG"]) {