diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h index 11b86d3b7..5e88872cc 100644 --- a/libsolidity/ast/AST.h +++ b/libsolidity/ast/AST.h @@ -504,23 +504,6 @@ public: m_abstract(_abstract) {} - ContractDefinition( - int64_t _id, - SourceLocation const& _location, - boost::filesystem::path const& _jsonSourceFile - ): - ContractDefinition{ - _id, - _location, - {}, // name - {}, // StructuredDocumentation - {}, // InheritanceSpecifier[] - {} // body - } - { - m_jsonSourceFile = _jsonSourceFile; - } - void accept(ASTVisitor& _visitor) override; void accept(ASTConstVisitor& _visitor) const override; @@ -577,14 +560,11 @@ public: /// @returns the next constructor in the inheritance hierarchy. FunctionDefinition const* nextConstructor(ContractDefinition const& _mostDerivedContract) const; - std::optional jsonSourceFile() const noexcept { return m_jsonSourceFile; } - private: std::vector> m_baseContracts; std::vector> m_subNodes; ContractKind m_contractKind; bool m_abstract{false}; - std::optional m_jsonSourceFile {std::nullopt}; util::LazyInit, FunctionTypePointer>>> m_interfaceFunctionList[2]; util::LazyInit> m_interfaceEvents; diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index 1c327cdce..fe4a68c16 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -277,14 +277,6 @@ bool CompilerStack::parse() void CompilerStack::loadMissingInterfaces(int64_t _baseNodeID) { vector> importedSources; - for (ASTPointer importedSourceUnit: importedSources) - { - Source source; - source.ast = importedSourceUnit; - auto const name = "__imported_interface_" + to_string(importedSourceUnit->id()); - // TODO: maybe we want to make sure this isn't used already - m_sources[name] = move(source); - } for (auto const& sourcePair: m_sources) { ASTPointer const& source = sourcePair.second.ast; @@ -311,7 +303,7 @@ void CompilerStack::loadMissingInterfaces(int64_t _baseNodeID) _baseNodeID++, SourceLocation{}, source->licenseString(), - vector{ jsonContract } + vector>{ jsonContract } ); importedSources.push_back(importedSource); } @@ -326,6 +318,15 @@ void CompilerStack::loadMissingInterfaces(int64_t _baseNodeID) } } } + + for (ASTPointer importedSourceUnit: importedSources) + { + Source source; + source.ast = importedSourceUnit; + auto const name = "__imported_interface_" + to_string(importedSourceUnit->id()); + solAssert(m_sources.count(name) == 0, ""); + m_sources[name] = move(source); + } } void CompilerStack::importASTs(map const& _sources) diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp index 47a216a09..8b519d2b3 100644 --- a/libsolidity/parsing/Parser.cpp +++ b/libsolidity/parsing/Parser.cpp @@ -316,7 +316,8 @@ ASTPointer Parser::parseInterfaceDefinition() nodeFactory.markEndPosition(); expectToken(Token::Semicolon); - return nodeFactory.createNode(jsonSourceFileName); + auto fileName = make_shared(jsonSourceFileName.string()); + return nodeFactory.createNode(name, fileName); } baseContracts = parseContractInheritanceList();