summaryrefslogtreecommitdiffstats
path: root/Sencha-lang/AST/VariableExpression.cpp
blob: 22f44653c9920c7750b3e04440dc2aa058d9e8f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
 * VariableExpression.cpp
 *
 *  Created on: Dec 17, 2012
 *      Author: att
 */

#include "VariableExpression.h"

VariableExpression::VariableExpression(std::string name, ContextManager * context_manager) {
	this->name = name;
	this->name_of_context = "global";
	this->context_manager = context_manager;
	this->type = "VariableExpression";
}

VariableExpression::~VariableExpression() {
	// Do nothing
}

SenchaObject VariableExpression::evaluate()
{

	auto context = context_manager->get_top();
	//std::cout << "I'm retrieving variable " + name + " from " + context->name << std::endl;
	SenchaObject result = context->get(name);
	//std::cout << "And it's: " + result.repr() << std::endl;
	result.name = name;
	return result;
}

SenchaObject  VariableExpression::execute()
{
	return evaluate();
}