mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
All interface functions are external.
This commit is contained in:
parent
53ef6900b7
commit
3ec6c0b1cb
2
AST.cpp
2
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())
|
||||
|
40
Compiler.cpp
40
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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user