[Sol->Yul] Enabling creation function call

This commit is contained in:
Djordje Mijovic
2020-04-27 16:15:57 +02:00
parent 99aa821410
commit f3f729549d
36 changed files with 420 additions and 28 deletions
@@ -0,0 +1 @@
--ir-optimized --optimize
@@ -0,0 +1,7 @@
pragma solidity >=0.6.0;
contract C {
constructor() public {}
}
contract D is C {
}
@@ -0,0 +1,55 @@
Optimized IR:
/*******************************************************
* WARNING *
* Solidity to Yul compilation is still EXPERIMENTAL *
* It can result in LOSS OF FUNDS or worse *
* !USE AT YOUR OWN RISK! *
*******************************************************/
object "C_6" {
code {
{
mstore(64, 128)
if callvalue() { revert(0, 0) }
let _1 := datasize("C_6_deployed")
codecopy(0, dataoffset("C_6_deployed"), _1)
return(0, _1)
}
}
object "C_6_deployed" {
code {
{
mstore(64, 128)
revert(0, 0)
}
}
}
}
Optimized IR:
/*******************************************************
* WARNING *
* Solidity to Yul compilation is still EXPERIMENTAL *
* It can result in LOSS OF FUNDS or worse *
* !USE AT YOUR OWN RISK! *
*******************************************************/
object "D_9" {
code {
{
mstore(64, 128)
if callvalue() { revert(0, 0) }
let _1 := datasize("D_9_deployed")
codecopy(0, dataoffset("D_9_deployed"), _1)
return(0, _1)
}
}
object "D_9_deployed" {
code {
{
mstore(64, 128)
revert(0, 0)
}
}
}
}
@@ -0,0 +1 @@
--ir-optimized --optimize
@@ -0,0 +1,5 @@
Warning: Unused local variable.
--> ir_compiler_subobjects/input.sol:6:9:
|
6 | C c = new C();
| ^^^
@@ -0,0 +1,8 @@
pragma solidity >=0.6.0;
contract C {}
contract D {
function f() public {
C c = new C();
}
}
@@ -0,0 +1,96 @@
Optimized IR:
/*******************************************************
* WARNING *
* Solidity to Yul compilation is still EXPERIMENTAL *
* It can result in LOSS OF FUNDS or worse *
* !USE AT YOUR OWN RISK! *
*******************************************************/
object "C_2" {
code {
{
mstore(64, 128)
if callvalue() { revert(0, 0) }
let _1 := datasize("C_2_deployed")
codecopy(0, dataoffset("C_2_deployed"), _1)
return(0, _1)
}
}
object "C_2_deployed" {
code {
{
mstore(64, 128)
revert(0, 0)
}
}
}
}
Optimized IR:
/*******************************************************
* WARNING *
* Solidity to Yul compilation is still EXPERIMENTAL *
* It can result in LOSS OF FUNDS or worse *
* !USE AT YOUR OWN RISK! *
*******************************************************/
object "D_13" {
code {
{
mstore(64, 128)
if callvalue() { revert(0, 0) }
let _1 := datasize("D_13_deployed")
codecopy(0, dataoffset("D_13_deployed"), _1)
return(0, _1)
}
}
object "D_13_deployed" {
code {
{
mstore(64, 128)
if iszero(lt(calldatasize(), 4))
{
let _1 := 0
if eq(0x26121ff0, shr(224, calldataload(_1)))
{
if callvalue() { revert(_1, _1) }
if slt(add(calldatasize(), not(3)), _1) { revert(_1, _1) }
let _2 := datasize("C_2")
let _3 := add(128, _2)
if or(gt(_3, 0xffffffffffffffff), lt(_3, 128)) { revert(_1, _1) }
datacopy(128, dataoffset("C_2"), _2)
pop(create(_1, 128, _2))
return(allocateMemory(_1), _1)
}
}
revert(0, 0)
}
function allocateMemory(size) -> memPtr
{
memPtr := mload(64)
let newFreePtr := add(memPtr, size)
if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { revert(0, 0) }
mstore(64, newFreePtr)
}
}
object "C_2" {
code {
{
mstore(64, 128)
if callvalue() { revert(0, 0) }
let _1 := datasize("C_2_deployed")
codecopy(0, dataoffset("C_2_deployed"), _1)
return(0, _1)
}
}
object "C_2_deployed" {
code {
{
mstore(64, 128)
revert(0, 0)
}
}
}
}
}
}
@@ -76,7 +76,9 @@ object \"C_6\" {
}
}
}
}
"}}},"sources":{"A":{"id":0}}}
@@ -131,7 +131,9 @@ object \"C_10\" {
}
}
}
}
"}}},"sources":{"A":{"id":0}}}
@@ -99,7 +99,9 @@ object \"C_10\" {
}
}
}
}
"}}},"sources":{"A":{"id":0}}}
@@ -111,7 +111,9 @@ object \"C_10\" {
}
}
}
}
"}}},"sources":{"A":{"id":0}}}
@@ -135,7 +135,9 @@ object \"C_10\" {
}
}
}
}
"}}},"sources":{"A":{"id":0}}}
@@ -111,7 +111,9 @@ object \"C_10\" {
}
}
}
}
"}}},"sources":{"A":{"id":0}}}