OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 | 93 |
94 #define BOOL_ACCESSORS(holder, field, name, offset) \ | 94 #define BOOL_ACCESSORS(holder, field, name, offset) \ |
95 bool holder::name() { \ | 95 bool holder::name() { \ |
96 return BooleanBit::get(field(), offset); \ | 96 return BooleanBit::get(field(), offset); \ |
97 } \ | 97 } \ |
98 void holder::set_##name(bool value) { \ | 98 void holder::set_##name(bool value) { \ |
99 set_##field(BooleanBit::set(field(), offset, value)); \ | 99 set_##field(BooleanBit::set(field(), offset, value)); \ |
100 } | 100 } |
101 | 101 |
102 | 102 |
| 103 bool Object::IsInstanceOf(FunctionTemplateInfo* expected) { |
| 104 // There is a constraint on the object; check. |
| 105 if (!this->IsJSObject()) return false; |
| 106 // Fetch the constructor function of the object. |
| 107 Object* cons_obj = JSObject::cast(this)->map()->constructor(); |
| 108 if (!cons_obj->IsJSFunction()) return false; |
| 109 JSFunction* fun = JSFunction::cast(cons_obj); |
| 110 // Iterate through the chain of inheriting function templates to |
| 111 // see if the required one occurs. |
| 112 for (Object* type = fun->shared()->function_data(); |
| 113 type->IsFunctionTemplateInfo(); |
| 114 type = FunctionTemplateInfo::cast(type)->parent_template()) { |
| 115 if (type == expected) return true; |
| 116 } |
| 117 // Didn't find the required type in the inheritance chain. |
| 118 return false; |
| 119 } |
| 120 |
| 121 |
103 bool Object::IsSmi() { | 122 bool Object::IsSmi() { |
104 return HAS_SMI_TAG(this); | 123 return HAS_SMI_TAG(this); |
105 } | 124 } |
106 | 125 |
107 | 126 |
108 bool Object::IsHeapObject() { | 127 bool Object::IsHeapObject() { |
109 return HAS_HEAP_OBJECT_TAG(this); | 128 return HAS_HEAP_OBJECT_TAG(this); |
110 } | 129 } |
111 | 130 |
112 | 131 |
(...skipping 2716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2829 #undef WRITE_INT_FIELD | 2848 #undef WRITE_INT_FIELD |
2830 #undef READ_SHORT_FIELD | 2849 #undef READ_SHORT_FIELD |
2831 #undef WRITE_SHORT_FIELD | 2850 #undef WRITE_SHORT_FIELD |
2832 #undef READ_BYTE_FIELD | 2851 #undef READ_BYTE_FIELD |
2833 #undef WRITE_BYTE_FIELD | 2852 #undef WRITE_BYTE_FIELD |
2834 | 2853 |
2835 | 2854 |
2836 } } // namespace v8::internal | 2855 } } // namespace v8::internal |
2837 | 2856 |
2838 #endif // V8_OBJECTS_INL_H_ | 2857 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |