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

Unified Diff: src/scopes.cc

Issue 1332873003: Implement sloppy-mode block-defined functions (Annex B 3.3) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: An extra test and comment fix Created 5 years, 3 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/scopes.cc
diff --git a/src/scopes.cc b/src/scopes.cc
index 963d539afb96e664e8b2f063a14f7e85ee03048f..511cda265a18dc56f98e0d317d58cf32246d43a7 100644
--- a/src/scopes.cc
+++ b/src/scopes.cc
@@ -66,6 +66,30 @@ Variable* VariableMap::Lookup(const AstRawString* name) {
}
+SloppyBlockFunctionMap::SloppyBlockFunctionMap(Zone* zone)
+ : ZoneHashMap(ZoneHashMap::PointersMatch, 8, ZoneAllocationPolicy(zone)),
+ zone_(zone) {}
+SloppyBlockFunctionMap::~SloppyBlockFunctionMap() {}
+
+
+void SloppyBlockFunctionMap::Declare(const AstRawString* name,
+ DelegateStatement* stmt) {
+ // AstRawStrings are unambiguous, i.e., the same string is always represented
+ // by the same AstRawString*.
+ // FIXME(marja): fix the type of Lookup.
adamk 2015/09/11 15:42:56 What's this TODO about? The return value seems fin
Dan Ehrenberg 2015/09/17 17:44:10 I think it's about using the hash. I copied it fro
+ Entry* p =
+ ZoneHashMap::LookupOrInsert(const_cast<AstRawString*>(name), name->hash(),
+ ZoneAllocationPolicy(zone_));
+ if (!p->value) {
adamk 2015/09/11 15:42:56 Nit: p->value == nullptr is the v8 style here, gen
Dan Ehrenberg 2015/09/17 17:44:10 Done
+ p->value = new (zone_->New(sizeof(ZoneVector<DelegateStatement*>)))
adamk 2015/09/11 15:42:56 Might be worth typedefing ZoneVector<DelegateState
Dan Ehrenberg 2015/09/17 17:44:10 Done
+ ZoneVector<DelegateStatement*>(zone_);
+ }
+ ZoneVector<DelegateStatement*>* delegates =
+ reinterpret_cast<ZoneVector<DelegateStatement*>*>(p->value);
+ delegates->push_back(stmt);
+}
+
+
// ----------------------------------------------------------------------------
// Implementation of Scope
@@ -79,6 +103,7 @@ Scope::Scope(Zone* zone, Scope* outer_scope, ScopeType scope_type,
decls_(4, zone),
module_descriptor_(
scope_type == MODULE_SCOPE ? ModuleDescriptor::New(zone) : NULL),
+ sloppy_block_function_map_(zone),
already_resolved_(false),
ast_value_factory_(ast_value_factory),
zone_(zone),
@@ -100,6 +125,7 @@ Scope::Scope(Zone* zone, Scope* inner_scope, ScopeType scope_type,
unresolved_(16, zone),
decls_(4, zone),
module_descriptor_(NULL),
+ sloppy_block_function_map_(zone),
already_resolved_(true),
ast_value_factory_(value_factory),
zone_(zone),
@@ -125,6 +151,7 @@ Scope::Scope(Zone* zone, Scope* inner_scope,
unresolved_(0, zone),
decls_(0, zone),
module_descriptor_(NULL),
+ sloppy_block_function_map_(zone),
already_resolved_(true),
ast_value_factory_(value_factory),
zone_(zone),

Powered by Google App Engine
This is Rietveld 408576698