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

Side by Side Diff: src/lexer/lexer-shell.cc

Issue 67643005: Remove ascii encoding from lexer-shell, latin1 should be used instead. (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "scopeinfo.h" 43 #include "scopeinfo.h"
44 #include "string-stream.h" 44 #include "string-stream.h"
45 #include "scanner.h" 45 #include "scanner.h"
46 46
47 #include "experimental-scanner.h" 47 #include "experimental-scanner.h"
48 #include "lexer.h" 48 #include "lexer.h"
49 49
50 using namespace v8::internal; 50 using namespace v8::internal;
51 51
52 enum Encoding { 52 enum Encoding {
53 ASCII,
54 LATIN1, 53 LATIN1,
55 UTF8, 54 UTF8,
56 UTF16 55 UTF16
57 }; 56 };
58 57
59 58
60 const byte* ReadFile(const char* name, Isolate* isolate, int* size) { 59 const byte* ReadFile(const char* name, Isolate* isolate, int* size) {
61 FILE* file = fopen(name, "rb"); 60 FILE* file = fopen(name, "rb");
62 *size = 0; 61 *size = 0;
63 if (file == NULL) return NULL; 62 if (file == NULL) return NULL;
(...skipping 17 matching lines...) Expand all
81 BaselineScanner(const char* fname, 80 BaselineScanner(const char* fname,
82 Isolate* isolate, 81 Isolate* isolate,
83 Encoding encoding, 82 Encoding encoding,
84 ElapsedTimer* timer) 83 ElapsedTimer* timer)
85 : stream_(NULL) { 84 : stream_(NULL) {
86 int length = 0; 85 int length = 0;
87 source_ = ReadFile(fname, isolate, &length); 86 source_ = ReadFile(fname, isolate, &length);
88 unicode_cache_ = new UnicodeCache(); 87 unicode_cache_ = new UnicodeCache();
89 scanner_ = new Scanner(unicode_cache_); 88 scanner_ = new Scanner(unicode_cache_);
90 switch (encoding) { 89 switch (encoding) {
91 case ASCII:
92 case UTF8: 90 case UTF8:
93 stream_ = new Utf8ToUtf16CharacterStream(source_, length); 91 stream_ = new Utf8ToUtf16CharacterStream(source_, length);
94 break; 92 break;
95 case UTF16: { 93 case UTF16: {
96 Handle<String> result = isolate->factory()->NewStringFromTwoByte( 94 Handle<String> result = isolate->factory()->NewStringFromTwoByte(
97 Vector<const uint16_t>( 95 Vector<const uint16_t>(
98 reinterpret_cast<const uint16_t*>(source_), 96 reinterpret_cast<const uint16_t*>(source_),
99 length / 2)); 97 length / 2));
100 stream_ = 98 stream_ =
101 new GenericStringUtf16CharacterStream(result, 0, result->length()); 99 new GenericStringUtf16CharacterStream(result, 0, result->length());
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 bool check_tokens = true; 267 bool check_tokens = true;
270 std::vector<std::string> fnames; 268 std::vector<std::string> fnames;
271 std::string benchmark; 269 std::string benchmark;
272 for (int i = 0; i < argc; ++i) { 270 for (int i = 0; i < argc; ++i) {
273 if (strcmp(argv[i], "--latin1") == 0) { 271 if (strcmp(argv[i], "--latin1") == 0) {
274 encoding = LATIN1; 272 encoding = LATIN1;
275 } else if (strcmp(argv[i], "--utf8") == 0) { 273 } else if (strcmp(argv[i], "--utf8") == 0) {
276 encoding = UTF8; 274 encoding = UTF8;
277 } else if (strcmp(argv[i], "--utf16") == 0) { 275 } else if (strcmp(argv[i], "--utf16") == 0) {
278 encoding = UTF16; 276 encoding = UTF16;
279 } else if (strcmp(argv[i], "--ascii") == 0) {
280 encoding = ASCII;
281 } else if (strcmp(argv[i], "--print-tokens") == 0) { 277 } else if (strcmp(argv[i], "--print-tokens") == 0) {
282 print_tokens = true; 278 print_tokens = true;
283 } else if (strcmp(argv[i], "--no-baseline") == 0) { 279 } else if (strcmp(argv[i], "--no-baseline") == 0) {
284 run_baseline = false; 280 run_baseline = false;
285 } else if (strcmp(argv[i], "--no-experimental") == 0) { 281 } else if (strcmp(argv[i], "--no-experimental") == 0) {
286 run_experimental = false; 282 run_experimental = false;
287 } else if (strcmp(argv[i], "--no-check") == 0) { 283 } else if (strcmp(argv[i], "--no-check") == 0) {
288 check_tokens = false; 284 check_tokens = false;
289 } else if (strncmp(argv[i], "--benchmark=", 12) == 0) { 285 } else if (strncmp(argv[i], "--benchmark=", 12) == 0) {
290 benchmark = std::string(argv[i]).substr(12); 286 benchmark = std::string(argv[i]).substr(12);
(...skipping 26 matching lines...) Expand all
317 if (run_experimental) { 313 if (run_experimental) {
318 if (benchmark.empty()) benchmark = "Experimental"; 314 if (benchmark.empty()) benchmark = "Experimental";
319 printf("%s(RunTime): %.f ms\n", benchmark.c_str(), 315 printf("%s(RunTime): %.f ms\n", benchmark.c_str(),
320 experimental_total); 316 experimental_total);
321 } 317 }
322 } 318 }
323 } 319 }
324 v8::V8::Dispose(); 320 v8::V8::Dispose();
325 return 0; 321 return 0;
326 } 322 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698