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

Side by Side Diff: src/collection.js

Issue 280243002: Avoid name clashes of builtins and runtime functions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/builtins.cc ('k') | src/harmony-math.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 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 "use strict"; 5 "use strict";
6 6
7 // This file relies on the fact that the following declaration has been made 7 // This file relies on the fact that the following declaration has been made
8 // in runtime.js: 8 // in runtime.js:
9 // var $Array = global.Array; 9 // var $Array = global.Array;
10 10
(...skipping 25 matching lines...) Expand all
36 36
37 function SetConstructor() { 37 function SetConstructor() {
38 if (%_IsConstructCall()) { 38 if (%_IsConstructCall()) {
39 %SetInitialize(this); 39 %SetInitialize(this);
40 } else { 40 } else {
41 throw MakeTypeError('constructor_not_function', ['Set']); 41 throw MakeTypeError('constructor_not_function', ['Set']);
42 } 42 }
43 } 43 }
44 44
45 45
46 function SetAdd(key) { 46 function SetAddJS(key) {
47 if (!IS_SET(this)) { 47 if (!IS_SET(this)) {
48 throw MakeTypeError('incompatible_method_receiver', 48 throw MakeTypeError('incompatible_method_receiver',
49 ['Set.prototype.add', this]); 49 ['Set.prototype.add', this]);
50 } 50 }
51 return %SetAdd(this, NormalizeKey(key)); 51 return %SetAdd(this, NormalizeKey(key));
52 } 52 }
53 53
54 54
55 function SetHas(key) { 55 function SetHasJS(key) {
56 if (!IS_SET(this)) { 56 if (!IS_SET(this)) {
57 throw MakeTypeError('incompatible_method_receiver', 57 throw MakeTypeError('incompatible_method_receiver',
58 ['Set.prototype.has', this]); 58 ['Set.prototype.has', this]);
59 } 59 }
60 return %SetHas(this, NormalizeKey(key)); 60 return %SetHas(this, NormalizeKey(key));
61 } 61 }
62 62
63 63
64 function SetDelete(key) { 64 function SetDeleteJS(key) {
65 if (!IS_SET(this)) { 65 if (!IS_SET(this)) {
66 throw MakeTypeError('incompatible_method_receiver', 66 throw MakeTypeError('incompatible_method_receiver',
67 ['Set.prototype.delete', this]); 67 ['Set.prototype.delete', this]);
68 } 68 }
69 key = NormalizeKey(key); 69 key = NormalizeKey(key);
70 if (%SetHas(this, key)) { 70 if (%SetHas(this, key)) {
71 %SetDelete(this, key); 71 %SetDelete(this, key);
72 return true; 72 return true;
73 } else { 73 } else {
74 return false; 74 return false;
75 } 75 }
76 } 76 }
77 77
78 78
79 function SetGetSize() { 79 function SetGetSizeJS() {
80 if (!IS_SET(this)) { 80 if (!IS_SET(this)) {
81 throw MakeTypeError('incompatible_method_receiver', 81 throw MakeTypeError('incompatible_method_receiver',
82 ['Set.prototype.size', this]); 82 ['Set.prototype.size', this]);
83 } 83 }
84 return %SetGetSize(this); 84 return %SetGetSize(this);
85 } 85 }
86 86
87 87
88 function SetClear() { 88 function SetClearJS() {
89 if (!IS_SET(this)) { 89 if (!IS_SET(this)) {
90 throw MakeTypeError('incompatible_method_receiver', 90 throw MakeTypeError('incompatible_method_receiver',
91 ['Set.prototype.clear', this]); 91 ['Set.prototype.clear', this]);
92 } 92 }
93 %SetClear(this); 93 %SetClear(this);
94 } 94 }
95 95
96 96
97 function SetForEach(f, receiver) { 97 function SetForEach(f, receiver) {
98 if (!IS_SET(this)) { 98 if (!IS_SET(this)) {
(...skipping 22 matching lines...) Expand all
121 function SetUpSet() { 121 function SetUpSet() {
122 %CheckIsBootstrapping(); 122 %CheckIsBootstrapping();
123 123
124 %SetCode($Set, SetConstructor); 124 %SetCode($Set, SetConstructor);
125 %FunctionSetPrototype($Set, new $Object()); 125 %FunctionSetPrototype($Set, new $Object());
126 %SetProperty($Set.prototype, "constructor", $Set, DONT_ENUM); 126 %SetProperty($Set.prototype, "constructor", $Set, DONT_ENUM);
127 127
128 %FunctionSetLength(SetForEach, 1); 128 %FunctionSetLength(SetForEach, 1);
129 129
130 // Set up the non-enumerable functions on the Set prototype object. 130 // Set up the non-enumerable functions on the Set prototype object.
131 InstallGetter($Set.prototype, "size", SetGetSize); 131 InstallGetter($Set.prototype, "size", SetGetSizeJS);
132 InstallFunctions($Set.prototype, DONT_ENUM, $Array( 132 InstallFunctions($Set.prototype, DONT_ENUM, $Array(
133 "add", SetAdd, 133 "add", SetAddJS,
134 "has", SetHas, 134 "has", SetHasJS,
135 "delete", SetDelete, 135 "delete", SetDeleteJS,
136 "clear", SetClear, 136 "clear", SetClearJS,
137 "forEach", SetForEach 137 "forEach", SetForEach
138 )); 138 ));
139 } 139 }
140 140
141 SetUpSet(); 141 SetUpSet();
142 142
143 143
144 // ------------------------------------------------------------------- 144 // -------------------------------------------------------------------
145 // Harmony Map 145 // Harmony Map
146 146
147 function MapConstructor() { 147 function MapConstructor() {
148 if (%_IsConstructCall()) { 148 if (%_IsConstructCall()) {
149 %MapInitialize(this); 149 %MapInitialize(this);
150 } else { 150 } else {
151 throw MakeTypeError('constructor_not_function', ['Map']); 151 throw MakeTypeError('constructor_not_function', ['Map']);
152 } 152 }
153 } 153 }
154 154
155 155
156 function MapGet(key) { 156 function MapGetJS(key) {
157 if (!IS_MAP(this)) { 157 if (!IS_MAP(this)) {
158 throw MakeTypeError('incompatible_method_receiver', 158 throw MakeTypeError('incompatible_method_receiver',
159 ['Map.prototype.get', this]); 159 ['Map.prototype.get', this]);
160 } 160 }
161 return %MapGet(this, NormalizeKey(key)); 161 return %MapGet(this, NormalizeKey(key));
162 } 162 }
163 163
164 164
165 function MapSet(key, value) { 165 function MapSetJS(key, value) {
166 if (!IS_MAP(this)) { 166 if (!IS_MAP(this)) {
167 throw MakeTypeError('incompatible_method_receiver', 167 throw MakeTypeError('incompatible_method_receiver',
168 ['Map.prototype.set', this]); 168 ['Map.prototype.set', this]);
169 } 169 }
170 return %MapSet(this, NormalizeKey(key), value); 170 return %MapSet(this, NormalizeKey(key), value);
171 } 171 }
172 172
173 173
174 function MapHas(key) { 174 function MapHasJS(key) {
175 if (!IS_MAP(this)) { 175 if (!IS_MAP(this)) {
176 throw MakeTypeError('incompatible_method_receiver', 176 throw MakeTypeError('incompatible_method_receiver',
177 ['Map.prototype.has', this]); 177 ['Map.prototype.has', this]);
178 } 178 }
179 return %MapHas(this, NormalizeKey(key)); 179 return %MapHas(this, NormalizeKey(key));
180 } 180 }
181 181
182 182
183 function MapDelete(key) { 183 function MapDeleteJS(key) {
184 if (!IS_MAP(this)) { 184 if (!IS_MAP(this)) {
185 throw MakeTypeError('incompatible_method_receiver', 185 throw MakeTypeError('incompatible_method_receiver',
186 ['Map.prototype.delete', this]); 186 ['Map.prototype.delete', this]);
187 } 187 }
188 return %MapDelete(this, NormalizeKey(key)); 188 return %MapDelete(this, NormalizeKey(key));
189 } 189 }
190 190
191 191
192 function MapGetSize() { 192 function MapGetSizeJS() {
193 if (!IS_MAP(this)) { 193 if (!IS_MAP(this)) {
194 throw MakeTypeError('incompatible_method_receiver', 194 throw MakeTypeError('incompatible_method_receiver',
195 ['Map.prototype.size', this]); 195 ['Map.prototype.size', this]);
196 } 196 }
197 return %MapGetSize(this); 197 return %MapGetSize(this);
198 } 198 }
199 199
200 200
201 function MapClear() { 201 function MapClearJS() {
202 if (!IS_MAP(this)) { 202 if (!IS_MAP(this)) {
203 throw MakeTypeError('incompatible_method_receiver', 203 throw MakeTypeError('incompatible_method_receiver',
204 ['Map.prototype.clear', this]); 204 ['Map.prototype.clear', this]);
205 } 205 }
206 %MapClear(this); 206 %MapClear(this);
207 } 207 }
208 208
209 209
210 function MapForEach(f, receiver) { 210 function MapForEach(f, receiver) {
211 if (!IS_MAP(this)) { 211 if (!IS_MAP(this)) {
(...skipping 22 matching lines...) Expand all
234 function SetUpMap() { 234 function SetUpMap() {
235 %CheckIsBootstrapping(); 235 %CheckIsBootstrapping();
236 236
237 %SetCode($Map, MapConstructor); 237 %SetCode($Map, MapConstructor);
238 %FunctionSetPrototype($Map, new $Object()); 238 %FunctionSetPrototype($Map, new $Object());
239 %SetProperty($Map.prototype, "constructor", $Map, DONT_ENUM); 239 %SetProperty($Map.prototype, "constructor", $Map, DONT_ENUM);
240 240
241 %FunctionSetLength(MapForEach, 1); 241 %FunctionSetLength(MapForEach, 1);
242 242
243 // Set up the non-enumerable functions on the Map prototype object. 243 // Set up the non-enumerable functions on the Map prototype object.
244 InstallGetter($Map.prototype, "size", MapGetSize); 244 InstallGetter($Map.prototype, "size", MapGetSizeJS);
245 InstallFunctions($Map.prototype, DONT_ENUM, $Array( 245 InstallFunctions($Map.prototype, DONT_ENUM, $Array(
246 "get", MapGet, 246 "get", MapGetJS,
247 "set", MapSet, 247 "set", MapSetJS,
248 "has", MapHas, 248 "has", MapHasJS,
249 "delete", MapDelete, 249 "delete", MapDeleteJS,
250 "clear", MapClear, 250 "clear", MapClearJS,
251 "forEach", MapForEach 251 "forEach", MapForEach
252 )); 252 ));
253 } 253 }
254 254
255 SetUpMap(); 255 SetUpMap();
OLDNEW
« no previous file with comments | « src/builtins.cc ('k') | src/harmony-math.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698