Skip to content

Commit

Permalink
Yul: remove deprecated dialect
Browse files Browse the repository at this point in the history
  • Loading branch information
clonker committed Aug 12, 2024
1 parent 55a5fd9 commit 44e008b
Show file tree
Hide file tree
Showing 34 changed files with 43 additions and 91 deletions.
28 changes: 0 additions & 28 deletions libyul/Dialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,31 +48,3 @@ bool Dialect::validTypeForLiteral(LiteralKind _kind, LiteralValue const&, YulNam
else
return true;
}

Dialect const& Dialect::yulDeprecated()
{
static std::unique_ptr<Dialect> dialect;
static YulStringRepository::ResetCallback callback{[&] { dialect.reset(); }};

if (!dialect)
{
// TODO will probably change, especially the list of types.
dialect = std::make_unique<Dialect>();
dialect->defaultType = "u256"_yulname;
dialect->boolType = "bool"_yulname;
dialect->types = {
"bool"_yulname,
"u8"_yulname,
"s8"_yulname,
"u32"_yulname,
"s32"_yulname,
"u64"_yulname,
"s64"_yulname,
"u128"_yulname,
"s128"_yulname,
"u256"_yulname,
"s256"_yulname};
};

return *dialect;
}
3 changes: 0 additions & 3 deletions libyul/Dialect.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@ struct Dialect

Dialect() = default;
virtual ~Dialect() = default;

/// Old "yul" dialect. This is only used for testing.
static Dialect const& yulDeprecated();
};

}
4 changes: 2 additions & 2 deletions libyul/YulStack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ Dialect const& languageToDialect(YulStack::Language _language, EVMVersion _versi
case YulStack::Language::Yul:
return EVMDialectTyped::instance(_version);
}
yulAssert(false, "");
return Dialect::yulDeprecated();
yulAssert(false);
util::unreachable();
}

}
Expand Down
11 changes: 3 additions & 8 deletions test/libyul/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ using namespace solidity::langutil;

namespace
{
Dialect const& defaultDialect(bool _yul)
Dialect const& defaultDialect()
{
return _yul ? yul::Dialect::yulDeprecated() : yul::EVMDialect::strictAssemblyForEVM(solidity::test::CommonOptions::get().evmVersion());
return yul::EVMDialect::strictAssemblyForEVM(solidity::test::CommonOptions::get().evmVersion());
}
}

Expand Down Expand Up @@ -91,7 +91,7 @@ std::pair<std::shared_ptr<Object>, std::shared_ptr<yul::AsmAnalysisInfo>> yul::t
yul::Block yul::test::disambiguate(std::string const& _source, bool _yul)
{
auto result = parse(_source, _yul);
return std::get<Block>(Disambiguator(defaultDialect(_yul), *result.second, {})(result.first->root()));
return std::get<Block>(Disambiguator(defaultDialect(), *result.second, {})(result.first->root()));
}

std::string yul::test::format(std::string const& _source, bool _yul)
Expand All @@ -113,11 +113,6 @@ std::map<std::string const, yul::Dialect const& (*)(langutil::EVMVersion)> const
"evmTyped",
[](langutil::EVMVersion _evmVersion) -> yul::Dialect const&
{ return yul::EVMDialectTyped::instance(_evmVersion); }
},
{
"yul",
[](langutil::EVMVersion) -> yul::Dialect const&
{ return yul::Dialect::yulDeprecated(); }
}
};

Expand Down
4 changes: 2 additions & 2 deletions test/libyul/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ std::optional<Error> parseAndReturnFirstError(std::string const& _source, Dialec
return {};
}

bool successParse(std::string const& _source, Dialect const& _dialect = Dialect::yulDeprecated(), bool _allowWarningsAndInfos = true)
bool successParse(std::string const& _source, Dialect const& _dialect, bool _allowWarningsAndInfos = true)
{
return !parseAndReturnFirstError(_source, _dialect, _allowWarningsAndInfos);
}

