Changeset 203953 in webkit for trunk/Source/JavaScriptCore/parser/ModuleScopeData.h
- Timestamp:
- Jul 31, 2016, 12:04:57 AM (9 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/parser/ModuleScopeData.h
r203952 r203953 1 1 /* 2 2 * Copyright (C) 2015 Apple Inc. All rights reserved. 3 * Copyright (C) 2016 Yusuke Suzuki <[email protected]> 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 24 25 */ 25 26 26 #ifndef ModuleAnalyzer_h 27 #define ModuleAnalyzer_h 27 #pragma once 28 28 29 #include "Nodes.h" 29 #include "Identifier.h" 30 #include <wtf/RefPtr.h> 30 31 31 32 namespace JSC { 32 33 33 class JSModuleRecord; 34 class SourceCode; 34 class ModuleScopeData : public RefCounted<ModuleScopeData> { 35 WTF_MAKE_NONCOPYABLE(ModuleScopeData); 36 WTF_MAKE_FAST_ALLOCATED; 37 public: 38 typedef HashMap<RefPtr<UniquedStringImpl>, IdentifierSet, IdentifierRepHash, HashTraits<RefPtr<UniquedStringImpl>>> IdentifierAliasMap; 35 39 36 class ModuleAnalyzer { 37 WTF_MAKE_NONCOPYABLE(ModuleAnalyzer); 38 public: 39 ModuleAnalyzer(ExecState*, const Identifier& moduleKey, const SourceCode&, const VariableEnvironment& declaredVariables, const VariableEnvironment& lexicalVariables); 40 static Ref<ModuleScopeData> create() { return adoptRef(*new ModuleScopeData); } 40 41 41 JSModuleRecord* analyze(ModuleProgramNode&);42 const IdentifierAliasMap& exportedBindings() const { return m_exportedBindings; } 42 43 43 VM& vm() { return *m_vm; } 44 bool exportName(const Identifier& exportedName) 45 { 46 return m_exportedNames.add(exportedName.impl()).isNewEntry; 47 } 44 48 45 JSModuleRecord* moduleRecord() { return m_moduleRecord.get(); } 49 void exportBinding(const Identifier& localName, const Identifier& exportedName) 50 { 51 m_exportedBindings.add(localName.impl(), IdentifierSet()).iterator->value.add(exportedName.impl()); 52 } 46 53 47 void declareExportAlias(const Identifier& localName, const Identifier& exportName); 54 void exportBinding(const Identifier& localName) 55 { 56 exportBinding(localName, localName); 57 } 48 58 49 59 private: 50 typedef HashMap<RefPtr<UniquedStringImpl>, Identifier, IdentifierRepHash, HashTraits<RefPtr<UniquedStringImpl>>> IdentifierAliasMap;60 ModuleScopeData() = default; 51 61 52 void exportVariable(const RefPtr<UniquedStringImpl>&, const VariableEnvironmentEntry&); 53 54 Identifier exportedBinding(const RefPtr<UniquedStringImpl>& ident); 55 56 VM* m_vm; 57 Strong<JSModuleRecord> m_moduleRecord; 58 IdentifierAliasMap m_aliasMap; 62 IdentifierSet m_exportedNames { }; 63 IdentifierAliasMap m_exportedBindings { }; 59 64 }; 60 65 61 } // namespace JSC 62 63 #endif // ModuleAnalyzer_h 66 } // namespace
Note:
See TracChangeset
for help on using the changeset viewer.