Skip to content

Commit 12ad902

Browse files
committed
[libsolidity] Refactor Compiler Stack imported source type.
1 parent 2201526 commit 12ad902

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

libsolidity/interface/CompilerStack.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ void CompilerStack::importASTs(map<string, Json::Value> const& _sources)
410410
m_sources[path] = std::move(source);
411411
}
412412
m_stackState = ParsedAndImported;
413-
m_importedSources = true;
413+
m_importedSourceType = ImportedSourceType::SolidityAST;
414414

415415
storeContractDefinitions();
416416
}
@@ -1482,7 +1482,19 @@ string CompilerStack::createMetadata(Contract const& _contract, bool _forIR) con
14821482
{
14831483
Json::Value meta{Json::objectValue};
14841484
meta["version"] = 1;
1485-
meta["language"] = m_importedSources ? "SolidityAST" : "Solidity";
1485+
string sourceType;
1486+
switch (m_importedSourceType)
1487+
{
1488+
case ImportedSourceType::None:
1489+
sourceType = "Solidity";
1490+
break;
1491+
case ImportedSourceType::SolidityAST:
1492+
sourceType = "SolidityAST";
1493+
break;
1494+
default:
1495+
solAssert(false);
1496+
}
1497+
meta["language"] = sourceType;
14861498
meta["compiler"]["version"] = VersionStringStrict;
14871499

14881500
/// All the source files (including self), which should be included in the metadata.

libsolidity/interface/CompilerStack.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ class CompilerStack: public langutil::CharStreamProvider
117117
None
118118
};
119119

120+
enum class ImportedSourceType {
121+
None,
122+
SolidityAST
123+
};
124+
120125
/// Creates a new compiler stack.
121126
/// @param _readFile callback used to read files for import statements. Must return
122127
/// and must not emit exceptions.
@@ -511,7 +516,7 @@ class CompilerStack: public langutil::CharStreamProvider
511516
langutil::DebugInfoSelection m_debugInfoSelection = langutil::DebugInfoSelection::Default();
512517
bool m_parserErrorRecovery = false;
513518
State m_stackState = Empty;
514-
bool m_importedSources = false;
519+
ImportedSourceType m_importedSourceType = ImportedSourceType::None;
515520
/// Whether or not there has been an error during processing.
516521
/// If this is true, the stack will refuse to generate code.
517522
bool m_hasError = false;

0 commit comments

Comments
 (0)