OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 | 44 |
45 namespace v8 { | 45 namespace v8 { |
46 namespace internal { | 46 namespace internal { |
47 | 47 |
48 // Getters and setters are stored in a fixed array property. These are | 48 // Getters and setters are stored in a fixed array property. These are |
49 // constants for their indices. | 49 // constants for their indices. |
50 const int kGetterIndex = 0; | 50 const int kGetterIndex = 0; |
51 const int kSetterIndex = 1; | 51 const int kSetterIndex = 1; |
52 | 52 |
53 bool Object::IsInstanceOf(FunctionTemplateInfo* expected) { | |
54 // There is a constraint on the object; check | |
55 if (!this->IsJSObject()) return false; | |
56 // Fetch the constructor function of the object | |
57 Object* cons_obj = JSObject::cast(this)->map()->constructor(); | |
58 if (!cons_obj->IsJSFunction()) return false; | |
59 JSFunction* fun = JSFunction::cast(cons_obj); | |
60 // Iterate through the chain of inheriting function templates to | |
61 // see if the required one occurs. | |
62 for (Object* type = fun->shared()->function_data(); | |
63 type->IsFunctionTemplateInfo(); | |
64 type = FunctionTemplateInfo::cast(type)->parent_template()) { | |
65 if (type == expected) return true; | |
66 } | |
67 // Didn't find the required type in the inheritance chain. | |
68 return false; | |
69 } | |
70 | |
71 | 53 |
72 static Object* CreateJSValue(JSFunction* constructor, Object* value) { | 54 static Object* CreateJSValue(JSFunction* constructor, Object* value) { |
73 Object* result = Heap::AllocateJSObject(constructor); | 55 Object* result = Heap::AllocateJSObject(constructor); |
74 if (result->IsFailure()) return result; | 56 if (result->IsFailure()) return result; |
75 JSValue::cast(result)->set_value(value); | 57 JSValue::cast(result)->set_value(value); |
76 return result; | 58 return result; |
77 } | 59 } |
78 | 60 |
79 | 61 |
80 Object* Object::ToObject(Context* global_context) { | 62 Object* Object::ToObject(Context* global_context) { |
(...skipping 7841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7922 if (break_point_objects()->IsUndefined()) return 0; | 7904 if (break_point_objects()->IsUndefined()) return 0; |
7923 // Single beak point. | 7905 // Single beak point. |
7924 if (!break_point_objects()->IsFixedArray()) return 1; | 7906 if (!break_point_objects()->IsFixedArray()) return 1; |
7925 // Multiple break points. | 7907 // Multiple break points. |
7926 return FixedArray::cast(break_point_objects())->length(); | 7908 return FixedArray::cast(break_point_objects())->length(); |
7927 } | 7909 } |
7928 #endif | 7910 #endif |
7929 | 7911 |
7930 | 7912 |
7931 } } // namespace v8::internal | 7913 } } // namespace v8::internal |
OLD | NEW |