Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: src/symbol.js

Issue 1126213002: Wrap runtime.js in a function. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/string-iterator.js ('k') | src/typedarray.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 // Expects following symbols to be set in the bootstrapper during genesis: 5 // Expects following symbols to be set in the bootstrapper during genesis:
6 // - symbolHasInstance 6 // - symbolHasInstance
7 // - symbolIsConcatSpreadable 7 // - symbolIsConcatSpreadable
8 // - symbolIsRegExp 8 // - symbolIsRegExp
9 // - symbolIterator 9 // - symbolIterator
10 // - symbolToStringTag 10 // - symbolToStringTag
11 // - symbolUnscopables 11 // - symbolUnscopables
12 12
13 var $symbolToString; 13 var $symbolToString;
14 14
15 (function() { 15 (function() {
16 16
17 "use strict"; 17 "use strict";
18 18
19 %CheckIsBootstrapping(); 19 %CheckIsBootstrapping();
20 20
21 var GlobalObject = global.Object; 21 var GlobalObject = global.Object;
22 var GlobalSymbol = global.Symbol; 22 var GlobalSymbol = global.Symbol;
23 23
24 // ------------------------------------------------------------------- 24 // -------------------------------------------------------------------
25 25
26 function SymbolConstructor(x) { 26 function SymbolConstructor(x) {
27 if (%_IsConstructCall()) throw MakeTypeError(kNotConstructor, "Symbol"); 27 if (%_IsConstructCall()) throw MakeTypeError(kNotConstructor, "Symbol");
28 // NOTE: Passing in a Symbol value will throw on ToString(). 28 // NOTE: Passing in a Symbol value will throw on ToString().
29 return %CreateSymbol(IS_UNDEFINED(x) ? x : ToString(x)); 29 return %CreateSymbol(IS_UNDEFINED(x) ? x : $toString(x));
30 } 30 }
31 31
32 32
33 function SymbolToString() { 33 function SymbolToString() {
34 if (!(IS_SYMBOL(this) || IS_SYMBOL_WRAPPER(this))) { 34 if (!(IS_SYMBOL(this) || IS_SYMBOL_WRAPPER(this))) {
35 throw MakeTypeError(kIncompatibleMethodReceiver, 35 throw MakeTypeError(kIncompatibleMethodReceiver,
36 "Symbol.prototype.toString", this); 36 "Symbol.prototype.toString", this);
37 } 37 }
38 var description = %SymbolDescription(%_ValueOf(this)); 38 var description = %SymbolDescription(%_ValueOf(this));
39 return "Symbol(" + (IS_UNDEFINED(description) ? "" : description) + ")"; 39 return "Symbol(" + (IS_UNDEFINED(description) ? "" : description) + ")";
(...skipping 22 matching lines...) Expand all
62 62
63 63
64 function SymbolKeyFor(symbol) { 64 function SymbolKeyFor(symbol) {
65 if (!IS_SYMBOL(symbol)) throw MakeTypeError("not_a_symbol", [symbol]); 65 if (!IS_SYMBOL(symbol)) throw MakeTypeError("not_a_symbol", [symbol]);
66 return %SymbolRegistry().keyFor[symbol]; 66 return %SymbolRegistry().keyFor[symbol];
67 } 67 }
68 68
69 69
70 // ES6 19.1.2.8 70 // ES6 19.1.2.8
71 function ObjectGetOwnPropertySymbols(obj) { 71 function ObjectGetOwnPropertySymbols(obj) {
72 obj = ToObject(obj); 72 obj = $toObject(obj);
73 73
74 // TODO(arv): Proxies use a shared trap for String and Symbol keys. 74 // TODO(arv): Proxies use a shared trap for String and Symbol keys.
75 75
76 return $objectGetOwnPropertyKeys(obj, PROPERTY_ATTRIBUTES_STRING); 76 return $objectGetOwnPropertyKeys(obj, PROPERTY_ATTRIBUTES_STRING);
77 } 77 }
78 78
79 //------------------------------------------------------------------- 79 //-------------------------------------------------------------------
80 80
81 %SetCode(GlobalSymbol, SymbolConstructor); 81 %SetCode(GlobalSymbol, SymbolConstructor);
82 %FunctionSetPrototype(GlobalSymbol, new GlobalObject()); 82 %FunctionSetPrototype(GlobalSymbol, new GlobalObject());
(...skipping 25 matching lines...) Expand all
108 "valueOf", SymbolValueOf 108 "valueOf", SymbolValueOf
109 ]); 109 ]);
110 110
111 $installFunctions(GlobalObject, DONT_ENUM, [ 111 $installFunctions(GlobalObject, DONT_ENUM, [
112 "getOwnPropertySymbols", ObjectGetOwnPropertySymbols 112 "getOwnPropertySymbols", ObjectGetOwnPropertySymbols
113 ]); 113 ]);
114 114
115 $symbolToString = SymbolToString; 115 $symbolToString = SymbolToString;
116 116
117 })(); 117 })();
OLDNEW
« no previous file with comments | « src/string-iterator.js ('k') | src/typedarray.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698