OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 (static_cast<uint64_t>(kNaNOrInfinityLowerBoundUpper32) << 32); | 480 (static_cast<uint64_t>(kNaNOrInfinityLowerBoundUpper32) << 32); |
481 | 481 |
482 | 482 |
483 // The order of this enum has to be kept in sync with the predicates below. | 483 // The order of this enum has to be kept in sync with the predicates below. |
484 enum VariableMode { | 484 enum VariableMode { |
485 // User declared variables: | 485 // User declared variables: |
486 VAR, // declared via 'var', and 'function' declarations | 486 VAR, // declared via 'var', and 'function' declarations |
487 | 487 |
488 CONST, // declared via 'const' declarations | 488 CONST, // declared via 'const' declarations |
489 | 489 |
490 LET, // declared via 'let' declarations | 490 LET, // declared via 'let' declarations (first lexical) |
491 | 491 |
492 CONST_HARMONY, // declared via 'const' declarations in harmony mode | 492 CONST_HARMONY, // declared via 'const' declarations in harmony mode |
493 | 493 |
| 494 MODULE, // declared via 'module' declaration (last lexical) |
| 495 |
494 // Variables introduced by the compiler: | 496 // Variables introduced by the compiler: |
| 497 INTERNAL, // like VAR, but not user-visible (may or may not |
| 498 // be in a context) |
| 499 |
| 500 TEMPORARY, // temporary variables (not user-visible), never |
| 501 // in a context |
| 502 |
495 DYNAMIC, // always require dynamic lookup (we don't know | 503 DYNAMIC, // always require dynamic lookup (we don't know |
496 // the declaration) | 504 // the declaration) |
497 | 505 |
498 DYNAMIC_GLOBAL, // requires dynamic lookup, but we know that the | 506 DYNAMIC_GLOBAL, // requires dynamic lookup, but we know that the |
499 // variable is global unless it has been shadowed | 507 // variable is global unless it has been shadowed |
500 // by an eval-introduced variable | 508 // by an eval-introduced variable |
501 | 509 |
502 DYNAMIC_LOCAL, // requires dynamic lookup, but we know that the | 510 DYNAMIC_LOCAL // requires dynamic lookup, but we know that the |
503 // variable is local and where it is unless it | 511 // variable is local and where it is unless it |
504 // has been shadowed by an eval-introduced | 512 // has been shadowed by an eval-introduced |
505 // variable | 513 // variable |
506 | |
507 INTERNAL, // like VAR, but not user-visible (may or may not | |
508 // be in a context) | |
509 | |
510 TEMPORARY // temporary variables (not user-visible), never | |
511 // in a context | |
512 }; | 514 }; |
513 | 515 |
514 | 516 |
515 inline bool IsDynamicVariableMode(VariableMode mode) { | 517 inline bool IsDynamicVariableMode(VariableMode mode) { |
516 return mode >= DYNAMIC && mode <= DYNAMIC_LOCAL; | 518 return mode >= DYNAMIC && mode <= DYNAMIC_LOCAL; |
517 } | 519 } |
518 | 520 |
519 | 521 |
520 inline bool IsDeclaredVariableMode(VariableMode mode) { | 522 inline bool IsDeclaredVariableMode(VariableMode mode) { |
521 return mode >= VAR && mode <= CONST_HARMONY; | 523 return mode >= VAR && mode <= MODULE; |
522 } | 524 } |
523 | 525 |
524 | 526 |
525 inline bool IsLexicalVariableMode(VariableMode mode) { | 527 inline bool IsLexicalVariableMode(VariableMode mode) { |
526 return mode >= LET && mode <= CONST_HARMONY; | 528 return mode >= LET && mode <= MODULE; |
527 } | 529 } |
528 | 530 |
529 | 531 |
530 inline bool IsImmutableVariableMode(VariableMode mode) { | 532 inline bool IsImmutableVariableMode(VariableMode mode) { |
531 return mode == CONST || mode == CONST_HARMONY; | 533 return mode == CONST || (mode >= CONST_HARMONY && mode <= MODULE); |
532 } | 534 } |
533 | 535 |
534 | 536 |
535 // ES6 Draft Rev3 10.2 specifies declarative environment records with mutable | 537 // ES6 Draft Rev3 10.2 specifies declarative environment records with mutable |
536 // and immutable bindings that can be in two states: initialized and | 538 // and immutable bindings that can be in two states: initialized and |
537 // uninitialized. In ES5 only immutable bindings have these two states. When | 539 // uninitialized. In ES5 only immutable bindings have these two states. When |
538 // accessing a binding, it needs to be checked for initialization. However in | 540 // accessing a binding, it needs to be checked for initialization. However in |
539 // the following cases the binding is initialized immediately after creation | 541 // the following cases the binding is initialized immediately after creation |
540 // so the initialization check can always be skipped: | 542 // so the initialization check can always be skipped: |
541 // 1. Var declared local variables. | 543 // 1. Var declared local variables. |
(...skipping 29 matching lines...) Expand all Loading... |
571 | 573 |
572 enum ClearExceptionFlag { | 574 enum ClearExceptionFlag { |
573 KEEP_EXCEPTION, | 575 KEEP_EXCEPTION, |
574 CLEAR_EXCEPTION | 576 CLEAR_EXCEPTION |
575 }; | 577 }; |
576 | 578 |
577 | 579 |
578 } } // namespace v8::internal | 580 } } // namespace v8::internal |
579 | 581 |
580 #endif // V8_V8GLOBALS_H_ | 582 #endif // V8_V8GLOBALS_H_ |
OLD | NEW |