2019-07-09 12:06:33 +00:00
|
|
|
object "main" {
|
|
|
|
code {
|
|
|
|
// Arguments to ``datasize`` and ``dataoffset`` need to be
|
|
|
|
// literals. We cannot simplify their arguments, but we can
|
|
|
|
// simplify them as a full expression.
|
|
|
|
// ``datacopy`` does not have this restriction.
|
|
|
|
let r := "abc"
|
|
|
|
let a := datasize("abc")
|
|
|
|
let x := dataoffset("abc")
|
|
|
|
// should be replaced by a
|
|
|
|
let y := datasize("abc")
|
|
|
|
datacopy("abc", x, y)
|
|
|
|
mstore(a, x)
|
|
|
|
}
|
|
|
|
data "abc" "Hello, World!"
|
2018-12-20 16:39:52 +00:00
|
|
|
}
|
|
|
|
// ----
|
2020-03-17 22:31:56 +00:00
|
|
|
// step: commonSubexpressionEliminator
|
|
|
|
//
|
2020-08-04 23:32:18 +00:00
|
|
|
// object "main" {
|
|
|
|
// code {
|
|
|
|
// let r := "abc"
|
|
|
|
// let a := datasize("abc")
|
|
|
|
// let x := dataoffset("abc")
|
|
|
|
// let y := a
|
|
|
|
// datacopy(r, x, a)
|
|
|
|
// mstore(a, x)
|
|
|
|
// }
|
|
|
|
// data "abc" hex"48656c6c6f2c20576f726c6421"
|
2018-12-20 16:39:52 +00:00
|
|
|
// }
|