use of com.github.anba.es6draft.compiler.PropertyGenerator.PropertyEvaluation in project es6draft by anba.
the class ExpressionGenerator method visit.
/**
* 12.2.6 Object Initializer
* <p>
* 12.2.6.8 Runtime Semantics: Evaluation
*/
@Override
public ValType visit(ObjectLiteral node, CodeVisitor mv) {
List<MethodDefinition> decoratedMethods = DecoratedMethods(node.getProperties());
if (decoratedMethods.isEmpty()) {
/* step 1 */
mv.loadExecutionContext();
mv.get(Fields.Intrinsics_ObjectPrototype);
mv.invoke(Methods.OrdinaryObject_ObjectCreate);
/* steps 2-3 */
PropertyEvaluation(codegen, node.getProperties(), mv);
/* step 4 */
return ValType.Object;
}
mv.enterVariableScope();
/* step 1 */
Variable<OrdinaryObject> object = mv.newVariable("object", OrdinaryObject.class);
mv.loadExecutionContext();
mv.get(Fields.Intrinsics_ObjectPrototype);
mv.invoke(Methods.OrdinaryObject_ObjectCreate);
mv.store(object);
int decoratorsCount = decoratedMethods.stream().mapToInt(m -> m.getDecorators().size()).sum();
int decoratorsLength = decoratorsCount + decoratedMethods.size();
StoreToArray<Object> methodDecorators = StoreToArray.create("methodDecorators", decoratorsLength, Object[].class, mv);
/* steps 2-3 */
PropertyEvaluation(codegen, node.getProperties(), object, methodDecorators, mv);
MethodName decoratorsMethod = mv.compile(node, this::objectMethodDecorators);
// 0 = hint for stacktraces to omit this frame
mv.lineInfo(0);
mv.invoke(decoratorsMethod, mv.executionContext(), object, methodDecorators.array);
mv.load(object);
mv.exitVariableScope();
/* step 4 */
return ValType.Object;
}
Aggregations