OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_PARSING_PREPARSER_H | 5 #ifndef V8_PARSING_PREPARSER_H |
6 #define V8_PARSING_PREPARSER_H | 6 #define V8_PARSING_PREPARSER_H |
7 | 7 |
8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
9 #include "src/parsing/parser-base.h" | 9 #include "src/parsing/parser-base.h" |
10 | 10 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 bool IsArguments() const { return type_ == kArgumentsIdentifier; } | 72 bool IsArguments() const { return type_ == kArgumentsIdentifier; } |
73 bool IsEvalOrArguments() const { return IsEval() || IsArguments(); } | 73 bool IsEvalOrArguments() const { return IsEval() || IsArguments(); } |
74 bool IsUndefined() const { return type_ == kUndefinedIdentifier; } | 74 bool IsUndefined() const { return type_ == kUndefinedIdentifier; } |
75 bool IsLet() const { return type_ == kLetIdentifier; } | 75 bool IsLet() const { return type_ == kLetIdentifier; } |
76 bool IsStatic() const { return type_ == kStaticIdentifier; } | 76 bool IsStatic() const { return type_ == kStaticIdentifier; } |
77 bool IsYield() const { return type_ == kYieldIdentifier; } | 77 bool IsYield() const { return type_ == kYieldIdentifier; } |
78 bool IsPrototype() const { return type_ == kPrototypeIdentifier; } | 78 bool IsPrototype() const { return type_ == kPrototypeIdentifier; } |
79 bool IsConstructor() const { return type_ == kConstructorIdentifier; } | 79 bool IsConstructor() const { return type_ == kConstructorIdentifier; } |
80 bool IsEnum() const { return type_ == kEnumIdentifier; } | 80 bool IsEnum() const { return type_ == kEnumIdentifier; } |
81 bool IsAwait() const { return type_ == kAwaitIdentifier; } | 81 bool IsAwait() const { return type_ == kAwaitIdentifier; } |
82 bool IsFutureStrictReserved() const { | |
83 return type_ == kFutureStrictReservedIdentifier || | |
84 type_ == kLetIdentifier || type_ == kStaticIdentifier || | |
85 type_ == kYieldIdentifier; | |
86 } | |
87 | 82 |
88 // Allow identifier->name()[->length()] to work. The preparser | 83 // Allow identifier->name()[->length()] to work. The preparser |
89 // does not need the actual positions/lengths of the identifiers. | 84 // does not need the actual positions/lengths of the identifiers. |
90 const PreParserIdentifier* operator->() const { return this; } | 85 const PreParserIdentifier* operator->() const { return this; } |
91 const PreParserIdentifier raw_name() const { return *this; } | 86 const PreParserIdentifier raw_name() const { return *this; } |
92 | 87 |
93 int position() const { return 0; } | 88 int position() const { return 0; } |
94 int length() const { return 0; } | 89 int length() const { return 0; } |
95 | 90 |
96 private: | 91 private: |
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1002 PreParserStatement block, | 997 PreParserStatement block, |
1003 const DeclarationDescriptor* declaration_descriptor, | 998 const DeclarationDescriptor* declaration_descriptor, |
1004 const DeclarationParsingResult::Declaration* declaration, | 999 const DeclarationParsingResult::Declaration* declaration, |
1005 ZoneList<const AstRawString*>* names, bool* ok); | 1000 ZoneList<const AstRawString*>* names, bool* ok); |
1006 | 1001 |
1007 V8_INLINE ZoneList<const AstRawString*>* DeclareLabel( | 1002 V8_INLINE ZoneList<const AstRawString*>* DeclareLabel( |
1008 ZoneList<const AstRawString*>* labels, PreParserExpression expr, | 1003 ZoneList<const AstRawString*>* labels, PreParserExpression expr, |
1009 bool* ok) { | 1004 bool* ok) { |
1010 DCHECK(!expr.AsIdentifier().IsEnum()); | 1005 DCHECK(!expr.AsIdentifier().IsEnum()); |
1011 DCHECK(!parsing_module_ || !expr.AsIdentifier().IsAwait()); | 1006 DCHECK(!parsing_module_ || !expr.AsIdentifier().IsAwait()); |
1012 DCHECK(is_sloppy(language_mode()) || | 1007 DCHECK(IsIdentifier(expr)); |
1013 !IsFutureStrictReserved(expr.AsIdentifier())); | |
1014 return labels; | 1008 return labels; |
1015 } | 1009 } |
1016 | 1010 |
1017 // TODO(nikolaos): The preparser currently does not keep track of labels. | 1011 // TODO(nikolaos): The preparser currently does not keep track of labels. |
1018 V8_INLINE bool ContainsLabel(ZoneList<const AstRawString*>* labels, | 1012 V8_INLINE bool ContainsLabel(ZoneList<const AstRawString*>* labels, |
1019 PreParserIdentifier label) { | 1013 PreParserIdentifier label) { |
1020 return false; | 1014 return false; |
1021 } | 1015 } |
1022 | 1016 |
1023 V8_INLINE PreParserExpression RewriteReturn(PreParserExpression return_value, | 1017 V8_INLINE PreParserExpression RewriteReturn(PreParserExpression return_value, |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1118 } | 1112 } |
1119 | 1113 |
1120 V8_INLINE bool IsUndefined(PreParserIdentifier identifier) const { | 1114 V8_INLINE bool IsUndefined(PreParserIdentifier identifier) const { |
1121 return identifier.IsUndefined(); | 1115 return identifier.IsUndefined(); |
1122 } | 1116 } |
1123 | 1117 |
1124 V8_INLINE bool IsAwait(PreParserIdentifier identifier) const { | 1118 V8_INLINE bool IsAwait(PreParserIdentifier identifier) const { |
1125 return identifier.IsAwait(); | 1119 return identifier.IsAwait(); |
1126 } | 1120 } |
1127 | 1121 |
1128 V8_INLINE bool IsFutureStrictReserved(PreParserIdentifier identifier) const { | |
1129 return identifier.IsFutureStrictReserved(); | |
1130 } | |
1131 | |
1132 // Returns true if the expression is of type "this.foo". | 1122 // Returns true if the expression is of type "this.foo". |
1133 V8_INLINE static bool IsThisProperty(PreParserExpression expression) { | 1123 V8_INLINE static bool IsThisProperty(PreParserExpression expression) { |
1134 return expression.IsThisProperty(); | 1124 return expression.IsThisProperty(); |
1135 } | 1125 } |
1136 | 1126 |
1137 V8_INLINE static bool IsIdentifier(PreParserExpression expression) { | 1127 V8_INLINE static bool IsIdentifier(PreParserExpression expression) { |
1138 return expression.IsIdentifier(); | 1128 return expression.IsIdentifier(); |
1139 } | 1129 } |
1140 | 1130 |
1141 V8_INLINE static PreParserIdentifier AsIdentifier( | 1131 V8_INLINE static PreParserIdentifier AsIdentifier( |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1562 function_state_->NextMaterializedLiteralIndex(); | 1552 function_state_->NextMaterializedLiteralIndex(); |
1563 function_state_->NextMaterializedLiteralIndex(); | 1553 function_state_->NextMaterializedLiteralIndex(); |
1564 } | 1554 } |
1565 return EmptyExpression(); | 1555 return EmptyExpression(); |
1566 } | 1556 } |
1567 | 1557 |
1568 } // namespace internal | 1558 } // namespace internal |
1569 } // namespace v8 | 1559 } // namespace v8 |
1570 | 1560 |
1571 #endif // V8_PARSING_PREPARSER_H | 1561 #endif // V8_PARSING_PREPARSER_H |
OLD | NEW |