Skip to content

Commit 0da1ce3

Browse files
aarltchriseth
authored andcommitted
[libsolidity] Refactor Compiler Stack imported source type.
1 parent 2201526 commit 0da1ce3

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

libsolidity/interface/CompilerStack.cpp

Lines changed: 12 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_compilationSourceType = CompilationSourceType::SolidityAST;
414414

415415
storeContractDefinitions();
416416
}
@@ -1482,7 +1482,17 @@ 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_compilationSourceType)
1487+
{
1488+
case CompilationSourceType::Solidity:
1489+
sourceType = "Solidity";
1490+
break;
1491+
case CompilationSourceType::SolidityAST:
1492+
sourceType = "SolidityAST";
1493+
break;
1494+
}
1495+
meta["language"] = sourceType;
14861496
meta["compiler"]["version"] = VersionStringStrict;
14871497

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

libsolidity/interface/CompilerStack.h

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

120+
enum class CompilationSourceType {
121+
/// Regular compilation from Solidity source files.
122+
Solidity,
123+
/// Compilation from an imported Solidity AST.
124+
SolidityAST
125+
};
126+
120127
/// Creates a new compiler stack.
121128
/// @param _readFile callback used to read files for import statements. Must return
122129
/// and must not emit exceptions.
@@ -511,7 +518,7 @@ class CompilerStack: public langutil::CharStreamProvider
511518
langutil::DebugInfoSelection m_debugInfoSelection = langutil::DebugInfoSelection::Default();
512519
bool m_parserErrorRecovery = false;
513520
State m_stackState = Empty;
514-
bool m_importedSources = false;
521+
CompilationSourceType m_compilationSourceType = CompilationSourceType::Solidity;
515522
/// Whether or not there has been an error during processing.
516523
/// If this is true, the stack will refuse to generate code.
517524
bool m_hasError = false;

0 commit comments

Comments
 (0)