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

Unified Diff: src/parsing/parser.h

Issue 2313703002: Revert of [parser] Refactor of Parse*Statement*, part 1 (Closed)
Patch Set: Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/parsing/parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser.h
diff --git a/src/parsing/parser.h b/src/parsing/parser.h
index e8b9ab8aaea97092f3c607297f5d309cbf8bf6a6..38695495545aa9d69e4d6dee9adb7b42fd748472 100644
--- a/src/parsing/parser.h
+++ b/src/parsing/parser.h
@@ -21,8 +21,7 @@
class ParseInfo;
class ScriptData;
-class ParserTarget;
-class ParserTargetScope;
+class Target;
class FunctionEntry BASE_EMBEDDED {
public:
@@ -153,15 +152,11 @@
typedef ZoneList<v8::internal::Expression*>* ExpressionList;
typedef ZoneList<ObjectLiteral::Property*>* PropertyList;
typedef ParserFormalParameters FormalParameters;
- typedef v8::internal::Statement* Statement;
typedef ZoneList<v8::internal::Statement*>* StatementList;
typedef v8::internal::Block* Block;
// For constructing objects returned by the traversing functions.
typedef AstNodeFactory Factory;
-
- typedef ParserTarget Target;
- typedef ParserTargetScope TargetScope;
};
class Parser : public ParserBase<Parser> {
@@ -244,6 +239,12 @@
return compile_options_ == ScriptCompiler::kProduceParserCache;
}
+ // All ParseXXX functions take as the last argument an *ok parameter
+ // which is set to false if parsing failed; it is unchanged otherwise.
+ // By making the 'exception handling' explicit, we are forced to check
+ // for failure at the call sites.
+ void ParseStatementList(ZoneList<Statement*>* body, int end_token, bool* ok);
+ Statement* ParseStatementListItem(bool* ok);
void ParseModuleItemList(ZoneList<Statement*>* body, bool* ok);
Statement* ParseModuleItem(bool* ok);
const AstRawString* ParseModuleSpecifier(bool* ok);
@@ -265,6 +266,14 @@
location(location) {}
};
ZoneList<const NamedImport*>* ParseNamedImports(int pos, bool* ok);
+ Statement* ParseStatement(ZoneList<const AstRawString*>* labels,
+ AllowLabelledFunctionStatement allow_function,
+ bool* ok);
+ Statement* ParseSubStatement(ZoneList<const AstRawString*>* labels,
+ AllowLabelledFunctionStatement allow_function,
+ bool* ok);
+ Statement* ParseStatementAsUnlabelled(ZoneList<const AstRawString*>* labels,
+ bool* ok);
Statement* ParseFunctionDeclaration(bool* ok);
Statement* ParseHoistableDeclaration(ZoneList<const AstRawString*>* names,
bool default_export, bool* ok);
@@ -571,7 +580,7 @@
int pos);
void SetLanguageMode(Scope* scope, LanguageMode mode);
- void SetAsmModule();
+ void RaiseLanguageMode(LanguageMode mode);
V8_INLINE void MarkCollectedTailCallExpressions();
V8_INLINE void MarkTailPosition(Expression* expression);
@@ -691,26 +700,6 @@
V8_INLINE static bool IsArrayIndex(const AstRawString* string,
uint32_t* index) {
return string->AsArrayIndex(index);
- }
-
- V8_INLINE bool IsUseStrictDirective(Statement* statement) const {
- return IsStringLiteral(statement, ast_value_factory()->use_strict_string());
- }
-
- V8_INLINE bool IsUseAsmDirective(Statement* statement) const {
- return IsStringLiteral(statement, ast_value_factory()->use_asm_string());
- }
-
- // Returns true if the statement is an expression statement containing
- // a single string literal. If a second argument is given, the literal
- // is also compared with it and the result is true only if they are equal.
- V8_INLINE bool IsStringLiteral(Statement* statement,
- const AstRawString* arg = nullptr) const {
- ExpressionStatement* e_stat = statement->AsExpressionStatement();
- if (e_stat == nullptr) return false;
- Literal* literal = e_stat->expression()->AsLiteral();
- if (literal == nullptr || !literal->raw_value()->IsString()) return false;
- return arg == nullptr || literal->raw_value()->AsString() == arg;
}
V8_INLINE static Expression* GetPropertyValue(
@@ -859,17 +848,7 @@
V8_INLINE static ZoneList<Expression*>* NullExpressionList() {
return nullptr;
}
- V8_INLINE static bool IsNullExpressionList(ZoneList<Expression*>* exprs) {
- return exprs == nullptr;
- }
V8_INLINE static ZoneList<Statement*>* NullStatementList() { return nullptr; }
- V8_INLINE static bool IsNullStatementList(ZoneList<Statement*>* stmts) {
- return stmts == nullptr;
- }
- V8_INLINE static Statement* NullStatement() { return nullptr; }
- V8_INLINE bool IsNullOrEmptyStatement(Statement* stmt) {
- return stmt == nullptr || stmt->IsEmpty();
- }
// Non-NULL empty string.
V8_INLINE const AstRawString* EmptyIdentifierString() const {
@@ -1031,11 +1010,7 @@
Scanner scanner_;
PreParser* reusable_preparser_;
Scope* original_scope_; // for ES5 function declarations in sloppy eval
-
- friend class ParserTarget;
- friend class ParserTargetScope;
- ParserTarget* target_stack_; // for break, continue statements
-
+ Target* target_stack_; // for break, continue statements
ScriptCompiler::CompileOptions compile_options_;
ParseData* cached_parse_data_;
« no previous file with comments | « no previous file | src/parsing/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698