aboutsummaryrefslogtreecommitdiffstats
path: root/CompilerContext.h
diff options
context:
space:
mode:
authorChristian <c@ethdev.com>2014-11-10 20:30:59 +0800
committerChristian <c@ethdev.com>2014-11-10 20:30:59 +0800
commita0c72065fee89c4558eeb4a98e5273633635bc39 (patch)
treed9629fd7a81f46b76d82086a211de831c19657b3 /CompilerContext.h
parentdc8fb45e1f1d098442458f14d80c343e4a445619 (diff)
parentd9822190c6fb3ac5025296c0f47977cca9547b91 (diff)
downloaddexon-solidity-a0c72065fee89c4558eeb4a98e5273633635bc39.tar.gz
dexon-solidity-a0c72065fee89c4558eeb4a98e5273633635bc39.tar.zst
dexon-solidity-a0c72065fee89c4558eeb4a98e5273633635bc39.zip
Merge remote-tracking branch 'ethereum/develop' into sol_optimizer
Conflicts: libevmcore/Instruction.cpp
Diffstat (limited to 'CompilerContext.h')
-rw-r--r--CompilerContext.h25
1 files changed, 19 insertions, 6 deletions
diff --git a/CompilerContext.h b/CompilerContext.h
index 866c621d..562c2932 100644
--- a/CompilerContext.h
+++ b/CompilerContext.h
@@ -38,19 +38,28 @@ namespace solidity {
class CompilerContext
{
public:
- CompilerContext() {}
+ CompilerContext(): m_stateVariablesSize(0) {}
+ void addStateVariable(VariableDeclaration const& _declaration);
void startNewFunction() { m_localVariables.clear(); m_asm.setDeposit(0); }
void initializeLocalVariables(unsigned _numVariables);
void addVariable(VariableDeclaration const& _declaration) { m_localVariables.push_back(&_declaration); }
- /// Returns the distance of the given local variable from the top of the stack.
- int getStackPositionOfVariable(Declaration const& _declaration);
-
void addFunction(FunctionDefinition const& _function) { m_functionEntryLabels.insert(std::make_pair(&_function, m_asm.newTag())); }
- eth::AssemblyItem getFunctionEntryLabel(FunctionDefinition const& _function) const;
void adjustStackOffset(int _adjustment) { m_asm.adjustDeposit(_adjustment); }
+ bool isFunctionDefinition(Declaration const* _declaration) const { return m_functionEntryLabels.count(_declaration); }
+ bool isLocalVariable(Declaration const* _declaration) const;
+ bool isStateVariable(Declaration const* _declaration) const { return m_stateVariables.count(_declaration); }
+
+ eth::AssemblyItem getFunctionEntryLabel(FunctionDefinition const& _function) const;
+ /// Returns the distance of the given local variable from the top of the local variable stack.
+ unsigned getBaseStackOffsetOfVariable(Declaration const& _declaration) const;
+ /// If supplied by a value returned by @ref getBaseStackOffsetOfVariable(variable), returns
+ /// the distance of that variable from the current top of the stack.
+ unsigned baseToCurrentStackOffset(unsigned _baseOffset) const;
+ u256 getStorageLocationOfVariable(Declaration const& _declaration) const;
+
/// Appends a JUMPI instruction to a new tag and @returns the tag
eth::AssemblyItem appendConditionalJump() { return m_asm.appendJumpI().tag(); }
/// Appends a JUMPI instruction to @a _tag
@@ -79,10 +88,14 @@ public:
private:
eth::Assembly m_asm;
+ /// Size of the state variables, offset of next variable to be added.
+ u256 m_stateVariablesSize;
+ /// Storage offsets of state variables
+ std::map<Declaration const*, u256> m_stateVariables;
/// Offsets of local variables on the stack.
std::vector<Declaration const*> m_localVariables;
/// Labels pointing to the entry points of funcitons.
- std::map<FunctionDefinition const*, eth::AssemblyItem> m_functionEntryLabels;
+ std::map<Declaration const*, eth::AssemblyItem> m_functionEntryLabels;
};
}