Conversation
| if (m_julia) | ||
| { | ||
| Scope& rootScope = scope(&_block); | ||
| rootScope.registerFunction("abort", {}, {}); |
There was a problem hiding this comment.
Looked at making this into a vector but that looked just way more code than it needs to be.
There was a problem hiding this comment.
The following might work:
for (auto const& f: vector<tuple<string, strings, strings>>{
{"discardu256", { "u256" }, { }},
{"splitu256tou64", { "u256" }, { "u64", ... }},
...
})
rootScope.registerFunction(get<0>(f), get<1>(f), get<2>(f));
There was a problem hiding this comment.
I had the same code, but for some reason I got an error when providing the list as constructor parameters to the vector.
There was a problem hiding this comment.
We might want to write a small parsing function for something like keccak256(u256, u256) -> u256, then it is also much more readable.
There was a problem hiding this comment.
and parsing here would just consist of boost::split(s, "(") calls.
There was a problem hiding this comment.
That sounds like a better idea.
| rootScope.registerFunction("mulu256", { "u256", "u256" }, { "u256" }); | ||
| rootScope.registerFunction("divu256", { "u256", "u256" }, { "u256" }); | ||
| rootScope.registerFunction("modu256", { "u256", "u256" }, { "u256" }); | ||
| } |
There was a problem hiding this comment.
Needs to be updated with all the functions from #2129.
|
|
||
| m_assembly.setSourceLocation(_call.location); | ||
|
|
||
| if (_call.functionName.name == "abort") |
There was a problem hiding this comment.
This could be handled with a vector which lists the name, instruction, argument and return value count.
|
|
||
| m_assembly.setSourceLocation(_call.location); | ||
|
|
||
| if (m_builtinFunctions.count(_call.functionName.name)) |
There was a problem hiding this comment.
Can you combine this with functionalInstruction?
There was a problem hiding this comment.
Don't see a simple way which would keep it readable. Also note we have two different kinds of builtins:
- simple ones, which fit this scheme
- complex ones, which don't (such as split/combine)
For the second case it might be better to inject a FunctionDefinition.
c6d81cb to
4c1142e
Compare
2570a97 to
3f75966
Compare
3f75966 to
3c71937
Compare
| m_stackAdjustment(_stackAdjustment), | ||
| m_context(_context) | ||
| { | ||
| m_builtinFunctions["abort"] = solidity::Instruction::INVALID; |
There was a problem hiding this comment.
Should this really be a member or rather just a static variable in the cpp file?
There was a problem hiding this comment.
Statis variable should be fine.
|
Added a commit, please be careful when rebasing / pushing. |
b139d31 to
1ae77fc
Compare
|
Rebased and squashed commits. Need to add the proper list of builtin funcs and it is ready to merge. |
| { | ||
| auto openParen = find(sig.begin(), sig.end(), '('); | ||
| auto closeParen = find(openParen, sig.end(), ')'); | ||
| auto arrow = find(closeParen, sig.end(), '>'); |
There was a problem hiding this comment.
Should have some asserts for these three.
1ae77fc to
b069a39
Compare
|
Depends on finalising the builtin list in #2129. |
b069a39 to
bd07b24
Compare
|
Replaced by #5616 |
Depends on #3226 and #3238.