porffor 0.55.28 → 0.55.32

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/bun.lock ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "lockfileVersion": 1,
3
+ "workspaces": {
4
+ "": {
5
+ "name": "porffor",
6
+ "dependencies": {
7
+ "acorn": "^8.14.0",
8
+ "node-repl-polyfill": "github:CanadaHonk/node-repl-polyfill",
9
+ },
10
+ "optionalDependencies": {
11
+ "@babel/parser": "^7.24.4",
12
+ "hermes-parser": "^0.18.2",
13
+ "meriyah": "^4.3.9",
14
+ },
15
+ },
16
+ },
17
+ "packages": {
18
+ "@babel/helper-string-parser": ["@babel/helper-string-parser@7.25.9", "", {}, "sha512-4A/SCr/2KLd5jrtOMFzaKjVtAei3+2r/NChoBNoZ3EyP/+GlhoaEGoWOZUmFmoITP7zOJyHIMm+DYRd8o3PvHA=="],
19
+
20
+ "@babel/helper-validator-identifier": ["@babel/helper-validator-identifier@7.25.9", "", {}, "sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ=="],
21
+
22
+ "@babel/parser": ["@babel/parser@7.26.9", "", { "dependencies": { "@babel/types": "^7.26.9" }, "bin": "./bin/babel-parser.js" }, "sha512-81NWa1njQblgZbQHxWHpxxCzNsa3ZwvFqpUg7P+NNUU6f3UU2jBEg4OlF/J6rl8+PQGh1q6/zWScd001YwcA5A=="],
23
+
24
+ "@babel/types": ["@babel/types@7.26.9", "", { "dependencies": { "@babel/helper-string-parser": "^7.25.9", "@babel/helper-validator-identifier": "^7.25.9" } }, "sha512-Y3IR1cRnOxOCDvMmNiym7XpXQ93iGDDPHx+Zj+NM+rg0fBaShfQLkg+hKPaZCEvg5N/LeCo4+Rj/i3FuJsIQaw=="],
25
+
26
+ "acorn": ["acorn@8.14.0", "", { "bin": { "acorn": "bin/acorn" } }, "sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA=="],
27
+
28
+ "hermes-estree": ["hermes-estree@0.18.2", "", {}, "sha512-KoLsoWXJ5o81nit1wSyEZnWUGy9cBna9iYMZBR7skKh7okYAYKqQ9/OczwpMHn/cH0hKDyblulGsJ7FknlfVxQ=="],
29
+
30
+ "hermes-parser": ["hermes-parser@0.18.2", "", { "dependencies": { "hermes-estree": "0.18.2" } }, "sha512-1eQfvib+VPpgBZ2zYKQhpuOjw1tH+Emuib6QmjkJWJMhyjM8xnXMvA+76o9LhF0zOAJDZgPfQhg43cyXEyl5Ew=="],
31
+
32
+ "meriyah": ["meriyah@4.5.0", "", {}, "sha512-Rbiu0QPIxTXgOXwiIpRVJfZRQ2FWyfzYrOGBs9SN5RbaXg1CN5ELn/plodwWwluX93yzc4qO/bNIen1ThGFCxw=="],
33
+
34
+ "node-repl-polyfill": ["node-repl-polyfill@github:CanadaHonk/node-repl-polyfill#8d8a080", {}, "CanadaHonk-node-repl-polyfill-8d8a080"],
35
+ }
36
+ }
package/compiler/2c.js CHANGED
@@ -217,7 +217,7 @@ export default ({ funcs, globals, tags, data, exceptions, pages }) => {
217
217
 
218
218
  if (pages.size > 0) {
219
219
  includes.set('stdlib.h', true);
220
- prepend.set('_memory', `char* _memory; u32 _memoryPages = ${pages.size};\n`);
220
+ prepend.set('_memory', `char* _memory; u32 _memoryPages = ${Math.ceil((pages.size * pageSize) / PageSize)};\n`);
221
221
  prependMain.set('_initMemory', `_memory = malloc(_memoryPages * ${PageSize});\n`);
222
222
  if (Prefs['2cMemcpy']) includes.set('string.h', true);
223
223
  }
@@ -850,7 +850,7 @@ _time_out = _time.tv_nsec / 1000000. + _time.tv_sec * 1000.;`);
850
850
  const id = localTmpId++;
851
851
  line(`const u32 _oldPages${id} = _memoryPages`);
852
852
  line(`_memoryPages += ${vals.pop()}`);
853
- line(`_memory = realloc(_memory, _memoryPages * ${pageSize})`);
853
+ line(`_memory = realloc(_memory, _memoryPages * ${PageSize})`);
854
854
  vals.push(`_oldPages${id}`);
855
855
  break;
856
856
  }
@@ -860,7 +860,7 @@ _time_out = _time.tv_nsec / 1000000. + _time.tv_sec * 1000.;`);
860
860
  const name = invOpcodes[i[0]];
