Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yul: Remove boolType and defaultType from dialect #15332

Merged
merged 5 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Compiler Features:
* Standard JSON Interface: Do not perform IR optimization when only unoptimized IR is requested.
* Standard JSON Interface: Add ``transientStorageLayout`` output.
* Yul: Drop the deprecated typed Yul dialect that was only accessible via ``--yul`` in the CLI.
* Yul: The presence of types in untyped Yul dialects is now a parser error.
* Yul Optimizer: Caching of optimized IR to speed up optimization of contracts with bytecode dependencies.
* Yul Optimizer: The optimizer now treats some previously unrecognized identical literals as identical.
* Commandline Interface: Allow the use of ``--asm-json`` output option in assembler mode to export EVM assembly of the contracts in JSON format.
Expand Down
2 changes: 1 addition & 1 deletion libsolidity/analysis/ReferencesResolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ void ReferencesResolver::operator()(yul::FunctionDefinition const& _function)
{
solAssert(nativeLocationOf(_function) == originLocationOf(_function), "");
validateYulIdentifierName(_function.name, nativeLocationOf(_function));
for (yul::TypedName const& varName: _function.parameters + _function.returnVariables)
for (yul::NameWithDebugData const& varName: _function.parameters + _function.returnVariables)
{
solAssert(nativeLocationOf(varName) == originLocationOf(varName), "");
validateYulIdentifierName(varName.name, nativeLocationOf(varName));
Expand Down
4 changes: 2 additions & 2 deletions libsolidity/codegen/CompilerContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,8 @@ void CompilerContext::appendInlineAssembly(
{
// Store as generated sources, but first re-parse to update the source references.
solAssert(m_generatedYulUtilityCode.empty(), "");
m_generatedYulUtilityCode = yul::AsmPrinter(yul::AsmPrinter::TypePrinting::OmitDefault, dialect)(obj.code()->root());
std::string code = yul::AsmPrinter{yul::AsmPrinter::TypePrinting::OmitDefault, dialect}(obj.code()->root());
m_generatedYulUtilityCode = yul::AsmPrinter()(obj.code()->root());
std::string code = yul::AsmPrinter{}(obj.code()->root());
langutil::CharStream charStream(m_generatedYulUtilityCode, _sourceName);
obj.setCode(yul::Parser(errorReporter, dialect).parse(charStream));
obj.analysisInfo = std::make_shared<yul::AsmAnalysisInfo>(yul::AsmAnalyzer::analyzeStrictAssertCorrect(dialect, obj));
Expand Down
4 changes: 2 additions & 2 deletions libsolidity/codegen/ir/IRGeneratorForStatements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ struct CopyTranslate: public yul::ASTCopier
solAssert(false);

if (isDigit(value.front()))
return yul::Literal{_identifier.debugData, yul::LiteralKind::Number, yul::valueOfNumberLiteral(value), {}};
return yul::Literal{_identifier.debugData, yul::LiteralKind::Number, yul::valueOfNumberLiteral(value)};
else
return yul::Identifier{_identifier.debugData, yul::YulName{value}};
}
Expand Down Expand Up @@ -2256,7 +2256,7 @@ bool IRGeneratorForStatements::visit(InlineAssembly const& _inlineAsm)

solAssert(std::holds_alternative<yul::Block>(modified));

appendCode() << yul::AsmPrinter(yul::AsmPrinter::TypePrinting::Full, _inlineAsm.dialect())(std::get<yul::Block>(modified)) << "\n";
appendCode() << yul::AsmPrinter()(std::get<yul::Block>(modified)) << "\n";
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ bool IRGeneratorForStatements::visit(InlineAssembly const& _assembly)
CopyTranslate bodyCopier{m_context, _assembly.dialect(), _assembly.annotation().externalReferences};
yul::Statement modified = bodyCopier(_assembly.operations().root());
solAssert(std::holds_alternative<yul::Block>(modified));
m_code << yul::AsmPrinter(yul::AsmPrinter::TypePrinting::Full, _assembly.dialect())(std::get<yul::Block>(modified)) << "\n";
m_code << yul::AsmPrinter()(std::get<yul::Block>(modified)) << "\n";
return false;
}

Expand Down
12 changes: 5 additions & 7 deletions libyul/AST.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@
namespace solidity::yul
{

using Type = YulName;

struct TypedName { langutil::DebugData::ConstPtr debugData; YulName name; Type type; };
using TypedNameList = std::vector<TypedName>;
struct NameWithDebugData { langutil::DebugData::ConstPtr debugData; YulName name; };
using NameWithDebugDataList = std::vector<NameWithDebugData>;

/// Literal number or string (up to 32 bytes)
enum class LiteralKind { Number, Boolean, String };
Expand Down Expand Up @@ -68,7 +66,7 @@ class LiteralValue {
std::optional<Data> m_numericValue;
std::shared_ptr<std::string> m_stringValue;
};
struct Literal { langutil::DebugData::ConstPtr debugData; LiteralKind kind; LiteralValue value; Type type; };
struct Literal { langutil::DebugData::ConstPtr debugData; LiteralKind kind; LiteralValue value; };
/// External / internal identifier or label reference
struct Identifier { langutil::DebugData::ConstPtr debugData; YulName name; };
/// Assignment ("x := mload(20:u256)", expects push-1-expression on the right hand
Expand All @@ -82,11 +80,11 @@ struct FunctionCall { langutil::DebugData::ConstPtr debugData; Identifier functi
/// Statement that contains only a single expression
struct ExpressionStatement { langutil::DebugData::ConstPtr debugData; Expression expression; };
/// Block-scope variable declaration ("let x:u256 := mload(20:u256)"), non-hoisted
struct VariableDeclaration { langutil::DebugData::ConstPtr debugData; TypedNameList variables; std::unique_ptr<Expression> value; };
struct VariableDeclaration { langutil::DebugData::ConstPtr debugData; NameWithDebugDataList variables; std::unique_ptr<Expression> value; };
/// Block that creates a scope (frees declared stack variables)
struct Block { langutil::DebugData::ConstPtr debugData; std::vector<Statement> statements; };
/// Function definition ("function f(a, b) -> (d, e) { ... }")
struct FunctionDefinition { langutil::DebugData::ConstPtr debugData; YulName name; TypedNameList parameters; TypedNameList returnVariables; Block body; };
struct FunctionDefinition { langutil::DebugData::ConstPtr debugData; YulName name; NameWithDebugDataList parameters; NameWithDebugDataList returnVariables; Block body; };
/// Conditional execution without "else" part.
struct If { langutil::DebugData::ConstPtr debugData; std::unique_ptr<Expression> condition; Block body; };
/// Switch case or default case
Expand Down
2 changes: 1 addition & 1 deletion libyul/ASTForward.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct ExpressionStatement;
struct Block;
class AST;

struct TypedName;
struct NameWithDebugData;

using Expression = std::variant<FunctionCall, Identifier, Literal>;
using Statement = std::variant<ExpressionStatement, Assignment, VariableDeclaration, FunctionDefinition, If, Switch, ForLoop, Break, Continue, Leave, Block>;
Expand Down
Loading