mirror of
https://github.com/cc65/cc65.git
synced 2025-02-05 04:37:23 +00:00
rework to use a magic value instead of a flag, as suggested by Oliver
This commit is contained in:
parent
ef74226993
commit
18f94d1fe0
@ -1738,8 +1738,7 @@ static FuncDesc* ParseFuncDecl (void)
|
|||||||
{
|
{
|
||||||
SymEntry* Sym;
|
SymEntry* Sym;
|
||||||
SymEntry* WrappedCall;
|
SymEntry* WrappedCall;
|
||||||
unsigned char WrappedCallData;
|
unsigned int WrappedCallData;
|
||||||
int WrappedCallUseBank;
|
|
||||||
|
|
||||||
/* Create a new function descriptor */
|
/* Create a new function descriptor */
|
||||||
FuncDesc* F = NewFuncDesc ();
|
FuncDesc* F = NewFuncDesc ();
|
||||||
@ -1792,11 +1791,10 @@ static FuncDesc* ParseFuncDecl (void)
|
|||||||
RememberFunctionLevel (F);
|
RememberFunctionLevel (F);
|
||||||
|
|
||||||
/* Did we have a WrappedCall for this function? */
|
/* Did we have a WrappedCall for this function? */
|
||||||
GetWrappedCall((void **) &WrappedCall, &WrappedCallData, &WrappedCallUseBank);
|
GetWrappedCall((void **) &WrappedCall, &WrappedCallData);
|
||||||
if (WrappedCall) {
|
if (WrappedCall) {
|
||||||
F->WrappedCall = WrappedCall;
|
F->WrappedCall = WrappedCall;
|
||||||
F->WrappedCallData = WrappedCallData;
|
F->WrappedCallData = WrappedCallData;
|
||||||
F->WrappedCallUseBank = WrappedCallUseBank;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the function descriptor */
|
/* Return the function descriptor */
|
||||||
|
@ -997,7 +997,7 @@ static void FunctionCall (ExprDesc* Expr)
|
|||||||
char tmp[64];
|
char tmp[64];
|
||||||
StrBuf S = AUTO_STRBUF_INITIALIZER;
|
StrBuf S = AUTO_STRBUF_INITIALIZER;
|
||||||
|
|
||||||
if (Func->WrappedCallUseBank) {
|
if (Func->WrappedCallData == WRAPPED_CALL_USE_BANK) {
|
||||||
/* Store the bank attribute in tmp4 */
|
/* Store the bank attribute in tmp4 */
|
||||||
SB_AppendStr (&S, "ldy #<.bank(_");
|
SB_AppendStr (&S, "ldy #<.bank(_");
|
||||||
SB_AppendStr (&S, (const char*) Expr->Name);
|
SB_AppendStr (&S, (const char*) Expr->Name);
|
||||||
|
@ -58,7 +58,7 @@
|
|||||||
/* Bits that must be ignored when comparing funcs */
|
/* Bits that must be ignored when comparing funcs */
|
||||||
#define FD_IGNORE (FD_INCOMPLETE_PARAM | FD_OLDSTYLE | FD_OLDSTYLE_INTRET | FD_UNNAMED_PARAMS | FD_CALL_WRAPPER)
|
#define FD_IGNORE (FD_INCOMPLETE_PARAM | FD_OLDSTYLE | FD_OLDSTYLE_INTRET | FD_UNNAMED_PARAMS | FD_CALL_WRAPPER)
|
||||||
|
|
||||||
|
#define WRAPPED_CALL_USE_BANK 0x0100U /* WrappedCall uses .bank() */
|
||||||
|
|
||||||
/* Function descriptor */
|
/* Function descriptor */
|
||||||
typedef struct FuncDesc FuncDesc;
|
typedef struct FuncDesc FuncDesc;
|
||||||
@ -71,8 +71,7 @@ struct FuncDesc {
|
|||||||
struct SymEntry* LastParam; /* Pointer to last parameter */
|
struct SymEntry* LastParam; /* Pointer to last parameter */
|
||||||
struct FuncDesc* FuncDef; /* Descriptor used in definition */
|
struct FuncDesc* FuncDef; /* Descriptor used in definition */
|
||||||
struct SymEntry* WrappedCall; /* Pointer to the WrappedCall */
|
struct SymEntry* WrappedCall; /* Pointer to the WrappedCall */
|
||||||
unsigned char WrappedCallData;/* The WrappedCall's user data */
|
unsigned int WrappedCallData;/* The WrappedCall's user data */
|
||||||
int WrappedCallUseBank;/* Flag: does WrappedCall use .bank() or literal value */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -497,7 +497,6 @@ static void WrappedCallPragma (StrBuf* B)
|
|||||||
const char *Name;
|
const char *Name;
|
||||||
long Val;
|
long Val;
|
||||||
SymEntry *Entry;
|
SymEntry *Entry;
|
||||||
int UseBank = 0;
|
|
||||||
|
|
||||||
/* Check for the "push" or "pop" keywords */
|
/* Check for the "push" or "pop" keywords */
|
||||||
switch (ParsePushPop (B)) {
|
switch (ParsePushPop (B)) {
|
||||||
@ -538,13 +537,13 @@ static void WrappedCallPragma (StrBuf* B)
|
|||||||
|
|
||||||
/* Next must be either a numeric value, or "bank" */
|
/* Next must be either a numeric value, or "bank" */
|
||||||
if (HasStr (B, "bank")) {
|
if (HasStr (B, "bank")) {
|
||||||
UseBank = 1;
|
Val = WRAPPED_CALL_USE_BANK;
|
||||||
} else if (!GetNumber (B, &Val)) {
|
} else if (!GetNumber (B, &Val)) {
|
||||||
Error ("Value required for wrapped-call identifier");
|
Error ("Value required for wrapped-call identifier");
|
||||||
goto ExitPoint;
|
goto ExitPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!UseBank && (Val < 0 || Val > 255)) {
|
if (!(Val == WRAPPED_CALL_USE_BANK) && (Val < 0 || Val > 255)) {
|
||||||
Error ("Identifier must be between 0-255");
|
Error ("Identifier must be between 0-255");
|
||||||
goto ExitPoint;
|
goto ExitPoint;
|
||||||
}
|
}
|
||||||
@ -556,7 +555,7 @@ static void WrappedCallPragma (StrBuf* B)
|
|||||||
/* Check if the name is valid */
|
/* Check if the name is valid */
|
||||||
if (Entry && (Entry->Flags & SC_FUNC) == SC_FUNC) {
|
if (Entry && (Entry->Flags & SC_FUNC) == SC_FUNC) {
|
||||||
|
|
||||||
PushWrappedCall(Entry, (unsigned char) Val, UseBank);
|
PushWrappedCall(Entry, (unsigned int) Val);
|
||||||
Entry->Flags |= SC_REF;
|
Entry->Flags |= SC_REF;
|
||||||
GetFuncDesc (Entry->Type)->Flags |= FD_CALL_WRAPPER;
|
GetFuncDesc (Entry->Type)->Flags |= FD_CALL_WRAPPER;
|
||||||
|
|
||||||
|
@ -64,13 +64,13 @@ static IntPtrStack WrappedCalls;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void PushWrappedCall (void *Ptr, unsigned char Val, int UseBank)
|
void PushWrappedCall (void *Ptr, unsigned int Val)
|
||||||
/* Push the current WrappedCall */
|
/* Push the current WrappedCall */
|
||||||
{
|
{
|
||||||
if (IPS_IsFull (&WrappedCalls)) {
|
if (IPS_IsFull (&WrappedCalls)) {
|
||||||
Error ("WrappedCall stack overflow");
|
Error ("WrappedCall stack overflow");
|
||||||
} else {
|
} else {
|
||||||
IPS_Push (&WrappedCalls, Val | (UseBank << 8), Ptr);
|
IPS_Push (&WrappedCalls, Val, Ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ void PopWrappedCall (void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void GetWrappedCall (void **Ptr, unsigned char *Val, int *UseBank)
|
void GetWrappedCall (void **Ptr, unsigned int *Val)
|
||||||
/* Get the current WrappedCall */
|
/* Get the current WrappedCall */
|
||||||
{
|
{
|
||||||
if (IPS_GetCount (&WrappedCalls) < 1) {
|
if (IPS_GetCount (&WrappedCalls) < 1) {
|
||||||
@ -97,7 +97,6 @@ void GetWrappedCall (void **Ptr, unsigned char *Val, int *UseBank)
|
|||||||
} else {
|
} else {
|
||||||
long Temp;
|
long Temp;
|
||||||
IPS_Get (&WrappedCalls, &Temp, Ptr);
|
IPS_Get (&WrappedCalls, &Temp, Ptr);
|
||||||
*UseBank = (int) Temp >> 8;
|
*Val = (unsigned int) Temp;
|
||||||
*Val = (unsigned char) Temp & 0xff;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,13 +50,13 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void PushWrappedCall (void *Ptr, unsigned char Val, int usebank);
|
void PushWrappedCall (void *Ptr, unsigned int Val);
|
||||||
/* Push the current WrappedCall */
|
/* Push the current WrappedCall */
|
||||||
|
|
||||||
void PopWrappedCall (void);
|
void PopWrappedCall (void);
|
||||||
/* Pop the current WrappedCall */
|
/* Pop the current WrappedCall */
|
||||||
|
|
||||||
void GetWrappedCall (void **Ptr, unsigned char *Val, int *usebank);
|
void GetWrappedCall (void **Ptr, unsigned int *Val);
|
||||||
/* Get the current WrappedCall, if any */
|
/* Get the current WrappedCall, if any */
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user