| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_SCOPES_H_ | 5 #ifndef V8_SCOPES_H_ |
| 6 #define V8_SCOPES_H_ | 6 #define V8_SCOPES_H_ |
| 7 | 7 |
| 8 #include "src/ast.h" | 8 #include "src/ast.h" |
| 9 #include "src/zone.h" | 9 #include "src/zone.h" |
| 10 | 10 |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 | 207 |
| 208 // Inform the scope that the corresponding code contains a with statement. | 208 // Inform the scope that the corresponding code contains a with statement. |
| 209 void RecordWithStatement() { scope_contains_with_ = true; } | 209 void RecordWithStatement() { scope_contains_with_ = true; } |
| 210 | 210 |
| 211 // Inform the scope that the corresponding code contains an eval call. | 211 // Inform the scope that the corresponding code contains an eval call. |
| 212 void RecordEvalCall() { if (!is_global_scope()) scope_calls_eval_ = true; } | 212 void RecordEvalCall() { if (!is_global_scope()) scope_calls_eval_ = true; } |
| 213 | 213 |
| 214 // Set the strict mode flag (unless disabled by a global flag). | 214 // Set the strict mode flag (unless disabled by a global flag). |
| 215 void SetStrictMode(StrictMode strict_mode) { strict_mode_ = strict_mode; } | 215 void SetStrictMode(StrictMode strict_mode) { strict_mode_ = strict_mode; } |
| 216 | 216 |
| 217 // Set the ASM module flag. |
| 218 void SetAsmModule() { asm_module_ = true; } |
| 219 |
| 217 // Position in the source where this scope begins and ends. | 220 // Position in the source where this scope begins and ends. |
| 218 // | 221 // |
| 219 // * For the scope of a with statement | 222 // * For the scope of a with statement |
| 220 // with (obj) stmt | 223 // with (obj) stmt |
| 221 // start position: start position of first token of 'stmt' | 224 // start position: start position of first token of 'stmt' |
| 222 // end position: end position of last token of 'stmt' | 225 // end position: end position of last token of 'stmt' |
| 223 // * For the scope of a block | 226 // * For the scope of a block |
| 224 // { stmts } | 227 // { stmts } |
| 225 // start position: start position of '{' | 228 // start position: start position of '{' |
| 226 // end position: end position of '}' | 229 // end position: end position of '}' |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 } | 277 } |
| 275 | 278 |
| 276 // Information about which scopes calls eval. | 279 // Information about which scopes calls eval. |
| 277 bool calls_eval() const { return scope_calls_eval_; } | 280 bool calls_eval() const { return scope_calls_eval_; } |
| 278 bool calls_sloppy_eval() { | 281 bool calls_sloppy_eval() { |
| 279 return scope_calls_eval_ && strict_mode_ == SLOPPY; | 282 return scope_calls_eval_ && strict_mode_ == SLOPPY; |
| 280 } | 283 } |
| 281 bool outer_scope_calls_sloppy_eval() const { | 284 bool outer_scope_calls_sloppy_eval() const { |
| 282 return outer_scope_calls_sloppy_eval_; | 285 return outer_scope_calls_sloppy_eval_; |
| 283 } | 286 } |
| 287 bool asm_module() const { return asm_module_; } |
| 288 bool asm_function() const { return asm_function_; } |
| 284 | 289 |
| 285 // Is this scope inside a with statement. | 290 // Is this scope inside a with statement. |
| 286 bool inside_with() const { return scope_inside_with_; } | 291 bool inside_with() const { return scope_inside_with_; } |
| 287 // Does this scope contain a with statement. | 292 // Does this scope contain a with statement. |
| 288 bool contains_with() const { return scope_contains_with_; } | 293 bool contains_with() const { return scope_contains_with_; } |
| 289 | 294 |
| 290 // --------------------------------------------------------------------------- | 295 // --------------------------------------------------------------------------- |
| 291 // Accessors. | 296 // Accessors. |
| 292 | 297 |
| 293 // The type of this scope. | 298 // The type of this scope. |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 | 461 |
| 457 // Scope-specific information computed during parsing. | 462 // Scope-specific information computed during parsing. |
| 458 // | 463 // |
| 459 // This scope is inside a 'with' of some outer scope. | 464 // This scope is inside a 'with' of some outer scope. |
| 460 bool scope_inside_with_; | 465 bool scope_inside_with_; |
| 461 // This scope contains a 'with' statement. | 466 // This scope contains a 'with' statement. |
| 462 bool scope_contains_with_; | 467 bool scope_contains_with_; |
| 463 // This scope or a nested catch scope or with scope contain an 'eval' call. At | 468 // This scope or a nested catch scope or with scope contain an 'eval' call. At |
| 464 // the 'eval' call site this scope is the declaration scope. | 469 // the 'eval' call site this scope is the declaration scope. |
| 465 bool scope_calls_eval_; | 470 bool scope_calls_eval_; |
| 471 // This scope contains an "use asm" annotation. |
| 472 bool asm_module_; |
| 473 // This scope's outer context is an asm module. |
| 474 bool asm_function_; |
| 466 // The strict mode of this scope. | 475 // The strict mode of this scope. |
| 467 StrictMode strict_mode_; | 476 StrictMode strict_mode_; |
| 468 // Source positions. | 477 // Source positions. |
| 469 int start_position_; | 478 int start_position_; |
| 470 int end_position_; | 479 int end_position_; |
| 471 | 480 |
| 472 // Computed via PropagateScopeInfo. | 481 // Computed via PropagateScopeInfo. |
| 473 bool outer_scope_calls_sloppy_eval_; | 482 bool outer_scope_calls_sloppy_eval_; |
| 474 bool inner_scope_calls_eval_; | 483 bool inner_scope_calls_eval_; |
| 475 bool force_eager_compilation_; | 484 bool force_eager_compilation_; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 Scope* outer_scope, | 620 Scope* outer_scope, |
| 612 Handle<ScopeInfo> scope_info); | 621 Handle<ScopeInfo> scope_info); |
| 613 | 622 |
| 614 AstValueFactory* ast_value_factory_; | 623 AstValueFactory* ast_value_factory_; |
| 615 Zone* zone_; | 624 Zone* zone_; |
| 616 }; | 625 }; |
| 617 | 626 |
| 618 } } // namespace v8::internal | 627 } } // namespace v8::internal |
| 619 | 628 |
| 620 #endif // V8_SCOPES_H_ | 629 #endif // V8_SCOPES_H_ |
| OLD | NEW |