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

Unified Diff: src/ast/scopes.cc

Issue 2231813003: Make Variable::is_this always return the correct value (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: remove patch 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
Index: src/ast/scopes.cc
diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc
index 9dc1f422ec0c9c9f3023b566163d174c1cc34679..7a5b6a4d733e1936eb94de61f3edf05d583d5b82 100644
--- a/src/ast/scopes.cc
+++ b/src/ast/scopes.cc
@@ -674,10 +674,11 @@ Variable* Scope::DeclareLocal(const AstRawString* name, VariableMode mode,
maybe_assigned_flag);
}
-Variable* DeclarationScope::DeclareDynamicGlobal(const AstRawString* name) {
+Variable* DeclarationScope::DeclareDynamicGlobal(const AstRawString* name,
+ Variable::Kind kind) {
DCHECK(is_script_scope());
- return variables_.Declare(zone(), this, name, DYNAMIC_GLOBAL,
- Variable::NORMAL, kCreatedInitialized);
+ return variables_.Declare(zone(), this, name, DYNAMIC_GLOBAL, kind,
+ kCreatedInitialized);
}
@@ -1251,8 +1252,8 @@ void Scope::CheckZones() {
}
#endif // DEBUG
-
-Variable* Scope::NonLocal(const AstRawString* name, VariableMode mode) {
+Variable* Scope::NonLocal(const AstRawString* name, VariableMode mode,
+ Variable::Kind kind) {
if (dynamics_ == NULL) dynamics_ = new (zone()) DynamicScopePart(zone());
VariableMap* map = dynamics_->GetMap(mode);
Variable* var = map->Lookup(name);
@@ -1260,7 +1261,7 @@ Variable* Scope::NonLocal(const AstRawString* name, VariableMode mode) {
// Declare a new non-local.
InitializationFlag init_flag = (mode == VAR)
? kCreatedInitialized : kNeedsInitialization;
- var = map->Declare(zone(), NULL, name, mode, Variable::NORMAL, init_flag);
+ var = map->Declare(zone(), NULL, name, mode, kind, init_flag);
// Allocate it by giving it a dynamic lookup.
var->AllocateTo(VariableLocation::LOOKUP, -1);
}
@@ -1394,29 +1395,30 @@ void Scope::ResolveTo(ParseInfo* info, BindingKind binding_kind,
// scope which was not promoted to a context, this can happen if we use
// debugger to evaluate arbitrary expressions at a break point).
if (var->IsGlobalObjectProperty()) {
- var = NonLocal(proxy->raw_name(), DYNAMIC_GLOBAL);
+ var = NonLocal(proxy->raw_name(), DYNAMIC_GLOBAL, proxy->var_kind());
} else if (var->is_dynamic()) {
- var = NonLocal(proxy->raw_name(), DYNAMIC);
+ var = NonLocal(proxy->raw_name(), DYNAMIC, proxy->var_kind());
} else {
Variable* invalidated = var;
- var = NonLocal(proxy->raw_name(), DYNAMIC_LOCAL);
+ var = NonLocal(proxy->raw_name(), DYNAMIC_LOCAL, proxy->var_kind());
var->set_local_if_not_shadowed(invalidated);
}
break;
case UNBOUND:
// No binding has been found. Declare a variable on the global object.
- var = info->script_scope()->DeclareDynamicGlobal(proxy->raw_name());
+ var = info->script_scope()->DeclareDynamicGlobal(proxy->raw_name(),
+ proxy->var_kind());
break;
case UNBOUND_EVAL_SHADOWED:
// No binding has been found. But some scope makes a sloppy 'eval' call.
- var = NonLocal(proxy->raw_name(), DYNAMIC_GLOBAL);
+ var = NonLocal(proxy->raw_name(), DYNAMIC_GLOBAL, proxy->var_kind());
break;
case DYNAMIC_LOOKUP:
// The variable could not be resolved statically.
- var = NonLocal(proxy->raw_name(), DYNAMIC);
+ var = NonLocal(proxy->raw_name(), DYNAMIC, proxy->var_kind());
break;
}

Powered by Google App Engine
This is Rietveld 408576698