| 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/contexts.h" |     9 #include "src/contexts.h" | 
|    10 #include "src/deoptimizer.h" |    10 #include "src/deoptimizer.h" | 
| (...skipping 1384 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1395 // |  1395 // | 
|  1396 // Accessors::MakeModuleExport |  1396 // Accessors::MakeModuleExport | 
|  1397 // |  1397 // | 
|  1398  |  1398  | 
|  1399 static void ModuleGetExport( |  1399 static void ModuleGetExport( | 
|  1400     v8::Local<v8::String> property, |  1400     v8::Local<v8::String> property, | 
|  1401     const v8::PropertyCallbackInfo<v8::Value>& info) { |  1401     const v8::PropertyCallbackInfo<v8::Value>& info) { | 
|  1402   JSModule* instance = JSModule::cast(*v8::Utils::OpenHandle(*info.Holder())); |  1402   JSModule* instance = JSModule::cast(*v8::Utils::OpenHandle(*info.Holder())); | 
|  1403   Context* context = Context::cast(instance->context()); |  1403   Context* context = Context::cast(instance->context()); | 
|  1404   DCHECK(context->IsModuleContext()); |  1404   DCHECK(context->IsModuleContext()); | 
|  1405   int slot = info.Data()->Int32Value(); |  1405   Isolate* isolate = instance->GetIsolate(); | 
 |  1406   int slot = info.Data() | 
 |  1407                  ->Int32Value(info.GetIsolate()->GetCurrentContext()) | 
 |  1408                  .FromMaybe(-1); | 
 |  1409   if (slot < 0 || slot >= context->length()) { | 
 |  1410     Handle<String> name = v8::Utils::OpenHandle(*property); | 
 |  1411  | 
 |  1412     Handle<Object> exception = isolate->factory()->NewReferenceError( | 
 |  1413         MessageTemplate::kNotDefined, name); | 
 |  1414     isolate->ScheduleThrow(*exception); | 
 |  1415     return; | 
 |  1416   } | 
|  1406   Object* value = context->get(slot); |  1417   Object* value = context->get(slot); | 
|  1407   Isolate* isolate = instance->GetIsolate(); |  | 
|  1408   if (value->IsTheHole()) { |  1418   if (value->IsTheHole()) { | 
|  1409     Handle<String> name = v8::Utils::OpenHandle(*property); |  1419     Handle<String> name = v8::Utils::OpenHandle(*property); | 
|  1410  |  1420  | 
|  1411     Handle<Object> exception = isolate->factory()->NewReferenceError( |  1421     Handle<Object> exception = isolate->factory()->NewReferenceError( | 
|  1412         MessageTemplate::kNotDefined, name); |  1422         MessageTemplate::kNotDefined, name); | 
|  1413     isolate->ScheduleThrow(*exception); |  1423     isolate->ScheduleThrow(*exception); | 
|  1414     return; |  1424     return; | 
|  1415   } |  1425   } | 
|  1416   info.GetReturnValue().Set(v8::Utils::ToLocal(Handle<Object>(value, isolate))); |  1426   info.GetReturnValue().Set(v8::Utils::ToLocal(Handle<Object>(value, isolate))); | 
|  1417 } |  1427 } | 
|  1418  |  1428  | 
|  1419  |  1429  | 
|  1420 static void ModuleSetExport( |  1430 static void ModuleSetExport( | 
|  1421     v8::Local<v8::String> property, |  1431     v8::Local<v8::String> property, | 
|  1422     v8::Local<v8::Value> value, |  1432     v8::Local<v8::Value> value, | 
|  1423     const v8::PropertyCallbackInfo<v8::Value>& info) { |  1433     const v8::PropertyCallbackInfo<v8::Value>& info) { | 
|  1424   JSModule* instance = JSModule::cast(*v8::Utils::OpenHandle(*info.Holder())); |  1434   JSModule* instance = JSModule::cast(*v8::Utils::OpenHandle(*info.Holder())); | 
|  1425   Context* context = Context::cast(instance->context()); |  1435   Context* context = Context::cast(instance->context()); | 
|  1426   DCHECK(context->IsModuleContext()); |  1436   DCHECK(context->IsModuleContext()); | 
|  1427   int slot = info.Data()->Int32Value(); |  1437   Isolate* isolate = instance->GetIsolate(); | 
 |  1438   int slot = info.Data() | 
 |  1439                  ->Int32Value(info.GetIsolate()->GetCurrentContext()) | 
 |  1440                  .FromMaybe(-1); | 
 |  1441   if (slot < 0 || slot >= context->length()) { | 
 |  1442     Handle<String> name = v8::Utils::OpenHandle(*property); | 
 |  1443     Handle<Object> exception = isolate->factory()->NewReferenceError( | 
 |  1444         MessageTemplate::kNotDefined, name); | 
 |  1445     isolate->ScheduleThrow(*exception); | 
 |  1446     return; | 
 |  1447   } | 
|  1428   Object* old_value = context->get(slot); |  1448   Object* old_value = context->get(slot); | 
|  1429   Isolate* isolate = context->GetIsolate(); |  | 
|  1430   if (old_value->IsTheHole()) { |  1449   if (old_value->IsTheHole()) { | 
|  1431     Handle<String> name = v8::Utils::OpenHandle(*property); |  1450     Handle<String> name = v8::Utils::OpenHandle(*property); | 
|  1432     Handle<Object> exception = isolate->factory()->NewReferenceError( |  1451     Handle<Object> exception = isolate->factory()->NewReferenceError( | 
|  1433         MessageTemplate::kNotDefined, name); |  1452         MessageTemplate::kNotDefined, name); | 
|  1434     isolate->ScheduleThrow(*exception); |  1453     isolate->ScheduleThrow(*exception); | 
|  1435     return; |  1454     return; | 
|  1436   } |  1455   } | 
|  1437   context->set(slot, *v8::Utils::OpenHandle(*value)); |  1456   context->set(slot, *v8::Utils::OpenHandle(*value)); | 
|  1438 } |  1457 } | 
|  1439  |  1458  | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
|  1453   Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); |  1472   Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); | 
|  1454   Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); |  1473   Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); | 
|  1455   info->set_getter(*getter); |  1474   info->set_getter(*getter); | 
|  1456   if (!(attributes & ReadOnly)) info->set_setter(*setter); |  1475   if (!(attributes & ReadOnly)) info->set_setter(*setter); | 
|  1457   return info; |  1476   return info; | 
|  1458 } |  1477 } | 
|  1459  |  1478  | 
|  1460  |  1479  | 
|  1461 }  // namespace internal |  1480 }  // namespace internal | 
|  1462 }  // namespace v8 |  1481 }  // namespace v8 | 
| OLD | NEW |