| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 FILE* file = fopen(name, "rb"); | 44 FILE* file = fopen(name, "rb"); |
| 45 *size = 0; | 45 *size = 0; |
| 46 if (file == NULL) return NULL; | 46 if (file == NULL) return NULL; |
| 47 | 47 |
| 48 fseek(file, 0, SEEK_END); | 48 fseek(file, 0, SEEK_END); |
| 49 int file_size = ftell(file); | 49 int file_size = ftell(file); |
| 50 rewind(file); | 50 rewind(file); |
| 51 | 51 |
| 52 *size = file_size * repeat; | 52 *size = file_size * repeat; |
| 53 | 53 |
| 54 byte* chars = new byte[*size + 1]; | 54 byte* chars = new byte[*size]; |
| 55 for (int i = 0; i < file_size;) { | 55 for (int i = 0; i < file_size;) { |
| 56 int read = static_cast<int>(fread(&chars[i], 1, file_size - i, file)); | 56 int read = static_cast<int>(fread(&chars[i], 1, file_size - i, file)); |
| 57 i += read; | 57 i += read; |
| 58 } | 58 } |
| 59 fclose(file); | 59 fclose(file); |
| 60 | 60 |
| 61 for (int i = file_size; i < *size; i++) { | 61 for (int i = file_size; i < *size; i++) { |
| 62 chars[i] = chars[i - file_size]; | 62 chars[i] = chars[i - file_size]; |
| 63 } | 63 } |
| 64 chars[*size] = 0; | |
| 65 | 64 |
| 66 return chars; | 65 return chars; |
| 67 } | 66 } |
| 68 | 67 |
| 69 | 68 |
| 70 ExperimentalScanner::ExperimentalScanner(const char* fname, | 69 ExperimentalScanner::ExperimentalScanner(const char* fname, |
| 71 bool read_all_at_once, | 70 bool read_all_at_once, |
| 72 Isolate* isolate, | 71 Isolate* isolate, |
| 73 int repeat) | 72 int repeat) |
| 74 : current_(0), | 73 : current_(0), |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 if (fetched_ >= token_.size()) { | 135 if (fetched_ >= token_.size()) { |
| 137 token_.resize(token_.size() * 2); | 136 token_.resize(token_.size() * 2); |
| 138 } | 137 } |
| 139 token_[fetched_].value = token; | 138 token_[fetched_].value = token; |
| 140 token_[fetched_].beg = beg; | 139 token_[fetched_].beg = beg; |
| 141 token_[fetched_].end = end; | 140 token_[fetched_].end = end; |
| 142 fetched_++; | 141 fetched_++; |
| 143 } | 142 } |
| 144 | 143 |
| 145 } } // namespace v8::internal | 144 } } // namespace v8::internal |
| OLD | NEW |