porffor 0.14.0-320727338 → 0.14.0-3905158d3

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.
@@ -18,9 +18,9 @@ const compile = async (file, [ _funcs, _globals ]) => {
18
18
  first = source.slice(0, source.indexOf('\n'));
19
19
  }
20
20
 
21
- let args = ['--bytestring', '--todo-time=compile', '--truthy=no_nan_negative', '--no-treeshake-wasm-imports', '--no-rm-unused-types', '--scoped-page-names', '--funsafe-no-unlikely-proto-checks', '--fast-length', '--parse-types', '--opt-types'];
21
+ let args = ['--bytestring', '--todo-time=compile', '--no-treeshake-wasm-imports', '--no-rm-unused-types', '--scoped-page-names', '--funsafe-no-unlikely-proto-checks', '--fast-length', '--parse-types', '--opt-types'];
22
22
  if (first.startsWith('// @porf')) {
23
- args = first.slice('// @porf '.length).split(' ').concat(args);
23
+ args = args.concat(first.slice('// @porf '.length).split(' '));
24
24
  }
25
25
  process.argv = argv.concat(args);
26
26
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "porffor",
3
3
  "description": "a basic experimental wip aot optimizing js -> wasm engine/compiler/runtime in js",
4
- "version": "0.14.0-320727338",
4
+ "version": "0.14.0-3905158d3",
5
5
  "author": "CanadaHonk",
6
6
  "license": "MIT",
7
7
  "scripts": {
package/porffor_tmp.c ADDED
@@ -0,0 +1,152 @@
1
+ #include <stdint.h>
2
+ #include <string.h>
3
+ #include <stdio.h>
4
+
5
+ typedef uint8_t i8;
6
+ typedef uint16_t i16;
7
+ typedef int32_t i32;
8
+ typedef uint32_t u32;
9
+ typedef int64_t i64;
10
+ typedef uint64_t u64;
11
+ typedef float f32;
12
+ typedef double f64;
13
+
14
+ f64 NAN = 0e+0/0e+0;
15
+
16
+ struct ReturnValue {
17
+ f64 value;
18
+ i32 type;
19
+ };
20
+
21
+ char _memory[65536];
22
+
23
+ i32 i32_load(i32 align, i32 offset, i32 pointer) {
24
+ i32 out;
25
+ memcpy(&out, _memory + offset + pointer, sizeof(out));
26
+ return out;
27
+ }
28
+
29
+ i32 i32_load8_u(i32 align, i32 offset, i32 pointer) {
30
+ i8 out;
31
+ memcpy(&out, _memory + offset + pointer, sizeof(out));
32
+ return out;
33
+ }
34
+
35
+
36
+ int main() {
37
+ memcpy(_memory + 1, (unsigned char[]){12,0,0,0,104,101,108,108,111,32,119,111,114,108,100,33}, 16);
38
+
39
+ __Porffor_print(1e+0, 18);
40
+ printf("%c", (int)(1e+1));
41
+
42
+ return 0;
43
+ }
44
+
45
+ void inline __Porffor_print(f64 x, i32 y) {
46
+ i32 a = 0;
47
+ i32 b = 0;
48
+ i32 dtypeswitch_tmp = 0;
49
+
50
+ dtypeswitch_tmp = y;
51
+ // block
52
+ // if
53
+ if (dtypeswitch_tmp == 0) {
54
+ printf("%g\n", x);
55
+ goto j0;
56
+ }
57
+ // end
58
+ j1:;
59
+ // if
60
+ if (dtypeswitch_tmp == 1) {
61
+ // if
62
+ if (((u32)x) != 0) {
63
+ printf("%c", (int)(1.16e+2));
64
+ printf("%c", (int)(1.14e+2));
65
+ printf("%c", (int)(1.17e+2));
66
+ printf("%c", (int)(1.01e+2));
67
+ } else {
68
+ printf("%c", (int)(1.02e+2));
69
+ printf("%c", (int)(9.7e+1));
70
+ printf("%c", (int)(1.08e+2));
71
+ printf("%c", (int)(1.15e+2));
72
+ printf("%c", (int)(1.01e+2));
73
+ }
74
+ // end
75
+ j3:;
76
+ goto j0;
77
+ }
78
+ // end
79
+ j2:;
80
+ // if
81
+ if (dtypeswitch_tmp == 3) {
82
+ printf("%c", (int)(1.17e+2));
83
+ printf("%c", (int)(1.1e+2));
84
+ printf("%c", (int)(1e+2));
85
+ printf("%c", (int)(1.01e+2));
86
+ printf("%c", (int)(1.02e+2));
87
+ printf("%c", (int)(1.05e+2));
88
+ printf("%c", (int)(1.1e+2));
89
+ printf("%c", (int)(1.01e+2));
90
+ printf("%c", (int)(1e+2));
91
+ goto j0;
92
+ }
93
+ // end
94
+ j4:;
95
+ // if
96
+ if (dtypeswitch_tmp == 4) {
97
+ // if
98
+ if (((u32)x) != 0) {
99
+ printf("%c", (int)(1.23e+2));
100
+ printf("%c", (int)(1.25e+2));
101
+ } else {
102
+ printf("%c", (int)(1.1e+2));
103
+ printf("%c", (int)(1.17e+2));
104
+ printf("%c", (int)(1.08e+2));
105
+ printf("%c", (int)(1.08e+2));
106
+ }
107
+ // end
108
+ j6:;
109
+ goto j0;
110
+ }
111
+ // end
112
+ j5:;
113
+ // if
114
+ if (dtypeswitch_tmp == 5) {
115
+ printf("%c", (int)(1.02e+2));
116
+ printf("%c", (int)(1.17e+2));
117
+ printf("%c", (int)(1.1e+2));
118
+ printf("%c", (int)(9.9e+1));
119
+ printf("%c", (int)(1.16e+2));
120
+ printf("%c", (int)(1.05e+2));
121
+ printf("%c", (int)(1.11e+2));
122
+ printf("%c", (int)(1.1e+2));
123
+ printf("%c", (int)(3.2e+1));
124
+ printf("%c", (int)(4e+1));
125
+ printf("%c", (int)(4.1e+1));
126
+ printf("%c", (int)(3.2e+1));
127
+ printf("%c", (int)(1.23e+2));
128
+ printf("%c", (int)(1.25e+2));
129
+ goto j0;
130
+ }
131
+ // end
132
+ j7:;
133
+ // if
134
+ if (dtypeswitch_tmp == 18) {
135
+ a = (u32)x;
136
+ b = i32_load(1, 0, a) + a;
137
+ // loop
138
+ j9:;
139
+ printf("%c", (int)((f64)(i32_load8_u(0, 4, a))));
140
+ a = a + 1;
141
+ if (a != b) {
142
+ goto j9;
143
+ }
144
+ // end
145
+ goto j0;
146
+ }
147
+ // end
148
+ j8:;
149
+ printf("%g\n", x);
150
+ // end
151
+ j0:;
152
+ }