1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-25 13:29:41 +00:00

More preparations for an extension of the calling conventions.

git-svn-id: svn://svn.cc65.org/cc65/trunk@4650 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz 2010-04-29 20:30:49 +00:00
parent 77bfcc1ff0
commit 54740da820
4 changed files with 55 additions and 11 deletions

View File

@ -249,6 +249,7 @@ void PrintType (FILE* F, const Type* T)
C = PrintTypeComp (F, C, T_QUAL_NEAR, "__near__");
C = PrintTypeComp (F, C, T_QUAL_FAR, "__far__");
C = PrintTypeComp (F, C, T_QUAL_FASTCALL, "__fastcall__");
C = PrintTypeComp (F, C, T_QUAL_CDECL, "__cdecl__");
/* Signedness. Omit the signedness specifier for long and int */
if ((C & T_MASK_TYPE) != T_TYPE_INT && (C & T_MASK_TYPE) != T_TYPE_LONG) {
@ -333,6 +334,9 @@ void PrintFuncSig (FILE* F, const char* Name, Type* T)
if (IsQualFastcall (T)) {
fprintf (F, " __fastcall__");
}
if (IsQualCDecl (T)) {
fprintf (F, " __cdecl__");
}
fprintf (F, " %s (", Name);
/* Parameters */

View File

@ -6,10 +6,10 @@
/* */
/* */
/* */
/* (C) 1998-2008 Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* (C) 1998-2010, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
@ -110,7 +110,9 @@ enum {
T_QUAL_FAR = 0x008000,
T_QUAL_ADDRSIZE = T_QUAL_NEAR | T_QUAL_FAR,
T_QUAL_FASTCALL = 0x010000,
T_MASK_QUAL = 0x01F800,
T_QUAL_CDECL = 0x020000,
T_QUAL_CCONV = T_QUAL_FASTCALL | T_QUAL_CDECL,
T_MASK_QUAL = 0x03F800,
/* Types */
T_CHAR = T_TYPE_CHAR | T_CLASS_INT | T_SIGN_UNSIGNED | T_SIZE_NONE,
@ -591,6 +593,16 @@ INLINE int IsQualFastcall (const Type* T)
# define IsQualFastcall(T) (((T)->C & T_QUAL_FASTCALL) != 0)
#endif
#if defined(HAVE_INLINE)
INLINE int IsQualCDecl (const Type* T)
/* Return true if the given type has a cdecl qualifier */
{
return (T->C & T_QUAL_CDECL) != 0;
}
#else
# define IsQualCDecl(T) (((T)->C & T_QUAL_CDECL) != 0)
#endif
int IsVariadicFunc (const Type* T) attribute ((const));
/* Return true if this is a function type or pointer to function type with
* variable parameter list

View File

@ -6,10 +6,10 @@
/* */
/* */
/* */
/* (C) 1998-2008 Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* (C) 1998-2010, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
@ -185,6 +185,17 @@ static TypeCode OptionalQualifiers (TypeCode Allowed)
}
break;
case TOK_CDECL:
if (Allowed & T_QUAL_CDECL) {
if (Q & T_QUAL_CDECL) {
DuplicateQualifier ("cdecl");
}
Q |= T_QUAL_CDECL;
} else {
goto Done;
}
break;
default:
goto Done;
@ -208,6 +219,19 @@ Done:
Q &= ~T_QUAL_ADDRSIZE;
}
/* We cannot have more than one calling convention specifier */
switch (Q & T_QUAL_CCONV) {
case T_QUAL_NONE:
case T_QUAL_FASTCALL:
case T_QUAL_CDECL:
break;
default:
Error ("Cannot specify more than one calling convention qualifier");
Q &= ~T_QUAL_CCONV;
}
/* Return the qualifiers read */
return Q;
}
@ -1405,6 +1429,9 @@ static void Declarator (const DeclSpec* Spec, Declaration* D, declmode_t Mode)
if (Qualifiers & T_QUAL_FASTCALL) {
Error ("Invalid `__fastcall__' qualifier");
}
if (Qualifiers & T_QUAL_CDECL) {
Error ("Invalid `__cdecl__' qualifier");
}
}

View File

@ -205,8 +205,9 @@ static int SkipWhite (void)
int TokIsFuncSpec (const Token* T)
/* Return true if the token is a function specifier */
{
return (T->Tok == TOK_INLINE) || (T->Tok == TOK_FASTCALL) ||
(T->Tok == TOK_NEAR) || (T->Tok == TOK_FAR);
return (T->Tok == TOK_INLINE) ||
(T->Tok == TOK_FASTCALL) || (T->Tok == TOK_CDECL) ||
(T->Tok == TOK_NEAR) || (T->Tok == TOK_FAR);
}