OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 // with statements or eval calls. | 142 // with statements or eval calls. |
143 Variable* DeclareGlobal(Handle<String> name); | 143 Variable* DeclareGlobal(Handle<String> name); |
144 | 144 |
145 // Add a parameter to the parameter list. The parameter must have been | 145 // Add a parameter to the parameter list. The parameter must have been |
146 // declared via Declare. The same parameter may occur more than once in | 146 // declared via Declare. The same parameter may occur more than once in |
147 // the parameter list; they must be added in source order, from left to | 147 // the parameter list; they must be added in source order, from left to |
148 // right. | 148 // right. |
149 void AddParameter(Variable* var); | 149 void AddParameter(Variable* var); |
150 | 150 |
151 // Create a new unresolved variable. | 151 // Create a new unresolved variable. |
152 virtual VariableProxy* NewUnresolved(Handle<String> name, bool inside_with); | 152 virtual VariableProxy* NewUnresolved(Handle<String> name, |
| 153 bool inside_with, |
| 154 int position = RelocInfo::kNoPosition); |
153 | 155 |
154 // Remove a unresolved variable. During parsing, an unresolved variable | 156 // Remove a unresolved variable. During parsing, an unresolved variable |
155 // may have been added optimistically, but then only the variable name | 157 // may have been added optimistically, but then only the variable name |
156 // was used (typically for labels). If the variable was not declared, the | 158 // was used (typically for labels). If the variable was not declared, the |
157 // addition introduced a new unresolved variable which may end up being | 159 // addition introduced a new unresolved variable which may end up being |
158 // allocated globally as a "ghost" variable. RemoveUnresolved removes | 160 // allocated globally as a "ghost" variable. RemoveUnresolved removes |
159 // such a variable again if it was added; otherwise this is a no-op. | 161 // such a variable again if it was added; otherwise this is a no-op. |
160 void RemoveUnresolved(VariableProxy* var); | 162 void RemoveUnresolved(VariableProxy* var); |
161 | 163 |
162 // Creates a new temporary variable in this scope. The name is only used | 164 // Creates a new temporary variable in this scope. The name is only used |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 nesting_level_--; | 474 nesting_level_--; |
473 ASSERT(nesting_level_ >= 0); | 475 ASSERT(nesting_level_ >= 0); |
474 if (nesting_level_ < inside_with_level_) { | 476 if (nesting_level_ < inside_with_level_) { |
475 inside_with_level_ = kNotInsideWith; | 477 inside_with_level_ = kNotInsideWith; |
476 } | 478 } |
477 ASSERT(inside_with_level_ <= nesting_level_); | 479 ASSERT(inside_with_level_ <= nesting_level_); |
478 } | 480 } |
479 | 481 |
480 virtual Variable* Lookup(Handle<String> name) { return NULL; } | 482 virtual Variable* Lookup(Handle<String> name) { return NULL; } |
481 | 483 |
482 virtual VariableProxy* NewUnresolved(Handle<String> name, bool inside_with) { | 484 virtual VariableProxy* NewUnresolved(Handle<String> name, |
| 485 bool inside_with, |
| 486 int position = RelocInfo::kNoPosition) { |
483 return NULL; | 487 return NULL; |
484 } | 488 } |
485 | 489 |
486 virtual Variable* NewTemporary(Handle<String> name) { return NULL; } | 490 virtual Variable* NewTemporary(Handle<String> name) { return NULL; } |
487 | 491 |
488 virtual bool HasTrivialOuterContext() const { | 492 virtual bool HasTrivialOuterContext() const { |
489 return (nesting_level_ == 0 || inside_with_level_ <= 0); | 493 return (nesting_level_ == 0 || inside_with_level_ <= 0); |
490 } | 494 } |
491 | 495 |
492 private: | 496 private: |
493 static const int kNotInsideWith = -1; | 497 static const int kNotInsideWith = -1; |
494 // Number of surrounding scopes of the current scope. | 498 // Number of surrounding scopes of the current scope. |
495 int nesting_level_; | 499 int nesting_level_; |
496 // Nesting level of outermost scope that is contained in a with statement, | 500 // Nesting level of outermost scope that is contained in a with statement, |
497 // or kNotInsideWith if there are no with's around the current scope. | 501 // or kNotInsideWith if there are no with's around the current scope. |
498 int inside_with_level_; | 502 int inside_with_level_; |
499 }; | 503 }; |
500 | 504 |
501 | 505 |
502 } } // namespace v8::internal | 506 } } // namespace v8::internal |
503 | 507 |
504 #endif // V8_SCOPES_H_ | 508 #endif // V8_SCOPES_H_ |
OLD | NEW |