Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(642)

Unified Diff: src/lexer/experimental-scanner.cc

Issue 71373004: Add a flag to lexer-shell to replicate input file. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/lexer/experimental-scanner.h ('k') | src/lexer/lexer-shell.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/lexer/experimental-scanner.cc
diff --git a/src/lexer/experimental-scanner.cc b/src/lexer/experimental-scanner.cc
index d52b7793456f24c2668df2e36364b9086f92813d..968fd173673c53cb69dfb63f06c20c0868a87a76 100644
--- a/src/lexer/experimental-scanner.cc
+++ b/src/lexer/experimental-scanner.cc
@@ -39,47 +39,54 @@
namespace v8 {
namespace internal {
-namespace {
-// Will go away.
-const byte* ReadFile(const char* name, Isolate* isolate, int* size) {
+const byte* ReadFile(const char* name, Isolate* isolate,
+ int* size, int repeat) {
FILE* file = fopen(name, "rb");
*size = 0;
if (file == NULL) return NULL;
fseek(file, 0, SEEK_END);
- *size = ftell(file);
+ int file_size = ftell(file);
rewind(file);
+ *size = file_size * repeat;
+
byte* chars = new byte[*size + 1];
- chars[*size] = 0;
- for (int i = 0; i < *size;) {
- int read = static_cast<int>(fread(&chars[i], 1, *size - i, file));
+ for (int i = 0; i < file_size;) {
+ int read = static_cast<int>(fread(&chars[i], 1, file_size - i, file));
i += read;
}
fclose(file);
+
+ for (int i = file_size; i < *size; i++) {
+ chars[i] = chars[i - file_size];
+ }
+ chars[*size] = 0;
+
return chars;
}
-}
ExperimentalScanner::ExperimentalScanner(const char* fname,
bool read_all_at_once,
- Isolate* isolate)
+ Isolate* isolate,
+ int repeat)
: current_(0),
fetched_(0),
read_all_at_once_(read_all_at_once),
already_pushed_(false),
source_(0),
length_(0) {
+ CHECK(repeat == 1 || read_all_at_once);
file_ = fopen(fname, "rb");
// python generated version
scanner_ = new EvenMoreExperimentalScanner(this, isolate->unicode_cache());
// re2c version
// scanner_ = new PushScanner(this, isolate->unicode_cache());
if (read_all_at_once_) {
- source_ = ReadFile(fname, isolate, &length_);
- token_.resize(1500);
+ source_ = ReadFile(fname, isolate, &length_, repeat);
+ token_.resize(length_);
} else {
token_.resize(BUFFER_SIZE);
}
« no previous file with comments | « src/lexer/experimental-scanner.h ('k') | src/lexer/lexer-shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698