| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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, | 152 virtual VariableProxy* NewUnresolved(Handle<String> name, bool inside_with); |
| 153 bool inside_with, | |
| 154 int position = RelocInfo::kNoPosition); | |
| 155 | 153 |
| 156 // Remove a unresolved variable. During parsing, an unresolved variable | 154 // Remove a unresolved variable. During parsing, an unresolved variable |
| 157 // may have been added optimistically, but then only the variable name | 155 // may have been added optimistically, but then only the variable name |
| 158 // was used (typically for labels). If the variable was not declared, the | 156 // was used (typically for labels). If the variable was not declared, the |
| 159 // addition introduced a new unresolved variable which may end up being | 157 // addition introduced a new unresolved variable which may end up being |
| 160 // allocated globally as a "ghost" variable. RemoveUnresolved removes | 158 // allocated globally as a "ghost" variable. RemoveUnresolved removes |
| 161 // such a variable again if it was added; otherwise this is a no-op. | 159 // such a variable again if it was added; otherwise this is a no-op. |
| 162 void RemoveUnresolved(VariableProxy* var); | 160 void RemoveUnresolved(VariableProxy* var); |
| 163 | 161 |
| 164 // Creates a new temporary variable in this scope. The name is only used | 162 // Creates a new temporary variable in this scope. The name is only used |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 nesting_level_--; | 464 nesting_level_--; |
| 467 ASSERT(nesting_level_ >= 0); | 465 ASSERT(nesting_level_ >= 0); |
| 468 if (nesting_level_ < inside_with_level_) { | 466 if (nesting_level_ < inside_with_level_) { |
| 469 inside_with_level_ = kNotInsideWith; | 467 inside_with_level_ = kNotInsideWith; |
| 470 } | 468 } |
| 471 ASSERT(inside_with_level_ <= nesting_level_); | 469 ASSERT(inside_with_level_ <= nesting_level_); |
| 472 } | 470 } |
| 473 | 471 |
| 474 virtual Variable* Lookup(Handle<String> name) { return NULL; } | 472 virtual Variable* Lookup(Handle<String> name) { return NULL; } |
| 475 | 473 |
| 476 virtual VariableProxy* NewUnresolved(Handle<String> name, | 474 virtual VariableProxy* NewUnresolved(Handle<String> name, bool inside_with) { |
| 477 bool inside_with, | |
| 478 int position = RelocInfo::kNoPosition) { | |
| 479 return NULL; | 475 return NULL; |
| 480 } | 476 } |
| 481 | 477 |
| 482 virtual Variable* NewTemporary(Handle<String> name) { return NULL; } | 478 virtual Variable* NewTemporary(Handle<String> name) { return NULL; } |
| 483 | 479 |
| 484 virtual bool HasTrivialOuterContext() const { | 480 virtual bool HasTrivialOuterContext() const { |
| 485 return (nesting_level_ == 0 || inside_with_level_ <= 0); | 481 return (nesting_level_ == 0 || inside_with_level_ <= 0); |
| 486 } | 482 } |
| 487 | 483 |
| 488 private: | 484 private: |
| 489 static const int kNotInsideWith = -1; | 485 static const int kNotInsideWith = -1; |
| 490 // Number of surrounding scopes of the current scope. | 486 // Number of surrounding scopes of the current scope. |
| 491 int nesting_level_; | 487 int nesting_level_; |
| 492 // Nesting level of outermost scope that is contained in a with statement, | 488 // Nesting level of outermost scope that is contained in a with statement, |
| 493 // or kNotInsideWith if there are no with's around the current scope. | 489 // or kNotInsideWith if there are no with's around the current scope. |
| 494 int inside_with_level_; | 490 int inside_with_level_; |
| 495 }; | 491 }; |
| 496 | 492 |
| 497 | 493 |
| 498 } } // namespace v8::internal | 494 } } // namespace v8::internal |
| 499 | 495 |
| 500 #endif // V8_SCOPES_H_ | 496 #endif // V8_SCOPES_H_ |
| OLD | NEW |