| 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/api.h" | 5 #include "src/api.h" |
| 6 | 6 |
| 7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
| 8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
| 9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
| 10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
| (...skipping 1585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1596 } | 1596 } |
| 1597 | 1597 |
| 1598 | 1598 |
| 1599 Local<Script> UnboundScript::BindToCurrentContext() { | 1599 Local<Script> UnboundScript::BindToCurrentContext() { |
| 1600 i::Handle<i::HeapObject> obj = | 1600 i::Handle<i::HeapObject> obj = |
| 1601 i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this)); | 1601 i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this)); |
| 1602 i::Handle<i::SharedFunctionInfo> | 1602 i::Handle<i::SharedFunctionInfo> |
| 1603 function_info(i::SharedFunctionInfo::cast(*obj), obj->GetIsolate()); | 1603 function_info(i::SharedFunctionInfo::cast(*obj), obj->GetIsolate()); |
| 1604 i::Isolate* isolate = obj->GetIsolate(); | 1604 i::Isolate* isolate = obj->GetIsolate(); |
| 1605 | 1605 |
| 1606 i::ScopeInfo* scope_info = function_info->scope_info(); | |
| 1607 i::Handle<i::JSReceiver> global(isolate->native_context()->global_object()); | 1606 i::Handle<i::JSReceiver> global(isolate->native_context()->global_object()); |
| 1608 for (int i = 0; i < scope_info->StrongModeFreeVariableCount(); ++i) { | |
| 1609 i::Handle<i::String> name_string(scope_info->StrongModeFreeVariableName(i)); | |
| 1610 i::ScriptContextTable::LookupResult result; | |
| 1611 i::Handle<i::ScriptContextTable> script_context_table( | |
| 1612 isolate->native_context()->script_context_table()); | |
| 1613 if (!i::ScriptContextTable::Lookup(script_context_table, name_string, | |
| 1614 &result)) { | |
| 1615 i::Handle<i::Name> name(scope_info->StrongModeFreeVariableName(i)); | |
| 1616 Maybe<bool> has = i::JSReceiver::HasProperty(global, name); | |
| 1617 if (has.IsJust() && !has.FromJust()) { | |
| 1618 i::PendingCompilationErrorHandler pending_error_handler_; | |
| 1619 pending_error_handler_.ReportMessageAt( | |
| 1620 scope_info->StrongModeFreeVariableStartPosition(i), | |
| 1621 scope_info->StrongModeFreeVariableEndPosition(i), | |
| 1622 i::MessageTemplate::kStrongUnboundGlobal, name_string, | |
| 1623 i::kReferenceError); | |
| 1624 i::Handle<i::Script> script(i::Script::cast(function_info->script())); | |
| 1625 pending_error_handler_.ThrowPendingError(isolate, script); | |
| 1626 isolate->ReportPendingMessages(); | |
| 1627 isolate->OptionalRescheduleException(true); | |
| 1628 return Local<Script>(); | |
| 1629 } | |
| 1630 } | |
| 1631 } | |
| 1632 i::Handle<i::JSFunction> function = | 1607 i::Handle<i::JSFunction> function = |
| 1633 obj->GetIsolate()->factory()->NewFunctionFromSharedFunctionInfo( | 1608 obj->GetIsolate()->factory()->NewFunctionFromSharedFunctionInfo( |
| 1634 function_info, isolate->native_context()); | 1609 function_info, isolate->native_context()); |
| 1635 return ToApiHandle<Script>(function); | 1610 return ToApiHandle<Script>(function); |
| 1636 } | 1611 } |
| 1637 | 1612 |
| 1638 | 1613 |
| 1639 int UnboundScript::GetId() { | 1614 int UnboundScript::GetId() { |
| 1640 i::Handle<i::HeapObject> obj = | 1615 i::Handle<i::HeapObject> obj = |
| 1641 i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this)); | 1616 i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this)); |
| (...skipping 6912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8554 Address callback_address = | 8529 Address callback_address = |
| 8555 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8530 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 8556 VMState<EXTERNAL> state(isolate); | 8531 VMState<EXTERNAL> state(isolate); |
| 8557 ExternalCallbackScope call_scope(isolate, callback_address); | 8532 ExternalCallbackScope call_scope(isolate, callback_address); |
| 8558 callback(info); | 8533 callback(info); |
| 8559 } | 8534 } |
| 8560 | 8535 |
| 8561 | 8536 |
| 8562 } // namespace internal | 8537 } // namespace internal |
| 8563 } // namespace v8 | 8538 } // namespace v8 |
| OLD | NEW |