summaryrefslogtreecommitdiffstats
path: root/Sencha-lang/AST/VariableExpression.cpp
diff options
context:
space:
mode:
authorJustyna Ilczuk <justyna.ilczuk@gmail.com>2012-12-17 10:41:48 +0100
committerJustyna Ilczuk <justyna.ilczuk@gmail.com>2012-12-17 10:41:48 +0100
commitb9d9788da24cea3d0e193ac318d07f6c8e1b54ab (patch)
treee26f3027b71af16aade5bf482caa3c33e5bc12c4 /Sencha-lang/AST/VariableExpression.cpp
parent46ac5b352b7668047c0ca19745f82b8dbd0c0270 (diff)
downloadsencha-lang-b9d9788da24cea3d0e193ac318d07f6c8e1b54ab.tar.gz
sencha-lang-b9d9788da24cea3d0e193ac318d07f6c8e1b54ab.tar.bz2
sencha-lang-b9d9788da24cea3d0e193ac318d07f6c8e1b54ab.tar.xz
sencha-lang-b9d9788da24cea3d0e193ac318d07f6c8e1b54ab.zip
New class for variables. It's much more appropriate than storing
variables in constant expression class isn't it?
Diffstat (limited to 'Sencha-lang/AST/VariableExpression.cpp')
-rw-r--r--Sencha-lang/AST/VariableExpression.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/Sencha-lang/AST/VariableExpression.cpp b/Sencha-lang/AST/VariableExpression.cpp
new file mode 100644
index 0000000..93856f0
--- /dev/null
+++ b/Sencha-lang/AST/VariableExpression.cpp
@@ -0,0 +1,41 @@
+/*
+ * VariableExpression.cpp
+ *
+ * Created on: Dec 17, 2012
+ * Author: att
+ */
+
+#include "VariableExpression.h"
+
+VariableExpression::VariableExpression(ASTNode * parent, Context * context, std::string name) {
+
+ this->name = name;
+ this->parent = parent;
+ this->context = context;
+}
+
+std::string VariableExpression::debug()
+{
+ std::string debug_note = "variable: " + name;
+ return debug_note;
+}
+VariableExpression::~VariableExpression() {
+ // Do nothing
+}
+
+SenchaObject VariableExpression::evaluate()
+{
+ SenchaObject result = context->get(name);
+ result.name = name;
+ return result;
+}
+
+void VariableExpression::execute()
+{
+ std::cout << evaluate().repr() << std::endl;
+}
+
+void VariableExpression::execute_quietly()
+{
+ evaluate();
+}