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

60 lines
1.0 KiB
C++

/*
* ConstantExpression.cpp
*
* Created on: Dec 5, 2012
* Author: attero
*/
#include "ConstantExpression.h"
ConstantExpression::ConstantExpression() //Constructor which sets value to null SenchaObject.
{
value = SenchaObject();
this->type = "ConstantExpression";
}
ConstantExpression::~ConstantExpression() {
}
ConstantExpression::ConstantExpression(SenchaObject value) : value(value)
{
this->type = "ConstantExpression";
}
SenchaObject ConstantExpression::evaluate()
{
return value;
}
SenchaObject ConstantExpression::execute()
{
SenchaObject result = evaluate();
return result;
}
void ConstantExpression::accept(Visitor * visitor)
{
visitor->visit(this);
}
ConstantExpression::ConstantExpression( int number)
{
value = SenchaObject(number);
this->type = "ConstantExpression";
}
ConstantExpression::ConstantExpression( double number)
{
this->type = "ConstantExpression";
value = SenchaObject(number);
}
ConstantExpression::ConstantExpression( std::string text)
{
this->type = "ConstantExpression";
value = SenchaObject(text);
}