mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge remote-tracking branch 'ethereum/develop' into sol_typePromotion
This commit is contained in:
commit
6c2e3ffd76
20
AST.cpp
20
AST.cpp
@ -283,14 +283,6 @@ void WhileStatement::checkTypeRequirements()
|
|||||||
m_body->checkTypeRequirements();
|
m_body->checkTypeRequirements();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Continue::checkTypeRequirements()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Break::checkTypeRequirements()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Return::checkTypeRequirements()
|
void Return::checkTypeRequirements()
|
||||||
{
|
{
|
||||||
if (!m_expression)
|
if (!m_expression)
|
||||||
@ -326,8 +318,6 @@ void VariableDefinition::checkTypeRequirements()
|
|||||||
|
|
||||||
void Assignment::checkTypeRequirements()
|
void Assignment::checkTypeRequirements()
|
||||||
{
|
{
|
||||||
//@todo lefthandside actually has to be assignable
|
|
||||||
// add a feature to the type system to check that
|
|
||||||
m_leftHandSide->checkTypeRequirements();
|
m_leftHandSide->checkTypeRequirements();
|
||||||
if (!m_leftHandSide->isLvalue())
|
if (!m_leftHandSide->isLvalue())
|
||||||
BOOST_THROW_EXCEPTION(createTypeError("Expression has to be an lvalue."));
|
BOOST_THROW_EXCEPTION(createTypeError("Expression has to be an lvalue."));
|
||||||
@ -368,8 +358,8 @@ void UnaryOperation::checkTypeRequirements()
|
|||||||
|
|
||||||
void BinaryOperation::checkTypeRequirements()
|
void BinaryOperation::checkTypeRequirements()
|
||||||
{
|
{
|
||||||
m_right->checkTypeRequirements();
|
|
||||||
m_left->checkTypeRequirements();
|
m_left->checkTypeRequirements();
|
||||||
|
m_right->checkTypeRequirements();
|
||||||
if (m_right->getType()->isImplicitlyConvertibleTo(*m_left->getType()))
|
if (m_right->getType()->isImplicitlyConvertibleTo(*m_left->getType()))
|
||||||
m_commonType = m_left->getType();
|
m_commonType = m_left->getType();
|
||||||
else if (m_left->getType()->isImplicitlyConvertibleTo(*m_right->getType()))
|
else if (m_left->getType()->isImplicitlyConvertibleTo(*m_right->getType()))
|
||||||
@ -452,14 +442,6 @@ void Identifier::checkTypeRequirements()
|
|||||||
if (asserts(m_referencedDeclaration))
|
if (asserts(m_referencedDeclaration))
|
||||||
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Identifier not resolved."));
|
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Identifier not resolved."));
|
||||||
|
|
||||||
//@todo these dynamic casts here are not really nice...
|
|
||||||
// is i useful to have an AST visitor here?
|
|
||||||
// or can this already be done in NameAndTypeResolver?
|
|
||||||
// the only problem we get there is that in
|
|
||||||
// var x;
|
|
||||||
// x = 2;
|
|
||||||
// var y = x;
|
|
||||||
// the type of x is not yet determined.
|
|
||||||
VariableDeclaration* variable = dynamic_cast<VariableDeclaration*>(m_referencedDeclaration);
|
VariableDeclaration* variable = dynamic_cast<VariableDeclaration*>(m_referencedDeclaration);
|
||||||
if (variable)
|
if (variable)
|
||||||
{
|
{
|
||||||
|
4
AST.h
4
AST.h
@ -390,7 +390,7 @@ class Continue: public Statement
|
|||||||
public:
|
public:
|
||||||
Continue(Location const& _location): Statement(_location) {}
|
Continue(Location const& _location): Statement(_location) {}
|
||||||
virtual void accept(ASTVisitor& _visitor) override;
|
virtual void accept(ASTVisitor& _visitor) override;
|
||||||
virtual void checkTypeRequirements() override;
|
virtual void checkTypeRequirements() override {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class Break: public Statement
|
class Break: public Statement
|
||||||
@ -398,7 +398,7 @@ class Break: public Statement
|
|||||||
public:
|
public:
|
||||||
Break(Location const& _location): Statement(_location) {}
|
Break(Location const& _location): Statement(_location) {}
|
||||||
virtual void accept(ASTVisitor& _visitor) override;
|
virtual void accept(ASTVisitor& _visitor) override;
|
||||||
virtual void checkTypeRequirements() override;
|
virtual void checkTypeRequirements() override {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class Return: public Statement
|
class Return: public Statement
|
||||||
|
10
Compiler.cpp
10
Compiler.cpp
@ -252,17 +252,15 @@ bool Compiler::visit(WhileStatement& _whileStatement)
|
|||||||
|
|
||||||
bool Compiler::visit(Continue&)
|
bool Compiler::visit(Continue&)
|
||||||
{
|
{
|
||||||
if (asserts(!m_continueTags.empty()))
|
if (!m_continueTags.empty())
|
||||||
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Jump tag not available for \"continue\"."));
|
m_context.appendJumpTo(m_continueTags.back());
|
||||||
m_context.appendJumpTo(m_continueTags.back());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Compiler::visit(Break&)
|
bool Compiler::visit(Break&)
|
||||||
{
|
{
|
||||||
if (asserts(!m_breakTags.empty()))
|
if (!m_breakTags.empty())
|
||||||
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Jump tag not available for \"break\"."));
|
m_context.appendJumpTo(m_breakTags.back());
|
||||||
m_context.appendJumpTo(m_breakTags.back());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user