aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLefteris Karapetsas <lefteris@refu.co>2014-12-16 20:20:50 +0800
committerLefteris Karapetsas <lefteris@refu.co>2014-12-17 07:03:30 +0800
commit062b51e7bdf572abba25a76fc8c3bb6e96da71c9 (patch)
tree8ea9026902a73500d680dbf8e5dff4e1dba44c05
parent90e39c04d6e476491503573719c487744f529514 (diff)
downloaddexon-solidity-062b51e7bdf572abba25a76fc8c3bb6e96da71c9.tar.gz
dexon-solidity-062b51e7bdf572abba25a76fc8c3bb6e96da71c9.tar.zst
dexon-solidity-062b51e7bdf572abba25a76fc8c3bb6e96da71c9.zip
ForStatement typecheck and initExpression is a Statement
-rw-r--r--AST.cpp8
-rw-r--r--AST.h4
-rw-r--r--Parser.cpp4
-rw-r--r--Parser.h2
4 files changed, 11 insertions, 7 deletions
diff --git a/AST.cpp b/AST.cpp
index c286c412..4c042f2c 100644
--- a/AST.cpp
+++ b/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();
}
diff --git a/AST.h b/AST.h
index 297b7f4e..2fb6a2e3 100644
--- a/AST.h
+++ b/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;
diff --git a/Parser.cpp b/Parser.cpp
index 598f5ad4..2669ce20 100644
--- a/Parser.cpp
+++ b/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();
diff --git a/Parser.h b/Parser.h
index 343a85c0..cd3d5bab 100644
--- a/Parser.h
+++ b/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();