mirror of
https://github.com/vishapoberon/compiler.git
synced 2026-04-06 06:22:25 +00:00
Use typedefs rather than defines for basic types.
This commit is contained in:
parent
d3ee82a0c4
commit
5b77460e4f
3 changed files with 46 additions and 35 deletions
|
|
@ -54,13 +54,13 @@ void SYSTEM_ENUMR(void *adr, LONGINT *typ, LONGINT size, LONGINT n, void (*P)())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LONGINT SYSTEM_DIV(unsigned LONGINT x, unsigned LONGINT y)
|
LONGINT SYSTEM_DIV(U_LONGINT x, U_LONGINT y)
|
||||||
{ if ((LONGINT) x >= 0) return (x / y);
|
{ if ((LONGINT) x >= 0) return (x / y);
|
||||||
else return -((y - 1 - x) / y);
|
else return -((y - 1 - x) / y);
|
||||||
}
|
}
|
||||||
|
|
||||||
LONGINT SYSTEM_MOD(unsigned LONGINT x, unsigned LONGINT y)
|
LONGINT SYSTEM_MOD(U_LONGINT x, U_LONGINT y)
|
||||||
{ unsigned LONGINT m;
|
{ U_LONGINT m;
|
||||||
if ((LONGINT) x >= 0) return (x % y);
|
if ((LONGINT) x >= 0) return (x % y);
|
||||||
else { m = (-x) % y;
|
else { m = (-x) % y;
|
||||||
if (m != 0) return (y - m); else return 0;
|
if (m != 0) return (y - m); else return 0;
|
||||||
|
|
|
||||||
|
|
@ -41,25 +41,35 @@
|
||||||
|
|
||||||
// Oberon types
|
// Oberon types
|
||||||
|
|
||||||
#define BOOLEAN char
|
typedef char BOOLEAN;
|
||||||
#define SYSTEM_BYTE unsigned char
|
typedef unsigned char SYSTEM_BYTE;
|
||||||
#define CHAR unsigned char
|
typedef unsigned char CHAR;
|
||||||
#define SHORTINT signed char
|
typedef signed char SHORTINT;
|
||||||
#define REAL float
|
typedef float REAL;
|
||||||
#define LONGREAL double
|
typedef double LONGREAL;
|
||||||
#define SYSTEM_PTR void*
|
typedef void* SYSTEM_PTR;
|
||||||
|
|
||||||
|
// Unsigned variants are for use by shift and rotate macros.
|
||||||
|
|
||||||
|
typedef unsigned char U_SYSTEM_BYTE;
|
||||||
|
typedef unsigned char U_CHAR;
|
||||||
|
typedef unsigned char U_SHORTINT;
|
||||||
|
|
||||||
// For 32 bit builds, the size of LONGINT depends on a make option:
|
// For 32 bit builds, the size of LONGINT depends on a make option:
|
||||||
|
|
||||||
#if (__SIZEOF_POINTER__ == 8) || defined(LARGE) || defined(_WIN64)
|
#if (__SIZEOF_POINTER__ == 8) || defined(LARGE) || defined(_WIN64)
|
||||||
#define INTEGER int // INTEGER is 32 bit.
|
typedef int INTEGER; // INTEGER is 32 bit.
|
||||||
#define LONGINT long long // LONGINT is 64 bit. (long long is always 64 bits, while long can be 32 bits e.g. under MSC/MingW)
|
typedef long long LONGINT; // LONGINT is 64 bit. (long long is always 64 bits, while long can be 32 bits e.g. under MSC/MingW)
|
||||||
|
typedef int U_INTEGER;
|
||||||
|
typedef unsigned long long U_LONGINT;
|
||||||
#else
|
#else
|
||||||
#define INTEGER short int // INTEGER is 16 bit.
|
typedef short int INTEGER; // INTEGER is 16 bit.
|
||||||
#define LONGINT long // LONGINT is 32 bit.
|
typedef long LONGINT; // LONGINT is 32 bit.
|
||||||
|
typedef unsigned short int U_INTEGER;
|
||||||
|
typedef unsigned long U_LONGINT;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SET unsigned LONGINT
|
typedef U_LONGINT SET;
|
||||||
|
|
||||||
|
|
||||||
// OS Memory allocation interfaces are in PlatformXXX.Mod
|
// OS Memory allocation interfaces are in PlatformXXX.Mod
|
||||||
|
|
@ -78,8 +88,8 @@ extern double SYSTEM_ABSD (double i);
|
||||||
extern void SYSTEM_INHERIT(LONGINT *t, LONGINT *t0);
|
extern void SYSTEM_INHERIT(LONGINT *t, LONGINT *t0);
|
||||||
extern void SYSTEM_ENUMP (void *adr, LONGINT n, void (*P)());
|
extern void SYSTEM_ENUMP (void *adr, LONGINT n, void (*P)());
|
||||||
extern void SYSTEM_ENUMR (void *adr, LONGINT *typ, LONGINT size, LONGINT n, void (*P)());
|
extern void SYSTEM_ENUMR (void *adr, LONGINT *typ, LONGINT size, LONGINT n, void (*P)());
|
||||||
extern LONGINT SYSTEM_DIV (unsigned LONGINT x, unsigned LONGINT y);
|
extern LONGINT SYSTEM_DIV (U_LONGINT x, U_LONGINT y);
|
||||||
extern LONGINT SYSTEM_MOD (unsigned LONGINT x, unsigned LONGINT y);
|
extern LONGINT SYSTEM_MOD (U_LONGINT x, U_LONGINT y);
|
||||||
extern LONGINT SYSTEM_ENTIER (double x);
|
extern LONGINT SYSTEM_ENTIER (double x);
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -127,22 +137,22 @@ static int __str_cmp(CHAR *x, CHAR *y){
|
||||||
#define __GET(a, x, t) x= *(t*)(uintptr_t)(a)
|
#define __GET(a, x, t) x= *(t*)(uintptr_t)(a)
|
||||||
#define __PUT(a, x, t) *(t*)(uintptr_t)(a)=x
|
#define __PUT(a, x, t) *(t*)(uintptr_t)(a)=x
|
||||||
|
|
||||||
#define __LSHL(x, n, t) ((t)((unsigned t)(x)<<(n)))
|
#define __LSHL(x, n, t) ((t)((U_##t)(x)<<(n)))
|
||||||
#define __LSHR(x, n, t) ((t)((unsigned t)(x)>>(n)))
|
#define __LSHR(x, n, t) ((t)((U_##t)(x)>>(n)))
|
||||||
#define __LSH(x, n, t) ((n)>=0? __LSHL(x, n, t): __LSHR(x, -(n), t))
|
#define __LSH(x, n, t) ((n)>=0? __LSHL(x, n, t): __LSHR(x, -(n), t))
|
||||||
|
|
||||||
#define __ASHL(x, n) ((LONGINT)(x)<<(n))
|
#define __ASHL(x, n) ((LONGINT)(x)<<(n))
|
||||||
#define __ASHR(x, n) ((LONGINT)(x)>>(n))
|
#define __ASHR(x, n) ((LONGINT)(x)>>(n))
|
||||||
#define __ASH(x, n) ((n)>=0?__ASHL(x,n):__ASHR(x,-(n)))
|
#define __ASH(x, n) ((n)>=0?__ASHL(x,n):__ASHR(x,-(n)))
|
||||||
|
|
||||||
#define __ROTL(x, n, t) ((t)((unsigned t)(x)<<(n)|(unsigned t)(x)>>(8*sizeof(t)-(n))))
|
#define __ROTL(x, n, t) ((t)((U_##t)(x)<<(n)|(U_##t)(x)>>(8*sizeof(t)-(n))))
|
||||||
#define __ROTR(x, n, t) ((t)((unsigned t)(x)>>(n)|(unsigned t)(x)<<(8*sizeof(t)-(n))))
|
#define __ROTR(x, n, t) ((t)((U_##t)(x)>>(n)|(U_##t)(x)<<(8*sizeof(t)-(n))))
|
||||||
#define __ROT(x, n, t) ((n)>=0? __ROTL(x, n, t): __ROTR(x, -(n), t))
|
#define __ROT(x, n, t) ((n)>=0? __ROTL(x, n, t): __ROTR(x, -(n), t))
|
||||||
|
|
||||||
#define __BIT(x, n) (*(unsigned LONGINT*)(x)>>(n)&1)
|
#define __BIT(x, n) (*(U_LONGINT*)(x)>>(n)&1)
|
||||||
#define __MOVE(s, d, n) memcpy((char*)(uintptr_t)(d),(char*)(uintptr_t)(s),n)
|
#define __MOVE(s, d, n) memcpy((char*)(uintptr_t)(d),(char*)(uintptr_t)(s),n)
|
||||||
#define __ASHF(x, n) SYSTEM_ASH((LONGINT)(x), (LONGINT)(n))
|
#define __ASHF(x, n) SYSTEM_ASH((LONGINT)(x), (LONGINT)(n))
|
||||||
#define __SHORT(x, y) ((int)((unsigned LONGINT)(x)+(y)<(y)+(y)?(x):(__HALT(-8),0)))
|
#define __SHORT(x, y) ((int)((U_LONGINT)(x)+(y)<(y)+(y)?(x):(__HALT(-8),0)))
|
||||||
#define __SHORTF(x, y) ((int)(__RF((x)+(y),(y)+(y))-(y)))
|
#define __SHORTF(x, y) ((int)(__RF((x)+(y),(y)+(y))-(y)))
|
||||||
#define __CHR(x) ((CHAR)__R(x, 256))
|
#define __CHR(x) ((CHAR)__R(x, 256))
|
||||||
#define __CHRF(x) ((CHAR)__RF(x, 256))
|
#define __CHRF(x) ((CHAR)__RF(x, 256))
|
||||||
|
|
@ -165,9 +175,9 @@ static int __str_cmp(CHAR *x, CHAR *y){
|
||||||
|
|
||||||
// Runtime checks
|
// Runtime checks
|
||||||
|
|
||||||
#define __X(i, ub) (((unsigned LONGINT)(i)<(unsigned LONGINT)(ub))?i:(__HALT(-2),0))
|
#define __X(i, ub) (((U_LONGINT)(i)<(U_LONGINT)(ub))?i:(__HALT(-2),0))
|
||||||
#define __XF(i, ub) SYSTEM_XCHK((LONGINT)(i), (LONGINT)(ub))
|
#define __XF(i, ub) SYSTEM_XCHK((LONGINT)(i), (LONGINT)(ub))
|
||||||
#define __R(i, ub) (((unsigned LONGINT)(i)<(unsigned LONGINT)(ub))?i:(__HALT(-8),0))
|
#define __R(i, ub) (((U_LONGINT)(i)<(U_LONGINT)(ub))?i:(__HALT(-8),0))
|
||||||
#define __RF(i, ub) SYSTEM_RCHK((LONGINT)(i),(LONGINT)(ub))
|
#define __RF(i, ub) SYSTEM_RCHK((LONGINT)(i),(LONGINT)(ub))
|
||||||
#define __RETCHK __retchk: __HALT(-3); return 0;
|
#define __RETCHK __retchk: __HALT(-3); return 0;
|
||||||
#define __CASECHK __HALT(-4)
|
#define __CASECHK __HALT(-4)
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,9 @@
|
||||||
//
|
//
|
||||||
// Includes Windows.h while avoiding conflicts with Oberon types.
|
// Includes Windows.h while avoiding conflicts with Oberon types.
|
||||||
|
|
||||||
|
|
||||||
|
#define BOOLEAN _BOOLEAN
|
||||||
|
#define CHAR _CHAR
|
||||||
|
#include <windows.h>
|
||||||
#undef BOOLEAN
|
#undef BOOLEAN
|
||||||
#undef CHAR
|
#undef CHAR
|
||||||
#include <windows.h>
|
|
||||||
#define BOOLEAN char
|
|
||||||
#define CHAR unsigned char
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue