Merge pull request #9293 from ethereum/yul-restrict-linkersymbol-to-object-dialect

[Yul] Restrict `linkersymbol` to object dialect and add missing changelog entries
This commit is contained in:
Daniel Kirchner 2020-07-03 11:37:21 +02:00 committed by GitHub
commit c0ee566049
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 11 deletions

View File

@ -2,6 +2,8 @@
Language Features: Language Features:
* General: Add unit denomination ``gwei`` * General: Add unit denomination ``gwei``
* Yul: Support ``linkersymbol`` builtin in standalone assembly mode.
* Yul: Support using string literals exceeding 32 bytes as literal arguments for builtins.
Compiler Features: Compiler Features:

View File

@ -124,19 +124,18 @@ map<YulString, BuiltinFunctionForEVM> createBuiltins(langutil::EVMVersion _evmVe
) )
builtins.emplace(createEVMFunction(instr.first, instr.second)); builtins.emplace(createEVMFunction(instr.first, instr.second));
builtins.emplace(createFunction("linkersymbol", 1, 1, SideEffects{}, {true}, [](
FunctionCall const& _call,
AbstractAssembly& _assembly,
BuiltinContext&,
function<void(Expression const&)>
) {
yulAssert(_call.arguments.size() == 1, "");
Expression const& arg = _call.arguments.front();
_assembly.appendLinkerSymbol(std::get<Literal>(arg).value.str());
}));
if (_objectAccess) if (_objectAccess)
{ {
builtins.emplace(createFunction("linkersymbol", 1, 1, SideEffects{}, {true}, [](
FunctionCall const& _call,
AbstractAssembly& _assembly,
BuiltinContext&,
function<void(Expression const&)>
) {
yulAssert(_call.arguments.size() == 1, "");
Expression const& arg = _call.arguments.front();
_assembly.appendLinkerSymbol(std::get<Literal>(arg).value.str());
}));
builtins.emplace(createFunction("datasize", 1, 1, SideEffects{}, {true}, []( builtins.emplace(createFunction("datasize", 1, 1, SideEffects{}, {true}, [](
FunctionCall const& _call, FunctionCall const& _call,
AbstractAssembly& _assembly, AbstractAssembly& _assembly,

View File

@ -0,0 +1,10 @@
contract C {
function f() public pure {
assembly {
pop(linkersymbol("contract/library.sol:L"))
}
}
}
// ----
// DeclarationError 4619: (67-79): Function not found.
// TypeError 3950: (67-105): Expected expression to evaluate to one value, but got 0 values instead.

View File

@ -0,0 +1,10 @@
contract C {
function f() public pure {
assembly {
function linkersymbol(a) {}
linkersymbol("contract/library.sol:L")
}
}
}
// ----