| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/scopes.h" | 5 #include "src/scopes.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
| 9 #include "src/messages.h" | 9 #include "src/messages.h" |
| 10 #include "src/parser.h" | 10 #include "src/parser.h" |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 context = context->previous(); | 251 context = context->previous(); |
| 252 } | 252 } |
| 253 | 253 |
| 254 script_scope->AddInnerScope(current_scope); | 254 script_scope->AddInnerScope(current_scope); |
| 255 script_scope->PropagateScopeInfo(false); | 255 script_scope->PropagateScopeInfo(false); |
| 256 return (innermost_scope == NULL) ? script_scope : innermost_scope; | 256 return (innermost_scope == NULL) ? script_scope : innermost_scope; |
| 257 } | 257 } |
| 258 | 258 |
| 259 | 259 |
| 260 bool Scope::Analyze(ParseInfo* info) { | 260 bool Scope::Analyze(ParseInfo* info) { |
| 261 DCHECK(info->function() != NULL); | 261 DCHECK(info->literal() != NULL); |
| 262 DCHECK(info->scope() == NULL); | 262 DCHECK(info->scope() == NULL); |
| 263 Scope* scope = info->function()->scope(); | 263 Scope* scope = info->literal()->scope(); |
| 264 Scope* top = scope; | 264 Scope* top = scope; |
| 265 | 265 |
| 266 // Traverse the scope tree up to the first unresolved scope or the global | 266 // Traverse the scope tree up to the first unresolved scope or the global |
| 267 // scope and start scope resolution and variable allocation from that scope. | 267 // scope and start scope resolution and variable allocation from that scope. |
| 268 while (!top->is_script_scope() && | 268 while (!top->is_script_scope() && |
| 269 !top->outer_scope()->already_resolved()) { | 269 !top->outer_scope()->already_resolved()) { |
| 270 top = top->outer_scope(); | 270 top = top->outer_scope(); |
| 271 } | 271 } |
| 272 | 272 |
| 273 // Allocate the variables. | 273 // Allocate the variables. |
| (...skipping 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1610 function_ != NULL && function_->proxy()->var()->IsContextSlot(); | 1610 function_ != NULL && function_->proxy()->var()->IsContextSlot(); |
| 1611 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - | 1611 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - |
| 1612 (is_function_var_in_context ? 1 : 0); | 1612 (is_function_var_in_context ? 1 : 0); |
| 1613 } | 1613 } |
| 1614 | 1614 |
| 1615 | 1615 |
| 1616 int Scope::ContextGlobalCount() const { return num_global_slots(); } | 1616 int Scope::ContextGlobalCount() const { return num_global_slots(); } |
| 1617 | 1617 |
| 1618 } // namespace internal | 1618 } // namespace internal |
| 1619 } // namespace v8 | 1619 } // namespace v8 |
| OLD | NEW |