Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Unified Diff: src/contexts.cc

Issue 2200303002: Replace BindingFlags enum with InitializationFlag enum (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@fix-lexical-test
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/contexts.h ('k') | src/runtime/runtime-scopes.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/contexts.cc
diff --git a/src/contexts.cc b/src/contexts.cc
index f66e323333727b425d7f8da0b4cc78f40d936005..22c313ee047c31e2a0cece20cc28b48c433b2b36 100644
--- a/src/contexts.cc
+++ b/src/contexts.cc
@@ -176,51 +176,14 @@ static Maybe<bool> UnscopableLookup(LookupIterator* it) {
return Just(!blacklist->BooleanValue());
}
-static void GetAttributesAndBindingFlags(VariableMode mode,
- InitializationFlag init_flag,
- PropertyAttributes* attributes,
- BindingFlags* binding_flags) {
- switch (mode) {
- case VAR:
- *attributes = NONE;
- *binding_flags = BINDING_IS_INITIALIZED;
- break;
- case LET:
- *attributes = NONE;
- *binding_flags = (init_flag == kNeedsInitialization)
- ? BINDING_CHECK_INITIALIZED
- : BINDING_IS_INITIALIZED;
- break;
- case CONST_LEGACY:
- DCHECK_EQ(kCreatedInitialized, init_flag);
- *attributes = READ_ONLY;
- *binding_flags = BINDING_IS_INITIALIZED;
- break;
- case CONST:
- *attributes = READ_ONLY;
- *binding_flags = (init_flag == kNeedsInitialization)
- ? BINDING_CHECK_INITIALIZED
- : BINDING_IS_INITIALIZED;
- break;
- case IMPORT: // TODO(neis): Make sure this is what we want for IMPORT.
- case DYNAMIC:
- case DYNAMIC_GLOBAL:
- case DYNAMIC_LOCAL:
- case TEMPORARY:
- // Note: Fixed context slots are statically allocated by the compiler.
- // Statically allocated variables always have a statically known mode,
- // which is the mode with which they were declared when added to the
- // scope. Thus, the DYNAMIC mode (which corresponds to dynamically
- // declared variables that were introduced through declaration nodes)
- // must not appear here.
- UNREACHABLE();
- break;
- }
+static PropertyAttributes GetAttributesForMode(VariableMode mode) {
+ DCHECK(IsDeclaredVariableMode(mode));
+ return IsImmutableVariableMode(mode) ? READ_ONLY : NONE;
}
Handle<Object> Context::Lookup(Handle<String> name, ContextLookupFlags flags,
int* index, PropertyAttributes* attributes,
- BindingFlags* binding_flags,
+ InitializationFlag* init_flag,
VariableMode* variable_mode) {
Isolate* isolate = GetIsolate();
Handle<Context> context(this, isolate);
@@ -229,7 +192,7 @@ Handle<Object> Context::Lookup(Handle<String> name, ContextLookupFlags flags,
bool failed_whitelist = false;
*index = kNotFound;
*attributes = ABSENT;
- *binding_flags = MISSING_BINDING;
+ *init_flag = kCreatedInitialized;
*variable_mode = VAR;
if (FLAG_trace_contexts) {
@@ -270,8 +233,7 @@ Handle<Object> Context::Lookup(Handle<String> name, ContextLookupFlags flags,
}
*index = r.slot_index;
*variable_mode = r.mode;
- GetAttributesAndBindingFlags(r.mode, r.init_flag, attributes,
- binding_flags);
+ *attributes = GetAttributesForMode(r.mode);
return ScriptContextTable::GetContext(script_contexts,
r.context_index);
}
@@ -326,12 +288,10 @@ Handle<Object> Context::Lookup(Handle<String> name, ContextLookupFlags flags,
? context->closure()->shared()->scope_info()
: context->scope_info());
VariableMode mode;
- InitializationFlag init_flag;
- // TODO(sigurds) Figure out whether maybe_assigned_flag should
- // be used to compute binding_flags.
+ InitializationFlag flag;
MaybeAssignedFlag maybe_assigned_flag;
- int slot_index = ScopeInfo::ContextSlotIndex(
- scope_info, name, &mode, &init_flag, &maybe_assigned_flag);
+ int slot_index = ScopeInfo::ContextSlotIndex(scope_info, name, &mode,
+ &flag, &maybe_assigned_flag);
DCHECK(slot_index < 0 || slot_index >= MIN_CONTEXT_SLOTS);
if (slot_index >= 0) {
if (FLAG_trace_contexts) {
@@ -340,8 +300,8 @@ Handle<Object> Context::Lookup(Handle<String> name, ContextLookupFlags flags,
}
*index = slot_index;
*variable_mode = mode;
- GetAttributesAndBindingFlags(mode, init_flag, attributes,
- binding_flags);
+ *init_flag = flag;
+ *attributes = GetAttributesForMode(mode);
return context;
}
@@ -358,7 +318,7 @@ Handle<Object> Context::Lookup(Handle<String> name, ContextLookupFlags flags,
*index = function_index;
*attributes = READ_ONLY;
DCHECK(mode == CONST_LEGACY || mode == CONST);
- *binding_flags = BINDING_IS_INITIALIZED;
+ *init_flag = kCreatedInitialized;
*variable_mode = mode;
return context;
}
@@ -372,7 +332,7 @@ Handle<Object> Context::Lookup(Handle<String> name, ContextLookupFlags flags,
}
*index = Context::THROWN_OBJECT_INDEX;
*attributes = NONE;
- *binding_flags = BINDING_IS_INITIALIZED;
+ *init_flag = kCreatedInitialized;
*variable_mode = VAR;
return context;
}
@@ -391,9 +351,9 @@ Handle<Object> Context::Lookup(Handle<String> name, ContextLookupFlags flags,
// Check the original context, but do not follow its context chain.
obj = context->get(WRAPPED_CONTEXT_INDEX);
if (obj->IsContext()) {
- Handle<Object> result = Context::cast(obj)->Lookup(
- name, DONT_FOLLOW_CHAINS, index, attributes, binding_flags,
- variable_mode);
+ Handle<Object> result =
+ Context::cast(obj)->Lookup(name, DONT_FOLLOW_CHAINS, index,
+ attributes, init_flag, variable_mode);
if (!result.is_null()) return result;
}
// Check whitelist. Names that do not pass whitelist shall only resolve
« no previous file with comments | « src/contexts.h ('k') | src/runtime/runtime-scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698