[hir] Add a "type" field to ObjectProperty

This will be used to distinguish between a property and a method.
This commit is contained in:
Sathya Gunasekaran
2023-09-15 17:16:05 +01:00
parent 88f65d44a7
commit b26cc58070
2 changed files with 6 additions and 1 deletions
@@ -34,6 +34,7 @@ import {
JsxAttribute,
ObjectPattern,
ObjectProperty,
ObjectPropertyKey,
Place,
ReturnTerminal,
SourceLocation,
@@ -1159,7 +1160,7 @@ function lowerStatement(
function lowerObjectPropertyKey(
builder: HIRBuilder,
key: t.PrivateName | t.Expression
): { name: string; type: "string" | "identifier" } | null {
): ObjectPropertyKey | null {
if (key.type === "Identifier") {
return {
name: key.name,
@@ -1245,6 +1246,7 @@ function lowerExpression(
const value = lowerExpressionToTemporary(builder, valuePath);
properties.push({
kind: "ObjectProperty",
type: "property",
place: value,
key: loweredKey,
});
@@ -3123,6 +3125,7 @@ function lowerAssignment(
}
properties.push({
kind: "ObjectProperty",
type: "property",
place: identifier,
key: loweredKey,
});
@@ -3133,6 +3136,7 @@ function lowerAssignment(
);
properties.push({
kind: "ObjectProperty",
type: "property",
place: { ...temp },
key: loweredKey,
});
@@ -554,6 +554,7 @@ export type ObjectPropertyKey = {
export type ObjectProperty = {
kind: "ObjectProperty";
key: ObjectPropertyKey;
type: "property" | "method";
place: Place;
};