Fix and document TypeCompatible

master
melex750 2016-05-29 06:40:42 -04:00
parent b56cd11c98
commit 0165e8f348
2 changed files with 10 additions and 4 deletions

View File

@ -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)
{

View File

@ -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