summaryrefslogtreecommitdiffstats
path: root/Sencha-lang/AST/IfNode.h
blob: 6accc7dfa7cff559ef7fffa0f44cec192fd3b0c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
 * 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_ */