porffor 0.28.7 → 0.28.8

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.
@@ -3023,16 +3023,12 @@ const generateVar = (scope, decl) => {
3023
3023
  type: 'VariableDeclarator',
3024
3024
  id: e.left,
3025
3025
  init: {
3026
- type: 'LogicalExpression',
3027
- operator: '??',
3028
- left: {
3029
- type: 'MemberExpression',
3030
- object: { type: 'Identifier', name: tmpName },
3031
- property: { type: 'Literal', value: i },
3032
- computed: true
3033
- },
3034
- right: e.right
3035
- }
3026
+ type: 'MemberExpression',
3027
+ object: { type: 'Identifier', name: tmpName },
3028
+ property: { type: 'Literal', value: i },
3029
+ computed: true
3030
+ },
3031
+ _default: e.right
3036
3032
  });
3037
3033
 
3038
3034
  break;
@@ -3065,7 +3061,8 @@ const generateVar = (scope, decl) => {
3065
3061
  declarations: [{
3066
3062
  type: 'VariableDeclarator',
3067
3063
  id: { type: 'Identifier', name: tmpName },
3068
- init: x.init
3064
+ init: x.init,
3065
+ _default: x._default
3069
3066
  }],
3070
3067
  kind: decl.kind,
3071
3068
  _global: false
@@ -3110,16 +3107,12 @@ const generateVar = (scope, decl) => {
3110
3107
  type: 'VariableDeclarator',
3111
3108
  id: prop.value.left,
3112
3109
  init: {
3113
- type: 'LogicalExpression',
3114
- operator: '??',
3115
- left: {
3116
- type: 'MemberExpression',
3117
- object: { type: 'Identifier', name: tmpName },
3118
- property: prop.key,
3119
- computed: prop.computed
3120
- },
3121
- right: prop.value.right
3122
- }
3110
+ type: 'MemberExpression',
3111
+ object: { type: 'Identifier', name: tmpName },
3112
+ property: prop.key,
3113
+ computed: prop.computed
3114
+ },
3115
+ _default: prop.value.right
3123
3116
  });
3124
3117
  } else {
3125
3118
  decls.push({
@@ -3144,7 +3137,8 @@ const generateVar = (scope, decl) => {
3144
3137
  declarations: [{
3145
3138
  type: 'VariableDeclarator',
3146
3139
  id: { type: 'Identifier', name: tmpName },
3147
- init: x.init
3140
+ init: x.init,
3141
+ _default: x._default
3148
3142
  }],
3149
3143
  kind: decl.kind,
3150
3144
  _global: false
@@ -3226,6 +3220,17 @@ const generateVar = (scope, decl) => {
3226
3220
 
3227
3221
  out = out.concat(newOut);
3228
3222
 
3223
+ if (x._default) {
3224
+ out.push(
3225
+ ...typeIsOneOf(getType(scope, name), [ TYPES.undefined, TYPES.empty ]),
3226
+ [ Opcodes.if, Blocktype.void ],
3227
+ ...generate(scope, x._default, global, name),
3228
+ [ global ? Opcodes.global_set : Opcodes.local_set, idx ],
3229
+ ...setType(scope, name, getNodeType(scope, x._default)),
3230
+ [ Opcodes.end ],
3231
+ );
3232
+ }
3233
+
3229
3234
  if (globalThis.precompile && global) {
3230
3235
  scope.globalInits ??= {};
3231
3236
  scope.globalInits[name] = newOut;
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.28.7+a711fccd4",
4
+ "version": "0.28.8+a0f4bd584",
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.28.7+a711fccd4';
3
+ globalThis.version = '0.28.8+a0f4bd584';
4
4
 
5
5
  // deno compat
6
6
  if (typeof process === 'undefined' && typeof Deno !== 'undefined') {