| Index: src/preparser.h
|
| diff --git a/src/preparser.h b/src/preparser.h
|
| index ce8df77e7a8586b55b7016cd7713e4aa93faf7f9..de1015789dd66179d53402f3c39cde5817176dc5 100644
|
| --- a/src/preparser.h
|
| +++ b/src/preparser.h
|
| @@ -687,6 +687,67 @@ class PreParserExpressionList {
|
| };
|
|
|
|
|
| +class PreParserStatement {
|
| + public:
|
| + static PreParserStatement Default() {
|
| + return PreParserStatement(kUnknownStatement);
|
| + }
|
| +
|
| + static PreParserStatement FunctionDeclaration() {
|
| + return PreParserStatement(kFunctionDeclaration);
|
| + }
|
| +
|
| + // Creates expression statement from expression.
|
| + // Preserves being an unparenthesized string literal, possibly
|
| + // "use strict".
|
| + static PreParserStatement ExpressionStatement(
|
| + PreParserExpression expression) {
|
| + if (expression.IsUseStrictLiteral()) {
|
| + return PreParserStatement(kUseStrictExpressionStatement);
|
| + }
|
| + if (expression.IsStringLiteral()) {
|
| + return PreParserStatement(kStringLiteralExpressionStatement);
|
| + }
|
| + return Default();
|
| + }
|
| +
|
| + bool IsStringLiteral() {
|
| + return code_ == kStringLiteralExpressionStatement;
|
| + }
|
| +
|
| + bool IsUseStrictLiteral() {
|
| + return code_ == kUseStrictExpressionStatement;
|
| + }
|
| +
|
| + bool IsFunctionDeclaration() {
|
| + return code_ == kFunctionDeclaration;
|
| + }
|
| +
|
| + private:
|
| + enum Type {
|
| + kUnknownStatement,
|
| + kStringLiteralExpressionStatement,
|
| + kUseStrictExpressionStatement,
|
| + kFunctionDeclaration
|
| + };
|
| +
|
| + explicit PreParserStatement(Type code) : code_(code) {}
|
| + Type code_;
|
| +};
|
| +
|
| +
|
| +
|
| +// PreParserStatementList doesn't actually store the statements because
|
| +// the PreParser does not need them.
|
| +class PreParserStatementList {
|
| + public:
|
| + // These functions make list->Add(some_expression) work as no-ops.
|
| + PreParserStatementList() {}
|
| + PreParserStatementList* operator->() { return this; }
|
| + void Add(PreParserStatement, void*) {}
|
| +};
|
| +
|
| +
|
| class PreParserScope {
|
| public:
|
| explicit PreParserScope(PreParserScope* outer_scope, ScopeType scope_type)
|
| @@ -830,6 +891,7 @@ class PreParserTraits {
|
| typedef PreParserExpression Literal;
|
| typedef PreParserExpressionList ExpressionList;
|
| typedef PreParserExpressionList PropertyList;
|
| + typedef PreParserStatementList StatementList;
|
|
|
| // For constructing objects returned by the traversing functions.
|
| typedef PreParserFactory Factory;
|
| @@ -993,6 +1055,10 @@ class PreParserTraits {
|
| return PreParserExpressionList();
|
| }
|
|
|
| + static PreParserStatementList NewStatementList(int size, void* zone) {
|
| + return PreParserStatementList();
|
| + }
|
| +
|
| static PreParserExpressionList NewPropertyList(int size, void* zone) {
|
| return PreParserExpressionList();
|
| }
|
| @@ -1090,52 +1156,6 @@ class PreParser : public ParserBase<PreParserTraits> {
|
| kHasNoInitializers
|
| };
|
|
|
| - class Statement {
|
| - public:
|
| - static Statement Default() {
|
| - return Statement(kUnknownStatement);
|
| - }
|
| -
|
| - static Statement FunctionDeclaration() {
|
| - return Statement(kFunctionDeclaration);
|
| - }
|
| -
|
| - // Creates expression statement from expression.
|
| - // Preserves being an unparenthesized string literal, possibly
|
| - // "use strict".
|
| - static Statement ExpressionStatement(Expression expression) {
|
| - if (expression.IsUseStrictLiteral()) {
|
| - return Statement(kUseStrictExpressionStatement);
|
| - }
|
| - if (expression.IsStringLiteral()) {
|
| - return Statement(kStringLiteralExpressionStatement);
|
| - }
|
| - return Default();
|
| - }
|
| -
|
| - bool IsStringLiteral() {
|
| - return code_ == kStringLiteralExpressionStatement;
|
| - }
|
| -
|
| - bool IsUseStrictLiteral() {
|
| - return code_ == kUseStrictExpressionStatement;
|
| - }
|
| -
|
| - bool IsFunctionDeclaration() {
|
| - return code_ == kFunctionDeclaration;
|
| - }
|
| -
|
| - private:
|
| - enum Type {
|
| - kUnknownStatement,
|
| - kStringLiteralExpressionStatement,
|
| - kUseStrictExpressionStatement,
|
| - kFunctionDeclaration
|
| - };
|
| -
|
| - explicit Statement(Type code) : code_(code) {}
|
| - Type code_;
|
| - };
|
|
|
| enum SourceElements {
|
| kUnknownSourceElements
|
| @@ -1145,30 +1165,32 @@ class PreParser : public ParserBase<PreParserTraits> {
|
| // 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.
|
| - Statement ParseSourceElement(bool* ok);
|
| + PreParserStatement ParseSourceElement(bool* ok);
|
| SourceElements ParseSourceElements(int end_token, bool* ok);
|
| - Statement ParseStatement(bool* ok);
|
| - Statement ParseFunctionDeclaration(bool* ok);
|
| - Statement ParseBlock(bool* ok);
|
| - Statement ParseVariableStatement(VariableDeclarationContext var_context,
|
| - bool* ok);
|
| - Statement ParseVariableDeclarations(VariableDeclarationContext var_context,
|
| - VariableDeclarationProperties* decl_props,
|
| - int* num_decl,
|
| - bool* ok);
|
| - Statement ParseExpressionOrLabelledStatement(bool* ok);
|
| - Statement ParseIfStatement(bool* ok);
|
| - Statement ParseContinueStatement(bool* ok);
|
| - Statement ParseBreakStatement(bool* ok);
|
| - Statement ParseReturnStatement(bool* ok);
|
| - Statement ParseWithStatement(bool* ok);
|
| - Statement ParseSwitchStatement(bool* ok);
|
| - Statement ParseDoWhileStatement(bool* ok);
|
| - Statement ParseWhileStatement(bool* ok);
|
| - Statement ParseForStatement(bool* ok);
|
| - Statement ParseThrowStatement(bool* ok);
|
| - Statement ParseTryStatement(bool* ok);
|
| - Statement ParseDebuggerStatement(bool* ok);
|
| + PreParserStatement ParseStatement(bool* ok);
|
| + PreParserStatement ParseFunctionDeclaration(bool* ok);
|
| + PreParserStatement ParseBlock(bool* ok);
|
| + PreParserStatement ParseVariableStatement(
|
| + VariableDeclarationContext var_context,
|
| + bool* ok);
|
| + PreParserStatement ParseVariableDeclarations(
|
| + VariableDeclarationContext var_context,
|
| + VariableDeclarationProperties* decl_props,
|
| + int* num_decl,
|
| + bool* ok);
|
| + PreParserStatement ParseExpressionOrLabelledStatement(bool* ok);
|
| + PreParserStatement ParseIfStatement(bool* ok);
|
| + PreParserStatement ParseContinueStatement(bool* ok);
|
| + PreParserStatement ParseBreakStatement(bool* ok);
|
| + PreParserStatement ParseReturnStatement(bool* ok);
|
| + PreParserStatement ParseWithStatement(bool* ok);
|
| + PreParserStatement ParseSwitchStatement(bool* ok);
|
| + PreParserStatement ParseDoWhileStatement(bool* ok);
|
| + PreParserStatement ParseWhileStatement(bool* ok);
|
| + PreParserStatement ParseForStatement(bool* ok);
|
| + PreParserStatement ParseThrowStatement(bool* ok);
|
| + PreParserStatement ParseTryStatement(bool* ok);
|
| + PreParserStatement ParseDebuggerStatement(bool* ok);
|
| Expression ParseConditionalExpression(bool accept_IN, bool* ok);
|
| Expression ParseObjectLiteral(bool* ok);
|
| Expression ParseV8Intrinsic(bool* ok);
|
|
|