OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 virtual ~ParserRecorder() { } | 45 virtual ~ParserRecorder() { } |
46 | 46 |
47 // Logs the scope and some details of a function literal in the source. | 47 // Logs the scope and some details of a function literal in the source. |
48 virtual void LogFunction(int start, | 48 virtual void LogFunction(int start, |
49 int end, | 49 int end, |
50 int literals, | 50 int literals, |
51 int properties, | 51 int properties, |
52 StrictMode strict_mode) = 0; | 52 StrictMode strict_mode) = 0; |
53 | 53 |
54 // Logs a symbol creation of a literal or identifier. | 54 // Logs a symbol creation of a literal or identifier. |
55 virtual void LogAsciiSymbol(int start, Vector<const char> literal) { } | 55 virtual void LogOneByteSymbol(int start, Vector<const uint8_t> literal) = 0; |
56 virtual void LogUtf16Symbol(int start, Vector<const uc16> literal) { } | 56 virtual void LogTwoByteSymbol(int start, Vector<const uint16_t> literal) = 0; |
57 | 57 |
58 // Logs an error message and marks the log as containing an error. | 58 // Logs an error message and marks the log as containing an error. |
59 // Further logging will be ignored, and ExtractData will return a vector | 59 // Further logging will be ignored, and ExtractData will return a vector |
60 // representing the error only. | 60 // representing the error only. |
61 virtual void LogMessage(int start, | 61 virtual void LogMessage(int start, |
62 int end, | 62 int end, |
63 const char* message, | 63 const char* message, |
64 const char* argument_opt) = 0; | 64 const char* argument_opt) = 0; |
65 | 65 |
66 virtual int function_position() = 0; | 66 virtual int function_position() = 0; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 #endif | 141 #endif |
142 }; | 142 }; |
143 | 143 |
144 | 144 |
145 // ---------------------------------------------------------------------------- | 145 // ---------------------------------------------------------------------------- |
146 // PartialParserRecorder - Record only function entries | 146 // PartialParserRecorder - Record only function entries |
147 | 147 |
148 class PartialParserRecorder : public FunctionLoggingParserRecorder { | 148 class PartialParserRecorder : public FunctionLoggingParserRecorder { |
149 public: | 149 public: |
150 PartialParserRecorder() : FunctionLoggingParserRecorder() { } | 150 PartialParserRecorder() : FunctionLoggingParserRecorder() { } |
151 virtual void LogAsciiSymbol(int start, Vector<const char> literal) { } | 151 virtual void LogOneByteSymbol(int start, Vector<const uint8_t> literal) { } |
152 virtual void LogUtf16Symbol(int start, Vector<const uc16> literal) { } | 152 virtual void LogTwoByteSymbol(int start, Vector<const uint16_t> literal) { } |
153 virtual ~PartialParserRecorder() { } | 153 virtual ~PartialParserRecorder() { } |
154 virtual Vector<unsigned> ExtractData(); | 154 virtual Vector<unsigned> ExtractData(); |
155 virtual int symbol_position() { return 0; } | 155 virtual int symbol_position() { return 0; } |
156 virtual int symbol_ids() { return 0; } | 156 virtual int symbol_ids() { return 0; } |
157 }; | 157 }; |
158 | 158 |
159 | 159 |
160 // ---------------------------------------------------------------------------- | 160 // ---------------------------------------------------------------------------- |
161 // CompleteParserRecorder - Record both function entries and symbols. | 161 // CompleteParserRecorder - Record both function entries and symbols. |
162 | 162 |
163 class CompleteParserRecorder: public FunctionLoggingParserRecorder { | 163 class CompleteParserRecorder: public FunctionLoggingParserRecorder { |
164 public: | 164 public: |
165 CompleteParserRecorder(); | 165 CompleteParserRecorder(); |
166 virtual ~CompleteParserRecorder() { } | 166 virtual ~CompleteParserRecorder() { } |
167 | 167 |
168 virtual void LogAsciiSymbol(int start, Vector<const char> literal) { | 168 virtual void LogOneByteSymbol(int start, Vector<const uint8_t> literal) { |
169 if (!is_recording_) return; | 169 if (!is_recording_) return; |
170 int hash = vector_hash(literal); | 170 int hash = vector_hash(literal); |
171 LogSymbol(start, hash, true, Vector<const byte>::cast(literal)); | 171 LogSymbol(start, hash, true, literal); |
172 } | 172 } |
173 | 173 |
174 virtual void LogUtf16Symbol(int start, Vector<const uc16> literal) { | 174 virtual void LogTwoByteSymbol(int start, Vector<const uint16_t> literal) { |
175 if (!is_recording_) return; | 175 if (!is_recording_) return; |
176 int hash = vector_hash(literal); | 176 int hash = vector_hash(literal); |
177 LogSymbol(start, hash, false, Vector<const byte>::cast(literal)); | 177 LogSymbol(start, hash, false, Vector<const byte>::cast(literal)); |
178 } | 178 } |
179 | 179 |
180 virtual Vector<unsigned> ExtractData(); | 180 virtual Vector<unsigned> ExtractData(); |
181 | 181 |
182 virtual int symbol_position() { return symbol_store_.size(); } | 182 virtual int symbol_position() { return symbol_store_.size(); } |
183 virtual int symbol_ids() { return symbol_id_; } | 183 virtual int symbol_ids() { return symbol_id_; } |
184 | 184 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 Collector<byte> symbol_store_; | 226 Collector<byte> symbol_store_; |
227 Collector<Key> symbol_keys_; | 227 Collector<Key> symbol_keys_; |
228 HashMap string_table_; | 228 HashMap string_table_; |
229 int symbol_id_; | 229 int symbol_id_; |
230 }; | 230 }; |
231 | 231 |
232 | 232 |
233 } } // namespace v8::internal. | 233 } } // namespace v8::internal. |
234 | 234 |
235 #endif // V8_PREPARSE_DATA_H_ | 235 #endif // V8_PREPARSE_DATA_H_ |
OLD | NEW |