aboutsummaryrefslogtreecommitdiffstats
path: root/Compiler.cpp
diff options
context:
space:
mode:
authorChristian <c@ethdev.com>2015-01-16 03:04:24 +0800
committerChristian <c@ethdev.com>2015-01-20 06:35:04 +0800
commit4d833bc86bf10a685a8b5d72e90c49a24a33f8b3 (patch)
tree374e4529cd14685aa302dfda01e180f3bd51eba6 /Compiler.cpp
parente6c0a9b922a28001fcbdc4e4ee729659c987caef (diff)
downloaddexon-solidity-4d833bc86bf10a685a8b5d72e90c49a24a33f8b3.tar
dexon-solidity-4d833bc86bf10a685a8b5d72e90c49a24a33f8b3.tar.gz
dexon-solidity-4d833bc86bf10a685a8b5d72e90c49a24a33f8b3.tar.bz2
dexon-solidity-4d833bc86bf10a685a8b5d72e90c49a24a33f8b3.tar.lz
dexon-solidity-4d833bc86bf10a685a8b5d72e90c49a24a33f8b3.tar.xz
dexon-solidity-4d833bc86bf10a685a8b5d72e90c49a24a33f8b3.tar.zst
dexon-solidity-4d833bc86bf10a685a8b5d72e90c49a24a33f8b3.zip
Inheritance in compiler.
Diffstat (limited to 'Compiler.cpp')
-rw-r--r--Compiler.cpp24
1 files changed, 15 insertions, 9 deletions
diff --git a/Compiler.cpp b/Compiler.cpp
index d86c939c..aa3022aa 100644
--- a/Compiler.cpp
+++ b/Compiler.cpp
@@ -21,6 +21,7 @@
*/
#include <algorithm>
+#include <boost/range/adaptor/reversed.hpp>
#include <libevmcore/Instruction.h>
#include <libevmcore/Assembly.h>
#include <libsolidity/AST.h>
@@ -40,14 +41,16 @@ void Compiler::compileContract(ContractDefinition const& _contract,
m_context = CompilerContext(); // clear it just in case
initializeContext(_contract, _contracts);
- for (ASTPointer<FunctionDefinition> const& function: _contract.getDefinedFunctions())
- if (function->getName() != _contract.getName()) // don't add the constructor here
- m_context.addFunction(*function);
+ for (ContractDefinition const* contract: _contract.getLinearizedBaseContracts())
+ for (ASTPointer<FunctionDefinition> const& function: contract->getDefinedFunctions())
+ if (function->getName() != contract->getName()) // don't add the constructor here
+ m_context.addFunction(*function);
appendFunctionSelector(_contract);
- for (ASTPointer<FunctionDefinition> const& function: _contract.getDefinedFunctions())
- if (function->getName() != _contract.getName()) // don't add the constructor here
- function->accept(*this);
+ for (ContractDefinition const* contract: _contract.getLinearizedBaseContracts())
+ for (ASTPointer<FunctionDefinition> const& function: contract->getDefinedFunctions())
+ if (function->getName() != contract->getName()) // don't add the constructor here
+ function->accept(*this);
// Swap the runtime context with the creation-time context
swap(m_context, m_runtimeContext);
@@ -65,13 +68,16 @@ void Compiler::initializeContext(ContractDefinition const& _contract,
void Compiler::packIntoContractCreator(ContractDefinition const& _contract, CompilerContext const& _runtimeContext)
{
set<FunctionDefinition const*> neededFunctions;
+ // TODO constructors of base classes
FunctionDefinition const* constructor = _contract.getConstructor();
if (constructor)
neededFunctions = getFunctionsNeededByConstructor(*constructor);
+ // TODO we should add the overridden functions
for (FunctionDefinition const* fun: neededFunctions)
m_context.addFunction(*fun);
+ // we have many of them now
if (constructor)
appendConstructorCall(*constructor);
@@ -191,9 +197,9 @@ void Compiler::appendReturnValuePacker(FunctionDefinition const& _function)
void Compiler::registerStateVariables(ContractDefinition const& _contract)
{
- //@todo sort them?
- for (ASTPointer<VariableDeclaration> const& variable: _contract.getStateVariables())
- m_context.addStateVariable(*variable);
+ for (ContractDefinition const* contract: boost::adaptors::reverse(_contract.getLinearizedBaseContracts()))
+ for (ASTPointer<VariableDeclaration> const& variable: contract->getStateVariables())
+ m_context.addStateVariable(*variable);
}
bool Compiler::visit(FunctionDefinition const& _function)