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/scopes.h" | 7 #include "src/ast/scopes.h" |
8 #include "src/globals.h" | 8 #include "src/globals.h" |
9 #include "src/objects-inl.h" | 9 #include "src/objects-inl.h" |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 LocationField::encode(VariableLocation::UNALLOCATED) | | 30 LocationField::encode(VariableLocation::UNALLOCATED) | |
31 VariableKindField::encode(kind)) { | 31 VariableKindField::encode(kind)) { |
32 // Var declared variables never need initialization. | 32 // Var declared variables never need initialization. |
33 DCHECK(!(mode == VAR && initialization_flag == kNeedsInitialization)); | 33 DCHECK(!(mode == VAR && initialization_flag == kNeedsInitialization)); |
34 } | 34 } |
35 | 35 |
36 | 36 |
37 bool Variable::IsGlobalObjectProperty() const { | 37 bool Variable::IsGlobalObjectProperty() const { |
38 // Temporaries are never global, they must always be allocated in the | 38 // Temporaries are never global, they must always be allocated in the |
39 // activation frame. | 39 // activation frame. |
40 return (IsDynamicVariableMode(mode()) || | 40 return (IsDynamicVariableMode(mode()) || mode() == VAR) && |
41 (IsDeclaredVariableMode(mode()) && !IsLexicalVariableMode(mode()))) && | 41 scope_ != nullptr && scope_->is_script_scope(); |
42 scope_ != NULL && scope_->is_script_scope(); | |
43 } | 42 } |
44 | 43 |
45 } // namespace internal | 44 } // namespace internal |
46 } // namespace v8 | 45 } // namespace v8 |
OLD | NEW |