2012-12-05 19:32:43 +00:00
|
|
|
/*
|
|
|
|
* ConstantExpression.h
|
|
|
|
*
|
|
|
|
* Created on: Dec 5, 2012
|
|
|
|
* Author: attero
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CONSTANTEXPRESSION_H_
|
|
|
|
#define CONSTANTEXPRESSION_H_
|
|
|
|
#include "ASTExpression.h"
|
2012-12-08 21:33:34 +00:00
|
|
|
#include <iostream>
|
2012-12-31 16:10:37 +00:00
|
|
|
#include "../Elements/SenchaFunction.h"
|
2012-12-05 19:32:43 +00:00
|
|
|
|
2012-12-17 11:47:05 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
2012-12-31 16:10:37 +00:00
|
|
|
* It implements four virtual functions: debug, evaluate.
|
2012-12-17 11:47:05 +00:00
|
|
|
* It stores the value of expression.
|
|
|
|
*/
|
2012-12-05 19:32:43 +00:00
|
|
|
class ConstantExpression : public ASTExpression {
|
|
|
|
public:
|
2012-12-17 11:47:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor which sets value to null SenchaObject.o it
|
|
|
|
* @param number value will be set to SenchaObject representing this number
|
|
|
|
*/
|
2012-12-28 10:01:48 +00:00
|
|
|
ConstantExpression();
|
2012-12-17 11:47:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
*Constructor which creates SenchaObject(number) and sets value to it
|
|
|
|
* @param number value will be set to SenchaObject representing this number
|
|
|
|
*/
|
2012-12-28 10:01:48 +00:00
|
|
|
ConstantExpression( int number) ;
|
2012-12-17 11:47:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor which creates SenchaObject(number) and sets value to it
|
|
|
|
* @param number value will be set to SenchaObject representing this number
|
|
|
|
*/
|
2012-12-28 10:01:48 +00:00
|
|
|
ConstantExpression( double number) ;
|
2012-12-17 11:47:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor which creates SenchaObject(text) and sets value to it
|
|
|
|
* @param text value will be set to SenchaObject representing this text
|
|
|
|
*/
|
2012-12-28 10:01:48 +00:00
|
|
|
ConstantExpression( std::string text);
|
2012-12-17 11:47:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor which sets value to given value
|
|
|
|
* @param value this->value will be set to value
|
|
|
|
*/
|
2012-12-28 10:01:48 +00:00
|
|
|
ConstantExpression(SenchaObject value);
|
2012-12-09 16:42:13 +00:00
|
|
|
|
2012-12-17 11:47:05 +00:00
|
|
|
/** Here's value of constant expression */
|
2012-12-05 20:31:06 +00:00
|
|
|
SenchaObject value;
|
2012-12-06 17:41:16 +00:00
|
|
|
|
2012-12-18 20:22:33 +00:00
|
|
|
/** Implements visitor pattern */
|
2012-12-18 21:41:39 +00:00
|
|
|
virtual void accept(Visitor * visitor);
|
2012-12-18 20:22:33 +00:00
|
|
|
|
2012-12-05 19:32:43 +00:00
|
|
|
virtual ~ConstantExpression();
|
2012-12-17 11:47:05 +00:00
|
|
|
|
|
|
|
/**Returns value set in one of constructors */
|
2012-12-05 20:31:06 +00:00
|
|
|
virtual SenchaObject evaluate();
|
2012-12-08 21:33:34 +00:00
|
|
|
|
2012-12-17 11:47:05 +00:00
|
|
|
/**Prints representation of value */
|
2012-12-31 16:10:37 +00:00
|
|
|
virtual SenchaObject execute() ;
|
2012-12-17 11:47:05 +00:00
|
|
|
|
2012-12-05 19:32:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* CONSTANTEXPRESSION_H_ */
|