aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AST.cpp2
-rw-r--r--Compiler.cpp40
-rw-r--r--Compiler.h2
3 files changed, 35 insertions, 9 deletions
diff --git a/AST.cpp b/AST.cpp
index 38adebf9..bf3d9894 100644
--- a/AST.cpp
+++ b/AST.cpp
@@ -151,7 +151,7 @@ vector<tuple<FixedHash<4>, std::shared_ptr<FunctionType const>, Declaration cons
{
functionsSeen.insert(f->getName());
FixedHash<4> hash(dev::sha3(f->getCanonicalSignature()));
- m_interfaceFunctionList->push_back(make_tuple(hash, make_shared<FunctionType>(*f), f.get()));
+ m_interfaceFunctionList->push_back(make_tuple(hash, make_shared<FunctionType>(*f, false), f.get()));
}
for (ASTPointer<VariableDeclaration> const& v: contract->getStateVariables())
diff --git a/Compiler.cpp b/Compiler.cpp
index 28a9b3d1..c419f484 100644
--- a/Compiler.cpp
+++ b/Compiler.cpp
@@ -43,23 +43,30 @@ void Compiler::compileContract(ContractDefinition const& _contract,
for (ContractDefinition const* contract: _contract.getLinearizedBaseContracts())
{
- for (auto const& it: contract->getInterfaceFunctions())
- {
- auto funcDef = it.second.getFunctionDefinition();
- if (funcDef && funcDef->isConstructor())
- continue;
- m_context.addFunction(*it.second.getDeclaration());
- }
- for (ASTPointer<ModifierDefinition> const& modifier: contract->getFunctionModifiers())
+ for (ASTPointer<FunctionDefinition> const& function: contract->getDefinedFunctions())
+ if (!function->isConstructor())
+ m_context.addFunction(*function);
+
+ for (ASTPointer<VariableDeclaration> const& vardecl: contract->getStateVariables())
+ if (vardecl->isPublic())
+ m_context.addFunction(*vardecl);
+
+ for (ASTPointer<ModifierDefinition> const& modifier: contract->getFunctionModifiers())
m_context.addModifier(*modifier);
}
appendFunctionSelector(_contract);
for (ContractDefinition const* contract: _contract.getLinearizedBaseContracts())
+ {
for (ASTPointer<FunctionDefinition> const& function: contract->getDefinedFunctions())
if (!function->isConstructor())
function->accept(*this);
+ for (ASTPointer<VariableDeclaration> const& vardecl: contract->getStateVariables())
+ if (vardecl->isPublic())
+ generateAccessorCode(*vardecl);
+ }
+
// Swap the runtime context with the creation-time context
swap(m_context, m_runtimeContext);
initializeContext(_contract, _contracts);
@@ -285,6 +292,23 @@ void Compiler::registerStateVariables(ContractDefinition const& _contract)
m_context.addStateVariable(*variable);
}
+bool Compiler::generateAccessorCode(VariableDeclaration const& _varDecl)
+{
+ m_context.startNewFunction();
+ m_returnTag = m_context.newTag();
+ m_breakTags.clear();
+ m_continueTags.clear();
+
+ // TODO: Work in progress
+ m_context << m_context.getFunctionEntryLabel(_varDecl);
+ // CompilerUtils(m_context).moveToStackVariable(firstVariable);
+ m_context.appendJumpTo(m_returnTag);
+ m_context << m_returnTag;
+
+ // TODO: perhaps return void if there are no checks?
+ return true;
+}
+
bool Compiler::visit(FunctionDefinition const& _function)
{
//@todo to simplify this, the calling convention could by changed such that
diff --git a/Compiler.h b/Compiler.h
index f40339b0..71a12a66 100644
--- a/Compiler.h
+++ b/Compiler.h
@@ -63,6 +63,8 @@ private:
void registerStateVariables(ContractDefinition const& _contract);
+ bool generateAccessorCode(VariableDeclaration const& _varDecl);
+
virtual bool visit(FunctionDefinition const& _function) override;
virtual bool visit(IfStatement const& _ifStatement) override;
virtual bool visit(WhileStatement const& _whileStatement) override;