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

Side by Side Diff: src/preparse-data.h

Issue 894683003: Introduce LanguageMode, drop StrictMode. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebased (w/ conflicts) Created 5 years, 10 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 unified diff | Download patch
« no previous file with comments | « src/parser.cc ('k') | src/preparser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_PREPARSE_DATA_H_ 5 #ifndef V8_PREPARSE_DATA_H_
6 #define V8_PREPARSE_DATA_H_ 6 #define V8_PREPARSE_DATA_H_
7 7
8 #include "src/allocation.h" 8 #include "src/allocation.h"
9 #include "src/hashmap.h" 9 #include "src/hashmap.h"
10 #include "src/preparse-data-format.h" 10 #include "src/preparse-data-format.h"
11 #include "src/utils-inl.h" 11 #include "src/utils-inl.h"
12 12
13 namespace v8 { 13 namespace v8 {
14 namespace internal { 14 namespace internal {
15 15
16 class ScriptData; 16 class ScriptData;
17 17
18 18
19 // Abstract interface for preparse data recorder. 19 // Abstract interface for preparse data recorder.
20 class ParserRecorder { 20 class ParserRecorder {
21 public: 21 public:
22 ParserRecorder() { } 22 ParserRecorder() { }
23 virtual ~ParserRecorder() { } 23 virtual ~ParserRecorder() { }
24 24
25 // Logs the scope and some details of a function literal in the source. 25 // Logs the scope and some details of a function literal in the source.
26 virtual void LogFunction(int start, 26 virtual void LogFunction(int start, int end, int literals, int properties,
27 int end, 27 LanguageMode language_mode) = 0;
28 int literals,
29 int properties,
30 StrictMode strict_mode) = 0;
31 28
32 // Logs an error message and marks the log as containing an error. 29 // Logs an error message and marks the log as containing an error.
33 // Further logging will be ignored, and ExtractData will return a vector 30 // Further logging will be ignored, and ExtractData will return a vector
34 // representing the error only. 31 // representing the error only.
35 virtual void LogMessage(int start, 32 virtual void LogMessage(int start,
36 int end, 33 int end,
37 const char* message, 34 const char* message,
38 const char* argument_opt, 35 const char* argument_opt,
39 bool is_reference_error) = 0; 36 bool is_reference_error) = 0;
40 private: 37 private:
41 DISALLOW_COPY_AND_ASSIGN(ParserRecorder); 38 DISALLOW_COPY_AND_ASSIGN(ParserRecorder);
42 }; 39 };
43 40
44 41
45 class SingletonLogger : public ParserRecorder { 42 class SingletonLogger : public ParserRecorder {
46 public: 43 public:
47 SingletonLogger() 44 SingletonLogger()
48 : has_error_(false), start_(-1), end_(-1), is_reference_error_(false) {} 45 : has_error_(false), start_(-1), end_(-1), is_reference_error_(false) {}
49 virtual ~SingletonLogger() {} 46 virtual ~SingletonLogger() {}
50 47
51 void Reset() { has_error_ = false; } 48 void Reset() { has_error_ = false; }
52 49
53 virtual void LogFunction(int start, 50 virtual void LogFunction(int start, int end, int literals, int properties,
54 int end, 51 LanguageMode language_mode) {
55 int literals,
56 int properties,
57 StrictMode strict_mode) {
58 DCHECK(!has_error_); 52 DCHECK(!has_error_);
59 start_ = start; 53 start_ = start;
60 end_ = end; 54 end_ = end;
61 literals_ = literals; 55 literals_ = literals;
62 properties_ = properties; 56 properties_ = properties;
63 strict_mode_ = strict_mode; 57 language_mode_ = language_mode;
64 } 58 }
65 59
66 // Logs an error message and marks the log as containing an error. 60 // Logs an error message and marks the log as containing an error.
67 // Further logging will be ignored, and ExtractData will return a vector 61 // Further logging will be ignored, and ExtractData will return a vector
68 // representing the error only. 62 // representing the error only.
69 virtual void LogMessage(int start, 63 virtual void LogMessage(int start,
70 int end, 64 int end,
71 const char* message, 65 const char* message,
72 const char* argument_opt, 66 const char* argument_opt,
73 bool is_reference_error) { 67 bool is_reference_error) {
(...skipping 11 matching lines...) Expand all
85 int start() const { return start_; } 79 int start() const { return start_; }
86 int end() const { return end_; } 80 int end() const { return end_; }
87 int literals() const { 81 int literals() const {
88 DCHECK(!has_error_); 82 DCHECK(!has_error_);
89 return literals_; 83 return literals_;
90 } 84 }
91 int properties() const { 85 int properties() const {
92 DCHECK(!has_error_); 86 DCHECK(!has_error_);
93 return properties_; 87 return properties_;
94 } 88 }
95 StrictMode strict_mode() const { 89 LanguageMode language_mode() const {
96 DCHECK(!has_error_); 90 DCHECK(!has_error_);
97 return strict_mode_; 91 return language_mode_;
98 } 92 }
99 int is_reference_error() const { return is_reference_error_; } 93 int is_reference_error() const { return is_reference_error_; }
100 const char* message() { 94 const char* message() {
101 DCHECK(has_error_); 95 DCHECK(has_error_);
102 return message_; 96 return message_;
103 } 97 }
104 const char* argument_opt() const { 98 const char* argument_opt() const {
105 DCHECK(has_error_); 99 DCHECK(has_error_);
106 return argument_opt_; 100 return argument_opt_;
107 } 101 }
108 102
109 private: 103 private:
110 bool has_error_; 104 bool has_error_;
111 int start_; 105 int start_;
112 int end_; 106 int end_;
113 // For function entries. 107 // For function entries.
114 int literals_; 108 int literals_;
115 int properties_; 109 int properties_;
116 StrictMode strict_mode_; 110 LanguageMode language_mode_;
117 // For error messages. 111 // For error messages.
118 const char* message_; 112 const char* message_;
119 const char* argument_opt_; 113 const char* argument_opt_;
120 bool is_reference_error_; 114 bool is_reference_error_;
121 }; 115 };
122 116
123 117
124 class CompleteParserRecorder : public ParserRecorder { 118 class CompleteParserRecorder : public ParserRecorder {
125 public: 119 public:
126 struct Key { 120 struct Key {
127 bool is_one_byte; 121 bool is_one_byte;
128 Vector<const byte> literal_bytes; 122 Vector<const byte> literal_bytes;
129 }; 123 };
130 124
131 CompleteParserRecorder(); 125 CompleteParserRecorder();
132 virtual ~CompleteParserRecorder() {} 126 virtual ~CompleteParserRecorder() {}
133 127
134 virtual void LogFunction(int start, 128 virtual void LogFunction(int start, int end, int literals, int properties,
135 int end, 129 LanguageMode language_mode) {
136 int literals,
137 int properties,
138 StrictMode strict_mode) {
139 function_store_.Add(start); 130 function_store_.Add(start);
140 function_store_.Add(end); 131 function_store_.Add(end);
141 function_store_.Add(literals); 132 function_store_.Add(literals);
142 function_store_.Add(properties); 133 function_store_.Add(properties);
143 function_store_.Add(strict_mode); 134 function_store_.Add(language_mode);
144 } 135 }
145 136
146 // Logs an error message and marks the log as containing an error. 137 // Logs an error message and marks the log as containing an error.
147 // Further logging will be ignored, and ExtractData will return a vector 138 // Further logging will be ignored, and ExtractData will return a vector
148 // representing the error only. 139 // representing the error only.
149 virtual void LogMessage(int start, 140 virtual void LogMessage(int start,
150 int end, 141 int end,
151 const char* message, 142 const char* message,
152 const char* argument_opt, 143 const char* argument_opt,
153 bool is_reference_error_); 144 bool is_reference_error_);
(...skipping 18 matching lines...) Expand all
172 163
173 #ifdef DEBUG 164 #ifdef DEBUG
174 int prev_start_; 165 int prev_start_;
175 #endif 166 #endif
176 }; 167 };
177 168
178 169
179 } } // namespace v8::internal. 170 } } // namespace v8::internal.
180 171
181 #endif // V8_PREPARSE_DATA_H_ 172 #endif // V8_PREPARSE_DATA_H_
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | src/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698