110 } 111 } 112 113 /** 114 * Generate code for making the object. 115 * @param method Script method. 116 */ 117 public abstract void makeObject(final MethodEmitter method); 118 119 /** 120 * Create a new MapCreator 121 * @param clazz type of MapCreator 122 * @return map creator instantiated by type 123 */ 124 protected MapCreator newMapCreator(final Class<?> clazz) { 125 return new MapCreator(clazz, keys, symbols); 126 } 127 128 /** 129 * Construct the property map appropriate for the object. 130 */ 131 protected void makeMap() { 132 if (keys.isEmpty()) { //empty map 133 propertyMap = PropertyMap.newMap(fieldObjectClass); 134 return; 135 } 136 137 propertyMap = newMapCreator(fieldObjectClass).makeMap(isVarArg()); 138 } 139 140 /** 141 * Emit the correct map for the object. 142 * @param method method emitter 143 * @return the method emitter 144 */ 145 protected MethodEmitter loadMap(final MethodEmitter method) { 146 codegen.loadConstant(propertyMap); 147 return method; 148 } 149 150 /** 151 * Get the class name for the object class, 152 * e.g. {@code com.nashorn.oracle.scripts.JO$2P0} 153 * 154 * @return script class name 155 */ 156 public String getClassName() { 157 return fieldObjectClassName; | 110 } 111 } 112 113 /** 114 * Generate code for making the object. 115 * @param method Script method. 116 */ 117 public abstract void makeObject(final MethodEmitter method); 118 119 /** 120 * Create a new MapCreator 121 * @param clazz type of MapCreator 122 * @return map creator instantiated by type 123 */ 124 protected MapCreator newMapCreator(final Class<?> clazz) { 125 return new MapCreator(clazz, keys, symbols); 126 } 127 128 /** 129 * Construct the property map appropriate for the object. 130 * @return the newly created property map 131 */ 132 protected PropertyMap makeMap() { 133 if (keys.isEmpty()) { //empty map 134 propertyMap = PropertyMap.newMap(fieldObjectClass); 135 } else { 136 propertyMap = newMapCreator(fieldObjectClass).makeMap(isVarArg()); 137 } 138 return propertyMap; 139 } 140 141 /** 142 * Emit the correct map for the object. 143 * @param method method emitter 144 * @return the method emitter 145 */ 146 protected MethodEmitter loadMap(final MethodEmitter method) { 147 codegen.loadConstant(propertyMap); 148 return method; 149 } 150 151 /** 152 * Get the class name for the object class, 153 * e.g. {@code com.nashorn.oracle.scripts.JO$2P0} 154 * 155 * @return script class name 156 */ 157 public String getClassName() { 158 return fieldObjectClassName; |