add alias _Bool for bool

This commit is contained in:
drmortalwombat 2022-05-15 10:53:58 +02:00
parent 728e707024
commit 46fe117f1f
7 changed files with 60 additions and 10 deletions

View File

@ -914,3 +914,5 @@ void bmmc_flood_fill(const Bitmap * bm, const ClipRect * clip, int x, int y, cha
}
}
}
#pragma native(bmmc_flood_fill)

View File

@ -2,6 +2,12 @@
#include <math.h>
#include <fixmath.h>
void vec2_set(Vector2 * vd, float x, float y)
{
vd->v[0] = x;
vd->v[1] = y;
}
void vec2_sum(Vector2 * vd, const Vector2 * v1, const Vector2 * v2)
{
vd->v[0] = v1->v[0] + v2->v[0];

View File

@ -6,6 +6,8 @@ struct Vector2
float v[2];
};
inline void vec2_set(Vector2 * vd, float x, float y);
void vec2_sum(Vector2 * vd, const Vector2 * v1, const Vector2 * v2);
void vec2_diff(Vector2 * vd, const Vector2 * v1, const Vector2 * v2);

View File

@ -1,9 +1,11 @@
#ifndef STDBOOL_H
#define STDBOOL_H
#define bool bool
#define true true
#define false false
#define bool _Bool
#define true (0 == 0)
#define false (0 != 0)
#define __bool_true_false_are_defined 1
#endif

View File

@ -5045,6 +5045,30 @@ void InterCodeBasicBlock::UpdateLocalIntegerRangeSets(void)
{
case IC_LOAD:
vr = ins->mDst.mRange;
if (i > 0 &&
mInstructions[i - 1]->mCode == IC_LEA && mInstructions[i - 1]->mDst.mTemp == ins->mSrc[0].mTemp &&
mInstructions[i - 1]->mSrc[1].mTemp < 0 && mInstructions[i - 1]->mSrc[1].mMemory == IM_GLOBAL && (mInstructions[i - 1]->mSrc[1].mLinkerObject->mFlags & LOBJF_CONST))
{
if (ins->mDst.mType == IT_INT8)
{
LinkerObject* lo = mInstructions[i - 1]->mSrc[1].mLinkerObject;
int mi = 0, ma = 0;
for (int j = 0; j < lo->mSize; j++)
{
int v = lo->mData[j];
if (v & 0x80)
mi = -128;
if (v > ma)
ma = v;
}
vr.LimitMax(ma);
vr.LimitMin(mi);
}
}
break;
case IC_CONSTANT:
vr.mMaxState = vr.mMinState = IntegerValueRange::S_BOUND;

View File

@ -6279,6 +6279,19 @@ int NativeCodeBasicBlock::ShortMultiply(InterCodeProcedure* proc, NativeCodeProc
#endif
default:
if (mul & 0xff00)
{
if (ins->mSrc[index].IsUByte())
{
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_ZERO_PAGE, BC_REG_ACCU));
mIns.Push(NativeCodeInstruction(ASMIT_LDX, ASMIM_IMMEDIATE, mul & 0xff));
mIns.Push(NativeCodeInstruction(ASMIT_STX, ASMIM_ZERO_PAGE, BC_REG_ACCU + 0));
mIns.Push(NativeCodeInstruction(ASMIT_LDX, ASMIM_IMMEDIATE, mul >> 8));
mIns.Push(NativeCodeInstruction(ASMIT_STX, ASMIM_ZERO_PAGE, BC_REG_ACCU + 1));
NativeCodeGenerator::Runtime& rt(nproc->mGenerator->ResolveRuntime(Ident::Unique("mul16by8")));
mIns.Push(NativeCodeInstruction(ASMIT_JSR, ASMIM_ABSOLUTE, rt.mOffset, rt.mLinkerObject, NCIF_RUNTIME | NCIF_LOWER | NCIF_UPPER | NCIF_USE_CPU_REG_A));
}
else
{
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_IMMEDIATE, mul & 0xff));
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, BC_REG_WORK + 0));
@ -6288,6 +6301,7 @@ int NativeCodeBasicBlock::ShortMultiply(InterCodeProcedure* proc, NativeCodeProc
NativeCodeGenerator::Runtime& frt(nproc->mGenerator->ResolveRuntime(Ident::Unique("mul16")));
mIns.Push(NativeCodeInstruction(ASMIT_JSR, ASMIM_ABSOLUTE, frt.mOffset, frt.mLinkerObject, NCIF_RUNTIME | NCIF_LOWER | NCIF_UPPER));
}
}
else
{
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_IMMEDIATE, mul));

View File

@ -1269,7 +1269,7 @@ void Scanner::NextRawToken(void)
mToken = TK_INT;
else if (!strcmp(tkident, "float"))
mToken = TK_FLOAT;
else if (!strcmp(tkident, "bool"))
else if (!strcmp(tkident, "bool") || !strcmp(tkident, "_Bool"))
mToken = TK_BOOL;
else if (!strcmp(tkident, "char"))
mToken = TK_CHAR;