diff options
author | Christian <c@ethdev.com> | 2015-02-14 08:22:44 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2015-02-17 02:25:24 +0800 |
commit | f7ba85e0ecb6f690d62bcf66e0f0525f2ed97337 (patch) | |
tree | bbd2b50913748f78b311b6cbea27bb6ba5ec9c9e /AST.cpp | |
parent | 3e29ec2cb2075fc6734a0f350503c393fbeeb3d6 (diff) | |
download | dexon-solidity-f7ba85e0ecb6f690d62bcf66e0f0525f2ed97337.tar.gz dexon-solidity-f7ba85e0ecb6f690d62bcf66e0f0525f2ed97337.tar.zst dexon-solidity-f7ba85e0ecb6f690d62bcf66e0f0525f2ed97337.zip |
No write access to parameters of external functions.
Diffstat (limited to 'AST.cpp')
-rw-r--r-- | AST.cpp | 28 |
1 files changed, 19 insertions, 9 deletions
@@ -288,12 +288,23 @@ string FunctionDefinition::getCanonicalSignature() const return FunctionType(*this).getCanonicalSignature(getName()); } -Declaration::LValueType VariableDeclaration::getLValueType() const +bool VariableDeclaration::isLValue() const { - if (dynamic_cast<FunctionDefinition const*>(getScope()) || dynamic_cast<ModifierDefinition const*>(getScope())) - return Declaration::LValueType::Local; - else - return Declaration::LValueType::Storage; + if (auto const* function = dynamic_cast<FunctionDefinition const*>(getScope())) + if (function->getVisibility() == Declaration::Visibility::External && isFunctionParameter()) + return false; + return true; +} + +bool VariableDeclaration::isFunctionParameter() const +{ + auto const* function = dynamic_cast<FunctionDefinition const*>(getScope()); + if (!function) + return false; + for (auto const& variable: function->getParameters()) + if (variable.get() == this) + return true; + return false; } TypePointer ModifierDefinition::getType(ContractDefinition const*) const @@ -586,8 +597,7 @@ void MemberAccess::checkTypeRequirements() if (!m_type) BOOST_THROW_EXCEPTION(createTypeError("Member \"" + *m_memberName + "\" not found or not " "visible in " + type.toString())); - //@todo later, this will not always be STORAGE - m_lvalue = type.getCategory() == Type::Category::Struct ? Declaration::LValueType::Storage : Declaration::LValueType::None; + m_isLValue = (type.getCategory() == Type::Category::Struct); } void IndexAccess::checkTypeRequirements() @@ -599,14 +609,14 @@ void IndexAccess::checkTypeRequirements() MappingType const& type = dynamic_cast<MappingType const&>(*m_base->getType()); m_index->expectType(*type.getKeyType()); m_type = type.getValueType(); - m_lvalue = Declaration::LValueType::Storage; + m_isLValue = true; } void Identifier::checkTypeRequirements() { solAssert(m_referencedDeclaration, "Identifier not resolved."); - m_lvalue = m_referencedDeclaration->getLValueType(); + m_isLValue = m_referencedDeclaration->isLValue(); m_type = m_referencedDeclaration->getType(m_currentContract); if (!m_type) BOOST_THROW_EXCEPTION(createTypeError("Declaration referenced before type could be determined.")); |