134
param.node.loc ?? GeneratedSource,
135
InstructionKind.Let,
136
param,
137
- place
137
+ place,
138
+ "Assignment"
139
);
140
} else if (param.isRestElement()) {
141
const place: Place = {
154
param.node.loc ?? GeneratedSource,
155
InstructionKind.Let,
156
param.get("argument"),
156
- place
157
+ place,
158
+ "Assignment"
159
);
160
} else {
161
builder.errors.push({
818
stmt.node.loc ?? GeneratedSource,
819
kind,
820
id,
819
- value
821
+ value,
822
+ id.isObjectPattern() || id.isArrayPattern()
823
+ ? "Destructure"
824
+ : "Assignment"
825
);
826
} else if (id.isIdentifier()) {
827
const identifier = builder.resolveIdentifier(id);
983
stmt.node.loc ?? GeneratedSource,
984
InstructionKind.Let,
985
id,
981
- fn
986
+ fn,
987
+ "Assignment"
988
);
989
990
return;
1049
leftLoc,
1050
InstructionKind.Let,
1051
id,
1046
- nextIterableOf
1052
+ nextIterableOf,
1053
+ "Assignment"
1054
);
1055
test = lowerValueToTemporary(builder, assign);
1056
} else {
1135
leftLoc,
1136
InstructionKind.Let,
1137
id,
1131
- nextIterableOf
1138
+ nextIterableOf,
1139
+ "Assignment"
1140
);
1141
test = lowerValueToTemporary(builder, assign);
1142
} else {
1237
handlerBinding.path.node.loc ?? GeneratedSource,
1238
InstructionKind.Catch,
1239
handlerBinding.path,
1232
- { ...handlerBinding.place }
1240
+ { ...handlerBinding.place },
1241
+ "Assignment"
1242
);
1243
}
1244
lowerStatement(builder, handlerPath.get("body"));
1823
left.node.loc ?? GeneratedSource,
1824
InstructionKind.Reassign,
1825
left,
1817
- lowerExpressionToTemporary(builder, expr.get("right"))
1826
+ lowerExpressionToTemporary(builder, expr.get("right")),
1827
+ left.isArrayPattern() || left.isObjectPattern()
1828
+ ? "Destructure"
1829
+ : "Assignment"
1830
);
1831
}
1832
3250
loc: SourceLocation,
3251
kind: InstructionKind,
3252
lvaluePath: NodePath<t.LVal>,
3241
- value: Place
3253
+ value: Place,
3254
+ assignmentKind: "Destructure" | "Assignment"
3255
): InstructionValue {
3256
const lvalueNode = lvaluePath.node;
3257
switch (lvalueNode.type) {
3395
}
3396
if (element.isRestElement()) {
3397
const argument = element.get("argument");
3385
- if (argument.isIdentifier() && !forceTemporaries) {
3398
+ if (
3399
+ argument.isIdentifier() &&
3400
+ !forceTemporaries &&
3401
+ (assignmentKind === "Assignment" ||
3402
+ getStoreKind(builder, argument) === "StoreLocal")
3403
+ ) {
3404
const identifier = lowerIdentifierForAssignment(
3405
builder,
3406
element.node.loc ?? GeneratedSource,
3425
});
3426
followups.push({ place: temp, path: argument as NodePath<t.LVal> }); // TODO remove type cast
3427
}
3410
- } else if (element.isIdentifier() && !forceTemporaries) {
3428
+ } else if (
3429
+ element.isIdentifier() &&
3430
+ !forceTemporaries &&
3431
+ (assignmentKind === "Assignment" ||
3432
+ getStoreKind(builder, element) === "StoreLocal")
3433
+ ) {
3434
const identifier = lowerIdentifierForAssignment(
3435
builder,
3436
element.node.loc ?? GeneratedSource,
3463
loc,
3464
});
3465
for (const { place, path } of followups) {
3443
- lowerAssignment(builder, path.node.loc ?? loc, kind, path, place);
3466
+ lowerAssignment(
3467
+ builder,
3468
+ path.node.loc ?? loc,
3469
+ kind,
3470
+ path,
3471
+ place,
3472
+ assignmentKind
3473
+ );
3474
}
3475
return { kind: "LoadLocal", place: temporary, loc: value.loc };
3476
}
3508
});
3509
continue;
3510
}
3481
- if (forceTemporaries) {
3511
+ if (
3512
+ forceTemporaries ||
3513
+ getStoreKind(builder, argument) === "StoreContext"
3514
+ ) {
3515
const temp = buildTemporaryPlace(
3516
builder,
3517
property.node.loc ?? GeneratedSource
3570
});
3571
continue;
3572
}
3540
- if (element.isIdentifier() && !forceTemporaries) {
3573
+ if (
3574
+ element.isIdentifier() &&
3575
+ !forceTemporaries &&
3576
+ (assignmentKind === "Assignment" ||
3577
+ getStoreKind(builder, element) === "StoreLocal")
3578
+ ) {
3579
const identifier = lowerIdentifierForAssignment(
3580
builder,
3581
element.node.loc ?? GeneratedSource,
3619
loc,
3620
});
3621
for (const { place, path } of followups) {
3584
- lowerAssignment(builder, path.node.loc ?? loc, kind, path, place);
3622
+ lowerAssignment(
3623
+ builder,
3624
+ path.node.loc ?? loc,
3625
+ kind,
3626
+ path,
3627
+ place,
3628
+ assignmentKind
3629
+ );
3630
}
3631
return { kind: "LoadLocal", place: temporary, loc: value.loc };
3632
}
3713
continuationBlock
3714
);
3715
3671
- return lowerAssignment(builder, loc, kind, lvalue.get("left"), temp);
3716
+ return lowerAssignment(
3717
+ builder,
3718
+ loc,
3719
+ kind,
3720
+ lvalue.get("left"),
3721
+ temp,
3722
+ assignmentKind
3723
+ );
3724
}
3725
default: {
3726
builder.errors.push({