< prev index next >

src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/FieldObjectCreator.java

Print this page




 103         // subsequently the "PUTFIELD J04.L0" instruction in the continuation code would fail bytecode verification.
 104         assert fieldObjectClass != null;
 105         method._new(fieldObjectClass).dup();
 106 
 107         loadMap(method); //load the map
 108 
 109         if (isScope()) {
 110             loadScope(method);
 111 
 112             if (hasArguments()) {
 113                 method.loadCompilerConstant(ARGUMENTS);
 114                 method.invoke(constructorNoLookup(className, PropertyMap.class, ScriptObject.class, ARGUMENTS.type()));
 115             } else {
 116                 method.invoke(constructorNoLookup(className, PropertyMap.class, ScriptObject.class));
 117             }
 118         } else {
 119             method.invoke(constructorNoLookup(className, PropertyMap.class));
 120         }
 121     }
 122 



















 123     @Override
 124     public void populateRange(final MethodEmitter method, final Type objectType, final int objectSlot, final int start, final int end) {
 125         method.load(objectType, objectSlot);
 126         // Set values.
 127         for (int i = start; i < end; i++) {
 128             final MapTuple<T> tuple = tuples.get(i);
 129             //we only load when we have both symbols and values (which can be == the symbol)
 130             //if we didn't load, we need an array property
 131             if (tuple.symbol != null && tuple.value != null) {
 132                 final int index = getArrayIndex(tuple.key);
 133                 method.dup();
 134                 if (!isValidArrayIndex(index)) {
 135                     putField(method, tuple.key, tuple.symbol.getFieldIndex(), tuple);
 136                 } else {
 137                     putSlot(method, ArrayIndex.toLongIndex(index), tuple);
 138                 }
 139 
 140                 //this is a nop of tuple.key isn't e.g. "apply" or another special name
 141                 method.invalidateSpecialName(tuple.key);
 142             }




 103         // subsequently the "PUTFIELD J04.L0" instruction in the continuation code would fail bytecode verification.
 104         assert fieldObjectClass != null;
 105         method._new(fieldObjectClass).dup();
 106 
 107         loadMap(method); //load the map
 108 
 109         if (isScope()) {
 110             loadScope(method);
 111 
 112             if (hasArguments()) {
 113                 method.loadCompilerConstant(ARGUMENTS);
 114                 method.invoke(constructorNoLookup(className, PropertyMap.class, ScriptObject.class, ARGUMENTS.type()));
 115             } else {
 116                 method.invoke(constructorNoLookup(className, PropertyMap.class, ScriptObject.class));
 117             }
 118         } else {
 119             method.invoke(constructorNoLookup(className, PropertyMap.class));
 120         }
 121     }
 122 
 123     /**
 124      * Create a scope for a for-in/of loop as defined in ES6 13.7.5.13 step 5.g.iii
 125      *
 126      * @param method the method emitter
 127      */
 128     void createForInIterationScope(final MethodEmitter method) {
 129         assert fieldObjectClass != null;
 130         assert isScope();
 131         assert getMap() != null;
 132 
 133         final String className = getClassName();
 134         method._new(fieldObjectClass).dup();
 135         loadMap(method); //load the map
 136         loadScope(method);
 137         // We create a scope identical to the currently active one, so use its parent as our parent
 138         method.invoke(ScriptObject.GET_PROTO);
 139         method.invoke(constructorNoLookup(className, PropertyMap.class, ScriptObject.class));
 140     }
 141 
 142     @Override
 143     public void populateRange(final MethodEmitter method, final Type objectType, final int objectSlot, final int start, final int end) {
 144         method.load(objectType, objectSlot);
 145         // Set values.
 146         for (int i = start; i < end; i++) {
 147             final MapTuple<T> tuple = tuples.get(i);
 148             //we only load when we have both symbols and values (which can be == the symbol)
 149             //if we didn't load, we need an array property
 150             if (tuple.symbol != null && tuple.value != null) {
 151                 final int index = getArrayIndex(tuple.key);
 152                 method.dup();
 153                 if (!isValidArrayIndex(index)) {
 154                     putField(method, tuple.key, tuple.symbol.getFieldIndex(), tuple);
 155                 } else {
 156                     putSlot(method, ArrayIndex.toLongIndex(index), tuple);
 157                 }
 158 
 159                 //this is a nop of tuple.key isn't e.g. "apply" or another special name
 160                 method.invalidateSpecialName(tuple.key);
 161             }


< prev index next >