summaryrefslogtreecommitdiffstats
path: root/Sencha-lang/AST/ConstantExpression.cpp
blob: ec8cbd508d3640d39a17c3d9ca737478491bef28 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
 * ConstantExpression.cpp
 *
 *  Created on: Dec 5, 2012
 *      Author: attero
 */

#include "ConstantExpression.h"

ConstantExpression::ConstantExpression(ASTNode * parent) //Constructor which sets value to null SenchaObject.
{
	this->parent = parent;
	value = SenchaObject();
	this->type = "ConstantExpression";
}

ConstantExpression::~ConstantExpression() {

}

ConstantExpression::ConstantExpression(ASTNode * parent, SenchaObject value) : value(value)
{
	this->parent = parent;
	this->type = "ConstantExpression";
}

SenchaObject ConstantExpression::evaluate()
{
	return value;
}

void  ConstantExpression::execute()
{
	std::cout <<  evaluate().repr() << std::endl;
}

void ConstantExpression::execute_quietly()
{
	evaluate();
}

void ConstantExpression::accept(Visitor * visitor)
{
	visitor->visit(this);
}

ConstantExpression::ConstantExpression(ASTNode * parent, int number)
{
	this->parent = parent; value = SenchaObject(number);
	this->type = "ConstantExpression";
}

ConstantExpression::ConstantExpression(ASTNode * parent, double number)
{
	this->parent = parent;
	this->type = "ConstantExpression";
	value = SenchaObject(number);
}

ConstantExpression::ConstantExpression(ASTNode * parent, std::string text)
{
	this->type = "ConstantExpression";
	this->parent = parent; value = SenchaObject(text);
}

std::string ConstantExpression::debug() { return "Constant expression:\n" + value.repr() + "\n"; }