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

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

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

Powered by Google App Engine
This is Rietveld 408576698