OLD | NEW |
---|---|
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 #include <iomanip> | 5 #include <iomanip> |
6 #include <sstream> | 6 #include <sstream> |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/accessors.h" | 10 #include "src/accessors.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 } | 90 } |
91 | 91 |
92 | 92 |
93 bool Object::BooleanValue() { | 93 bool Object::BooleanValue() { |
94 if (IsBoolean()) return IsTrue(); | 94 if (IsBoolean()) return IsTrue(); |
95 if (IsSmi()) return Smi::cast(this)->value() != 0; | 95 if (IsSmi()) return Smi::cast(this)->value() != 0; |
96 if (IsUndefined() || IsNull()) return false; | 96 if (IsUndefined() || IsNull()) return false; |
97 if (IsUndetectableObject()) return false; // Undetectable object is false. | 97 if (IsUndetectableObject()) return false; // Undetectable object is false. |
98 if (IsString()) return String::cast(this)->length() != 0; | 98 if (IsString()) return String::cast(this)->length() != 0; |
99 if (IsHeapNumber()) return HeapNumber::cast(this)->HeapNumberBooleanValue(); | 99 if (IsHeapNumber()) return HeapNumber::cast(this)->HeapNumberBooleanValue(); |
100 if (IsFloat32x4()) return Float32x4::cast(this)->Float32x4BooleanValue(); | |
titzer
2015/06/03 13:27:15
Maybe it's better just to return true for now here
bbudge
2015/06/03 20:31:48
Done. (I'll remove the Float32x4BooleanValue() fun
| |
100 return true; | 101 return true; |
101 } | 102 } |
102 | 103 |
103 | 104 |
104 bool Object::IsCallable() const { | 105 bool Object::IsCallable() const { |
105 const Object* fun = this; | 106 const Object* fun = this; |
106 while (fun->IsJSFunctionProxy()) { | 107 while (fun->IsJSFunctionProxy()) { |
107 fun = JSFunctionProxy::cast(fun)->call_trap(); | 108 fun = JSFunctionProxy::cast(fun)->call_trap(); |
108 } | 109 } |
109 return fun->IsJSFunction() || | 110 return fun->IsJSFunction() || |
(...skipping 1283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1393 HeapNumber::cast(this)->HeapNumberPrint(os); | 1394 HeapNumber::cast(this)->HeapNumberPrint(os); |
1394 os << ">"; | 1395 os << ">"; |
1395 break; | 1396 break; |
1396 } | 1397 } |
1397 case MUTABLE_HEAP_NUMBER_TYPE: { | 1398 case MUTABLE_HEAP_NUMBER_TYPE: { |
1398 os << "<MutableNumber: "; | 1399 os << "<MutableNumber: "; |
1399 HeapNumber::cast(this)->HeapNumberPrint(os); | 1400 HeapNumber::cast(this)->HeapNumberPrint(os); |
1400 os << '>'; | 1401 os << '>'; |
1401 break; | 1402 break; |
1402 } | 1403 } |
1404 case FLOAT32X4_TYPE: { | |
1405 os << "<Float32x4: "; | |
1406 Float32x4::cast(this)->Float32x4Print(os); | |
1407 os << '>'; | |
1408 break; | |
1409 } | |
1403 case JS_PROXY_TYPE: | 1410 case JS_PROXY_TYPE: |
1404 os << "<JSProxy>"; | 1411 os << "<JSProxy>"; |
1405 break; | 1412 break; |
1406 case JS_FUNCTION_PROXY_TYPE: | 1413 case JS_FUNCTION_PROXY_TYPE: |
1407 os << "<JSFunctionProxy>"; | 1414 os << "<JSFunctionProxy>"; |
1408 break; | 1415 break; |
1409 case FOREIGN_TYPE: | 1416 case FOREIGN_TYPE: |
1410 os << "<Foreign>"; | 1417 os << "<Foreign>"; |
1411 break; | 1418 break; |
1412 case CELL_TYPE: { | 1419 case CELL_TYPE: { |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1536 break; | 1543 break; |
1537 case WEAK_CELL_TYPE: | 1544 case WEAK_CELL_TYPE: |
1538 WeakCell::BodyDescriptor::IterateBody(this, v); | 1545 WeakCell::BodyDescriptor::IterateBody(this, v); |
1539 break; | 1546 break; |
1540 case SYMBOL_TYPE: | 1547 case SYMBOL_TYPE: |
1541 Symbol::BodyDescriptor::IterateBody(this, v); | 1548 Symbol::BodyDescriptor::IterateBody(this, v); |
1542 break; | 1549 break; |
1543 | 1550 |
1544 case HEAP_NUMBER_TYPE: | 1551 case HEAP_NUMBER_TYPE: |
1545 case MUTABLE_HEAP_NUMBER_TYPE: | 1552 case MUTABLE_HEAP_NUMBER_TYPE: |
1553 case FLOAT32X4_TYPE: | |
1546 case FILLER_TYPE: | 1554 case FILLER_TYPE: |
1547 case BYTE_ARRAY_TYPE: | 1555 case BYTE_ARRAY_TYPE: |
1548 case FREE_SPACE_TYPE: | 1556 case FREE_SPACE_TYPE: |
1549 break; | 1557 break; |
1550 | 1558 |
1551 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ | 1559 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ |
1552 case EXTERNAL_##TYPE##_ARRAY_TYPE: \ | 1560 case EXTERNAL_##TYPE##_ARRAY_TYPE: \ |
1553 case FIXED_##TYPE##_ARRAY_TYPE: \ | 1561 case FIXED_##TYPE##_ARRAY_TYPE: \ |
1554 break; | 1562 break; |
1555 | 1563 |
(...skipping 25 matching lines...) Expand all Loading... | |
1581 bool HeapNumber::HeapNumberBooleanValue() { | 1589 bool HeapNumber::HeapNumberBooleanValue() { |
1582 return DoubleToBoolean(value()); | 1590 return DoubleToBoolean(value()); |
1583 } | 1591 } |
1584 | 1592 |
1585 | 1593 |
1586 void HeapNumber::HeapNumberPrint(std::ostream& os) { // NOLINT | 1594 void HeapNumber::HeapNumberPrint(std::ostream& os) { // NOLINT |
1587 os << value(); | 1595 os << value(); |
1588 } | 1596 } |
1589 | 1597 |
1590 | 1598 |
1599 bool Float32x4::Float32x4BooleanValue() { return true; } | |
1600 | |
1601 | |
1602 void Float32x4::Float32x4Print(std::ostream& os) { // NOLINT | |
1603 os << get_lane(0) << "," << get_lane(1) << "," << get_lane(2) << "," | |
1604 << get_lane(3); | |
1605 } | |
1606 | |
1607 | |
1591 String* JSReceiver::class_name() { | 1608 String* JSReceiver::class_name() { |
1592 if (IsJSFunction() || IsJSFunctionProxy()) { | 1609 if (IsJSFunction() || IsJSFunctionProxy()) { |
1593 return GetHeap()->Function_string(); | 1610 return GetHeap()->Function_string(); |
1594 } | 1611 } |
1595 Object* maybe_constructor = map()->GetConstructor(); | 1612 Object* maybe_constructor = map()->GetConstructor(); |
1596 if (maybe_constructor->IsJSFunction()) { | 1613 if (maybe_constructor->IsJSFunction()) { |
1597 JSFunction* constructor = JSFunction::cast(maybe_constructor); | 1614 JSFunction* constructor = JSFunction::cast(maybe_constructor); |
1598 return String::cast(constructor->shared()->instance_class_name()); | 1615 return String::cast(constructor->shared()->instance_class_name()); |
1599 } | 1616 } |
1600 // If the constructor is not present, return "Object". | 1617 // If the constructor is not present, return "Object". |
(...skipping 15351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
16952 Handle<Object> new_value) { | 16969 Handle<Object> new_value) { |
16953 if (cell->value() != *new_value) { | 16970 if (cell->value() != *new_value) { |
16954 cell->set_value(*new_value); | 16971 cell->set_value(*new_value); |
16955 Isolate* isolate = cell->GetIsolate(); | 16972 Isolate* isolate = cell->GetIsolate(); |
16956 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 16973 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
16957 isolate, DependentCode::kPropertyCellChangedGroup); | 16974 isolate, DependentCode::kPropertyCellChangedGroup); |
16958 } | 16975 } |
16959 } | 16976 } |
16960 } // namespace internal | 16977 } // namespace internal |
16961 } // namespace v8 | 16978 } // namespace v8 |
OLD | NEW |