aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/codegen/CompilerContext.h
diff options
context:
space:
mode:
authorYoichi Hirai <i@yoichihirai.com>2016-11-08 22:25:32 +0800
committerchriseth <c@ethdev.com>2016-11-16 21:37:18 +0800
commitc9f9b2ab4d421e99055425ace5deeb76d8f4fdd2 (patch)
tree3ac98a19b929334a70d6ed47551b36d41a0f6a62 /libsolidity/codegen/CompilerContext.h
parent5011d6339a185a55d6cdc3e952dea7bdd14a2ff7 (diff)
downloaddexon-solidity-c9f9b2ab4d421e99055425ace5deeb76d8f4fdd2.tar.gz
dexon-solidity-c9f9b2ab4d421e99055425ace5deeb76d8f4fdd2.tar.zst
dexon-solidity-c9f9b2ab4d421e99055425ace5deeb76d8f4fdd2.zip
codegen: add a compilation mode and a runtime context to CompilerContext
Diffstat (limited to 'libsolidity/codegen/CompilerContext.h')
-rw-r--r--libsolidity/codegen/CompilerContext.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/libsolidity/codegen/CompilerContext.h b/libsolidity/codegen/CompilerContext.h
index 6c509685..8b95c9f5 100644
--- a/libsolidity/codegen/CompilerContext.h
+++ b/libsolidity/codegen/CompilerContext.h
@@ -37,6 +37,10 @@ namespace dev {
namespace solidity {
+/// Depending on the compilation is on the runtime code or the creation code,
+/// the interpretation of internal function values differ.
+enum class CompilationMode { Runtime, Creation };
+
/**
* Context to be shared by all units that compile the same contract.
* It stores the generated bytecode and the position of identifiers in memory and on the stack.
@@ -44,6 +48,13 @@ namespace solidity {
class CompilerContext
{
public:
+ CompilerContext(CompilationMode _mode, CompilerContext* _runtimeContext = nullptr) :
+ m_mode(_mode), m_runtimeContext(_runtimeContext)
+ {
+ solAssert(m_mode != CompilationMode::Runtime || !m_runtimeContext, "runtime but another runtime context provided");
+ solAssert(m_mode != CompilationMode::Creation || m_runtimeContext, "creation but no runtime context provided");
+ }
+
bool isCreationPhase() const { return m_mode == CompilationMode::Creation; }
void addMagicGlobal(MagicVariableDeclaration const& _declaration);
@@ -230,6 +241,10 @@ private:
std::vector<ContractDefinition const*> m_inheritanceHierarchy;
/// Stack of current visited AST nodes, used for location attachment
std::stack<ASTNode const*> m_visitedNodes;
+ /// The current mode of the compilation
+ CompilationMode m_mode;
+ /// The runtime context if in Creation mode, this is used for generating tags that would be stored into the storage and then used at runtime.
+ CompilerContext *m_runtimeContext;
};
}