mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
WIP-2
This commit is contained in:
@@ -263,6 +263,8 @@ bool CompilerStack::parse()
|
||||
m_sources[newPath].scanner = make_shared<Scanner>(CharStream(newContents, newPath));
|
||||
sourcesToParse.push_back(newPath);
|
||||
}
|
||||
|
||||
loadMissingInterfaces();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,6 +274,46 @@ bool CompilerStack::parse()
|
||||
return !m_hasError;
|
||||
}
|
||||
|
||||
void CompilerStack::loadMissingInterfaces()
|
||||
{
|
||||
for (auto const& sourcePair: m_sources)
|
||||
{
|
||||
ASTPointer<SourceUnit> const& source = sourcePair.second.ast;;
|
||||
|
||||
for (auto const& astNode: source->nodes())
|
||||
{
|
||||
if (auto* contract = dynamic_cast<ContractDefinition*>(astNode.get()))
|
||||
{
|
||||
if (auto const fileName = contract->jsonSourceFile(); fileName.has_value())
|
||||
{
|
||||
printf("%s needs replacement\n", fileName->string().c_str());
|
||||
|
||||
ReadCallback::Result result{false, string("File not supplied initially.")};
|
||||
if (m_readFile)
|
||||
result = m_readFile(ReadCallback::kindString(ReadCallback::Kind::ReadFile), fileName.value().string());
|
||||
if (result.success)
|
||||
{
|
||||
string const& jsonString = result.responseOrErrorMessage;
|
||||
printf("jsonString: %s\n", jsonString.c_str());
|
||||
Json::Value json;
|
||||
util::jsonParseStrict(jsonString, json, nullptr);
|
||||
ASTPointer<ContractDefinition> jsonContract = ASTJsonImporter{m_evmVersion}.jsonToContract(json);
|
||||
//TODO: contract = *jsonContract;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_errorReporter.fatalParserError(
|
||||
31415_error, // TODO
|
||||
contract->location(),
|
||||
"Cannot load JSON source."
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CompilerStack::importASTs(map<string, Json::Value> const& _sources)
|
||||
{
|
||||
if (m_stackState != Empty)
|
||||
|
||||
@@ -360,6 +360,8 @@ private:
|
||||
std::string applyRemapping(std::string const& _path, std::string const& _context);
|
||||
void resolveImports();
|
||||
|
||||
void loadMissingInterfaces();
|
||||
|
||||
/// @returns true if the source is requested to be compiled.
|
||||
bool isRequestedSource(std::string const& _sourceName) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user