Changeset 187890 in webkit for trunk/Source/JavaScriptCore/parser/Parser.h
- Timestamp:
- Aug 4, 2015, 2:26:49 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/parser/Parser.h
r187351 r187890 128 128 return isEval(vm, ident) || isArguments(vm, ident); 129 129 } 130 ALWAYS_INLINE static bool isIdentifierOrKeyword(const JSToken& token) 131 { 132 return token.m_type == IDENT || token.m_type & KeywordTokenFlag; 133 } 134 135 class ModuleScopeData : public RefCounted<ModuleScopeData> { 136 public: 137 static Ref<ModuleScopeData> create() { return adoptRef(*new ModuleScopeData); } 138 139 const IdentifierSet& exportedBindings() const { return m_exportedBindings; } 140 141 bool exportName(const Identifier& exportedName) 142 { 143 return m_exportedNames.add(exportedName.impl()).isNewEntry; 144 } 145 146 void exportBinding(const Identifier& localName) 147 { 148 m_exportedBindings.add(localName.impl()); 149 } 150 151 private: 152 IdentifierSet m_exportedNames { }; 153 IdentifierSet m_exportedBindings { }; 154 }; 130 155 131 156 struct Scope { … … 165 190 , m_loopDepth(rhs.m_loopDepth) 166 191 , m_switchDepth(rhs.m_switchDepth) 192 , m_moduleScopeData(rhs.m_moduleScopeData) 167 193 { 168 194 if (rhs.m_labels) { … … 216 242 } 217 243 244 void setIsModule() 245 { 246 m_moduleScopeData = ModuleScopeData::create(); 247 } 248 218 249 bool isFunction() const { return m_isFunction; } 219 250 bool isFunctionBoundary() const { return m_isFunctionBoundary; } … … 235 266 236 267 return m_lexicalVariables; 268 } 269 270 ModuleScopeData& moduleScopeData() const 271 { 272 ASSERT(m_moduleScopeData); 273 return *m_moduleScopeData; 237 274 } 238 275 … … 533 570 IdentifierSet m_closedVariableCandidates; 534 571 IdentifierSet m_writtenVariables; 572 RefPtr<ModuleScopeData> m_moduleScopeData { }; 535 573 }; 536 574 … … 848 886 } 849 887 850 ALWAYS_INLINE bool isofToken() 851 { 852 return m_token.m_type == IDENT && *m_token.m_data.ident == m_vm->propertyNames->of; 888 ALWAYS_INLINE bool matchContextualKeyword(const Identifier& identifier) 889 { 890 return m_token.m_type == IDENT && *m_token.m_data.ident == identifier; 891 } 892 893 ALWAYS_INLINE bool matchIdentifierOrKeyword() 894 { 895 return isIdentifierOrKeyword(m_token); 853 896 } 854 897 … … 1008 1051 template <class TreeBuilder> TreeStatement parseStatementListItem(TreeBuilder&, const Identifier*& directive, unsigned* directiveLiteralLength); 1009 1052 template <class TreeBuilder> TreeStatement parseStatement(TreeBuilder&, const Identifier*& directive, unsigned* directiveLiteralLength = 0); 1053 enum class ExportType { Exported, NotExported }; 1010 1054 #if ENABLE(ES6_CLASS_SYNTAX) 1011 template <class TreeBuilder> TreeStatement parseClassDeclaration(TreeBuilder& );1055 template <class TreeBuilder> TreeStatement parseClassDeclaration(TreeBuilder&, ExportType = ExportType::NotExported); 1012 1056 #endif 1013 template <class TreeBuilder> TreeStatement parseFunctionDeclaration(TreeBuilder& );1014 template <class TreeBuilder> TreeStatement parseVariableDeclaration(TreeBuilder&, DeclarationType );1057 template <class TreeBuilder> TreeStatement parseFunctionDeclaration(TreeBuilder&, ExportType = ExportType::NotExported); 1058 template <class TreeBuilder> TreeStatement parseVariableDeclaration(TreeBuilder&, DeclarationType, ExportType = ExportType::NotExported); 1015 1059 template <class TreeBuilder> TreeStatement parseDoWhileStatement(TreeBuilder&); 1016 1060 template <class TreeBuilder> TreeStatement parseWhileStatement(TreeBuilder&); … … 1048 1092 template <class TreeBuilder> ALWAYS_INLINE bool parseFormalParameters(TreeBuilder&, TreeFormalParameterList, unsigned&); 1049 1093 enum VarDeclarationListContext { ForLoopContext, VarDeclarationContext }; 1050 template <class TreeBuilder> TreeExpression parseVariableDeclarationList(TreeBuilder&, int& declarations, TreeDestructuringPattern& lastPattern, TreeExpression& lastInitializer, JSTextPosition& identStart, JSTextPosition& initStart, JSTextPosition& initEnd, VarDeclarationListContext, DeclarationType, bool& forLoopConstDoesNotHaveInitializer);1094 template <class TreeBuilder> TreeExpression parseVariableDeclarationList(TreeBuilder&, int& declarations, TreeDestructuringPattern& lastPattern, TreeExpression& lastInitializer, JSTextPosition& identStart, JSTextPosition& initStart, JSTextPosition& initEnd, VarDeclarationListContext, DeclarationType, ExportType, bool& forLoopConstDoesNotHaveInitializer); 1051 1095 template <class TreeBuilder> TreeSourceElements parseArrowFunctionSingleExpressionBodySourceElements(TreeBuilder&); 1052 1096 template <class TreeBuilder> TreeExpression parseArrowFunctionExpression(TreeBuilder&); 1053 template <class TreeBuilder> NEVER_INLINE TreeDestructuringPattern createBindingPattern(TreeBuilder&, DestructuringKind, const Identifier&, int depth, JSToken, AssignmentContext, const Identifier** duplicateIdentifier);1054 template <class TreeBuilder> NEVER_INLINE TreeDestructuringPattern parseDestructuringPattern(TreeBuilder&, DestructuringKind, const Identifier** duplicateIdentifier = nullptr, bool* hasDestructuringPattern = nullptr, AssignmentContext = AssignmentContext::DeclarationStatement, int depth = 0);1097 template <class TreeBuilder> NEVER_INLINE TreeDestructuringPattern createBindingPattern(TreeBuilder&, DestructuringKind, ExportType, const Identifier&, int depth, JSToken, AssignmentContext, const Identifier** duplicateIdentifier); 1098 template <class TreeBuilder> NEVER_INLINE TreeDestructuringPattern parseDestructuringPattern(TreeBuilder&, DestructuringKind, ExportType, const Identifier** duplicateIdentifier = nullptr, bool* hasDestructuringPattern = nullptr, AssignmentContext = AssignmentContext::DeclarationStatement, int depth = 0); 1055 1099 template <class TreeBuilder> NEVER_INLINE TreeDestructuringPattern tryParseDestructuringPatternExpression(TreeBuilder&, AssignmentContext); 1056 1100 template <class TreeBuilder> NEVER_INLINE TreeExpression parseDefaultValueForDestructuringPattern(TreeBuilder&); 1101 template <class TreeBuilder> TreeSourceElements parseModuleSourceElements(TreeBuilder&); 1102 enum class ImportSpecifierType { NamespaceImport, NamedImport, DefaultImport }; 1103 template <class TreeBuilder> typename TreeBuilder::ImportSpecifier parseImportClauseItem(TreeBuilder&, ImportSpecifierType); 1104 template <class TreeBuilder> typename TreeBuilder::ModuleSpecifier parseModuleSpecifier(TreeBuilder&); 1105 template <class TreeBuilder> TreeStatement parseImportDeclaration(TreeBuilder&); 1106 template <class TreeBuilder> typename TreeBuilder::ExportSpecifier parseExportSpecifier(TreeBuilder& context, Vector<const Identifier*>& maybeLocalNames, bool& hasKeywordForLocalBindings); 1107 template <class TreeBuilder> TreeStatement parseExportDeclaration(TreeBuilder&); 1057 1108 1058 1109 template <class TreeBuilder> NEVER_INLINE bool parseFunctionInfo(TreeBuilder&, FunctionRequirements, FunctionParseMode, bool nameIsInContainingScope, ConstructorKind, SuperBinding, int functionKeywordStart, ParserFunctionInfo<TreeBuilder>&, FunctionParseType); … … 1182 1233 CodeFeatures m_features; 1183 1234 int m_numConstants; 1235 JSParserCodeType m_codeType; 1184 1236 1185 1237 struct DepthManager {
Note:
See TracChangeset
for help on using the changeset viewer.