mirror of
https://github.com/cc65/cc65.git
synced 2024-12-28 22:30:12 +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* WrappedCall;
|
||||
unsigned char WrappedCallData;
|
||||
int WrappedCallUseBank;
|
||||
unsigned int WrappedCallData;
|
||||
|
||||
/* Create a new function descriptor */
|
||||
FuncDesc* F = NewFuncDesc ();
|
||||
@ -1792,11 +1791,10 @@ static FuncDesc* ParseFuncDecl (void)
|
||||
RememberFunctionLevel (F);
|
||||
|
||||
/* Did we have a WrappedCall for this function? */
|
||||
GetWrappedCall((void **) &WrappedCall, &WrappedCallData, &WrappedCallUseBank);
|
||||
GetWrappedCall((void **) &WrappedCall, &WrappedCallData);
|
||||
if (WrappedCall) {
|
||||
F->WrappedCall = WrappedCall;
|
||||
F->WrappedCallData = WrappedCallData;
|
||||
F->WrappedCallUseBank = WrappedCallUseBank;
|
||||
}
|
||||
|
||||
/* Return the function descriptor */
|
||||
|
@ -997,7 +997,7 @@ static void FunctionCall (ExprDesc* Expr)
|
||||
char tmp[64];
|
||||
StrBuf S = AUTO_STRBUF_INITIALIZER;
|
||||
|
||||
if (Func->WrappedCallUseBank) {
|
||||
if (Func->WrappedCallData == WRAPPED_CALL_USE_BANK) {
|
||||
/* Store the bank attribute in tmp4 */
|
||||
SB_AppendStr (&S, "ldy #<.bank(_");
|
||||
SB_AppendStr (&S, (const char*) Expr->Name);
|
||||
|
@ -58,7 +58,7 @@
|
||||
/* 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 WRAPPED_CALL_USE_BANK 0x0100U /* WrappedCall uses .bank() */
|
||||
|
||||
/* Function descriptor */
|
||||
typedef struct FuncDesc FuncDesc;
|
||||
@ -71,8 +71,7 @@ struct FuncDesc {
|
||||
struct SymEntry* LastParam; /* Pointer to last parameter */
|
||||
struct FuncDesc* FuncDef; /* Descriptor used in definition */
|
||||
struct SymEntry* WrappedCall; /* Pointer to the WrappedCall */
|
||||
unsigned char WrappedCallData;/* The WrappedCall's user data */
|
||||
int WrappedCallUseBank;/* Flag: does WrappedCall use .bank() or literal value */
|
||||
unsigned int WrappedCallData;/* The WrappedCall's user data */
|
||||
};
|
||||
|
||||
|
||||
|
@ -497,7 +497,6 @@ static void WrappedCallPragma (StrBuf* B)
|
||||
const char *Name;
|
||||
long Val;
|
||||
SymEntry *Entry;
|
||||
int UseBank = 0;
|
||||
|
||||
/* Check for the "push" or "pop" keywords */
|
||||
switch (ParsePushPop (B)) {
|
||||
@ -538,13 +537,13 @@ static void WrappedCallPragma (StrBuf* B)
|
||||
|
||||
/* Next must be either a numeric value, or "bank" */
|
||||
if (HasStr (B, "bank")) {
|
||||
UseBank = 1;
|
||||
Val = WRAPPED_CALL_USE_BANK;
|
||||
} else if (!GetNumber (B, &Val)) {
|
||||
Error ("Value required for wrapped-call identifier");
|
||||
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");
|
||||
goto ExitPoint;
|
||||
}
|
||||
@ -556,7 +555,7 @@ static void WrappedCallPragma (StrBuf* B)
|
||||
/* Check if the name is valid */
|
||||
if (Entry && (Entry->Flags & SC_FUNC) == SC_FUNC) {
|
||||
|
||||
PushWrappedCall(Entry, (unsigned char) Val, UseBank);
|
||||
PushWrappedCall(Entry, (unsigned int) Val);
|
||||
Entry->Flags |= SC_REF;
|
||||
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 */
|
||||
{
|
||||
if (IPS_IsFull (&WrappedCalls)) {
|
||||
Error ("WrappedCall stack overflow");
|
||||
} 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 */
|
||||
{
|
||||
if (IPS_GetCount (&WrappedCalls) < 1) {
|
||||
@ -97,7 +97,6 @@ void GetWrappedCall (void **Ptr, unsigned char *Val, int *UseBank)
|
||||
} else {
|
||||
long Temp;
|
||||
IPS_Get (&WrappedCalls, &Temp, Ptr);
|
||||
*UseBank = (int) Temp >> 8;
|
||||
*Val = (unsigned char) Temp & 0xff;
|
||||
*Val = (unsigned int) Temp;
|
||||
}
|
||||
}
|
||||
|
@ -50,13 +50,13 @@
|
||||
|
||||
|
||||
|
||||
void PushWrappedCall (void *Ptr, unsigned char Val, int usebank);
|
||||
void PushWrappedCall (void *Ptr, unsigned int Val);
|
||||
/* Push the current WrappedCall */
|
||||
|
||||
void PopWrappedCall (void);
|
||||
/* 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 */
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user