diff options
| author | 2015-04-25 11:43:06 +0200 | |
|---|---|---|
| committer | 2015-04-25 11:43:06 +0200 | |
| commit | 942cf3f75f49d83c4e512d5350f7de69f0ec8aa7 (patch) | |
| tree | dc1bc3470ee90a7950747e0d1d25e4e66a0218c0 /node | |
| parent | 8beb664172cf2c15abb4e12938b8978506471c02 (diff) | |
| parent | 74275e3e17b7f8e9409d86382aa355c36e7005bd (diff) | |
| download | OneRoll-942cf3f75f49d83c4e512d5350f7de69f0ec8aa7.tar.gz OneRoll-942cf3f75f49d83c4e512d5350f7de69f0ec8aa7.zip | |
Merge branch 'master' of github.com:obiwankennedy/DiceParser
Diffstat (limited to 'node')
| -rw-r--r-- | node/executionnode.cpp | 2 | ||||
| -rw-r--r-- | node/executionnode.h | 2 | ||||
| -rw-r--r-- | node/jumpbackwardnode.cpp | 25 | ||||
| -rw-r--r-- | node/scalaroperatornode.cpp | 5 | ||||
| -rw-r--r-- | node/sortresult.cpp | 3 |
5 files changed, 31 insertions, 6 deletions
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/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/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 <QDebug> 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<DiceResult*>(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;i<diceResult->getResultList().size();++i) + { + Die* tmp =diceResult->getResultList().at(i); + Die* tmp2 =m_diceResult->getResultList().at(i); + if(tmp->isHighlighted()) + { + tmp2->setHighlighted(true); + } + } + + } 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; } 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); } } |