861
861
  const func = CMemFuncs[i[0]];
862
862
  if (!prepend.has(name)) {
863
- prepend.set(name, `inline ${func.returns || 'void'} ${name}(i32 align, i32 offset, ${func.args.map((x, i) => `${func.argTypes[i]} ${x}`).join(', ')}) {\n ${func.c.replaceAll('\n', '\n ')}\n}\n`);
863
+ prepend.set(name, `${func.returns || 'void'} ${name}(i32 align, i32 offset, ${func.args.map((x, i) => `${func.argTypes[i]} ${x}`).join(', ')}) {\n ${func.c.replaceAll('\n', '\n ')}\n}\n`);
864
864
  }
865
865
 
866
866
  const immediates = [ i[1], read_unsignedLEB128(i.slice(2)) ];
@@ -911,7 +911,6 @@ _time_out = _time.tv_nsec / 1000000. + _time.tv_sec * 1000.;`);
911
911
  }
912
912
 
913
913
  const shouldInline = false;
914
-
915
914
  return `${!typedReturns ? (returns ? CValtype[f.returns[0]] : 'void') : 'struct ReturnValue'} ${shouldInline ? 'inline ' : ''}${ffiFuncs[f.name] ? '(*' : ''}${sanitize(f.name)}${ffiFuncs[f.name] ? ')' : ''}(${rawParams(f).map((x, i) => `${CValtype[x]} ${invLocals[i]}`).join(', ')});`;
916
915
  }).join('\n'));
917
916
 
@@ -6,7 +6,7 @@ export const __Porffor_object_underlying = (obj: any): any => {
6
6
 
7
7
  if (Porffor.fastAnd(
8
8
  t >= Porffor.TYPES.error,
9
- t <= Porffor.TYPES.todoerror
9
+ t < 0x40
10
10
  )) {
11
11
  return obj as object;
12
12
  }
@@ -2,32 +2,29 @@ export default () => {
2
2
  let out = '';
3
3
 
4
4
  const errors = [];
5
- const error = name => {
6
- errors.push(name);
7
- out += `export const ${name} = function (message: any) {
5
+ const error = (name, type = true) => {
6
+ if (type) errors.push(name);
7
+ out += `export const ${name} = function (message: any): ${type ? name : 'Error'} {
8
8
  if (message === undefined) message = '';
9
9
  else message = ecma262.ToString(message);
10
10
 
11
11
  const obj: object = Porffor.allocateBytes(128);
12
-
13
12
  obj.name = '${name}';
14
13
  obj.message = message;
15
14
  obj.constructor = ${name};
16
15
 
17
- const out: ${name} = obj;
18
- return out;
16
+ return obj as ${type ? name : 'Error'};
19
17
  };
20
18
 
21
- export const __${name}_prototype_toString = (_this: ${name}) => {
22
- const obj: object = _this;
23
-
24
- const message: any = obj.message;
19
+ ${type ? `export const __${name}_prototype_toString = (_this: ${name}) => {
20
+ const name: any = (_this as object).name;
21
+ const message: any = (_this as object).message;
25
22
  if (message.length == 0) {
26
- return obj.name;
23
+ return name;
27
24
  }
28
25
 
29
- return obj.name + ': ' + message;
30
- };`;
26
+ return name + ': ' + message;
27
+ };` : ''}`;
31
28
  };
32
29
 
33
30
  error('Error');
@@ -38,9 +35,8 @@ export const __${name}_prototype_toString = (_this: ${name}) => {
38
35
  error('RangeError');
39
36
  error('EvalError');
40
37
  error('URIError');
41
-
42
38
  error('Test262Error');
43
- error('TodoError');
39
+ error('TodoError', false);
44
40
 
45
41
  out += `
46
42
  export const __Test262Error_thrower = message => {