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 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 230 HandleScope scope(isolate); |
| 231 JSModuleNamespace* holder = |
| 232 JSModuleNamespace::cast(*Utils::OpenHandle(*info.Holder())); |
| 233 Handle<Object> result; |
| 234 if (!holder->GetExport(Handle<String>::cast(Utils::OpenHandle(*name))) |
| 235 .ToHandle(&result)) { |
| 236 isolate->OptionalRescheduleException(false); |
| 237 } else { |
| 238 info.GetReturnValue().Set(Utils::ToLocal(result)); |
| 239 } |
| 240 } |
| 241 |
| 242 void Accessors::ModuleNamespaceEntrySetter( |
| 243 v8::Local<v8::Name> name, v8::Local<v8::Value> val, |
| 244 const v8::PropertyCallbackInfo<void>& info) { |
| 245 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 246 HandleScope scope(isolate); |
| 247 Factory* factory = isolate->factory(); |
| 248 Handle<JSModuleNamespace> holder = |
| 249 Handle<JSModuleNamespace>::cast(Utils::OpenHandle(*info.Holder())); |
| 250 |
| 251 if (info.ShouldThrowOnError()) { |
| 252 isolate->Throw(*factory->NewTypeError( |
| 253 MessageTemplate::kStrictReadOnlyProperty, Utils::OpenHandle(*name), |
| 254 i::Object::TypeOf(isolate, holder), holder)); |
| 255 isolate->OptionalRescheduleException(false); |
| 256 } else { |
| 257 info.GetReturnValue().Set(Utils::ToLocal(factory->ToBoolean(false))); |
| 258 } |
| 259 } |
| 260 |
| 261 Handle<AccessorInfo> Accessors::ModuleNamespaceEntryInfo( |
| 262 Isolate* isolate, Handle<String> name, PropertyAttributes attributes) { |
| 263 return MakeAccessor(isolate, name, &ModuleNamespaceEntryGetter, |
| 264 &ModuleNamespaceEntrySetter, attributes); |
| 265 } |
| 266 |
205 | 267 |
206 // | 268 // |
207 // Accessors::StringLength | 269 // Accessors::StringLength |
208 // | 270 // |
209 | 271 |
210 void Accessors::StringLengthGetter( | 272 void Accessors::StringLengthGetter( |
211 v8::Local<v8::Name> name, | 273 v8::Local<v8::Name> name, |
212 const v8::PropertyCallbackInfo<v8::Value>& info) { | 274 const v8::PropertyCallbackInfo<v8::Value>& info) { |
213 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 275 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
214 DisallowHeapAllocation no_allocation; | 276 DisallowHeapAllocation no_allocation; |
(...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1227 Handle<AccessorInfo> Accessors::ErrorStackInfo(Isolate* isolate, | 1289 Handle<AccessorInfo> Accessors::ErrorStackInfo(Isolate* isolate, |
1228 PropertyAttributes attributes) { | 1290 PropertyAttributes attributes) { |
1229 Handle<AccessorInfo> info = | 1291 Handle<AccessorInfo> info = |
1230 MakeAccessor(isolate, isolate->factory()->stack_string(), | 1292 MakeAccessor(isolate, isolate->factory()->stack_string(), |
1231 &ErrorStackGetter, &ErrorStackSetter, attributes); | 1293 &ErrorStackGetter, &ErrorStackSetter, attributes); |
1232 return info; | 1294 return info; |
1233 } | 1295 } |
1234 | 1296 |
1235 } // namespace internal | 1297 } // namespace internal |
1236 } // namespace v8 | 1298 } // namespace v8 |
OLD | NEW |