aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian <c@ethdev.com>2015-02-10 16:00:50 +0800
committerChristian <c@ethdev.com>2015-02-12 18:33:09 +0800
commit20b4c6900982302fd07df12e2a1f6f0e15886834 (patch)
tree3a202298db494951bb5caa6bf04f92517d525d14
parent1369337808ef5d2e4394336eec78f0cff406d55c (diff)
downloaddexon-solidity-20b4c6900982302fd07df12e2a1f6f0e15886834.tar
dexon-solidity-20b4c6900982302fd07df12e2a1f6f0e15886834.tar.gz
dexon-solidity-20b4c6900982302fd07df12e2a1f6f0e15886834.tar.bz2
dexon-solidity-20b4c6900982302fd07df12e2a1f6f0e15886834.tar.lz
dexon-solidity-20b4c6900982302fd07df12e2a1f6f0e15886834.tar.xz
dexon-solidity-20b4c6900982302fd07df12e2a1f6f0e15886834.tar.zst
dexon-solidity-20b4c6900982302fd07df12e2a1f6f0e15886834.zip
Tests and some code for msg.data.
-rw-r--r--AST.cpp3
-rw-r--r--Types.cpp14
-rw-r--r--Types.h2
3 files changed, 16 insertions, 3 deletions
diff --git a/AST.cpp b/AST.cpp
index 041b6277..33cf8c12 100644
--- a/AST.cpp
+++ b/AST.cpp
@@ -403,7 +403,8 @@ void Assignment::checkTypeRequirements()
m_leftHandSide->checkTypeRequirements();
m_leftHandSide->requireLValue();
//@todo later, assignments to structs might be possible, but not to mappings
- if (!m_leftHandSide->getType()->isValueType() && !m_leftHandSide->isLocalLValue())
+ if (m_leftHandSide->getType()->getCategory() != Type::Category::ByteArray &&
+ !m_leftHandSide->getType()->isValueType() && !m_leftHandSide->isLocalLValue())
BOOST_THROW_EXCEPTION(createTypeError("Assignment to non-local non-value lvalue."));
m_type = m_leftHandSide->getType();
if (m_assigmentOperator == Token::Assign)
diff --git a/Types.cpp b/Types.cpp
index 069493e6..9faa3f3c 100644
--- a/Types.cpp
+++ b/Types.cpp
@@ -508,6 +508,16 @@ TypePointer ContractType::unaryOperatorResult(Token::Value _operator) const
return _operator == Token::Delete ? make_shared<VoidType>() : TypePointer();
}
+bool ByteArrayType::isImplicitlyConvertibleTo(const Type& _convertTo) const
+{
+ if (*this == _convertTo)
+ return true;
+ if (_convertTo.getCategory() != Category::ByteArray)
+ return false;
+ auto const& other = dynamic_cast<ByteArrayType const&>(_convertTo);
+ return (m_dynamicLength == other.m_dynamicLength || m_length == other.m_length);
+}
+
bool ByteArrayType::operator==(Type const& _other) const
{
if (_other.getCategory() != getCategory())
@@ -952,7 +962,9 @@ MagicType::MagicType(MagicType::Kind _kind):
case Kind::Message:
m_members = MemberList({{"sender", make_shared<IntegerType>(0, IntegerType::Modifier::Address)},
{"gas", make_shared<IntegerType>(256)},
- {"value", make_shared<IntegerType>(256)}});
+ {"value", make_shared<IntegerType>(256)},
+ {"data", make_shared<ByteArrayType>(ByteArrayType::Location::CallData,
+ 0, 0, true)}});
break;
case Kind::Transaction:
m_members = MemberList({{"origin", make_shared<IntegerType>(0, IntegerType::Modifier::Address)},
diff --git a/Types.h b/Types.h
index 927ca290..ddcfad9e 100644
--- a/Types.h
+++ b/Types.h
@@ -287,11 +287,11 @@ public:
virtual Category getCategory() const override { return Category::ByteArray; }
ByteArrayType(Location _location, u256 const& _offset, u256 const& _length, bool _dynamicLength):
m_location(_location), m_offset(_offset), m_length(_length), m_dynamicLength(_dynamicLength) {}
+ virtual bool isImplicitlyConvertibleTo(Type const& _convertTo) const override;
virtual bool operator==(const Type& _other) const override;
virtual unsigned getSizeOnStack() const override { return 1; /* TODO */ }
virtual std::string toString() const override { return "bytes"; }
-
private:
Location m_location;
u256 m_offset;