Index: src/runtime/runtime-scopes.cc |
diff --git a/src/runtime/runtime-scopes.cc b/src/runtime/runtime-scopes.cc |
index 4363190e3d029c10eb0e3c7c2831cbbe7e124244..5a6e3efddf59c98cfe7edadb318f205ff2cbd146 100644 |
--- a/src/runtime/runtime-scopes.cc |
+++ b/src/runtime/runtime-scopes.cc |
@@ -188,12 +188,12 @@ RUNTIME_FUNCTION(Runtime_InitializeConstGlobal) { |
return *value; |
} |
+RUNTIME_FUNCTION(Runtime_DeclareLookupSlot) { |
+ HandleScope scope(isolate); |
+ DCHECK_EQ(2, args.length()); |
+ CONVERT_ARG_HANDLE_CHECKED(String, name, 0); |
+ CONVERT_ARG_HANDLE_CHECKED(Object, initial_value, 1); |
-namespace { |
- |
-Object* DeclareLookupSlot(Isolate* isolate, Handle<String> name, |
- Handle<Object> initial_value, |
- PropertyAttributes attr) { |
// Declarations are always made in a function, eval or script context, or |
// a declaration block scope. |
// In the case of eval code, the context passed is the context of the caller, |
@@ -201,6 +201,10 @@ Object* DeclareLookupSlot(Isolate* isolate, Handle<String> name, |
Handle<Context> context_arg(isolate->context(), isolate); |
Handle<Context> context(context_arg->declaration_context(), isolate); |
+ DCHECK(context->IsFunctionContext() || context->IsNativeContext() || |
+ context->IsScriptContext() || |
+ (context->IsBlockContext() && context->has_extension())); |
+ |
// TODO(verwaest): Unify the encoding indicating "var" with DeclareGlobals. |
bool is_var = *initial_value == NULL; |
bool is_function = initial_value->IsJSFunction(); |
@@ -210,52 +214,40 @@ Object* DeclareLookupSlot(Isolate* isolate, Handle<String> name, |
PropertyAttributes attributes; |
BindingFlags binding_flags; |
- if ((attr & EVAL_DECLARED) != 0) { |
- // Check for a conflict with a lexically scoped variable |
- context_arg->Lookup(name, LEXICAL_TEST, &index, &attributes, |
- &binding_flags); |
- if (attributes != ABSENT && binding_flags == BINDING_CHECK_INITIALIZED) { |
- return ThrowRedeclarationError(isolate, name); |
- } |
- attr = static_cast<PropertyAttributes>(attr & ~EVAL_DECLARED); |
+ // Check for a conflict with a lexically scoped variable |
+ context_arg->Lookup(name, LEXICAL_TEST, &index, &attributes, &binding_flags); |
+ if (attributes != ABSENT && binding_flags == BINDING_CHECK_INITIALIZED) { |
+ return ThrowRedeclarationError(isolate, name); |
} |
Handle<Object> holder = context->Lookup(name, DONT_FOLLOW_CHAINS, &index, |
&attributes, &binding_flags); |
- if (holder.is_null()) { |
- // In case of JSProxy, an exception might have been thrown. |
- if (isolate->has_pending_exception()) return isolate->heap()->exception(); |
- } |
+ DCHECK(!isolate->has_pending_exception()); |
Handle<JSObject> object; |
Handle<Object> value = |
is_function ? initial_value |
: Handle<Object>::cast(isolate->factory()->undefined_value()); |
- // TODO(verwaest): This case should probably not be covered by this function, |
- // but by DeclareGlobals instead. |
if (attributes != ABSENT && holder->IsJSGlobalObject()) { |
return DeclareGlobals(isolate, Handle<JSGlobalObject>::cast(holder), name, |
- value, attr, is_var, is_function); |
+ value, NONE, is_var, is_function); |
} |
if (context_arg->extension()->IsJSGlobalObject()) { |
Handle<JSGlobalObject> global( |
JSGlobalObject::cast(context_arg->extension()), isolate); |
- return DeclareGlobals(isolate, global, name, value, attr, is_var, |
+ return DeclareGlobals(isolate, global, name, value, NONE, is_var, |
is_function); |
} else if (context->IsScriptContext()) { |
DCHECK(context->global_object()->IsJSGlobalObject()); |
Handle<JSGlobalObject> global( |
JSGlobalObject::cast(context->global_object()), isolate); |
- return DeclareGlobals(isolate, global, name, value, attr, is_var, |
+ return DeclareGlobals(isolate, global, name, value, NONE, is_var, |
is_function); |
} |
if (attributes != ABSENT) { |
- // The name was declared before; check for conflicting re-declarations. |
- if ((attributes & READ_ONLY) != 0) { |
- return ThrowRedeclarationError(isolate, name); |
- } |
+ DCHECK_EQ(NONE, attributes); |
// Skip var re-declarations. |
if (is_var) return isolate->heap()->undefined_value(); |
@@ -292,27 +284,11 @@ Object* DeclareLookupSlot(Isolate* isolate, Handle<String> name, |
} |
RETURN_FAILURE_ON_EXCEPTION(isolate, JSObject::SetOwnPropertyIgnoreAttributes( |
- object, name, value, attr)); |
+ object, name, value, NONE)); |
return isolate->heap()->undefined_value(); |
} |
-} // namespace |
- |
- |
-RUNTIME_FUNCTION(Runtime_DeclareLookupSlot) { |
- HandleScope scope(isolate); |
- DCHECK_EQ(3, args.length()); |
- CONVERT_ARG_HANDLE_CHECKED(String, name, 0); |
- CONVERT_ARG_HANDLE_CHECKED(Object, initial_value, 1); |
- CONVERT_ARG_HANDLE_CHECKED(Smi, property_attributes, 2); |
- |
- PropertyAttributes attributes = |
- static_cast<PropertyAttributes>(property_attributes->value()); |
- return DeclareLookupSlot(isolate, name, initial_value, attributes); |
-} |
- |
- |
namespace { |
// Find the arguments of the JavaScript function invocation that called |