aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/codegen/CompilerContext.h
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2017-01-20 00:21:55 +0800
committerchriseth <c@ethdev.com>2017-01-24 19:06:40 +0800
commitb60623521f052b8a36c61f8632d868cac552bf29 (patch)
tree2d8b2bd51b3b052b89f17530e4e5399e40838d4d /libsolidity/codegen/CompilerContext.h
parentd0e8d340a53395de4c83e4e1d6ccf4c8eab5889a (diff)
downloaddexon-solidity-b60623521f052b8a36c61f8632d868cac552bf29.tar.gz
dexon-solidity-b60623521f052b8a36c61f8632d868cac552bf29.tar.zst
dexon-solidity-b60623521f052b8a36c61f8632d868cac552bf29.zip
Move some util functions to low-level functions.
Diffstat (limited to 'libsolidity/codegen/CompilerContext.h')
-rw-r--r--libsolidity/codegen/CompilerContext.h35
1 files changed, 24 insertions, 11 deletions
diff --git a/libsolidity/codegen/CompilerContext.h b/libsolidity/codegen/CompilerContext.h
index 34befc13..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,11 +94,18 @@ public:
/// as "having code".
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);
+ /// 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).
@@ -256,6 +267,8 @@ private:
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;
};
}