2012-12-08 19:59:05 +00:00
|
|
|
/*
|
|
|
|
* Assignment.cpp
|
|
|
|
*
|
|
|
|
* Created on: Dec 7, 2012
|
|
|
|
* Author: attero
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "Assignment.h"
|
|
|
|
|
2012-12-09 10:29:08 +00:00
|
|
|
SenchaObject Assignment::evaluate()
|
|
|
|
{
|
|
|
|
return static_cast<ASTExpression *>(children[1])->evaluate();
|
|
|
|
}
|
|
|
|
|
2012-12-09 20:17:13 +00:00
|
|
|
|
2012-12-09 10:29:08 +00:00
|
|
|
void Assignment::execute()
|
|
|
|
{
|
|
|
|
auto left_value = static_cast<ASTExpression *>(children[0])->evaluate();
|
|
|
|
auto right_value = static_cast<ASTExpression *>(children[1])->evaluate();
|
2012-12-09 11:57:51 +00:00
|
|
|
static_cast<ASTExpression *>(children[1])->execute_quietly();
|
2012-12-09 20:17:13 +00:00
|
|
|
|
|
|
|
if(name != "")
|
2012-12-09 10:29:08 +00:00
|
|
|
{
|
2012-12-09 20:17:13 +00:00
|
|
|
context->set(name, right_value);
|
2012-12-09 10:29:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-09 11:57:51 +00:00
|
|
|
void Assignment::execute_quietly()
|
|
|
|
{
|
|
|
|
auto left_value = static_cast<ASTExpression *>(children[0])->evaluate();
|
|
|
|
auto right_value = static_cast<ASTExpression *>(children[1])->evaluate();
|
|
|
|
static_cast<ASTExpression *>(children[1])->execute_quietly();
|
|
|
|
if(left_value.name != "")
|
|
|
|
{
|
|
|
|
context->set(left_value.name, right_value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-30 13:59:30 +00:00
|
|
|
Assignment::Assignment(ContextManager * context, std::string name, ASTExpression * left, ASTExpression * right)
|
2012-12-09 10:29:08 +00:00
|
|
|
{
|
|
|
|
this->context = context;
|
2012-12-22 10:06:55 +00:00
|
|
|
this->type = "Assignment";
|
2012-12-28 15:19:47 +00:00
|
|
|
this->children.push_back(left);
|
|
|
|
this->children.push_back(right);
|
|
|
|
this->name = name;
|
2012-12-09 10:29:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-12-08 19:59:05 +00:00
|
|
|
Assignment::~Assignment() {
|
2012-12-17 08:25:58 +00:00
|
|
|
for(auto it = children.begin(); it != children.end(); )
|
|
|
|
{
|
|
|
|
delete *it;
|
|
|
|
it = children.erase(it);
|
|
|
|
}
|
2012-12-08 19:59:05 +00:00
|
|
|
}
|
|
|
|
|