MCPcopy
hub / github.com/rollup/rollup / getObjectEntity

Method getObjectEntity

src/ast/nodes/ObjectExpression.ts:135–180  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

133 }
134
135 private getObjectEntity(): ObjectEntity {
136 if (this.objectEntity !== null) {
137 return this.objectEntity;
138 }
139 let prototype: ExpressionEntity | null = OBJECT_PROTOTYPE;
140 const properties: ObjectProperty[] = [];
141 for (const property of this.properties) {
142 if (property instanceof SpreadElement) {
143 properties.push({ key: UnknownKey, kind: 'init', property });
144 continue;
145 }
146 let key: string;
147 if (property.computed) {
148 const keyValue = property.key.getLiteralValueAtPath(
149 EMPTY_PATH,
150 SHARED_RECURSION_TRACKER,
151 this
152 );
153 if (typeof keyValue === 'symbol') {
154 properties.push({
155 key: isAnyWellKnown(keyValue) ? keyValue : UnknownKey,
156 kind: property.kind,
157 property
158 });
159 continue;
160 } else {
161 key = String(keyValue);
162 }
163 } else {
164 key =
165 property.key instanceof Identifier
166 ? property.key.name
167 : String((property.key as Literal).value);
168 if (key === '__proto__' && property.kind === 'init') {
169 this.protoProp = property;
170 prototype =
171 property.value instanceof Literal && property.value.value === null
172 ? null
173 : property.value;
174 continue;
175 }
176 }
177 properties.push({ key, kind: property.kind, property });
178 }
179 return (this.objectEntity = new ObjectEntity(properties, prototype));
180 }
181}
182
183ObjectExpression.prototype.applyDeoptimizations = doNotDeoptimize;

Callers 8

deoptimizeCacheMethod · 0.95
deoptimizePathMethod · 0.95
getLiteralValueAtPathMethod · 0.95
includeMethod · 0.95
includePathMethod · 0.95

Calls 3

isAnyWellKnownFunction · 0.90
pushMethod · 0.80
getLiteralValueAtPathMethod · 0.45

Tested by

no test coverage detected