diff --git a/oscar64/Declaration.cpp b/oscar64/Declaration.cpp index e06286d..5c8d061 100644 --- a/oscar64/Declaration.cpp +++ b/oscar64/Declaration.cpp @@ -526,6 +526,18 @@ Expression* Expression::ConstantFold(Errors * errors, LinkerSection * dataSectio ex->mDecType = mDecType; return ex; } + else if (mType == EX_PREFIX && mToken == TK_BINARY_AND && mLeft->mType == EX_INDEX && mLeft->mLeft->mType == EX_VARIABLE && (mLeft->mLeft->mDecValue->mFlags & (DTF_STATIC | DTF_GLOBAL)) && mLeft->mRight->mType == EX_CONSTANT) + { + Expression* ex = new Expression(mLocation, EX_VARIABLE); + Declaration* dec = new Declaration(mLocation, DT_VARIABLE_REF); + dec->mFlags = mLeft->mLeft->mDecValue->mFlags; + dec->mBase = mLeft->mLeft->mDecValue; + dec->mSize = mLeft->mLeft->mDecType->mBase->mSize - int(mLeft->mRight->mDecValue->mInteger) * dec->mSize; + dec->mOffset = int(mLeft->mRight->mDecValue->mInteger) * dec->mSize; + ex->mDecValue = dec; + ex->mDecType = mLeft->mLeft->mDecType; + return ex; + } else if (mType == EX_PREFIX && mToken == TK_BINARY_AND && mLeft->mType == EX_PREFIX && mLeft->mToken == TK_MUL) { return mLeft->mLeft; diff --git a/oscar64/InterCode.cpp b/oscar64/InterCode.cpp index 3b13296..26f4148 100644 --- a/oscar64/InterCode.cpp +++ b/oscar64/InterCode.cpp @@ -17586,12 +17586,15 @@ void InterCodeProcedure::RebuildIntegerRangeSet(void) ResetVisited(); mEntryBlock->RestartLocalIntegerRangeSets(mTemporaries.Size(), mLocalVars, mParamVars); + // No need to re-init the loop specific parts, we are restarting. + // Would lead to inifinte pumping weak - bound in some cases +#if 0 do { DisassembleDebug("tr"); ResetVisited(); } while (mEntryBlock->BuildGlobalIntegerRangeSets(true, mLocalVars, mParamVars)); - +#endif do { DisassembleDebug("tr"); @@ -18431,7 +18434,7 @@ void InterCodeProcedure::Close(void) { GrowingTypeArray tstack(IT_NONE); - CheckFunc = !strcmp(mIdent->mString, "fill"); + CheckFunc = !strcmp(mIdent->mString, "getReady"); CheckCase = false; mEntryBlock = mBlocks[0]; diff --git a/oscar64/InterCodeGenerator.cpp b/oscar64/InterCodeGenerator.cpp index f0a1165..d5ef5aa 100644 --- a/oscar64/InterCodeGenerator.cpp +++ b/oscar64/InterCodeGenerator.cpp @@ -712,6 +712,14 @@ void InterCodeGenerator::InitGlobalVariable(InterCodeModule * mod, Declaration* DestructStack* destack = nullptr; TranslateExpression(nullptr, mMainInitProc, mMainInitBlock, dec->mValue, destack, BranchTarget(), BranchTarget(), nullptr); } + else if (dec->mValue->mType == EX_VARIABLE && dec->mValue->mDecType->mType == DT_TYPE_ARRAY && dec->mBase->mType == DT_TYPE_POINTER && dec->mBase->CanAssign(dec->mValue->mDecType)) + { + Declaration* ndec = new Declaration(dec->mValue->mLocation, DT_CONST_POINTER); + ndec->mValue = dec->mValue; + ndec->mBase = dec->mValue->mDecType; + + BuildInitializer(mod, d, 0, ndec, var); + } else mErrors->Error(dec->mLocation, EERR_CONSTANT_INITIALIZER, "Non constant initializer"); } @@ -2060,7 +2068,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration* block->Append(ins); if (!(dec->mBase->mFlags & DTF_DEFINED)) - mErrors->Error(dec->mLocation, EERR_VARIABLE_TYPE, "Undefined variable type"); + mErrors->Error(dec->mLocation, EERR_VARIABLE_TYPE, "Undefined variable type for", dec->mQualIdent); if (exp->mDecType->IsReference()) return ExValue(exp->mDecType->mBase, ins->mDst.mTemp, ref + 1); @@ -4517,7 +4525,10 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration* } else { - vr = Dereference(proc, exp, block, inlineMapper, vr); + if (vr.mType->mType == DT_TYPE_ARRAY) + vr = Dereference(proc, exp, block, inlineMapper, vr, 1); + else + vr = Dereference(proc, exp, block, inlineMapper, vr); ins->mCode = IC_TYPECAST; ins->mSrc[0].mType = vr.mReference > 0 ? IT_POINTER : InterTypeOf(vr.mType); ins->mSrc[0].mTemp = vr.mTemp;