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

Unified Diff: src/ast/scopes.cc

Issue 2109733003: Add errors for declarations which conflict with catch parameters. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: correct loop index Created 4 years, 6 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 95ab56a46c20978bcb8fc0c204c369b9c0d92623..f5e3e7405567d5563b9d90a5778c62c3f98a1d1e 100644
--- a/src/ast/scopes.cc
+++ b/src/ast/scopes.cc
@@ -141,7 +141,7 @@ Scope::Scope(Zone* zone, Scope* inner_scope,
zone_(zone) {
SetDefaults(CATCH_SCOPE, NULL, Handle<ScopeInfo>::null());
AddInnerScope(inner_scope);
- ++num_var_or_const_;
+ ++num_var_;
num_heap_slots_ = Context::MIN_CONTEXT_SLOTS;
Variable* variable = variables_.Declare(this,
catch_variable_name,
@@ -185,7 +185,7 @@ void Scope::SetDefaults(ScopeType scope_type, Scope* outer_scope,
force_eager_compilation_ = false;
force_context_allocation_ = (outer_scope != NULL && !is_function_scope())
? outer_scope->has_forced_context_allocation() : false;
- num_var_or_const_ = 0;
+ num_var_ = 0;
num_stack_slots_ = 0;
num_heap_slots_ = 0;
num_global_slots_ = 0;
@@ -339,8 +339,7 @@ Scope* Scope::FinalizeBlockScope() {
DCHECK(temps_.is_empty());
DCHECK(params_.is_empty());
- if (num_var_or_const() > 0 ||
- (is_declaration_scope() && calls_sloppy_eval())) {
+ if (num_var() > 0 || (is_declaration_scope() && calls_sloppy_eval())) {
return this;
}
@@ -512,7 +511,7 @@ Variable* Scope::DeclareLocal(const AstRawString* name, VariableMode mode,
// introduced during variable allocation, and TEMPORARY variables are
// allocated via NewTemporary().
DCHECK(IsDeclaredVariableMode(mode));
- ++num_var_or_const_;
+ ++num_var_;
return variables_.Declare(this, name, mode, kind, init_flag,
maybe_assigned_flag);
}
@@ -611,6 +610,25 @@ Declaration* Scope::CheckConflictingVarDeclarations() {
return NULL;
}
+Declaration* Scope::CheckLexDeclarationsConflictingWith(
adamk 2016/07/01 19:14:03 Is this only called on block scopes? Can you add a
+ ZoneList<const AstRawString*>* names) {
+ int length = names->length();
adamk 2016/07/01 19:14:04 Nit: should be no need to hoist this.
+ for (int i = 0; i < length; ++i) {
+ Variable* var = LookupLocal(names->at(i));
+ if (var != nullptr && IsLexicalVariableMode(var->mode())) {
adamk 2016/07/01 19:14:03 If my DCHECK suggestion above is correct, then can
+ // Conflict; find and return its declaration.
+ const AstRawString* name = names->at(i);
+ int decls_length = decls_.length();
adamk 2016/07/01 19:14:04 Again, no need to hoist this out of the loop.
+ for (int j = 0; j < decls_length; ++j) {
+ if (decls_[j]->proxy()->raw_name() == name) {
+ return decls_[j];
+ }
+ }
+ DCHECK(false);
+ }
+ }
+ return nullptr;
+}
class VarAndOrder {
public:

Powered by Google App Engine
This is Rietveld 408576698