aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/codegen/CompilerContext.h
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-01-25 00:37:22 +0800
committerGitHub <noreply@github.com>2017-01-25 00:37:22 +0800
commit3dc83aa34e83d668cde82953f9efa94ebb7de8ed (patch)
tree06013ebd774f99584be9ca09c22feac010ebc2c7 /libsolidity/codegen/CompilerContext.h
parent29dab03ec8b595fc25e010bd8b60b2e280d0ebed (diff)
parent7e6f1b3f0008d03e6cdfa186b8f9976570865d4e (diff)
downloaddexon-solidity-3dc83aa34e83d668cde82953f9efa94ebb7de8ed.tar
dexon-solidity-3dc83aa34e83d668cde82953f9efa94ebb7de8ed.tar.gz
dexon-solidity-3dc83aa34e83d668cde82953f9efa94ebb7de8ed.tar.bz2
dexon-solidity-3dc83aa34e83d668cde82953f9efa94ebb7de8ed.tar.lz
dexon-solidity-3dc83aa34e83d668cde82953f9efa94ebb7de8ed.tar.xz
dexon-solidity-3dc83aa34e83d668cde82953f9efa94ebb7de8ed.tar.zst
dexon-solidity-3dc83aa34e83d668cde82953f9efa94ebb7de8ed.zip
Merge pull request #1588 from ethereum/fixrecursivestructs
Introduce low-level functions
Diffstat (limited to 'libsolidity/codegen/CompilerContext.h')
-rw-r--r--libsolidity/codegen/CompilerContext.h33
1 files changed, 27 insertions, 6 deletions
diff --git a/libsolidity/codegen/CompilerContext.h b/libsolidity/codegen/CompilerContext.h
index 80671528..f024b010 100644
--- a/libsolidity/codegen/CompilerContext.h
+++ b/libsolidity/codegen/CompilerContext.h
@@ -22,17 +22,21 @@
#pragma once
-#include <ostream>
-#include <stack>
-#include <queue>
-#include <utility>
-#include <libevmasm/Instruction.h>
-#include <libevmasm/Assembly.h>
#include <libsolidity/ast/ASTForward.h>
#include <libsolidity/ast/Types.h>
#include <libsolidity/ast/ASTAnnotations.h>
+
+#include <libevmasm/Instruction.h>
+#include <libevmasm/Assembly.h>
+
#include <libdevcore/Common.h>
+#include <ostream>
+#include <stack>
+#include <queue>
+#include <utility>
+#include <functional>
+
namespace dev {
namespace solidity {
@@ -90,6 +94,19 @@ public:
/// as "having code".
void startFunction(Declaration const& _function);
+ /// Appends a call to the named low-level function and inserts the generator into the
+ /// list of low-level-functions to be generated, unless it already exists.
+ /// Note that the generator should not assume that objects are still alive when it is called,
+ /// unless they are guaranteed to be alive for the whole run of the compiler (AST nodes, for example).
+ void callLowLevelFunction(
+ std::string const& _name,
+ unsigned _inArgs,
+ unsigned _outArgs,
+ std::function<void(CompilerContext&)> const& _generator
+ );
+ /// Generates the code for missing low-level functions, i.e. calls the generators passed above.
+ void appendMissingLowLevelFunctions();
+
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).
unsigned baseStackOffsetOfVariable(Declaration const& _declaration) const;
@@ -248,6 +265,10 @@ private:
CompilerContext *m_runtimeContext;
/// The index of the runtime subroutine.
size_t m_runtimeSub = -1;
+ /// An index of low-level function labels by name.
+ std::map<std::string, eth::AssemblyItem> m_lowLevelFunctions;
+ /// The queue of low-level functions to generate.
+ std::queue<std::tuple<std::string, unsigned, unsigned, std::function<void(CompilerContext&)>>> m_lowLevelFunctionGenerationQueue;
};
}