Chromium Code Reviews| Index: src/parsing/parser-base.h |
| diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h |
| index 18366443b70c1955069e97ec1026fb9d2ce493d7..4e20391c2504ab73dec28aed54e578ed653700e0 100644 |
| --- a/src/parsing/parser-base.h |
| +++ b/src/parsing/parser-base.h |
| @@ -224,7 +224,8 @@ class ParserBase { |
| allow_harmony_restrictive_generators_(false), |
| allow_harmony_trailing_commas_(false), |
| allow_harmony_class_fields_(false), |
| - allow_harmony_object_rest_spread_(false) {} |
| + allow_harmony_object_rest_spread_(false), |
| + allow_harmony_dynamic_import_(false) {} |
| #define ALLOW_ACCESSORS(name) \ |
| bool allow_##name() const { return allow_##name##_; } \ |
| @@ -238,6 +239,7 @@ class ParserBase { |
| ALLOW_ACCESSORS(harmony_trailing_commas); |
| ALLOW_ACCESSORS(harmony_class_fields); |
| ALLOW_ACCESSORS(harmony_object_rest_spread); |
| + ALLOW_ACCESSORS(harmony_dynamic_import); |
| #undef ALLOW_ACCESSORS |
| @@ -1206,6 +1208,7 @@ class ParserBase { |
| int class_token_pos, bool* ok); |
| ExpressionT ParseTemplateLiteral(ExpressionT tag, int start, bool* ok); |
| ExpressionT ParseSuperExpression(bool is_new, bool* ok); |
| + ExpressionT ParseDynamicImportExpression(bool* ok); |
| ExpressionT ParseNewTargetExpression(bool* ok); |
| void ParseFormalParameter(FormalParametersT* parameters, bool* ok); |
| @@ -1484,6 +1487,7 @@ class ParserBase { |
| bool allow_harmony_trailing_commas_; |
| bool allow_harmony_class_fields_; |
| bool allow_harmony_object_rest_spread_; |
| + bool allow_harmony_dynamic_import_; |
| friend class DiscardableZoneScope; |
| }; |
| @@ -3403,6 +3407,8 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseMemberExpression( |
| } else if (peek() == Token::SUPER) { |
| const bool is_new = false; |
| result = ParseSuperExpression(is_new, CHECK_OK); |
| + } else if (allow_harmony_dynamic_import() && peek() == Token::IMPORT) { |
| + result = ParseDynamicImportExpression(CHECK_OK); |
| } else { |
| result = ParsePrimaryExpression(is_async, CHECK_OK); |
| } |
| @@ -3412,6 +3418,20 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseMemberExpression( |
| } |
| template <typename Impl> |
| +typename ParserBase<Impl>::ExpressionT |
| +ParserBase<Impl>::ParseDynamicImportExpression(bool* ok) { |
| + DCHECK(allow_harmony_dynamic_import()); |
| + int pos = position(); |
|
adamk
2017/01/31 00:29:33
I think you want peek_position() here (or alternat
gsathya
2017/01/31 00:35:09
Done.
|
| + Consume(Token::IMPORT); |
| + Expect(Token::LPAREN, CHECK_OK); |
| + ExpressionT arg_ref = ParseAssignmentExpression(true, CHECK_OK); |
|
adamk
2017/01/31 00:29:33
Naming nit: I think I'd like "arg" better, "_ref"
gsathya
2017/01/31 00:35:09
I was using the same identifier as the spec. Chang
|
| + Expect(Token::RPAREN, CHECK_OK); |
| + ZoneList<ExpressionT>* args = new (zone()) ZoneList<ExpressionT>(1, zone()); |
| + args->Add(arg_ref, zone()); |
| + return factory()->NewCallRuntime(Runtime::kDynamicImportCall, args, pos); |
| +} |
| + |
| +template <typename Impl> |
| typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseSuperExpression( |
| bool is_new, bool* ok) { |
| Expect(Token::SUPER, CHECK_OK); |