aboutsummaryrefslogtreecommitdiffstats
path: root/Types.cpp
diff options
context:
space:
mode:
authorChristian <c@ethdev.com>2014-10-30 08:20:32 +0800
committerChristian <c@ethdev.com>2014-10-30 08:25:42 +0800
commit7f19f3d133b74bd7ebc96d18b09e145417b7daac (patch)
treea344a8faf9675882eb42f4f83e57f3a825844dcf /Types.cpp
parent51349bdae53e7d495732085c446ff9488473dcc8 (diff)
downloaddexon-solidity-7f19f3d133b74bd7ebc96d18b09e145417b7daac.tar.gz
dexon-solidity-7f19f3d133b74bd7ebc96d18b09e145417b7daac.tar.zst
dexon-solidity-7f19f3d133b74bd7ebc96d18b09e145417b7daac.zip
Contract compiler and also add ExpressionStatement to AST.
ExpressionStatement functions as glue between Statements and Expressions. This way it is possible to detect when the border between statements and expressions is crossed while walking the AST. Note that ExpressionStatement is not the only border, almost every statement can contains expressions.
Diffstat (limited to 'Types.cpp')
-rw-r--r--Types.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/Types.cpp b/Types.cpp
index 05b12df0..165787c5 100644
--- a/Types.cpp
+++ b/Types.cpp
@@ -159,14 +159,12 @@ std::string IntegerType::toString() const
return prefix + dev::toString(m_bits);
}
-bytes IntegerType::literalToBigEndian(const Literal& _literal) const
+u256 IntegerType::literalValue(const Literal& _literal) const
{
bigint value(_literal.getValue());
- if (!isSigned() && value < 0)
- return bytes(); // @todo this should already be caught by "smallestTypeforLiteral"
- //@todo check that the number of bits is correct
- //@todo does "toCompactBigEndian" work for signed numbers?
- return toCompactBigEndian(value);
+ //@todo check that the number is not too large
+ //@todo does this work for signed numbers?
+ return u256(value);
}
bool BoolType::isExplicitlyConvertibleTo(Type const& _convertTo) const
@@ -182,14 +180,14 @@ bool BoolType::isExplicitlyConvertibleTo(Type const& _convertTo) const
return isImplicitlyConvertibleTo(_convertTo);
}
-bytes BoolType::literalToBigEndian(const Literal& _literal) const
+u256 BoolType::literalValue(const Literal& _literal) const
{
if (_literal.getToken() == Token::TRUE_LITERAL)
- return bytes(1, 1);
+ return u256(1);
else if (_literal.getToken() == Token::FALSE_LITERAL)
- return bytes(1, 0);
+ return u256(0);
else
- return NullBytes;
+ assert(false);
}
bool ContractType::operator==(const Type& _other) const