src/jdk/nashorn/internal/codegen/CodeGenerator.java

Print this page




2329                 protected void loadValue(final Expression node, final Type type) {
2330                     loadExpressionAsType(node, type);
2331                 }};
2332         }
2333         oc.makeObject(method);
2334 
2335         //if this is a rest of method and our continuation point was found as one of the values
2336         //in the properties above, we need to reset the map to oc.getMap() in the continuation
2337         //handler
2338         if (restOfProperty) {
2339             final ContinuationInfo ci = getContinuationInfo();
2340             // Can be set at most once for a single rest-of method
2341             assert ci.getObjectLiteralMap() == null;
2342             ci.setObjectLiteralMap(oc.getMap());
2343             ci.setObjectLiteralStackDepth(method.getStackSize());
2344         }
2345 
2346         method.dup();
2347         if (protoNode != null) {
2348             loadExpressionAsObject(protoNode);
2349             method.invoke(ScriptObject.SET_PROTO_CHECK);


2350         } else {
2351             method.invoke(ScriptObject.SET_GLOBAL_OBJECT_PROTO);
2352         }
2353 
2354         for (final PropertyNode propertyNode : gettersSetters) {
2355             final FunctionNode getter = propertyNode.getGetter();
2356             final FunctionNode setter = propertyNode.getSetter();
2357 
2358             assert getter != null || setter != null;
2359 
2360             method.dup().loadKey(propertyNode.getKey());
2361             if (getter == null) {
2362                 method.loadNull();
2363             } else {
2364                 getter.accept(this);
2365             }
2366 
2367             if (setter == null) {
2368                 method.loadNull();
2369             } else {




2329                 protected void loadValue(final Expression node, final Type type) {
2330                     loadExpressionAsType(node, type);
2331                 }};
2332         }
2333         oc.makeObject(method);
2334 
2335         //if this is a rest of method and our continuation point was found as one of the values
2336         //in the properties above, we need to reset the map to oc.getMap() in the continuation
2337         //handler
2338         if (restOfProperty) {
2339             final ContinuationInfo ci = getContinuationInfo();
2340             // Can be set at most once for a single rest-of method
2341             assert ci.getObjectLiteralMap() == null;
2342             ci.setObjectLiteralMap(oc.getMap());
2343             ci.setObjectLiteralStackDepth(method.getStackSize());
2344         }
2345 
2346         method.dup();
2347         if (protoNode != null) {
2348             loadExpressionAsObject(protoNode);
2349             // take care of { __proto__: 34 } or some such!
2350             method.convert(Type.OBJECT);
2351             method.invoke(ScriptObject.SET_PROTO_FROM_LITERAL);
2352         } else {
2353             method.invoke(ScriptObject.SET_GLOBAL_OBJECT_PROTO);
2354         }
2355 
2356         for (final PropertyNode propertyNode : gettersSetters) {
2357             final FunctionNode getter = propertyNode.getGetter();
2358             final FunctionNode setter = propertyNode.getSetter();
2359 
2360             assert getter != null || setter != null;
2361 
2362             method.dup().loadKey(propertyNode.getKey());
2363             if (getter == null) {
2364                 method.loadNull();
2365             } else {
2366                 getter.accept(this);
2367             }
2368 
2369             if (setter == null) {
2370                 method.loadNull();
2371             } else {