| OLD | NEW | 
|---|
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without | 
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are | 
| 4 // met: | 4 // met: | 
| 5 // | 5 // | 
| 6 //     * Redistributions of source code must retain the above copyright | 6 //     * Redistributions of source code must retain the above copyright | 
| 7 //       notice, this list of conditions and the following disclaimer. | 7 //       notice, this list of conditions and the following disclaimer. | 
| 8 //     * Redistributions in binary form must reproduce the above | 8 //     * Redistributions in binary form must reproduce the above | 
| 9 //       copyright notice, this list of conditions and the following | 9 //       copyright notice, this list of conditions and the following | 
| 10 //       disclaimer in the documentation and/or other materials provided | 10 //       disclaimer in the documentation and/or other materials provided | 
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 49 function InstallFunctions(object, attributes, functions) { | 49 function InstallFunctions(object, attributes, functions) { | 
| 50   if (functions.length >= 8) { | 50   if (functions.length >= 8) { | 
| 51     %OptimizeObjectForAddingMultipleProperties(object, functions.length >> 1); | 51     %OptimizeObjectForAddingMultipleProperties(object, functions.length >> 1); | 
| 52   } | 52   } | 
| 53   for (var i = 0; i < functions.length; i += 2) { | 53   for (var i = 0; i < functions.length; i += 2) { | 
| 54     var key = functions[i]; | 54     var key = functions[i]; | 
| 55     var f = functions[i + 1]; | 55     var f = functions[i + 1]; | 
| 56     %FunctionSetName(f, key); | 56     %FunctionSetName(f, key); | 
| 57     %FunctionRemovePrototype(f); | 57     %FunctionRemovePrototype(f); | 
| 58     %SetProperty(object, key, f, attributes); | 58     %SetProperty(object, key, f, attributes); | 
| 59     %SetNativeFlag(f); | 59     %SetES5Flag(f); | 
| 60   } | 60   } | 
| 61   %ToFastProperties(object); | 61   %ToFastProperties(object); | 
| 62 } | 62 } | 
| 63 | 63 | 
| 64 // Emulates JSC by installing functions on a hidden prototype that | 64 // Emulates JSC by installing functions on a hidden prototype that | 
| 65 // lies above the current object/prototype.  This lets you override | 65 // lies above the current object/prototype.  This lets you override | 
| 66 // functions on String.prototype etc. and then restore the old function | 66 // functions on String.prototype etc. and then restore the old function | 
| 67 // with delete.  See http://code.google.com/p/chromium/issues/detail?id=1717 | 67 // with delete.  See http://code.google.com/p/chromium/issues/detail?id=1717 | 
| 68 function InstallFunctionsOnHiddenPrototype(object, attributes, functions) { | 68 function InstallFunctionsOnHiddenPrototype(object, attributes, functions) { | 
| 69   var hidden_prototype = new $Object(); | 69   var hidden_prototype = new $Object(); | 
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 125 function GlobalParseFloat(string) { | 125 function GlobalParseFloat(string) { | 
| 126   string = TO_STRING_INLINE(string); | 126   string = TO_STRING_INLINE(string); | 
| 127   if (%_HasCachedArrayIndex(string)) return %_GetCachedArrayIndex(string); | 127   if (%_HasCachedArrayIndex(string)) return %_GetCachedArrayIndex(string); | 
| 128   return %StringParseFloat(string); | 128   return %StringParseFloat(string); | 
| 129 } | 129 } | 
| 130 | 130 | 
| 131 | 131 | 
| 132 function GlobalEval(x) { | 132 function GlobalEval(x) { | 
| 133   if (!IS_STRING(x)) return x; | 133   if (!IS_STRING(x)) return x; | 
| 134 | 134 | 
| 135   var receiver = this; |  | 
| 136   var global_receiver = %GlobalReceiver(global); | 135   var global_receiver = %GlobalReceiver(global); | 
| 137 | 136   var this_is_global_receiver = (this === global_receiver); | 
| 138   if (receiver == null && !IS_UNDETECTABLE(receiver)) { |  | 
| 139     receiver = global_receiver; |  | 
| 140   } |  | 
| 141 |  | 
| 142   var this_is_global_receiver = (receiver === global_receiver); |  | 
| 143   var global_is_detached = (global === global_receiver); | 137   var global_is_detached = (global === global_receiver); | 
| 144 | 138 | 
| 145   // For consistency with JSC we require the global object passed to |  | 
| 146   // eval to be the global object from which 'eval' originated. This |  | 
| 147   // is not mandated by the spec. |  | 
| 148   if (!this_is_global_receiver || global_is_detached) { | 139   if (!this_is_global_receiver || global_is_detached) { | 
| 149     throw new $EvalError('The "this" object passed to eval must ' + | 140     throw new $EvalError('The "this" object passed to eval must ' + | 
| 150                          'be the global object from which eval originated'); | 141                          'be the global object from which eval originated'); | 
| 151   } | 142   } | 
| 152 | 143 | 
| 153   var f = %CompileString(x); | 144   var f = %CompileString(x); | 
| 154   if (!IS_FUNCTION(f)) return f; | 145   if (!IS_FUNCTION(f)) return f; | 
| 155 | 146 | 
| 156   return %_CallFunction(receiver, f); | 147   return %_CallFunction(this, f); | 
| 157 } | 148 } | 
| 158 | 149 | 
| 159 | 150 | 
| 160 // ---------------------------------------------------------------------------- | 151 // ---------------------------------------------------------------------------- | 
| 161 | 152 | 
| 162 | 153 | 
| 163 function SetupGlobal() { | 154 function SetupGlobal() { | 
| 164   // ECMA 262 - 15.1.1.1. | 155   // ECMA 262 - 15.1.1.1. | 
| 165   %SetProperty(global, "NaN", $NaN, DONT_ENUM | DONT_DELETE); | 156   %SetProperty(global, "NaN", $NaN, DONT_ENUM | DONT_DELETE); | 
| 166 | 157 | 
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 248 | 239 | 
| 249 | 240 | 
| 250 // ECMA-262 - 15.2.4.6 | 241 // ECMA-262 - 15.2.4.6 | 
| 251 function ObjectPropertyIsEnumerable(V) { | 242 function ObjectPropertyIsEnumerable(V) { | 
| 252   return %IsPropertyEnumerable(ToObject(this), ToString(V)); | 243   return %IsPropertyEnumerable(ToObject(this), ToString(V)); | 
| 253 } | 244 } | 
| 254 | 245 | 
| 255 | 246 | 
| 256 // Extensions for providing property getters and setters. | 247 // Extensions for providing property getters and setters. | 
| 257 function ObjectDefineGetter(name, fun) { | 248 function ObjectDefineGetter(name, fun) { | 
| 258   var receiver = this; | 249   if (this == null && !IS_UNDETECTABLE(this)) { | 
| 259   if (receiver == null && !IS_UNDETECTABLE(receiver)) { | 250     throw new $TypeError('Object.prototype.__defineGetter__: this is Null'); | 
| 260     receiver = %GlobalReceiver(global); |  | 
| 261   } | 251   } | 
| 262   if (!IS_FUNCTION(fun)) { | 252   if (!IS_FUNCTION(fun)) { | 
| 263     throw new $TypeError('Object.prototype.__defineGetter__: Expecting function'
      ); | 253     throw new $TypeError('Object.prototype.__defineGetter__: Expecting function'
      ); | 
| 264   } | 254   } | 
| 265   var desc = new PropertyDescriptor(); | 255   var desc = new PropertyDescriptor(); | 
| 266   desc.setGet(fun); | 256   desc.setGet(fun); | 
| 267   desc.setEnumerable(true); | 257   desc.setEnumerable(true); | 
| 268   desc.setConfigurable(true); | 258   desc.setConfigurable(true); | 
| 269   DefineOwnProperty(ToObject(receiver), ToString(name), desc, false); | 259   DefineOwnProperty(ToObject(this), ToString(name), desc, false); | 
| 270 } | 260 } | 
| 271 | 261 | 
| 272 | 262 | 
| 273 function ObjectLookupGetter(name) { | 263 function ObjectLookupGetter(name) { | 
| 274   var receiver = this; | 264   if (this == null && !IS_UNDETECTABLE(this)) { | 
| 275   if (receiver == null && !IS_UNDETECTABLE(receiver)) { | 265     throw new $TypeError('Object.prototype.__lookupGetter__: this is Null'); | 
| 276     receiver = %GlobalReceiver(global); |  | 
| 277   } | 266   } | 
| 278   return %LookupAccessor(ToObject(receiver), ToString(name), GETTER); | 267   return %LookupAccessor(ToObject(this), ToString(name), GETTER); | 
| 279 } | 268 } | 
| 280 | 269 | 
| 281 | 270 | 
| 282 function ObjectDefineSetter(name, fun) { | 271 function ObjectDefineSetter(name, fun) { | 
| 283   var receiver = this; | 272   if (this == null && !IS_UNDETECTABLE(this)) { | 
| 284   if (receiver == null && !IS_UNDETECTABLE(receiver)) { | 273     throw new $TypeError('Object.prototype.__defineSetter__: this is Null'); | 
| 285     receiver = %GlobalReceiver(global); |  | 
| 286   } | 274   } | 
| 287   if (!IS_FUNCTION(fun)) { | 275   if (!IS_FUNCTION(fun)) { | 
| 288     throw new $TypeError( | 276     throw new $TypeError( | 
| 289         'Object.prototype.__defineSetter__: Expecting function'); | 277         'Object.prototype.__defineSetter__: Expecting function'); | 
| 290   } | 278   } | 
| 291   var desc = new PropertyDescriptor(); | 279   var desc = new PropertyDescriptor(); | 
| 292   desc.setSet(fun); | 280   desc.setSet(fun); | 
| 293   desc.setEnumerable(true); | 281   desc.setEnumerable(true); | 
| 294   desc.setConfigurable(true); | 282   desc.setConfigurable(true); | 
| 295   DefineOwnProperty(ToObject(receiver), ToString(name), desc, false); | 283   DefineOwnProperty(ToObject(this), ToString(name), desc, false); | 
| 296 } | 284 } | 
| 297 | 285 | 
| 298 | 286 | 
| 299 function ObjectLookupSetter(name) { | 287 function ObjectLookupSetter(name) { | 
| 300   var receiver = this; | 288   if (this == null && !IS_UNDETECTABLE(this)) { | 
| 301   if (receiver == null && !IS_UNDETECTABLE(receiver)) { | 289     throw new $TypeError('Object.prototype.__lookupSetter__: this is Null'); | 
| 302     receiver = %GlobalReceiver(global); |  | 
| 303   } | 290   } | 
| 304   return %LookupAccessor(ToObject(receiver), ToString(name), SETTER); | 291   return %LookupAccessor(ToObject(this), ToString(name), SETTER); | 
| 305 } | 292 } | 
| 306 | 293 | 
| 307 | 294 | 
| 308 function ObjectKeys(obj) { | 295 function ObjectKeys(obj) { | 
| 309   if (!IS_SPEC_OBJECT(obj)) | 296   if (!IS_SPEC_OBJECT(obj)) | 
| 310     throw MakeTypeError("obj_ctor_property_non_object", ["keys"]); | 297     throw MakeTypeError("obj_ctor_property_non_object", ["keys"]); | 
| 311   return %LocalKeys(obj); | 298   return %LocalKeys(obj); | 
| 312 } | 299 } | 
| 313 | 300 | 
| 314 | 301 | 
| (...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1314 // ---------------------------------------------------------------------------- | 1301 // ---------------------------------------------------------------------------- | 
| 1315 | 1302 | 
| 1316 function SetupFunction() { | 1303 function SetupFunction() { | 
| 1317   InstallFunctions($Function.prototype, DONT_ENUM, $Array( | 1304   InstallFunctions($Function.prototype, DONT_ENUM, $Array( | 
| 1318     "bind", FunctionBind, | 1305     "bind", FunctionBind, | 
| 1319     "toString", FunctionToString | 1306     "toString", FunctionToString | 
| 1320   )); | 1307   )); | 
| 1321 } | 1308 } | 
| 1322 | 1309 | 
| 1323 SetupFunction(); | 1310 SetupFunction(); | 
| OLD | NEW | 
|---|