diff options
author | Justyna Ilczuk <justyna.ilczuk@gmail.com> | 2012-12-18 21:22:33 +0100 |
---|---|---|
committer | Justyna Ilczuk <justyna.ilczuk@gmail.com> | 2012-12-18 21:22:33 +0100 |
commit | 9b28dfa8ddbb5fbf4ecb16fa481490f30d480754 (patch) | |
tree | 27f464224eb599ac59466fddb44873c5604f4d91 | |
parent | ce22fb3cdf6f9a529a7f54d22926dfca6356cc29 (diff) | |
download | sencha-lang-9b28dfa8ddbb5fbf4ecb16fa481490f30d480754.tar.gz sencha-lang-9b28dfa8ddbb5fbf4ecb16fa481490f30d480754.tar.bz2 sencha-lang-9b28dfa8ddbb5fbf4ecb16fa481490f30d480754.tar.xz sencha-lang-9b28dfa8ddbb5fbf4ecb16fa481490f30d480754.zip |
Preparing test, and classes to work using new structure.
-rw-r--r-- | Sencha-lang/AST/BasicExpression.h | 1 | ||||
-rw-r--r-- | Sencha-lang/AST/BasicStatement.cpp | 5 | ||||
-rw-r--r-- | Sencha-lang/AST/ConstantExpression.cpp | 6 | ||||
-rw-r--r-- | Sencha-lang/AST/ConstantExpression.h | 3 | ||||
-rw-r--r-- | Sencha-lang/Tests/TestASTInspector.cpp | 20 | ||||
-rw-r--r-- | Sencha-lang/Tests/TestASTInspector.h | 9 |
6 files changed, 42 insertions, 2 deletions
diff --git a/Sencha-lang/AST/BasicExpression.h b/Sencha-lang/AST/BasicExpression.h index 3984fb8..c563f1d 100644 --- a/Sencha-lang/AST/BasicExpression.h +++ b/Sencha-lang/AST/BasicExpression.h @@ -24,6 +24,7 @@ public: std::string debug() ; + void accept(Visitor * visitor); BasicExpression(ASTNode * parent); virtual ~BasicExpression(); diff --git a/Sencha-lang/AST/BasicStatement.cpp b/Sencha-lang/AST/BasicStatement.cpp index 88d70c2..b8dc1bf 100644 --- a/Sencha-lang/AST/BasicStatement.cpp +++ b/Sencha-lang/AST/BasicStatement.cpp @@ -34,3 +34,8 @@ void BasicStatement::execute() for(auto child: children) child->execute() ; } + +void BasicStatement::accept(Visitor * visitor) +{ + visitor->visit(this); +} diff --git a/Sencha-lang/AST/ConstantExpression.cpp b/Sencha-lang/AST/ConstantExpression.cpp index a59cc82..3e2ba71 100644 --- a/Sencha-lang/AST/ConstantExpression.cpp +++ b/Sencha-lang/AST/ConstantExpression.cpp @@ -38,7 +38,11 @@ void ConstantExpression::execute_quietly() evaluate(); } -/*! \fn Constructor which creates SenchaObject(number) and sets value to it */ +void ConstantExpression::accept(Visitor * visitor) +{ + visitor->visit(this); +} + ConstantExpression::ConstantExpression(ASTNode * parent, int number) { this->parent = parent; value = SenchaObject(number); diff --git a/Sencha-lang/AST/ConstantExpression.h b/Sencha-lang/AST/ConstantExpression.h index 8d9b312..5529c72 100644 --- a/Sencha-lang/AST/ConstantExpression.h +++ b/Sencha-lang/AST/ConstantExpression.h @@ -65,6 +65,9 @@ public: /** Provides some useful information */ std::string debug(); + /** Implements visitor pattern */ + void accept(Visitor * visitor); + virtual ~ConstantExpression(); /**Returns value set in one of constructors */ diff --git a/Sencha-lang/Tests/TestASTInspector.cpp b/Sencha-lang/Tests/TestASTInspector.cpp index 17e8e4f..875fe76 100644 --- a/Sencha-lang/Tests/TestASTInspector.cpp +++ b/Sencha-lang/Tests/TestASTInspector.cpp @@ -16,3 +16,23 @@ TestASTInspector::~TestASTInspector() { // TODO Auto-generated destructor stub } +std::string TestASTInspector::test_inspecting_basic_expression() +{ + BasicExpression * be = build_basic_expression("+", SenchaObject(9), SenchaObject(122)); + + +} + +virtual std::string TestASTInspector::all_tests() +{ + +} + +BasicExpression * TestASTInspector::build_basic_expression(std::string oper, SenchaObject arg1, SenchaObject arg2) +{ + BasicExpression * be = new BasicExpression(NULL); + be->set_operator(oper); + be->set_left_operand(new ConstantExpression(be, arg1)); + be->set_right_operand(new ConstantExpression(be, arg2)); + return be; +} diff --git a/Sencha-lang/Tests/TestASTInspector.h b/Sencha-lang/Tests/TestASTInspector.h index 962771e..a9439ff 100644 --- a/Sencha-lang/Tests/TestASTInspector.h +++ b/Sencha-lang/Tests/TestASTInspector.h @@ -10,14 +10,21 @@ #include "TestSuite.h" #include "../ASTInspector.h" +#include "../AST/BasicExpression.h" +#include "../AST/ConstantExpression.h" + + class TestASTInspector: public TestSuite { public: TestASTInspector(); virtual ~TestASTInspector(); std::string test_inspecting_basic_expression(); + virtual std::string all_tests(); +private: + BasicExpression * build_basic_expression(std::string oper, SenchaObject arg1, SenchaObject arg2); - + ASTInspector inspector; }; #endif /* TESTASTINSPECTOR_H_ */ |