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

Unified Diff: src/scopes.cc

Issue 8344046: Reapply r9673 "Scope tree serialization and ScopeIterator cleanup." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Skip nested contexts of an internal function. Created 9 years, 2 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/scopes.h ('k') | src/v8globals.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scopes.cc
diff --git a/src/scopes.cc b/src/scopes.cc
index 0ceecb2ba2c714004aaafc54b8d326518aeb902b..9672bd6642a6c6cbb3bf6101b174de8749695042 100644
--- a/src/scopes.cc
+++ b/src/scopes.cc
@@ -114,7 +114,7 @@ Variable* VariableMap::Lookup(Handle<String> name) {
// Dummy constructor
-Scope::Scope(Type type)
+Scope::Scope(ScopeType type)
: isolate_(Isolate::Current()),
inner_scopes_(0),
variables_(false),
@@ -127,7 +127,7 @@ Scope::Scope(Type type)
}
-Scope::Scope(Scope* outer_scope, Type type)
+Scope::Scope(Scope* outer_scope, ScopeType type)
: isolate_(Isolate::Current()),
inner_scopes_(4),
variables_(),
@@ -146,7 +146,7 @@ Scope::Scope(Scope* outer_scope, Type type)
Scope::Scope(Scope* inner_scope,
- Type type,
+ ScopeType type,
Handle<SerializedScopeInfo> scope_info)
: isolate_(Isolate::Current()),
inner_scopes_(4),
@@ -185,7 +185,7 @@ Scope::Scope(Scope* inner_scope, Handle<String> catch_variable_name)
}
-void Scope::SetDefaults(Type type,
+void Scope::SetDefaults(ScopeType type,
Scope* outer_scope,
Handle<SerializedScopeInfo> scope_info) {
outer_scope_ = outer_scope;
@@ -208,6 +208,8 @@ void Scope::SetDefaults(Type type,
num_stack_slots_ = 0;
num_heap_slots_ = 0;
scope_info_ = scope_info;
+ start_position_ = RelocInfo::kNoPosition;
+ end_position_ = RelocInfo::kNoPosition;
}
@@ -630,15 +632,33 @@ Handle<SerializedScopeInfo> Scope::GetSerializedScopeInfo() {
}
+void Scope::GetNestedScopeChain(
+ List<Handle<SerializedScopeInfo> >* chain,
+ int position) {
+ chain->Add(Handle<SerializedScopeInfo>(GetSerializedScopeInfo()));
+
+ for (int i = 0; i < inner_scopes_.length(); i++) {
+ Scope* scope = inner_scopes_[i];
+ int beg_pos = scope->start_position();
+ int end_pos = scope->end_position();
+ ASSERT(beg_pos >= 0 && end_pos >= 0);
+ if (beg_pos <= position && position <= end_pos) {
+ scope->GetNestedScopeChain(chain, position);
+ return;
+ }
+ }
+}
+
+
#ifdef DEBUG
-static const char* Header(Scope::Type type) {
+static const char* Header(ScopeType type) {
switch (type) {
- case Scope::EVAL_SCOPE: return "eval";
- case Scope::FUNCTION_SCOPE: return "function";
- case Scope::GLOBAL_SCOPE: return "global";
- case Scope::CATCH_SCOPE: return "catch";
- case Scope::BLOCK_SCOPE: return "block";
- case Scope::WITH_SCOPE: return "with";
+ case EVAL_SCOPE: return "eval";
+ case FUNCTION_SCOPE: return "function";
+ case GLOBAL_SCOPE: return "global";
+ case CATCH_SCOPE: return "catch";
+ case BLOCK_SCOPE: return "block";
+ case WITH_SCOPE: return "with";
}
UNREACHABLE();
return NULL;
« no previous file with comments | « src/scopes.h ('k') | src/v8globals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698