/*
 * 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)
{
	right_value = right->evaluate();
	children[0] = right;
}

DeclarationStatement::DeclarationStatement(ASTNode * parent, Context * context)
{
	this->context = context;
	is_function = false;
	body = NULL;
	right_value = SenchaObject();
	children.push_back(new ConstantExpression(this));
}

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
	{
		context->add(name, right_value);
		children[0]->execute() ;
	}
}

void DeclarationStatement::add_body(ASTStatement * statement)
{
	is_function = true;
	body = statement;
}
