length member for byte arrays.

This commit is contained in:
Christian 2015-02-12 15:44:35 +01:00
parent 5e40b79426
commit b836d952b2
3 changed files with 10 additions and 0 deletions

View File

@ -504,6 +504,12 @@ void ExpressionCompiler::endVisit(MemberAccess const& _memberAccess)
}
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Invalid member access to " + type.toString()));
}
case Type::Category::ByteArray:
{
solAssert(member == "length", "Illegal bytearray member.");
m_context << eth::Instruction::SLOAD;
break;
}
default:
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Member access to unknown type."));
}

View File

@ -541,6 +541,8 @@ unsigned ByteArrayType::getSizeOnStack() const
return 1;
}
const MemberList ByteArrayType::s_byteArrayMemberList = MemberList({{"length", make_shared<IntegerType >(256)}});
bool ContractType::operator==(Type const& _other) const
{
if (_other.getCategory() != getCategory())

View File

@ -292,11 +292,13 @@ public:
virtual bool operator==(const Type& _other) const override;
virtual unsigned getSizeOnStack() const override;
virtual std::string toString() const override { return "bytes"; }
virtual MemberList const& getMembers() const override { return s_byteArrayMemberList; }
Location getLocation() const { return m_location; }
private:
Location m_location;
static const MemberList s_byteArrayMemberList;
};
/**