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
3 // found in the LICENSE file.
9 #include "src/pending-compilation-error-handler.h"
17 // A hash map to support fast variable declaration and lookup.
18 class VariableMap: public ZoneHashMap {
20 explicit VariableMap(Zone* zone);
22 virtual ~VariableMap();
24 Variable* Declare(Scope* scope, const AstRawString* name, VariableMode mode,
25 Variable::Kind kind, InitializationFlag initialization_flag,
26 MaybeAssignedFlag maybe_assigned_flag = kNotAssigned);
28 Variable* Lookup(const AstRawString* name);
30 Zone* zone() const { return zone_; }
37 // The dynamic scope part holds hash maps for the variables that will
38 // be looked up dynamically from within eval and with scopes. The objects
39 // are allocated on-demand from Scope::NonLocal to avoid wasting memory
40 // and setup time for scopes that don't need them.
41 class DynamicScopePart : public ZoneObject {
43 explicit DynamicScopePart(Zone* zone) {
44 for (int i = 0; i < 3; i++)
45 maps_[i] = new(zone->New(sizeof(VariableMap))) VariableMap(zone);
48 VariableMap* GetMap(VariableMode mode) {
49 int index = mode - DYNAMIC;
50 DCHECK(index >= 0 && index < 3);
55 VariableMap *maps_[3];
59 // Global invariants after AST construction: Each reference (i.e. identifier)
60 // to a JavaScript variable (including global properties) is represented by a
61 // VariableProxy node. Immediately after AST construction and before variable
62 // allocation, most VariableProxy nodes are "unresolved", i.e. not bound to a
63 // corresponding variable (though some are bound during parse time). Variable
64 // allocation binds each unresolved VariableProxy to one Variable and assigns
65 // a location. Note that many VariableProxy nodes may refer to the same Java-
68 class Scope: public ZoneObject {
70 // ---------------------------------------------------------------------------
73 Scope(Zone* zone, Scope* outer_scope, ScopeType scope_type,
74 AstValueFactory* value_factory,
75 FunctionKind function_kind = kNormalFunction);
77 // Compute top scope and allocate variables. For lazy compilation the top
78 // scope only contains the single lazily compiled function, so this
79 // doesn't re-allocate variables repeatedly.
80 static bool Analyze(ParseInfo* info);
82 static Scope* DeserializeScopeChain(Isolate* isolate, Zone* zone,
83 Context* context, Scope* script_scope);
85 // The scope name is only used for printing/debugging.
86 void SetScopeName(const AstRawString* scope_name) {
87 scope_name_ = scope_name;
92 // Checks if the block scope is redundant, i.e. it does not contain any
93 // block scoped declarations. In that case it is removed from the scope
94 // tree and its children are reparented.
95 Scope* FinalizeBlockScope();
97 Zone* zone() const { return zone_; }
99 // ---------------------------------------------------------------------------
102 // Lookup a variable in this scope. Returns the variable or NULL if not found.
103 Variable* LookupLocal(const AstRawString* name);
105 // This lookup corresponds to a lookup in the "intermediate" scope sitting
106 // between this scope and the outer scope. (ECMA-262, 3rd., requires that
107 // the name of named function literal is kept in an intermediate scope
108 // in between this scope and the next outer scope.)
109 Variable* LookupFunctionVar(const AstRawString* name,
110 AstNodeFactory* factory);
112 // Lookup a variable in this scope or outer scopes.
113 // Returns the variable or NULL if not found.
114 Variable* Lookup(const AstRawString* name);
116 // Declare the function variable for a function literal. This variable
117 // is in an intermediate scope between this function scope and the the
118 // outer scope. Only possible for function scopes; at most one variable.
119 void DeclareFunctionVar(VariableDeclaration* declaration) {
120 DCHECK(is_function_scope());
121 function_ = declaration;
124 // Declare a parameter in this scope. When there are duplicated
125 // parameters the rightmost one 'wins'. However, the implementation
126 // expects all parameters to be declared and from left to right.
127 Variable* DeclareParameter(const AstRawString* name, VariableMode mode,
128 bool is_rest = false);
130 // Declare a local variable in this scope. If the variable has been
131 // declared before, the previously declared variable is returned.
132 Variable* DeclareLocal(const AstRawString* name, VariableMode mode,
133 InitializationFlag init_flag, Variable::Kind kind,
134 MaybeAssignedFlag maybe_assigned_flag = kNotAssigned);
136 // Declare an implicit global variable in this scope which must be a
137 // script scope. The variable was introduced (possibly from an inner
138 // scope) by a reference to an unresolved variable with no intervening
139 // with statements or eval calls.
140 Variable* DeclareDynamicGlobal(const AstRawString* name);
142 // Create a new unresolved variable.
143 VariableProxy* NewUnresolved(AstNodeFactory* factory,
144 const AstRawString* name,
145 int start_position = RelocInfo::kNoPosition,
146 int end_position = RelocInfo::kNoPosition) {
147 // Note that we must not share the unresolved variables with
148 // the same name because they may be removed selectively via
149 // RemoveUnresolved().
150 DCHECK(!already_resolved());
151 VariableProxy* proxy = factory->NewVariableProxy(
152 name, Variable::NORMAL, start_position, end_position);
153 unresolved_.Add(proxy, zone_);
157 // Remove a unresolved variable. During parsing, an unresolved variable
158 // may have been added optimistically, but then only the variable name
159 // was used (typically for labels). If the variable was not declared, the
160 // addition introduced a new unresolved variable which may end up being
161 // allocated globally as a "ghost" variable. RemoveUnresolved removes
162 // such a variable again if it was added; otherwise this is a no-op.
163 void RemoveUnresolved(VariableProxy* var);
165 // Creates a new internal variable in this scope. The name is only used
166 // for printing and cannot be used to find the variable. In particular,
167 // the only way to get hold of the temporary is by keeping the Variable*
169 Variable* NewInternal(const AstRawString* name);
171 // Creates a new temporary variable in this scope. The name is only used
172 // for printing and cannot be used to find the variable. In particular,
173 // the only way to get hold of the temporary is by keeping the Variable*
174 // around. The name should not clash with a legitimate variable names.
175 Variable* NewTemporary(const AstRawString* name);
177 // Adds the specific declaration node to the list of declarations in
178 // this scope. The declarations are processed as part of entering
179 // the scope; see codegen.cc:ProcessDeclarations.
180 void AddDeclaration(Declaration* declaration);
182 // ---------------------------------------------------------------------------
183 // Illegal redeclaration support.
185 // Set an expression node that will be executed when the scope is
186 // entered. We only keep track of one illegal redeclaration node per
187 // scope - the first one - so if you try to set it multiple times
188 // the additional requests will be silently ignored.
189 void SetIllegalRedeclaration(Expression* expression);
191 // Visit the illegal redeclaration expression. Do not call if the
192 // scope doesn't have an illegal redeclaration node.
193 void VisitIllegalRedeclaration(AstVisitor* visitor);
195 // Check if the scope has (at least) one illegal redeclaration.
196 bool HasIllegalRedeclaration() const { return illegal_redecl_ != NULL; }
198 // For harmony block scoping mode: Check if the scope has conflicting var
199 // declarations, i.e. a var declaration that has been hoisted from a nested
200 // scope over a let binding of the same name.
201 Declaration* CheckConflictingVarDeclarations();
203 // ---------------------------------------------------------------------------
204 // Scope-specific info.
206 // Inform the scope that the corresponding code contains a with statement.
207 void RecordWithStatement() { scope_contains_with_ = true; }
209 // Inform the scope that the corresponding code contains an eval call.
210 void RecordEvalCall() { if (!is_script_scope()) scope_calls_eval_ = true; }
212 // Inform the scope that the corresponding code uses "arguments".
213 void RecordArgumentsUsage() { scope_uses_arguments_ = true; }
215 // Inform the scope that the corresponding code uses "super".
216 void RecordSuperPropertyUsage() { scope_uses_super_property_ = true; }
218 // Inform the scope that the corresponding code uses "this".
219 void RecordThisUsage() { scope_uses_this_ = true; }
221 // Set the language mode flag (unless disabled by a global flag).
222 void SetLanguageMode(LanguageMode language_mode) {
223 language_mode_ = language_mode;
226 // Set the ASM module flag.
227 void SetAsmModule() { asm_module_ = true; }
229 // Position in the source where this scope begins and ends.
231 // * For the scope of a with statement
233 // start position: start position of first token of 'stmt'
234 // end position: end position of last token of 'stmt'
235 // * For the scope of a block
237 // start position: start position of '{'
238 // end position: end position of '}'
239 // * For the scope of a function literal or decalaration
240 // function fun(a,b) { stmts }
241 // start position: start position of '('
242 // end position: end position of '}'
243 // * For the scope of a catch block
244 // try { stms } catch(e) { stmts }
245 // start position: start position of '('
246 // end position: end position of ')'
247 // * For the scope of a for-statement
248 // for (let x ...) stmt
249 // start position: start position of '('
250 // end position: end position of last token of 'stmt'
251 int start_position() const { return start_position_; }
252 void set_start_position(int statement_pos) {
253 start_position_ = statement_pos;
255 int end_position() const { return end_position_; }
256 void set_end_position(int statement_pos) {
257 end_position_ = statement_pos;
260 // In some cases we want to force context allocation for a whole scope.
261 void ForceContextAllocation() {
262 DCHECK(!already_resolved());
263 force_context_allocation_ = true;
265 bool has_forced_context_allocation() const {
266 return force_context_allocation_;
269 // ---------------------------------------------------------------------------
272 // Specific scope types.
273 bool is_eval_scope() const { return scope_type_ == EVAL_SCOPE; }
274 bool is_function_scope() const {
275 return scope_type_ == FUNCTION_SCOPE || scope_type_ == ARROW_SCOPE;
277 bool is_module_scope() const { return scope_type_ == MODULE_SCOPE; }
278 bool is_script_scope() const { return scope_type_ == SCRIPT_SCOPE; }
279 bool is_catch_scope() const { return scope_type_ == CATCH_SCOPE; }
280 bool is_block_scope() const { return scope_type_ == BLOCK_SCOPE; }
281 bool is_with_scope() const { return scope_type_ == WITH_SCOPE; }
282 bool is_arrow_scope() const { return scope_type_ == ARROW_SCOPE; }
283 void tag_as_class_scope() {
284 DCHECK(is_block_scope());
285 block_scope_is_class_scope_ = true;
287 bool is_class_scope() const {
288 return is_block_scope() && block_scope_is_class_scope_;
290 bool is_declaration_scope() const {
291 return is_eval_scope() || is_function_scope() ||
292 is_module_scope() || is_script_scope();
294 bool is_strict_eval_scope() const {
295 return is_eval_scope() && is_strict(language_mode_);
298 // Information about which scopes calls eval.
299 bool calls_eval() const { return scope_calls_eval_; }
300 bool calls_sloppy_eval() {
301 return scope_calls_eval_ && is_sloppy(language_mode_);
303 bool outer_scope_calls_sloppy_eval() const {
304 return outer_scope_calls_sloppy_eval_;
306 bool asm_module() const { return asm_module_; }
307 bool asm_function() const { return asm_function_; }
309 // Is this scope inside a with statement.
310 bool inside_with() const { return scope_inside_with_; }
311 // Does this scope contain a with statement.
312 bool contains_with() const { return scope_contains_with_; }
314 // Does this scope access "arguments".
315 bool uses_arguments() const { return scope_uses_arguments_; }
316 // Does any inner scope access "arguments".
317 bool inner_uses_arguments() const { return inner_scope_uses_arguments_; }
318 // Does this scope access "super" property (super.foo).
319 bool uses_super_property() const { return scope_uses_super_property_; }
320 // Does any inner scope access "super" property.
321 bool inner_uses_super_property() const {
322 return inner_scope_uses_super_property_;
324 // Does this scope access "this".
325 bool uses_this() const { return scope_uses_this_; }
326 // Does any inner scope access "this".
327 bool inner_uses_this() const { return inner_scope_uses_this_; }
329 const Scope* NearestOuterEvalScope() const {
330 if (is_eval_scope()) return this;
331 if (outer_scope() == nullptr) return nullptr;
332 return outer_scope()->NearestOuterEvalScope();
335 // ---------------------------------------------------------------------------
338 // The type of this scope.
339 ScopeType scope_type() const { return scope_type_; }
341 FunctionKind function_kind() const { return function_kind_; }
343 // The language mode of this scope.
344 LanguageMode language_mode() const { return language_mode_; }
346 // The variable corresponding to the 'this' value.
347 Variable* receiver() { return receiver_; }
349 // The variable corresponding to the 'new.target' value.
350 Variable* new_target_var() { return new_target_; }
352 // The variable holding the function literal for named function
353 // literals, or NULL. Only valid for function scopes.
354 VariableDeclaration* function() const {
355 DCHECK(is_function_scope());
359 // Parameters. The left-most parameter has index 0.
360 // Only valid for function scopes.
361 Variable* parameter(int index) const {
362 DCHECK(is_function_scope());
363 return params_[index];
366 // Returns the default function arity --- does not include rest parameters.
367 int default_function_length() const {
368 int count = params_.length();
369 if (rest_index_ >= 0) {
371 DCHECK(is_function_scope());
377 int num_parameters() const { return params_.length(); }
379 // A function can have at most one rest parameter. Returns Variable* or NULL.
380 Variable* rest_parameter(int* index) const {
381 *index = rest_index_;
382 if (rest_index_ < 0) return NULL;
383 return rest_parameter_;
386 bool has_rest_parameter() const {
387 return rest_index_ >= 0;
390 bool is_simple_parameter_list() const {
391 DCHECK(is_function_scope());
392 if (rest_index_ >= 0) return false;
396 // The local variable 'arguments' if we need to allocate it; NULL otherwise.
397 Variable* arguments() const { return arguments_; }
399 // Declarations list.
400 ZoneList<Declaration*>* declarations() { return &decls_; }
403 ZoneList<Scope*>* inner_scopes() { return &inner_scopes_; }
405 // The scope immediately surrounding this scope, or NULL.
406 Scope* outer_scope() const { return outer_scope_; }
408 // The ModuleDescriptor for this scope; only for module scopes.
409 ModuleDescriptor* module() const { return module_descriptor_; }
411 // ---------------------------------------------------------------------------
412 // Variable allocation.
414 // Collect stack and context allocated local variables in this scope. Note
415 // that the function variable - if present - is not collected and should be
416 // handled separately.
417 void CollectStackAndContextLocals(
418 ZoneList<Variable*>* stack_locals, ZoneList<Variable*>* context_locals,
419 ZoneList<Variable*>* strong_mode_free_variables = nullptr);
421 // Current number of var or const locals.
422 int num_var_or_const() { return num_var_or_const_; }
424 // Result of variable allocation.
425 int num_stack_slots() const { return num_stack_slots_; }
426 int num_heap_slots() const { return num_heap_slots_; }
428 int StackLocalCount() const;
429 int ContextLocalCount() const;
431 // For script scopes, the number of module literals (including nested ones).
432 int num_modules() const { return num_modules_; }
434 // For module scopes, the host scope's internal variable binding this module.
435 Variable* module_var() const { return module_var_; }
437 // Make sure this scope and all outer scopes are eagerly compiled.
438 void ForceEagerCompilation() { force_eager_compilation_ = true; }
440 // Determine if we can use lazy compilation for this scope.
441 bool AllowsLazyCompilation() const;
443 // Determine if we can use lazy compilation for this scope without a context.
444 bool AllowsLazyCompilationWithoutContext() const;
446 // True if the outer context of this scope is always the native context.
447 bool HasTrivialOuterContext() const;
449 // True if the outer context allows lazy compilation of this scope.
450 bool HasLazyCompilableOuterContext() const;
452 // The number of contexts between this and scope; zero if this == scope.
453 int ContextChainLength(Scope* scope);
455 // Find the script scope.
456 // Used in modules implemenetation to find hosting scope.
457 // TODO(rossberg): is this needed?
458 Scope* ScriptScope();
460 // Find the first function, global, or eval scope. This is the scope
461 // where var declarations will be hoisted to in the implementation.
462 Scope* DeclarationScope();
464 Handle<ScopeInfo> GetScopeInfo(Isolate* isolate);
466 // Get the chain of nested scopes within this scope for the source statement
467 // position. The scopes will be added to the list from the outermost scope to
468 // the innermost scope. Only nested block, catch or with scopes are tracked
469 // and will be returned, but no inner function scopes.
470 void GetNestedScopeChain(Isolate* isolate, List<Handle<ScopeInfo> >* chain,
471 int statement_position);
473 // ---------------------------------------------------------------------------
474 // Strict mode support.
475 bool IsDeclared(const AstRawString* name) {
476 // During formal parameter list parsing the scope only contains
477 // two variables inserted at initialization: "this" and "arguments".
478 // "this" is an invalid parameter name and "arguments" is invalid parameter
479 // name in strict mode. Therefore looking up with the map which includes
480 // "this" and "arguments" in addition to all formal parameters is safe.
481 return variables_.Lookup(name) != NULL;
484 bool IsDeclaredParameter(const AstRawString* name) {
485 // If IsSimpleParameterList is false, duplicate parameters are not allowed,
486 // however `arguments` may be allowed if function is not strict code. Thus,
487 // the assumptions explained above do not hold.
488 return params_.Contains(variables_.Lookup(name));
492 void ReportMessage(int start_position, int end_position, const char* message,
493 const AstRawString* arg);
495 // ---------------------------------------------------------------------------
499 void Print(int n = 0); // n = indentation; n < 0 => don't print recursively
502 // ---------------------------------------------------------------------------
505 friend class ParserFactory;
508 Scope* outer_scope_; // the immediately enclosing outer scope, or NULL
509 ZoneList<Scope*> inner_scopes_; // the immediately enclosed inner scopes
512 ScopeType scope_type_;
513 // Some block scopes are tagged as class scopes.
514 bool block_scope_is_class_scope_;
515 // If the scope is a function scope, this is the function kind.
516 FunctionKind function_kind_;
518 // Debugging support.
519 const AstRawString* scope_name_;
521 // The variables declared in this scope:
523 // All user-declared variables (incl. parameters). For script scopes
524 // variables may be implicitly 'declared' by being used (possibly in
525 // an inner scope) with no intervening with statements or eval calls.
526 VariableMap variables_;
527 // Compiler-allocated (user-invisible) internals.
528 ZoneList<Variable*> internals_;
529 // Compiler-allocated (user-invisible) temporaries.
530 ZoneList<Variable*> temps_;
531 // Parameter list in source order.
532 ZoneList<Variable*> params_;
533 // Variables that must be looked up dynamically.
534 DynamicScopePart* dynamics_;
535 // Unresolved variables referred to from this scope.
536 ZoneList<VariableProxy*> unresolved_;
538 ZoneList<Declaration*> decls_;
539 // Convenience variable.
541 // Function variable, if any; function scopes only.
542 VariableDeclaration* function_;
543 // new.target variable, function scopes only.
544 Variable* new_target_;
545 // Convenience variable; function scopes only.
546 Variable* arguments_;
547 // Module descriptor; module scopes only.
548 ModuleDescriptor* module_descriptor_;
550 // Illegal redeclaration.
551 Expression* illegal_redecl_;
553 // Scope-specific information computed during parsing.
555 // This scope is inside a 'with' of some outer scope.
556 bool scope_inside_with_;
557 // This scope contains a 'with' statement.
558 bool scope_contains_with_;
559 // This scope or a nested catch scope or with scope contain an 'eval' call. At
560 // the 'eval' call site this scope is the declaration scope.
561 bool scope_calls_eval_;
562 // This scope uses "arguments".
563 bool scope_uses_arguments_;
564 // This scope uses "super" property ('super.foo').
565 bool scope_uses_super_property_;
566 // This scope uses "this".
567 bool scope_uses_this_;
568 // This scope contains an "use asm" annotation.
570 // This scope's outer context is an asm module.
572 // The language mode of this scope.
573 LanguageMode language_mode_;
578 // Computed via PropagateScopeInfo.
579 bool outer_scope_calls_sloppy_eval_;
580 bool inner_scope_calls_eval_;
581 bool inner_scope_uses_arguments_;
582 bool inner_scope_uses_super_property_;
583 bool inner_scope_uses_this_;
584 bool force_eager_compilation_;
585 bool force_context_allocation_;
587 // True if it doesn't need scope resolution (e.g., if the scope was
588 // constructed based on a serialized scope info or a catch context).
589 bool already_resolved_;
591 // Computed as variables are declared.
592 int num_var_or_const_;
594 // Computed via AllocateVariables; function, block and catch scopes only.
595 int num_stack_slots_;
598 // The number of modules (including nested ones).
601 // For module scopes, the host scope's internal variable binding this module.
602 Variable* module_var_;
605 Variable* rest_parameter_;
608 // Serialized scope info support.
609 Handle<ScopeInfo> scope_info_;
610 bool already_resolved() { return already_resolved_; }
612 // Create a non-local variable with a given name.
613 // These variables are looked up dynamically at runtime.
614 Variable* NonLocal(const AstRawString* name, VariableMode mode);
616 // Variable resolution.
617 // Possible results of a recursive variable lookup telling if and how a
618 // variable is bound. These are returned in the output parameter *binding_kind
619 // of the LookupRecursive function.
621 // The variable reference could be statically resolved to a variable binding
622 // which is returned. There is no 'with' statement between the reference and
623 // the binding and no scope between the reference scope (inclusive) and
624 // binding scope (exclusive) makes a sloppy 'eval' call.
627 // The variable reference could be statically resolved to a variable binding
628 // which is returned. There is no 'with' statement between the reference and
629 // the binding, but some scope between the reference scope (inclusive) and
630 // binding scope (exclusive) makes a sloppy 'eval' call, that might
631 // possibly introduce variable bindings shadowing the found one. Thus the
632 // found variable binding is just a guess.
635 // The variable reference could not be statically resolved to any binding
636 // and thus should be considered referencing a global variable. NULL is
637 // returned. The variable reference is not inside any 'with' statement and
638 // no scope between the reference scope (inclusive) and script scope
639 // (exclusive) makes a sloppy 'eval' call.
642 // The variable reference could not be statically resolved to any binding
643 // NULL is returned. The variable reference is not inside any 'with'
644 // statement, but some scope between the reference scope (inclusive) and
645 // script scope (exclusive) makes a sloppy 'eval' call, that might
646 // possibly introduce a variable binding. Thus the reference should be
647 // considered referencing a global variable unless it is shadowed by an
648 // 'eval' introduced binding.
649 UNBOUND_EVAL_SHADOWED,
651 // The variable could not be statically resolved and needs to be looked up
652 // dynamically. NULL is returned. There are two possible reasons:
653 // * A 'with' statement has been encountered and there is no variable
654 // binding for the name between the variable reference and the 'with'.
655 // The variable potentially references a property of the 'with' object.
656 // * The code is being executed as part of a call to 'eval' and the calling
657 // context chain contains either a variable binding for the name or it
658 // contains a 'with' context.
662 // Lookup a variable reference given by name recursively starting with this
663 // scope. If the code is executed because of a call to 'eval', the context
664 // parameter should be set to the calling context of 'eval'.
665 Variable* LookupRecursive(VariableProxy* proxy, BindingKind* binding_kind,
666 AstNodeFactory* factory);
668 bool ResolveVariable(ParseInfo* info, VariableProxy* proxy,
669 AstNodeFactory* factory);
671 bool ResolveVariablesRecursively(ParseInfo* info, AstNodeFactory* factory);
673 bool CheckStrongModeDeclaration(VariableProxy* proxy, Variable* var);
675 // If this scope is a method scope of a class, return the corresponding
676 // class variable, otherwise nullptr.
677 Variable* ClassVariableForMethod() const;
680 void PropagateScopeInfo(bool outer_scope_calls_sloppy_eval);
681 bool HasTrivialContext() const;
684 bool MustAllocate(Variable* var);
685 bool MustAllocateInContext(Variable* var);
686 bool HasArgumentsParameter(Isolate* isolate);
688 // Variable allocation.
689 void AllocateStackSlot(Variable* var);
690 void AllocateHeapSlot(Variable* var);
691 void AllocateParameterLocals(Isolate* isolate);
692 void AllocateNonParameterLocal(Isolate* isolate, Variable* var);
693 void AllocateNonParameterLocals(Isolate* isolate);
694 void AllocateVariablesRecursively(Isolate* isolate);
695 void AllocateModules();
697 // Resolve and fill in the allocation information for all variables
698 // in this scopes. Must be called *after* all scopes have been
699 // processed (parsed) to ensure that unresolved variables can be
700 // resolved properly.
702 // In the case of code compiled and run using 'eval', the context
703 // parameter is the context in which eval was called. In all other
704 // cases the context parameter is an empty handle.
706 bool AllocateVariables(ParseInfo* info, AstNodeFactory* factory);
709 // Construct a scope based on the scope info.
710 Scope(Zone* zone, Scope* inner_scope, ScopeType type,
711 Handle<ScopeInfo> scope_info, AstValueFactory* value_factory);
713 // Construct a catch scope with a binding for the name.
714 Scope(Zone* zone, Scope* inner_scope, const AstRawString* catch_variable_name,
715 AstValueFactory* value_factory);
717 void AddInnerScope(Scope* inner_scope) {
718 if (inner_scope != NULL) {
719 inner_scopes_.Add(inner_scope, zone_);
720 inner_scope->outer_scope_ = this;
724 void SetDefaults(ScopeType type, Scope* outer_scope,
725 Handle<ScopeInfo> scope_info,
726 FunctionKind function_kind = kNormalFunction);
728 AstValueFactory* ast_value_factory_;
731 PendingCompilationErrorHandler pending_error_handler_;
734 } } // namespace v8::internal
736 #endif // V8_SCOPES_H_