diff --git a/oscar64/InterCodeGenerator.cpp b/oscar64/InterCodeGenerator.cpp index 9fe9cf9..da41554 100644 --- a/oscar64/InterCodeGenerator.cpp +++ b/oscar64/InterCodeGenerator.cpp @@ -2452,8 +2452,16 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration* if (vl.mType->mType == DT_TYPE_POINTER || vr.mType->mType == DT_TYPE_POINTER) { dtype = vl.mType; - if (vl.mType->IsIntegerType() || vr.mType->IsIntegerType()) - ; + if (vl.mType->IsIntegerType()) + { + if ((mCompilerOptions & COPT_CPLUSPLUS) || exp->mLeft->mType != EX_CONSTANT || exp->mLeft->mDecValue->mInteger != 0) + mErrors->Error(exp->mLocation, EERR_INCOMPATIBLE_TYPES, "Cannot compare integer and pointer"); + } + else if (vr.mType->IsIntegerType()) + { + if ((mCompilerOptions & COPT_CPLUSPLUS) || exp->mRight->mType != EX_CONSTANT || exp->mRight->mDecValue->mInteger != 0) + mErrors->Error(exp->mLocation, EERR_INCOMPATIBLE_TYPES, "Cannot compare integer and pointer"); + } else if ((vl.mType->mType == DT_TYPE_POINTER || vl.mType->mType == DT_TYPE_ARRAY) && (vr.mType->mType == DT_TYPE_POINTER || vr.mType->mType == DT_TYPE_ARRAY)) { if (vl.mType->mBase->mType == DT_TYPE_VOID || vr.mType->mBase->mType == DT_TYPE_VOID) diff --git a/oscar64/NativeCodeGenerator.cpp b/oscar64/NativeCodeGenerator.cpp index 308af63..166976a 100644 --- a/oscar64/NativeCodeGenerator.cpp +++ b/oscar64/NativeCodeGenerator.cpp @@ -12350,7 +12350,7 @@ void NativeCodeBasicBlock::BuildCollisionTable(NumberSet* collisionSets) } } -void NativeCodeBasicBlock::BuildDominatorTree(NativeCodeBasicBlock* from) +void NativeCodeBasicBlock::BuildDominatorTree(NativeCodeBasicBlock* from, DominatorStacks& stacks) { if (from == this) return; @@ -12360,25 +12360,26 @@ void NativeCodeBasicBlock::BuildDominatorTree(NativeCodeBasicBlock* from) return; else { - ExpandingArray< NativeCodeBasicBlock * > d1, d2; + stacks.d1.SetSize(0); + stacks.d2.SetSize(0); NativeCodeBasicBlock* b = mDominator; while (b) { - d1.Push(b); + stacks.d1.Push(b); b = b->mDominator; } b = from; while (b) { - d2.Push(b); + stacks.d2.Push(b); b = b->mDominator; } b = nullptr; - while (d1.Size() > 0 && d2.Size() > 0 && d1.Last() == d2.Last()) + while (stacks.d1.Size() > 0 && stacks.d2.Size() > 0 && stacks.d1.Last() == stacks.d2.Last()) { - b = d1.Pop(); d2.Pop(); + b = stacks.d1.Pop(); stacks.d2.Pop(); } if (mDominator == b) @@ -12388,9 +12389,9 @@ void NativeCodeBasicBlock::BuildDominatorTree(NativeCodeBasicBlock* from) } if (mTrueJump) - mTrueJump->BuildDominatorTree(this); + mTrueJump->BuildDominatorTree(this, stacks); if (mFalseJump) - mFalseJump->BuildDominatorTree(this); + mFalseJump->BuildDominatorTree(this, stacks); } @@ -40657,8 +40658,9 @@ void NativeCodeProcedure::RebuildEntry(void) ResetVisited(); mEntryBlock->CollectEntryBlocks(nullptr); + NativeCodeBasicBlock::DominatorStacks stacks; - mEntryBlock->BuildDominatorTree(nullptr); + mEntryBlock->BuildDominatorTree(nullptr, stacks); } void NativeCodeProcedure::Optimize(void) @@ -41523,13 +41525,14 @@ void NativeCodeProcedure::ResetPatched(void) { for (int i = 0; i < mBlocks.Size(); i++) { - mBlocks[i]->mPatched = false; - mBlocks[i]->mPatchFail = false; - mBlocks[i]->mPatchChecked = false; - mBlocks[i]->mPatchStart = false; - mBlocks[i]->mPatchLoop = false; - mBlocks[i]->mPatchLoopChanged = false; - mBlocks[i]->mPatchExit = false; + NativeCodeBasicBlock* b = mBlocks[i]; + b->mPatched = false; + b->mPatchFail = false; + b->mPatchChecked = false; + b->mPatchStart = false; + b->mPatchLoop = false; + b->mPatchLoopChanged = false; + b->mPatchExit = false; } } diff --git a/oscar64/NativeCodeGenerator.h b/oscar64/NativeCodeGenerator.h index b5c8c5e..97e44bb 100644 --- a/oscar64/NativeCodeGenerator.h +++ b/oscar64/NativeCodeGenerator.h @@ -370,7 +370,13 @@ public: NativeCodeBasicBlock * ForwardAccuBranch(bool eq, bool ne, bool pl, bool mi, int limit); bool MergeBasicBlocks(void); void MarkLoopHead(void); - void BuildDominatorTree(NativeCodeBasicBlock * from); + + struct DominatorStacks + { + ExpandingArray< NativeCodeBasicBlock* > d1, d2; + }; + + void BuildDominatorTree(NativeCodeBasicBlock * from, DominatorStacks & stacks); bool MoveLoadStoreUp(int at); bool MoveLoadStoreXUp(int at); diff --git a/oscar64/Parser.cpp b/oscar64/Parser.cpp index 7f523b5..79cbbaf 100644 --- a/oscar64/Parser.cpp +++ b/oscar64/Parser.cpp @@ -1253,7 +1253,7 @@ void Parser::PrependMemberConstructor(Declaration* pthis, Declaration* cfunc) { Expression* pthisexp = new Expression(pthis->mLocation, EX_VARIABLE); pthisexp->mDecType = pthis; - pthisexp->mDecValue = pthis->mBase->mDestructor->mBase->mParams; + pthisexp->mDecValue = cfunc->mBase->mParams; Expression* thisexp = new Expression(mScanner->mLocation, EX_PREFIX); thisexp->mToken = TK_MUL; diff --git a/samples/memmap/charsetload.d64 b/samples/memmap/charsetload.d64 index 10be50b..ea91a38 100644 Binary files a/samples/memmap/charsetload.d64 and b/samples/memmap/charsetload.d64 differ