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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 int literals, | 48 int literals, |
49 int properties, | 49 int properties, |
50 StrictMode strict_mode) = 0; | 50 StrictMode strict_mode) = 0; |
51 | 51 |
52 // Logs an error message and marks the log as containing an error. | 52 // Logs an error message and marks the log as containing an error. |
53 // Further logging will be ignored, and ExtractData will return a vector | 53 // Further logging will be ignored, and ExtractData will return a vector |
54 // representing the error only. | 54 // representing the error only. |
55 virtual void LogMessage(int start, | 55 virtual void LogMessage(int start, |
56 int end, | 56 int end, |
57 const char* message, | 57 const char* message, |
58 const char* argument_opt) = 0; | 58 const char* argument_opt, |
| 59 bool is_reference_error) = 0; |
59 | 60 |
60 // Logs a symbol creation of a literal or identifier. | 61 // Logs a symbol creation of a literal or identifier. |
61 bool ShouldLogSymbols() { return should_log_symbols_; } | 62 bool ShouldLogSymbols() { return should_log_symbols_; } |
62 // The following functions are only callable on CompleteParserRecorder | 63 // The following functions are only callable on CompleteParserRecorder |
63 // and are guarded by calls to ShouldLogSymbols. | 64 // and are guarded by calls to ShouldLogSymbols. |
64 virtual void LogOneByteSymbol(int start, Vector<const uint8_t> literal) { | 65 virtual void LogOneByteSymbol(int start, Vector<const uint8_t> literal) { |
65 UNREACHABLE(); | 66 UNREACHABLE(); |
66 } | 67 } |
67 virtual void LogTwoByteSymbol(int start, Vector<const uint16_t> literal) { | 68 virtual void LogTwoByteSymbol(int start, Vector<const uint16_t> literal) { |
68 UNREACHABLE(); | 69 UNREACHABLE(); |
69 } | 70 } |
70 virtual void PauseRecording() { UNREACHABLE(); } | 71 virtual void PauseRecording() { UNREACHABLE(); } |
71 virtual void ResumeRecording() { UNREACHABLE(); } | 72 virtual void ResumeRecording() { UNREACHABLE(); } |
72 | 73 |
73 protected: | 74 protected: |
74 bool should_log_symbols_; | 75 bool should_log_symbols_; |
75 | 76 |
76 private: | 77 private: |
77 DISALLOW_COPY_AND_ASSIGN(ParserRecorder); | 78 DISALLOW_COPY_AND_ASSIGN(ParserRecorder); |
78 }; | 79 }; |
79 | 80 |
80 | 81 |
81 class SingletonLogger : public ParserRecorder { | 82 class SingletonLogger : public ParserRecorder { |
82 public: | 83 public: |
83 SingletonLogger() : has_error_(false), start_(-1), end_(-1) { } | 84 SingletonLogger() |
84 virtual ~SingletonLogger() { } | 85 : has_error_(false), start_(-1), end_(-1), is_reference_error_(false) {} |
| 86 virtual ~SingletonLogger() {} |
85 | 87 |
86 void Reset() { has_error_ = false; } | 88 void Reset() { has_error_ = false; } |
87 | 89 |
88 virtual void LogFunction(int start, | 90 virtual void LogFunction(int start, |
89 int end, | 91 int end, |
90 int literals, | 92 int literals, |
91 int properties, | 93 int properties, |
92 StrictMode strict_mode) { | 94 StrictMode strict_mode) { |
93 ASSERT(!has_error_); | 95 ASSERT(!has_error_); |
94 start_ = start; | 96 start_ = start; |
95 end_ = end; | 97 end_ = end; |
96 literals_ = literals; | 98 literals_ = literals; |
97 properties_ = properties; | 99 properties_ = properties; |
98 strict_mode_ = strict_mode; | 100 strict_mode_ = strict_mode; |
99 }; | 101 }; |
100 | 102 |
101 // Logs an error message and marks the log as containing an error. | 103 // Logs an error message and marks the log as containing an error. |
102 // Further logging will be ignored, and ExtractData will return a vector | 104 // Further logging will be ignored, and ExtractData will return a vector |
103 // representing the error only. | 105 // representing the error only. |
104 virtual void LogMessage(int start, | 106 virtual void LogMessage(int start, |
105 int end, | 107 int end, |
106 const char* message, | 108 const char* message, |
107 const char* argument_opt) { | 109 const char* argument_opt, |
| 110 bool is_reference_error) { |
108 if (has_error_) return; | 111 if (has_error_) return; |
109 has_error_ = true; | 112 has_error_ = true; |
110 start_ = start; | 113 start_ = start; |
111 end_ = end; | 114 end_ = end; |
112 message_ = message; | 115 message_ = message; |
113 argument_opt_ = argument_opt; | 116 argument_opt_ = argument_opt; |
| 117 is_reference_error_ = is_reference_error; |
114 } | 118 } |
115 | 119 |
116 bool has_error() { return has_error_; } | 120 bool has_error() const { return has_error_; } |
117 | 121 |
118 int start() { return start_; } | 122 int start() const { return start_; } |
119 int end() { return end_; } | 123 int end() const { return end_; } |
120 int literals() { | 124 int literals() const { |
121 ASSERT(!has_error_); | 125 ASSERT(!has_error_); |
122 return literals_; | 126 return literals_; |
123 } | 127 } |
124 int properties() { | 128 int properties() const { |
125 ASSERT(!has_error_); | 129 ASSERT(!has_error_); |
126 return properties_; | 130 return properties_; |
127 } | 131 } |
128 StrictMode strict_mode() { | 132 StrictMode strict_mode() const { |
129 ASSERT(!has_error_); | 133 ASSERT(!has_error_); |
130 return strict_mode_; | 134 return strict_mode_; |
131 } | 135 } |
| 136 int is_reference_error() const { return is_reference_error_; } |
132 const char* message() { | 137 const char* message() { |
133 ASSERT(has_error_); | 138 ASSERT(has_error_); |
134 return message_; | 139 return message_; |
135 } | 140 } |
136 const char* argument_opt() { | 141 const char* argument_opt() const { |
137 ASSERT(has_error_); | 142 ASSERT(has_error_); |
138 return argument_opt_; | 143 return argument_opt_; |
139 } | 144 } |
140 | 145 |
141 private: | 146 private: |
142 bool has_error_; | 147 bool has_error_; |
143 int start_; | 148 int start_; |
144 int end_; | 149 int end_; |
145 // For function entries. | 150 // For function entries. |
146 int literals_; | 151 int literals_; |
147 int properties_; | 152 int properties_; |
148 StrictMode strict_mode_; | 153 StrictMode strict_mode_; |
149 // For error messages. | 154 // For error messages. |
150 const char* message_; | 155 const char* message_; |
151 const char* argument_opt_; | 156 const char* argument_opt_; |
| 157 bool is_reference_error_; |
152 }; | 158 }; |
153 | 159 |
154 | 160 |
155 class CompleteParserRecorder : public ParserRecorder { | 161 class CompleteParserRecorder : public ParserRecorder { |
156 public: | 162 public: |
157 struct Key { | 163 struct Key { |
158 bool is_one_byte; | 164 bool is_one_byte; |
159 Vector<const byte> literal_bytes; | 165 Vector<const byte> literal_bytes; |
160 }; | 166 }; |
161 | 167 |
(...skipping 11 matching lines...) Expand all Loading... |
173 function_store_.Add(properties); | 179 function_store_.Add(properties); |
174 function_store_.Add(strict_mode); | 180 function_store_.Add(strict_mode); |
175 } | 181 } |
176 | 182 |
177 // Logs an error message and marks the log as containing an error. | 183 // Logs an error message and marks the log as containing an error. |
178 // Further logging will be ignored, and ExtractData will return a vector | 184 // Further logging will be ignored, and ExtractData will return a vector |
179 // representing the error only. | 185 // representing the error only. |
180 virtual void LogMessage(int start, | 186 virtual void LogMessage(int start, |
181 int end, | 187 int end, |
182 const char* message, | 188 const char* message, |
183 const char* argument_opt); | 189 const char* argument_opt, |
| 190 bool is_reference_error_); |
184 | 191 |
185 virtual void PauseRecording() { | 192 virtual void PauseRecording() { |
186 ASSERT(should_log_symbols_); | 193 ASSERT(should_log_symbols_); |
187 should_log_symbols_ = false; | 194 should_log_symbols_ = false; |
188 } | 195 } |
189 | 196 |
190 virtual void ResumeRecording() { | 197 virtual void ResumeRecording() { |
191 ASSERT(!should_log_symbols_); | 198 ASSERT(!should_log_symbols_); |
192 should_log_symbols_ = !has_error(); | 199 should_log_symbols_ = !has_error(); |
193 } | 200 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 Collector<byte> symbol_store_; | 232 Collector<byte> symbol_store_; |
226 Collector<Key> symbol_keys_; | 233 Collector<Key> symbol_keys_; |
227 HashMap string_table_; | 234 HashMap string_table_; |
228 int symbol_id_; | 235 int symbol_id_; |
229 }; | 236 }; |
230 | 237 |
231 | 238 |
232 } } // namespace v8::internal. | 239 } } // namespace v8::internal. |
233 | 240 |
234 #endif // V8_PREPARSE_DATA_H_ | 241 #endif // V8_PREPARSE_DATA_H_ |
OLD | NEW |