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

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

Issue 1083193005: WIP: new.target (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 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
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"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 // Abstract interface for preparse data recorder. 47 // Abstract interface for preparse data recorder.
48 class ParserRecorder { 48 class ParserRecorder {
49 public: 49 public:
50 ParserRecorder() { } 50 ParserRecorder() { }
51 virtual ~ParserRecorder() { } 51 virtual ~ParserRecorder() { }
52 52
53 // Logs the scope and some details of a function literal in the source. 53 // Logs the scope and some details of a function literal in the source.
54 virtual void LogFunction(int start, int end, int literals, int properties, 54 virtual void LogFunction(int start, int end, int literals, int properties,
55 LanguageMode language_mode, 55 LanguageMode language_mode,
56 bool uses_super_property) = 0; 56 bool scope_uses_super_property,
57 bool scope_uses_new_target) = 0;
57 58
58 // Logs an error message and marks the log as containing an error. 59 // Logs an error message and marks the log as containing an error.
59 // Further logging will be ignored, and ExtractData will return a vector 60 // Further logging will be ignored, and ExtractData will return a vector
60 // representing the error only. 61 // representing the error only.
61 virtual void LogMessage(int start, int end, const char* message, 62 virtual void LogMessage(int start, int end, const char* message,
62 const char* argument_opt, 63 const char* argument_opt,
63 ParseErrorType error_type) = 0; 64 ParseErrorType error_type) = 0;
64 65
65 private: 66 private:
66 DISALLOW_COPY_AND_ASSIGN(ParserRecorder); 67 DISALLOW_COPY_AND_ASSIGN(ParserRecorder);
67 }; 68 };
68 69
69 70
70 class SingletonLogger : public ParserRecorder { 71 class SingletonLogger : public ParserRecorder {
71 public: 72 public:
72 SingletonLogger() 73 SingletonLogger()
73 : has_error_(false), start_(-1), end_(-1), error_type_(kSyntaxError) {} 74 : has_error_(false), start_(-1), end_(-1), error_type_(kSyntaxError) {}
74 virtual ~SingletonLogger() {} 75 virtual ~SingletonLogger() {}
75 76
76 void Reset() { has_error_ = false; } 77 void Reset() { has_error_ = false; }
77 78
78 virtual void LogFunction(int start, int end, int literals, int properties, 79 virtual void LogFunction(int start, int end, int literals, int properties,
79 LanguageMode language_mode, 80 LanguageMode language_mode,
80 bool scope_uses_super_property) { 81 bool scope_uses_super_property,
82 bool scope_uses_new_target) {
81 DCHECK(!has_error_); 83 DCHECK(!has_error_);
82 start_ = start; 84 start_ = start;
83 end_ = end; 85 end_ = end;
84 literals_ = literals; 86 literals_ = literals;
85 properties_ = properties; 87 properties_ = properties;
86 language_mode_ = language_mode; 88 language_mode_ = language_mode;
87 scope_uses_super_property_ = scope_uses_super_property; 89 scope_uses_super_property_ = scope_uses_super_property;
90 scope_uses_new_target_ = scope_uses_new_target;
88 } 91 }
89 92
90 // Logs an error message and marks the log as containing an error. 93 // Logs an error message and marks the log as containing an error.
91 // Further logging will be ignored, and ExtractData will return a vector 94 // Further logging will be ignored, and ExtractData will return a vector
92 // representing the error only. 95 // representing the error only.
93 virtual void LogMessage(int start, int end, const char* message, 96 virtual void LogMessage(int start, int end, const char* message,
94 const char* argument_opt, ParseErrorType error_type) { 97 const char* argument_opt, ParseErrorType error_type) {
95 if (has_error_) return; 98 if (has_error_) return;
96 has_error_ = true; 99 has_error_ = true;
97 start_ = start; 100 start_ = start;
(...skipping 16 matching lines...) Expand all
114 return properties_; 117 return properties_;
115 } 118 }
116 LanguageMode language_mode() const { 119 LanguageMode language_mode() const {
117 DCHECK(!has_error_); 120 DCHECK(!has_error_);
118 return language_mode_; 121 return language_mode_;
119 } 122 }
120 bool scope_uses_super_property() const { 123 bool scope_uses_super_property() const {
121 DCHECK(!has_error_); 124 DCHECK(!has_error_);
122 return scope_uses_super_property_; 125 return scope_uses_super_property_;
123 } 126 }
127 bool scope_uses_new_target() const {
128 DCHECK(!has_error_);
129 return scope_uses_new_target_;
130 }
124 ParseErrorType error_type() const { 131 ParseErrorType error_type() const {
125 DCHECK(has_error_); 132 DCHECK(has_error_);
126 return error_type_; 133 return error_type_;
127 } 134 }
128 const char* message() { 135 const char* message() {
129 DCHECK(has_error_); 136 DCHECK(has_error_);
130 return message_; 137 return message_;
131 } 138 }
132 const char* argument_opt() const { 139 const char* argument_opt() const {
133 DCHECK(has_error_); 140 DCHECK(has_error_);
134 return argument_opt_; 141 return argument_opt_;
135 } 142 }
136 143
137 private: 144 private:
138 bool has_error_; 145 bool has_error_;
139 int start_; 146 int start_;
140 int end_; 147 int end_;
141 // For function entries. 148 // For function entries.
142 int literals_; 149 int literals_;
143 int properties_; 150 int properties_;
144 LanguageMode language_mode_; 151 LanguageMode language_mode_;
145 bool scope_uses_super_property_; 152 bool scope_uses_super_property_;
153 bool scope_uses_new_target_;
146 // For error messages. 154 // For error messages.
147 const char* message_; 155 const char* message_;
148 const char* argument_opt_; 156 const char* argument_opt_;
149 ParseErrorType error_type_; 157 ParseErrorType error_type_;
150 }; 158 };
151 159
152 160
153 class CompleteParserRecorder : public ParserRecorder { 161 class CompleteParserRecorder : public ParserRecorder {
154 public: 162 public:
155 struct Key { 163 struct Key {
156 bool is_one_byte; 164 bool is_one_byte;
157 Vector<const byte> literal_bytes; 165 Vector<const byte> literal_bytes;
158 }; 166 };
159 167
160 CompleteParserRecorder(); 168 CompleteParserRecorder();
161 virtual ~CompleteParserRecorder() {} 169 virtual ~CompleteParserRecorder() {}
162 170
163 virtual void LogFunction(int start, int end, int literals, int properties, 171 virtual void LogFunction(int start, int end, int literals, int properties,
164 LanguageMode language_mode, 172 LanguageMode language_mode,
165 bool scope_uses_super_property) { 173 bool scope_uses_super_property,
174 bool scope_uses_new_target) {
166 function_store_.Add(start); 175 function_store_.Add(start);
167 function_store_.Add(end); 176 function_store_.Add(end);
168 function_store_.Add(literals); 177 function_store_.Add(literals);
169 function_store_.Add(properties); 178 function_store_.Add(properties);
170 function_store_.Add(language_mode); 179 function_store_.Add(language_mode);
171 function_store_.Add(scope_uses_super_property); 180 function_store_.Add(scope_uses_super_property);
181 function_store_.Add(scope_uses_new_target);
172 } 182 }
173 183
174 // Logs an error message and marks the log as containing an error. 184 // Logs an error message and marks the log as containing an error.
175 // Further logging will be ignored, and ExtractData will return a vector 185 // Further logging will be ignored, and ExtractData will return a vector
176 // representing the error only. 186 // representing the error only.
177 virtual void LogMessage(int start, int end, const char* message, 187 virtual void LogMessage(int start, int end, const char* message,
178 const char* argument_opt, ParseErrorType error_type); 188 const char* argument_opt, ParseErrorType error_type);
179 ScriptData* GetScriptData(); 189 ScriptData* GetScriptData();
180 190
181 bool HasError() { 191 bool HasError() {
(...skipping 15 matching lines...) Expand all
197 207
198 #ifdef DEBUG 208 #ifdef DEBUG
199 int prev_start_; 209 int prev_start_;
200 #endif 210 #endif
201 }; 211 };
202 212
203 213
204 } } // namespace v8::internal. 214 } } // namespace v8::internal.
205 215
206 #endif // V8_PREPARSE_DATA_H_ 216 #endif // V8_PREPARSE_DATA_H_
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | src/preparse-data-format.h » ('j') | src/runtime/runtime-classes.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698