diff options
author | Christian <c@ethdev.com> | 2014-10-25 22:52:22 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2014-10-29 21:33:25 +0800 |
commit | b5a4d12fa328f69d4dfba9bf57ac289935877649 (patch) | |
tree | dfa92c635af822197b7bb25a7b23870d1d26a179 /AST.cpp | |
parent | 01224287f5e24f7074f398ac9b064b27b2c3877e (diff) | |
download | dexon-solidity-b5a4d12fa328f69d4dfba9bf57ac289935877649.tar.gz dexon-solidity-b5a4d12fa328f69d4dfba9bf57ac289935877649.tar.zst dexon-solidity-b5a4d12fa328f69d4dfba9bf57ac289935877649.zip |
Compiler for assignments.
Diffstat (limited to 'AST.cpp')
-rw-r--r-- | AST.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -326,6 +326,8 @@ void Assignment::checkTypeRequirements() //@todo lefthandside actually has to be assignable // add a feature to the type system to check that m_leftHandSide->checkTypeRequirements(); + if (!m_leftHandSide->isLvalue()) + BOOST_THROW_EXCEPTION(createTypeError("Expression has to be an lvalue.")); expectType(*m_rightHandSide, *m_leftHandSide->getType()); m_type = m_leftHandSide->getType(); if (m_assigmentOperator != Token::ASSIGN) @@ -338,8 +340,13 @@ void Assignment::checkTypeRequirements() void UnaryOperation::checkTypeRequirements() { - // INC, DEC, NOT, BIT_NOT, DELETE + // INC, DEC, ADD, SUB, NOT, BIT_NOT, DELETE m_subExpression->checkTypeRequirements(); + if (m_operator == Token::Value::INC || m_operator == Token::Value::DEC || m_operator == Token::Value::DELETE) + { + if (!m_subExpression->isLvalue()) + BOOST_THROW_EXCEPTION(createTypeError("Expression has to be an lvalue.")); + } m_type = m_subExpression->getType(); if (!m_type->acceptsUnaryOperator(m_operator)) BOOST_THROW_EXCEPTION(createTypeError("Unary operator not compatible with type.")); @@ -441,9 +448,9 @@ void Identifier::checkTypeRequirements() if (variable) { if (!variable->getType()) - BOOST_THROW_EXCEPTION(createTypeError("Variable referenced before type " - "could be determined.")); + BOOST_THROW_EXCEPTION(createTypeError("Variable referenced before type could be determined.")); m_type = variable->getType(); + m_isLvalue = true; return; } //@todo can we unify these with TypeName::toType()? |