aboutsummaryrefslogtreecommitdiffstats
path: root/AST.cpp
diff options
context:
space:
mode:
authorChristian <c@ethdev.com>2015-02-14 08:22:44 +0800
committerChristian <c@ethdev.com>2015-02-17 02:25:24 +0800
commitf7ba85e0ecb6f690d62bcf66e0f0525f2ed97337 (patch)
treebbd2b50913748f78b311b6cbea27bb6ba5ec9c9e /AST.cpp
parent3e29ec2cb2075fc6734a0f350503c393fbeeb3d6 (diff)
downloaddexon-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.cpp28
1 files changed, 19 insertions, 9 deletions
diff --git a/AST.cpp b/AST.cpp
index 0dbad433..0fafd2d1 100644
--- a/AST.cpp
+++ b/AST.cpp
@@ -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."));