blob: 8d9b312ceac0272aca4f3967bf2a0eecb08680c2 (
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
/*
* ConstantExpression.h
*
* Created on: Dec 5, 2012
* Author: attero
*/
#ifndef CONSTANTEXPRESSION_H_
#define CONSTANTEXPRESSION_H_
#include "ASTExpression.h"
#include <iostream>
#include "../Context.h"
/**
* ConstantExpression class is used to store complex expression, which are actually
* SenchaObjects. Constant Expressions are made in parser when it encounter some of primitives
* like string literal or numbers, they also can be made on already made SenchaObject.
* ConstantExpression is a part of AST, so it must have parent. It's a node in which it is build.
* It implements four virtual functions: debug, evaluate, execute_quietly.
* It stores the value of expression.
*/
class ConstantExpression : public ASTExpression {
public:
/**
* Constructor which sets value to null SenchaObject.o it
* @param parent of the ConstantExpression node
* @param number value will be set to SenchaObject representing this number
*/
ConstantExpression(ASTNode * parent);
/**
*Constructor which creates SenchaObject(number) and sets value to it
* @param parent of the ConstantExpression node
* @param number value will be set to SenchaObject representing this number
*/
ConstantExpression(ASTNode * parent, int number) ;
/**
* Constructor which creates SenchaObject(number) and sets value to it
* @param parent of the ConstantExpression node
* @param number value will be set to SenchaObject representing this number
*/
ConstantExpression(ASTNode * parent, double number) ;
/**
* Constructor which creates SenchaObject(text) and sets value to it
* @param parent of the ConstantExpression node
* @param text value will be set to SenchaObject representing this text
*/
ConstantExpression(ASTNode * parent, std::string text);
/**
* Constructor which sets value to given value
* @param parent of the ConstantExpression node
* @param value this->value will be set to value
*/
ConstantExpression(ASTNode * parent, SenchaObject value);
/** Here's value of constant expression */
SenchaObject value;
/** Provides some useful information */
std::string debug();
virtual ~ConstantExpression();
/**Returns value set in one of constructors */
virtual SenchaObject evaluate();
/**Prints representation of value */
virtual void execute() ;
/**Does nothing */
virtual void execute_quietly() ;
};
#endif /* CONSTANTEXPRESSION_H_ */
|