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.
- package/compiler/codegen.js +27 -22
- package/package.json +1 -1
- package/runner/index.js +1 -1
package/compiler/codegen.js
CHANGED
@@ -3023,16 +3023,12 @@ const generateVar = (scope, decl) => {
|
|
3023
3023
|
type: 'VariableDeclarator',
|
3024
3024
|
id: e.left,
|
3025
3025
|
init: {
|
3026
|
-
type: '
|
3027
|
-
|
3028
|
-
|
3029
|
-
|
3030
|
-
|
3031
|
-
|
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: '
|
3114
|
-
|
3115
|
-
|
3116
|
-
|
3117
|
-
|
3118
|
-
|
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