All interface functions are external.

This commit is contained in:
Lefteris Karapetsas 2015-01-26 16:58:54 +01:00
parent 53ef6900b7
commit 3ec6c0b1cb
3 changed files with 35 additions and 9 deletions

View File

@ -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())

View File

@ -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

View File

@ -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;