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

Side by Side Diff: src/weak-collection.js

Issue 1086313003: Migrate error messages, part 2. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 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/v8natives.js ('k') | test/mjsunit/messages.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
11 var $WeakMap = global.WeakMap; 11 var $WeakMap = global.WeakMap;
12 var $WeakSet = global.WeakSet; 12 var $WeakSet = global.WeakSet;
13 13
14 14
15 // ------------------------------------------------------------------- 15 // -------------------------------------------------------------------
16 // Harmony WeakMap 16 // Harmony WeakMap
17 17
18 function WeakMapConstructor(iterable) { 18 function WeakMapConstructor(iterable) {
19 if (!%_IsConstructCall()) { 19 if (!%_IsConstructCall()) {
20 throw MakeTypeError('constructor_not_function', ['WeakMap']); 20 throw MakeTypeError('constructor_not_function', ['WeakMap']);
21 } 21 }
22 22
23 %WeakCollectionInitialize(this); 23 %WeakCollectionInitialize(this);
24 24
25 if (!IS_NULL_OR_UNDEFINED(iterable)) { 25 if (!IS_NULL_OR_UNDEFINED(iterable)) {
26 var adder = this.set; 26 var adder = this.set;
27 if (!IS_SPEC_FUNCTION(adder)) { 27 if (!IS_SPEC_FUNCTION(adder)) {
28 throw MakeTypeError(kPropertyNotFunction, ['set', this]); 28 throw MakeTypeError(kPropertyNotFunction, 'set', this);
29 } 29 }
30 for (var nextItem of iterable) { 30 for (var nextItem of iterable) {
31 if (!IS_SPEC_OBJECT(nextItem)) { 31 if (!IS_SPEC_OBJECT(nextItem)) {
32 throw MakeTypeError('iterator_value_not_an_object', [nextItem]); 32 throw MakeTypeError('iterator_value_not_an_object', [nextItem]);
33 } 33 }
34 %_CallFunction(this, nextItem[0], nextItem[1], adder); 34 %_CallFunction(this, nextItem[0], nextItem[1], adder);
35 } 35 }
36 } 36 }
37 } 37 }
38 38
39 39
40 function WeakMapGet(key) { 40 function WeakMapGet(key) {
41 if (!IS_WEAKMAP(this)) { 41 if (!IS_WEAKMAP(this)) {
42 throw MakeTypeError('incompatible_method_receiver', 42 throw MakeTypeError(kIncompatibleMethodReceiver,
43 ['WeakMap.prototype.get', this]); 43 'WeakMap.prototype.get', this);
44 } 44 }
45 if (!IS_SPEC_OBJECT(key)) return UNDEFINED; 45 if (!IS_SPEC_OBJECT(key)) return UNDEFINED;
46 return %WeakCollectionGet(this, key); 46 return %WeakCollectionGet(this, key);
47 } 47 }
48 48
49 49
50 function WeakMapSet(key, value) { 50 function WeakMapSet(key, value) {
51 if (!IS_WEAKMAP(this)) { 51 if (!IS_WEAKMAP(this)) {
52 throw MakeTypeError('incompatible_method_receiver', 52 throw MakeTypeError(kIncompatibleMethodReceiver,
53 ['WeakMap.prototype.set', this]); 53 'WeakMap.prototype.set', this);
54 } 54 }
55 if (!IS_SPEC_OBJECT(key)) { 55 if (!IS_SPEC_OBJECT(key)) {
56 throw %MakeTypeError('invalid_weakmap_key', [this, key]); 56 throw %MakeTypeError('invalid_weakmap_key', [this, key]);
57 } 57 }
58 return %WeakCollectionSet(this, key, value); 58 return %WeakCollectionSet(this, key, value);
59 } 59 }
60 60
61 61
62 function WeakMapHas(key) { 62 function WeakMapHas(key) {
63 if (!IS_WEAKMAP(this)) { 63 if (!IS_WEAKMAP(this)) {
64 throw MakeTypeError('incompatible_method_receiver', 64 throw MakeTypeError(kIncompatibleMethodReceiver,
65 ['WeakMap.prototype.has', this]); 65 'WeakMap.prototype.has', this);
66 } 66 }
67 if (!IS_SPEC_OBJECT(key)) return false; 67 if (!IS_SPEC_OBJECT(key)) return false;
68 return %WeakCollectionHas(this, key); 68 return %WeakCollectionHas(this, key);
69 } 69 }
70 70
71 71
72 function WeakMapDelete(key) { 72 function WeakMapDelete(key) {
73 if (!IS_WEAKMAP(this)) { 73 if (!IS_WEAKMAP(this)) {
74 throw MakeTypeError('incompatible_method_receiver', 74 throw MakeTypeError(kIncompatibleMethodReceiver,
75 ['WeakMap.prototype.delete', this]); 75 'WeakMap.prototype.delete', this);
76 } 76 }
77 if (!IS_SPEC_OBJECT(key)) return false; 77 if (!IS_SPEC_OBJECT(key)) return false;
78 return %WeakCollectionDelete(this, key); 78 return %WeakCollectionDelete(this, key);
79 } 79 }
80 80
81 81
82 // ------------------------------------------------------------------- 82 // -------------------------------------------------------------------
83 83
84 function SetUpWeakMap() { 84 function SetUpWeakMap() {
85 %CheckIsBootstrapping(); 85 %CheckIsBootstrapping();
(...skipping 23 matching lines...) Expand all
109 function WeakSetConstructor(iterable) { 109 function WeakSetConstructor(iterable) {
110 if (!%_IsConstructCall()) { 110 if (!%_IsConstructCall()) {
111 throw MakeTypeError('constructor_not_function', ['WeakSet']); 111 throw MakeTypeError('constructor_not_function', ['WeakSet']);
112 } 112 }
113 113
114 %WeakCollectionInitialize(this); 114 %WeakCollectionInitialize(this);
115 115
116 if (!IS_NULL_OR_UNDEFINED(iterable)) { 116 if (!IS_NULL_OR_UNDEFINED(iterable)) {
117 var adder = this.add; 117 var adder = this.add;
118 if (!IS_SPEC_FUNCTION(adder)) { 118 if (!IS_SPEC_FUNCTION(adder)) {
119 throw MakeTypeError(kPropertyNotFunction, ['add', this]); 119 throw MakeTypeError(kPropertyNotFunction, 'add', this);
120 } 120 }
121 for (var value of iterable) { 121 for (var value of iterable) {
122 %_CallFunction(this, value, adder); 122 %_CallFunction(this, value, adder);
123 } 123 }
124 } 124 }
125 } 125 }
126 126
127 127
128 function WeakSetAdd(value) { 128 function WeakSetAdd(value) {
129 if (!IS_WEAKSET(this)) { 129 if (!IS_WEAKSET(this)) {
130 throw MakeTypeError('incompatible_method_receiver', 130 throw MakeTypeError(kIncompatibleMethodReceiver,
131 ['WeakSet.prototype.add', this]); 131 'WeakSet.prototype.add', this);
132 } 132 }
133 if (!IS_SPEC_OBJECT(value)) { 133 if (!IS_SPEC_OBJECT(value)) {
134 throw %MakeTypeError('invalid_weakset_value', [this, value]); 134 throw %MakeTypeError('invalid_weakset_value', [this, value]);
135 } 135 }
136 return %WeakCollectionSet(this, value, true); 136 return %WeakCollectionSet(this, value, true);
137 } 137 }
138 138
139 139
140 function WeakSetHas(value) { 140 function WeakSetHas(value) {
141 if (!IS_WEAKSET(this)) { 141 if (!IS_WEAKSET(this)) {
142 throw MakeTypeError('incompatible_method_receiver', 142 throw MakeTypeError(kIncompatibleMethodReceiver,
143 ['WeakSet.prototype.has', this]); 143 'WeakSet.prototype.has', this);
144 } 144 }
145 if (!IS_SPEC_OBJECT(value)) return false; 145 if (!IS_SPEC_OBJECT(value)) return false;
146 return %WeakCollectionHas(this, value); 146 return %WeakCollectionHas(this, value);
147 } 147 }
148 148
149 149
150 function WeakSetDelete(value) { 150 function WeakSetDelete(value) {
151 if (!IS_WEAKSET(this)) { 151 if (!IS_WEAKSET(this)) {
152 throw MakeTypeError('incompatible_method_receiver', 152 throw MakeTypeError(kIncompatibleMethodReceiver,
153 ['WeakSet.prototype.delete', this]); 153 'WeakSet.prototype.delete', this);
154 } 154 }
155 if (!IS_SPEC_OBJECT(value)) return false; 155 if (!IS_SPEC_OBJECT(value)) return false;
156 return %WeakCollectionDelete(this, value); 156 return %WeakCollectionDelete(this, value);
157 } 157 }
158 158
159 159
160 // ------------------------------------------------------------------- 160 // -------------------------------------------------------------------
161 161
162 function SetUpWeakSet() { 162 function SetUpWeakSet() {
163 %CheckIsBootstrapping(); 163 %CheckIsBootstrapping();
164 164
165 %SetCode($WeakSet, WeakSetConstructor); 165 %SetCode($WeakSet, WeakSetConstructor);
166 %FunctionSetLength($WeakSet, 0); 166 %FunctionSetLength($WeakSet, 0);
167 %FunctionSetPrototype($WeakSet, new $Object()); 167 %FunctionSetPrototype($WeakSet, new $Object());
168 %AddNamedProperty($WeakSet.prototype, "constructor", $WeakSet, DONT_ENUM); 168 %AddNamedProperty($WeakSet.prototype, "constructor", $WeakSet, DONT_ENUM);
169 %AddNamedProperty( 169 %AddNamedProperty(
170 $WeakSet.prototype, symbolToStringTag, "WeakSet", DONT_ENUM | READ_ONLY); 170 $WeakSet.prototype, symbolToStringTag, "WeakSet", DONT_ENUM | READ_ONLY);
171 171
172 // Set up the non-enumerable functions on the WeakSet prototype object. 172 // Set up the non-enumerable functions on the WeakSet prototype object.
173 InstallFunctions($WeakSet.prototype, DONT_ENUM, [ 173 InstallFunctions($WeakSet.prototype, DONT_ENUM, [
174 "add", WeakSetAdd, 174 "add", WeakSetAdd,
175 "has", WeakSetHas, 175 "has", WeakSetHas,
176 "delete", WeakSetDelete 176 "delete", WeakSetDelete
177 ]); 177 ]);
178 } 178 }
179 179
180 SetUpWeakSet(); 180 SetUpWeakSet();
OLDNEW
« no previous file with comments | « src/v8natives.js ('k') | test/mjsunit/messages.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698