OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
993 bool Object::IsNull() { | 993 bool Object::IsNull() { |
994 return IsOddball() && Oddball::cast(this)->kind() == Oddball::kNull; | 994 return IsOddball() && Oddball::cast(this)->kind() == Oddball::kNull; |
995 } | 995 } |
996 | 996 |
997 | 997 |
998 bool Object::IsTheHole() { | 998 bool Object::IsTheHole() { |
999 return IsOddball() && Oddball::cast(this)->kind() == Oddball::kTheHole; | 999 return IsOddball() && Oddball::cast(this)->kind() == Oddball::kTheHole; |
1000 } | 1000 } |
1001 | 1001 |
1002 | 1002 |
| 1003 bool Object::IsException() { |
| 1004 return IsOddball() && Oddball::cast(this)->kind() == Oddball::kException; |
| 1005 } |
| 1006 |
| 1007 |
1003 bool Object::IsUninitialized() { | 1008 bool Object::IsUninitialized() { |
1004 return IsOddball() && Oddball::cast(this)->kind() == Oddball::kUninitialized; | 1009 return IsOddball() && Oddball::cast(this)->kind() == Oddball::kUninitialized; |
1005 } | 1010 } |
1006 | 1011 |
1007 | 1012 |
1008 bool Object::IsTrue() { | 1013 bool Object::IsTrue() { |
1009 return IsOddball() && Oddball::cast(this)->kind() == Oddball::kTrue; | 1014 return IsOddball() && Oddball::cast(this)->kind() == Oddball::kTrue; |
1010 } | 1015 } |
1011 | 1016 |
1012 | 1017 |
(...skipping 26 matching lines...) Expand all Loading... |
1039 double value = Handle<HeapNumber>::cast(object)->value(); | 1044 double value = Handle<HeapNumber>::cast(object)->value(); |
1040 int int_value = FastD2I(value); | 1045 int int_value = FastD2I(value); |
1041 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) { | 1046 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) { |
1042 return handle(Smi::FromInt(int_value), isolate); | 1047 return handle(Smi::FromInt(int_value), isolate); |
1043 } | 1048 } |
1044 } | 1049 } |
1045 return Handle<Object>(); | 1050 return Handle<Object>(); |
1046 } | 1051 } |
1047 | 1052 |
1048 | 1053 |
1049 // TODO(ishell): Use handlified version instead. | |
1050 MaybeObject* Object::ToSmi() { | |
1051 if (IsSmi()) return this; | |
1052 if (IsHeapNumber()) { | |
1053 double value = HeapNumber::cast(this)->value(); | |
1054 int int_value = FastD2I(value); | |
1055 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) { | |
1056 return Smi::FromInt(int_value); | |
1057 } | |
1058 } | |
1059 return Failure::Exception(); | |
1060 } | |
1061 | |
1062 | |
1063 MaybeHandle<JSReceiver> Object::ToObject(Isolate* isolate, | 1054 MaybeHandle<JSReceiver> Object::ToObject(Isolate* isolate, |
1064 Handle<Object> object) { | 1055 Handle<Object> object) { |
1065 return ToObject( | 1056 return ToObject( |
1066 isolate, object, handle(isolate->context()->native_context(), isolate)); | 1057 isolate, object, handle(isolate->context()->native_context(), isolate)); |
1067 } | 1058 } |
1068 | 1059 |
1069 | 1060 |
1070 bool Object::HasSpecificClassOf(String* name) { | 1061 bool Object::HasSpecificClassOf(String* name) { |
1071 return this->IsJSObject() && (JSObject::cast(this)->class_name() == name); | 1062 return this->IsJSObject() && (JSObject::cast(this)->class_name() == name); |
1072 } | 1063 } |
(...skipping 5907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6980 #undef READ_SHORT_FIELD | 6971 #undef READ_SHORT_FIELD |
6981 #undef WRITE_SHORT_FIELD | 6972 #undef WRITE_SHORT_FIELD |
6982 #undef READ_BYTE_FIELD | 6973 #undef READ_BYTE_FIELD |
6983 #undef WRITE_BYTE_FIELD | 6974 #undef WRITE_BYTE_FIELD |
6984 #undef NOBARRIER_READ_BYTE_FIELD | 6975 #undef NOBARRIER_READ_BYTE_FIELD |
6985 #undef NOBARRIER_WRITE_BYTE_FIELD | 6976 #undef NOBARRIER_WRITE_BYTE_FIELD |
6986 | 6977 |
6987 } } // namespace v8::internal | 6978 } } // namespace v8::internal |
6988 | 6979 |
6989 #endif // V8_OBJECTS_INL_H_ | 6980 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |