mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Low level named functions for CompilerContext.
This commit is contained in:
parent
dea59bfbdc
commit
d0e8d340a5
@ -125,6 +125,21 @@ Declaration const* CompilerContext::nextFunctionToCompile() const
|
|||||||
return m_functionCompilationQueue.nextFunctionToCompile();
|
return m_functionCompilationQueue.nextFunctionToCompile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eth::AssemblyItem const* CompilerContext::lowLevelFunctionEntryPoint(string const& _name) const
|
||||||
|
{
|
||||||
|
auto it = m_lowLevelFunctions.find(_name);
|
||||||
|
if (it == m_lowLevelFunctions.end())
|
||||||
|
return nullptr;
|
||||||
|
else
|
||||||
|
return *it;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CompilerContext::addLowLevelFunction(string const& _name, eth::AssemblyItem const& _label)
|
||||||
|
{
|
||||||
|
solAssert(lowLevelFunctionEntryPoint(_name) != nullptr, "Low level function with that name already exists.");
|
||||||
|
m_lowLevelFunctions[_name] = _label.pushTag();
|
||||||
|
}
|
||||||
|
|
||||||
ModifierDefinition const& CompilerContext::functionModifier(string const& _name) const
|
ModifierDefinition const& CompilerContext::functionModifier(string const& _name) const
|
||||||
{
|
{
|
||||||
solAssert(!m_inheritanceHierarchy.empty(), "No inheritance hierarchy set.");
|
solAssert(!m_inheritanceHierarchy.empty(), "No inheritance hierarchy set.");
|
||||||
|
@ -90,6 +90,12 @@ public:
|
|||||||
/// as "having code".
|
/// as "having code".
|
||||||
void startFunction(Declaration const& _function);
|
void startFunction(Declaration const& _function);
|
||||||
|
|
||||||
|
/// Returns the label of the low level function with the given name or nullptr if it
|
||||||
|
/// does not exist. The lifetime of the returned pointer is short.
|
||||||
|
eth::AssemblyItem const* lowLevelFunctionEntryPoint(std::string const& _name) const;
|
||||||
|
/// Inserts a low level function entry point into the list of low level functions.
|
||||||
|
void addLowLevelFunction(std::string const& _name, eth::AssemblyItem const& _label);
|
||||||
|
|
||||||
ModifierDefinition const& functionModifier(std::string const& _name) const;
|
ModifierDefinition const& functionModifier(std::string const& _name) const;
|
||||||
/// Returns the distance of the given local variable from the bottom of the stack (of the current function).
|
/// Returns the distance of the given local variable from the bottom of the stack (of the current function).
|
||||||
unsigned baseStackOffsetOfVariable(Declaration const& _declaration) const;
|
unsigned baseStackOffsetOfVariable(Declaration const& _declaration) const;
|
||||||
@ -248,6 +254,8 @@ private:
|
|||||||
CompilerContext *m_runtimeContext;
|
CompilerContext *m_runtimeContext;
|
||||||
/// The index of the runtime subroutine.
|
/// The index of the runtime subroutine.
|
||||||
size_t m_runtimeSub = -1;
|
size_t m_runtimeSub = -1;
|
||||||
|
/// An index of low-level function labels by name.
|
||||||
|
std::map<std::string, eth::AssemblyItem> m_lowLevelFunctions;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user