OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 #include "src/ast/variables.h" | 5 #include "src/ast/variables.h" |
6 | 6 |
7 #include "src/ast/ast.h" | 7 #include "src/ast/ast.h" |
8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
9 #include "src/globals.h" | 9 #include "src/globals.h" |
10 | 10 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 // Var declared variables never need initialization. | 47 // Var declared variables never need initialization. |
48 DCHECK(!(mode == VAR && initialization_flag == kNeedsInitialization)); | 48 DCHECK(!(mode == VAR && initialization_flag == kNeedsInitialization)); |
49 } | 49 } |
50 | 50 |
51 | 51 |
52 bool Variable::IsGlobalObjectProperty() const { | 52 bool Variable::IsGlobalObjectProperty() const { |
53 // Temporaries are never global, they must always be allocated in the | 53 // Temporaries are never global, they must always be allocated in the |
54 // activation frame. | 54 // activation frame. |
55 return (IsDynamicVariableMode(mode_) || | 55 return (IsDynamicVariableMode(mode_) || |
56 (IsDeclaredVariableMode(mode_) && !IsLexicalVariableMode(mode_))) && | 56 (IsDeclaredVariableMode(mode_) && !IsLexicalVariableMode(mode_))) && |
57 scope_ != NULL && scope_->is_script_scope() && !is_this(); | 57 scope_ != NULL && scope_->is_script_scope(); |
58 } | 58 } |
59 | 59 |
60 | 60 |
61 bool Variable::IsStaticGlobalObjectProperty() const { | 61 bool Variable::IsStaticGlobalObjectProperty() const { |
62 // Temporaries are never global, they must always be allocated in the | 62 // Temporaries are never global, they must always be allocated in the |
63 // activation frame. | 63 // activation frame. |
64 return (IsDeclaredVariableMode(mode_) && !IsLexicalVariableMode(mode_)) && | 64 return (IsDeclaredVariableMode(mode_) && !IsLexicalVariableMode(mode_)) && |
65 scope_ != NULL && scope_->is_script_scope() && !is_this(); | 65 scope_ != NULL && scope_->is_script_scope(); |
66 } | 66 } |
67 | 67 |
68 | 68 |
69 int Variable::CompareIndex(Variable* const* v, Variable* const* w) { | 69 int Variable::CompareIndex(Variable* const* v, Variable* const* w) { |
70 int x = (*v)->index(); | 70 int x = (*v)->index(); |
71 int y = (*w)->index(); | 71 int y = (*w)->index(); |
72 // Consider sorting them according to type as well? | 72 // Consider sorting them according to type as well? |
73 return x - y; | 73 return x - y; |
74 } | 74 } |
75 | 75 |
76 } // namespace internal | 76 } // namespace internal |
77 } // namespace v8 | 77 } // namespace v8 |
OLD | NEW |