Fix address of array in const declaration to return correct pointer type

This commit is contained in:
drmortalwombat 2023-09-24 11:03:54 +02:00
parent bba8931860
commit da29a87477
5 changed files with 30 additions and 5 deletions

View File

@ -108,6 +108,22 @@ void spr_color(char sp, char color)
vic.spr_color[sp] = color;
}
void spr_expand(char sp, bool xexpand, bool yexpand)
{
__assume (sp < 8);
char m = 1 << sp;
if (xexpand)
vic.spr_expand_x |= m;
else
vic.spr_expand_x &= ~m;
if (yexpand)
vic.spr_expand_y |= m;
else
vic.spr_expand_y &= ~m;
}
static char vspriteYLow[VSPRITES_MAX], vspriteXLow[VSPRITES_MAX], vspriteXHigh[VSPRITES_MAX];
static char vspriteImage[VSPRITES_MAX], vspriteColor[VSPRITES_MAX];

View File

@ -39,6 +39,10 @@ inline void spr_image(char sp, char image);
inline void spr_color(char sp, char color);
// change the image of a sprite
inline void spr_expand(char sp, bool xexpand, bool yexpand);
// The virtual sprite system works with the rasterirq library to multiplex
// 16 virtual sprites onto the actual eight hardware sprites. It uses the slots
// 0 to 8 of the rasterirq library to switch the sprites mid screen. The

View File

@ -967,6 +967,14 @@ Declaration* Declaration::BuildArrayPointer(void)
return this;
}
Declaration* Declaration::BuildAddressOfPointer(void)
{
if (mType == DT_TYPE_ARRAY)
return BuildArrayPointer();
else
return BuildPointer(mLocation);
}
bool Declaration::IsNullConst(void) const
{
if (mType == DT_CONST_INTEGER || mType == DT_CONST_ADDRESS)

View File

@ -323,6 +323,7 @@ public:
Declaration* BuildConstRValueRef(const Location& loc);
Declaration* NonRefBase(void);
Declaration* BuildArrayPointer(void);
Declaration* BuildAddressOfPointer(void);
Declaration* DeduceAuto(Declaration* dec);
Declaration* ConstCast(Declaration* ntype);
bool IsNullConst(void) const;

View File

@ -7010,11 +7010,7 @@ Expression* Parser::ParsePrefixExpression(bool lhs)
}
else if (nexp->mToken == TK_BINARY_AND)
{
Declaration* pdec = new Declaration(nexp->mLocation, DT_TYPE_POINTER);
pdec->mBase = nexp->mLeft->mDecType;
pdec->mSize = 2;
pdec->mFlags |= DTF_DEFINED;
nexp->mDecType = pdec;
nexp->mDecType = nexp->mLeft->mDecType->BuildAddressOfPointer();
}
else if (nexp->mToken == TK_BANKOF)
{