| Index: src/api.cc
|
| diff --git a/src/api.cc b/src/api.cc
|
| index 2d2bd1f23b8b11d80b6c1bc190a856b43b15ac99..57112cd6ec2898506d36a2e614fc99948f96e240 100644
|
| --- a/src/api.cc
|
| +++ b/src/api.cc
|
| @@ -22,6 +22,7 @@
|
| #include "src/bootstrapper.h"
|
| #include "src/code-stubs.h"
|
| #include "src/compiler.h"
|
| +#include "src/contexts.h"
|
| #include "src/conversions-inl.h"
|
| #include "src/counters.h"
|
| #include "src/cpu-profiler.h"
|
| @@ -36,6 +37,7 @@
|
| #include "src/messages.h"
|
| #include "src/natives.h"
|
| #include "src/parser.h"
|
| +#include "src/pending-compilation-error-handler.h"
|
| #include "src/profile-generator-inl.h"
|
| #include "src/property.h"
|
| #include "src/property-details.h"
|
| @@ -1490,9 +1492,36 @@ Local<Script> UnboundScript::BindToCurrentContext() {
|
| i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this));
|
| i::Handle<i::SharedFunctionInfo>
|
| function_info(i::SharedFunctionInfo::cast(*obj), obj->GetIsolate());
|
| + i::Isolate* isolate = obj->GetIsolate();
|
| +
|
| + i::ScopeInfo* scope_info = function_info->scope_info();
|
| + i::Handle<i::JSReceiver> global(isolate->native_context()->global_object());
|
| + for (int i = 0; i < scope_info->StrongModeFreeVariableCount(); ++i) {
|
| + i::Handle<i::String> name_string(scope_info->StrongModeFreeVariableName(i));
|
| + i::ScriptContextTable::LookupResult result;
|
| + i::Handle<i::ScriptContextTable> script_context_table(
|
| + isolate->native_context()->script_context_table());
|
| + if (!i::ScriptContextTable::Lookup(script_context_table, name_string,
|
| + &result)) {
|
| + i::Handle<i::Name> name(scope_info->StrongModeFreeVariableName(i));
|
| + Maybe<bool> has = i::JSReceiver::HasProperty(global, name);
|
| + if (has.IsJust() && !has.FromJust()) {
|
| + i::PendingCompilationErrorHandler pending_error_handler_;
|
| + pending_error_handler_.ReportMessageAt(
|
| + scope_info->StrongModeFreeVariableStartPosition(i),
|
| + scope_info->StrongModeFreeVariableEndPosition(i),
|
| + "strong_unbound_global", name_string, i::kReferenceError);
|
| + i::Handle<i::Script> script(i::Script::cast(function_info->script()));
|
| + pending_error_handler_.ThrowPendingError(isolate, script);
|
| + isolate->ReportPendingMessages();
|
| + isolate->OptionalRescheduleException(true);
|
| + return Local<Script>();
|
| + }
|
| + }
|
| + }
|
| i::Handle<i::JSFunction> function =
|
| obj->GetIsolate()->factory()->NewFunctionFromSharedFunctionInfo(
|
| - function_info, obj->GetIsolate()->native_context());
|
| + function_info, isolate->native_context());
|
| return ToApiHandle<Script>(function);
|
| }
|
|
|
| @@ -1940,7 +1969,9 @@ MaybeLocal<Script> ScriptCompiler::Compile(Local<Context> context,
|
| i::Handle<i::SharedFunctionInfo> result(raw_result, isolate);
|
| Local<UnboundScript> generic = ToApiHandle<UnboundScript>(result);
|
| if (generic.IsEmpty()) return Local<Script>();
|
| - RETURN_ESCAPED(generic->BindToCurrentContext());
|
| + Local<Script> bound = generic->BindToCurrentContext();
|
| + if (bound.IsEmpty()) return Local<Script>();
|
| + RETURN_ESCAPED(bound);
|
| }
|
|
|
|
|
|
|