summaryrefslogtreecommitdiffstats
path: root/Sencha-lang/AST/UnaryExpression.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Sencha-lang/AST/UnaryExpression.cpp')
-rw-r--r--Sencha-lang/AST/UnaryExpression.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/Sencha-lang/AST/UnaryExpression.cpp b/Sencha-lang/AST/UnaryExpression.cpp
new file mode 100644
index 0000000..47ef287
--- /dev/null
+++ b/Sencha-lang/AST/UnaryExpression.cpp
@@ -0,0 +1,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();
+}