summaryrefslogtreecommitdiffstats
path: root/Sencha-lang/AST/UnaryExpression.cpp
blob: 47ef28721033fa07cc115faf3481b4dd5c629de4 (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
/*
 * UnaryExpression.cpp
 *
 *  Created on: Jan 1, 2013
 *      Author: att
 */

#include "UnaryExpression.h"

UnaryExpression::UnaryExpression(ASTNode * argument, std::string oper) {
	type = "UnaryExpression";
	children.push_back(argument);
	this->oper = oper;
}

UnaryExpression::~UnaryExpression() {
	// TODO Auto-generated destructor stub
}

SenchaObject UnaryExpression::execute()
{
	auto argument = children[0];
	if(oper == "-") return - argument->execute();
	else if(oper == "!") return ! argument->execute();
	else return SenchaObject();
}

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