OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 |
11 // with the distribution. | 11 // with the distribution. |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 | 195 |
196 | 196 |
197 void fail(v8::PreParserData* data, const char* message, ...) { | 197 void fail(v8::PreParserData* data, const char* message, ...) { |
198 va_list args; | 198 va_list args; |
199 va_start(args, message); | 199 va_start(args, message); |
200 vfprintf(stderr, message, args); | 200 vfprintf(stderr, message, args); |
201 va_end(args); | 201 va_end(args); |
202 fflush(stderr); | 202 fflush(stderr); |
203 if (data != NULL) { | 203 if (data != NULL) { |
204 // Print preparser data to stdout. | 204 // Print preparser data to stdout. |
205 uint32_t size = data->size(); | 205 uint32_t size = static_cast<uint32_t>(data->size()); |
206 fprintf(stderr, "LOG: data size: %u\n", size); | 206 fprintf(stderr, "LOG: data size: %u\n", size); |
207 if (!WriteBuffer(stdout, data->data(), size)) { | 207 if (!WriteBuffer(stdout, data->data(), size)) { |
208 perror("ERROR: Writing data"); | 208 perror("ERROR: Writing data"); |
209 fflush(stderr); | 209 fflush(stderr); |
210 } | 210 } |
211 } | 211 } |
212 exit(EXIT_FAILURE); | 212 exit(EXIT_FAILURE); |
213 } | 213 } |
214 | 214 |
215 | 215 |
216 bool IsFlag(const char* arg) { | 216 bool IsFlag(const char* arg) { |
217 // Anything starting with '-' is considered a flag. | 217 // Anything starting with '-' is considered a flag. |
218 // It's summarily ignored for now. | 218 // It's summarily ignored for now. |
219 return arg[0] == '-'; | 219 return arg[0] == '-'; |
220 } | 220 } |
221 | 221 |
222 | 222 |
223 struct ExceptionExpectation { | 223 struct ExceptionExpectation { |
224 ExceptionExpectation() | 224 ExceptionExpectation() |
225 : throws(false), type(NULL), beg_pos(-1), end_pos(-1) { } | 225 : throws(false), type(NULL), beg_pos(-1), end_pos(-1) { } |
226 bool throws; | 226 bool throws; |
227 const char* type; | 227 const char* type; |
228 int beg_pos; | 228 int beg_pos; |
229 int end_pos; | 229 int end_pos; |
230 }; | 230 }; |
231 | 231 |
232 | 232 |
233 void CheckException(v8::PreParserData* data, | 233 void CheckException(v8::PreParserData* data, |
234 ExceptionExpectation* expects) { | 234 ExceptionExpectation* expects) { |
235 PreparseDataInterpreter reader(data->data(), data->size()); | 235 PreparseDataInterpreter reader(data->data(), static_cast<int>(data->size())); |
236 if (expects->throws) { | 236 if (expects->throws) { |
237 if (!reader.throws()) { | 237 if (!reader.throws()) { |
238 if (expects->type == NULL) { | 238 if (expects->type == NULL) { |
239 fail(data, "Didn't throw as expected\n"); | 239 fail(data, "Didn't throw as expected\n"); |
240 } else { | 240 } else { |
241 fail(data, "Didn't throw \"%s\" as expected\n", expects->type); | 241 fail(data, "Didn't throw \"%s\" as expected\n", expects->type); |
242 } | 242 } |
243 } | 243 } |
244 if (expects->type != NULL) { | 244 if (expects->type != NULL) { |
245 const char* actual_message = reader.message(); | 245 const char* actual_message = reader.message(); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 if (data.stack_overflow()) { | 361 if (data.stack_overflow()) { |
362 fail(&data, "ERROR: Stack overflow\n"); | 362 fail(&data, "ERROR: Stack overflow\n"); |
363 } | 363 } |
364 | 364 |
365 // Check that the expected exception is thrown, if an exception is | 365 // Check that the expected exception is thrown, if an exception is |
366 // expected. | 366 // expected. |
367 CheckException(&data, &expects); | 367 CheckException(&data, &expects); |
368 | 368 |
369 return EXIT_SUCCESS; | 369 return EXIT_SUCCESS; |
370 } | 370 } |
OLD | NEW |