porffor 0.2.0-fde989a → 0.14.0-0d97d1e6a
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/CONTRIBUTING.md +256 -0
- package/LICENSE +20 -20
- package/README.md +131 -86
- package/asur/README.md +2 -0
- package/asur/index.js +1262 -0
- package/byg/index.js +216 -0
- package/compiler/2c.js +2 -53
- package/compiler/{sections.js → assemble.js} +95 -21
- package/compiler/builtins/annexb_string.js +72 -0
- package/compiler/builtins/annexb_string.ts +18 -0
- package/compiler/builtins/array.ts +145 -0
- package/compiler/builtins/base64.ts +76 -0
- package/compiler/builtins/boolean.ts +18 -0
- package/compiler/builtins/crypto.ts +120 -0
- package/compiler/builtins/date.ts +2067 -0
- package/compiler/builtins/escape.ts +141 -0
- package/compiler/builtins/function.ts +5 -0
- package/compiler/builtins/int.ts +145 -0
- package/compiler/builtins/number.ts +529 -0
- package/compiler/builtins/object.ts +4 -0
- package/compiler/builtins/porffor.d.ts +60 -0
- package/compiler/builtins/set.ts +187 -0
- package/compiler/builtins/string.ts +1080 -0
- package/compiler/builtins/symbol.ts +61 -0
- package/compiler/builtins.js +440 -285
- package/compiler/{codeGen.js → codegen.js} +1116 -489
- package/compiler/decompile.js +3 -4
- package/compiler/embedding.js +22 -22
- package/compiler/encoding.js +94 -10
- package/compiler/expression.js +1 -1
- package/compiler/generated_builtins.js +1670 -0
- package/compiler/index.js +27 -43
- package/compiler/log.js +6 -3
- package/compiler/opt.js +55 -41
- package/compiler/parse.js +38 -30
- package/compiler/precompile.js +120 -0
- package/compiler/prefs.js +31 -0
- package/compiler/prototype.js +31 -46
- package/compiler/types.js +38 -0
- package/compiler/wasmSpec.js +33 -8
- package/compiler/wrap.js +107 -71
- package/package.json +9 -5
- package/porf +2 -0
- package/rhemyn/compile.js +46 -27
- package/rhemyn/parse.js +322 -320
- package/rhemyn/test/parse.js +58 -58
- package/runner/compare.js +33 -34
- package/runner/debug.js +117 -0
- package/runner/index.js +78 -11
- package/runner/profiler.js +75 -0
- package/runner/repl.js +40 -13
- package/runner/sizes.js +37 -37
- package/runner/version.js +10 -8
- package/compiler/builtins/base64.js +0 -92
- package/filesize.cmd +0 -2
- package/runner/info.js +0 -89
- package/runner/profile.js +0 -46
- package/runner/results.json +0 -1
- package/runner/transform.js +0 -15
- package/tmp.c +0 -661
- package/util/enum.js +0 -20
@@ -0,0 +1,61 @@
|
|
1
|
+
export const __Porffor_symbol_descStore = (op: boolean, value: any): any => {
|
2
|
+
const ptr: bytestring = '';
|
3
|
+
|
4
|
+
if (op) { // write
|
5
|
+
const size: number = Porffor.wasm.i32.load(ptr, 0, 0);
|
6
|
+
Porffor.wasm.i32.store(ptr, size + 1, 0, 0)
|
7
|
+
|
8
|
+
// reuse set internals to store description
|
9
|
+
__Porffor_set_write(ptr, size, value);
|
10
|
+
return size;
|
11
|
+
} else { // read
|
12
|
+
return __Porffor_set_read(ptr, value);
|
13
|
+
}
|
14
|
+
};
|
15
|
+
|
16
|
+
export const Symbol = (description: any): Symbol => {
|
17
|
+
// 1-based so always truthy as numeric value
|
18
|
+
return __Porffor_symbol_descStore(true, description) + 1;
|
19
|
+
};
|
20
|
+
|
21
|
+
// todo: this should be a getter somehow not a method
|
22
|
+
export const __Symbol_prototype_description = (_this: Symbol) => {
|
23
|
+
const description: bytestring = __Porffor_symbol_descStore(false,
|
24
|
+
Porffor.wasm`local.get ${_this}` - 1);
|
25
|
+
return description;
|
26
|
+
};
|
27
|
+
|
28
|
+
export const __Symbol_prototype_toString = (_this: Symbol) => {
|
29
|
+
let out: bytestring = '';
|
30
|
+
|
31
|
+
// Symbol(
|
32
|
+
Porffor.wasm.i32.store8(out, 83, 0, 4);
|
33
|
+
Porffor.wasm.i32.store8(out, 121, 0, 5);
|
34
|
+
Porffor.wasm.i32.store8(out, 109, 0, 6);
|
35
|
+
Porffor.wasm.i32.store8(out, 98, 0, 7);
|
36
|
+
Porffor.wasm.i32.store8(out, 111, 0, 8);
|
37
|
+
Porffor.wasm.i32.store8(out, 108, 0, 9);
|
38
|
+
Porffor.wasm.i32.store8(out, 40, 0, 10);
|
39
|
+
|
40
|
+
const description: bytestring = __Porffor_symbol_descStore(false,
|
41
|
+
Porffor.wasm`local.get ${_this}` - 1);
|
42
|
+
|
43
|
+
const descLen: i32 = description.length;
|
44
|
+
let outPtr: i32 = Porffor.wasm`local.get ${out}` + 7;
|
45
|
+
let descPtr: i32 = Porffor.wasm`local.get ${description}`;
|
46
|
+
const descPtrEnd: i32 = descPtr + descLen;
|
47
|
+
while (descPtr < descPtrEnd) {
|
48
|
+
Porffor.wasm.i32.store8(outPtr++, Porffor.wasm.i32.load8_u(descPtr++, 0, 4), 0, 4);
|
49
|
+
}
|
50
|
+
|
51
|
+
// )
|
52
|
+
Porffor.wasm.i32.store8(Porffor.wasm`local.get ${out}` + descLen, 41, 0, 11);
|
53
|
+
|
54
|
+
out.length = 8 + descLen;
|
55
|
+
|
56
|
+
return out;
|
57
|
+
};
|
58
|
+
|
59
|
+
export const __Symbol_prototype_valueOf = (_this: Symbol) => {
|
60
|
+
return _this;
|
61
|
+
};
|