@wllzhang/afsim-compiler 0.5.2 → 0.5.3
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/package.json
CHANGED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compiles JSON string to AFSIM DSL. Returns "ERROR: ..." on failure.
|
|
3
|
+
* @param {string} input
|
|
4
|
+
* @returns {string}
|
|
5
|
+
*/
|
|
6
|
+
export function compile_json(input) {
|
|
7
|
+
let deferred2_0;
|
|
8
|
+
let deferred2_1;
|
|
9
|
+
try {
|
|
10
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
11
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
12
|
+
const len0 = WASM_VECTOR_LEN;
|
|
13
|
+
wasm.compile_json(retptr, ptr0, len0);
|
|
14
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
15
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
16
|
+
deferred2_0 = r0;
|
|
17
|
+
deferred2_1 = r1;
|
|
18
|
+
return getStringFromWasm0(r0, r1);
|
|
19
|
+
} finally {
|
|
20
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
21
|
+
wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
let cachedDataViewMemory0 = null;
|
|
25
|
+
function getDataViewMemory0() {
|
|
26
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
27
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
28
|
+
}
|
|
29
|
+
return cachedDataViewMemory0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function getStringFromWasm0(ptr, len) {
|
|
33
|
+
ptr = ptr >>> 0;
|
|
34
|
+
return decodeText(ptr, len);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let cachedUint8ArrayMemory0 = null;
|
|
38
|
+
function getUint8ArrayMemory0() {
|
|
39
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
40
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
41
|
+
}
|
|
42
|
+
return cachedUint8ArrayMemory0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
46
|
+
if (realloc === undefined) {
|
|
47
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
48
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
49
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
50
|
+
WASM_VECTOR_LEN = buf.length;
|
|
51
|
+
return ptr;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
let len = arg.length;
|
|
55
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
56
|
+
|
|
57
|
+
const mem = getUint8ArrayMemory0();
|
|
58
|
+
|
|
59
|
+
let offset = 0;
|
|
60
|
+
|
|
61
|
+
for (; offset < len; offset++) {
|
|
62
|
+
const code = arg.charCodeAt(offset);
|
|
63
|
+
if (code > 0x7F) break;
|
|
64
|
+
mem[ptr + offset] = code;
|
|
65
|
+
}
|
|
66
|
+
if (offset !== len) {
|
|
67
|
+
if (offset !== 0) {
|
|
68
|
+
arg = arg.slice(offset);
|
|
69
|
+
}
|
|
70
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
71
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
72
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
73
|
+
|
|
74
|
+
offset += ret.written;
|
|
75
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
WASM_VECTOR_LEN = offset;
|
|
79
|
+
return ptr;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
83
|
+
cachedTextDecoder.decode();
|
|
84
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
85
|
+
let numBytesDecoded = 0;
|
|
86
|
+
function decodeText(ptr, len) {
|
|
87
|
+
numBytesDecoded += len;
|
|
88
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
89
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
90
|
+
cachedTextDecoder.decode();
|
|
91
|
+
numBytesDecoded = len;
|
|
92
|
+
}
|
|
93
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const cachedTextEncoder = new TextEncoder();
|
|
97
|
+
|
|
98
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
99
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
100
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
101
|
+
view.set(buf);
|
|
102
|
+
return {
|
|
103
|
+
read: arg.length,
|
|
104
|
+
written: buf.length
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
let WASM_VECTOR_LEN = 0;
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
let wasm;
|
|
113
|
+
export function __wbg_set_wasm(val) {
|
|
114
|
+
wasm = val;
|
|
115
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const compile_json: (a: number, b: number, c: number) => void;
|
|
5
|
+
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
6
|
+
export const __wbindgen_export: (a: number, b: number) => number;
|
|
7
|
+
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
8
|
+
export const __wbindgen_export3: (a: number, b: number, c: number) => void;
|
package/pkg/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "afsim-script-generator",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"description": "JSON to AFSIM DSL compiler",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"files": [
|
|
7
|
+
"afsim_compiler_bg.wasm",
|
|
8
|
+
"afsim_compiler.js",
|
|
9
|
+
"afsim_compiler_bg.js",
|
|
10
|
+
"afsim_compiler.d.ts"
|
|
11
|
+
],
|
|
12
|
+
"main": "afsim_compiler.js",
|
|
13
|
+
"types": "afsim_compiler.d.ts",
|
|
14
|
+
"sideEffects": [
|
|
15
|
+
"./afsim_compiler.js",
|
|
16
|
+
"./snippets/*"
|
|
17
|
+
]
|
|
18
|
+
}
|