From d7bfd0a668ccdca58dc824ef0223b869d688a4be Mon Sep 17 00:00:00 2001 From: drmortalwombat <90205530+drmortalwombat@users.noreply.github.com> Date: Sat, 21 Sep 2024 22:00:54 +0200 Subject: [PATCH] Fix invalid function parameter crossing --- oscar64/InterCode.cpp | 4 +++- oscar64/Parser.cpp | 25 ++++++++++++++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/oscar64/InterCode.cpp b/oscar64/InterCode.cpp index 1a00001..d9075f8 100644 --- a/oscar64/InterCode.cpp +++ b/oscar64/InterCode.cpp @@ -783,6 +783,8 @@ bool InterCodeBasicBlock::CollidingMem(const InterOperand& op1, InterType type1, case IM_LOCAL: case IM_FPARAM: case IM_PARAM: + case IM_FRAME: + case IM_FFRAME: return op1.mVarIndex == op2.mVarIndex && op1.mIntConst < op2.mIntConst + op2.mOperandSize && op2.mIntConst < op1.mIntConst + op1.mOperandSize; case IM_ABSOLUTE: return op1.mIntConst < op2.mIntConst + op2.mOperandSize && op2.mIntConst < op1.mIntConst + op1.mOperandSize; @@ -22306,7 +22308,7 @@ void InterCodeProcedure::Close(void) { GrowingTypeArray tstack(IT_NONE); - CheckFunc = !strcmp(mIdent->mString, "f"); + CheckFunc = !strcmp(mIdent->mString, "main"); CheckCase = false; mEntryBlock = mBlocks[0]; diff --git a/oscar64/Parser.cpp b/oscar64/Parser.cpp index 7d63856..2f54500 100644 --- a/oscar64/Parser.cpp +++ b/oscar64/Parser.cpp @@ -5813,19 +5813,34 @@ Expression* Parser::ParseCastExpression(Expression* exp) { if (mScanner->mToken == TK_OPEN_BRACE) { + Declaration* cdec = new Declaration(mScanner->mLocation, DT_VARIABLE); + cdec->mBase = exp->mDecType->ToConstType(); + cdec->mFlags |= DTF_CONST | DTF_STATIC | DTF_GLOBAL | DTF_DEFINED; + + Expression* cexp = new Expression(mScanner->mLocation, EX_VARIABLE); + cexp->mDecValue = cdec; + cexp->mDecType = cdec->mBase; + + cdec->mValue = ParseInitExpression(cdec->mBase); + cdec->mSection = mDataSection; + cdec->mSize = cdec->mBase->mSize; + Declaration* vdec = new Declaration(mScanner->mLocation, DT_VARIABLE); vdec->mBase = exp->mDecType; - vdec->mFlags |= DTF_CONST | DTF_STATIC | DTF_GLOBAL; + vdec->mVarIndex = mLocalIndex++; + vdec->mFlags |= DTF_DEFINED; + vdec->mSize = vdec->mBase->mSize; Expression* nexp = new Expression(mScanner->mLocation, EX_VARIABLE); nexp->mDecValue = vdec; nexp->mDecType = vdec->mBase; - vdec->mValue = ParseInitExpression(vdec->mBase); - vdec->mSection = mDataSection; - vdec->mSize = vdec->mBase->mSize; + Expression* iexp = new Expression(mScanner->mLocation, EX_INITIALIZATION); + iexp->mLeft = nexp; + iexp->mRight = cexp; + iexp->mDecType = exp->mDecType; - exp = nexp; + exp = iexp; } else {