Fix autotest assert
This commit is contained in:
parent
d8f31b170d
commit
551316fe59
|
@ -16,7 +16,7 @@ int main(void)
|
||||||
put(j, j);
|
put(j, j);
|
||||||
int s = -45;
|
int s = -45;
|
||||||
for(int j=0; j<10; j++)
|
for(int j=0; j<10; j++)
|
||||||
s += get[j];
|
s += get(j);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,6 +87,9 @@ rem @echo off
|
||||||
@call :test arrayinittest.c
|
@call :test arrayinittest.c
|
||||||
@if %errorlevel% neq 0 goto :error
|
@if %errorlevel% neq 0 goto :error
|
||||||
|
|
||||||
|
@call :test arrayindexintrangecheck.c
|
||||||
|
@if %errorlevel% neq 0 goto :error
|
||||||
|
|
||||||
@call :test array2stringinittest.c
|
@call :test array2stringinittest.c
|
||||||
@if %errorlevel% neq 0 goto :error
|
@if %errorlevel% neq 0 goto :error
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ int main(void)
|
||||||
cmpflt( 1.0, 0.0, false, false, true);
|
cmpflt( 1.0, 0.0, false, false, true);
|
||||||
cmpflt(-1.0, 0.0, false, true, false);
|
cmpflt(-1.0, 0.0, false, true, false);
|
||||||
|
|
||||||
#if 1
|
|
||||||
cmpflt( 1.0, 1.0, true, false, false);
|
cmpflt( 1.0, 1.0, true, false, false);
|
||||||
cmpflt( 1.0, 2.0, false, true, false);
|
cmpflt( 1.0, 2.0, false, true, false);
|
||||||
cmpflt( 2.0, 1.0, false, false, true);
|
cmpflt( 2.0, 1.0, false, false, true);
|
||||||
|
@ -94,7 +94,6 @@ int main(void)
|
||||||
cmpflt( -1.0, -1.000001, false, false, true);
|
cmpflt( -1.0, -1.000001, false, false, true);
|
||||||
cmpflt( -1.000001, -1.0, false, true, false);
|
cmpflt( -1.000001, -1.0, false, true, false);
|
||||||
cmpflt( -1.000001, -1.000001, true, false, false);
|
cmpflt( -1.000001, -1.000001, true, false, false);
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,7 +126,7 @@ void DeclarationScope::End(const Location& loc)
|
||||||
}
|
}
|
||||||
|
|
||||||
Expression::Expression(const Location& loc, ExpressionType type)
|
Expression::Expression(const Location& loc, ExpressionType type)
|
||||||
: mLocation(loc), mEndLocation(loc), mType(type), mLeft(nullptr), mRight(nullptr), mConst(false), mDecType(nullptr), mDecValue(nullptr)
|
: mLocation(loc), mEndLocation(loc), mType(type), mLeft(nullptr), mRight(nullptr), mConst(false), mDecType(nullptr), mDecValue(nullptr), mToken(TK_NONE)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1797,6 +1797,7 @@ InterInstruction* InterInstruction::Clone(void) const
|
||||||
{
|
{
|
||||||
InterInstruction* ins = new InterInstruction(mLocation, mCode);
|
InterInstruction* ins = new InterInstruction(mLocation, mCode);
|
||||||
*ins = *this;
|
*ins = *this;
|
||||||
|
ins->mRemove = false;
|
||||||
return ins;
|
return ins;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3866,6 +3867,8 @@ void InterInstruction::BuildCollisionTable(NumberSet& liveTemps, NumberSet* coll
|
||||||
{
|
{
|
||||||
if (mDst.mTemp >= 0)
|
if (mDst.mTemp >= 0)
|
||||||
{
|
{
|
||||||
|
// Ensure collision with unused destination register
|
||||||
|
UpdateCollisionSet(liveTemps, collisionSets, mDst.mTemp);
|
||||||
// if (!liveTemps[ttemp]) __asm int 3
|
// if (!liveTemps[ttemp]) __asm int 3
|
||||||
liveTemps -= mDst.mTemp;
|
liveTemps -= mDst.mTemp;
|
||||||
}
|
}
|
||||||
|
@ -4500,6 +4503,10 @@ void InterCodeBasicBlock::Append(InterInstruction * code)
|
||||||
{
|
{
|
||||||
assert(code->mSrc[1].mType != IT_POINTER);
|
assert(code->mSrc[1].mType != IT_POINTER);
|
||||||
}
|
}
|
||||||
|
if (code->mCode == IC_CONSTANT)
|
||||||
|
{
|
||||||
|
assert(code->mDst.mType == code->mConst.mType);
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < code->mNumOperands; i++)
|
for (int i = 0; i < code->mNumOperands; i++)
|
||||||
assert(code->mSrc[i].mType != IT_NONE);
|
assert(code->mSrc[i].mType != IT_NONE);
|
||||||
|
@ -7928,7 +7935,9 @@ bool InterCodeBasicBlock::CalculateSingleAssignmentTemps(FastNumberSet& tassigne
|
||||||
valid = false;
|
valid = false;
|
||||||
else if (ins->mCode == IC_LOAD)
|
else if (ins->mCode == IC_LOAD)
|
||||||
{
|
{
|
||||||
if (ins->mSrc[0].mMemory == paramMemory)
|
if (ins->mVolatile)
|
||||||
|
valid = false;
|
||||||
|
else if (ins->mSrc[0].mMemory == paramMemory)
|
||||||
{
|
{
|
||||||
if (modifiedParams[ins->mSrc[0].mVarIndex])
|
if (modifiedParams[ins->mSrc[0].mVarIndex])
|
||||||
valid = false;
|
valid = false;
|
||||||
|
@ -12450,6 +12459,8 @@ bool InterCodeBasicBlock::CheapInlining(int & numTemps)
|
||||||
InterInstruction* pins = nins->Clone();
|
InterInstruction* pins = nins->Clone();
|
||||||
if (pins->mSrc[0].mTemp >= 0)
|
if (pins->mSrc[0].mTemp >= 0)
|
||||||
pins->mSrc[0].mTemp = tmap[pins->mSrc[0].mTemp];
|
pins->mSrc[0].mTemp = tmap[pins->mSrc[0].mTemp];
|
||||||
|
if (pins->mSrc[1].mTemp >= 0)
|
||||||
|
pins->mSrc[1].mTemp = tmap[pins->mSrc[1].mTemp];
|
||||||
mInstructions.Insert(i, pins);
|
mInstructions.Insert(i, pins);
|
||||||
i++;
|
i++;
|
||||||
} break;
|
} break;
|
||||||
|
@ -12462,20 +12473,43 @@ bool InterCodeBasicBlock::CheapInlining(int & numTemps)
|
||||||
mInstructions.Insert(i, pins);
|
mInstructions.Insert(i, pins);
|
||||||
i++;
|
i++;
|
||||||
} break;
|
} break;
|
||||||
|
case IC_RETURN:
|
||||||
|
break;
|
||||||
case IC_RETURN_VALUE:
|
case IC_RETURN_VALUE:
|
||||||
{
|
{
|
||||||
if (ins->mDst.mTemp >= 0)
|
if (ins->mDst.mTemp >= 0)
|
||||||
{
|
{
|
||||||
InterInstruction* pins = nins->Clone();
|
InterInstruction* pins = nins->Clone();
|
||||||
|
if (pins->mSrc[0].mTemp < 0)
|
||||||
|
{
|
||||||
|
pins->mCode = IC_CONSTANT;
|
||||||
|
pins->mConst = pins->mSrc[0];
|
||||||
|
pins->mNumOperands = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
pins->mCode = IC_LOAD_TEMPORARY;
|
pins->mCode = IC_LOAD_TEMPORARY;
|
||||||
|
pins->mNumOperands = 1;
|
||||||
|
}
|
||||||
|
|
||||||
pins->mDst = ins->mDst;
|
pins->mDst = ins->mDst;
|
||||||
if (pins->mSrc[0].mTemp >= 0)
|
if (pins->mSrc[0].mTemp >= 0)
|
||||||
pins->mSrc[0].mTemp = tmap[pins->mSrc[0].mTemp];
|
pins->mSrc[0].mTemp = tmap[pins->mSrc[0].mTemp];
|
||||||
pins->mNumOperands = 1;
|
|
||||||
mInstructions.Insert(i, pins);
|
mInstructions.Insert(i, pins);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
InterInstruction* pins = nins->Clone();
|
||||||
|
for (int k = 0; k < pins->mNumOperands; k++)
|
||||||
|
if (pins->mSrc[k].mTemp >= 0)
|
||||||
|
pins->mSrc[k].mTemp = tmap[pins->mSrc[k].mTemp];
|
||||||
|
if (pins->mDst.mTemp >= 0)
|
||||||
|
pins->mDst.mTemp = ntemps;
|
||||||
|
mInstructions.Insert(i, pins);
|
||||||
|
i++;
|
||||||
|
} break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nins->mDst.mTemp >= 0)
|
if (nins->mDst.mTemp >= 0)
|
||||||
|
@ -15853,12 +15887,12 @@ void InterCodeProcedure::SingleAssignmentForwarding(void)
|
||||||
ResetVisited();
|
ResetVisited();
|
||||||
mEntryBlock->SingleAssignmentTempForwarding(tunified, tvalues);
|
mEntryBlock->SingleAssignmentTempForwarding(tunified, tvalues);
|
||||||
|
|
||||||
|
DisassembleDebug("single assignment forwarding");
|
||||||
|
|
||||||
BuildDataFlowSets();
|
BuildDataFlowSets();
|
||||||
TempForwarding();
|
TempForwarding();
|
||||||
RemoveUnusedInstructions();
|
RemoveUnusedInstructions();
|
||||||
|
|
||||||
DisassembleDebug("single assignment forwarding");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InterCodeProcedure::PeepholeOptimization(void)
|
void InterCodeProcedure::PeepholeOptimization(void)
|
||||||
|
@ -16435,7 +16469,7 @@ void InterCodeProcedure::Close(void)
|
||||||
{
|
{
|
||||||
GrowingTypeArray tstack(IT_NONE);
|
GrowingTypeArray tstack(IT_NONE);
|
||||||
|
|
||||||
CheckFunc = !strcmp(mIdent->mString, "tile_draw_g");
|
CheckFunc = !strcmp(mIdent->mString, "main");
|
||||||
|
|
||||||
mEntryBlock = mBlocks[0];
|
mEntryBlock = mBlocks[0];
|
||||||
|
|
||||||
|
@ -16542,7 +16576,7 @@ void InterCodeProcedure::Close(void)
|
||||||
// Check for cheap inlining
|
// Check for cheap inlining
|
||||||
//
|
//
|
||||||
|
|
||||||
if (mCompilerOptions & COPT_OPTIMIZE_AUTO_INLINE)
|
if (mCompilerOptions & COPT_OPTIMIZE_INLINE)
|
||||||
{
|
{
|
||||||
ResetVisited();
|
ResetVisited();
|
||||||
if (mEntryBlock->CheapInlining(numTemps))
|
if (mEntryBlock->CheapInlining(numTemps))
|
||||||
|
@ -16551,6 +16585,8 @@ void InterCodeProcedure::Close(void)
|
||||||
mTemporaries.SetSize(numTemps, true);
|
mTemporaries.SetSize(numTemps, true);
|
||||||
|
|
||||||
DisassembleDebug("Cheap Inlining");
|
DisassembleDebug("Cheap Inlining");
|
||||||
|
|
||||||
|
BuildDataFlowSets();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17263,7 +17299,7 @@ void InterCodeProcedure::Close(void)
|
||||||
|
|
||||||
if (!mEntryBlock->mTrueJump)
|
if (!mEntryBlock->mTrueJump)
|
||||||
{
|
{
|
||||||
int nconst = 0, nvariables = 0, nparams = 0, ncalls = 0, nret = 0, nother = 0;
|
int nconst = 0, nvariables = 0, nparams = 0, ncalls = 0, nret = 0, nother = 0, nops = 0;
|
||||||
for (int i = 0; i < mEntryBlock->mInstructions.Size(); i++)
|
for (int i = 0; i < mEntryBlock->mInstructions.Size(); i++)
|
||||||
{
|
{
|
||||||
InterInstruction* ins = mEntryBlock->mInstructions[i];
|
InterInstruction* ins = mEntryBlock->mInstructions[i];
|
||||||
|
@ -17284,10 +17320,34 @@ void InterCodeProcedure::Close(void)
|
||||||
break;
|
break;
|
||||||
case IC_STORE:
|
case IC_STORE:
|
||||||
if (ins->mSrc[1].mTemp >= 0 || (ins->mSrc[1].mMemory != IM_FFRAME && ins->mSrc[1].mMemory != IM_FRAME))
|
if (ins->mSrc[1].mTemp >= 0 || (ins->mSrc[1].mMemory != IM_FFRAME && ins->mSrc[1].mMemory != IM_FRAME))
|
||||||
nother++;
|
nops++;
|
||||||
if (ins->mSrc[0].mTemp < 0)
|
if (ins->mSrc[0].mTemp < 0)
|
||||||
nconst++;
|
nconst++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
case IC_CONSTANT:
|
||||||
|
if (ins->mConst.mType == IT_POINTER && (ins->mConst.mMemory == IM_FPARAM || ins->mConst.mMemory == IM_PARAM || ins->mConst.mMemory == IM_LOCAL))
|
||||||
|
nother++;
|
||||||
|
else
|
||||||
|
nconst++;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
#if 1
|
||||||
|
case IC_LEA:
|
||||||
|
if (ins->mSrc[1].mTemp >= 0 || (ins->mSrc[1].mMemory != IM_FPARAM && ins->mSrc[1].mMemory != IM_PARAM && ins->mSrc[1].mMemory != IM_LOCAL))
|
||||||
|
nops++;
|
||||||
|
else
|
||||||
|
nother++;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
#if 1
|
||||||
|
case IC_BINARY_OPERATOR:
|
||||||
|
case IC_UNARY_OPERATOR:
|
||||||
|
case IC_RELATIONAL_OPERATOR:
|
||||||
|
nops++;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
case IC_CALL:
|
case IC_CALL:
|
||||||
case IC_CALL_NATIVE:
|
case IC_CALL_NATIVE:
|
||||||
if (ins->mSrc[0].mTemp < 0)
|
if (ins->mSrc[0].mTemp < 0)
|
||||||
|
@ -17304,7 +17364,7 @@ void InterCodeProcedure::Close(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nother == 0 && ncalls == 1 && nret == 1 && nconst < 2)
|
if (nother == 0 && ncalls <= 1 && nret == 1 && nconst <= 1 + nparams && nops <= 1 + nparams)
|
||||||
mCheapInline = true;
|
mCheapInline = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -925,6 +925,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateInline(Declaration* pro
|
||||||
InterInstruction* ains = new InterInstruction(pex->mLocation, IC_CONSTANT);
|
InterInstruction* ains = new InterInstruction(pex->mLocation, IC_CONSTANT);
|
||||||
ains->mDst.mType = IT_POINTER;
|
ains->mDst.mType = IT_POINTER;
|
||||||
ains->mDst.mTemp = proc->AddTemporary(ains->mDst.mType);
|
ains->mDst.mTemp = proc->AddTemporary(ains->mDst.mType);
|
||||||
|
ains->mConst.mType = IT_POINTER;
|
||||||
ains->mConst.mMemory = IM_LOCAL;
|
ains->mConst.mMemory = IM_LOCAL;
|
||||||
ains->mConst.mVarIndex = nindex;
|
ains->mConst.mVarIndex = nindex;
|
||||||
|
|
||||||
|
@ -1090,6 +1091,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateInline(Declaration* pro
|
||||||
InterInstruction* ins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
InterInstruction* ins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
||||||
ins->mDst.mType = IT_POINTER;
|
ins->mDst.mType = IT_POINTER;
|
||||||
ins->mDst.mTemp = proc->AddTemporary(ins->mDst.mType);
|
ins->mDst.mTemp = proc->AddTemporary(ins->mDst.mType);
|
||||||
|
ins->mConst.mType = IT_POINTER;
|
||||||
ins->mConst.mOperandSize = rdec->mSize;
|
ins->mConst.mOperandSize = rdec->mSize;
|
||||||
ins->mConst.mIntConst = rdec->mOffset;
|
ins->mConst.mIntConst = rdec->mOffset;
|
||||||
ins->mConst.mVarIndex = rdec->mVarIndex;
|
ins->mConst.mVarIndex = rdec->mVarIndex;
|
||||||
|
@ -1158,6 +1160,7 @@ void InterCodeGenerator::CopyStruct(InterCodeProcedure* proc, Expression* exp, I
|
||||||
InterInstruction* ains = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
InterInstruction* ains = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
||||||
ains->mDst.mType = IT_POINTER;
|
ains->mDst.mType = IT_POINTER;
|
||||||
ains->mDst.mTemp = proc->AddTemporary(ains->mDst.mType);
|
ains->mDst.mTemp = proc->AddTemporary(ains->mDst.mType);
|
||||||
|
ains->mConst.mType = IT_POINTER;
|
||||||
ains->mConst.mMemory = IM_LOCAL;
|
ains->mConst.mMemory = IM_LOCAL;
|
||||||
ains->mConst.mVarIndex = nindex;
|
ains->mConst.mVarIndex = nindex;
|
||||||
|
|
||||||
|
@ -1192,6 +1195,7 @@ void InterCodeGenerator::CopyStruct(InterCodeProcedure* proc, Expression* exp, I
|
||||||
ains->mNumOperands = 0;
|
ains->mNumOperands = 0;
|
||||||
ains->mDst.mType = IT_POINTER;
|
ains->mDst.mType = IT_POINTER;
|
||||||
ains->mDst.mTemp = proc->AddTemporary(ains->mDst.mType);
|
ains->mDst.mTemp = proc->AddTemporary(ains->mDst.mType);
|
||||||
|
ains->mConst.mType = IT_POINTER;
|
||||||
ains->mConst.mMemory = IM_LOCAL;
|
ains->mConst.mMemory = IM_LOCAL;
|
||||||
ains->mConst.mVarIndex = nindex;
|
ains->mConst.mVarIndex = nindex;
|
||||||
|
|
||||||
|
@ -1230,6 +1234,7 @@ void InterCodeGenerator::CopyStruct(InterCodeProcedure* proc, Expression* exp, I
|
||||||
InterInstruction* psins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
InterInstruction* psins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
||||||
psins->mDst.mType = IT_POINTER;
|
psins->mDst.mType = IT_POINTER;
|
||||||
psins->mDst.mTemp = proc->AddTemporary(IT_POINTER);
|
psins->mDst.mTemp = proc->AddTemporary(IT_POINTER);
|
||||||
|
psins->mConst.mType = IT_POINTER;
|
||||||
psins->mConst.mVarIndex = 0;
|
psins->mConst.mVarIndex = 0;
|
||||||
psins->mConst.mIntConst = 0;
|
psins->mConst.mIntConst = 0;
|
||||||
psins->mConst.mOperandSize = 2;
|
psins->mConst.mOperandSize = 2;
|
||||||
|
@ -1253,6 +1258,7 @@ void InterCodeGenerator::CopyStruct(InterCodeProcedure* proc, Expression* exp, I
|
||||||
InterInstruction* plins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
InterInstruction* plins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
||||||
plins->mDst.mType = IT_POINTER;
|
plins->mDst.mType = IT_POINTER;
|
||||||
plins->mDst.mTemp = proc->AddTemporary(IT_POINTER);
|
plins->mDst.mTemp = proc->AddTemporary(IT_POINTER);
|
||||||
|
plins->mConst.mType = IT_POINTER;
|
||||||
plins->mConst.mVarIndex = 2;
|
plins->mConst.mVarIndex = 2;
|
||||||
plins->mConst.mIntConst = 0;
|
plins->mConst.mIntConst = 0;
|
||||||
plins->mConst.mOperandSize = 2;
|
plins->mConst.mOperandSize = 2;
|
||||||
|
@ -1374,6 +1380,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
ains->mCode = IC_CONSTANT;
|
ains->mCode = IC_CONSTANT;
|
||||||
ains->mDst.mType = IT_POINTER;
|
ains->mDst.mType = IT_POINTER;
|
||||||
ains->mDst.mTemp = proc->AddTemporary(IT_POINTER);
|
ains->mDst.mTemp = proc->AddTemporary(IT_POINTER);
|
||||||
|
ains->mConst.mType = IT_POINTER;
|
||||||
ains->mConst.mOperandSize = procType->mBase->mSize;
|
ains->mConst.mOperandSize = procType->mBase->mSize;
|
||||||
ains->mConst.mIntConst = 0;
|
ains->mConst.mIntConst = 0;
|
||||||
ains->mConst.mVarIndex = inlineMapper->mResult;
|
ains->mConst.mVarIndex = inlineMapper->mResult;
|
||||||
|
@ -1386,6 +1393,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
InterInstruction* pins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
InterInstruction* pins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
||||||
pins->mDst.mType = IT_POINTER;
|
pins->mDst.mType = IT_POINTER;
|
||||||
pins->mDst.mTemp = proc->AddTemporary(IT_POINTER);
|
pins->mDst.mTemp = proc->AddTemporary(IT_POINTER);
|
||||||
|
pins->mConst.mType = IT_POINTER;
|
||||||
pins->mConst.mVarIndex = 0;
|
pins->mConst.mVarIndex = 0;
|
||||||
pins->mConst.mIntConst = 0;
|
pins->mConst.mIntConst = 0;
|
||||||
pins->mConst.mOperandSize = 2;
|
pins->mConst.mOperandSize = 2;
|
||||||
|
@ -1426,6 +1434,8 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
InterInstruction * ins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
InterInstruction * ins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
||||||
ins->mDst.mType = InterTypeOf(dec->mBase);
|
ins->mDst.mType = InterTypeOf(dec->mBase);
|
||||||
ins->mDst.mTemp = proc->AddTemporary(ins->mDst.mType);
|
ins->mDst.mTemp = proc->AddTemporary(ins->mDst.mType);
|
||||||
|
ins->mConst.mType = ins->mDst.mType;
|
||||||
|
|
||||||
if (ins->mDst.mType == IT_INT8)
|
if (ins->mDst.mType == IT_INT8)
|
||||||
{
|
{
|
||||||
if (dec->mBase->mFlags & DTF_SIGNED)
|
if (dec->mBase->mFlags & DTF_SIGNED)
|
||||||
|
@ -1485,6 +1495,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
InterInstruction * ins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
InterInstruction * ins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
||||||
ins->mDst.mType = InterTypeOf(dec->mBase);
|
ins->mDst.mType = InterTypeOf(dec->mBase);
|
||||||
ins->mDst.mTemp = proc->AddTemporary(ins->mDst.mType);
|
ins->mDst.mTemp = proc->AddTemporary(ins->mDst.mType);
|
||||||
|
ins->mConst.mType = ins->mDst.mType;
|
||||||
ins->mConst.mFloatConst = dec->mNumber;
|
ins->mConst.mFloatConst = dec->mNumber;
|
||||||
block->Append(ins);
|
block->Append(ins);
|
||||||
return ExValue(dec->mBase, ins->mDst.mTemp);
|
return ExValue(dec->mBase, ins->mDst.mTemp);
|
||||||
|
@ -1496,6 +1507,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
InterInstruction * ins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
InterInstruction * ins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
||||||
ins->mDst.mType = IT_POINTER;
|
ins->mDst.mType = IT_POINTER;
|
||||||
ins->mDst.mTemp = proc->AddTemporary(IT_POINTER);
|
ins->mDst.mTemp = proc->AddTemporary(IT_POINTER);
|
||||||
|
ins->mConst.mType = IT_POINTER;
|
||||||
ins->mConst.mIntConst = dec->mInteger;
|
ins->mConst.mIntConst = dec->mInteger;
|
||||||
ins->mConst.mMemory = IM_ABSOLUTE;
|
ins->mConst.mMemory = IM_ABSOLUTE;
|
||||||
block->Append(ins);
|
block->Append(ins);
|
||||||
|
@ -1513,6 +1525,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
InterInstruction * ins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
InterInstruction * ins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
||||||
ins->mDst.mType = InterTypeOf(dec->mBase);
|
ins->mDst.mType = InterTypeOf(dec->mBase);
|
||||||
ins->mDst.mTemp = proc->AddTemporary(ins->mDst.mType);
|
ins->mDst.mTemp = proc->AddTemporary(ins->mDst.mType);
|
||||||
|
ins->mConst.mType = ins->mDst.mType;
|
||||||
ins->mConst.mVarIndex = dec->mVarIndex;
|
ins->mConst.mVarIndex = dec->mVarIndex;
|
||||||
ins->mConst.mLinkerObject = dec->mLinkerObject;
|
ins->mConst.mLinkerObject = dec->mLinkerObject;
|
||||||
ins->mConst.mMemory = IM_PROCEDURE;
|
ins->mConst.mMemory = IM_PROCEDURE;
|
||||||
|
@ -1530,6 +1543,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
InterInstruction* ins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
InterInstruction* ins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
||||||
ins->mDst.mType = IT_POINTER;
|
ins->mDst.mType = IT_POINTER;
|
||||||
ins->mDst.mTemp = proc->AddTemporary(ins->mDst.mType);
|
ins->mDst.mTemp = proc->AddTemporary(ins->mDst.mType);
|
||||||
|
ins->mConst.mType = IT_POINTER;
|
||||||
ins->mConst.mVarIndex = dec->mVarIndex;
|
ins->mConst.mVarIndex = dec->mVarIndex;
|
||||||
ins->mConst.mLinkerObject = dec->mLinkerObject;
|
ins->mConst.mLinkerObject = dec->mLinkerObject;
|
||||||
ins->mConst.mMemory = IM_PROCEDURE;
|
ins->mConst.mMemory = IM_PROCEDURE;
|
||||||
|
@ -1566,6 +1580,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
InterInstruction * ins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
InterInstruction * ins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
||||||
ins->mDst.mType = IT_POINTER;
|
ins->mDst.mType = IT_POINTER;
|
||||||
ins->mDst.mTemp = proc->AddTemporary(IT_POINTER);
|
ins->mDst.mTemp = proc->AddTemporary(IT_POINTER);
|
||||||
|
ins->mConst.mType = IT_POINTER;
|
||||||
ins->mConst.mIntConst = 0;
|
ins->mConst.mIntConst = 0;
|
||||||
ins->mConst.mVarIndex = dec->mVarIndex;
|
ins->mConst.mVarIndex = dec->mVarIndex;
|
||||||
assert(dec->mVarIndex >= 0);
|
assert(dec->mVarIndex >= 0);
|
||||||
|
@ -1599,6 +1614,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
InterInstruction * ins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
InterInstruction * ins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
||||||
ins->mDst.mType = IT_POINTER;
|
ins->mDst.mType = IT_POINTER;
|
||||||
ins->mDst.mTemp = proc->AddTemporary(IT_POINTER);
|
ins->mDst.mTemp = proc->AddTemporary(IT_POINTER);
|
||||||
|
ins->mConst.mType = IT_POINTER;
|
||||||
ins->mConst.mIntConst = 0;
|
ins->mConst.mIntConst = 0;
|
||||||
ins->mConst.mVarIndex = dec->mVarIndex;
|
ins->mConst.mVarIndex = dec->mVarIndex;
|
||||||
assert(dec->mVarIndex >= 0);
|
assert(dec->mVarIndex >= 0);
|
||||||
|
@ -1823,6 +1839,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
if (vl.mType->mType == DT_TYPE_POINTER)
|
if (vl.mType->mType == DT_TYPE_POINTER)
|
||||||
{
|
{
|
||||||
InterInstruction * cins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
InterInstruction * cins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
||||||
|
cins->mConst.mType = IT_INT16;
|
||||||
|
|
||||||
if (exp->mToken == TK_ASSIGN_ADD)
|
if (exp->mToken == TK_ASSIGN_ADD)
|
||||||
{
|
{
|
||||||
|
@ -2002,6 +2019,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
vr = CoerceType(proc, exp, block, vr, TheSignedIntTypeDeclaration);
|
vr = CoerceType(proc, exp, block, vr, TheSignedIntTypeDeclaration);
|
||||||
|
|
||||||
InterInstruction * cins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
InterInstruction * cins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
||||||
|
cins->mConst.mType = IT_INT16;
|
||||||
cins->mConst.mIntConst = stride;
|
cins->mConst.mIntConst = stride;
|
||||||
cins->mDst.mType = IT_INT16;
|
cins->mDst.mType = IT_INT16;
|
||||||
cins->mDst.mTemp = proc->AddTemporary(cins->mDst.mType);
|
cins->mDst.mTemp = proc->AddTemporary(cins->mDst.mType);
|
||||||
|
@ -2042,6 +2060,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
mErrors->Error(exp->mLocation, EERR_NOT_AN_LVALUE, "Not an addressable expression");
|
mErrors->Error(exp->mLocation, EERR_NOT_AN_LVALUE, "Not an addressable expression");
|
||||||
|
|
||||||
InterInstruction * cins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
InterInstruction * cins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
||||||
|
cins->mConst.mType = IT_INT16;
|
||||||
cins->mConst.mIntConst = exp->mDecValue->mOffset;
|
cins->mConst.mIntConst = exp->mDecValue->mOffset;
|
||||||
cins->mDst.mType = IT_INT16;
|
cins->mDst.mType = IT_INT16;
|
||||||
cins->mDst.mTemp = proc->AddTemporary(cins->mDst.mType);
|
cins->mDst.mTemp = proc->AddTemporary(cins->mDst.mType);
|
||||||
|
@ -2090,6 +2109,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
if (vr.mType->IsIntegerType())
|
if (vr.mType->IsIntegerType())
|
||||||
{
|
{
|
||||||
InterInstruction * cins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
InterInstruction * cins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
||||||
|
cins->mConst.mType = IT_INT16;
|
||||||
|
|
||||||
if (exp->mToken == TK_ADD)
|
if (exp->mToken == TK_ADD)
|
||||||
{
|
{
|
||||||
|
@ -2160,6 +2180,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
}
|
}
|
||||||
|
|
||||||
InterInstruction * cins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
InterInstruction * cins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
||||||
|
cins->mConst.mType = IT_INT16;
|
||||||
cins->mConst.mIntConst = s;
|
cins->mConst.mIntConst = s;
|
||||||
cins->mDst.mType = IT_INT16;
|
cins->mDst.mType = IT_INT16;
|
||||||
cins->mDst.mTemp = proc->AddTemporary(cins->mDst.mType);
|
cins->mDst.mTemp = proc->AddTemporary(cins->mDst.mType);
|
||||||
|
@ -2209,6 +2230,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
if (vl.mType->IsIntegerType())
|
if (vl.mType->IsIntegerType())
|
||||||
{
|
{
|
||||||
InterInstruction* cins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
InterInstruction* cins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
||||||
|
cins->mConst.mType = IT_INT16;
|
||||||
|
|
||||||
if (exp->mToken == TK_ADD)
|
if (exp->mToken == TK_ADD)
|
||||||
{
|
{
|
||||||
|
@ -2394,10 +2416,15 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
|
|
||||||
cins->mDst.mType = ftype ? IT_FLOAT : IT_INT16;
|
cins->mDst.mType = ftype ? IT_FLOAT : IT_INT16;
|
||||||
cins->mDst.mTemp = proc->AddTemporary(cins->mDst.mType);
|
cins->mDst.mTemp = proc->AddTemporary(cins->mDst.mType);
|
||||||
|
cins->mConst.mType = cins->mDst.mType;
|
||||||
|
|
||||||
if (vdl.mType->mType == DT_TYPE_POINTER)
|
if (vdl.mType->mType == DT_TYPE_POINTER)
|
||||||
cins->mConst.mIntConst = exp->mToken == TK_INC ? vdl.mType->Stride() : -(vdl.mType->Stride());
|
cins->mConst.mIntConst = exp->mToken == TK_INC ? vdl.mType->Stride() : -(vdl.mType->Stride());
|
||||||
else if (vdl.mType->IsNumericType())
|
else if (vdl.mType->IsNumericType())
|
||||||
|
{
|
||||||
cins->mConst.mIntConst = exp->mToken == TK_INC ? 1 : -1;
|
cins->mConst.mIntConst = exp->mToken == TK_INC ? 1 : -1;
|
||||||
|
cins->mConst.mFloatConst = double(cins->mConst.mIntConst);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
mErrors->Error(exp->mLocation, EERR_INCOMPATIBLE_OPERATOR, "Not a numeric value or pointer");
|
mErrors->Error(exp->mLocation, EERR_INCOMPATIBLE_OPERATOR, "Not a numeric value or pointer");
|
||||||
|
|
||||||
|
@ -2456,10 +2483,15 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
|
|
||||||
cins->mDst.mType = ftype ? IT_FLOAT : IT_INT16;
|
cins->mDst.mType = ftype ? IT_FLOAT : IT_INT16;
|
||||||
cins->mDst.mTemp = proc->AddTemporary(cins->mDst.mType);
|
cins->mDst.mTemp = proc->AddTemporary(cins->mDst.mType);
|
||||||
|
cins->mConst.mType = cins->mDst.mType;
|
||||||
|
|
||||||
if (vdl.mType->mType == DT_TYPE_POINTER)
|
if (vdl.mType->mType == DT_TYPE_POINTER)
|
||||||
cins->mConst.mIntConst = exp->mToken == TK_INC ? vdl.mType->Stride() : -(vdl.mType->Stride());
|
cins->mConst.mIntConst = exp->mToken == TK_INC ? vdl.mType->Stride() : -(vdl.mType->Stride());
|
||||||
else if (vdl.mType->IsNumericType())
|
else if (vdl.mType->IsNumericType())
|
||||||
|
{
|
||||||
cins->mConst.mIntConst = exp->mToken == TK_INC ? 1 : -1;
|
cins->mConst.mIntConst = exp->mToken == TK_INC ? 1 : -1;
|
||||||
|
cins->mConst.mFloatConst = double(cins->mConst.mIntConst);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
mErrors->Error(exp->mLocation, EERR_INCOMPATIBLE_OPERATOR, "Not a numeric value or pointer");
|
mErrors->Error(exp->mLocation, EERR_INCOMPATIBLE_OPERATOR, "Not a numeric value or pointer");
|
||||||
block->Append(cins);
|
block->Append(cins);
|
||||||
|
@ -2838,6 +2870,8 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
mErrors->Error(sex->mLocation, EERR_INCOMPATIBLE_TYPES, "Cannot assign incompatible types");
|
mErrors->Error(sex->mLocation, EERR_INCOMPATIBLE_TYPES, "Cannot assign incompatible types");
|
||||||
|
|
||||||
InterInstruction* ins = new InterInstruction(exp->mLocation, IC_STRCPY);
|
InterInstruction* ins = new InterInstruction(exp->mLocation, IC_STRCPY);
|
||||||
|
ins->mNumOperands = 2;
|
||||||
|
|
||||||
ins->mSrc[0].mType = IT_POINTER;
|
ins->mSrc[0].mType = IT_POINTER;
|
||||||
ins->mSrc[0].mMemory = IM_INDIRECT;
|
ins->mSrc[0].mMemory = IM_INDIRECT;
|
||||||
ins->mSrc[0].mTemp = vr.mTemp;
|
ins->mSrc[0].mTemp = vr.mTemp;
|
||||||
|
@ -3006,6 +3040,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
InterInstruction* vins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
InterInstruction* vins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
||||||
vins->mDst.mType = IT_POINTER;
|
vins->mDst.mType = IT_POINTER;
|
||||||
vins->mDst.mTemp = proc->AddTemporary(IT_POINTER);
|
vins->mDst.mTemp = proc->AddTemporary(IT_POINTER);
|
||||||
|
vins->mConst.mType = IT_POINTER;
|
||||||
vins->mConst.mMemory = IM_LOCAL;
|
vins->mConst.mMemory = IM_LOCAL;
|
||||||
vins->mConst.mVarIndex = nindex;
|
vins->mConst.mVarIndex = nindex;
|
||||||
vins->mConst.mOperandSize = ftype->mBase->mSize;
|
vins->mConst.mOperandSize = ftype->mBase->mSize;
|
||||||
|
@ -3017,6 +3052,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
InterInstruction* ains = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
InterInstruction* ains = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
||||||
ains->mDst.mType = IT_POINTER;
|
ains->mDst.mType = IT_POINTER;
|
||||||
ains->mDst.mTemp = proc->AddTemporary(IT_POINTER);
|
ains->mDst.mTemp = proc->AddTemporary(IT_POINTER);
|
||||||
|
ains->mConst.mType = IT_POINTER;
|
||||||
ains->mConst.mVarIndex = 0;
|
ains->mConst.mVarIndex = 0;
|
||||||
ains->mConst.mIntConst = 0;
|
ains->mConst.mIntConst = 0;
|
||||||
ains->mConst.mOperandSize = 2;
|
ains->mConst.mOperandSize = 2;
|
||||||
|
@ -3055,6 +3091,8 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
while (pex)
|
while (pex)
|
||||||
{
|
{
|
||||||
InterInstruction * ains = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
InterInstruction * ains = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
||||||
|
ains->mConst.mType = IT_POINTER;
|
||||||
|
|
||||||
ains->mDst.mType = IT_POINTER;
|
ains->mDst.mType = IT_POINTER;
|
||||||
ains->mDst.mTemp = proc->AddTemporary(ains->mDst.mType);
|
ains->mDst.mTemp = proc->AddTemporary(ains->mDst.mType);
|
||||||
if (pdec)
|
if (pdec)
|
||||||
|
@ -3285,6 +3323,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
InterInstruction* vins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
InterInstruction* vins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
||||||
vins->mDst.mType = IT_POINTER;
|
vins->mDst.mType = IT_POINTER;
|
||||||
vins->mDst.mTemp = proc->AddTemporary(IT_POINTER);
|
vins->mDst.mTemp = proc->AddTemporary(IT_POINTER);
|
||||||
|
vins->mConst.mType = IT_POINTER;
|
||||||
vins->mConst.mMemory = IM_LOCAL;
|
vins->mConst.mMemory = IM_LOCAL;
|
||||||
vins->mConst.mVarIndex = decResult->mVarIndex;
|
vins->mConst.mVarIndex = decResult->mVarIndex;
|
||||||
block->Append(vins);
|
block->Append(vins);
|
||||||
|
@ -3314,6 +3353,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
InterInstruction* ins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
InterInstruction* ins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
||||||
ins->mDst.mType = IT_POINTER;
|
ins->mDst.mType = IT_POINTER;
|
||||||
ins->mDst.mTemp = proc->AddTemporary(ins->mDst.mType);
|
ins->mDst.mTemp = proc->AddTemporary(ins->mDst.mType);
|
||||||
|
ins->mConst.mType = IT_POINTER;
|
||||||
ins->mConst.mOperandSize = dec->mSize;
|
ins->mConst.mOperandSize = dec->mSize;
|
||||||
ins->mConst.mIntConst = 0;
|
ins->mConst.mIntConst = 0;
|
||||||
ins->mConst.mMemory = IM_GLOBAL;
|
ins->mConst.mMemory = IM_GLOBAL;
|
||||||
|
@ -3332,6 +3372,8 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
for (int i = 0; i < refvars.Size(); i++)
|
for (int i = 0; i < refvars.Size(); i++)
|
||||||
{
|
{
|
||||||
InterInstruction* vins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
InterInstruction* vins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
||||||
|
vins->mConst.mType = IT_POINTER;
|
||||||
|
|
||||||
vins->mDst.mType = IT_POINTER;
|
vins->mDst.mType = IT_POINTER;
|
||||||
vins->mDst.mTemp = proc->AddTemporary(ins->mDst.mType);
|
vins->mDst.mTemp = proc->AddTemporary(ins->mDst.mType);
|
||||||
|
|
||||||
|
@ -3425,6 +3467,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
InterInstruction* ains = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
InterInstruction* ains = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
||||||
ains->mDst.mType = IT_POINTER;
|
ains->mDst.mType = IT_POINTER;
|
||||||
ains->mDst.mTemp = proc->AddTemporary(ins->mDst.mType);
|
ains->mDst.mTemp = proc->AddTemporary(ins->mDst.mType);
|
||||||
|
ains->mConst.mType = IT_POINTER;
|
||||||
ains->mConst.mOperandSize = procType->mBase->mSize;
|
ains->mConst.mOperandSize = procType->mBase->mSize;
|
||||||
ains->mConst.mIntConst = 0;
|
ains->mConst.mIntConst = 0;
|
||||||
ains->mConst.mVarIndex = inlineMapper->mResult;;
|
ains->mConst.mVarIndex = inlineMapper->mResult;;
|
||||||
|
@ -3461,6 +3504,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
ains->mCode = IC_CONSTANT;
|
ains->mCode = IC_CONSTANT;
|
||||||
ains->mDst.mType = IT_POINTER;
|
ains->mDst.mType = IT_POINTER;
|
||||||
ains->mDst.mTemp = proc->AddTemporary(IT_POINTER);
|
ains->mDst.mTemp = proc->AddTemporary(IT_POINTER);
|
||||||
|
ains->mConst.mType = IT_POINTER;
|
||||||
ains->mConst.mOperandSize = procType->mBase->mSize;
|
ains->mConst.mOperandSize = procType->mBase->mSize;
|
||||||
ains->mConst.mIntConst = 0;
|
ains->mConst.mIntConst = 0;
|
||||||
ains->mConst.mVarIndex = inlineMapper->mResult;
|
ains->mConst.mVarIndex = inlineMapper->mResult;
|
||||||
|
@ -3475,6 +3519,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
InterInstruction* pins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
InterInstruction* pins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
||||||
pins->mDst.mType = IT_POINTER;
|
pins->mDst.mType = IT_POINTER;
|
||||||
pins->mDst.mTemp = proc->AddTemporary(IT_POINTER);
|
pins->mDst.mTemp = proc->AddTemporary(IT_POINTER);
|
||||||
|
pins->mConst.mType = IT_POINTER;
|
||||||
pins->mConst.mVarIndex = 0;
|
pins->mConst.mVarIndex = 0;
|
||||||
pins->mConst.mIntConst = 0;
|
pins->mConst.mIntConst = 0;
|
||||||
pins->mConst.mOperandSize = 2;
|
pins->mConst.mOperandSize = 2;
|
||||||
|
@ -3641,6 +3686,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
InterInstruction* ains = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
InterInstruction* ains = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
||||||
ains->mDst.mType = IT_POINTER;
|
ains->mDst.mType = IT_POINTER;
|
||||||
ains->mDst.mTemp = proc->AddTemporary(ins->mDst.mType);
|
ains->mDst.mTemp = proc->AddTemporary(ins->mDst.mType);
|
||||||
|
ains->mConst.mType = IT_POINTER;
|
||||||
ains->mConst.mOperandSize = procType->mBase->mSize;
|
ains->mConst.mOperandSize = procType->mBase->mSize;
|
||||||
ains->mConst.mIntConst = 0;
|
ains->mConst.mIntConst = 0;
|
||||||
ains->mConst.mVarIndex = inlineMapper->mResult;;
|
ains->mConst.mVarIndex = inlineMapper->mResult;;
|
||||||
|
@ -3751,6 +3797,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
InterInstruction * zins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
InterInstruction * zins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
||||||
zins->mDst.mType = InterTypeOf(vl.mType);
|
zins->mDst.mType = InterTypeOf(vl.mType);
|
||||||
zins->mDst.mTemp = proc->AddTemporary(zins->mDst.mType);
|
zins->mDst.mTemp = proc->AddTemporary(zins->mDst.mType);
|
||||||
|
zins->mConst.mType = zins->mDst.mType;
|
||||||
zins->mConst.mIntConst = 0;
|
zins->mConst.mIntConst = 0;
|
||||||
block->Append(zins);
|
block->Append(zins);
|
||||||
|
|
||||||
|
@ -4079,12 +4126,14 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
int ttemp = proc->AddTemporary(IT_BOOL);
|
int ttemp = proc->AddTemporary(IT_BOOL);
|
||||||
|
|
||||||
InterInstruction* tins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
InterInstruction* tins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
||||||
|
tins->mConst.mType = IT_BOOL;
|
||||||
tins->mConst.mIntConst = 1;
|
tins->mConst.mIntConst = 1;
|
||||||
tins->mDst.mType = IT_BOOL;
|
tins->mDst.mType = IT_BOOL;
|
||||||
tins->mDst.mTemp = ttemp;
|
tins->mDst.mTemp = ttemp;
|
||||||
tblock->Append(tins);
|
tblock->Append(tins);
|
||||||
|
|
||||||
InterInstruction* fins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
InterInstruction* fins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
||||||
|
fins->mConst.mType = IT_BOOL;
|
||||||
fins->mConst.mIntConst = 0;
|
fins->mConst.mIntConst = 0;
|
||||||
fins->mDst.mType = IT_BOOL;
|
fins->mDst.mType = IT_BOOL;
|
||||||
fins->mDst.mTemp = ttemp;
|
fins->mDst.mTemp = ttemp;
|
||||||
|
|
|
@ -25065,6 +25065,8 @@ bool NativeCodeBasicBlock::MoveZeroPageCrossBlockUp(int at, const NativeCodeInst
|
||||||
return false;
|
return false;
|
||||||
else if (mIns[i].ReferencesZeroPage(sins.mAddress))
|
else if (mIns[i].ReferencesZeroPage(sins.mAddress))
|
||||||
return false;
|
return false;
|
||||||
|
else if (mIns[i].mType == ASMIT_JSR && mIns[i].ReferencesZeroPage(lins.mAddress))
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40393,7 +40395,7 @@ void NativeCodeProcedure::Compile(InterCodeProcedure* proc)
|
||||||
{
|
{
|
||||||
mInterProc = proc;
|
mInterProc = proc;
|
||||||
|
|
||||||
CheckFunc = !strcmp(mInterProc->mIdent->mString, "getchar");
|
CheckFunc = !strcmp(mInterProc->mIdent->mString, "main");
|
||||||
|
|
||||||
int nblocks = proc->mBlocks.Size();
|
int nblocks = proc->mBlocks.Size();
|
||||||
tblocks = new NativeCodeBasicBlock * [nblocks];
|
tblocks = new NativeCodeBasicBlock * [nblocks];
|
||||||
|
@ -41688,7 +41690,6 @@ void NativeCodeProcedure::Optimize(void)
|
||||||
else
|
else
|
||||||
cnt++;
|
cnt++;
|
||||||
|
|
||||||
|
|
||||||
} while (changed);
|
} while (changed);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5002,6 +5002,7 @@ Expression* Parser::ParsePostfixExpression(bool lhs)
|
||||||
mScanner->NextToken();
|
mScanner->NextToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool parentCall = false;
|
||||||
if ((exp->mDecType->mFlags & DTF_FUNC_THIS) && mThisPointer && mThisPointer->mType == DT_ARGUMENT)
|
if ((exp->mDecType->mFlags & DTF_FUNC_THIS) && mThisPointer && mThisPointer->mType == DT_ARGUMENT)
|
||||||
{
|
{
|
||||||
Expression* texp = new Expression(mScanner->mLocation, EX_VARIABLE);
|
Expression* texp = new Expression(mScanner->mLocation, EX_VARIABLE);
|
||||||
|
@ -5017,13 +5018,20 @@ Expression* Parser::ParsePostfixExpression(bool lhs)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
nexp->mRight = texp;
|
nexp->mRight = texp;
|
||||||
|
|
||||||
|
parentCall = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
nexp = ResolveOverloadCall(nexp);
|
nexp = ResolveOverloadCall(nexp);
|
||||||
nexp->mDecType = exp->mDecType->mBase;
|
nexp->mDecType = exp->mDecType->mBase;
|
||||||
|
|
||||||
if (nexp->mLeft->mDecType->mFlags & DTF_VIRTUAL)
|
if (nexp->mLeft->mDecType->mFlags & DTF_VIRTUAL)
|
||||||
|
{
|
||||||
|
if (parentCall)
|
||||||
|
exp->mDecType->mFlags |= DTF_STACKCALL;
|
||||||
|
else
|
||||||
nexp->mType = EX_VCALL;
|
nexp->mType = EX_VCALL;
|
||||||
|
}
|
||||||
|
|
||||||
exp = nexp;
|
exp = nexp;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue