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

Unified Diff: tools/lexer-shell.cc

Issue 209353008: Add parser-shell. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased Created 6 years, 9 months 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 | « build/all.gyp ('k') | tools/lexer-shell.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/lexer-shell.cc
diff --git a/tools/lexer-shell.cc b/tools/lexer-shell.cc
index 0610e7f70d22887114047fe32514c6038a22672e..8c7debcab8b1554fa6026cd8d7d283b213e87016 100644
--- a/tools/lexer-shell.cc
+++ b/tools/lexer-shell.cc
@@ -26,7 +26,6 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assert.h>
-#include <fcntl.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
@@ -35,53 +34,18 @@
#include "v8.h"
#include "api.h"
-#include "ast.h"
-#include "char-predicates-inl.h"
#include "messages.h"
#include "platform.h"
#include "runtime.h"
#include "scanner-character-streams.h"
#include "scopeinfo.h"
+#include "shell-utils.h"
#include "string-stream.h"
#include "scanner.h"
using namespace v8::internal;
-enum Encoding {
- LATIN1,
- UTF8,
- UTF16
-};
-
-
-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);
- int file_size = ftell(file);
- rewind(file);
-
- *size = file_size * repeat;
-
- byte* chars = new byte[*size + 1];
- 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;
-}
-
class BaselineScanner {
public:
@@ -92,7 +56,7 @@ class BaselineScanner {
int repeat)
: stream_(NULL) {
int length = 0;
- source_ = ReadFile(fname, isolate, &length, repeat);
+ source_ = ReadFileAndRepeat(fname, &length, repeat);
unicode_cache_ = new UnicodeCache();
scanner_ = new Scanner(unicode_cache_);
switch (encoding) {
« no previous file with comments | « build/all.gyp ('k') | tools/lexer-shell.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698