summaryrefslogtreecommitdiffstats
path: root/Sencha-lang/AST
diff options
context:
space:
mode:
Diffstat (limited to 'Sencha-lang/AST')
-rw-r--r--Sencha-lang/AST/Assignment.cpp34
-rw-r--r--Sencha-lang/AST/Assignment.h6
-rw-r--r--Sencha-lang/AST/BasicExpression.cpp42
-rw-r--r--Sencha-lang/AST/BasicExpression.h7
-rw-r--r--Sencha-lang/AST/IfNode.h2
-rw-r--r--Sencha-lang/AST/PostfixExpression.cpp9
-rw-r--r--Sencha-lang/AST/PostfixExpression.h6
-rw-r--r--Sencha-lang/AST/VariableExpression.cpp2
-rw-r--r--Sencha-lang/AST/VariableExpression.h2
9 files changed, 21 insertions, 89 deletions
diff --git a/Sencha-lang/AST/Assignment.cpp b/Sencha-lang/AST/Assignment.cpp
index 1e98070..a74d166 100644
--- a/Sencha-lang/AST/Assignment.cpp
+++ b/Sencha-lang/AST/Assignment.cpp
@@ -12,10 +12,6 @@ SenchaObject Assignment::evaluate()
return static_cast<ASTExpression *>(children[1])->evaluate();
}
-void Assignment::set_name(std::string name)
-{
- this->name = name;
-}
void Assignment::execute()
{
@@ -38,37 +34,15 @@ void Assignment::execute_quietly()
{
context->set(left_value.name, right_value);
}
-
}
-void Assignment::add_lvalue(ASTExpression * left)
-{
- if(children.size()==0)
- children.push_back(left);
- else
- children[0] = left;
-}
-
-void Assignment::add_rvalue(ASTExpression * right)
-{
- if(children.size()==1)
- children.push_back(right);
- else if(children.size()>1)
- children[1] = right;
-
-}
-
-std::string Assignment::debug()
-{
- std::string debug_note = static_cast<ASTExpression *>(children[0])->evaluate().repr();
- debug_note += " = " + static_cast<ASTExpression *>(children[1])->evaluate().repr() + "\n";
- return debug_note;
-}
-
-Assignment::Assignment(Context * context)
+Assignment::Assignment(Context * context, std::string name, ASTExpression * left, ASTExpression * right)
{
this->context = context;
this->type = "Assignment";
+ this->children.push_back(left);
+ this->children.push_back(right);
+ this->name = name;
}
diff --git a/Sencha-lang/AST/Assignment.h b/Sencha-lang/AST/Assignment.h
index a646af4..55a79c3 100644
--- a/Sencha-lang/AST/Assignment.h
+++ b/Sencha-lang/AST/Assignment.h
@@ -27,13 +27,9 @@ public:
std::string name;
SenchaObject evaluate();
- void set_name(std::string name);
void execute();
void execute_quietly();
- void add_lvalue(ASTExpression *);
- void add_rvalue(ASTExpression *);
- virtual std::string debug() ;
- Assignment(Context * context);
+ Assignment(Context * context, std::string name, ASTExpression * left, ASTExpression * right);
virtual ~Assignment();
};
diff --git a/Sencha-lang/AST/BasicExpression.cpp b/Sencha-lang/AST/BasicExpression.cpp
index 540dca4..a2fab44 100644
--- a/Sencha-lang/AST/BasicExpression.cpp
+++ b/Sencha-lang/AST/BasicExpression.cpp
@@ -7,41 +7,6 @@
#include "BasicExpression.h"
-void BasicExpression::set_operator(std::string op)
-{
- this->oper = op;
-}
-
-void BasicExpression::set_left_operand(ASTNode * left)
-{
- if(!this->children_set)
- {
- children.push_back(left);
- }
- else
- {
- this->children[0] = left;
- }
-
- if(children.size() == 2)
- children_set = true;
-}
-
-void BasicExpression::set_right_operand(ASTNode * right)
-{
- if(!this->children_set)
- {
- children.push_back(right);
-
- }
- else
- {
- this->children[1] = right;
- }
-
- if(children.size() == 2)
- children_set = true;
-}
void BasicExpression::execute()
{
std::cout << evaluate().repr() << std::endl;
@@ -51,6 +16,7 @@ void BasicExpression::execute_quietly()
{
evaluate();
}
+
SenchaObject BasicExpression::evaluate()
{
//TODO refactor it ;)
@@ -115,8 +81,12 @@ SenchaObject BasicExpression::evaluate()
return so;
}
-BasicExpression::BasicExpression() : children_set(false){
+BasicExpression::BasicExpression(ASTNode * left, ASTNode * right, std::string oper )
+{
this->type= "BasicExpression";
+ this->children.push_back(left);
+ this->children.push_back(right);
+ this->oper = oper;
}
BasicExpression::~BasicExpression() {
diff --git a/Sencha-lang/AST/BasicExpression.h b/Sencha-lang/AST/BasicExpression.h
index 69b3f18..ee75cac 100644
--- a/Sencha-lang/AST/BasicExpression.h
+++ b/Sencha-lang/AST/BasicExpression.h
@@ -20,21 +20,16 @@
class BasicExpression : public ASTExpression {
public:
- void set_operator(std::string op);
- void set_left_operand(ASTNode * left);
- void set_right_operand(ASTNode * right);
virtual SenchaObject evaluate();
virtual void execute();
virtual void execute_quietly();
std::string get_operator() { return oper; }
virtual void accept(Visitor * visitor);
- BasicExpression();
+ BasicExpression(ASTNode * left, ASTNode * right, std::string oper);
virtual ~BasicExpression();
private:
- //Do I use it for anything actually?
- bool children_set;
std::string oper;
};
diff --git a/Sencha-lang/AST/IfNode.h b/Sencha-lang/AST/IfNode.h
index 6accc7d..82ae46a 100644
--- a/Sencha-lang/AST/IfNode.h
+++ b/Sencha-lang/AST/IfNode.h
@@ -12,7 +12,7 @@
#include "ASTExpression.h"
/**
- * This is a regular if then_block else else_block
+ * This is a regular if then_block else else_block.
* New IfNode is build like that:
* First you add condition, then then-block which is called body
* and if it is needed, it's possible to add else-block too.
diff --git a/Sencha-lang/AST/PostfixExpression.cpp b/Sencha-lang/AST/PostfixExpression.cpp
index d277560..737b287 100644
--- a/Sencha-lang/AST/PostfixExpression.cpp
+++ b/Sencha-lang/AST/PostfixExpression.cpp
@@ -7,11 +7,10 @@
#include "PostfixExpression.h"
-PostfixExpression::PostfixExpression(Context * context) {
- this->context = context;
- name = "";
- native = false;
- this->type = "PostfixExpression";
+PostfixExpression::PostfixExpression(std::string name, Context * context):
+ context(context), name(name), native(false), type("PostfixExpression")
+{
+
}
PostfixExpression::~PostfixExpression() {
diff --git a/Sencha-lang/AST/PostfixExpression.h b/Sencha-lang/AST/PostfixExpression.h
index b6e4db1..4677a56 100644
--- a/Sencha-lang/AST/PostfixExpression.h
+++ b/Sencha-lang/AST/PostfixExpression.h
@@ -21,15 +21,13 @@ public:
bool native;
Context * context;
std::vector<ASTExpression *> arguments;
- void set_name(std::string name);
void add_argument(ASTExpression * expression);
virtual SenchaObject evaluate();
virtual void execute();
- virtual void execute_quietly(){ execute();
- };
+ virtual void execute_quietly(){ execute();};
- PostfixExpression( Context * context);
+ PostfixExpression( std::string name, Context * context);
virtual ~PostfixExpression();
};
diff --git a/Sencha-lang/AST/VariableExpression.cpp b/Sencha-lang/AST/VariableExpression.cpp
index 6ebf0dd..fafec2e 100644
--- a/Sencha-lang/AST/VariableExpression.cpp
+++ b/Sencha-lang/AST/VariableExpression.cpp
@@ -7,7 +7,7 @@
#include "VariableExpression.h"
-VariableExpression::VariableExpression(Context * context, std::string name) {
+VariableExpression::VariableExpression(std::string name, Context * context) {
this->name = name;
this->context = context;
this->type = "VariableExpression";
diff --git a/Sencha-lang/AST/VariableExpression.h b/Sencha-lang/AST/VariableExpression.h
index f07ba7a..add5190 100644
--- a/Sencha-lang/AST/VariableExpression.h
+++ b/Sencha-lang/AST/VariableExpression.h
@@ -19,7 +19,7 @@
class VariableExpression: public ASTExpression {
public:
VariableExpression();
- VariableExpression(Context * context, std::string name);
+ VariableExpression(std::string name, Context * context);
Context * context;
std::string name;