2157 // for its side effect and visit the body, and not bother opening and closing a WithObject. 2158 final boolean hasScope = method.hasScope(); 2159 2160 final Label tryLabel; 2161 if (hasScope) { 2162 tryLabel = new Label("with_try"); 2163 method.label(tryLabel); 2164 method.loadCompilerConstant(SCOPE); 2165 } else { 2166 tryLabel = null; 2167 } 2168 2169 load(expression); 2170 assert expression.getType().isObject() : "with expression needs to be object: " + expression; 2171 2172 if (hasScope) { 2173 // Construct a WithObject if we have a scope 2174 method.invoke(ScriptRuntime.OPEN_WITH); 2175 method.storeCompilerConstant(SCOPE); 2176 } else { 2177 // We just loaded the expression for its side effect; discard it 2178 method.pop(); 2179 } 2180 2181 2182 // Always process body 2183 body.accept(this); 2184 2185 if (hasScope) { 2186 // Ensure we always close the WithObject 2187 final Label endLabel = new Label("with_end"); 2188 final Label catchLabel = new Label("with_catch"); 2189 final Label exitLabel = new Label("with_exit"); 2190 2191 if (!body.isTerminal()) { 2192 closeWith(); 2193 method._goto(exitLabel); 2194 } 2195 2196 method.label(endLabel); 2197 2198 method._catch(catchLabel); 3238 3239 private MethodEmitter globalAllocateArguments() { 3240 return method.invokestatic(GLOBAL_OBJECT, "allocateArguments", methodDescriptor(ScriptObject.class, Object[].class, Object.class, int.class)); 3241 } 3242 3243 private MethodEmitter globalNewRegExp() { 3244 return method.invokestatic(GLOBAL_OBJECT, "newRegExp", methodDescriptor(Object.class, String.class, String.class)); 3245 } 3246 3247 private MethodEmitter globalRegExpCopy() { 3248 return method.invokestatic(GLOBAL_OBJECT, "regExpCopy", methodDescriptor(Object.class, Object.class)); 3249 } 3250 3251 private MethodEmitter globalAllocateArray(final ArrayType type) { 3252 //make sure the native array is treated as an array type 3253 return method.invokestatic(GLOBAL_OBJECT, "allocate", "(" + type.getDescriptor() + ")Ljdk/nashorn/internal/objects/NativeArray;"); 3254 } 3255 3256 private MethodEmitter globalIsEval() { 3257 return method.invokestatic(GLOBAL_OBJECT, "isEval", methodDescriptor(boolean.class, Object.class)); 3258 } 3259 3260 private MethodEmitter globalDirectEval() { 3261 return method.invokestatic(GLOBAL_OBJECT, "directEval", 3262 methodDescriptor(Object.class, Object.class, Object.class, Object.class, Object.class, Object.class)); 3263 } 3264 } | 2157 // for its side effect and visit the body, and not bother opening and closing a WithObject. 2158 final boolean hasScope = method.hasScope(); 2159 2160 final Label tryLabel; 2161 if (hasScope) { 2162 tryLabel = new Label("with_try"); 2163 method.label(tryLabel); 2164 method.loadCompilerConstant(SCOPE); 2165 } else { 2166 tryLabel = null; 2167 } 2168 2169 load(expression); 2170 assert expression.getType().isObject() : "with expression needs to be object: " + expression; 2171 2172 if (hasScope) { 2173 // Construct a WithObject if we have a scope 2174 method.invoke(ScriptRuntime.OPEN_WITH); 2175 method.storeCompilerConstant(SCOPE); 2176 } else { 2177 // We just loaded the expression for its side effect and to check 2178 // for null or undefined value. 2179 globalCheckObjectCoercible(); 2180 } 2181 2182 2183 // Always process body 2184 body.accept(this); 2185 2186 if (hasScope) { 2187 // Ensure we always close the WithObject 2188 final Label endLabel = new Label("with_end"); 2189 final Label catchLabel = new Label("with_catch"); 2190 final Label exitLabel = new Label("with_exit"); 2191 2192 if (!body.isTerminal()) { 2193 closeWith(); 2194 method._goto(exitLabel); 2195 } 2196 2197 method.label(endLabel); 2198 2199 method._catch(catchLabel); 3239 3240 private MethodEmitter globalAllocateArguments() { 3241 return method.invokestatic(GLOBAL_OBJECT, "allocateArguments", methodDescriptor(ScriptObject.class, Object[].class, Object.class, int.class)); 3242 } 3243 3244 private MethodEmitter globalNewRegExp() { 3245 return method.invokestatic(GLOBAL_OBJECT, "newRegExp", methodDescriptor(Object.class, String.class, String.class)); 3246 } 3247 3248 private MethodEmitter globalRegExpCopy() { 3249 return method.invokestatic(GLOBAL_OBJECT, "regExpCopy", methodDescriptor(Object.class, Object.class)); 3250 } 3251 3252 private MethodEmitter globalAllocateArray(final ArrayType type) { 3253 //make sure the native array is treated as an array type 3254 return method.invokestatic(GLOBAL_OBJECT, "allocate", "(" + type.getDescriptor() + ")Ljdk/nashorn/internal/objects/NativeArray;"); 3255 } 3256 3257 private MethodEmitter globalIsEval() { 3258 return method.invokestatic(GLOBAL_OBJECT, "isEval", methodDescriptor(boolean.class, Object.class)); 3259 } 3260 3261 private MethodEmitter globalCheckObjectCoercible() { 3262 return method.invokestatic(GLOBAL_OBJECT, "checkObjectCoercible", methodDescriptor(void.class, Object.class)); 3263 } 3264 3265 private MethodEmitter globalDirectEval() { 3266 return method.invokestatic(GLOBAL_OBJECT, "directEval", 3267 methodDescriptor(Object.class, Object.class, Object.class, Object.class, Object.class, Object.class)); 3268 } 3269 } |