@biuxiu/codegen 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- package/lua/bin/linux/luac +0 -0
- package/lua/bin/win/luac.exe +0 -0
- package/package.json +4 -2
- package/pkg/lua_codegen.d.ts +8 -0
- package/pkg/lua_codegen.js +176 -0
- package/pkg/lua_codegen_bg.wasm +0 -0
Binary file
|
Binary file
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@biuxiu/codegen",
|
3
|
-
"version": "0.1.
|
3
|
+
"version": "0.1.4",
|
4
4
|
"description": "代码生成工具",
|
5
5
|
"main": "index.js",
|
6
6
|
"scripts": {
|
@@ -14,7 +14,9 @@
|
|
14
14
|
"files": [
|
15
15
|
"lua/bin",
|
16
16
|
"dist",
|
17
|
-
"pkg",
|
17
|
+
"pkg/lua_codegen_bg.wasm",
|
18
|
+
"pkg/lua_codegen.d.ts",
|
19
|
+
"pkg/lua_codegen.js",
|
18
20
|
"sources",
|
19
21
|
"README.md"
|
20
22
|
],
|
@@ -0,0 +1,176 @@
|
|
1
|
+
let imports = {};
|
2
|
+
imports['__wbindgen_placeholder__'] = module.exports;
|
3
|
+
let wasm;
|
4
|
+
const { printToNode } = require(`@/libs`);
|
5
|
+
const { renderNestCode } = require(`@/libs/nest-lib`);
|
6
|
+
const { genWebCode } = require(`@/libs/vue-lib`);
|
7
|
+
const { TextDecoder, TextEncoder } = require(`util`);
|
8
|
+
|
9
|
+
const heap = new Array(128).fill(undefined);
|
10
|
+
|
11
|
+
heap.push(undefined, null, true, false);
|
12
|
+
|
13
|
+
function getObject(idx) { return heap[idx]; }
|
14
|
+
|
15
|
+
let heap_next = heap.length;
|
16
|
+
|
17
|
+
function dropObject(idx) {
|
18
|
+
if (idx < 132) return;
|
19
|
+
heap[idx] = heap_next;
|
20
|
+
heap_next = idx;
|
21
|
+
}
|
22
|
+
|
23
|
+
function takeObject(idx) {
|
24
|
+
const ret = getObject(idx);
|
25
|
+
dropObject(idx);
|
26
|
+
return ret;
|
27
|
+
}
|
28
|
+
|
29
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
30
|
+
|
31
|
+
cachedTextDecoder.decode();
|
32
|
+
|
33
|
+
let cachedUint8Memory0 = null;
|
34
|
+
|
35
|
+
function getUint8Memory0() {
|
36
|
+
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
|
37
|
+
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
38
|
+
}
|
39
|
+
return cachedUint8Memory0;
|
40
|
+
}
|
41
|
+
|
42
|
+
function getStringFromWasm0(ptr, len) {
|
43
|
+
ptr = ptr >>> 0;
|
44
|
+
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
45
|
+
}
|
46
|
+
|
47
|
+
function addHeapObject(obj) {
|
48
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
49
|
+
const idx = heap_next;
|
50
|
+
heap_next = heap[idx];
|
51
|
+
|
52
|
+
heap[idx] = obj;
|
53
|
+
return idx;
|
54
|
+
}
|
55
|
+
|
56
|
+
let WASM_VECTOR_LEN = 0;
|
57
|
+
|
58
|
+
function passArray8ToWasm0(arg, malloc) {
|
59
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
60
|
+
getUint8Memory0().set(arg, ptr / 1);
|
61
|
+
WASM_VECTOR_LEN = arg.length;
|
62
|
+
return ptr;
|
63
|
+
}
|
64
|
+
|
65
|
+
let cachedTextEncoder = new TextEncoder('utf-8');
|
66
|
+
|
67
|
+
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
68
|
+
? function (arg, view) {
|
69
|
+
return cachedTextEncoder.encodeInto(arg, view);
|
70
|
+
}
|
71
|
+
: function (arg, view) {
|
72
|
+
const buf = cachedTextEncoder.encode(arg);
|
73
|
+
view.set(buf);
|
74
|
+
return {
|
75
|
+
read: arg.length,
|
76
|
+
written: buf.length
|
77
|
+
};
|
78
|
+
});
|
79
|
+
|
80
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
81
|
+
|
82
|
+
if (realloc === undefined) {
|
83
|
+
const buf = cachedTextEncoder.encode(arg);
|
84
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
85
|
+
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
|
86
|
+
WASM_VECTOR_LEN = buf.length;
|
87
|
+
return ptr;
|
88
|
+
}
|
89
|
+
|
90
|
+
let len = arg.length;
|
91
|
+
let ptr = malloc(len, 1) >>> 0;
|
92
|
+
|
93
|
+
const mem = getUint8Memory0();
|
94
|
+
|
95
|
+
let offset = 0;
|
96
|
+
|
97
|
+
for (; offset < len; offset++) {
|
98
|
+
const code = arg.charCodeAt(offset);
|
99
|
+
if (code > 0x7F) break;
|
100
|
+
mem[ptr + offset] = code;
|
101
|
+
}
|
102
|
+
|
103
|
+
if (offset !== len) {
|
104
|
+
if (offset !== 0) {
|
105
|
+
arg = arg.slice(offset);
|
106
|
+
}
|
107
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
108
|
+
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
|
109
|
+
const ret = encodeString(arg, view);
|
110
|
+
|
111
|
+
offset += ret.written;
|
112
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
113
|
+
}
|
114
|
+
|
115
|
+
WASM_VECTOR_LEN = offset;
|
116
|
+
return ptr;
|
117
|
+
}
|
118
|
+
/**
|
119
|
+
* 运行lua代码
|
120
|
+
* @param {Uint8Array} data
|
121
|
+
* @param {string} file_name
|
122
|
+
*/
|
123
|
+
module.exports.run = function(data, file_name) {
|
124
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
125
|
+
const len0 = WASM_VECTOR_LEN;
|
126
|
+
const ptr1 = passStringToWasm0(file_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
127
|
+
const len1 = WASM_VECTOR_LEN;
|
128
|
+
wasm.run(ptr0, len0, ptr1, len1);
|
129
|
+
};
|
130
|
+
|
131
|
+
function handleError(f, args) {
|
132
|
+
try {
|
133
|
+
return f.apply(this, args);
|
134
|
+
} catch (e) {
|
135
|
+
wasm.__wbindgen_exn_store(addHeapObject(e));
|
136
|
+
}
|
137
|
+
}
|
138
|
+
|
139
|
+
module.exports.__wbindgen_object_drop_ref = function(arg0) {
|
140
|
+
takeObject(arg0);
|
141
|
+
};
|
142
|
+
|
143
|
+
module.exports.__wbg_renderNestCode_ba91730cbcd316b3 = function(arg0, arg1, arg2, arg3) {
|
144
|
+
renderNestCode(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
|
145
|
+
};
|
146
|
+
|
147
|
+
module.exports.__wbg_genWebCode_2826bcda9a2b9845 = function(arg0, arg1, arg2) {
|
148
|
+
genWebCode(getStringFromWasm0(arg0, arg1), getObject(arg2));
|
149
|
+
};
|
150
|
+
|
151
|
+
module.exports.__wbg_printToNode_f8646f4da26c5023 = function(arg0) {
|
152
|
+
printToNode(getObject(arg0));
|
153
|
+
};
|
154
|
+
|
155
|
+
module.exports.__wbindgen_string_new = function(arg0, arg1) {
|
156
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
157
|
+
return addHeapObject(ret);
|
158
|
+
};
|
159
|
+
|
160
|
+
module.exports.__wbg_parse_66d1801634e099ac = function() { return handleError(function (arg0, arg1) {
|
161
|
+
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
162
|
+
return addHeapObject(ret);
|
163
|
+
}, arguments) };
|
164
|
+
|
165
|
+
module.exports.__wbindgen_throw = function(arg0, arg1) {
|
166
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
167
|
+
};
|
168
|
+
|
169
|
+
const path = require('path').join(__dirname, 'lua_codegen_bg.wasm');
|
170
|
+
const bytes = require('fs').readFileSync(path);
|
171
|
+
|
172
|
+
const wasmModule = new WebAssembly.Module(bytes);
|
173
|
+
const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
|
174
|
+
wasm = wasmInstance.exports;
|
175
|
+
module.exports.__wasm = wasm;
|
176
|
+
|
Binary file
|