| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 MaybeObject* Accessors::ReadOnlySetAccessor(Isolate* isolate, | 72 MaybeObject* Accessors::ReadOnlySetAccessor(Isolate* isolate, |
| 73 JSObject*, | 73 JSObject*, |
| 74 Object* value, | 74 Object* value, |
| 75 void*) { | 75 void*) { |
| 76 // According to ECMA-262, section 8.6.2.2, page 28, setting | 76 // According to ECMA-262, section 8.6.2.2, page 28, setting |
| 77 // read-only properties must be silently ignored. | 77 // read-only properties must be silently ignored. |
| 78 return value; | 78 return value; |
| 79 } | 79 } |
| 80 | 80 |
| 81 | 81 |
| 82 static V8_INLINE bool CheckForName(Handle<String> name, | |
| 83 String* property_name, | |
| 84 int offset, | |
| 85 int* object_offset) { | |
| 86 if (name->Equals(property_name)) { | |
| 87 *object_offset = offset; | |
| 88 return true; | |
| 89 } | |
| 90 return false; | |
| 91 } | |
| 92 | |
| 93 | |
| 94 bool Accessors::IsJSObjectFieldAccessor(Handle<HeapType> type, | |
| 95 Handle<String> name, | |
| 96 int* object_offset) { | |
| 97 Isolate* isolate = name->GetIsolate(); | |
| 98 | |
| 99 if (type->Is(HeapType::String())) { | |
| 100 return CheckForName(name, isolate->heap()->length_string(), | |
| 101 String::kLengthOffset, object_offset); | |
| 102 } | |
| 103 | |
| 104 if (!type->IsClass()) return false; | |
| 105 Handle<Map> map = type->AsClass(); | |
| 106 | |
| 107 switch (map->instance_type()) { | |
| 108 case JS_ARRAY_TYPE: | |
| 109 return | |
| 110 CheckForName(name, isolate->heap()->length_string(), | |
| 111 JSArray::kLengthOffset, object_offset); | |
| 112 case JS_TYPED_ARRAY_TYPE: | |
| 113 return | |
| 114 CheckForName(name, isolate->heap()->length_string(), | |
| 115 JSTypedArray::kLengthOffset, object_offset) || | |
| 116 CheckForName(name, isolate->heap()->byte_length_string(), | |
| 117 JSTypedArray::kByteLengthOffset, object_offset) || | |
| 118 CheckForName(name, isolate->heap()->byte_offset_string(), | |
| 119 JSTypedArray::kByteOffsetOffset, object_offset) || | |
| 120 CheckForName(name, isolate->heap()->buffer_string(), | |
| 121 JSTypedArray::kBufferOffset, object_offset); | |
| 122 case JS_ARRAY_BUFFER_TYPE: | |
| 123 return | |
| 124 CheckForName(name, isolate->heap()->byte_length_string(), | |
| 125 JSArrayBuffer::kByteLengthOffset, object_offset); | |
| 126 case JS_DATA_VIEW_TYPE: | |
| 127 return | |
| 128 CheckForName(name, isolate->heap()->byte_length_string(), | |
| 129 JSDataView::kByteLengthOffset, object_offset) || | |
| 130 CheckForName(name, isolate->heap()->byte_offset_string(), | |
| 131 JSDataView::kByteOffsetOffset, object_offset) || | |
| 132 CheckForName(name, isolate->heap()->buffer_string(), | |
| 133 JSDataView::kBufferOffset, object_offset); | |
| 134 default: | |
| 135 return false; | |
| 136 } | |
| 137 } | |
| 138 | |
| 139 | |
| 140 // | 82 // |
| 141 // Accessors::ArrayLength | 83 // Accessors::ArrayLength |
| 142 // | 84 // |
| 143 | 85 |
| 144 | 86 |
| 145 MaybeObject* Accessors::ArrayGetLength(Isolate* isolate, | 87 MaybeObject* Accessors::ArrayGetLength(Isolate* isolate, |
| 146 Object* object, | 88 Object* object, |
| 147 void*) { | 89 void*) { |
| 148 // Traverse the prototype chain until we reach an array. | 90 // Traverse the prototype chain until we reach an array. |
| 149 JSArray* holder = FindInstanceOf<JSArray>(isolate, object); | 91 JSArray* holder = FindInstanceOf<JSArray>(isolate, object); |
| (...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 973 info->set_data(Smi::FromInt(index)); | 915 info->set_data(Smi::FromInt(index)); |
| 974 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); | 916 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); |
| 975 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); | 917 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); |
| 976 info->set_getter(*getter); | 918 info->set_getter(*getter); |
| 977 if (!(attributes & ReadOnly)) info->set_setter(*setter); | 919 if (!(attributes & ReadOnly)) info->set_setter(*setter); |
| 978 return info; | 920 return info; |
| 979 } | 921 } |
| 980 | 922 |
| 981 | 923 |
| 982 } } // namespace v8::internal | 924 } } // namespace v8::internal |
| OLD | NEW |