| 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/bailout-reason.h" | 9 #include "src/bailout-reason.h" |
| 10 #include "src/hashmap.h" | 10 #include "src/hashmap.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 } | 48 } |
| 49 static PreParserIdentifier Yield() { | 49 static PreParserIdentifier Yield() { |
| 50 return PreParserIdentifier(kYieldIdentifier); | 50 return PreParserIdentifier(kYieldIdentifier); |
| 51 } | 51 } |
| 52 static PreParserIdentifier Prototype() { | 52 static PreParserIdentifier Prototype() { |
| 53 return PreParserIdentifier(kPrototypeIdentifier); | 53 return PreParserIdentifier(kPrototypeIdentifier); |
| 54 } | 54 } |
| 55 static PreParserIdentifier Constructor() { | 55 static PreParserIdentifier Constructor() { |
| 56 return PreParserIdentifier(kConstructorIdentifier); | 56 return PreParserIdentifier(kConstructorIdentifier); |
| 57 } | 57 } |
| 58 static PreParserIdentifier Enum() { |
| 59 return PreParserIdentifier(kEnumIdentifier); |
| 60 } |
| 61 static PreParserIdentifier Await() { |
| 62 return PreParserIdentifier(kAwaitIdentifier); |
| 63 } |
| 58 bool IsEval() const { return type_ == kEvalIdentifier; } | 64 bool IsEval() const { return type_ == kEvalIdentifier; } |
| 59 bool IsArguments() const { return type_ == kArgumentsIdentifier; } | 65 bool IsArguments() const { return type_ == kArgumentsIdentifier; } |
| 60 bool IsEvalOrArguments() const { return IsEval() || IsArguments(); } | 66 bool IsEvalOrArguments() const { return IsEval() || IsArguments(); } |
| 61 bool IsUndefined() const { return type_ == kUndefinedIdentifier; } | 67 bool IsUndefined() const { return type_ == kUndefinedIdentifier; } |
| 62 bool IsLet() const { return type_ == kLetIdentifier; } | 68 bool IsLet() const { return type_ == kLetIdentifier; } |
| 63 bool IsStatic() const { return type_ == kStaticIdentifier; } | 69 bool IsStatic() const { return type_ == kStaticIdentifier; } |
| 64 bool IsYield() const { return type_ == kYieldIdentifier; } | 70 bool IsYield() const { return type_ == kYieldIdentifier; } |
| 65 bool IsPrototype() const { return type_ == kPrototypeIdentifier; } | 71 bool IsPrototype() const { return type_ == kPrototypeIdentifier; } |
| 66 bool IsConstructor() const { return type_ == kConstructorIdentifier; } | 72 bool IsConstructor() const { return type_ == kConstructorIdentifier; } |
| 67 bool IsFutureReserved() const { return type_ == kFutureReservedIdentifier; } | 73 bool IsEnum() const { return type_ == kEnumIdentifier; } |
| 74 bool IsAwait() const { return type_ == kAwaitIdentifier; } |
| 68 bool IsFutureStrictReserved() const { | 75 bool IsFutureStrictReserved() const { |
| 69 return type_ == kFutureStrictReservedIdentifier || | 76 return type_ == kFutureStrictReservedIdentifier || |
| 70 type_ == kLetIdentifier || type_ == kStaticIdentifier || | 77 type_ == kLetIdentifier || type_ == kStaticIdentifier || |
| 71 type_ == kYieldIdentifier; | 78 type_ == kYieldIdentifier; |
| 72 } | 79 } |
| 73 | 80 |
| 74 // Allow identifier->name()[->length()] to work. The preparser | 81 // Allow identifier->name()[->length()] to work. The preparser |
| 75 // does not need the actual positions/lengths of the identifiers. | 82 // does not need the actual positions/lengths of the identifiers. |
| 76 const PreParserIdentifier* operator->() const { return this; } | 83 const PreParserIdentifier* operator->() const { return this; } |
| 77 const PreParserIdentifier raw_name() const { return *this; } | 84 const PreParserIdentifier raw_name() const { return *this; } |
| 78 | 85 |
| 79 int position() const { return 0; } | 86 int position() const { return 0; } |
| 80 int length() const { return 0; } | 87 int length() const { return 0; } |
| 81 | 88 |
| 82 private: | 89 private: |
| 83 enum Type { | 90 enum Type { |
| 84 kUnknownIdentifier, | 91 kUnknownIdentifier, |
| 85 kFutureReservedIdentifier, | 92 kFutureReservedIdentifier, |
| 86 kFutureStrictReservedIdentifier, | 93 kFutureStrictReservedIdentifier, |
| 87 kLetIdentifier, | 94 kLetIdentifier, |
| 88 kStaticIdentifier, | 95 kStaticIdentifier, |
| 89 kYieldIdentifier, | 96 kYieldIdentifier, |
| 90 kEvalIdentifier, | 97 kEvalIdentifier, |
| 91 kArgumentsIdentifier, | 98 kArgumentsIdentifier, |
| 92 kUndefinedIdentifier, | 99 kUndefinedIdentifier, |
| 93 kPrototypeIdentifier, | 100 kPrototypeIdentifier, |
| 94 kConstructorIdentifier | 101 kConstructorIdentifier, |
| 102 kEnumIdentifier, |
| 103 kAwaitIdentifier |
| 95 }; | 104 }; |
| 96 | 105 |
| 97 explicit PreParserIdentifier(Type type) : type_(type) {} | 106 explicit PreParserIdentifier(Type type) : type_(type) {} |
| 98 Type type_; | 107 Type type_; |
| 99 | 108 |
| 100 friend class PreParserExpression; | 109 friend class PreParserExpression; |
| 101 }; | 110 }; |
| 102 | 111 |
| 103 | 112 |
| 104 class PreParserExpression { | 113 class PreParserExpression { |
| (...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1169 const PreParserFormalParameters& parameters, FunctionKind kind, | 1178 const PreParserFormalParameters& parameters, FunctionKind kind, |
| 1170 FunctionLiteral::FunctionType function_type, bool* ok) { | 1179 FunctionLiteral::FunctionType function_type, bool* ok) { |
| 1171 return pre_parser_->ParseEagerFunctionBody(function_name, pos, parameters, | 1180 return pre_parser_->ParseEagerFunctionBody(function_name, pos, parameters, |
| 1172 kind, function_type, ok); | 1181 kind, function_type, ok); |
| 1173 } | 1182 } |
| 1174 | 1183 |
| 1175 } // namespace internal | 1184 } // namespace internal |
| 1176 } // namespace v8 | 1185 } // namespace v8 |
| 1177 | 1186 |
| 1178 #endif // V8_PARSING_PREPARSER_H | 1187 #endif // V8_PARSING_PREPARSER_H |
| OLD | NEW |