| 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/api.h" | 8 #include "src/api.h" |
| 9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
| 10 #include "src/contexts.h" | 10 #include "src/contexts.h" |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 isolate->OptionalRescheduleException(false); | 255 isolate->OptionalRescheduleException(false); |
| 256 return; | 256 return; |
| 257 } | 257 } |
| 258 | 258 |
| 259 if (uint32_v->Number() == number_v->Number()) { | 259 if (uint32_v->Number() == number_v->Number()) { |
| 260 maybe = JSArray::SetElementsLength(array_handle, uint32_v); | 260 maybe = JSArray::SetElementsLength(array_handle, uint32_v); |
| 261 maybe.Check(); | 261 maybe.Check(); |
| 262 return; | 262 return; |
| 263 } | 263 } |
| 264 | 264 |
| 265 isolate->ScheduleThrow( | 265 Handle<Object> exception; |
| 266 *isolate->factory()->NewRangeError("invalid_array_length", | 266 maybe = isolate->factory()->NewRangeError("invalid_array_length", |
| 267 HandleVector<Object>(NULL, 0))); | 267 HandleVector<Object>(NULL, 0)); |
| 268 if (!maybe.ToHandle(&exception)) { |
| 269 isolate->OptionalRescheduleException(false); |
| 270 return; |
| 271 } |
| 272 |
| 273 isolate->ScheduleThrow(*exception); |
| 268 } | 274 } |
| 269 | 275 |
| 270 | 276 |
| 271 Handle<AccessorInfo> Accessors::ArrayLengthInfo( | 277 Handle<AccessorInfo> Accessors::ArrayLengthInfo( |
| 272 Isolate* isolate, PropertyAttributes attributes) { | 278 Isolate* isolate, PropertyAttributes attributes) { |
| 273 return MakeAccessor(isolate, | 279 return MakeAccessor(isolate, |
| 274 isolate->factory()->length_string(), | 280 isolate->factory()->length_string(), |
| 275 &ArrayLengthGetter, | 281 &ArrayLengthGetter, |
| 276 &ArrayLengthSetter, | 282 &ArrayLengthSetter, |
| 277 attributes); | 283 attributes); |
| (...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1343 v8::Local<v8::String> property, | 1349 v8::Local<v8::String> property, |
| 1344 const v8::PropertyCallbackInfo<v8::Value>& info) { | 1350 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 1345 JSModule* instance = JSModule::cast(*v8::Utils::OpenHandle(*info.Holder())); | 1351 JSModule* instance = JSModule::cast(*v8::Utils::OpenHandle(*info.Holder())); |
| 1346 Context* context = Context::cast(instance->context()); | 1352 Context* context = Context::cast(instance->context()); |
| 1347 DCHECK(context->IsModuleContext()); | 1353 DCHECK(context->IsModuleContext()); |
| 1348 int slot = info.Data()->Int32Value(); | 1354 int slot = info.Data()->Int32Value(); |
| 1349 Object* value = context->get(slot); | 1355 Object* value = context->get(slot); |
| 1350 Isolate* isolate = instance->GetIsolate(); | 1356 Isolate* isolate = instance->GetIsolate(); |
| 1351 if (value->IsTheHole()) { | 1357 if (value->IsTheHole()) { |
| 1352 Handle<String> name = v8::Utils::OpenHandle(*property); | 1358 Handle<String> name = v8::Utils::OpenHandle(*property); |
| 1353 isolate->ScheduleThrow( | 1359 |
| 1354 *isolate->factory()->NewReferenceError("not_defined", | 1360 Handle<Object> exception; |
| 1355 HandleVector(&name, 1))); | 1361 MaybeHandle<Object> maybe = isolate->factory()->NewReferenceError( |
| 1362 "not_defined", HandleVector(&name, 1)); |
| 1363 if (!maybe.ToHandle(&exception)) { |
| 1364 isolate->OptionalRescheduleException(false); |
| 1365 return; |
| 1366 } |
| 1367 |
| 1368 isolate->ScheduleThrow(*exception); |
| 1356 return; | 1369 return; |
| 1357 } | 1370 } |
| 1358 info.GetReturnValue().Set(v8::Utils::ToLocal(Handle<Object>(value, isolate))); | 1371 info.GetReturnValue().Set(v8::Utils::ToLocal(Handle<Object>(value, isolate))); |
| 1359 } | 1372 } |
| 1360 | 1373 |
| 1361 | 1374 |
| 1362 static void ModuleSetExport( | 1375 static void ModuleSetExport( |
| 1363 v8::Local<v8::String> property, | 1376 v8::Local<v8::String> property, |
| 1364 v8::Local<v8::Value> value, | 1377 v8::Local<v8::Value> value, |
| 1365 const v8::PropertyCallbackInfo<v8::Value>& info) { | 1378 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 1366 JSModule* instance = JSModule::cast(*v8::Utils::OpenHandle(*info.Holder())); | 1379 JSModule* instance = JSModule::cast(*v8::Utils::OpenHandle(*info.Holder())); |
| 1367 Context* context = Context::cast(instance->context()); | 1380 Context* context = Context::cast(instance->context()); |
| 1368 DCHECK(context->IsModuleContext()); | 1381 DCHECK(context->IsModuleContext()); |
| 1369 int slot = info.Data()->Int32Value(); | 1382 int slot = info.Data()->Int32Value(); |
| 1370 Object* old_value = context->get(slot); | 1383 Object* old_value = context->get(slot); |
| 1384 Isolate* isolate = context->GetIsolate(); |
| 1371 if (old_value->IsTheHole()) { | 1385 if (old_value->IsTheHole()) { |
| 1372 Handle<String> name = v8::Utils::OpenHandle(*property); | 1386 Handle<String> name = v8::Utils::OpenHandle(*property); |
| 1373 Isolate* isolate = instance->GetIsolate(); | 1387 Handle<Object> exception; |
| 1374 isolate->ScheduleThrow( | 1388 MaybeHandle<Object> maybe = isolate->factory()->NewReferenceError( |
| 1375 *isolate->factory()->NewReferenceError("not_defined", | 1389 "not_defined", HandleVector(&name, 1)); |
| 1376 HandleVector(&name, 1))); | 1390 if (!maybe.ToHandle(&exception)) { |
| 1391 isolate->OptionalRescheduleException(false); |
| 1392 return; |
| 1393 } |
| 1394 |
| 1395 isolate->ScheduleThrow(*exception); |
| 1377 return; | 1396 return; |
| 1378 } | 1397 } |
| 1379 context->set(slot, *v8::Utils::OpenHandle(*value)); | 1398 context->set(slot, *v8::Utils::OpenHandle(*value)); |
| 1380 } | 1399 } |
| 1381 | 1400 |
| 1382 | 1401 |
| 1383 Handle<AccessorInfo> Accessors::MakeModuleExport( | 1402 Handle<AccessorInfo> Accessors::MakeModuleExport( |
| 1384 Handle<String> name, | 1403 Handle<String> name, |
| 1385 int index, | 1404 int index, |
| 1386 PropertyAttributes attributes) { | 1405 PropertyAttributes attributes) { |
| 1387 Isolate* isolate = name->GetIsolate(); | 1406 Isolate* isolate = name->GetIsolate(); |
| 1388 Factory* factory = isolate->factory(); | 1407 Factory* factory = isolate->factory(); |
| 1389 Handle<ExecutableAccessorInfo> info = factory->NewExecutableAccessorInfo(); | 1408 Handle<ExecutableAccessorInfo> info = factory->NewExecutableAccessorInfo(); |
| 1390 info->set_property_attributes(attributes); | 1409 info->set_property_attributes(attributes); |
| 1391 info->set_all_can_read(true); | 1410 info->set_all_can_read(true); |
| 1392 info->set_all_can_write(true); | 1411 info->set_all_can_write(true); |
| 1393 info->set_name(*name); | 1412 info->set_name(*name); |
| 1394 info->set_data(Smi::FromInt(index)); | 1413 info->set_data(Smi::FromInt(index)); |
| 1395 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); | 1414 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); |
| 1396 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); | 1415 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); |
| 1397 info->set_getter(*getter); | 1416 info->set_getter(*getter); |
| 1398 if (!(attributes & ReadOnly)) info->set_setter(*setter); | 1417 if (!(attributes & ReadOnly)) info->set_setter(*setter); |
| 1399 return info; | 1418 return info; |
| 1400 } | 1419 } |
| 1401 | 1420 |
| 1402 | 1421 |
| 1403 } } // namespace v8::internal | 1422 } } // namespace v8::internal |
| OLD | NEW |