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 #ifndef V8_PREPARSE_DATA_H_ | 5 #ifndef V8_PREPARSE_DATA_H_ |
6 #define V8_PREPARSE_DATA_H_ | 6 #define V8_PREPARSE_DATA_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/hashmap.h" | 9 #include "src/hashmap.h" |
10 #include "src/messages.h" | 10 #include "src/messages.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 // Abstract interface for preparse data recorder. | 48 // Abstract interface for preparse data recorder. |
49 class ParserRecorder { | 49 class ParserRecorder { |
50 public: | 50 public: |
51 ParserRecorder() { } | 51 ParserRecorder() { } |
52 virtual ~ParserRecorder() { } | 52 virtual ~ParserRecorder() { } |
53 | 53 |
54 // Logs the scope and some details of a function literal in the source. | 54 // Logs the scope and some details of a function literal in the source. |
55 virtual void LogFunction(int start, int end, int literals, int properties, | 55 virtual void LogFunction(int start, int end, int literals, int properties, |
56 LanguageMode language_mode, bool uses_super_property, | 56 LanguageMode language_mode, bool uses_super_property, |
57 bool calls_eval) = 0; | 57 bool calls_eval, bool has_simple_parameters) = 0; |
58 | 58 |
59 // Logs an error message and marks the log as containing an error. | 59 // Logs an error message and marks the log as containing an error. |
60 // Further logging will be ignored, and ExtractData will return a vector | 60 // Further logging will be ignored, and ExtractData will return a vector |
61 // representing the error only. | 61 // representing the error only. |
62 virtual void LogMessage(int start, int end, MessageTemplate::Template message, | 62 virtual void LogMessage(int start, int end, MessageTemplate::Template message, |
63 const char* argument_opt, | 63 const char* argument_opt, |
64 ParseErrorType error_type) = 0; | 64 ParseErrorType error_type) = 0; |
65 | 65 |
66 private: | 66 private: |
67 DISALLOW_COPY_AND_ASSIGN(ParserRecorder); | 67 DISALLOW_COPY_AND_ASSIGN(ParserRecorder); |
68 }; | 68 }; |
69 | 69 |
70 | 70 |
71 class SingletonLogger : public ParserRecorder { | 71 class SingletonLogger : public ParserRecorder { |
72 public: | 72 public: |
73 SingletonLogger() | 73 SingletonLogger() |
74 : has_error_(false), start_(-1), end_(-1), error_type_(kSyntaxError) {} | 74 : has_error_(false), start_(-1), end_(-1), error_type_(kSyntaxError) {} |
75 virtual ~SingletonLogger() {} | 75 virtual ~SingletonLogger() {} |
76 | 76 |
77 void Reset() { has_error_ = false; } | 77 void Reset() { has_error_ = false; } |
78 | 78 |
79 virtual void LogFunction(int start, int end, int literals, int properties, | 79 virtual void LogFunction(int start, int end, int literals, int properties, |
80 LanguageMode language_mode, bool uses_super_property, | 80 LanguageMode language_mode, bool uses_super_property, |
81 bool calls_eval) { | 81 bool calls_eval, bool has_simple_parameters) { |
82 DCHECK(!has_error_); | 82 DCHECK(!has_error_); |
83 start_ = start; | 83 start_ = start; |
84 end_ = end; | 84 end_ = end; |
85 literals_ = literals; | 85 literals_ = literals; |
86 properties_ = properties; | 86 properties_ = properties; |
87 language_mode_ = language_mode; | 87 language_mode_ = language_mode; |
88 uses_super_property_ = uses_super_property; | 88 uses_super_property_ = uses_super_property; |
89 calls_eval_ = calls_eval; | 89 calls_eval_ = calls_eval; |
| 90 has_simple_parameters_ = has_simple_parameters; |
90 } | 91 } |
91 | 92 |
92 // Logs an error message and marks the log as containing an error. | 93 // Logs an error message and marks the log as containing an error. |
93 // Further logging will be ignored, and ExtractData will return a vector | 94 // Further logging will be ignored, and ExtractData will return a vector |
94 // representing the error only. | 95 // representing the error only. |
95 virtual void LogMessage(int start, int end, MessageTemplate::Template message, | 96 virtual void LogMessage(int start, int end, MessageTemplate::Template message, |
96 const char* argument_opt, ParseErrorType error_type) { | 97 const char* argument_opt, ParseErrorType error_type) { |
97 if (has_error_) return; | 98 if (has_error_) return; |
98 has_error_ = true; | 99 has_error_ = true; |
99 start_ = start; | 100 start_ = start; |
(...skipping 20 matching lines...) Expand all Loading... |
120 return language_mode_; | 121 return language_mode_; |
121 } | 122 } |
122 bool uses_super_property() const { | 123 bool uses_super_property() const { |
123 DCHECK(!has_error_); | 124 DCHECK(!has_error_); |
124 return uses_super_property_; | 125 return uses_super_property_; |
125 } | 126 } |
126 bool calls_eval() const { | 127 bool calls_eval() const { |
127 DCHECK(!has_error_); | 128 DCHECK(!has_error_); |
128 return calls_eval_; | 129 return calls_eval_; |
129 } | 130 } |
| 131 bool has_simple_parameters() const { |
| 132 DCHECK(!has_error_); |
| 133 return has_simple_parameters_; |
| 134 } |
130 ParseErrorType error_type() const { | 135 ParseErrorType error_type() const { |
131 DCHECK(has_error_); | 136 DCHECK(has_error_); |
132 return error_type_; | 137 return error_type_; |
133 } | 138 } |
134 MessageTemplate::Template message() { | 139 MessageTemplate::Template message() { |
135 DCHECK(has_error_); | 140 DCHECK(has_error_); |
136 return message_; | 141 return message_; |
137 } | 142 } |
138 const char* argument_opt() const { | 143 const char* argument_opt() const { |
139 DCHECK(has_error_); | 144 DCHECK(has_error_); |
140 return argument_opt_; | 145 return argument_opt_; |
141 } | 146 } |
142 | 147 |
143 private: | 148 private: |
144 bool has_error_; | 149 bool has_error_; |
145 int start_; | 150 int start_; |
146 int end_; | 151 int end_; |
147 // For function entries. | 152 // For function entries. |
148 int literals_; | 153 int literals_; |
149 int properties_; | 154 int properties_; |
150 LanguageMode language_mode_; | 155 LanguageMode language_mode_; |
151 bool uses_super_property_; | 156 bool uses_super_property_; |
152 bool calls_eval_; | 157 bool calls_eval_; |
| 158 bool has_simple_parameters_; |
153 // For error messages. | 159 // For error messages. |
154 MessageTemplate::Template message_; | 160 MessageTemplate::Template message_; |
155 const char* argument_opt_; | 161 const char* argument_opt_; |
156 ParseErrorType error_type_; | 162 ParseErrorType error_type_; |
157 }; | 163 }; |
158 | 164 |
159 | 165 |
160 class CompleteParserRecorder : public ParserRecorder { | 166 class CompleteParserRecorder : public ParserRecorder { |
161 public: | 167 public: |
162 struct Key { | 168 struct Key { |
163 bool is_one_byte; | 169 bool is_one_byte; |
164 Vector<const byte> literal_bytes; | 170 Vector<const byte> literal_bytes; |
165 }; | 171 }; |
166 | 172 |
167 CompleteParserRecorder(); | 173 CompleteParserRecorder(); |
168 virtual ~CompleteParserRecorder() {} | 174 virtual ~CompleteParserRecorder() {} |
169 | 175 |
170 virtual void LogFunction(int start, int end, int literals, int properties, | 176 virtual void LogFunction(int start, int end, int literals, int properties, |
171 LanguageMode language_mode, bool uses_super_property, | 177 LanguageMode language_mode, bool uses_super_property, |
172 bool calls_eval) { | 178 bool calls_eval, bool has_simple_parameters) { |
173 function_store_.Add(start); | 179 function_store_.Add(start); |
174 function_store_.Add(end); | 180 function_store_.Add(end); |
175 function_store_.Add(literals); | 181 function_store_.Add(literals); |
176 function_store_.Add(properties); | 182 function_store_.Add(properties); |
177 function_store_.Add(language_mode); | 183 function_store_.Add(language_mode); |
178 function_store_.Add(uses_super_property); | 184 function_store_.Add(uses_super_property); |
179 function_store_.Add(calls_eval); | 185 function_store_.Add(calls_eval); |
| 186 function_store_.Add(has_simple_parameters); |
180 } | 187 } |
181 | 188 |
182 // Logs an error message and marks the log as containing an error. | 189 // Logs an error message and marks the log as containing an error. |
183 // Further logging will be ignored, and ExtractData will return a vector | 190 // Further logging will be ignored, and ExtractData will return a vector |
184 // representing the error only. | 191 // representing the error only. |
185 virtual void LogMessage(int start, int end, MessageTemplate::Template message, | 192 virtual void LogMessage(int start, int end, MessageTemplate::Template message, |
186 const char* argument_opt, ParseErrorType error_type); | 193 const char* argument_opt, ParseErrorType error_type); |
187 ScriptData* GetScriptData(); | 194 ScriptData* GetScriptData(); |
188 | 195 |
189 bool HasError() { | 196 bool HasError() { |
(...skipping 12 matching lines...) Expand all Loading... |
202 | 209 |
203 #ifdef DEBUG | 210 #ifdef DEBUG |
204 int prev_start_; | 211 int prev_start_; |
205 #endif | 212 #endif |
206 }; | 213 }; |
207 | 214 |
208 | 215 |
209 } } // namespace v8::internal. | 216 } } // namespace v8::internal. |
210 | 217 |
211 #endif // V8_PREPARSE_DATA_H_ | 218 #endif // V8_PREPARSE_DATA_H_ |
OLD | NEW |