mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Use bool type in conditional simplifier and for loop condition into body.
This commit is contained in:
parent
a52c9af5b9
commit
a52305d3bd
@ -77,12 +77,7 @@ void ConditionalSimplifier::operator()(Block& _block)
|
|||||||
Assignment{
|
Assignment{
|
||||||
location,
|
location,
|
||||||
{Identifier{location, condition}},
|
{Identifier{location, condition}},
|
||||||
make_unique<Expression>(Literal{
|
make_unique<Expression>(m_dialect.zeroLiteralForType(m_dialect.boolType))
|
||||||
location,
|
|
||||||
LiteralKind::Number,
|
|
||||||
"0"_yulstring,
|
|
||||||
{}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -56,9 +56,9 @@ void ForLoopConditionIntoBody::operator()(ForLoop& _forLoop)
|
|||||||
_forLoop.condition = make_unique<Expression>(
|
_forLoop.condition = make_unique<Expression>(
|
||||||
Literal {
|
Literal {
|
||||||
loc,
|
loc,
|
||||||
LiteralKind::Number,
|
LiteralKind::Boolean,
|
||||||
"1"_yulstring,
|
"true"_yulstring,
|
||||||
{}
|
m_dialect.boolType
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
let y:bool := false
|
||||||
|
for {} true { } {
|
||||||
|
if y { break }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ====
|
||||||
|
// dialect: yul
|
||||||
|
// step: conditionalSimplifier
|
||||||
|
// ----
|
||||||
|
// {
|
||||||
|
// let y:bool := false
|
||||||
|
// for { } true { }
|
||||||
|
// {
|
||||||
|
// if y { break }
|
||||||
|
// y := false
|
||||||
|
// }
|
||||||
|
// }
|
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
let y:i32 := 0:i32
|
||||||
|
for {} true { } {
|
||||||
|
if y { break }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ====
|
||||||
|
// dialect: ewasm
|
||||||
|
// step: conditionalSimplifier
|
||||||
|
// ----
|
||||||
|
// {
|
||||||
|
// let y:i32 := 0:i32
|
||||||
|
// for { } true { }
|
||||||
|
// {
|
||||||
|
// if y { break }
|
||||||
|
// y := false
|
||||||
|
// }
|
||||||
|
// }
|
@ -19,7 +19,7 @@
|
|||||||
// { }
|
// { }
|
||||||
// for { } a { }
|
// for { } a { }
|
||||||
// { }
|
// { }
|
||||||
// for { } 1 { }
|
// for { } true { }
|
||||||
// {
|
// {
|
||||||
// if iszero(add(a, a)) { break }
|
// if iszero(add(a, a)) { break }
|
||||||
// }
|
// }
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
// step: forLoopConditionIntoBody
|
// step: forLoopConditionIntoBody
|
||||||
// ----
|
// ----
|
||||||
// {
|
// {
|
||||||
// for { let a := 1 } 1 { a := add(a, 1) }
|
// for { let a := 1 } true { a := add(a, 1) }
|
||||||
// {
|
// {
|
||||||
// if iszero(iszero(eq(a, 10))) { break }
|
// if iszero(iszero(eq(a, 10))) { break }
|
||||||
// }
|
// }
|
||||||
|
@ -19,16 +19,16 @@
|
|||||||
// {
|
// {
|
||||||
// let random := 42
|
// let random := 42
|
||||||
// for {
|
// for {
|
||||||
// for { let a := 1 } 1 { }
|
// for { let a := 1 } true { }
|
||||||
// {
|
// {
|
||||||
// if iszero(iszero(eq(a, 10))) { break }
|
// if iszero(iszero(eq(a, 10))) { break }
|
||||||
// a := add(a, 1)
|
// a := add(a, 1)
|
||||||
// }
|
// }
|
||||||
// let b := 1
|
// let b := 1
|
||||||
// }
|
// }
|
||||||
// 1
|
// true
|
||||||
// {
|
// {
|
||||||
// for { let c := 1 } 1 { c := add(c, 1) }
|
// for { let c := 1 } true { c := add(c, 1) }
|
||||||
// {
|
// {
|
||||||
// if iszero(iszero(eq(c, 2))) { break }
|
// if iszero(iszero(eq(c, 2))) { break }
|
||||||
// b := add(b, 1)
|
// b := add(b, 1)
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
// ----
|
// ----
|
||||||
// {
|
// {
|
||||||
// let random := 42
|
// let random := 42
|
||||||
// for { let a := 1 } 1 { a := add(a, 1) }
|
// for { let a := 1 } true { a := add(a, 1) }
|
||||||
// {
|
// {
|
||||||
// if iszero(iszero(eq(a, 10))) { break }
|
// if iszero(iszero(eq(a, 10))) { break }
|
||||||
// a := add(a, 1)
|
// a := add(a, 1)
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
// {
|
// {
|
||||||
// let _1 := iszero(caller())
|
// let _1 := iszero(caller())
|
||||||
// for { }
|
// for { }
|
||||||
// 1
|
// true
|
||||||
// {
|
// {
|
||||||
// for { } iszero(_1) { }
|
// for { } iszero(_1) { }
|
||||||
// { }
|
// { }
|
||||||
|
Loading…
Reference in New Issue
Block a user