[colobot] 125/145: Fix initializing an array using variables
Didier Raboud
odyx at moszumanska.debian.org
Mon Jul 11 12:56:24 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 0d74b4f36b8e9fbd6236c56976d82abf56545fea
Author: melex750 <melex750 at users.noreply.github.com>
Date: Fri Jun 24 16:56:17 2016 -0400
Fix initializing an array using variables
Resolves a conflict between CBotListArray and CBotExprVar
---
src/CBot/CBotInstr/CBotListArray.cpp | 19 +++++++++----------
src/CBot/CBotInstr/CBotListArray.h | 2 +-
2 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/src/CBot/CBotInstr/CBotListArray.cpp b/src/CBot/CBotInstr/CBotListArray.cpp
index 559bb9d..89cbb79 100644
--- a/src/CBot/CBotInstr/CBotListArray.cpp
+++ b/src/CBot/CBotInstr/CBotListArray.cpp
@@ -98,7 +98,7 @@ CBotInstr* CBotListArray::Compile(CBotToken* &p, CBotCStack* pStack, CBotTypResu
}
}
- inst->m_expr->AddNext3(i);
+ inst->m_expr->AddNext3b(i);
if ( p->GetType() == ID_COMMA ) continue;
if ( p->GetType() == ID_CLBLK ) break;
@@ -114,10 +114,10 @@ CBotInstr* CBotListArray::Compile(CBotToken* &p, CBotCStack* pStack, CBotTypResu
{
goto error;
}
- CBotVar* pv = pStk->GetVar(); // result of the expression
- if (pv == nullptr || (!TypesCompatibles( type, pv->GetTypResult()) &&
- !(type.Eq(CBotTypPointer) && pv->GetTypResult().Eq(CBotTypNullPointer)) ))
+ CBotTypResult valType = pStk->GetTypResult();
+
+ if (!TypeCompatible(valType, type, ID_ASS) )
{
pStk->SetError(CBotErrBadType1, p->GetStart());
goto error;
@@ -133,15 +133,14 @@ CBotInstr* CBotListArray::Compile(CBotToken* &p, CBotCStack* pStack, CBotTypResu
goto error;
}
- CBotVar* pv = pStk->GetVar(); // result of the expression
+ CBotTypResult valType = pStk->GetTypResult();
- if (pv == nullptr || (!TypesCompatibles( type, pv->GetTypResult()) &&
- !(type.Eq(CBotTypPointer) && pv->GetTypResult().Eq(CBotTypNullPointer)) ))
+ if (!TypeCompatible(valType, type, ID_ASS) )
{
pStk->SetError(CBotErrBadType1, p->GetStart());
goto error;
}
- inst->m_expr->AddNext3(i);
+ inst->m_expr->AddNext3b(i);
if (p->GetType() == ID_COMMA) continue;
if (p->GetType() == ID_CLBLK) break;
@@ -175,7 +174,7 @@ bool CBotListArray::Execute(CBotStack* &pj, CBotVar* pVar)
int n = 0;
- for (; p != nullptr ; n++, p = p->GetNext3())
+ for (; p != nullptr ; n++, p = p->GetNext3b())
{
if (pile1->GetState() > n) continue;
@@ -207,7 +206,7 @@ void CBotListArray::RestoreState(CBotStack* &pj, bool bMain)
int state = pile->GetState();
- while(state-- > 0) p = p->GetNext3() ;
+ while(state-- > 0) p = p->GetNext3b() ;
p->RestoreState(pile, bMain); // size calculation //interrupted!
}
diff --git a/src/CBot/CBotInstr/CBotListArray.h b/src/CBot/CBotInstr/CBotListArray.h
index c5f800b..18d6b56 100644
--- a/src/CBot/CBotInstr/CBotListArray.h
+++ b/src/CBot/CBotInstr/CBotListArray.h
@@ -62,7 +62,7 @@ protected:
virtual std::map<std::string, CBotInstr*> GetDebugLinks() override;
private:
- //! An expression for an element others are linked with CBotInstr :: m_next3;
+ //! An expression for an element others are linked with CBotInstr :: m_next3b;
CBotInstr* m_expr;
};
--
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