| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VM_SCOPES_H_ | 5 #ifndef VM_SCOPES_H_ |
| 6 #define VM_SCOPES_H_ | 6 #define VM_SCOPES_H_ |
| 7 | 7 |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "platform/globals.h" | 9 #include "platform/globals.h" |
| 10 #include "vm/allocation.h" | 10 #include "vm/allocation.h" |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 SourceLabel* LookupLabel(const String& name); | 272 SourceLabel* LookupLabel(const String& name); |
| 273 | 273 |
| 274 // Lookup the "innermost" label that labels a for, while, do, or switch | 274 // Lookup the "innermost" label that labels a for, while, do, or switch |
| 275 // statement. | 275 // statement. |
| 276 SourceLabel* LookupInnermostLabel(Token::Kind jump_kind); | 276 SourceLabel* LookupInnermostLabel(Token::Kind jump_kind); |
| 277 | 277 |
| 278 // Lookup scope of outer switch statement at same function level. | 278 // Lookup scope of outer switch statement at same function level. |
| 279 // Returns NULL if this scope is not embedded in a switch. | 279 // Returns NULL if this scope is not embedded in a switch. |
| 280 LocalScope* LookupSwitchScope(); | 280 LocalScope* LookupSwitchScope(); |
| 281 | 281 |
| 282 // Looks up variable in this scope and mark as captured if applicable. | 282 // Mark this variable as captured by this scope. |
| 283 // Finds the variable even if it is marked invisible. Returns true if | 283 void CaptureVariable(LocalVariable* variable); |
| 284 // the variable was found, false if it was not found. | |
| 285 bool CaptureVariable(const String& name); | |
| 286 | 284 |
| 287 // Look for unresolved forward references to labels in this scope. | 285 // Look for unresolved forward references to labels in this scope. |
| 288 // If there are any, propagate the forward reference to the next | 286 // If there are any, propagate the forward reference to the next |
| 289 // outer scope of a switch statement. If there is no outer switch | 287 // outer scope of a switch statement. If there is no outer switch |
| 290 // statement, return the first unresolved label found. | 288 // statement, return the first unresolved label found. |
| 291 SourceLabel* CheckUnresolvedLabels(); | 289 SourceLabel* CheckUnresolvedLabels(); |
| 292 | 290 |
| 293 // Accessing the variables in the scope. | 291 // Accessing the variables in the scope. |
| 294 intptr_t num_variables() const { return variables_.length(); } | 292 intptr_t num_variables() const { return variables_.length(); } |
| 295 LocalVariable* VariableAt(intptr_t index) const { | 293 LocalVariable* VariableAt(intptr_t index) const { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 322 bool* found_captured_variables); | 320 bool* found_captured_variables); |
| 323 | 321 |
| 324 // Creates variable info for the scope and all its nested scopes. | 322 // Creates variable info for the scope and all its nested scopes. |
| 325 // Must be called after AllocateVariables() has been called. | 323 // Must be called after AllocateVariables() has been called. |
| 326 RawLocalVarDescriptors* GetVarDescriptors(const Function& func); | 324 RawLocalVarDescriptors* GetVarDescriptors(const Function& func); |
| 327 | 325 |
| 328 // Create a ContextScope object describing all captured variables referenced | 326 // Create a ContextScope object describing all captured variables referenced |
| 329 // from this scope and belonging to outer scopes. | 327 // from this scope and belonging to outer scopes. |
| 330 RawContextScope* PreserveOuterScope(int current_context_level) const; | 328 RawContextScope* PreserveOuterScope(int current_context_level) const; |
| 331 | 329 |
| 332 | |
| 333 // Recursively traverses all siblings and children and marks all variables as | 330 // Recursively traverses all siblings and children and marks all variables as |
| 334 // captured. | 331 // captured. |
| 335 void RecursivelyCaptureAllVariables(); | 332 void RecursivelyCaptureAllVariables(); |
| 336 | 333 |
| 337 // Creates a LocalScope representing the outer scope of a local function to be | 334 // Creates a LocalScope representing the outer scope of a local function to be |
| 338 // compiled. This outer scope contains the variables captured by the function | 335 // compiled. This outer scope contains the variables captured by the function |
| 339 // as specified by the given ContextScope, which was created during the | 336 // as specified by the given ContextScope, which was created during the |
| 340 // compilation of the enclosing function. | 337 // compilation of the enclosing function. |
| 341 static LocalScope* RestoreOuterScope(const ContextScope& context_scope); | 338 static LocalScope* RestoreOuterScope(const ContextScope& context_scope); |
| 342 | 339 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 // List of names referenced in this scope and its children that | 375 // List of names referenced in this scope and its children that |
| 379 // are not resolved to local variables. | 376 // are not resolved to local variables. |
| 380 GrowableArray<NameReference*> referenced_; | 377 GrowableArray<NameReference*> referenced_; |
| 381 | 378 |
| 382 DISALLOW_COPY_AND_ASSIGN(LocalScope); | 379 DISALLOW_COPY_AND_ASSIGN(LocalScope); |
| 383 }; | 380 }; |
| 384 | 381 |
| 385 } // namespace dart | 382 } // namespace dart |
| 386 | 383 |
| 387 #endif // VM_SCOPES_H_ | 384 #endif // VM_SCOPES_H_ |
| OLD | NEW |