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 $delete; | 5 var $delete; |
6 var $functionSourceString; | 6 var $functionSourceString; |
7 var $getIterator; | 7 var $getIterator; |
8 var $getMethod; | 8 var $getMethod; |
9 var $globalEval; | 9 var $globalEval; |
10 var $installConstants; | 10 var $installConstants; |
(...skipping 14 matching lines...) Expand all Loading... |
25 var $objectLookupGetter; | 25 var $objectLookupGetter; |
26 var $objectLookupSetter; | 26 var $objectLookupSetter; |
27 var $objectToString; | 27 var $objectToString; |
28 var $overrideFunction; | 28 var $overrideFunction; |
29 var $ownPropertyKeys; | 29 var $ownPropertyKeys; |
30 var $setFunctionName; | 30 var $setFunctionName; |
31 var $setUpLockedPrototype; | 31 var $setUpLockedPrototype; |
32 var $toCompletePropertyDescriptor; | 32 var $toCompletePropertyDescriptor; |
33 var $toNameArray; | 33 var $toNameArray; |
34 | 34 |
35 (function() { | 35 (function(global, shared, exports) { |
36 | 36 |
37 %CheckIsBootstrapping(); | 37 %CheckIsBootstrapping(); |
38 | 38 |
39 var GlobalArray = global.Array; | 39 var GlobalArray = global.Array; |
40 var GlobalBoolean = global.Boolean; | 40 var GlobalBoolean = global.Boolean; |
41 var GlobalFunction = global.Function; | 41 var GlobalFunction = global.Function; |
42 var GlobalNumber = global.Number; | 42 var GlobalNumber = global.Number; |
43 var GlobalObject = global.Object; | 43 var GlobalObject = global.Object; |
44 | 44 |
45 // ---------------------------------------------------------------------------- | 45 // ---------------------------------------------------------------------------- |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 function GlobalParseFloat(string) { | 205 function GlobalParseFloat(string) { |
206 string = TO_STRING_INLINE(string); | 206 string = TO_STRING_INLINE(string); |
207 if (%_HasCachedArrayIndex(string)) return %_GetCachedArrayIndex(string); | 207 if (%_HasCachedArrayIndex(string)) return %_GetCachedArrayIndex(string); |
208 return %StringParseFloat(string); | 208 return %StringParseFloat(string); |
209 } | 209 } |
210 | 210 |
211 | 211 |
212 function GlobalEval(x) { | 212 function GlobalEval(x) { |
213 if (!IS_STRING(x)) return x; | 213 if (!IS_STRING(x)) return x; |
214 | 214 |
215 var global_proxy = %GlobalProxy(global); | 215 var global_proxy = %GlobalProxy(GlobalEval); |
216 | 216 |
217 var f = %CompileString(x, false); | 217 var f = %CompileString(x, false); |
218 if (!IS_FUNCTION(f)) return f; | 218 if (!IS_FUNCTION(f)) return f; |
219 | 219 |
220 return %_CallFunction(global_proxy, f); | 220 return %_CallFunction(global_proxy, f); |
221 } | 221 } |
222 | 222 |
223 | 223 |
224 // ---------------------------------------------------------------------------- | 224 // ---------------------------------------------------------------------------- |
225 | 225 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 return IS_UNDEFINED(desc) ? false : desc.isEnumerable(); | 315 return IS_UNDEFINED(desc) ? false : desc.isEnumerable(); |
316 } | 316 } |
317 return %IsPropertyEnumerable(TO_OBJECT_INLINE(this), P); | 317 return %IsPropertyEnumerable(TO_OBJECT_INLINE(this), P); |
318 } | 318 } |
319 | 319 |
320 | 320 |
321 // Extensions for providing property getters and setters. | 321 // Extensions for providing property getters and setters. |
322 function ObjectDefineGetter(name, fun) { | 322 function ObjectDefineGetter(name, fun) { |
323 var receiver = this; | 323 var receiver = this; |
324 if (receiver == null && !IS_UNDETECTABLE(receiver)) { | 324 if (receiver == null && !IS_UNDETECTABLE(receiver)) { |
325 receiver = %GlobalProxy(global); | 325 receiver = %GlobalProxy(ObjectDefineGetter); |
326 } | 326 } |
327 if (!IS_SPEC_FUNCTION(fun)) { | 327 if (!IS_SPEC_FUNCTION(fun)) { |
328 throw MakeTypeError(kObjectGetterExpectingFunction); | 328 throw MakeTypeError(kObjectGetterExpectingFunction); |
329 } | 329 } |
330 var desc = new PropertyDescriptor(); | 330 var desc = new PropertyDescriptor(); |
331 desc.setGet(fun); | 331 desc.setGet(fun); |
332 desc.setEnumerable(true); | 332 desc.setEnumerable(true); |
333 desc.setConfigurable(true); | 333 desc.setConfigurable(true); |
334 DefineOwnProperty(TO_OBJECT_INLINE(receiver), $toName(name), desc, false); | 334 DefineOwnProperty(TO_OBJECT_INLINE(receiver), $toName(name), desc, false); |
335 } | 335 } |
336 | 336 |
337 | 337 |
338 function ObjectLookupGetter(name) { | 338 function ObjectLookupGetter(name) { |
339 var receiver = this; | 339 var receiver = this; |
340 if (receiver == null && !IS_UNDETECTABLE(receiver)) { | 340 if (receiver == null && !IS_UNDETECTABLE(receiver)) { |
341 receiver = %GlobalProxy(global); | 341 receiver = %GlobalProxy(ObjectLookupGetter); |
342 } | 342 } |
343 return %LookupAccessor(TO_OBJECT_INLINE(receiver), $toName(name), GETTER); | 343 return %LookupAccessor(TO_OBJECT_INLINE(receiver), $toName(name), GETTER); |
344 } | 344 } |
345 | 345 |
346 | 346 |
347 function ObjectDefineSetter(name, fun) { | 347 function ObjectDefineSetter(name, fun) { |
348 var receiver = this; | 348 var receiver = this; |
349 if (receiver == null && !IS_UNDETECTABLE(receiver)) { | 349 if (receiver == null && !IS_UNDETECTABLE(receiver)) { |
350 receiver = %GlobalProxy(global); | 350 receiver = %GlobalProxy(ObjectDefineSetter); |
351 } | 351 } |
352 if (!IS_SPEC_FUNCTION(fun)) { | 352 if (!IS_SPEC_FUNCTION(fun)) { |
353 throw MakeTypeError(kObjectSetterExpectingFunction); | 353 throw MakeTypeError(kObjectSetterExpectingFunction); |
354 } | 354 } |
355 var desc = new PropertyDescriptor(); | 355 var desc = new PropertyDescriptor(); |
356 desc.setSet(fun); | 356 desc.setSet(fun); |
357 desc.setEnumerable(true); | 357 desc.setEnumerable(true); |
358 desc.setConfigurable(true); | 358 desc.setConfigurable(true); |
359 DefineOwnProperty(TO_OBJECT_INLINE(receiver), $toName(name), desc, false); | 359 DefineOwnProperty(TO_OBJECT_INLINE(receiver), $toName(name), desc, false); |
360 } | 360 } |
361 | 361 |
362 | 362 |
363 function ObjectLookupSetter(name) { | 363 function ObjectLookupSetter(name) { |
364 var receiver = this; | 364 var receiver = this; |
365 if (receiver == null && !IS_UNDETECTABLE(receiver)) { | 365 if (receiver == null && !IS_UNDETECTABLE(receiver)) { |
366 receiver = %GlobalProxy(global); | 366 receiver = %GlobalProxy(ObjectLookupSetter); |
367 } | 367 } |
368 return %LookupAccessor(TO_OBJECT_INLINE(receiver), $toName(name), SETTER); | 368 return %LookupAccessor(TO_OBJECT_INLINE(receiver), $toName(name), SETTER); |
369 } | 369 } |
370 | 370 |
371 | 371 |
372 function ObjectKeys(obj) { | 372 function ObjectKeys(obj) { |
373 obj = TO_OBJECT_INLINE(obj); | 373 obj = TO_OBJECT_INLINE(obj); |
374 if (%_IsJSProxy(obj)) { | 374 if (%_IsJSProxy(obj)) { |
375 var handler = %GetHandler(obj); | 375 var handler = %GetHandler(obj); |
376 var names = CallTrap0(handler, "keys", $proxyDerivedKeysTrap); | 376 var names = CallTrap0(handler, "keys", $proxyDerivedKeysTrap); |
(...skipping 1509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1886 // comments we can include a trailing block comment to catch this. | 1886 // comments we can include a trailing block comment to catch this. |
1887 p += '\n/' + '**/'; | 1887 p += '\n/' + '**/'; |
1888 } | 1888 } |
1889 var body = (n > 0) ? $toString(args[n - 1]) : ''; | 1889 var body = (n > 0) ? $toString(args[n - 1]) : ''; |
1890 return '(' + function_token + '(' + p + ') {\n' + body + '\n})'; | 1890 return '(' + function_token + '(' + p + ') {\n' + body + '\n})'; |
1891 } | 1891 } |
1892 | 1892 |
1893 | 1893 |
1894 function FunctionConstructor(arg1) { // length == 1 | 1894 function FunctionConstructor(arg1) { // length == 1 |
1895 var source = NewFunctionString(arguments, 'function'); | 1895 var source = NewFunctionString(arguments, 'function'); |
1896 var global_proxy = %GlobalProxy(global); | 1896 var global_proxy = %GlobalProxy(FunctionConstructor); |
1897 // Compile the string in the constructor and not a helper so that errors | 1897 // Compile the string in the constructor and not a helper so that errors |
1898 // appear to come from here. | 1898 // appear to come from here. |
1899 var f = %_CallFunction(global_proxy, %CompileString(source, true)); | 1899 var f = %_CallFunction(global_proxy, %CompileString(source, true)); |
1900 %FunctionMarkNameShouldPrintAsAnonymous(f); | 1900 %FunctionMarkNameShouldPrintAsAnonymous(f); |
1901 return f; | 1901 return f; |
1902 } | 1902 } |
1903 | 1903 |
1904 | 1904 |
1905 // ---------------------------------------------------------------------------- | 1905 // ---------------------------------------------------------------------------- |
1906 | 1906 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1957 $objectLookupGetter = ObjectLookupGetter; | 1957 $objectLookupGetter = ObjectLookupGetter; |
1958 $objectLookupSetter = ObjectLookupSetter; | 1958 $objectLookupSetter = ObjectLookupSetter; |
1959 $objectToString = ObjectToString; | 1959 $objectToString = ObjectToString; |
1960 $overrideFunction = OverrideFunction; | 1960 $overrideFunction = OverrideFunction; |
1961 $ownPropertyKeys = OwnPropertyKeys; | 1961 $ownPropertyKeys = OwnPropertyKeys; |
1962 $setFunctionName = SetFunctionName; | 1962 $setFunctionName = SetFunctionName; |
1963 $setUpLockedPrototype = SetUpLockedPrototype; | 1963 $setUpLockedPrototype = SetUpLockedPrototype; |
1964 $toCompletePropertyDescriptor = ToCompletePropertyDescriptor; | 1964 $toCompletePropertyDescriptor = ToCompletePropertyDescriptor; |
1965 $toNameArray = ToNameArray; | 1965 $toNameArray = ToNameArray; |
1966 | 1966 |
1967 })(); | 1967 }) |
OLD | NEW |