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 23 matching lines...) Expand all Loading... |
34 namespace v8 { | 34 namespace v8 { |
35 namespace internal { | 35 namespace internal { |
36 | 36 |
37 // ---------------------------------------------------------------------------- | 37 // ---------------------------------------------------------------------------- |
38 // Implementation Variable. | 38 // Implementation Variable. |
39 | 39 |
40 const char* Variable::Mode2String(VariableMode mode) { | 40 const char* Variable::Mode2String(VariableMode mode) { |
41 switch (mode) { | 41 switch (mode) { |
42 case VAR: return "VAR"; | 42 case VAR: return "VAR"; |
43 case CONST: return "CONST"; | 43 case CONST: return "CONST"; |
| 44 case LET: return "LET"; |
44 case CONST_HARMONY: return "CONST_HARMONY"; | 45 case CONST_HARMONY: return "CONST_HARMONY"; |
45 case LET: return "LET"; | 46 case MODULE: return "MODULE"; |
46 case DYNAMIC: return "DYNAMIC"; | 47 case DYNAMIC: return "DYNAMIC"; |
47 case DYNAMIC_GLOBAL: return "DYNAMIC_GLOBAL"; | 48 case DYNAMIC_GLOBAL: return "DYNAMIC_GLOBAL"; |
48 case DYNAMIC_LOCAL: return "DYNAMIC_LOCAL"; | 49 case DYNAMIC_LOCAL: return "DYNAMIC_LOCAL"; |
49 case INTERNAL: return "INTERNAL"; | 50 case INTERNAL: return "INTERNAL"; |
50 case TEMPORARY: return "TEMPORARY"; | 51 case TEMPORARY: return "TEMPORARY"; |
51 } | 52 } |
52 UNREACHABLE(); | 53 UNREACHABLE(); |
53 return NULL; | 54 return NULL; |
54 } | 55 } |
55 | 56 |
(...skipping 21 matching lines...) Expand all Loading... |
77 // Names must be canonicalized for fast equality checks. | 78 // Names must be canonicalized for fast equality checks. |
78 ASSERT(name->IsSymbol()); | 79 ASSERT(name->IsSymbol()); |
79 // Var declared variables never need initialization. | 80 // Var declared variables never need initialization. |
80 ASSERT(!(mode == VAR && initialization_flag == kNeedsInitialization)); | 81 ASSERT(!(mode == VAR && initialization_flag == kNeedsInitialization)); |
81 } | 82 } |
82 | 83 |
83 | 84 |
84 bool Variable::IsGlobalObjectProperty() const { | 85 bool Variable::IsGlobalObjectProperty() const { |
85 // Temporaries are never global, they must always be allocated in the | 86 // Temporaries are never global, they must always be allocated in the |
86 // activation frame. | 87 // activation frame. |
87 return mode_ != TEMPORARY && !IsLexicalVariableMode(mode_) | 88 return (IsDynamicVariableMode(mode_) || |
| 89 (IsDeclaredVariableMode(mode_) && !IsLexicalVariableMode(mode_))) |
88 && scope_ != NULL && scope_->is_global_scope(); | 90 && scope_ != NULL && scope_->is_global_scope(); |
89 } | 91 } |
90 | 92 |
91 | 93 |
92 int Variable::CompareIndex(Variable* const* v, Variable* const* w) { | 94 int Variable::CompareIndex(Variable* const* v, Variable* const* w) { |
93 int x = (*v)->index(); | 95 int x = (*v)->index(); |
94 int y = (*w)->index(); | 96 int y = (*w)->index(); |
95 // Consider sorting them according to type as well? | 97 // Consider sorting them according to type as well? |
96 return x - y; | 98 return x - y; |
97 } | 99 } |
98 | 100 |
99 } } // namespace v8::internal | 101 } } // namespace v8::internal |
OLD | NEW |