Allow calling internal functions of libraries.

Internal functions of libraries can be called as if the library were a
base contract of the calling contract. As the calling convention for
internal functions is to not create a new call context, the code of
these functions will be pulled into the context of the caller,
duplicating their code. This might pull in code of further internal or
even private functions.

The use case for such functions is to allow libraries which can operate
on memory types such that these types can also be modified in place.
This commit is contained in:
chriseth committed 2016-05-03 22:41:18 +02:00
1 parent aa4dcbb88c
commit 7ea3d950d7
5 files changed
+193 -59

No files matched your search

+6
View File
@@ -91,6 +91,12 @@ eth::AssemblyItem CompilerContext::functionEntryLabelIfExists(Declaration const&
eth::AssemblyItem CompilerContext::virtualFunctionEntryLabel(FunctionDefinition const& _function)
{
// Libraries do not allow inheritance and their functions can be inlined, so we should not
// search the inheritance hierarchy (which will be the wrong one in case the function
// is inlined).
if (auto scope = dynamic_cast<ContractDefinition const*>(_function.scope()))
if (scope->isLibrary())
return functionEntryLabel(_function);
solAssert(!m_inheritanceHierarchy.empty(), "No inheritance hierarchy set.");
return virtualFunctionEntryLabel(_function, m_inheritanceHierarchy.begin());
}