toilscript 0.1.60 → 0.1.62
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/dist/cli.js +31 -24
- package/dist/cli.js.map +2 -2
- package/dist/importmap.json +2 -2
- package/dist/web.js +3 -3
- package/package.json +1 -1
- package/std/assembly/json.ts +30 -23
package/dist/importmap.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"imports": {
|
|
3
|
-
"toilscript": "https://cdn.jsdelivr.net/npm/toilscript@0.1.
|
|
4
|
-
"toilscript/cli": "https://cdn.jsdelivr.net/npm/toilscript@0.1.
|
|
3
|
+
"toilscript": "https://cdn.jsdelivr.net/npm/toilscript@0.1.62/dist/toilscript.js",
|
|
4
|
+
"toilscript/cli": "https://cdn.jsdelivr.net/npm/toilscript@0.1.62/dist/cli.js",
|
|
5
5
|
"binaryen": "https://cdn.jsdelivr.net/npm/binaryen@130.0.0/index.js",
|
|
6
6
|
"long": "https://cdn.jsdelivr.net/npm/long@5.3.2/index.js"
|
|
7
7
|
}
|
package/dist/web.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var ASSEMBLYSCRIPT_VERSION = "0.1.
|
|
1
|
+
var ASSEMBLYSCRIPT_VERSION = "0.1.62";
|
|
2
2
|
var ASSEMBLYSCRIPT_IMPORTMAP = {
|
|
3
3
|
"imports": {
|
|
4
|
-
"toilscript": "https://cdn.jsdelivr.net/npm/toilscript@0.1.
|
|
5
|
-
"toilscript/cli": "https://cdn.jsdelivr.net/npm/toilscript@0.1.
|
|
4
|
+
"toilscript": "https://cdn.jsdelivr.net/npm/toilscript@0.1.62/dist/toilscript.js",
|
|
5
|
+
"toilscript/cli": "https://cdn.jsdelivr.net/npm/toilscript@0.1.62/dist/cli.js",
|
|
6
6
|
"binaryen": "https://cdn.jsdelivr.net/npm/binaryen@130.0.0/index.js",
|
|
7
7
|
"long": "https://cdn.jsdelivr.net/npm/long@5.3.2/index.js"
|
|
8
8
|
}
|
package/package.json
CHANGED
package/std/assembly/json.ts
CHANGED
|
@@ -300,20 +300,26 @@ export class JSON {
|
|
|
300
300
|
// ---- shared string escaping ----
|
|
301
301
|
|
|
302
302
|
private static quote(s: string): string {
|
|
303
|
-
|
|
303
|
+
const out: i32[] = [0x22];
|
|
304
|
+
const digits = "0123456789abcdef";
|
|
304
305
|
for (let i = 0, len = s.length; i < len; i++) {
|
|
305
306
|
const c = s.charCodeAt(i);
|
|
306
|
-
if (c == 0x22) out
|
|
307
|
-
else if (c
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
307
|
+
if (c == 0x22 || c == 0x5c) { out.push(0x5c); out.push(c); }
|
|
308
|
+
else if (c < 0x20) {
|
|
309
|
+
out.push(0x5c);
|
|
310
|
+
if (c == 0x08) out.push(0x62);
|
|
311
|
+
else if (c == 0x0c) out.push(0x66);
|
|
312
|
+
else if (c == 0x0a) out.push(0x6e);
|
|
313
|
+
else if (c == 0x0d) out.push(0x72);
|
|
314
|
+
else if (c == 0x09) out.push(0x74);
|
|
315
|
+
else {
|
|
316
|
+
out.push(0x75);
|
|
317
|
+
for (let shift = 12; shift >= 0; shift -= 4) out.push(digits.charCodeAt((c >> shift) & 0xf));
|
|
318
|
+
}
|
|
319
|
+
} else out.push(c);
|
|
315
320
|
}
|
|
316
|
-
|
|
321
|
+
out.push(0x22);
|
|
322
|
+
return String.fromCharCodes(out);
|
|
317
323
|
}
|
|
318
324
|
|
|
319
325
|
private static hex4(c: i32): string {
|
|
@@ -394,7 +400,7 @@ class Parser {
|
|
|
394
400
|
/** Read a quoted string starting at the current `"`. Sets err on failure. */
|
|
395
401
|
private readString(): string {
|
|
396
402
|
this.pos++; // opening "
|
|
397
|
-
|
|
403
|
+
const out: i32[] = [];
|
|
398
404
|
while (true) {
|
|
399
405
|
if (this.atEnd()) {
|
|
400
406
|
this.fail("unterminated string");
|
|
@@ -408,14 +414,14 @@ class Parser {
|
|
|
408
414
|
return "";
|
|
409
415
|
}
|
|
410
416
|
const e = this.take();
|
|
411
|
-
if (e == 0x22) out
|
|
412
|
-
else if (e == 0x5c) out
|
|
413
|
-
else if (e == 0x2f) out
|
|
414
|
-
else if (e == 0x62) out
|
|
415
|
-
else if (e == 0x66) out
|
|
416
|
-
else if (e == 0x6e) out
|
|
417
|
-
else if (e == 0x72) out
|
|
418
|
-
else if (e == 0x74) out
|
|
417
|
+
if (e == 0x22) out.push(0x22);
|
|
418
|
+
else if (e == 0x5c) out.push(0x5c);
|
|
419
|
+
else if (e == 0x2f) out.push(0x2f);
|
|
420
|
+
else if (e == 0x62) out.push(0x08);
|
|
421
|
+
else if (e == 0x66) out.push(0x0c);
|
|
422
|
+
else if (e == 0x6e) out.push(0x0a);
|
|
423
|
+
else if (e == 0x72) out.push(0x0d);
|
|
424
|
+
else if (e == 0x74) out.push(0x09);
|
|
419
425
|
else if (e == 0x75) {
|
|
420
426
|
let code = 0;
|
|
421
427
|
for (let k = 0; k < 4; k++) {
|
|
@@ -426,16 +432,17 @@ class Parser {
|
|
|
426
432
|
}
|
|
427
433
|
code = (code << 4) | d;
|
|
428
434
|
}
|
|
429
|
-
out
|
|
435
|
+
out.push(code);
|
|
430
436
|
} else {
|
|
431
437
|
this.fail("invalid escape");
|
|
432
438
|
return "";
|
|
433
439
|
}
|
|
434
440
|
} else {
|
|
435
|
-
|
|
441
|
+
if (c < 0x20) { this.fail("unescaped control character"); return ""; }
|
|
442
|
+
out.push(c);
|
|
436
443
|
}
|
|
437
444
|
}
|
|
438
|
-
return out;
|
|
445
|
+
return String.fromCharCodes(out);
|
|
439
446
|
}
|
|
440
447
|
|
|
441
448
|
private parseNumber(): JSON {
|