porffor 0.47.7 → 0.48.0

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.
@@ -2202,7 +2202,10 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
2202
2202
  generate(scope, decl.arguments[0] ?? DEFAULT_VALUE()),
2203
2203
  getNodeType(scope, decl.arguments[0] ?? DEFAULT_VALUE()),
2204
2204
  protoLocal, protoLocal2,
2205
- () => [ [ Opcodes.call, includeBuiltin(scope, '__Porffor_allocate').index ] ],
2205
+ bytes => [
2206
+ ...number(bytes, Valtype.i32),
2207
+ [ Opcodes.call, includeBuiltin(scope, '__Porffor_allocateBytes').index ]
2208
+ ],
2206
2209
  () => {
2207
2210
  optUnused = true;
2208
2211
  return unusedValue;
@@ -3011,7 +3014,6 @@ const generateVarDstr = (scope, kind, pattern, init, defaultValue, global) => {
3011
3014
  }
3012
3015
  }
3013
3016
 
3014
-
3015
3017
  const topLevel = scope.name === 'main';
3016
3018
 
3017
3019
  if (typeof pattern === 'string') {
@@ -3033,6 +3035,11 @@ const generateVarDstr = (scope, kind, pattern, init, defaultValue, global) => {
3033
3035
  }
3034
3036
  }
3035
3037
 
3038
+ if (defaultValue && isFuncType(defaultValue.type)) {
3039
+ // set id as name, but do not use it as it is only default value
3040
+ if (!defaultValue.id) defaultValue.id = { name };
3041
+ }
3042
+
3036
3043
  if (topLevel && Object.hasOwn(builtinVars, name)) {
3037
3044
  // cannot redeclare
3038
3045
  if (kind !== 'var') return internalThrow(scope, 'SyntaxError', `Identifier '${unhackName(name)}' has already been declared`);
@@ -4188,7 +4195,8 @@ const generateForOf = (scope, decl) => {
4188
4195
  ...setType(scope, tmpName, TYPES.string),
4189
4196
 
4190
4197
  // allocate out string
4191
- [ Opcodes.call, includeBuiltin(scope, '__Porffor_allocate').index ],
4198
+ ...number(8, Valtype.i32),
4199
+ [ Opcodes.call, includeBuiltin(scope, '__Porffor_allocateBytes').index ],
4192
4200
  [ Opcodes.local_tee, localTmp(scope, '#forof_allocd', Valtype.i32) ],
4193
4201
 
4194
4202
  // set length to 1
@@ -4243,7 +4251,8 @@ const generateForOf = (scope, decl) => {
4243
4251
  ...setType(scope, tmpName, TYPES.bytestring),
4244
4252
 
4245
4253
  // allocate out string
4246
- [ Opcodes.call, includeBuiltin(scope, '__Porffor_allocate').index ],
4254
+ ...number(8, Valtype.i32),
4255
+ [ Opcodes.call, includeBuiltin(scope, '__Porffor_allocateBytes').index ],
4247
4256
  [ Opcodes.local_tee, localTmp(scope, '#forof_allocd', Valtype.i32) ],
4248
4257
 
4249
4258
  // set length to 1
@@ -5442,7 +5451,8 @@ const generateMember = (scope, decl, _global, _name, _objectWasm = undefined) =>
5442
5451
 
5443
5452
  [TYPES.string]: () => [
5444
5453
  // allocate out string
5445
- [ Opcodes.call, includeBuiltin(scope, '__Porffor_allocate').index ],
5454
+ ...number(8, Valtype.i32),
5455
+ [ Opcodes.call, includeBuiltin(scope, '__Porffor_allocateBytes').index ],
5446
5456
  [ Opcodes.local_tee, localTmp(scope, '#member_allocd', Valtype.i32) ],
5447
5457
 
5448
5458
  // set length to 1
@@ -5476,7 +5486,8 @@ const generateMember = (scope, decl, _global, _name, _objectWasm = undefined) =>
5476
5486
 
5477
5487
  [TYPES.bytestring]: () => [
5478
5488
  // allocate out string
5479
- [ Opcodes.call, includeBuiltin(scope, '__Porffor_allocate').index ],
5489
+ ...number(8, Valtype.i32),
5490
+ [ Opcodes.call, includeBuiltin(scope, '__Porffor_allocateBytes').index ],
5480
5491
  [ Opcodes.local_tee, localTmp(scope, '#member_allocd', Valtype.i32) ],
5481
5492
 
5482
5493
  // set length to 1
@@ -177,7 +177,7 @@ export const PrototypeFuncs = function() {
177
177
  this[TYPES.string] = {
178
178
  at: (pointer, length, wIndex, wType, iTmp, iOut, alloc) => [
179
179
  // setup new/out array and use pointer for store
180
- ...alloc(),
180
+ ...alloc(8),
181
181
  [ Opcodes.local_tee, iOut ],
182
182
 
183
183
  // out.length = 1
@@ -235,7 +235,7 @@ export const PrototypeFuncs = function() {
235
235
  // todo: out of bounds properly
236
236
  charAt: (pointer, length, wIndex, wType, iTmp, _, alloc) => [
237
237
  // setup new/out array and use as pointer for store
238
- ...alloc(),
238
+ ...alloc(8),
239
239
  [ Opcodes.local_tee, iTmp ],
240
240
 
241
241
  // out.length = 1
@@ -315,7 +315,7 @@ export const PrototypeFuncs = function() {
315
315
  this[TYPES.bytestring] = {
316
316
  at: (pointer, length, wIndex, wType, iTmp, iOut, alloc) => [
317
317
  // setup new/out array and use pointer for store
318
- ...alloc(),
318
+ ...alloc(8),
319
319
  [ Opcodes.local_tee, iOut ],
320
320
 
321
321
  // out.length = 1
@@ -371,7 +371,7 @@ export const PrototypeFuncs = function() {
371
371
  // todo: out of bounds properly
372
372
  charAt: (pointer, length, wIndex, wType, iTmp, _, alloc) => [
373
373
  // setup new/out array and use as pointer for store
374
- ...alloc(),
374
+ ...alloc(8),
375
375
  [ Opcodes.local_tee, iTmp ],
376
376
 
377
377
  // out.length = 1
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.47.7",
4
+ "version": "0.48.0",
5
5
  "author": "CanadaHonk",
6
6
  "license": "MIT",
7
7
  "scripts": {},
package/runner/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import fs from 'node:fs';
3
- globalThis.version = '0.47.7';
3
+ globalThis.version = '0.48.0';
4
4
 
5
5
  // deno compat
6
6
  if (typeof process === 'undefined' && typeof Deno !== 'undefined') {