Oberon || Library || Module Index || Search Engine || Definition || Module


Ulm's Oberon Library:
Types


NAME

Types - collection of compiler-dependent base types

SYNOPSIS

TYPE Address = SYSTEM.ADDRESS;
TYPE UntracedAddress = SYSTEM.UNTRACEDADDRESS;
TYPE IntAddress = LONGINT;
TYPE Count = LONGINT;
TYPE Size = Count;
TYPE Byte = BYTE;


CONST bigEndian = 0; littleEndian = 1; CONST byteorder = bigEndian; (* machine-dependent constant *) TYPE ByteOrder = SHORTINT; (* bigEndian or littleEndian *)

TYPE Int8 = SHORTINT; TYPE Int16 = SYSTEM.INT16; TYPE Int32 = LONGINT;

TYPE Real32 = REAL; TYPE Real64 = REAL; TYPE Real128 = LONGREAL;

CONST bigEndian = 0; (* SPARC, M68K etc *) CONST littleEndian = 1; (* Intel 80x86, VAX etc *) CONST byteorder = bigEndian; (* machine-dependent constant *) TYPE ByteOrder = SHORTINT; (* bigEndian or littleEndian *)

(* relationship between SET and INTEGER *) TYPE SetInt = INTEGER; (* INTEGER type that corresponds to SET *) CONST msb = SYS.VAL(SET, MIN(SetInt)); CONST msbIsMax = SYS.VAL(SHORTINT, (msb = {MAX(SET)})); CONST msbIs0 = SYS.VAL(SHORTINT, (msb = {0})); CONST msbindex = msbIsMax * MAX(SET); CONST lsbindex = MAX(SET) - msbindex; CONST nofbits = MAX(SET) + 1;

PROCEDURE ToInt8(int: LONGINT) : Int8; PROCEDURE ToInt16(int: LONGINT) : Int16; PROCEDURE ToInt32(int: LONGINT) : Int32;

PROCEDURE ToReal32(real: LONGREAL) : Real32; PROCEDURE ToReal64(real: LONGREAL) : Real64; PROCEDURE ToReal128(real: LONGREAL) : Real128;

DESCRIPTION

Types exports some base type definitions which are compiler-dependent. The Oberon Report assumes that LONGINT is the appropriate type for address arithmetic (e.g. SYSTEM.ADR is defined to return LONGINT) but this is not necessarily true for all Oberon implementations. Ulm's Oberon compiler, for example, distinguishes between addresses which are to be traced by the garbage collector and those which are to be ignored. For this to work, SYSTEM exports ADDRESS and UNTRACEDADDRESS. Both are compatible to LONGINT but not identical. Types allows to reduce the dependency from Ulm's version of SYSTEM by use of Types.Address and Types.UntracedAddress instead of SYSTEM.ADDRESS and SYSTEM.UNTRACEDADDRESS.

Count is expected to be the return type of LEN, and consequently an appropriate type for array indices. Size should be compatible to the return type of SYSTEM.SIZE. Some Oberon compilers define BYTE as standard type, others export BYTE from SYSTEM. Byte allows to avoid this compiler dependency.

The numeric types Int8 .. Real128 are expected to be defined to the best-fitting base type respectively, that is

Some constants and a type are provided to make conversions between SET and a corresponding integer type more portable. SetInt is the integer type whose size is identical to that of SET. The correspondence between set elements (ranging from 0 to MAX(SET)) and individual bits of an integer value that is represented as 2-complement depends on endianess and the discretion of the compiler writer. msbindex is the set element that corresponds to the most significant bit; likewise lsbindex designates the set element representing the least significant bit. Both constants depend on following auxiliary constants:

msb
represents the set converted from an integer value having only the most-significant bit set (MIN(INTEGER))
msbIsMax
is 1, if the most-significant bit is represented by element MAX(SET), and 0 otherwise.
msbIs0
is 1, if the most-significant bit is represented by element 0, and 0 otherwise.
Exactly one of the constants msbIsMax and msbIs0 is 1. This assertion is included in the initialization part.

SEE ALSO

SYSTEM
compiler-dependent address types ADDRESS and UNTRACEDADDRESS
Report of Ulm's Oberon Compiler
Edited by: borchert, last change: 2005/03/11, revision: 1.5, converted to HTML: 2005/03/11

Oberon || Library || Module Index || Search Engine || Definition || Module