Skip to content

Commit

Permalink
feat(ast): implement RS:Evaluation for ObjectLiteral
Browse files Browse the repository at this point in the history
  • Loading branch information
fkleuver committed Nov 25, 2019
1 parent 65efb20 commit 04d5eab
Showing 1 changed file with 9 additions and 21 deletions.
30 changes: 9 additions & 21 deletions packages/aot/src/vm/ast/expressions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ export class $ObjectLiteralExpression implements I$Node {
// 12.2.6.7 Runtime Semantics: Evaluation
public Evaluate(
ctx: ExecutionContext,
): $Object {
): $Object | $Error {
const realm = ctx.Realm;
const intrinsics = realm['[[Intrinsics]]'];

Expand All @@ -597,28 +597,16 @@ export class $ObjectLiteralExpression implements I$Node {
// ObjectLiteral : { PropertyDefinitionList } { PropertyDefinitionList , }

// 1. Let obj be ObjectCreate(%ObjectPrototype%).
// 2. Perform ? PropertyDefinitionEvaluation of PropertyDefinitionList with arguments obj and true.
// 3. Return obj.

// LiteralPropertyName : IdentifierName

// 1. Return StringValue of IdentifierName.

// LiteralPropertyName : StringLiteral

// 1. Return the String value whose code units are the SV of the StringLiteral.
const obj = $Object.ObjectCreate(ctx, 'Object', intrinsics['%ObjectPrototype%']);

// LiteralPropertyName : NumericLiteral

// 1. Let nbr be the result of forming the value of the NumericLiteral.
// 2. Return ! ToString(nbr).

// ComputedPropertyName : [ AssignmentExpression ]
// 2. Perform ? PropertyDefinitionEvaluation of PropertyDefinitionList with arguments obj and true.
for (const prop of this.$properties) {
const $PropertyDefinitionEvaluationResult = prop.EvaluatePropertyDefinition(ctx, obj, intrinsics.true);
if ($PropertyDefinitionEvaluationResult.isAbrupt) { return $PropertyDefinitionEvaluationResult; }
}

// 1. Let exprValue be the result of evaluating AssignmentExpression.
// 2. Let propName be ? GetValue(exprValue).
// 3. Return ? ToPropertyKey(propName).
return intrinsics['%ObjectPrototype%']; // TODO: implement this
// 3. Return obj.
return obj;
}
}

Expand Down

0 comments on commit 04d5eab

Please sign in to comment.