sencha-lang/Sencha-lang/AST/ConstantExpression.h

81 lines
2.4 KiB
C
Raw Normal View History

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"
#include <iostream>
#include "../Context.h"
2012-12-05 19:32:43 +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.
* It implements four virtual functions: debug, evaluate, execute_quietly.
* It stores the value of expression.
*/
2012-12-05 19:32:43 +00:00
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
*/
2012-12-06 17:41:16 +00:00
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
*/
2012-12-06 17:41:16 +00:00
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
*/
2012-12-06 17:41:16 +00:00
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;
2012-12-06 17:41:16 +00:00
/** Implements visitor pattern */
virtual void accept(Visitor * visitor);
2012-12-05 19:32:43 +00:00
virtual ~ConstantExpression();
/**Returns value set in one of constructors */
virtual SenchaObject evaluate();
/**Prints representation of value */
virtual void execute() ;
/**Does nothing */
2012-12-09 11:57:51 +00:00
virtual void execute_quietly() ;
2012-12-05 19:32:43 +00:00
};
#endif /* CONSTANTEXPRESSION_H_ */