OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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_PARSING_FUNC_NAME_INFERRER_H_ | 5 #ifndef V8_PARSING_FUNC_NAME_INFERRER_H_ |
6 #define V8_PARSING_FUNC_NAME_INFERRER_H_ | 6 #define V8_PARSING_FUNC_NAME_INFERRER_H_ |
7 | 7 |
8 #include "src/handles.h" | 8 #include "src/handles.h" |
9 #include "src/zone.h" | 9 #include "src/zone.h" |
10 | 10 |
11 namespace v8 { | 11 namespace v8 { |
12 namespace internal { | 12 namespace internal { |
13 | 13 |
14 class AstRawString; | 14 class AstRawString; |
15 class AstString; | 15 class AstString; |
16 class AstValueFactory; | 16 class AstValueFactory; |
17 class FunctionLiteral; | 17 class FunctionLiteral; |
18 | 18 |
| 19 enum class InferName { Yes, No }; |
| 20 |
19 // FuncNameInferrer is a stateful class that is used to perform name | 21 // FuncNameInferrer is a stateful class that is used to perform name |
20 // inference for anonymous functions during static analysis of source code. | 22 // inference for anonymous functions during static analysis of source code. |
21 // Inference is performed in cases when an anonymous function is assigned | 23 // Inference is performed in cases when an anonymous function is assigned |
22 // to a variable or a property (see test-func-name-inference.cc for examples.) | 24 // to a variable or a property (see test-func-name-inference.cc for examples.) |
23 // | 25 // |
24 // The basic idea is that during parsing of LHSs of certain expressions | 26 // The basic idea is that during parsing of LHSs of certain expressions |
25 // (assignments, declarations, object literals) we collect name strings, | 27 // (assignments, declarations, object literals) we collect name strings, |
26 // and during parsing of the RHS, a function literal can be collected. After | 28 // and during parsing of the RHS, a function literal can be collected. After |
27 // parsing the RHS we can infer a name for function literals that do not have | 29 // parsing the RHS we can infer a name for function literals that do not have |
28 // a name. | 30 // a name. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 funcs_to_infer_.Add(func_to_infer, zone()); | 66 funcs_to_infer_.Add(func_to_infer, zone()); |
65 } | 67 } |
66 } | 68 } |
67 | 69 |
68 void RemoveLastFunction() { | 70 void RemoveLastFunction() { |
69 if (IsOpen() && !funcs_to_infer_.is_empty()) { | 71 if (IsOpen() && !funcs_to_infer_.is_empty()) { |
70 funcs_to_infer_.RemoveLast(); | 72 funcs_to_infer_.RemoveLast(); |
71 } | 73 } |
72 } | 74 } |
73 | 75 |
| 76 void RemoveAsyncKeywordFromEnd(); |
| 77 |
74 // Infers a function name and leaves names collection state. | 78 // Infers a function name and leaves names collection state. |
75 void Infer() { | 79 void Infer() { |
76 DCHECK(IsOpen()); | 80 DCHECK(IsOpen()); |
77 if (!funcs_to_infer_.is_empty()) { | 81 if (!funcs_to_infer_.is_empty()) { |
78 InferFunctionsNames(); | 82 InferFunctionsNames(); |
79 } | 83 } |
80 } | 84 } |
81 | 85 |
82 private: | 86 private: |
83 enum NameType { | 87 enum NameType { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 Zone* zone_; | 122 Zone* zone_; |
119 | 123 |
120 DISALLOW_COPY_AND_ASSIGN(FuncNameInferrer); | 124 DISALLOW_COPY_AND_ASSIGN(FuncNameInferrer); |
121 }; | 125 }; |
122 | 126 |
123 | 127 |
124 } // namespace internal | 128 } // namespace internal |
125 } // namespace v8 | 129 } // namespace v8 |
126 | 130 |
127 #endif // V8_PARSING_FUNC_NAME_INFERRER_H_ | 131 #endif // V8_PARSING_FUNC_NAME_INFERRER_H_ |
OLD | NEW |