| 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, 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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 nesting_level_--; | 466 nesting_level_--; |
| 465 ASSERT(nesting_level_ >= 0); | 467 ASSERT(nesting_level_ >= 0); |
| 466 if (nesting_level_ < inside_with_level_) { | 468 if (nesting_level_ < inside_with_level_) { |
| 467 inside_with_level_ = kNotInsideWith; | 469 inside_with_level_ = kNotInsideWith; |
| 468 } | 470 } |
| 469 ASSERT(inside_with_level_ <= nesting_level_); | 471 ASSERT(inside_with_level_ <= nesting_level_); |
| 470 } | 472 } |
| 471 | 473 |
| 472 virtual Variable* Lookup(Handle<String> name) { return NULL; } | 474 virtual Variable* Lookup(Handle<String> name) { return NULL; } |
| 473 | 475 |
| 474 virtual VariableProxy* NewUnresolved(Handle<String> name, bool inside_with) { | 476 virtual VariableProxy* NewUnresolved(Handle<String> name, |
| 477 bool inside_with, |
| 478 int position = RelocInfo::kNoPosition) { |
| 475 return NULL; | 479 return NULL; |
| 476 } | 480 } |
| 477 | 481 |
| 478 virtual Variable* NewTemporary(Handle<String> name) { return NULL; } | 482 virtual Variable* NewTemporary(Handle<String> name) { return NULL; } |
| 479 | 483 |
| 480 virtual bool HasTrivialOuterContext() const { | 484 virtual bool HasTrivialOuterContext() const { |
| 481 return (nesting_level_ == 0 || inside_with_level_ <= 0); | 485 return (nesting_level_ == 0 || inside_with_level_ <= 0); |
| 482 } | 486 } |
| 483 | 487 |
| 484 private: | 488 private: |
| 485 static const int kNotInsideWith = -1; | 489 static const int kNotInsideWith = -1; |
| 486 // Number of surrounding scopes of the current scope. | 490 // Number of surrounding scopes of the current scope. |
| 487 int nesting_level_; | 491 int nesting_level_; |
| 488 // Nesting level of outermost scope that is contained in a with statement, | 492 // Nesting level of outermost scope that is contained in a with statement, |
| 489 // or kNotInsideWith if there are no with's around the current scope. | 493 // or kNotInsideWith if there are no with's around the current scope. |
| 490 int inside_with_level_; | 494 int inside_with_level_; |
| 491 }; | 495 }; |
| 492 | 496 |
| 493 | 497 |
| 494 } } // namespace v8::internal | 498 } } // namespace v8::internal |
| 495 | 499 |
| 496 #endif // V8_SCOPES_H_ | 500 #endif // V8_SCOPES_H_ |
| OLD | NEW |