OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 var $functionSourceString; | 5 var $functionSourceString; |
6 var $globalEval; | 6 var $globalEval; |
7 var $objectDefineOwnProperty; | 7 var $objectDefineOwnProperty; |
8 var $objectGetOwnPropertyDescriptor; | 8 var $objectGetOwnPropertyDescriptor; |
9 var $toCompletePropertyDescriptor; | 9 var $toCompletePropertyDescriptor; |
10 | 10 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 "parseFloat", GlobalParseFloat, | 132 "parseFloat", GlobalParseFloat, |
133 "eval", GlobalEval | 133 "eval", GlobalEval |
134 ]); | 134 ]); |
135 | 135 |
136 | 136 |
137 // ---------------------------------------------------------------------------- | 137 // ---------------------------------------------------------------------------- |
138 // Object | 138 // Object |
139 | 139 |
140 // ECMA-262 - 15.2.4.2 | 140 // ECMA-262 - 15.2.4.2 |
141 function ObjectToString() { | 141 function ObjectToString() { |
142 if (IS_UNDEFINED(this) && !IS_UNDETECTABLE(this)) return "[object Undefined]"; | 142 if (IS_UNDEFINED(this)) return "[object Undefined]"; |
143 if (IS_NULL(this)) return "[object Null]"; | 143 if (IS_NULL(this)) return "[object Null]"; |
144 var O = TO_OBJECT(this); | 144 var O = TO_OBJECT(this); |
145 var builtinTag = %_ClassOf(O); | 145 var builtinTag = %_ClassOf(O); |
146 var tag; | 146 var tag; |
147 | 147 |
148 // TODO(caitp): cannot wait to get rid of this flag :> | 148 // TODO(caitp): cannot wait to get rid of this flag :> |
149 if (harmony_tostring) { | 149 if (harmony_tostring) { |
150 tag = O[symbolToStringTag]; | 150 tag = O[symbolToStringTag]; |
151 if (!IS_STRING(tag)) { | 151 if (!IS_STRING(tag)) { |
152 tag = builtinTag; | 152 tag = builtinTag; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 var desc = GetOwnPropertyJS(this, P); | 206 var desc = GetOwnPropertyJS(this, P); |
207 return IS_UNDEFINED(desc) ? false : desc.isEnumerable(); | 207 return IS_UNDEFINED(desc) ? false : desc.isEnumerable(); |
208 } | 208 } |
209 return %IsPropertyEnumerable(TO_OBJECT(this), P); | 209 return %IsPropertyEnumerable(TO_OBJECT(this), P); |
210 } | 210 } |
211 | 211 |
212 | 212 |
213 // Extensions for providing property getters and setters. | 213 // Extensions for providing property getters and setters. |
214 function ObjectDefineGetter(name, fun) { | 214 function ObjectDefineGetter(name, fun) { |
215 var receiver = this; | 215 var receiver = this; |
216 if (receiver == null && !IS_UNDETECTABLE(receiver)) { | 216 if (IS_NULL(receiver) || IS_UNDEFINED(receiver)) { |
217 receiver = %GlobalProxy(ObjectDefineGetter); | 217 receiver = %GlobalProxy(ObjectDefineGetter); |
218 } | 218 } |
219 if (!IS_SPEC_FUNCTION(fun)) { | 219 if (!IS_SPEC_FUNCTION(fun)) { |
220 throw MakeTypeError(kObjectGetterExpectingFunction); | 220 throw MakeTypeError(kObjectGetterExpectingFunction); |
221 } | 221 } |
222 var desc = new PropertyDescriptor(); | 222 var desc = new PropertyDescriptor(); |
223 desc.setGet(fun); | 223 desc.setGet(fun); |
224 desc.setEnumerable(true); | 224 desc.setEnumerable(true); |
225 desc.setConfigurable(true); | 225 desc.setConfigurable(true); |
226 DefineOwnProperty(TO_OBJECT(receiver), $toName(name), desc, false); | 226 DefineOwnProperty(TO_OBJECT(receiver), $toName(name), desc, false); |
227 } | 227 } |
228 | 228 |
229 | 229 |
230 function ObjectLookupGetter(name) { | 230 function ObjectLookupGetter(name) { |
231 var receiver = this; | 231 var receiver = this; |
232 if (receiver == null && !IS_UNDETECTABLE(receiver)) { | 232 if (IS_NULL(receiver) || IS_UNDEFINED(receiver)) { |
233 receiver = %GlobalProxy(ObjectLookupGetter); | 233 receiver = %GlobalProxy(ObjectLookupGetter); |
234 } | 234 } |
235 return %LookupAccessor(TO_OBJECT(receiver), $toName(name), GETTER); | 235 return %LookupAccessor(TO_OBJECT(receiver), $toName(name), GETTER); |
236 } | 236 } |
237 | 237 |
238 | 238 |
239 function ObjectDefineSetter(name, fun) { | 239 function ObjectDefineSetter(name, fun) { |
240 var receiver = this; | 240 var receiver = this; |
241 if (receiver == null && !IS_UNDETECTABLE(receiver)) { | 241 if (IS_NULL(receiver) || IS_UNDEFINED(receiver)) { |
242 receiver = %GlobalProxy(ObjectDefineSetter); | 242 receiver = %GlobalProxy(ObjectDefineSetter); |
243 } | 243 } |
244 if (!IS_SPEC_FUNCTION(fun)) { | 244 if (!IS_SPEC_FUNCTION(fun)) { |
245 throw MakeTypeError(kObjectSetterExpectingFunction); | 245 throw MakeTypeError(kObjectSetterExpectingFunction); |
246 } | 246 } |
247 var desc = new PropertyDescriptor(); | 247 var desc = new PropertyDescriptor(); |
248 desc.setSet(fun); | 248 desc.setSet(fun); |
249 desc.setEnumerable(true); | 249 desc.setEnumerable(true); |
250 desc.setConfigurable(true); | 250 desc.setConfigurable(true); |
251 DefineOwnProperty(TO_OBJECT(receiver), $toName(name), desc, false); | 251 DefineOwnProperty(TO_OBJECT(receiver), $toName(name), desc, false); |
252 } | 252 } |
253 | 253 |
254 | 254 |
255 function ObjectLookupSetter(name) { | 255 function ObjectLookupSetter(name) { |
256 var receiver = this; | 256 var receiver = this; |
257 if (receiver == null && !IS_UNDETECTABLE(receiver)) { | 257 if (IS_NULL(receiver) || IS_UNDEFINED(receiver)) { |
258 receiver = %GlobalProxy(ObjectLookupSetter); | 258 receiver = %GlobalProxy(ObjectLookupSetter); |
259 } | 259 } |
260 return %LookupAccessor(TO_OBJECT(receiver), $toName(name), SETTER); | 260 return %LookupAccessor(TO_OBJECT(receiver), $toName(name), SETTER); |
261 } | 261 } |
262 | 262 |
263 | 263 |
264 function ObjectKeys(obj) { | 264 function ObjectKeys(obj) { |
265 obj = TO_OBJECT(obj); | 265 obj = TO_OBJECT(obj); |
266 if (%_IsJSProxy(obj)) { | 266 if (%_IsJSProxy(obj)) { |
267 var handler = %GetHandler(obj); | 267 var handler = %GetHandler(obj); |
(...skipping 1540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1808 to.ObjectGetOwnPropertyKeys = ObjectGetOwnPropertyKeys; | 1808 to.ObjectGetOwnPropertyKeys = ObjectGetOwnPropertyKeys; |
1809 to.ObjectHasOwnProperty = ObjectHasOwnProperty; | 1809 to.ObjectHasOwnProperty = ObjectHasOwnProperty; |
1810 to.ObjectIsFrozen = ObjectIsFrozen; | 1810 to.ObjectIsFrozen = ObjectIsFrozen; |
1811 to.ObjectIsSealed = ObjectIsSealed; | 1811 to.ObjectIsSealed = ObjectIsSealed; |
1812 to.ObjectToString = ObjectToString; | 1812 to.ObjectToString = ObjectToString; |
1813 to.OwnPropertyKeys = OwnPropertyKeys; | 1813 to.OwnPropertyKeys = OwnPropertyKeys; |
1814 to.ToNameArray = ToNameArray; | 1814 to.ToNameArray = ToNameArray; |
1815 }); | 1815 }); |
1816 | 1816 |
1817 }) | 1817 }) |
OLD | NEW |