mirror of
https://github.com/bendtherules/ask262.git
synced 2026-08-18 21:31:46 +00:00
Merge commit '6e92d2345e8231a44556ce7d416451f5f3e6c398' as 'engine262'
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { surroundingAgent } from '../host-defined/engine.mts';
|
||||
import { Value } from '../value.mts';
|
||||
import { Q } from '../completion.mts';
|
||||
import type { ParseNode } from '../parser/ParseNode.mts';
|
||||
import type { ValueEvaluator } from '../evaluator.mts';
|
||||
import {
|
||||
PropertyDefinitionEvaluation_PropertyDefinitionList,
|
||||
} from './all.mts';
|
||||
import { OrdinaryObjectCreate } from '#self';
|
||||
|
||||
/** https://tc39.es/ecma262/#sec-object-initializer-runtime-semantics-evaluation */
|
||||
// ObjectLiteral :
|
||||
// `{` `}`
|
||||
// `{` PropertyDefinitionList `}`
|
||||
// `{` PropertyDefinitionList `,` `}`
|
||||
export function* Evaluate_ObjectLiteral({ PropertyDefinitionList }: ParseNode.ObjectLiteral): ValueEvaluator {
|
||||
// 1. Let obj be OrdinaryObjectCreate(%Object.prototype%).
|
||||
const obj = OrdinaryObjectCreate(surroundingAgent.intrinsic('%Object.prototype%'));
|
||||
if (PropertyDefinitionList.length === 0) {
|
||||
return obj;
|
||||
}
|
||||
// 2. Perform ? PropertyDefinitionEvaluation of PropertyDefinitionList with arguments obj and true.
|
||||
Q(yield* PropertyDefinitionEvaluation_PropertyDefinitionList(PropertyDefinitionList, obj, Value.true));
|
||||
// 3. Return obj.
|
||||
return obj;
|
||||
}
|
||||
Reference in New Issue
Block a user