This commit is contained in:
Christian Parpart 2020-06-03 11:23:08 +02:00
parent a59e5d1dbe
commit 8df6b50a78
3 changed files with 12 additions and 30 deletions

View File

@ -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<boost::filesystem::path> jsonSourceFile() const noexcept { return m_jsonSourceFile; }
private:
std::vector<ASTPointer<InheritanceSpecifier>> m_baseContracts;
std::vector<ASTPointer<ASTNode>> m_subNodes;
ContractKind m_contractKind;
bool m_abstract{false};
std::optional<boost::filesystem::path> m_jsonSourceFile {std::nullopt};
util::LazyInit<std::vector<std::pair<util::FixedHash<4>, FunctionTypePointer>>> m_interfaceFunctionList[2];
util::LazyInit<std::vector<EventDefinition const*>> m_interfaceEvents;

View File

@ -277,14 +277,6 @@ bool CompilerStack::parse()
void CompilerStack::loadMissingInterfaces(int64_t _baseNodeID)
{
vector<ASTPointer<SourceUnit>> importedSources;
for (ASTPointer<SourceUnit> 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<SourceUnit> const& source = sourcePair.second.ast;
@ -311,7 +303,7 @@ void CompilerStack::loadMissingInterfaces(int64_t _baseNodeID)
_baseNodeID++,
SourceLocation{},
source->licenseString(),
vector{ jsonContract }
vector<ASTPointer<ASTNode>>{ jsonContract }
);
importedSources.push_back(importedSource);
}
@ -326,6 +318,15 @@ void CompilerStack::loadMissingInterfaces(int64_t _baseNodeID)
}
}
}
for (ASTPointer<SourceUnit> 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<string, Json::Value> const& _sources)

View File

@ -316,7 +316,8 @@ ASTPointer<ContractDefinition> Parser::parseInterfaceDefinition()
nodeFactory.markEndPosition();
expectToken(Token::Semicolon);
return nodeFactory.createNode<ContractDefinition>(jsonSourceFileName);
auto fileName = make_shared<ASTString>(jsonSourceFileName.string());
return nodeFactory.createNode<ImportedContractDefinition>(name, fileName);
}
baseContracts = parseContractInheritanceList();