Error expectError(std::string const& _source, Dialect const& _dialect = Dialect::yulDeprecated(), bool _allowWarningsAndInfos = false)
Error expectError(std::string const& _source, Dialect const& _dialect, bool _allowWarningsAndInfos = false)
{

auto error = parseAndReturnFirstError(_source, _dialect, _allowWarningsAndInfos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
}
}
// ====
// dialect: yul
// dialect: evmTyped
// ----
// step: conditionalSimplifier
//
Expand Down
10 changes: 5 additions & 5 deletions test/libyul/yulOptimizerTests/disambiguator/for_statement.yul
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{
{ let a:u256, b:u256 }
{
function eq(x: u256, y: u256) -> z: bool {}
for { let a:u256 } eq(a, a) { a := a } {
function eq_function(x: u256, y: u256) -> z: bool {}
for { let a:u256 } eq_function(a, a) { a := a } {
let b:u256 := a
}
}
}
// ====
// dialect: yul
// dialect: evmTyped
// ----
// step: disambiguator
//
// {
// { let a, b }
// {
// function eq(x, y) -> z:bool
// function eq_function(x, y) -> z:bool
// { }
// for { let a_1 } eq(a_1, a_1) { a_1 := a_1 }
// for { let a_1 } eq_function(a_1, a_1) { a_1 := a_1 }
// { let b_2 := a_1 }
// }
// }
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
}
// ====
// dialect: yul
// dialect: evmTyped
// ----
// step: disambiguator
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
}
}
// ====
// dialect: yul
// dialect: evmTyped
// ----
// step: disambiguator
//
Expand Down
2 changes: 1 addition & 1 deletion test/libyul/yulOptimizerTests/disambiguator/long_names.yul
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ { let aanteuhdaoneudbrgkjiuaothduiathudaoeuh:u256 } { let aanteuhdaoneudbrgkjiuaothduiathudaoeuh:u256 } }
// ====
// dialect: yul
// dialect: evmTyped
// ----
// step: disambiguator
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ }
// ====
// dialect: yul
// dialect: evmTyped
// ----
// step: disambiguator
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
}
}
// ====
// dialect: yul
// dialect: evmTyped
// ----
// step: disambiguator
//
Expand Down
2 changes: 1 addition & 1 deletion test/libyul/yulOptimizerTests/disambiguator/variables.yul
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ { let a:u256 } { let a:u256 } }
// ====
// dialect: yul
// dialect: evmTyped
// ----
// step: disambiguator
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ { let a:u256 let a_1:u256 } { let a:u256 } }
// ====
// dialect: yul
// dialect: evmTyped
// ----
// step: disambiguator
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
}
}
// ====
// dialect: yul
// dialect: evmTyped
// ----
// step: disambiguator
//
Expand Down
2 changes: 1 addition & 1 deletion test/libyul/yulOptimizerTests/expressionInliner/simple.yul
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
let y:u256 := f()
}
// ====
// dialect: yul
// dialect: evmTyped
// ----
// step: expressionInliner
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
let y:u256 := f(7:u256)
}
// ====
// dialect: yul
// dialect: evmTyped
// ----
// step: expressionInliner
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ let a:u256 { } function f() -> x:bool { let b:u256 := 4:u256 {} for {} f() {} {} } }
// ====
// dialect: yul
// dialect: evmTyped
// ----
// step: functionGrouper
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
let e:u256
}
// ====
// dialect: yul
// dialect: evmTyped
// ----
// step: functionGrouper
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
}
}
// ====
// dialect: yul
// dialect: evmTyped
// ----
// step: functionGrouper
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
let a:u256 function f() {}
}
// ====
// dialect: yul
// dialect: evmTyped
// ----
// step: functionGrouper
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
}
}
// ====
// dialect: yul
// dialect: evmTyped
// ----
// step: functionHoister
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
let e:u256
}
// ====
// dialect: yul
// dialect: evmTyped
// ----
// step: functionHoister
//
Expand Down
2 changes: 1 addition & 1 deletion test/libyul/yulOptimizerTests/functionHoister/nested.yul
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
}
// ====
// dialect: yul
// dialect: evmTyped
// ----
// step: functionHoister
//
Expand Down
2 changes: 1 addition & 1 deletion test/libyul/yulOptimizerTests/functionHoister/single.yul
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
function f() {}
}
// ====
// dialect: yul
// dialect: evmTyped
// ----
// step: functionHoister
//
Expand Down
13 changes: 2 additions & 11 deletions test/libyul/yulSyntaxTests/builtin_types.yul
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
{
let x1:bool := true:bool
let x2:u8 := 1:u8
let x3:s8 := 1:s8
let x4:u32 := 1:u32
let x5:s32 := 1:s32
let x6:u64 := 1:u64
let x7:s64 := 1:s64
let x8:u128 := 1:u128
let x9:s128 := 1:s128
let x10:u256 := 1:u256
let x11:s256 := 1:s256
let x2:u256 := 1:u256
}
// ====
// dialect: yul
// dialect: evmTyped
// ----
2 changes: 1 addition & 1 deletion test/libyul/yulSyntaxTests/for_visibility_9.yul
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
for { let x := 1 } 1 { let x := 1 } {}
}
// ====
// dialect: yul
// dialect: evmTyped
// ----
// DeclarationError 1395: (26-36): Variable name x already taken in this scope.
2 changes: 1 addition & 1 deletion test/libyul/yulSyntaxTests/for_visibility_A.yul
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
for { let x := 1 } 1 {} { let x := 1 }
}
// ====
// dialect: yul
// dialect: evm
// ----
// DeclarationError 1395: (29-39): Variable name x already taken in this scope.
2 changes: 1 addition & 1 deletion test/libyul/yulSyntaxTests/if_statement_invalid_3.yul
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
if 32 let x := 3
}
// ====
// dialect: yul
// dialect: evm
// ----
// ParserError 2314: (12-15): Expected '{' but got reserved keyword 'let'
2 changes: 1 addition & 1 deletion test/libyul/yulSyntaxTests/instructions.yul
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ pop }
// ====
// dialect: yul
// dialect: evm
// ----
// ParserError 6913: (6-7): Call or assignment expected.
2 changes: 1 addition & 1 deletion test/libyul/yulSyntaxTests/optional_types.yul
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
function g(a:u256) -> b {}
}
// ====
// dialect: yul
// dialect: evmTyped
// ----
5 changes: 1 addition & 4 deletions test/libyul/yulSyntaxTests/token_as_identifier.yul
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
let return:u256 := 1:u256
let byte:u256 := 1:u256
let address:u256 := 1:u256
let bool:u256 := 1:u256
}
// ====
// dialect: yul
// dialect: evmTyped
// ----
2 changes: 1 addition & 1 deletion test/libyul/yulSyntaxTests/vardecl.yul
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
let x := 7
}
// ====
// dialect: yul
// dialect: evm
// ----
6 changes: 3 additions & 3 deletions test/libyul/yulSyntaxTests/variable_declaration_complex.yul
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
function add(a:u256, b:u256) -> c:u256 {}
function add_fn(a:u256, b:u256) -> c:u256 {}
let y:u256 := 2:u256
let x:u256 := add(7:u256, add(6:u256, y))
let x:u256 := add_fn(7:u256, add_fn(6:u256, y))
}
// ====
// dialect: yul
// dialect: evmTyped
// ----

0 comments on commit 44e008b

Please sign in to comment.