OLD | NEW |
1 // Copyright 2017 the V8 project authors. All rights reserved. | 1 // Copyright 2017 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_CCTEST_SCOPE_TEST_HELPER_H_ | 5 #ifndef V8_CCTEST_SCOPE_TEST_HELPER_H_ |
6 #define V8_CCTEST_SCOPE_TEST_HELPER_H_ | 6 #define V8_CCTEST_SCOPE_TEST_HELPER_H_ |
7 | 7 |
8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
9 #include "src/ast/variables.h" | 9 #include "src/ast/variables.h" |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 for (Scope* inner = scope->inner_scope(); inner != nullptr; | 25 for (Scope* inner = scope->inner_scope(); inner != nullptr; |
26 inner = inner->sibling()) { | 26 inner = inner->sibling()) { |
27 if (!ScopeTreeIsHidden(inner)) { | 27 if (!ScopeTreeIsHidden(inner)) { |
28 return false; | 28 return false; |
29 } | 29 } |
30 } | 30 } |
31 return true; | 31 return true; |
32 } | 32 } |
33 | 33 |
34 static void CompareScopeToData(Scope* scope, const PreParsedScopeData* data, | 34 static void CompareScopeToData(Scope* scope, const PreParsedScopeData* data, |
35 size_t& index) { | 35 size_t& index, bool precise_maybe_assigned) { |
36 CHECK_EQ(data->backing_store_[index++], scope->scope_type()); | 36 CHECK_EQ(data->backing_store_[index++], scope->scope_type()); |
37 CHECK_EQ(data->backing_store_[index++], scope->start_position()); | 37 CHECK_EQ(data->backing_store_[index++], scope->start_position()); |
38 CHECK_EQ(data->backing_store_[index++], scope->end_position()); | 38 CHECK_EQ(data->backing_store_[index++], scope->end_position()); |
39 | 39 |
40 int inner_scope_count = 0; | 40 int inner_scope_count = 0; |
41 for (Scope* inner = scope->inner_scope(); inner != nullptr; | 41 for (Scope* inner = scope->inner_scope(); inner != nullptr; |
42 inner = inner->sibling()) { | 42 inner = inner->sibling()) { |
43 // FIXME(marja): This is probably not the right condition for knowing what | 43 // FIXME(marja): This is probably not the right condition for knowing what |
44 // scopes are present in the preparse data. | 44 // scopes are present in the preparse data. |
45 if (!ScopeTreeIsHidden(inner)) { | 45 if (!ScopeTreeIsHidden(inner)) { |
(...skipping 17 matching lines...) Expand all Loading... |
63 local->mode() == CONST) { | 63 local->mode() == CONST) { |
64 #ifdef DEBUG | 64 #ifdef DEBUG |
65 const AstRawString* local_name = local->raw_name(); | 65 const AstRawString* local_name = local->raw_name(); |
66 int name_length = data->backing_store_[index++]; | 66 int name_length = data->backing_store_[index++]; |
67 CHECK_EQ(name_length, local_name->length()); | 67 CHECK_EQ(name_length, local_name->length()); |
68 for (int i = 0; i < name_length; ++i) { | 68 for (int i = 0; i < name_length; ++i) { |
69 CHECK_EQ(data->backing_store_[index++], local_name->raw_data()[i]); | 69 CHECK_EQ(data->backing_store_[index++], local_name->raw_data()[i]); |
70 } | 70 } |
71 #endif | 71 #endif |
72 CHECK_EQ(data->backing_store_[index++], local->location()); | 72 CHECK_EQ(data->backing_store_[index++], local->location()); |
73 CHECK_EQ(data->backing_store_[index++], local->maybe_assigned()); | 73 if (precise_maybe_assigned) { |
| 74 CHECK_EQ(data->backing_store_[index++], local->maybe_assigned()); |
| 75 } else { |
| 76 STATIC_ASSERT(kMaybeAssigned > kNotAssigned); |
| 77 CHECK_GE(data->backing_store_[index++], local->maybe_assigned()); |
| 78 } |
74 } | 79 } |
75 } | 80 } |
76 | 81 |
77 for (Scope* inner = scope->inner_scope(); inner != nullptr; | 82 for (Scope* inner = scope->inner_scope(); inner != nullptr; |
78 inner = inner->sibling()) { | 83 inner = inner->sibling()) { |
79 if (!ScopeTreeIsHidden(inner)) { | 84 if (!ScopeTreeIsHidden(inner)) { |
80 CompareScopeToData(inner, data, index); | 85 CompareScopeToData(inner, data, index, precise_maybe_assigned); |
81 } | 86 } |
82 } | 87 } |
83 } | 88 } |
84 }; | 89 }; |
85 } // namespace internal | 90 } // namespace internal |
86 } // namespace v8 | 91 } // namespace v8 |
87 | 92 |
88 #endif // V8_CCTEST_SCOPE_TEST_HELPER_H_ | 93 #endif // V8_CCTEST_SCOPE_TEST_HELPER_H_ |
OLD | NEW |