aboutsummaryrefslogtreecommitdiffstats
path: root/AST.cpp
diff options
context:
space:
mode:
authorChristian <c@ethdev.com>2014-12-19 18:31:17 +0800
committerChristian <c@ethdev.com>2015-01-09 22:16:09 +0800
commitbe623273f329b841bfda2a0aef91f091aa81b216 (patch)
tree6467f6a373d9f7156b78e44685aa08fafa7d8e3e /AST.cpp
parentbe1e89da42e0ed9828dd2fb5939fd7bd48140be7 (diff)
downloaddexon-solidity-be623273f329b841bfda2a0aef91f091aa81b216.tar.gz
dexon-solidity-be623273f329b841bfda2a0aef91f091aa81b216.tar.zst
dexon-solidity-be623273f329b841bfda2a0aef91f091aa81b216.zip
Arbitrary precision integer constants.
Diffstat (limited to 'AST.cpp')
-rw-r--r--AST.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/AST.cpp b/AST.cpp
index 90b9962c..57aec8c3 100644
--- a/AST.cpp
+++ b/AST.cpp
@@ -174,7 +174,15 @@ void VariableDefinition::checkTypeRequirements()
{
// no type declared and no previous assignment, infer the type
m_value->checkTypeRequirements();
- m_variable->setType(m_value->getType());
+ TypePointer type = m_value->getType();
+ if (type->getCategory() == Type::Category::INTEGER_CONSTANT)
+ {
+ auto intType = dynamic_pointer_cast<IntegerConstantType const>(type)->getIntegerType();
+ if (!intType)
+ BOOST_THROW_EXCEPTION(m_value->createTypeError("Invalid integer constant " + type->toString()));
+ type = intType;
+ }
+ m_variable->setType(type);
}
}
}
@@ -196,13 +204,19 @@ void Assignment::checkTypeRequirements()
TypePointer resultType = m_type->binaryOperatorResult(Token::AssignmentToBinaryOp(m_assigmentOperator),
m_rightHandSide->getType());
if (!resultType || *resultType != *m_type)
- BOOST_THROW_EXCEPTION(createTypeError("Operator not compatible with type."));
+ BOOST_THROW_EXCEPTION(createTypeError("Operator " + string(Token::toString(m_assigmentOperator)) +
+ " not compatible with types " +
+ m_type->toString() + " and " +
+ m_rightHandSide->getType()->toString()));
}
}
void ExpressionStatement::checkTypeRequirements()
{
m_expression->checkTypeRequirements();
+ if (m_expression->getType()->getCategory() == Type::Category::INTEGER_CONSTANT)
+ if (!dynamic_pointer_cast<IntegerConstantType const>(m_expression->getType())->getIntegerType())
+ BOOST_THROW_EXCEPTION(m_expression->createTypeError("Invalid integer constant."));
}
void Expression::expectType(Type const& _expectedType)
@@ -388,7 +402,7 @@ void Literal::checkTypeRequirements()
{
m_type = Type::forLiteral(*this);
if (!m_type)
- BOOST_THROW_EXCEPTION(createTypeError("Literal value too large."));
+ BOOST_THROW_EXCEPTION(createTypeError("Invalid literal value."));
}
}