Browse Source

ForStatement typecheck and initExpression is a Statement

cl-refactor
Lefteris Karapetsas 10 years ago
parent
commit
5eec2c5ac6
  1. 8
      libsolidity/AST.cpp
  2. 4
      libsolidity/AST.h
  3. 4
      libsolidity/Parser.cpp
  4. 2
      libsolidity/Parser.h

8
libsolidity/AST.cpp

@ -132,8 +132,12 @@ void WhileStatement::checkTypeRequirements()
void ForStatement::checkTypeRequirements()
{
// LTODO
m_condExpression->expectType(BoolType());
if (m_initExpression)
m_initExpression->checkTypeRequirements();
if (m_condExpression)
m_condExpression->expectType(BoolType());
if (m_loopExpression)
m_loopExpression->checkTypeRequirements();
m_body->checkTypeRequirements();
}

4
libsolidity/AST.h

@ -513,7 +513,7 @@ class ForStatement: public BreakableStatement
{
public:
ForStatement(Location const& _location,
ASTPointer<ASTNode> const& _initExpression,
ASTPointer<Statement> const& _initExpression,
ASTPointer<Expression> const& _conditionExpression,
ASTPointer<ExpressionStatement> const& _loopExpression,
ASTPointer<Statement> const& _body):
@ -527,7 +527,7 @@ public:
virtual void checkTypeRequirements() override;
private:
ASTPointer<ASTNode> m_initExpression;
ASTPointer<Statement> m_initExpression;
ASTPointer<Expression> m_condExpression;
ASTPointer<ExpressionStatement> m_loopExpression;
ASTPointer<Statement> m_body;

4
libsolidity/Parser.cpp

@ -374,7 +374,7 @@ ASTPointer<WhileStatement> Parser::parseWhileStatement()
ASTPointer<ForStatement> Parser::parseForStatement()
{
ASTNodeFactory nodeFactory(*this);
ASTPointer<ASTNode> initExpression;
ASTPointer<Statement> initExpression;
ASTPointer<Expression> conditionExpression;
ASTPointer<ExpressionStatement> loopExpression;
expectToken(Token::FOR);
@ -401,7 +401,7 @@ ASTPointer<ForStatement> Parser::parseForStatement()
body);
}
ASTPointer<ASTNode> Parser::parseVardefOrExprstatement()
ASTPointer<Statement> Parser::parseVardefOrExprstatement()
{
if (peekVariableDefinition())
return parseVariableDefinition();

2
libsolidity/Parser.h

@ -60,7 +60,7 @@ private:
ASTPointer<IfStatement> parseIfStatement();
ASTPointer<WhileStatement> parseWhileStatement();
ASTPointer<ForStatement> parseForStatement();
ASTPointer<ASTNode> parseVardefOrExprstatement();
ASTPointer<Statement> parseVardefOrExprstatement();
ASTPointer<VariableDefinition> parseVariableDefinition();
ASTPointer<ExpressionStatement> parseExpressionStatement();
ASTPointer<Expression> parseExpression();

Loading…
Cancel
Save