/*
 * UnaryExpression.cpp
 *
 *  Created on: Jan 1, 2013
 *      Author: att
 */

#include "UnaryExpression.h"

UnaryExpression::UnaryExpression(ASTExpression * 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();
}
