Yul AST output on the CLI and in Standard JSON

This commit is contained in:
GiokaMarkella
2023-05-26 12:35:31 +02:00
committed by Kamil Śliwak
parent bb16f61e1c
commit 28a1abf89a
62 changed files with 4542 additions and 43 deletions
+6 -2
View File
@@ -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(
+3 -1
View File
@@ -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