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

Side by Side Diff: src/scopes.h

Issue 9704054: Refactoring of code generation for declarations, in preparation for modules. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed Florian's comments. Created 8 years, 8 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
« no previous file with comments | « src/scopeinfo.cc ('k') | src/scopes.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 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
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 Variable* LookupFunctionVar(Handle<String> name, 119 Variable* LookupFunctionVar(Handle<String> name,
120 AstNodeFactory<AstNullVisitor>* factory); 120 AstNodeFactory<AstNullVisitor>* factory);
121 121
122 // Lookup a variable in this scope or outer scopes. 122 // Lookup a variable in this scope or outer scopes.
123 // Returns the variable or NULL if not found. 123 // Returns the variable or NULL if not found.
124 Variable* Lookup(Handle<String> name); 124 Variable* Lookup(Handle<String> name);
125 125
126 // Declare the function variable for a function literal. This variable 126 // Declare the function variable for a function literal. This variable
127 // is in an intermediate scope between this function scope and the the 127 // is in an intermediate scope between this function scope and the the
128 // outer scope. Only possible for function scopes; at most one variable. 128 // outer scope. Only possible for function scopes; at most one variable.
129 template<class Visitor> 129 void DeclareFunctionVar(VariableDeclaration* declaration) {
130 Variable* DeclareFunctionVar(Handle<String> name, 130 ASSERT(is_function_scope());
131 VariableMode mode, 131 function_ = declaration;
132 AstNodeFactory<Visitor>* factory) {
133 ASSERT(is_function_scope() && function_ == NULL);
134 Variable* function_var = new Variable(
135 this, name, mode, true, Variable::NORMAL, kCreatedInitialized);
136 function_ = factory->NewVariableProxy(function_var);
137 return function_var;
138 } 132 }
139 133
140 // Declare a parameter in this scope. When there are duplicated 134 // Declare a parameter in this scope. When there are duplicated
141 // parameters the rightmost one 'wins'. However, the implementation 135 // parameters the rightmost one 'wins'. However, the implementation
142 // expects all parameters to be declared and from left to right. 136 // expects all parameters to be declared and from left to right.
143 void DeclareParameter(Handle<String> name, VariableMode mode); 137 void DeclareParameter(Handle<String> name, VariableMode mode);
144 138
145 // Declare a local variable in this scope. If the variable has been 139 // Declare a local variable in this scope. If the variable has been
146 // declared before, the previously declared variable is returned. 140 // declared before, the previously declared variable is returned.
147 Variable* DeclareLocal(Handle<String> name, 141 Variable* DeclareLocal(Handle<String> name,
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 // The type of this scope. 299 // The type of this scope.
306 ScopeType type() const { return type_; } 300 ScopeType type() const { return type_; }
307 301
308 // The language mode of this scope. 302 // The language mode of this scope.
309 LanguageMode language_mode() const { return language_mode_; } 303 LanguageMode language_mode() const { return language_mode_; }
310 304
311 // The variable corresponding the 'this' value. 305 // The variable corresponding the 'this' value.
312 Variable* receiver() { return receiver_; } 306 Variable* receiver() { return receiver_; }
313 307
314 // The variable holding the function literal for named function 308 // The variable holding the function literal for named function
315 // literals, or NULL. 309 // literals, or NULL. Only valid for function scopes.
316 // Only valid for function scopes. 310 VariableDeclaration* function() const {
317 VariableProxy* function() const {
318 ASSERT(is_function_scope()); 311 ASSERT(is_function_scope());
319 return function_; 312 return function_;
320 } 313 }
321 314
322 // Parameters. The left-most parameter has index 0. 315 // Parameters. The left-most parameter has index 0.
323 // Only valid for function scopes. 316 // Only valid for function scopes.
324 Variable* parameter(int index) const { 317 Variable* parameter(int index) const {
325 ASSERT(is_function_scope()); 318 ASSERT(is_function_scope());
326 return params_[index]; 319 return params_[index];
327 } 320 }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 ZoneList<Variable*> params_; 432 ZoneList<Variable*> params_;
440 // Variables that must be looked up dynamically. 433 // Variables that must be looked up dynamically.
441 DynamicScopePart* dynamics_; 434 DynamicScopePart* dynamics_;
442 // Unresolved variables referred to from this scope. 435 // Unresolved variables referred to from this scope.
443 ZoneList<VariableProxy*> unresolved_; 436 ZoneList<VariableProxy*> unresolved_;
444 // Declarations. 437 // Declarations.
445 ZoneList<Declaration*> decls_; 438 ZoneList<Declaration*> decls_;
446 // Convenience variable. 439 // Convenience variable.
447 Variable* receiver_; 440 Variable* receiver_;
448 // Function variable, if any; function scopes only. 441 // Function variable, if any; function scopes only.
449 VariableProxy* function_; 442 VariableDeclaration* function_;
450 // Convenience variable; function scopes only. 443 // Convenience variable; function scopes only.
451 Variable* arguments_; 444 Variable* arguments_;
452 // Interface; module scopes only. 445 // Interface; module scopes only.
453 Interface* interface_; 446 Interface* interface_;
454 447
455 // Illegal redeclaration. 448 // Illegal redeclaration.
456 Expression* illegal_redecl_; 449 Expression* illegal_redecl_;
457 450
458 // Scope-specific information computed during parsing. 451 // Scope-specific information computed during parsing.
459 // 452 //
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 } 591 }
599 592
600 void SetDefaults(ScopeType type, 593 void SetDefaults(ScopeType type,
601 Scope* outer_scope, 594 Scope* outer_scope,
602 Handle<ScopeInfo> scope_info); 595 Handle<ScopeInfo> scope_info);
603 }; 596 };
604 597
605 } } // namespace v8::internal 598 } } // namespace v8::internal
606 599
607 #endif // V8_SCOPES_H_ 600 #endif // V8_SCOPES_H_
OLDNEW
« no previous file with comments | « src/scopeinfo.cc ('k') | src/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698