StandardCompiler: Include file names in link references

This commit is contained in:
Kamil Śliwak
2020-11-17 17:51:04 +01:00
parent 9f0283df5c
commit 4174f38b02
7 changed files with 98 additions and 4 deletions
@@ -0,0 +1 @@
--strict-assembly --libraries library1.sol:L:0x1234567890123456789012345678901234567890
@@ -0,0 +1 @@
Warning: Yul is still experimental. Please use the output with care.
@@ -0,0 +1,6 @@
object "a" {
code {
let addr1 := linkersymbol("library1.sol:L")
let addr2 := linkersymbol("library2.sol:L")
}
}
@@ -0,0 +1,22 @@
======= linking_strict_assembly_same_library_name_different_files_in_link_references/input.yul (EVM) =======
Pretty printed source:
object "a" {
code {
let addr1 := linkersymbol("library1.sol:L")
let addr2 := linkersymbol("library2.sol:L")
}
}
Binary representation:
73123456789012345678901234567890123456789073__$c3523432985587641d17c68161d2f700c5$__5050
Text representation:
linkerSymbol("f3ffc10c396a7cc41ae954b050792839d20947bf73497d30c49a9fda1ea477ec")
/* "linking_strict_assembly_same_library_name_different_files_in_link_references/input.yul":32:75 */
linkerSymbol("c3523432985587641d17c68161d2f700c57aaf4ed21cda4f25d76193c831f97f")
/* "linking_strict_assembly_same_library_name_different_files_in_link_references/input.yul":22:133 */
pop
pop
+66 -2
View File
@@ -903,6 +903,38 @@ BOOST_AUTO_TEST_CASE(library_linking)
expectLinkReferences(contractResult, {{"library2.sol", {"L2"}}});
}
BOOST_AUTO_TEST_CASE(linking_yul)
{
char const* input = R"(
{
"language": "Yul",
"settings": {
"libraries": {
"fileB": {
"L": "0x4200000000000000000000000000000000000001"
}
},
"outputSelection": {
"fileA": {
"*": [
"evm.bytecode.linkReferences"
]
}
}
},
"sources": {
"fileA": {
"content": "object \"a\" { code { let addr := linkersymbol(\"fileB:L\") } }"
}
}
}
)";
Json::Value result = compile(input);
BOOST_TEST(containsAtMostWarnings(result));
Json::Value contractResult = getContractResult(result, "fileA", "a");
expectLinkReferences(contractResult, {});
}
BOOST_AUTO_TEST_CASE(linking_yul_empty_link_reference)
{
char const* input = R"(
@@ -932,7 +964,7 @@ BOOST_AUTO_TEST_CASE(linking_yul_empty_link_reference)
Json::Value result = compile(input);
BOOST_TEST(containsAtMostWarnings(result));
Json::Value contractResult = getContractResult(result, "fileA", "a");
expectLinkReferences(contractResult, {});
expectLinkReferences(contractResult, {{"", {""}}});
}
BOOST_AUTO_TEST_CASE(linking_yul_no_filename_in_link_reference)
@@ -964,7 +996,39 @@ BOOST_AUTO_TEST_CASE(linking_yul_no_filename_in_link_reference)
Json::Value result = compile(input);
BOOST_TEST(containsAtMostWarnings(result));
Json::Value contractResult = getContractResult(result, "fileA", "a");
expectLinkReferences(contractResult, {});
expectLinkReferences(contractResult, {{"", {"L"}}});
}
BOOST_AUTO_TEST_CASE(linking_yul_same_library_name_different_files)
{
char const* input = R"(
{
"language": "Yul",
"settings": {
"libraries": {
"fileB": {
"L": "0x4200000000000000000000000000000000000001"
}
},
"outputSelection": {
"fileA": {
"*": [
"evm.bytecode.linkReferences"
]
}
}
},
"sources": {
"fileA": {
"content": "object \"a\" { code { let addr := linkersymbol(\"fileC:L\") } }"
}
}
}
)";
Json::Value result = compile(input);
BOOST_TEST(containsAtMostWarnings(result));
Json::Value contractResult = getContractResult(result, "fileA", "a");
expectLinkReferences(contractResult, {{"fileC", {"L"}}});
}
BOOST_AUTO_TEST_CASE(evm_version)