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

Side by Side Diff: src/scopes.h

Issue 9221011: Collect AstNode type information (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: removed VariableProxy::ast_properties_ Created 8 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution. 11 // with the distribution.
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // --------------------------------------------------------------------------- 108 // ---------------------------------------------------------------------------
109 // Declarations 109 // Declarations
110 110
111 // Lookup a variable in this scope. Returns the variable or NULL if not found. 111 // Lookup a variable in this scope. Returns the variable or NULL if not found.
112 Variable* LocalLookup(Handle<String> name); 112 Variable* LocalLookup(Handle<String> name);
113 113
114 // This lookup corresponds to a lookup in the "intermediate" scope sitting 114 // This lookup corresponds to a lookup in the "intermediate" scope sitting
115 // between this scope and the outer scope. (ECMA-262, 3rd., requires that 115 // between this scope and the outer scope. (ECMA-262, 3rd., requires that
116 // the name of named function literal is kept in an intermediate scope 116 // the name of named function literal is kept in an intermediate scope
117 // in between this scope and the next outer scope.) 117 // in between this scope and the next outer scope.)
118 Variable* LookupFunctionVar(Handle<String> name); 118 Variable* LookupFunctionVar(Handle<String> name, AstNodeFactory* factory);
119 119
120 // Lookup a variable in this scope or outer scopes. 120 // Lookup a variable in this scope or outer scopes.
121 // Returns the variable or NULL if not found. 121 // Returns the variable or NULL if not found.
122 Variable* Lookup(Handle<String> name); 122 Variable* Lookup(Handle<String> name);
123 123
124 // Declare the function variable for a function literal. This variable 124 // Declare the function variable for a function literal. This variable
125 // is in an intermediate scope between this function scope and the the 125 // is in an intermediate scope between this function scope and the the
126 // outer scope. Only possible for function scopes; at most one variable. 126 // outer scope. Only possible for function scopes; at most one variable.
127 Variable* DeclareFunctionVar(Handle<String> name, VariableMode mode); 127 Variable* DeclareFunctionVar(Handle<String> name,
128 VariableMode mode,
129 AstNodeFactory* factory);
128 130
129 // Declare a parameter in this scope. When there are duplicated 131 // Declare a parameter in this scope. When there are duplicated
130 // parameters the rightmost one 'wins'. However, the implementation 132 // parameters the rightmost one 'wins'. However, the implementation
131 // expects all parameters to be declared and from left to right. 133 // expects all parameters to be declared and from left to right.
132 void DeclareParameter(Handle<String> name, VariableMode mode); 134 void DeclareParameter(Handle<String> name, VariableMode mode);
133 135
134 // Declare a local variable in this scope. If the variable has been 136 // Declare a local variable in this scope. If the variable has been
135 // declared before, the previously declared variable is returned. 137 // declared before, the previously declared variable is returned.
136 Variable* DeclareLocal(Handle<String> name, 138 Variable* DeclareLocal(Handle<String> name,
137 VariableMode mode, 139 VariableMode mode,
138 InitializationFlag init_flag); 140 InitializationFlag init_flag);
139 141
140 // Declare an implicit global variable in this scope which must be a 142 // Declare an implicit global variable in this scope which must be a
141 // global scope. The variable was introduced (possibly from an inner 143 // global scope. The variable was introduced (possibly from an inner
142 // scope) by a reference to an unresolved variable with no intervening 144 // scope) by a reference to an unresolved variable with no intervening
143 // with statements or eval calls. 145 // with statements or eval calls.
144 Variable* DeclareGlobal(Handle<String> name); 146 Variable* DeclareGlobal(Handle<String> name);
145 147
146 // Create a new unresolved variable. 148 // Create a new unresolved variable.
147 VariableProxy* NewUnresolved(Handle<String> name, 149 VariableProxy* NewUnresolved(AstNodeFactory* factory,
150 Handle<String> name,
148 int position = RelocInfo::kNoPosition); 151 int position = RelocInfo::kNoPosition);
149 152
150 // Remove a unresolved variable. During parsing, an unresolved variable 153 // Remove a unresolved variable. During parsing, an unresolved variable
151 // may have been added optimistically, but then only the variable name 154 // may have been added optimistically, but then only the variable name
152 // was used (typically for labels). If the variable was not declared, the 155 // was used (typically for labels). If the variable was not declared, the
153 // addition introduced a new unresolved variable which may end up being 156 // addition introduced a new unresolved variable which may end up being
154 // allocated globally as a "ghost" variable. RemoveUnresolved removes 157 // allocated globally as a "ghost" variable. RemoveUnresolved removes
155 // such a variable again if it was added; otherwise this is a no-op. 158 // such a variable again if it was added; otherwise this is a no-op.
156 void RemoveUnresolved(VariableProxy* var); 159 void RemoveUnresolved(VariableProxy* var);
157 160
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 ZoneList<Variable*>* context_locals); 328 ZoneList<Variable*>* context_locals);
326 329
327 // Resolve and fill in the allocation information for all variables 330 // Resolve and fill in the allocation information for all variables
328 // in this scopes. Must be called *after* all scopes have been 331 // in this scopes. Must be called *after* all scopes have been
329 // processed (parsed) to ensure that unresolved variables can be 332 // processed (parsed) to ensure that unresolved variables can be
330 // resolved properly. 333 // resolved properly.
331 // 334 //
332 // In the case of code compiled and run using 'eval', the context 335 // In the case of code compiled and run using 'eval', the context
333 // parameter is the context in which eval was called. In all other 336 // parameter is the context in which eval was called. In all other
334 // cases the context parameter is an empty handle. 337 // cases the context parameter is an empty handle.
335 void AllocateVariables(Scope* global_scope); 338 void AllocateVariables(Scope* global_scope, AstNodeFactory* factory);
336 339
337 // Current number of var or const locals. 340 // Current number of var or const locals.
338 int num_var_or_const() { return num_var_or_const_; } 341 int num_var_or_const() { return num_var_or_const_; }
339 342
340 // Result of variable allocation. 343 // Result of variable allocation.
341 int num_stack_slots() const { return num_stack_slots_; } 344 int num_stack_slots() const { return num_stack_slots_; }
342 int num_heap_slots() const { return num_heap_slots_; } 345 int num_heap_slots() const { return num_heap_slots_; }
343 346
344 int StackLocalCount() const; 347 int StackLocalCount() const;
345 int ContextLocalCount() const; 348 int ContextLocalCount() const;
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 // * The code is being executed as part of a call to 'eval' and the calling 515 // * The code is being executed as part of a call to 'eval' and the calling
513 // context chain contains either a variable binding for the name or it 516 // context chain contains either a variable binding for the name or it
514 // contains a 'with' context. 517 // contains a 'with' context.
515 DYNAMIC_LOOKUP 518 DYNAMIC_LOOKUP
516 }; 519 };
517 520
518 // Lookup a variable reference given by name recursively starting with this 521 // Lookup a variable reference given by name recursively starting with this
519 // scope. If the code is executed because of a call to 'eval', the context 522 // scope. If the code is executed because of a call to 'eval', the context
520 // parameter should be set to the calling context of 'eval'. 523 // parameter should be set to the calling context of 'eval'.
521 Variable* LookupRecursive(Handle<String> name, 524 Variable* LookupRecursive(Handle<String> name,
522 BindingKind* binding_kind); 525 BindingKind* binding_kind,
526 AstNodeFactory* factory);
523 void ResolveVariable(Scope* global_scope, 527 void ResolveVariable(Scope* global_scope,
524 VariableProxy* proxy); 528 VariableProxy* proxy,
525 void ResolveVariablesRecursively(Scope* global_scope); 529 AstNodeFactory* factory);
530 void ResolveVariablesRecursively(Scope* global_scope,
531 AstNodeFactory* factory);
526 532
527 // Scope analysis. 533 // Scope analysis.
528 bool PropagateScopeInfo(bool outer_scope_calls_non_strict_eval); 534 bool PropagateScopeInfo(bool outer_scope_calls_non_strict_eval);
529 bool HasTrivialContext() const; 535 bool HasTrivialContext() const;
530 536
531 // Predicates. 537 // Predicates.
532 bool MustAllocate(Variable* var); 538 bool MustAllocate(Variable* var);
533 bool MustAllocateInContext(Variable* var); 539 bool MustAllocateInContext(Variable* var);
534 bool HasArgumentsParameter(); 540 bool HasArgumentsParameter();
535 541
(...skipping 20 matching lines...) Expand all
556 } 562 }
557 563
558 void SetDefaults(ScopeType type, 564 void SetDefaults(ScopeType type,
559 Scope* outer_scope, 565 Scope* outer_scope,
560 Handle<ScopeInfo> scope_info); 566 Handle<ScopeInfo> scope_info);
561 }; 567 };
562 568
563 } } // namespace v8::internal 569 } } // namespace v8::internal
564 570
565 #endif // V8_SCOPES_H_ 571 #endif // V8_SCOPES_H_
OLDNEW
« src/compiler.h ('K') | « src/rewriter.cc ('k') | src/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698