1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-26 08:32:00 +00:00

Moved the check module to the common dir.

Replaced the type constants by something more expandable.


git-svn-id: svn://svn.cc65.org/cc65/trunk@248 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2000-08-01 15:04:35 +00:00
parent 9e47a53bb7
commit e133416d05
17 changed files with 201 additions and 180 deletions

View File

@ -33,8 +33,11 @@
#include "asmline.h" /* common */
#include "check.h" #include "check.h"
/* cc65 */
#include "asmline.h"
#include "global.h" #include "global.h"
#include "asmcode.h" #include "asmcode.h"
@ -67,8 +70,8 @@ void AddCodeHint (const char* Hint)
void AddEmptyLine (void) void AddEmptyLine (void)
/* Add an empty line for formatting purposes */ /* Add an empty line for formatting purposes */
{ {
/* Use a somewhat weird construct to avoid that gcc complains about /* Use a somewhat weird construct to avoid that gcc complains about
* an empty format string. * an empty format string.
*/ */
static const char EmptyLine[] = ""; static const char EmptyLine[] = "";

View File

@ -37,13 +37,13 @@
#include <string.h> #include <string.h>
/* common */ /* common */
#include "check.h"
#include "version.h" #include "version.h"
#include "xmalloc.h" #include "xmalloc.h"
/* cc65 */ /* cc65 */
#include "asmcode.h" #include "asmcode.h"
#include "asmlabel.h" #include "asmlabel.h"
#include "check.h"
#include "cpu.h" #include "cpu.h"
#include "error.h" #include "error.h"
#include "global.h" #include "global.h"
@ -53,7 +53,7 @@
#include "util.h" #include "util.h"
#include "codegen.h" #include "codegen.h"
/*****************************************************************************/ /*****************************************************************************/
/* Data */ /* Data */

View File

@ -35,8 +35,10 @@
#include <stdlib.h> #include <stdlib.h>
#include "../common/version.h" /* common */
#include "version.h"
/* cc65 */
#include "asmlabel.h" #include "asmlabel.h"
#include "codegen.h" #include "codegen.h"
#include "declare.h" #include "declare.h"
@ -159,7 +161,7 @@ static void Parse (void)
* void types in non ANSI mode. * void types in non ANSI mode.
*/ */
if (Size == 0) { if (Size == 0) {
if (!IsVoid (Decl.Type)) { if (!IsTypeVoid (Decl.Type)) {
if (!IsArray (Decl.Type)) { if (!IsArray (Decl.Type)) {
/* Size is unknown and not an array */ /* Size is unknown and not an array */
Error (ERR_UNKNOWN_SIZE); Error (ERR_UNKNOWN_SIZE);
@ -183,7 +185,7 @@ static void Parse (void)
ParseInit (Entry->Type); ParseInit (Entry->Type);
} else { } else {
if (IsVoid (Decl.Type)) { if (IsTypeVoid (Decl.Type)) {
/* We cannot declare variables of type void */ /* We cannot declare variables of type void */
Error (ERR_ILLEGAL_TYPE); Error (ERR_ILLEGAL_TYPE);
} else if (Size == 0) { } else if (Size == 0) {

View File

@ -35,9 +35,11 @@
#include <string.h> #include <string.h>
#include "../common/xmalloc.h" /* common */
#include "check.h" #include "check.h"
#include "xmalloc.h"
/* cc65 */
#include "codegen.h" #include "codegen.h"
#include "datatype.h" #include "datatype.h"
#include "error.h" #include "error.h"
@ -60,7 +62,7 @@ type type_uint [] = { T_UINT, T_END };
type type_long [] = { T_LONG, T_END }; type type_long [] = { T_LONG, T_END };
type type_ulong [] = { T_ULONG, T_END }; type type_ulong [] = { T_ULONG, T_END };
type type_void [] = { T_VOID, T_END }; type type_void [] = { T_VOID, T_END };
type type_pschar [] = { T_PTR, T_CHAR, T_END }; type type_pschar [] = { T_PTR, T_SCHAR, T_END };
type type_puchar [] = { T_PTR, T_UCHAR, T_END }; type type_puchar [] = { T_PTR, T_UCHAR, T_END };
@ -150,7 +152,7 @@ void TypeFree (type* T)
type GetDefaultChar (void) type GetDefaultChar (void)
/* Return the default char type (signed/unsigned) depending on the settings */ /* Return the default char type (signed/unsigned) depending on the settings */
{ {
return SignedChars? T_CHAR : T_UCHAR; return SignedChars? T_SCHAR : T_UCHAR;
} }
@ -203,64 +205,86 @@ type* GetImplicitFuncType (void)
void PrintType (FILE* F, const type* tarray) static type PrintTypeComp (FILE* F, type T, type Mask, const char* Name)
/* Check for a specific component of the type. If it is there, print the
* name and remove it. Return the type with the component removed.
*/
{
if ((T & Mask) == Mask) {
fprintf (F, "%s ", Name);
T &= ~Mask;
}
return T;
}
void PrintType (FILE* F, const type* Type)
/* Output translation of type array. */ /* Output translation of type array. */
{ {
const type* p; /* If the first field has const and/or volatile qualifiers, print and
* remove them.
*/
type T = *Type++;
T = PrintTypeComp (F, T, T_QUAL_CONST, "const");
T = PrintTypeComp (F, T, T_QUAL_VOLATILE, "volatile");
for (p = tarray; *p != T_END; ++p) { /* Walk over the complete string */
if (*p & T_UNSIGNED) { do {
fprintf (F, "unsigned ");
} /* Check for the sizes */
switch (*p) { T = PrintTypeComp (F, T, T_SIZE_SHORT, "short");
case T_VOID: T = PrintTypeComp (F, T, T_SIZE_LONG, "long");
fprintf (F, "void\n"); T = PrintTypeComp (F, T, T_SIZE_LONGLONG, "long long");
break;
case T_CHAR: /* Signedness */
case T_UCHAR: T = PrintTypeComp (F, T, T_SIGN_SIGNED, "signed");
T = PrintTypeComp (F, T, T_SIGN_UNSIGNED, "unsigned");
/* Now check the real type */
switch (T & T_MASK_TYPE) {
case T_TYPE_CHAR:
fprintf (F, "char\n"); fprintf (F, "char\n");
break; break;
case T_INT: case T_TYPE_INT:
case T_UINT:
fprintf (F, "int\n"); fprintf (F, "int\n");
break; break;
case T_SHORT: case T_TYPE_FLOAT:
case T_USHORT:
fprintf (F, "short\n");
break;
case T_LONG:
case T_ULONG:
fprintf (F, "long\n");
break;
case T_FLOAT:
fprintf (F, "float\n"); fprintf (F, "float\n");
break; break;
case T_DOUBLE: case T_TYPE_DOUBLE:
fprintf (F, "double\n"); fprintf (F, "double\n");
break; break;
case T_PTR: case T_TYPE_VOID:
fprintf (F, "void\n");
break;
case T_TYPE_STRUCT:
fprintf (F, "struct %s\n", ((SymEntry*) DecodePtr (Type))->Name);
Type += DECODE_SIZE;
break;
case T_TYPE_UNION:
fprintf (F, "union %s\n", ((SymEntry*) DecodePtr (Type))->Name);
Type += DECODE_SIZE;
break;
case T_TYPE_ARRAY:
fprintf (F, "array[%lu] of ", Decode (Type));
Type += DECODE_SIZE;
break;
case T_TYPE_PTR:
fprintf (F, "pointer to "); fprintf (F, "pointer to ");
break; break;
case T_ARRAY: case T_TYPE_FUNC:
fprintf (F, "array[%lu] of ", Decode (p + 1));
p += DECODE_SIZE;
break;
case T_STRUCT:
fprintf (F, "struct %s\n", ((SymEntry*) Decode (p + 1))->Name);
p += DECODE_SIZE;
break;
case T_UNION:
fprintf (F, "union %s\n", ((SymEntry*) Decode (p + 1))->Name);
p += DECODE_SIZE;
break;
case T_FUNC:
fprintf (F, "function returning "); fprintf (F, "function returning ");
p += DECODE_SIZE; Type += DECODE_SIZE;
break; break;
default: default:
fprintf (F, "unknown type: %04X\n", *p); fprintf (F, "unknown type: %04X\n", T);
} }
}
/* Get the next type element */
T = *Type++;
} while (T != T_END);
} }
@ -334,43 +358,53 @@ void CopyEncode (const type* Source, type* Target)
unsigned SizeOf (const type* tarray) unsigned SizeOf (const type* T)
/* Compute size of object represented by type array. */ /* Compute size of object represented by type array. */
{ {
SymEntry* Entry; SymEntry* Entry;
switch (*tarray) { switch (*T) {
case T_VOID: case T_VOID:
Error (ERR_ILLEGAL_SIZE); Error (ERR_ILLEGAL_SIZE);
return 0; return 0;
case T_CHAR: case T_SCHAR:
case T_UCHAR: case T_UCHAR:
return 1; return 1;
case T_INT:
case T_UINT:
case T_SHORT: case T_SHORT:
case T_USHORT: case T_USHORT:
case T_INT:
case T_UINT:
case T_PTR: case T_PTR:
case T_ENUM:
return 2; return 2;
case T_LONG: case T_LONG:
case T_ULONG: case T_ULONG:
return 4; return 4;
case T_ARRAY: case T_LONGLONG:
return (Decode (tarray + 1) * SizeOf (tarray + DECODE_SIZE + 1)); case T_ULONGLONG:
return 8;
case T_ENUM:
return 2;
case T_FLOAT:
case T_DOUBLE:
return 4;
case T_STRUCT: case T_STRUCT:
case T_UNION: case T_UNION:
Entry = DecodePtr (tarray+1); Entry = DecodePtr (T+1);
return Entry->V.S.Size; return Entry->V.S.Size;
case T_ARRAY:
return (Decode (T+ 1) * SizeOf (T + DECODE_SIZE + 1));
default: default:
Internal ("Unknown type: %04X", *tarray); Internal ("Unknown type in SizeOf: %04X", *T);
return 0; return 0;
} }
@ -378,17 +412,17 @@ unsigned SizeOf (const type* tarray)
unsigned PSizeOf (const type* tptr) unsigned PSizeOf (const type* T)
/* Compute size of pointer object. */ /* Compute size of pointer object. */
{ {
/* We are expecting a pointer expression */ /* We are expecting a pointer expression */
CHECK (*tptr & T_POINTER); CHECK ((*T & T_CLASS_PTR) != 0);
/* Skip the pointer or array token itself */ /* Skip the pointer or array token itself */
if (*tptr == T_ARRAY) { if (*T == T_ARRAY) {
return SizeOf (tptr + DECODE_SIZE + 1); return SizeOf (T + DECODE_SIZE + 1);
} else { } else {
return SizeOf (tptr + 1); return SizeOf (T + 1);
} }
} }
@ -401,7 +435,7 @@ unsigned TypeOf (const type* Type)
switch (*Type) { switch (*Type) {
case T_CHAR: case T_SCHAR:
return CF_CHAR; return CF_CHAR;
case T_UCHAR: case T_UCHAR:
@ -441,129 +475,130 @@ unsigned TypeOf (const type* Type)
type* Indirect (type* Type) type* Indirect (type* T)
/* Do one indirection for the given type, that is, return the type where the /* Do one indirection for the given type, that is, return the type where the
* given type points to. * given type points to.
*/ */
{ {
/* We are expecting a pointer expression */ /* We are expecting a pointer expression */
CHECK (Type[0] & T_POINTER); CHECK ((*T & T_MASK_CLASS) == T_CLASS_PTR);
/* Skip the pointer or array token itself */ /* Skip the pointer or array token itself */
if (Type[0] == T_ARRAY) { if (*T == T_ARRAY) {
return Type + DECODE_SIZE + 1; return T + DECODE_SIZE + 1;
} else { } else {
return Type + 1; return T + 1;
} }
} }
int IsVoid (const type* Type) int IsTypeVoid (const type* T)
/* Return true if this is a void type */ /* Return true if this is a void type */
{ {
return (Type[0] == T_VOID && Type[1] == T_END); return (T[0] == T_VOID && T[1] == T_END);
} }
int IsPtr (const type* Type) int IsPtr (const type* T)
/* Return true if this is a pointer type */ /* Return true if this is a pointer type */
{ {
return (Type[0] & T_POINTER) != 0; return (T[0] & T_MASK_CLASS) == T_CLASS_PTR;
} }
int IsChar (const type* Type) int IsChar (const type* T)
/* Return true if this is a character type */ /* Return true if this is a character type */
{ {
return (Type[0] == T_CHAR || Type[0] == T_UCHAR) && Type[1] == T_END; return (T[0] & T_MASK_TYPE) == T_TYPE_CHAR && T[1] == T_END;
} }
int IsInt (const type* Type) int IsInt (const type* T)
/* Return true if this is an integer type */ /* Return true if this is an integer type */
{ {
return (Type[0] & T_INTEGER) != 0; return (T[0] & T_MASK_CLASS) == T_CLASS_INT;
} }
int IsLong (const type* Type) int IsLong (const type* T)
/* Return true if this is a long type (signed or unsigned) */ /* Return true if this is a long type (signed or unsigned) */
{ {
return (Type[0] & T_LONG) == T_LONG; return (T[0] & T_MASK_SIZE) == T_SIZE_LONG;
} }
int IsUnsigned (const type* Type) int IsUnsigned (const type* T)
/* Return true if this is an unsigned type */ /* Return true if this is an unsigned type */
{ {
return (Type[0] & T_UNSIGNED) != 0; return (T[0] & T_MASK_SIGN) == T_SIGN_UNSIGNED;
} }
int IsStruct (const type* Type) int IsStruct (const type* T)
/* Return true if this is a struct type */ /* Return true if this is a struct type */
{ {
return (Type[0] == T_STRUCT || Type[0] == T_UNION); return (T[0] & T_MASK_CLASS) == T_CLASS_STRUCT;
} }
int IsFunc (const type* Type) int IsFunc (const type* T)
/* Return true if this is a function type */ /* Return true if this is a function type */
{ {
return (Type[0] == T_FUNC); return (T[0] == T_FUNC);
} }
int IsFastCallFunc (const type* Type) int IsFastCallFunc (const type* T)
/* Return true if this is a function type with __fastcall__ calling conventions */ /* Return true if this is a function type with __fastcall__ calling conventions */
{ {
FuncDesc* F; FuncDesc* F;
CHECK (*Type == T_FUNC); CHECK (T[0] == T_FUNC);
F = DecodePtr (Type+1); F = DecodePtr (T+1);
return (F->Flags & FD_FASTCALL) != 0; return (F->Flags & FD_FASTCALL) != 0;
} }
int IsFuncPtr (const type* Type) int IsFuncPtr (const type* T)
/* Return true if this is a function pointer */ /* Return true if this is a function pointer */
{ {
return (Type[0] == T_PTR && Type[1] == T_FUNC); return (T[0] == T_PTR && T[1] == T_FUNC);
} }
int IsArray (const type* Type) int IsArray (const type* T)
/* Return true if this is an array type */ /* Return true if this is an array type */
{ {
return (Type[0] == T_ARRAY); return (T[0] == T_ARRAY);
} }
struct FuncDesc* GetFuncDesc (const type* Type) struct FuncDesc* GetFuncDesc (const type* T)
/* Get the FuncDesc pointer from a function or pointer-to-function type */ /* Get the FuncDesc pointer from a function or pointer-to-function type */
{ {
if (Type[0] == T_PTR) { if (T[0] == T_PTR) {
/* Pointer to function */ /* Pointer to function */
++Type; ++T;
} }
/* Be sure it's a function type */ /* Be sure it's a function type */
CHECK (Type[0] == T_FUNC); CHECK (T[0] == T_FUNC);
/* Decode the function descriptor and return it */ /* Decode the function descriptor and return it */
return DecodePtr (Type+1); return DecodePtr (T+1);
} }

View File

@ -50,8 +50,8 @@
// Basic data types // Basic data types
enum type_t { enum {
T_NONE = 0x0000, T_END = 0x0000,
// Basic types // Basic types
T_TYPE_NONE = 0x0000, T_TYPE_NONE = 0x0000,
@ -97,61 +97,31 @@ enum type_t {
T_MASK_QUAL = 0x3000, T_MASK_QUAL = 0x3000,
// Types // Types
T_CHAR = T_TYPE_CHAR | T_CLASS_INT | T_SIGN_UNSIGNED | T_SIZE_NONE, T_CHAR = T_TYPE_CHAR | T_CLASS_INT | T_SIGN_UNSIGNED | T_SIZE_NONE,
T_SCHAR = T_TYPE_CHAR | T_CLASS_INT | T_SIGN_SIGNED | T_SIZE_NONE, T_SCHAR = T_TYPE_CHAR | T_CLASS_INT | T_SIGN_SIGNED | T_SIZE_NONE,
T_UCHAR = T_TYPE_CHAR | T_CLASS_INT | T_SIGN_UNSIGNED | T_SIZE_NONE, T_UCHAR = T_TYPE_CHAR | T_CLASS_INT | T_SIGN_UNSIGNED | T_SIZE_NONE,
T_SHORT = T_TYPE_INT | T_CLASS_INT | T_SIGN_SIGNED | T_SIZE_SHORT, T_SHORT = T_TYPE_INT | T_CLASS_INT | T_SIGN_SIGNED | T_SIZE_SHORT,
T_USHORT = T_TYPE_INT | T_CLASS_INT | T_SIGN_UNSIGNED | T_SIZE_SHORT, T_USHORT = T_TYPE_INT | T_CLASS_INT | T_SIGN_UNSIGNED | T_SIZE_SHORT,
T_INT = T_TYPE_INT | T_CLASS_INT | T_SIGN_SIGNED | T_SIZE_NONE, T_INT = T_TYPE_INT | T_CLASS_INT | T_SIGN_SIGNED | T_SIZE_NONE,
T_UINT = T_TYPE_INT | T_CLASS_INT | T_SIGN_UNSIGNED | T_SIZE_NONE, T_UINT = T_TYPE_INT | T_CLASS_INT | T_SIGN_UNSIGNED | T_SIZE_NONE,
T_LONG = T_TYPE_INT | T_CLASS_INT | T_SIGN_SIGNED | T_SIZE_LONG, T_LONG = T_TYPE_INT | T_CLASS_INT | T_SIGN_SIGNED | T_SIZE_LONG,
T_ULONG = T_TYPE_INT | T_CLASS_INT | T_SIGN_UNSIGNED | T_SIZE_LONG, T_ULONG = T_TYPE_INT | T_CLASS_INT | T_SIGN_UNSIGNED | T_SIZE_LONG,
T_LONGLONG = T_TYPE_INT | T_CLASS_INT | T_SIGN_SIGNED | T_SIZE_LONGLONG, T_LONGLONG = T_TYPE_INT | T_CLASS_INT | T_SIGN_SIGNED | T_SIZE_LONGLONG,
T_ULONGLONG = T_TYPE_INT | T_CLASS_INT | T_SIGN_UNSIGNED | T_SIZE_LONGLONG, T_ULONGLONG = T_TYPE_INT | T_CLASS_INT | T_SIGN_UNSIGNED | T_SIZE_LONGLONG,
T_ENUM = T_TYPE_ENUM | T_CLASS_INT | T_SIGN_SIGNED | T_SIZE_NONE, T_ENUM = T_TYPE_ENUM | T_CLASS_INT | T_SIGN_SIGNED | T_SIZE_NONE,
T_FLOAT = T_TYPE_FLOAT | T_CLASS_FLOAT | T_SIGN_NONE | T_SIZE_NONE, T_FLOAT = T_TYPE_FLOAT | T_CLASS_FLOAT | T_SIGN_NONE | T_SIZE_NONE,
T_DOUBLE = T_TYPE_DOUBLE | T_CLASS_FLOAT | T_SIGN_NONE | T_SIZE_NONE, T_DOUBLE = T_TYPE_DOUBLE | T_CLASS_FLOAT | T_SIGN_NONE | T_SIZE_NONE,
T_VOID = T_TYPE_VOID | T_CLASS_NONE | T_SIGN_NONE | T_SIZE_NONE, T_VOID = T_TYPE_VOID | T_CLASS_NONE | T_SIGN_NONE | T_SIZE_NONE,
T_STRUCT = T_TYPE_STRUCT | T_CLASS_STRUCT | T_SIGN_NONE | T_SIZE_NONE, T_STRUCT = T_TYPE_STRUCT | T_CLASS_STRUCT | T_SIGN_NONE | T_SIZE_NONE,
T_UNION = T_TYPE_UNION | T_CLASS_STRUCT | T_SIGN_NONE | T_SIZE_NONE, T_UNION = T_TYPE_UNION | T_CLASS_STRUCT | T_SIGN_NONE | T_SIZE_NONE,
T_ARRAY = T_TYPE_ARRAY | T_CLASS_PTR | T_SIGN_NONE | T_SIZE_NONE, T_ARRAY = T_TYPE_ARRAY | T_CLASS_PTR | T_SIGN_NONE | T_SIZE_NONE,
T_PTR = T_TYPE_PTR | T_CLASS_PTR | T_SIGN_NONE | T_SIZE_NONE, T_PTR = T_TYPE_PTR | T_CLASS_PTR | T_SIGN_NONE | T_SIZE_NONE,
T_FUNC = T_TYPE_FUNC | T_CLASS_FUNC | T_SIGN_NONE | T_SIZE_NONE, T_FUNC = T_TYPE_FUNC | T_CLASS_FUNC | T_SIGN_NONE | T_SIZE_NONE,
}; };
/* Data types */
#define T_END 0x0000
#define T_CHAR 0x0011
#define T_INT 0x0012
#define T_SHORT 0x0013
#define T_LONG 0x0014
#define T_ENUM 0x0015
#define T_UCHAR 0x0019
#define T_UINT 0x001A
#define T_USHORT 0x001B
#define T_ULONG 0x001C
#define T_FLOAT 0x0025
#define T_DOUBLE 0x0026
#define T_VOID 0x0001 /* void parameter list */
#define T_FUNC 0x0002 /* Function */
#define T_UNSIGNED 0x0008 /* Class */
#define T_INTEGER 0x0010 /* Class */
#define T_REAL 0x0020 /* Class */
#define T_POINTER 0x0040 /* Class */
#define T_PTR 0x0049
#define T_ARRAY 0x004A
#define T_STRUCT 0x0080
#define T_UNION 0x0081
#define T_SMASK 0x003F
/* Forward for a symbol entry */ /* Forward for a symbol entry */
struct SymEntry; struct SymEntry;
@ -251,7 +221,7 @@ type* Indirect (type* Type);
* given type points to. * given type points to.
*/ */
int IsVoid (const type* Type); int IsTypeVoid (const type* Type);
/* Return true if this is a void type */ /* Return true if this is a void type */
int IsPtr (const type* Type); int IsPtr (const type* Type);

View File

@ -840,7 +840,7 @@ void ParseDecl (const DeclSpec* Spec, Declaration* D, unsigned Mode)
TypeCpy (D->T, Spec->Type); TypeCpy (D->T, Spec->Type);
/* Check the size of the generated type */ /* Check the size of the generated type */
if (!IsFunc (D->Type) && SizeOf (D->Type) >= 0x10000) { if (!IsFunc (D->Type) && !IsTypeVoid (D->Type) && SizeOf (D->Type) >= 0x10000) {
Error (ERR_ILLEGAL_SIZE); Error (ERR_ILLEGAL_SIZE);
} }
} }
@ -886,7 +886,7 @@ static void ParseVoidInit (void)
constexpr (&lval); constexpr (&lval);
switch (lval.e_tptr[0]) { switch (lval.e_tptr[0]) {
case T_CHAR: case T_SCHAR:
case T_UCHAR: case T_UCHAR:
if ((lval.e_flags & E_MCTYPE) == E_TCONST) { if ((lval.e_flags & E_MCTYPE) == E_TCONST) {
/* Make it byte sized */ /* Make it byte sized */
@ -992,7 +992,7 @@ void ParseInit (type *tptr)
switch (*tptr) { switch (*tptr) {
case T_CHAR: case T_SCHAR:
case T_UCHAR: case T_UCHAR:
constexpr (&lval); constexpr (&lval);
if ((lval.e_flags & E_MCTYPE) == E_TCONST) { if ((lval.e_flags & E_MCTYPE) == E_TCONST) {

View File

@ -10,11 +10,13 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "../common/xmalloc.h" /* common */
#include "check.h"
#include "xmalloc.h"
/* cc65 */
#include "asmcode.h" #include "asmcode.h"
#include "asmlabel.h" #include "asmlabel.h"
#include "check.h"
#include "codegen.h" #include "codegen.h"
#include "datatype.h" #include "datatype.h"
#include "declare.h" #include "declare.h"
@ -202,7 +204,7 @@ unsigned assignadjust (type* lhst, struct expent* rhs)
rhs->e_tptr = lhst; rhs->e_tptr = lhst;
/* First, do some type checking */ /* First, do some type checking */
if (IsVoid (lhst) || IsVoid (rhst)) { if (IsTypeVoid (lhst) || IsTypeVoid (rhst)) {
/* If one of the sides are of type void, output a more apropriate /* If one of the sides are of type void, output a more apropriate
* error message. * error message.
*/ */
@ -948,7 +950,7 @@ static int arrayref (int k, struct expent* lval)
/* Done */ /* Done */
goto end_array; goto end_array;
} else if ((tptr2 = lval2.e_tptr) [0] & T_POINTER) { } else if (IsPtr (tptr2 = lval2.e_tptr)) {
/* Subscript is pointer, get element type */ /* Subscript is pointer, get element type */
lval2.e_tptr = Indirect (tptr2); lval2.e_tptr = Indirect (tptr2);
@ -1416,7 +1418,7 @@ static int typecast (struct expent* lval)
} }
/* Do the actual cast. Special handling for void casts */ /* Do the actual cast. Special handling for void casts */
if (!IsVoid (Type)) { if (!IsTypeVoid (Type)) {
/* Mark the lhs as const to avoid a manipulation of TOS */ /* Mark the lhs as const to avoid a manipulation of TOS */
g_typecast (TypeOf (Type) | CF_CONST, rflags); g_typecast (TypeOf (Type) | CF_CONST, rflags);
} }

View File

@ -33,8 +33,10 @@
#include "../common/xmalloc.h" /* common */
#include "xmalloc.h"
/* cc65 */
#include "asmcode.h" #include "asmcode.h"
#include "asmlabel.h" #include "asmlabel.h"
#include "codegen.h" #include "codegen.h"
@ -131,7 +133,7 @@ type* GetReturnType (Function* F)
int HasVoidReturn (const Function* F) int HasVoidReturn (const Function* F)
/* Return true if the function does not have a return value */ /* Return true if the function does not have a return value */
{ {
return IsVoid (F->ReturnType); return IsTypeVoid (F->ReturnType);
} }

View File

@ -37,10 +37,12 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include "../common/xmalloc.h" /* common */
#include "asmcode.h"
#include "check.h" #include "check.h"
#include "xmalloc.h"
/* cc65 */
#include "asmcode.h"
#include "error.h" #include "error.h"
#include "global.h" #include "global.h"
#include "incpath.h" #include "incpath.h"

View File

@ -35,8 +35,11 @@
#include <stdio.h> #include <stdio.h>
#include "asmlabel.h" /* common */
#include "check.h" #include "check.h"
/* cc65 */
#include "asmlabel.h"
#include "ctrans.h" #include "ctrans.h"
#include "codegen.h" #include "codegen.h"
#include "error.h" #include "error.h"

View File

@ -16,7 +16,6 @@ OBJS = anonname.o \
asmcode.o \ asmcode.o \
asmlabel.o \ asmlabel.o \
asmline.o \ asmline.o \
check.o \
codegen.o \ codegen.o \
compile.o \ compile.o \
cpu.o \ cpu.o \

View File

@ -71,7 +71,6 @@ OBJS = anonname.obj \
asmcode.obj \ asmcode.obj \
asmlabel.obj \ asmlabel.obj \
asmline.obj \ asmline.obj \
check.obj \
codegen.obj \ codegen.obj \
compile.obj \ compile.obj \
cpu.obj \ cpu.obj \
@ -128,7 +127,6 @@ FILE anonname.obj
FILE asmcode.obj FILE asmcode.obj
FILE asmlabel.obj FILE asmlabel.obj
FILE asmline.obj FILE asmline.obj
FILE check.obj
FILE codegen.obj FILE codegen.obj
FILE compile.obj FILE compile.obj
FILE cpu.obj FILE cpu.obj

View File

@ -40,12 +40,12 @@
/* common */ /* common */
#include "attrib.h" #include "attrib.h"
#include "check.h"
#include "xmalloc.h" #include "xmalloc.h"
/* cc65 */ /* cc65 */
#include "asmlabel.h" #include "asmlabel.h"
#include "asmline.h" #include "asmline.h"
#include "check.h"
#include "cpu.h" #include "cpu.h"
#include "error.h" #include "error.h"
#include "global.h" #include "global.h"

View File

@ -34,13 +34,13 @@
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
/* common */ /* common */
#include "check.h"
#include "xmalloc.h" #include "xmalloc.h"
/* cc65 */ /* cc65 */
#include "check.h"
#include "segname.h" #include "segname.h"

View File

@ -36,7 +36,10 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
/* common */
#include "check.h" #include "check.h"
/* cc65 */
#include "codegen.h" #include "codegen.h"
#include "error.h" #include "error.h"
#include "global.h" #include "global.h"

View File

@ -306,7 +306,7 @@ static void cascadeswitch (struct expent* eval)
val = lval.e_const; val = lval.e_const;
switch (*eval->e_tptr) { switch (*eval->e_tptr) {
case T_CHAR: case T_SCHAR:
/* Signed char */ /* Signed char */
if (val < -128 || val > 127) { if (val < -128 || val > 127) {
Error (ERR_RANGE); Error (ERR_RANGE);

View File

@ -38,12 +38,14 @@
#include <stdarg.h> #include <stdarg.h>
#include <string.h> #include <string.h>
#include "../common/hashstr.h" /* common */
#include "../common/xmalloc.h" #include "check.h"
#include "hashstr.h"
#include "xmalloc.h"
/* cc65 */
#include "asmcode.h" #include "asmcode.h"
#include "asmlabel.h" #include "asmlabel.h"
#include "check.h"
#include "codegen.h" #include "codegen.h"
#include "datatype.h" #include "datatype.h"
#include "declare.h" #include "declare.h"