Preparing test, and classes to work using new structure.
parent
ce22fb3cdf
commit
9b28dfa8dd
|
@ -24,6 +24,7 @@ public:
|
|||
|
||||
|
||||
std::string debug() ;
|
||||
void accept(Visitor * visitor);
|
||||
|
||||
BasicExpression(ASTNode * parent);
|
||||
virtual ~BasicExpression();
|
||||
|
|
|
@ -34,3 +34,8 @@ void BasicStatement::execute()
|
|||
for(auto child: children)
|
||||
child->execute() ;
|
||||
}
|
||||
|
||||
void BasicStatement::accept(Visitor * visitor)
|
||||
{
|
||||
visitor->visit(this);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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_ */
|
||||
|
|
Loading…
Reference in New Issue