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

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

Issue 949763003: WIP: new.target (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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 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"
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, int end, int literals, int properties, 26 virtual void LogFunction(int start, int end, int literals, int properties,
27 LanguageMode language_mode, 27 LanguageMode language_mode,
28 bool uses_super_property) = 0; 28 bool scope_uses_super_property,
29 bool scope_uses_new_target) = 0;
29 30
30 // Logs an error message and marks the log as containing an error. 31 // Logs an error message and marks the log as containing an error.
31 // Further logging will be ignored, and ExtractData will return a vector 32 // Further logging will be ignored, and ExtractData will return a vector
32 // representing the error only. 33 // representing the error only.
33 virtual void LogMessage(int start, int end, const char* message, 34 virtual void LogMessage(int start, int end, const char* message,
34 const char* argument_opt, 35 const char* argument_opt,
35 ParseErrorType error_type) = 0; 36 ParseErrorType error_type) = 0;
36 37
37 private: 38 private:
38 DISALLOW_COPY_AND_ASSIGN(ParserRecorder); 39 DISALLOW_COPY_AND_ASSIGN(ParserRecorder);
39 }; 40 };
40 41
41 42
42 class SingletonLogger : public ParserRecorder { 43 class SingletonLogger : public ParserRecorder {
43 public: 44 public:
44 SingletonLogger() 45 SingletonLogger()
45 : has_error_(false), start_(-1), end_(-1), error_type_(kSyntaxError) {} 46 : has_error_(false), start_(-1), end_(-1), error_type_(kSyntaxError) {}
46 virtual ~SingletonLogger() {} 47 virtual ~SingletonLogger() {}
47 48
48 void Reset() { has_error_ = false; } 49 void Reset() { has_error_ = false; }
49 50
50 virtual void LogFunction(int start, int end, int literals, int properties, 51 virtual void LogFunction(int start, int end, int literals, int properties,
51 LanguageMode language_mode, 52 LanguageMode language_mode,
52 bool scope_uses_super_property) { 53 bool scope_uses_super_property,
54 bool scope_uses_new_target) {
53 DCHECK(!has_error_); 55 DCHECK(!has_error_);
54 start_ = start; 56 start_ = start;
55 end_ = end; 57 end_ = end;
56 literals_ = literals; 58 literals_ = literals;
57 properties_ = properties; 59 properties_ = properties;
58 language_mode_ = language_mode; 60 language_mode_ = language_mode;
59 scope_uses_super_property_ = scope_uses_super_property; 61 scope_uses_super_property_ = scope_uses_super_property;
62 scope_uses_new_target_ = scope_uses_new_target;
60 } 63 }
61 64
62 // Logs an error message and marks the log as containing an error. 65 // Logs an error message and marks the log as containing an error.
63 // Further logging will be ignored, and ExtractData will return a vector 66 // Further logging will be ignored, and ExtractData will return a vector
64 // representing the error only. 67 // representing the error only.
65 virtual void LogMessage(int start, int end, const char* message, 68 virtual void LogMessage(int start, int end, const char* message,
66 const char* argument_opt, ParseErrorType error_type) { 69 const char* argument_opt, ParseErrorType error_type) {
67 if (has_error_) return; 70 if (has_error_) return;
68 has_error_ = true; 71 has_error_ = true;
69 start_ = start; 72 start_ = start;
(...skipping 16 matching lines...) Expand all
86 return properties_; 89 return properties_;
87 } 90 }
88 LanguageMode language_mode() const { 91 LanguageMode language_mode() const {
89 DCHECK(!has_error_); 92 DCHECK(!has_error_);
90 return language_mode_; 93 return language_mode_;
91 } 94 }
92 bool scope_uses_super_property() const { 95 bool scope_uses_super_property() const {
93 DCHECK(!has_error_); 96 DCHECK(!has_error_);
94 return scope_uses_super_property_; 97 return scope_uses_super_property_;
95 } 98 }
99 bool scope_uses_new_target() const {
100 DCHECK(!has_error_);
101 return scope_uses_new_target_;
102 }
96 ParseErrorType error_type() const { 103 ParseErrorType error_type() const {
97 DCHECK(has_error_); 104 DCHECK(has_error_);
98 return error_type_; 105 return error_type_;
99 } 106 }
100 const char* message() { 107 const char* message() {
101 DCHECK(has_error_); 108 DCHECK(has_error_);
102 return message_; 109 return message_;
103 } 110 }
104 const char* argument_opt() const { 111 const char* argument_opt() const {
105 DCHECK(has_error_); 112 DCHECK(has_error_);
106 return argument_opt_; 113 return argument_opt_;
107 } 114 }
108 115
109 private: 116 private:
110 bool has_error_; 117 bool has_error_;
111 int start_; 118 int start_;
112 int end_; 119 int end_;
113 // For function entries. 120 // For function entries.
114 int literals_; 121 int literals_;
115 int properties_; 122 int properties_;
116 LanguageMode language_mode_; 123 LanguageMode language_mode_;
117 bool scope_uses_super_property_; 124 bool scope_uses_super_property_;
125 bool scope_uses_new_target_;
118 // For error messages. 126 // For error messages.
119 const char* message_; 127 const char* message_;
120 const char* argument_opt_; 128 const char* argument_opt_;
121 ParseErrorType error_type_; 129 ParseErrorType error_type_;
122 }; 130 };
123 131
124 132
125 class CompleteParserRecorder : public ParserRecorder { 133 class CompleteParserRecorder : public ParserRecorder {
126 public: 134 public:
127 struct Key { 135 struct Key {
128 bool is_one_byte; 136 bool is_one_byte;
129 Vector<const byte> literal_bytes; 137 Vector<const byte> literal_bytes;
130 }; 138 };
131 139
132 CompleteParserRecorder(); 140 CompleteParserRecorder();
133 virtual ~CompleteParserRecorder() {} 141 virtual ~CompleteParserRecorder() {}
134 142
135 virtual void LogFunction(int start, int end, int literals, int properties, 143 virtual void LogFunction(int start, int end, int literals, int properties,
136 LanguageMode language_mode, 144 LanguageMode language_mode,
137 bool scope_uses_super_property) { 145 bool scope_uses_super_property,
146 bool scope_uses_new_target) {
138 function_store_.Add(start); 147 function_store_.Add(start);
139 function_store_.Add(end); 148 function_store_.Add(end);
140 function_store_.Add(literals); 149 function_store_.Add(literals);
141 function_store_.Add(properties); 150 function_store_.Add(properties);
142 function_store_.Add(language_mode); 151 function_store_.Add(language_mode);
143 function_store_.Add(scope_uses_super_property); 152 function_store_.Add(scope_uses_super_property);
153 function_store_.Add(scope_uses_new_target);
144 } 154 }
145 155
146 // Logs an error message and marks the log as containing an error. 156 // Logs an error message and marks the log as containing an error.
147 // Further logging will be ignored, and ExtractData will return a vector 157 // Further logging will be ignored, and ExtractData will return a vector
148 // representing the error only. 158 // representing the error only.
149 virtual void LogMessage(int start, int end, const char* message, 159 virtual void LogMessage(int start, int end, const char* message,
150 const char* argument_opt, ParseErrorType error_type); 160 const char* argument_opt, ParseErrorType error_type);
151 ScriptData* GetScriptData(); 161 ScriptData* GetScriptData();
152 162
153 bool HasError() { 163 bool HasError() {
(...skipping 15 matching lines...) Expand all
169 179
170 #ifdef DEBUG 180 #ifdef DEBUG
171 int prev_start_; 181 int prev_start_;
172 #endif 182 #endif
173 }; 183 };
174 184
175 185
176 } } // namespace v8::internal. 186 } } // namespace v8::internal.
177 187
178 #endif // V8_PREPARSE_DATA_H_ 188 #endif // V8_PREPARSE_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698