OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 "src/accessors.h" | 5 #include "src/accessors.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/contexts.h" | 8 #include "src/contexts.h" |
9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
10 #include "src/execution.h" | 10 #include "src/execution.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 | 195 |
196 Handle<AccessorInfo> Accessors::ArrayLengthInfo( | 196 Handle<AccessorInfo> Accessors::ArrayLengthInfo( |
197 Isolate* isolate, PropertyAttributes attributes) { | 197 Isolate* isolate, PropertyAttributes attributes) { |
198 return MakeAccessor(isolate, | 198 return MakeAccessor(isolate, |
199 isolate->factory()->length_string(), | 199 isolate->factory()->length_string(), |
200 &ArrayLengthGetter, | 200 &ArrayLengthGetter, |
201 &ArrayLengthSetter, | 201 &ArrayLengthSetter, |
202 attributes); | 202 attributes); |
203 } | 203 } |
204 | 204 |
| 205 // |
| 206 // Accessors::ModuleNamespaceToStringTag |
| 207 // |
| 208 |
| 209 void Accessors::ModuleNamespaceToStringTagGetter( |
| 210 v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 211 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 212 info.GetReturnValue().Set( |
| 213 Utils::ToLocal(isolate->factory()->NewStringFromAsciiChecked("Module"))); |
| 214 } |
| 215 |
| 216 Handle<AccessorInfo> Accessors::ModuleNamespaceToStringTagInfo( |
| 217 Isolate* isolate, PropertyAttributes attributes) { |
| 218 Handle<Name> name = isolate->factory()->to_string_tag_symbol(); |
| 219 return MakeAccessor(isolate, name, &ModuleNamespaceToStringTagGetter, nullptr, |
| 220 attributes); |
| 221 } |
| 222 |
| 223 // |
| 224 // Accessors::ModuleNamespaceEntry |
| 225 // |
| 226 |
| 227 void Accessors::ModuleNamespaceEntryGetter( |
| 228 v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 229 DisallowHeapAllocation no_allocation; |
| 230 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 231 HandleScope scope(isolate); |
| 232 JSModuleNamespace* holder = |
| 233 JSModuleNamespace::cast(*Utils::OpenHandle(*info.Holder())); |
| 234 Object* result = holder->Get(Handle<String>::cast(Utils::OpenHandle(*name))); |
| 235 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(result, isolate))); |
| 236 } |
| 237 |
| 238 void Accessors::ModuleNamespaceEntrySetter( |
| 239 v8::Local<v8::Name> name, v8::Local<v8::Value> val, |
| 240 const v8::PropertyCallbackInfo<void>& info) { |
| 241 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 242 HandleScope scope(isolate); |
| 243 Factory* factory = isolate->factory(); |
| 244 Handle<JSModuleNamespace> holder = |
| 245 Handle<JSModuleNamespace>::cast(Utils::OpenHandle(*info.Holder())); |
| 246 |
| 247 if (info.ShouldThrowOnError()) { |
| 248 isolate->Throw(*factory->NewTypeError( |
| 249 MessageTemplate::kStrictReadOnlyProperty, Utils::OpenHandle(*name), |
| 250 i::Object::TypeOf(isolate, holder), holder)); |
| 251 isolate->OptionalRescheduleException(false); |
| 252 } else { |
| 253 info.GetReturnValue().Set(Utils::ToLocal(factory->ToBoolean(false))); |
| 254 } |
| 255 } |
| 256 |
| 257 Handle<AccessorInfo> Accessors::ModuleNamespaceEntryInfo( |
| 258 Isolate* isolate, Handle<String> name, PropertyAttributes attributes) { |
| 259 return MakeAccessor(isolate, name, &ModuleNamespaceEntryGetter, |
| 260 &ModuleNamespaceEntrySetter, attributes); |
| 261 } |
| 262 |
205 | 263 |
206 // | 264 // |
207 // Accessors::StringLength | 265 // Accessors::StringLength |
208 // | 266 // |
209 | 267 |
210 void Accessors::StringLengthGetter( | 268 void Accessors::StringLengthGetter( |
211 v8::Local<v8::Name> name, | 269 v8::Local<v8::Name> name, |
212 const v8::PropertyCallbackInfo<v8::Value>& info) { | 270 const v8::PropertyCallbackInfo<v8::Value>& info) { |
213 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 271 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
214 DisallowHeapAllocation no_allocation; | 272 DisallowHeapAllocation no_allocation; |
(...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1227 Handle<AccessorInfo> Accessors::ErrorStackInfo(Isolate* isolate, | 1285 Handle<AccessorInfo> Accessors::ErrorStackInfo(Isolate* isolate, |
1228 PropertyAttributes attributes) { | 1286 PropertyAttributes attributes) { |
1229 Handle<AccessorInfo> info = | 1287 Handle<AccessorInfo> info = |
1230 MakeAccessor(isolate, isolate->factory()->stack_string(), | 1288 MakeAccessor(isolate, isolate->factory()->stack_string(), |
1231 &ErrorStackGetter, &ErrorStackSetter, attributes); | 1289 &ErrorStackGetter, &ErrorStackSetter, attributes); |
1232 return info; | 1290 return info; |
1233 } | 1291 } |
1234 | 1292 |
1235 } // namespace internal | 1293 } // namespace internal |
1236 } // namespace v8 | 1294 } // namespace v8 |
OLD | NEW |