From 5acfe8b8352ba028235e5ecf007d1b9b4fa3a0f8 Mon Sep 17 00:00:00 2001 From: Renaud G Date: Sat, 25 Apr 2015 11:37:46 +0200 Subject: Dot tree now also displays the result tree. (must be improved). --- node/executionnode.cpp | 2 ++ node/sortresult.cpp | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'node') diff --git a/node/executionnode.cpp b/node/executionnode.cpp index 343e8d9..0cb9c0b 100644 --- a/node/executionnode.cpp +++ b/node/executionnode.cpp @@ -59,5 +59,7 @@ void ExecutionNode::generateDotTree(QString& s) s.append(" -> "); s.append("NULL"); s.append(" [label=\"nextNode\"];\n"); + + m_result->generateDotTree(s); } } diff --git a/node/sortresult.cpp b/node/sortresult.cpp index 46e6eb8..deaf794 100644 --- a/node/sortresult.cpp +++ b/node/sortresult.cpp @@ -80,7 +80,8 @@ void SortResultNode::run(ExecutionNode* node) } else { - m_errors.append(DIE_RESULT_EXPECTED); + m_result = node->getResult(); + //m_errors.append(DIE_RESULT_EXPECTED); } } -- cgit v1.2.3-70-g09d2 From b1557c9fef9d7fa4e0ddac1d6e108ef9981f1196 Mon Sep 17 00:00:00 2001 From: Renaud G Date: Sat, 25 Apr 2015 11:38:13 +0200 Subject: add error divide_by_zero --- node/executionnode.h | 2 +- node/scalaroperatornode.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'node') diff --git a/node/executionnode.h b/node/executionnode.h index cf1514f..cc40867 100644 --- a/node/executionnode.h +++ b/node/executionnode.h @@ -9,7 +9,7 @@ class ExecutionNode { public: - enum ERROR_CODE {NO_ERROR,DIE_RESULT_EXPECTED,BAD_SYNTAXE,ENDLESS_LOOP_ERROR}; + enum ERROR_CODE {NO_ERROR,DIE_RESULT_EXPECTED,BAD_SYNTAXE,ENDLESS_LOOP_ERROR,DIVIDE_BY_ZERO}; /** * @brief ExecutionNode */ diff --git a/node/scalaroperatornode.cpp b/node/scalaroperatornode.cpp index 34eb6b8..8dfbc20 100644 --- a/node/scalaroperatornode.cpp +++ b/node/scalaroperatornode.cpp @@ -105,6 +105,11 @@ qint64 ScalarOperatorNode::substract(qint64 a,qint64 b) qreal ScalarOperatorNode::divide(qint64 a,qint64 b) { + if(b==0) + { + m_errors.append(DIVIDE_BY_ZERO); + return 0; + } return (qreal)a/b; } -- cgit v1.2.3-70-g09d2 From 74275e3e17b7f8e9409d86382aa355c36e7005bd Mon Sep 17 00:00:00 2001 From: Renaud G Date: Sat, 25 Apr 2015 11:40:34 +0200 Subject: better highlightment --- node/jumpbackwardnode.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'node') diff --git a/node/jumpbackwardnode.cpp b/node/jumpbackwardnode.cpp index af96ed8..d800394 100644 --- a/node/jumpbackwardnode.cpp +++ b/node/jumpbackwardnode.cpp @@ -1,5 +1,5 @@ #include "jumpbackwardnode.h" - +#include JumpBackwardNode::JumpBackwardNode() { @@ -32,12 +32,15 @@ void JumpBackwardNode::run(ExecutionNode* previous) if((NULL!=result)) { --i; - if((i==0)&&(parent->getResult()->hasResultOfType(Result::DICE_LIST))) + if((i==0)&&(result->hasResultOfType(Result::DICE_LIST))) { found =true; } } - parent = parent->getPreviousNode(); + if(!found) + { + parent = parent->getPreviousNode(); + } } DiceResult* diceResult = dynamic_cast(result); @@ -46,13 +49,27 @@ void JumpBackwardNode::run(ExecutionNode* previous) Die* tmpdie = new Die(); *tmpdie=*die; m_diceResult->insertResult(tmpdie); + die->displayed(); } - //*m_result = *result; + m_result->setPrevious(parent->getResult()); + + if(NULL!=m_nextNode) { m_nextNode->run(this); } + for(int i =0;igetResultList().size();++i) + { + Die* tmp =diceResult->getResultList().at(i); + Die* tmp2 =m_diceResult->getResultList().at(i); + if(tmp->isHighlighted()) + { + tmp2->setHighlighted(true); + } + } + + } -- cgit v1.2.3-70-g09d2