Skip to content

Commit 08af255

Browse files
authored
Merge pull request #13578 from ethereum/imported-source-type-refactoring
[libsolidity] Refactor Compiler Stack imported source type.
2 parents b052052 + 0da1ce3 commit 08af255

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
@@ -411,7 +411,7 @@ void CompilerStack::importASTs(map<string, Json::Value> const& _sources)
411411
m_sources[path] = std::move(source);
412412
}
413413
m_stackState = ParsedAndImported;
414-
m_importedSources = true;
414+
m_compilationSourceType = CompilationSourceType::SolidityAST;
415415

416416
storeContractDefinitions();
417417
}
@@ -1483,7 +1483,17 @@ string CompilerStack::createMetadata(Contract const& _contract, bool _forIR) con
14831483
{
14841484
Json::Value meta{Json::objectValue};
14851485
meta["version"] = 1;
1486-
meta["language"] = m_importedSources ? "SolidityAST" : "Solidity";
1486+
string sourceType;
1487+
switch (m_compilationSourceType)
1488+
{
1489+
case CompilationSourceType::Solidity:
1490+
sourceType = "Solidity";
1491+
break;
1492+
case CompilationSourceType::SolidityAST:
1493+
sourceType = "SolidityAST";
1494+
break;
1495+
}
1496+
meta["language"] = sourceType;
14871497
meta["compiler"]["version"] = VersionStringStrict;
14881498

14891499
/// 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.
@@ -514,7 +521,7 @@ class CompilerStack: public langutil::CharStreamProvider
514521
langutil::DebugInfoSelection m_debugInfoSelection = langutil::DebugInfoSelection::Default();
515522
bool m_parserErrorRecovery = false;
516523
State m_stackState = Empty;
517-
bool m_importedSources = false;
524+
CompilationSourceType m_compilationSourceType = CompilationSourceType::Solidity;
518525
/// Whether or not there has been an error during processing.
519526
/// If this is true, the stack will refuse to generate code.
520527
bool m_hasError = false;

0 commit comments

Comments
 (0)