39 lines
877 B
C++
39 lines
877 B
C++
/*
|
|
* IfNode.h
|
|
*
|
|
* Created on: Nov 18, 2012
|
|
* Author: attero
|
|
*/
|
|
|
|
#ifndef IFNODE_H_
|
|
#define IFNODE_H_
|
|
|
|
#include "ASTStatement.h"
|
|
#include "ASTExpression.h"
|
|
|
|
/**
|
|
* This is a regular if then_block else else_block.
|
|
* New IfNode is build like that:
|
|
* First you add condition, then then-block which is called body
|
|
* and if it is needed, it's possible to add else-block too.
|
|
* It has to be done in right order.
|
|
*/
|
|
class IfNode : public ASTStatement
|
|
{
|
|
public:
|
|
void add_condition(ASTExpression * expression);
|
|
void add_body(ASTStatement * statement);
|
|
void add_else_block(ASTStatement * statement);
|
|
bool is_else;
|
|
virtual void execute();
|
|
bool evaluate_condition();
|
|
ASTNode * condition() { return children[0]; }
|
|
ASTNode * then_block() { return children[1]; }
|
|
ASTNode * else_block() { return children[2]; }
|
|
IfNode();
|
|
virtual ~IfNode();
|
|
};
|
|
|
|
|
|
#endif /* IFNODE_H_ */
|