[colobot] 104/145: Fix and document TypeCompatible

Didier Raboud odyx at moszumanska.debian.org
Mon Jul 11 12:56:22 UTC 2016


This is an automated email from the git hooks/post-receive script.

odyx pushed a commit to branch debian/master
in repository colobot.

commit 0165e8f348f7e257d8866287ae440ec4c8051916
Author: melex750 <melex750 at users.noreply.github.com>
Date:   Sun May 29 06:40:42 2016 -0400

    Fix and document TypeCompatible
---
 src/CBot/CBotInstr/CBotInstrUtils.cpp | 6 +++---
 src/CBot/CBotInstr/CBotInstrUtils.h   | 8 +++++++-
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/CBot/CBotInstr/CBotInstrUtils.cpp b/src/CBot/CBotInstr/CBotInstrUtils.cpp
index 05de1a4..bbe80b2 100644
--- a/src/CBot/CBotInstr/CBotInstrUtils.cpp
+++ b/src/CBot/CBotInstr/CBotInstrUtils.cpp
@@ -97,9 +97,9 @@ bool TypeCompatible(CBotTypResult& type1, CBotTypResult& type2, int op)
     if (max == 99) return false;    // result is void?
 
     // special case for strin concatenation
-    if (op == ID_ADD && max >= CBotTypString) return true;
-    if (op == ID_ASSADD && max >= CBotTypString) return true;
-    if (op == ID_ASS && t1 == CBotTypString) return true;
+    if (op == ID_ADD && t1 == CBotTypString) return true;
+    if (op == ID_ASSADD && t2 == CBotTypString) return true;
+    if (op == ID_ASS && t2 == CBotTypString) return true;
 
     if (max >= CBotTypBoolean)
     {
diff --git a/src/CBot/CBotInstr/CBotInstrUtils.h b/src/CBot/CBotInstr/CBotInstrUtils.h
index a609988..b530288 100644
--- a/src/CBot/CBotInstr/CBotInstrUtils.h
+++ b/src/CBot/CBotInstr/CBotInstrUtils.h
@@ -39,7 +39,13 @@ CBotInstr* CompileParams(CBotToken* &p, CBotCStack* pStack, CBotVar** ppVars);
 
 /*!
  * \brief TypeCompatible Check if two results are consistent to make an
- * operation.
+ * operation. TypeCompatible is used in two ways:
+ * For non-assignment operations:  see CBotTwoOpExpr::Compile
+ * TypeCompatible( leftType, rightType, opType )
+
+ * For assignment or compound assignment operations (it's reversed):
+ * see CBotReturn::Compile & CBotExpression::Compile
+ * TypeCompatible( valueType, varType, opType ) 
  * \param type1
  * \param type2
  * \param op

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git



More information about the Pkg-games-commits mailing list