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

45 lines
847 B
C++
Raw Normal View History

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()
{
auto right_value = static_cast<ASTExpression *>(children[1])->evaluate();
auto context = context_manager->get_top();
context->add(name, right_value);
return children[0]->execute();
2012-12-09 10:29:08 +00:00
}
SenchaObject Assignment::execute()
2012-12-09 11:57:51 +00:00
{
return evaluate();
2012-12-09 11:57:51 +00:00
}
Assignment::Assignment(ContextManager * context_manager, std::string name, ASTExpression * left, ASTExpression * right)
2012-12-09 10:29:08 +00:00
{
this->context_manager = context_manager;
this->name_of_context = "global";
this->type = "Assignment";
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() {
for(auto it = children.begin(); it != children.end(); )
{
delete *it;
it = children.erase(it);
}
2012-12-08 19:59:05 +00:00
}