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

Unified Diff: src/parsing/preparse-data.h

Issue 2474393003: [parser] Give preparser and parser independent loggers (Closed)
Patch Set: Addressed comment Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parsing/parser-base.h ('k') | src/parsing/preparse-data.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/preparse-data.h
diff --git a/src/parsing/preparse-data.h b/src/parsing/preparse-data.h
index 42ab55cfeae058727cdda44a4d95c46d8e1fd0a6..364d123a0d01709cf37441c32fc98010327d30ca 100644
--- a/src/parsing/preparse-data.h
+++ b/src/parsing/preparse-data.h
@@ -46,34 +46,9 @@ class ScriptData {
DISALLOW_COPY_AND_ASSIGN(ScriptData);
};
-// Abstract interface for preparse data recorder.
-class ParserRecorder {
+class PreParserLogger final {
public:
- ParserRecorder() { }
- virtual ~ParserRecorder() { }
-
- // Logs the scope and some details of a function literal in the source.
- virtual void LogFunction(int start, int end, int num_parameters,
- int function_length, bool has_duplicate_parameters,
- int literals, int properties,
- LanguageMode language_mode, bool uses_super_property,
- bool calls_eval) = 0;
-
- // Logs an error message and marks the log as containing an error.
- // Further logging will be ignored, and ExtractData will return a vector
- // representing the error only.
- virtual void LogMessage(int start, int end, MessageTemplate::Template message,
- const char* argument_opt,
- ParseErrorType error_type) = 0;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ParserRecorder);
-};
-
-
-class SingletonLogger : public ParserRecorder {
- public:
- SingletonLogger()
+ PreParserLogger()
: has_error_(false),
start_(-1),
end_(-1),
@@ -81,35 +56,24 @@ class SingletonLogger : public ParserRecorder {
function_length_(-1),
has_duplicate_parameters_(false),
error_type_(kSyntaxError) {}
- virtual ~SingletonLogger() {}
-
- void Reset() { has_error_ = false; }
- virtual void LogFunction(int start, int end, int num_parameters,
- int function_length, bool has_duplicate_parameters,
- int literals, int properties,
- LanguageMode language_mode, bool uses_super_property,
- bool calls_eval) {
+ void LogFunction(int end, int num_parameters, int function_length,
+ bool has_duplicate_parameters, int literals,
+ int properties) {
DCHECK(!has_error_);
- // Check that we only log at most one function.
- DCHECK(start_ == -1 && end_ == -1);
- start_ = start;
end_ = end;
num_parameters_ = num_parameters;
function_length_ = function_length;
has_duplicate_parameters_ = has_duplicate_parameters;
literals_ = literals;
properties_ = properties;
- language_mode_ = language_mode;
- uses_super_property_ = uses_super_property;
- calls_eval_ = calls_eval;
}
// Logs an error message and marks the log as containing an error.
// Further logging will be ignored, and ExtractData will return a vector
// representing the error only.
- virtual void LogMessage(int start, int end, MessageTemplate::Template message,
- const char* argument_opt, ParseErrorType error_type) {
+ void LogMessage(int start, int end, MessageTemplate::Template message,
+ const char* argument_opt, ParseErrorType error_type) {
if (has_error_) return;
has_error_ = true;
start_ = start;
@@ -143,18 +107,6 @@ class SingletonLogger : public ParserRecorder {
DCHECK(!has_error_);
return properties_;
}
- LanguageMode language_mode() const {
- DCHECK(!has_error_);
- return language_mode_;
- }
- bool uses_super_property() const {
- DCHECK(!has_error_);
- return uses_super_property_;
- }
- bool calls_eval() const {
- DCHECK(!has_error_);
- return calls_eval_;
- }
ParseErrorType error_type() const {
DCHECK(has_error_);
return error_type_;
@@ -178,37 +130,31 @@ class SingletonLogger : public ParserRecorder {
bool has_duplicate_parameters_;
int literals_;
int properties_;
- LanguageMode language_mode_;
- bool uses_super_property_;
- bool calls_eval_;
// For error messages.
MessageTemplate::Template message_;
const char* argument_opt_;
ParseErrorType error_type_;
};
-
-class CompleteParserRecorder : public ParserRecorder {
+class ParserLogger final {
public:
struct Key {
bool is_one_byte;
Vector<const byte> literal_bytes;
};
- CompleteParserRecorder();
- virtual ~CompleteParserRecorder() {}
+ ParserLogger();
- virtual void LogFunction(int start, int end, int num_parameters,
- int function_length, bool has_duplicate_parameters,
- int literals, int properties,
- LanguageMode language_mode, bool uses_super_property,
- bool calls_eval);
+ void LogFunction(int start, int end, int num_parameters, int function_length,
+ bool has_duplicate_parameters, int literals, int properties,
+ LanguageMode language_mode, bool uses_super_property,
+ bool calls_eval);
// Logs an error message and marks the log as containing an error.
// Further logging will be ignored, and ExtractData will return a vector
// representing the error only.
- virtual void LogMessage(int start, int end, MessageTemplate::Template message,
- const char* argument_opt, ParseErrorType error_type);
+ void LogMessage(int start, int end, MessageTemplate::Template message,
+ const char* argument_opt, ParseErrorType error_type);
ScriptData* GetScriptData();
bool HasError() {
« no previous file with comments | « src/parsing/parser-base.h ('k') | src/parsing/preparse-data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698