mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
getRealType() introduced
This commit is contained in:
parent
76c9f13626
commit
2c9ff4747d
@ -852,7 +852,7 @@ unsigned ExpressionCompiler::appendArgumentsCopyToMemory(vector<ASTPointer<Expre
|
||||
for (unsigned i = 0; i < _arguments.size(); ++i)
|
||||
{
|
||||
_arguments[i]->accept(*this);
|
||||
length += moveTypeToMemory(*_arguments[i]->getType(), _arguments[i]->getLocation(), _memoryOffset + length);
|
||||
length += moveTypeToMemory(*_arguments[i]->getType()->getRealType(), _arguments[i]->getLocation(), _memoryOffset + length);
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
@ -361,6 +361,14 @@ u256 IntegerConstantType::literalValue(Literal const* _literal) const
|
||||
return value;
|
||||
}
|
||||
|
||||
TypePointer IntegerConstantType::getRealType() const
|
||||
{
|
||||
auto intType = getIntegerType();
|
||||
if (!intType)
|
||||
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("getRealType called with invalid integer constant" + toString()));
|
||||
return intType;
|
||||
}
|
||||
|
||||
shared_ptr<IntegerType const> IntegerConstantType::getIntegerType() const
|
||||
{
|
||||
bigint value = m_value;
|
||||
|
4
Types.h
4
Types.h
@ -130,6 +130,8 @@ public:
|
||||
/// i.e. it behaves differently in lvalue context and in value context.
|
||||
virtual bool isValueType() const { return false; }
|
||||
virtual unsigned getSizeOnStack() const { return 1; }
|
||||
/// @returns the real type of some types, like e.g: IntegerConstant
|
||||
virtual TypePointer getRealType() const { return TypePointer(); }
|
||||
|
||||
/// Returns the list of all members of this type. Default implementation: no members.
|
||||
virtual MemberList const& getMembers() const { return EmptyMemberList; }
|
||||
@ -175,6 +177,7 @@ public:
|
||||
virtual MemberList const& getMembers() const { return isAddress() ? AddressMemberList : EmptyMemberList; }
|
||||
|
||||
virtual std::string toString() const override;
|
||||
virtual TypePointer getRealType() const { return std::make_shared<IntegerType>(m_bits, m_modifier); }
|
||||
|
||||
int getNumBits() const { return m_bits; }
|
||||
bool isHash() const { return m_modifier == Modifier::HASH || m_modifier == Modifier::ADDRESS; }
|
||||
@ -214,6 +217,7 @@ public:
|
||||
|
||||
virtual std::string toString() const override;
|
||||
virtual u256 literalValue(Literal const* _literal) const override;
|
||||
virtual TypePointer getRealType() const override;
|
||||
|
||||
/// @returns the smallest integer type that can hold the value or an empty pointer if not possible.
|
||||
std::shared_ptr<IntegerType const> getIntegerType() const;
|
||||
|
Loading…
Reference in New Issue
Block a user