aboutsummaryrefslogtreecommitdiffstats
path: root/libjulia/backends/evm/EVMCodeTransform.h
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-06-14 03:58:25 +0800
committerchriseth <chris@ethereum.org>2017-06-14 04:01:15 +0800
commit45d96959f88e951af0e2ccf0217f19d75da66ed1 (patch)
tree428838dc48662743ed8eeff035d6184786efbbcf /libjulia/backends/evm/EVMCodeTransform.h
parent3699d27cc928c6beaef77e4990dacd786469d606 (diff)
downloaddexon-solidity-45d96959f88e951af0e2ccf0217f19d75da66ed1.tar
dexon-solidity-45d96959f88e951af0e2ccf0217f19d75da66ed1.tar.gz
dexon-solidity-45d96959f88e951af0e2ccf0217f19d75da66ed1.tar.bz2
dexon-solidity-45d96959f88e951af0e2ccf0217f19d75da66ed1.tar.lz
dexon-solidity-45d96959f88e951af0e2ccf0217f19d75da66ed1.tar.xz
dexon-solidity-45d96959f88e951af0e2ccf0217f19d75da66ed1.tar.zst
dexon-solidity-45d96959f88e951af0e2ccf0217f19d75da66ed1.zip
Move LabelIDs to generation phase.
Diffstat (limited to 'libjulia/backends/evm/EVMCodeTransform.h')
-rw-r--r--libjulia/backends/evm/EVMCodeTransform.h29
1 files changed, 23 insertions, 6 deletions
diff --git a/libjulia/backends/evm/EVMCodeTransform.h b/libjulia/backends/evm/EVMCodeTransform.h
index f65948dc..57781c91 100644
--- a/libjulia/backends/evm/EVMCodeTransform.h
+++ b/libjulia/backends/evm/EVMCodeTransform.h
@@ -64,7 +64,14 @@ public:
solidity::assembly::AsmAnalysisInfo& _analysisInfo,
bool _evm15 = false,
ExternalIdentifierAccess const& _identifierAccess = ExternalIdentifierAccess()
- ): CodeTransform(_assembly, _analysisInfo, _evm15, _identifierAccess, _assembly.stackHeight())
+ ): CodeTransform(
+ _assembly,
+ _analysisInfo,
+ _evm15,
+ _identifierAccess,
+ _assembly.stackHeight(),
+ std::make_shared<Context>()
+ )
{
}
@@ -72,18 +79,26 @@ public:
void run(solidity::assembly::Block const& _block);
protected:
+ struct Context
+ {
+ std::map<solidity::assembly::Scope::Label const*, AbstractAssembly::LabelID> labelIDs;
+ std::map<solidity::assembly::Scope::Function const*, AbstractAssembly::LabelID> functionEntryIDs;
+ };
+
CodeTransform(
julia::AbstractAssembly& _assembly,
solidity::assembly::AsmAnalysisInfo& _analysisInfo,
bool _evm15,
ExternalIdentifierAccess const& _identifierAccess,
- int _stackAdjustment
+ int _stackAdjustment,
+ std::shared_ptr<Context> _context
):
m_assembly(_assembly),
m_info(_analysisInfo),
m_evm15(_evm15),
m_identifierAccess(_identifierAccess),
- m_stackAdjustment(_stackAdjustment)
+ m_stackAdjustment(_stackAdjustment),
+ m_context(_context)
{}
public:
@@ -102,6 +117,10 @@ public:
private:
AbstractAssembly::LabelID labelFromIdentifier(solidity::assembly::Identifier const& _identifier);
+ /// @returns the label ID corresponding to the given label, allocating a new one if
+ /// necessary.
+ AbstractAssembly::LabelID labelID(solidity::assembly::Scope::Label const& _label);
+ AbstractAssembly::LabelID functionEntryID(solidity::assembly::Scope::Function const& _function);
/// Generates code for an expression that is supposed to return a single value.
void visitExpression(solidity::assembly::Statement const& _expression);
@@ -116,9 +135,6 @@ private:
void checkStackHeight(void const* _astElement);
- /// Assigns the label's or function's id to a value taken from eth::Assembly if it has not yet been set.
- void assignLabelIdIfUnset(boost::optional<AbstractAssembly::LabelID>& _labelId);
-
julia::AbstractAssembly& m_assembly;
solidity::assembly::AsmAnalysisInfo& m_info;
solidity::assembly::Scope* m_scope = nullptr;
@@ -129,6 +145,7 @@ private:
/// for inline assembly and different stack heights depending on the EVM backend used
/// (EVM 1.0 or 1.5).
int m_stackAdjustment = 0;
+ std::shared_ptr<Context> m_context;
};
}