2012-12-09 10:29:08 +00:00
|
|
|
/*
|
|
|
|
* DeclarationStatement.cpp
|
|
|
|
*
|
|
|
|
* Created on: Dec 9, 2012
|
|
|
|
* Author: attero
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "DeclarationStatement.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DeclarationStatement::~DeclarationStatement() {
|
|
|
|
// TODO Auto-generated destructor stub
|
|
|
|
}
|
|
|
|
|
|
|
|
void DeclarationStatement::add_right_value(ASTExpression * right)
|
|
|
|
{
|
2012-12-09 11:57:51 +00:00
|
|
|
right_value = right->evaluate();
|
|
|
|
children[0] = right;
|
2012-12-09 10:29:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DeclarationStatement::DeclarationStatement(ASTNode * parent, Context * context)
|
|
|
|
{
|
2012-12-09 11:57:51 +00:00
|
|
|
this->context = context;
|
2012-12-09 10:29:08 +00:00
|
|
|
is_function = false;
|
|
|
|
body = NULL;
|
2012-12-09 11:57:51 +00:00
|
|
|
right_value = SenchaObject();
|
|
|
|
children.push_back(new ConstantExpression(this));
|
2012-12-09 10:29:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string DeclarationStatement::debug()
|
|
|
|
{
|
|
|
|
std::string debug_note = "Declaration";
|
|
|
|
return debug_note;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DeclarationStatement::add_name(std::string name)
|
|
|
|
{
|
|
|
|
this->name = name;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DeclarationStatement::add_argument(std::string name)
|
|
|
|
{
|
|
|
|
arguments.push_back(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DeclarationStatement::execute()
|
|
|
|
{
|
|
|
|
if(is_function)
|
|
|
|
{
|
|
|
|
//TODO implement
|
|
|
|
//do function registering stuff
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-12-09 11:57:51 +00:00
|
|
|
context->add(name, right_value);
|
|
|
|
children[0]->execute() ;
|
2012-12-09 10:29:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DeclarationStatement::add_body(ASTStatement * statement)
|
|
|
|
{
|
|
|
|
is_function = true;
|
|
|
|
body = statement;
|
|
|
|
}
|