mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Yul AST output on the CLI and in Standard JSON
This commit is contained in:
committed by
Kamil Śliwak
parent
bb16f61e1c
commit
28a1abf89a
@@ -40,6 +40,8 @@
|
||||
|
||||
#include <liblangutil/SourceReferenceFormatter.h>
|
||||
|
||||
#include <json/json.h>
|
||||
|
||||
#include <sstream>
|
||||
#include <variant>
|
||||
|
||||
@@ -87,7 +89,7 @@ set<CallableDeclaration const*, ASTNode::CompareByID> collectReachableCallables(
|
||||
|
||||
}
|
||||
|
||||
pair<string, string> IRGenerator::run(
|
||||
tuple<string, Json::Value, string, Json::Value> IRGenerator::run(
|
||||
ContractDefinition const& _contract,
|
||||
bytes const& _cborMetadata,
|
||||
map<ContractDefinition const*, string_view const> const& _otherYulSources
|
||||
@@ -112,9 +114,11 @@ pair<string, string> IRGenerator::run(
|
||||
);
|
||||
solAssert(false, ir + "\n\nInvalid IR generated:\n" + errorMessage + "\n");
|
||||
}
|
||||
Json::Value irAst = asmStack.astJson();
|
||||
asmStack.optimize();
|
||||
Json::Value irOptAst = asmStack.astJson();
|
||||
|
||||
return {std::move(ir), asmStack.print(m_context.soliditySourceProvider())};
|
||||
return {std::move(ir), std::move(irAst), asmStack.print(m_context.soliditySourceProvider()), std::move(irOptAst)};
|
||||
}
|
||||
|
||||
string IRGenerator::generate(
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
#include <liblangutil/CharStreamProvider.h>
|
||||
#include <liblangutil/EVMVersion.h>
|
||||
|
||||
#include <json/json.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace solidity::frontend
|
||||
@@ -70,7 +72,7 @@ public:
|
||||
|
||||
/// Generates and returns the IR code, in unoptimized and optimized form
|
||||
/// (or just pretty-printed, depending on the optimizer settings).
|
||||
std::pair<std::string, std::string> run(
|
||||
std::tuple<std::string, Json::Value, std::string, Json::Value> run(
|
||||
ContractDefinition const& _contract,
|
||||
bytes const& _cborMetadata,
|
||||
std::map<ContractDefinition const*, std::string_view const> const& _otherYulSources
|
||||
|
||||
Reference in New Issue
Block a user