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

Side by Side Diff: src/js/v8natives.js

Issue 1904313004: Remove more dead code after Object.observe removal (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: cleanup more Created 4 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
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 (function(global, utils) { 5 (function(global, utils) {
6 6
7 %CheckIsBootstrapping(); 7 %CheckIsBootstrapping();
8 8
9 // ---------------------------------------------------------------------------- 9 // ----------------------------------------------------------------------------
10 // Imports 10 // Imports
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 return %HasInPrototypeChain(V, O); 135 return %HasInPrototypeChain(V, O);
136 } 136 }
137 137
138 138
139 // ES6 19.1.3.4 139 // ES6 19.1.3.4
140 function ObjectPropertyIsEnumerable(V) { 140 function ObjectPropertyIsEnumerable(V) {
141 var P = TO_NAME(V); 141 var P = TO_NAME(V);
142 return %PropertyIsEnumerable(TO_OBJECT(this), P); 142 return %PropertyIsEnumerable(TO_OBJECT(this), P);
143 } 143 }
144 144
145
146 // Extensions for providing property getters and setters.
147 function ObjectDefineGetter(name, fun) {
148 var receiver = this;
149 if (IS_NULL(receiver) || IS_UNDEFINED(receiver)) {
150 receiver = %GlobalProxy(ObjectDefineGetter);
151 }
152 if (!IS_CALLABLE(fun)) {
153 throw MakeTypeError(kObjectGetterExpectingFunction);
154 }
155 var desc = new PropertyDescriptor();
156 desc.setGet(fun);
157 desc.setEnumerable(true);
158 desc.setConfigurable(true);
159 DefineOwnProperty(TO_OBJECT(receiver), TO_NAME(name), desc, false);
160 }
161
162
163 function ObjectLookupGetter(name) {
164 var receiver = this;
165 if (IS_NULL(receiver) || IS_UNDEFINED(receiver)) {
166 receiver = %GlobalProxy(ObjectLookupGetter);
167 }
168 return %LookupAccessor(TO_OBJECT(receiver), TO_NAME(name), GETTER);
169 }
170
171
172 function ObjectDefineSetter(name, fun) {
173 var receiver = this;
174 if (IS_NULL(receiver) || IS_UNDEFINED(receiver)) {
175 receiver = %GlobalProxy(ObjectDefineSetter);
176 }
177 if (!IS_CALLABLE(fun)) {
178 throw MakeTypeError(kObjectSetterExpectingFunction);
179 }
180 var desc = new PropertyDescriptor();
181 desc.setSet(fun);
182 desc.setEnumerable(true);
183 desc.setConfigurable(true);
184 DefineOwnProperty(TO_OBJECT(receiver), TO_NAME(name), desc, false);
185 }
186
187
188 function ObjectLookupSetter(name) {
189 var receiver = this;
190 if (IS_NULL(receiver) || IS_UNDEFINED(receiver)) {
191 receiver = %GlobalProxy(ObjectLookupSetter);
192 }
193 return %LookupAccessor(TO_OBJECT(receiver), TO_NAME(name), SETTER);
194 }
195
196
197 // ES6 6.2.4.1
198 function IsAccessorDescriptor(desc) {
199 if (IS_UNDEFINED(desc)) return false;
200 return desc.hasGetter() || desc.hasSetter();
201 }
202
203
204 // ES6 6.2.4.2
205 function IsDataDescriptor(desc) {
206 if (IS_UNDEFINED(desc)) return false;
207 return desc.hasValue() || desc.hasWritable();
208 }
209
210
211 // ES6 6.2.4.3
212 function IsGenericDescriptor(desc) {
213 if (IS_UNDEFINED(desc)) return false;
214 return !(IsAccessorDescriptor(desc) || IsDataDescriptor(desc));
215 }
216
217
218 function IsInconsistentDescriptor(desc) {
219 return IsAccessorDescriptor(desc) && IsDataDescriptor(desc);
220 }
221
222
223 // Harmony Proxies
224 function FromGenericPropertyDescriptor(desc) {
225 if (IS_UNDEFINED(desc)) return desc;
226 var obj = new GlobalObject();
227
228 if (desc.hasValue()) {
229 %AddNamedProperty(obj, "value", desc.getValue(), NONE);
230 }
231 if (desc.hasWritable()) {
232 %AddNamedProperty(obj, "writable", desc.isWritable(), NONE);
233 }
234 if (desc.hasGetter()) {
235 %AddNamedProperty(obj, "get", desc.getGet(), NONE);
236 }
237 if (desc.hasSetter()) {
238 %AddNamedProperty(obj, "set", desc.getSet(), NONE);
239 }
240 if (desc.hasEnumerable()) {
241 %AddNamedProperty(obj, "enumerable", desc.isEnumerable(), NONE);
242 }
243 if (desc.hasConfigurable()) {
244 %AddNamedProperty(obj, "configurable", desc.isConfigurable(), NONE);
245 }
246 return obj;
247 }
248
249
250 // ES6 6.2.4.5
251 function ToPropertyDescriptor(obj) {
252 if (!IS_RECEIVER(obj)) throw MakeTypeError(kPropertyDescObject, obj);
253
254 var desc = new PropertyDescriptor();
255
256 if ("enumerable" in obj) {
257 desc.setEnumerable(TO_BOOLEAN(obj.enumerable));
258 }
259
260 if ("configurable" in obj) {
261 desc.setConfigurable(TO_BOOLEAN(obj.configurable));
262 }
263
264 if ("value" in obj) {
265 desc.setValue(obj.value);
266 }
267
268 if ("writable" in obj) {
269 desc.setWritable(TO_BOOLEAN(obj.writable));
270 }
271
272 if ("get" in obj) {
273 var get = obj.get;
274 if (!IS_UNDEFINED(get) && !IS_CALLABLE(get)) {
275 throw MakeTypeError(kObjectGetterCallable, get);
276 }
277 desc.setGet(get);
278 }
279
280 if ("set" in obj) {
281 var set = obj.set;
282 if (!IS_UNDEFINED(set) && !IS_CALLABLE(set)) {
283 throw MakeTypeError(kObjectSetterCallable, set);
284 }
285 desc.setSet(set);
286 }
287
288 if (IsInconsistentDescriptor(desc)) {
289 throw MakeTypeError(kValueAndAccessor, obj);
290 }
291 return desc;
292 }
293
294 // TODO(cbruni): remove once callers have been removed
295 function ToCompletePropertyDescriptor(obj) {
296 var desc = ToPropertyDescriptor(obj);
297 if (IsGenericDescriptor(desc) || IsDataDescriptor(desc)) {
298 if (!desc.hasValue()) desc.setValue(UNDEFINED);
299 if (!desc.hasWritable()) desc.setWritable(false);
300 } else {
301 // Is accessor descriptor.
302 if (!desc.hasGetter()) desc.setGet(UNDEFINED);
303 if (!desc.hasSetter()) desc.setSet(UNDEFINED);
304 }
305 if (!desc.hasEnumerable()) desc.setEnumerable(false);
306 if (!desc.hasConfigurable()) desc.setConfigurable(false);
307 return desc;
308 }
309
310
311 function PropertyDescriptor() {
312 // Initialize here so they are all in-object and have the same map.
313 // Default values from ES5 8.6.1.
314 this.value_ = UNDEFINED;
315 this.hasValue_ = false;
316 this.writable_ = false;
317 this.hasWritable_ = false;
318 this.enumerable_ = false;
319 this.hasEnumerable_ = false;
320 this.configurable_ = false;
321 this.hasConfigurable_ = false;
322 this.get_ = UNDEFINED;
323 this.hasGetter_ = false;
324 this.set_ = UNDEFINED;
325 this.hasSetter_ = false;
326 }
327
328 utils.SetUpLockedPrototype(PropertyDescriptor, [
329 "value_",
330 "hasValue_",
331 "writable_",
332 "hasWritable_",
333 "enumerable_",
334 "hasEnumerable_",
335 "configurable_",
336 "hasConfigurable_",
337 "get_",
338 "hasGetter_",
339 "set_",
340 "hasSetter_"
341 ], [
342 "toString", function PropertyDescriptor_ToString() {
343 return "[object PropertyDescriptor]";
344 },
345 "setValue", function PropertyDescriptor_SetValue(value) {
346 this.value_ = value;
347 this.hasValue_ = true;
348 },
349 "getValue", function PropertyDescriptor_GetValue() {
350 return this.value_;
351 },
352 "hasValue", function PropertyDescriptor_HasValue() {
353 return this.hasValue_;
354 },
355 "setEnumerable", function PropertyDescriptor_SetEnumerable(enumerable) {
356 this.enumerable_ = enumerable;
357 this.hasEnumerable_ = true;
358 },
359 "isEnumerable", function PropertyDescriptor_IsEnumerable() {
360 return this.enumerable_;
361 },
362 "hasEnumerable", function PropertyDescriptor_HasEnumerable() {
363 return this.hasEnumerable_;
364 },
365 "setWritable", function PropertyDescriptor_SetWritable(writable) {
366 this.writable_ = writable;
367 this.hasWritable_ = true;
368 },
369 "isWritable", function PropertyDescriptor_IsWritable() {
370 return this.writable_;
371 },
372 "hasWritable", function PropertyDescriptor_HasWritable() {
373 return this.hasWritable_;
374 },
375 "setConfigurable",
376 function PropertyDescriptor_SetConfigurable(configurable) {
377 this.configurable_ = configurable;
378 this.hasConfigurable_ = true;
379 },
380 "hasConfigurable", function PropertyDescriptor_HasConfigurable() {
381 return this.hasConfigurable_;
382 },
383 "isConfigurable", function PropertyDescriptor_IsConfigurable() {
384 return this.configurable_;
385 },
386 "setGet", function PropertyDescriptor_SetGetter(get) {
387 this.get_ = get;
388 this.hasGetter_ = true;
389 },
390 "getGet", function PropertyDescriptor_GetGetter() {
391 return this.get_;
392 },
393 "hasGetter", function PropertyDescriptor_HasGetter() {
394 return this.hasGetter_;
395 },
396 "setSet", function PropertyDescriptor_SetSetter(set) {
397 this.set_ = set;
398 this.hasSetter_ = true;
399 },
400 "getSet", function PropertyDescriptor_GetSetter() {
401 return this.set_;
402 },
403 "hasSetter", function PropertyDescriptor_HasSetter() {
404 return this.hasSetter_;
405 }
406 ]);
407
408
409 // Converts an array returned from Runtime_GetOwnProperty to an actual
410 // property descriptor. For a description of the array layout please
411 // see the runtime.cc file.
412 function ConvertDescriptorArrayToDescriptor(desc_array) {
413 if (IS_UNDEFINED(desc_array)) {
414 return UNDEFINED;
415 }
416
417 var desc = new PropertyDescriptor();
418 // This is an accessor.
419 if (desc_array[IS_ACCESSOR_INDEX]) {
420 desc.setGet(desc_array[GETTER_INDEX]);
421 desc.setSet(desc_array[SETTER_INDEX]);
422 } else {
423 desc.setValue(desc_array[VALUE_INDEX]);
424 desc.setWritable(desc_array[WRITABLE_INDEX]);
425 }
426 desc.setEnumerable(desc_array[ENUMERABLE_INDEX]);
427 desc.setConfigurable(desc_array[CONFIGURABLE_INDEX]);
428
429 return desc;
430 }
431
432
433 // For Harmony proxies.
434 function GetTrap(handler, name, defaultTrap) {
435 var trap = handler[name];
436 if (IS_UNDEFINED(trap)) {
437 if (IS_UNDEFINED(defaultTrap)) {
438 throw MakeTypeError(kIllegalInvocation);
439 }
440 trap = defaultTrap;
441 } else if (!IS_CALLABLE(trap)) {
442 throw MakeTypeError(kIllegalInvocation);
443 }
444 return trap;
445 }
446
447
448 function CallTrap1(handler, name, defaultTrap, x) {
449 return %_Call(GetTrap(handler, name, defaultTrap), handler, x);
450 }
451
452
453 function CallTrap2(handler, name, defaultTrap, x, y) {
454 return %_Call(GetTrap(handler, name, defaultTrap), handler, x, y);
455 }
456
457
458 // ES5 section 8.12.1.
459 // TODO(jkummerow): Deprecated. Migrate all callers to
460 // ObjectGetOwnPropertyDescriptor and delete this.
461 function GetOwnPropertyJS(obj, v) {
462 var p = TO_NAME(v);
463 if (IS_PROXY(obj)) {
464 // TODO(rossberg): adjust once there is a story for symbols vs proxies.
465 if (IS_SYMBOL(v)) return UNDEFINED;
466
467 var handler = %JSProxyGetHandler(obj);
468 var descriptor = CallTrap1(
469 handler, "getOwnPropertyDescriptor", UNDEFINED, p);
470 if (IS_UNDEFINED(descriptor)) return descriptor;
471 var desc = ToCompletePropertyDescriptor(descriptor);
472 if (!desc.isConfigurable()) {
473 throw MakeTypeError(kIllegalInvocation);
474 }
475 return desc;
476 }
477
478 // GetOwnProperty returns an array indexed by the constants
479 // defined in macros.py.
480 // If p is not a property on obj undefined is returned.
481 var props = %GetOwnProperty_Legacy(TO_OBJECT(obj), p);
482
483 return ConvertDescriptorArrayToDescriptor(props);
484 }
485
486
487 // ES6 7.3.9 145 // ES6 7.3.9
488 function GetMethod(obj, p) { 146 function GetMethod(obj, p) {
489 var func = obj[p]; 147 var func = obj[p];
490 if (IS_NULL_OR_UNDEFINED(func)) return UNDEFINED; 148 if (IS_NULL_OR_UNDEFINED(func)) return UNDEFINED;
491 if (IS_CALLABLE(func)) return func; 149 if (IS_CALLABLE(func)) return func;
492 throw MakeTypeError(kCalledNonCallable, typeof func); 150 throw MakeTypeError(kCalledNonCallable, typeof func);
493 } 151 }
494 152
495
496 // Harmony proxies.
497 function DefineProxyProperty(obj, p, attributes, should_throw) {
498 // TODO(rossberg): adjust once there is a story for symbols vs proxies.
499 if (IS_SYMBOL(p)) return false;
500
501 var handler = %JSProxyGetHandler(obj);
502 var result = CallTrap2(handler, "defineProperty", UNDEFINED, p, attributes);
503 if (!result) {
504 if (should_throw) {
505 throw MakeTypeError(kIllegalInvocation);
506 } else {
507 return false;
508 }
509 }
510 return true;
511 }
512
513
514 // ES6 9.1.6 [[DefineOwnProperty]](P, Desc)
515 function DefineObjectProperty(obj, p, desc, should_throw) {
516 var current_array = %GetOwnProperty_Legacy(obj, TO_NAME(p));
517 var current = ConvertDescriptorArrayToDescriptor(current_array);
518 var extensible = %object_is_extensible(obj);
519
520 if (IS_UNDEFINED(current) && !extensible) {
521 if (should_throw) {
522 throw MakeTypeError(kDefineDisallowed, p);
523 } else {
524 return false;
525 }
526 }
527
528 if (!IS_UNDEFINED(current)) {
529 if ((IsGenericDescriptor(desc) ||
530 IsDataDescriptor(desc) == IsDataDescriptor(current)) &&
531 (!desc.hasEnumerable() ||
532 %SameValue(desc.isEnumerable(), current.isEnumerable())) &&
533 (!desc.hasConfigurable() ||
534 %SameValue(desc.isConfigurable(), current.isConfigurable())) &&
535 (!desc.hasWritable() ||
536 %SameValue(desc.isWritable(), current.isWritable())) &&
537 (!desc.hasValue() ||
538 %SameValue(desc.getValue(), current.getValue())) &&
539 (!desc.hasGetter() ||
540 %SameValue(desc.getGet(), current.getGet())) &&
541 (!desc.hasSetter() ||
542 %SameValue(desc.getSet(), current.getSet()))) {
543 return true;
544 }
545 if (!current.isConfigurable()) {
546 // Step 7
547 if (desc.isConfigurable() ||
548 (desc.hasEnumerable() &&
549 desc.isEnumerable() != current.isEnumerable())) {
550 if (should_throw) {
551 throw MakeTypeError(kRedefineDisallowed, p);
552 } else {
553 return false;
554 }
555 }
556 // Step 8
557 if (!IsGenericDescriptor(desc)) {
558 // Step 9a
559 if (IsDataDescriptor(current) != IsDataDescriptor(desc)) {
560 if (should_throw) {
561 throw MakeTypeError(kRedefineDisallowed, p);
562 } else {
563 return false;
564 }
565 }
566 // Step 10a
567 if (IsDataDescriptor(current) && IsDataDescriptor(desc)) {
568 var currentIsWritable = current.isWritable();
569 if (currentIsWritable != desc.isWritable()) {
570 if (!currentIsWritable) {
571 if (should_throw) {
572 throw MakeTypeError(kRedefineDisallowed, p);
573 } else {
574 return false;
575 }
576 }
577 }
578 if (!currentIsWritable && desc.hasValue() &&
579 !%SameValue(desc.getValue(), current.getValue())) {
580 if (should_throw) {
581 throw MakeTypeError(kRedefineDisallowed, p);
582 } else {
583 return false;
584 }
585 }
586 }
587 // Step 11
588 if (IsAccessorDescriptor(desc) && IsAccessorDescriptor(current)) {
589 if (desc.hasSetter() &&
590 !%SameValue(desc.getSet(), current.getSet())) {
591 if (should_throw) {
592 throw MakeTypeError(kRedefineDisallowed, p);
593 } else {
594 return false;
595 }
596 }
597 if (desc.hasGetter() && !%SameValue(desc.getGet(),current.getGet())) {
598 if (should_throw) {
599 throw MakeTypeError(kRedefineDisallowed, p);
600 } else {
601 return false;
602 }
603 }
604 }
605 }
606 }
607 }
608
609 // Send flags - enumerable and configurable are common - writable is
610 // only send to the data descriptor.
611 // Take special care if enumerable and configurable is not defined on
612 // desc (we need to preserve the existing values from current).
613 var flag = NONE;
614 if (desc.hasEnumerable()) {
615 flag |= desc.isEnumerable() ? 0 : DONT_ENUM;
616 } else if (!IS_UNDEFINED(current)) {
617 flag |= current.isEnumerable() ? 0 : DONT_ENUM;
618 } else {
619 flag |= DONT_ENUM;
620 }
621
622 if (desc.hasConfigurable()) {
623 flag |= desc.isConfigurable() ? 0 : DONT_DELETE;
624 } else if (!IS_UNDEFINED(current)) {
625 flag |= current.isConfigurable() ? 0 : DONT_DELETE;
626 } else
627 flag |= DONT_DELETE;
628
629 if (IsDataDescriptor(desc) ||
630 (IsGenericDescriptor(desc) &&
631 (IS_UNDEFINED(current) || IsDataDescriptor(current)))) {
632 // There are 3 cases that lead here:
633 // Step 4a - defining a new data property.
634 // Steps 9b & 12 - replacing an existing accessor property with a data
635 // property.
636 // Step 12 - updating an existing data property with a data or generic
637 // descriptor.
638
639 if (desc.hasWritable()) {
640 flag |= desc.isWritable() ? 0 : READ_ONLY;
641 } else if (!IS_UNDEFINED(current)) {
642 flag |= current.isWritable() ? 0 : READ_ONLY;
643 } else {
644 flag |= READ_ONLY;
645 }
646
647 var value = UNDEFINED; // Default value is undefined.
648 if (desc.hasValue()) {
649 value = desc.getValue();
650 } else if (!IS_UNDEFINED(current) && IsDataDescriptor(current)) {
651 value = current.getValue();
652 }
653
654 %DefineDataPropertyUnchecked(obj, p, value, flag);
655 } else {
656 // There are 3 cases that lead here:
657 // Step 4b - defining a new accessor property.
658 // Steps 9c & 12 - replacing an existing data property with an accessor
659 // property.
660 // Step 12 - updating an existing accessor property with an accessor
661 // descriptor.
662 var getter = null;
663 if (desc.hasGetter()) {
664 getter = desc.getGet();
665 } else if (IsAccessorDescriptor(current) && current.hasGetter()) {
666 getter = current.getGet();
667 }
668 var setter = null;
669 if (desc.hasSetter()) {
670 setter = desc.getSet();
671 } else if (IsAccessorDescriptor(current) && current.hasSetter()) {
672 setter = current.getSet();
673 }
674 %DefineAccessorPropertyUnchecked(obj, p, getter, setter, flag);
675 }
676 return true;
677 }
678
679
680 // ES5 section 15.4.5.1.
681 function DefineArrayProperty(obj, p, desc, should_throw) {
682 // Step 3 - Special handling for array index.
683 if (!IS_SYMBOL(p)) {
684 var index = TO_UINT32(p);
685 if (TO_STRING(index) == p && index != 4294967295) {
686 var length = obj.length;
687 var length_desc = GetOwnPropertyJS(obj, "length");
688 if ((index >= length && !length_desc.isWritable()) ||
689 !DefineObjectProperty(obj, p, desc, true)) {
690 if (should_throw) {
691 throw MakeTypeError(kDefineDisallowed, p);
692 } else {
693 return false;
694 }
695 }
696 if (index >= length) {
697 obj.length = index + 1;
698 }
699 return true;
700 }
701 }
702
703 // Step 5 - Fallback to default implementation.
704 return DefineObjectProperty(obj, p, desc, should_throw);
705 }
706
707
708 // ES5 section 8.12.9, ES5 section 15.4.5.1 and Harmony proxies.
709 function DefineOwnProperty(obj, p, desc, should_throw) {
710 if (IS_PROXY(obj)) {
711 // TODO(rossberg): adjust once there is a story for symbols vs proxies.
712 if (IS_SYMBOL(p)) return false;
713
714 var attributes = FromGenericPropertyDescriptor(desc);
715 return DefineProxyProperty(obj, p, attributes, should_throw);
716 } else if (IS_ARRAY(obj)) {
717 return DefineArrayProperty(obj, p, desc, should_throw);
718 } else {
719 return DefineObjectProperty(obj, p, desc, should_throw);
720 }
721 }
722
723
724 // ES6 section 19.1.2.9 153 // ES6 section 19.1.2.9
725 function ObjectGetPrototypeOf(obj) { 154 function ObjectGetPrototypeOf(obj) {
726 return %_GetPrototype(TO_OBJECT(obj)); 155 return %_GetPrototype(TO_OBJECT(obj));
727 } 156 }
728 157
729 // ES6 section 19.1.2.18. 158 // ES6 section 19.1.2.18.
730 function ObjectSetPrototypeOf(obj, proto) { 159 function ObjectSetPrototypeOf(obj, proto) {
731 CHECK_OBJECT_COERCIBLE(obj, "Object.setPrototypeOf"); 160 CHECK_OBJECT_COERCIBLE(obj, "Object.setPrototypeOf");
732 161
733 if (proto !== null && !IS_RECEIVER(proto)) { 162 if (proto !== null && !IS_RECEIVER(proto)) {
734 throw MakeTypeError(kProtoObjectOrNull, proto); 163 throw MakeTypeError(kProtoObjectOrNull, proto);
735 } 164 }
736 165
737 if (IS_RECEIVER(obj)) { 166 if (IS_RECEIVER(obj)) {
738 %SetPrototype(obj, proto); 167 %SetPrototype(obj, proto);
739 } 168 }
740 169
741 return obj; 170 return obj;
742 } 171 }
743 172
744 173
745 // ES5 section 15.2.3.6. 174 // ES5 section 15.2.3.6.
746 function ObjectDefineProperty(obj, p, attributes) { 175 function ObjectDefineProperty(obj, p, attributes) {
747 // The new pure-C++ implementation doesn't support O.o.
748 // TODO(jkummerow): Implement missing features and remove fallback path.
749 return %ObjectDefineProperty(obj, p, attributes); 176 return %ObjectDefineProperty(obj, p, attributes);
750 } 177 }
751 178
752 179
753 // ES5 section 15.2.3.7. 180 // ES5 section 15.2.3.7.
754 function ObjectDefineProperties(obj, properties) { 181 function ObjectDefineProperties(obj, properties) {
755 // The new pure-C++ implementation doesn't support O.o.
756 // TODO(jkummerow): Implement missing features and remove fallback path.
757 return %ObjectDefineProperties(obj, properties); 182 return %ObjectDefineProperties(obj, properties);
758 } 183 }
759 184
760 185
761 // ES6 B.2.2.1.1 186 // ES6 B.2.2.1.1
762 function ObjectGetProto() { 187 function ObjectGetProto() {
763 return %_GetPrototype(TO_OBJECT(this)); 188 return %_GetPrototype(TO_OBJECT(this));
764 } 189 }
765 190
766 191
(...skipping 26 matching lines...) Expand all
793 %AddNamedProperty(GlobalObject.prototype, "constructor", GlobalObject, 218 %AddNamedProperty(GlobalObject.prototype, "constructor", GlobalObject,
794 DONT_ENUM); 219 DONT_ENUM);
795 220
796 // Set up non-enumerable functions on the Object.prototype object. 221 // Set up non-enumerable functions on the Object.prototype object.
797 utils.InstallFunctions(GlobalObject.prototype, DONT_ENUM, [ 222 utils.InstallFunctions(GlobalObject.prototype, DONT_ENUM, [
798 "toString", ObjectToString, 223 "toString", ObjectToString,
799 "toLocaleString", ObjectToLocaleString, 224 "toLocaleString", ObjectToLocaleString,
800 "valueOf", ObjectValueOf, 225 "valueOf", ObjectValueOf,
801 "isPrototypeOf", ObjectIsPrototypeOf, 226 "isPrototypeOf", ObjectIsPrototypeOf,
802 "propertyIsEnumerable", ObjectPropertyIsEnumerable, 227 "propertyIsEnumerable", ObjectPropertyIsEnumerable,
803 "__defineGetter__", ObjectDefineGetter, 228 // __defineGetter__ is added in bootstrapper.cc.
804 "__lookupGetter__", ObjectLookupGetter, 229 // __lookupGetter__ is added in bootstrapper.cc.
805 "__defineSetter__", ObjectDefineSetter, 230 // __defineSetter__ is added in bootstrapper.cc.
806 "__lookupSetter__", ObjectLookupSetter 231 // __lookupSetter__ is added in bootstrapper.cc.
807 ]); 232 ]);
808 utils.InstallGetterSetter(GlobalObject.prototype, "__proto__", ObjectGetProto, 233 utils.InstallGetterSetter(GlobalObject.prototype, "__proto__", ObjectGetProto,
809 ObjectSetProto); 234 ObjectSetProto);
810 235
811 // Set up non-enumerable functions in the Object object. 236 // Set up non-enumerable functions in the Object object.
812 utils.InstallFunctions(GlobalObject, DONT_ENUM, [ 237 utils.InstallFunctions(GlobalObject, DONT_ENUM, [
813 // assign is added in bootstrapper.cc. 238 // assign is added in bootstrapper.cc.
814 // keys is added in bootstrapper.cc. 239 // keys is added in bootstrapper.cc.
815 "defineProperty", ObjectDefineProperty, 240 "defineProperty", ObjectDefineProperty,
816 "defineProperties", ObjectDefineProperties, 241 "defineProperties", ObjectDefineProperties,
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 to.ObjectDefineProperties = ObjectDefineProperties; 480 to.ObjectDefineProperties = ObjectDefineProperties;
1056 to.ObjectDefineProperty = ObjectDefineProperty; 481 to.ObjectDefineProperty = ObjectDefineProperty;
1057 to.ObjectHasOwnProperty = GlobalObject.prototype.hasOwnProperty; 482 to.ObjectHasOwnProperty = GlobalObject.prototype.hasOwnProperty;
1058 }); 483 });
1059 484
1060 %InstallToContext([ 485 %InstallToContext([
1061 "object_value_of", ObjectValueOf, 486 "object_value_of", ObjectValueOf,
1062 ]); 487 ]);
1063 488
1064 }) 489 })
OLDNEW
« src/builtins.cc ('K') | « src/js/prologue.js ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698