Changeset 69516 in webkit for trunk/JavaScriptCore/runtime/JSFunction.cpp
- Timestamp:
- Oct 11, 2010, 12:12:29 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/JSFunction.cpp
r65104 r69516 123 123 } 124 124 125 static const char* StrictModeCallerAccessError = "Cannot access caller property of a strict mode function"; 126 static const char* StrictModeArgumentsAccessError = "Cannot access arguments property of a strict mode function"; 127 128 static void createDescriptorForThrowingProperty(ExecState* exec, PropertyDescriptor& descriptor, const char* message) 129 { 130 JSValue thrower = createTypeErrorFunction(exec, message); 131 descriptor.setAccessorDescriptor(thrower, thrower, DontEnum | DontDelete | Getter | Setter); 132 } 133 125 134 const UString& JSFunction::name(ExecState* exec) 126 135 { … … 210 219 211 220 if (propertyName == exec->propertyNames().arguments) { 221 if (jsExecutable()->isStrictMode()) { 222 throwTypeError(exec, "Can't access arguments object of a strict mode function"); 223 slot.setValue(jsNull()); 224 return true; 225 } 226 212 227 slot.setCacheableCustom(this, argumentsGetter); 213 228 return true; … … 220 235 221 236 if (propertyName == exec->propertyNames().caller) { 237 if (jsExecutable()->isStrictMode()) { 238 throwTypeError(exec, StrictModeCallerAccessError); 239 slot.setValue(jsNull()); 240 return true; 241 } 222 242 slot.setCacheableCustom(this, callerGetter); 223 243 return true; … … 227 247 } 228 248 229 bool JSFunction::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) 230 { 231 if (isHostFunction()) 232 return Base::getOwnPropertyDescriptor(exec, propertyName, descriptor); 233 234 if (propertyName == exec->propertyNames().prototype) { 235 PropertySlot slot; 236 getOwnPropertySlot(exec, propertyName, slot); 237 return Base::getOwnPropertyDescriptor(exec, propertyName, descriptor); 238 } 239 240 if (propertyName == exec->propertyNames().arguments) { 249 bool JSFunction::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) 250 { 251 if (isHostFunction()) 252 return Base::getOwnPropertyDescriptor(exec, propertyName, descriptor); 253 254 if (propertyName == exec->propertyNames().prototype) { 255 PropertySlot slot; 256 getOwnPropertySlot(exec, propertyName, slot); 257 return Base::getOwnPropertyDescriptor(exec, propertyName, descriptor); 258 } 259 260 if (propertyName == exec->propertyNames().arguments) { 261 if (jsExecutable()->isStrictMode()) 262 createDescriptorForThrowingProperty(exec, descriptor, StrictModeArgumentsAccessError); 263 else 241 264 descriptor.setDescriptor(exec->interpreter()->retrieveArguments(exec, this), ReadOnly | DontEnum | DontDelete); 242 return true; 243 } 244 245 if (propertyName == exec->propertyNames().length) { 246 descriptor.setDescriptor(jsNumber(exec, jsExecutable()->parameterCount()), ReadOnly | DontEnum | DontDelete); 247 return true; 248 } 249 250 if (propertyName == exec->propertyNames().caller) { 265 return true; 266 } 267 268 if (propertyName == exec->propertyNames().length) { 269 descriptor.setDescriptor(jsNumber(exec, jsExecutable()->parameterCount()), ReadOnly | DontEnum | DontDelete); 270 return true; 271 } 272 273 if (propertyName == exec->propertyNames().caller) { 274 if (jsExecutable()->isStrictMode()) 275 createDescriptorForThrowingProperty(exec, descriptor, StrictModeCallerAccessError); 276 else 251 277 descriptor.setDescriptor(exec->interpreter()->retrieveCaller(exec, this), ReadOnly | DontEnum | DontDelete); 252 253 254 255 256 257 278 return true; 279 } 280 281 return Base::getOwnPropertyDescriptor(exec, propertyName, descriptor); 282 } 283 258 284 void JSFunction::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode) 259 285 { … … 273 299 return; 274 300 } 301 if (jsExecutable()->isStrictMode()) { 302 if (propertyName == exec->propertyNames().arguments) { 303 throwTypeError(exec, StrictModeArgumentsAccessError); 304 return; 305 } 306 if (propertyName == exec->propertyNames().caller) { 307 throwTypeError(exec, StrictModeCallerAccessError); 308 return; 309 } 310 } 275 311 if (propertyName == exec->propertyNames().arguments || propertyName == exec->propertyNames().length) 276 312 return;
Note:
See TracChangeset
for help on using the changeset viewer.