mirror of
https://github.com/vishapoberon/compiler.git
synced 2026-04-06 19:12:25 +00:00
Merge branch 'new-system-types'
Conflicts: voc
This commit is contained in:
commit
26542b84df
27 changed files with 972 additions and 687 deletions
|
|
@ -12,6 +12,7 @@ uses double # as concatenation operator
|
|||
*/
|
||||
|
||||
#include <alloca.h>
|
||||
#include <stdint.h> /* for type sizes -- noch */
|
||||
//#include <string.h>
|
||||
|
||||
extern void *memcpy(void *dest, const void *src, unsigned long n);
|
||||
|
|
@ -52,6 +53,10 @@ typedef void *SYSTEM_PTR;
|
|||
//#define *SYSTEM_PTR void
|
||||
//typedef unsigned char SYSTEM_BYTE;
|
||||
#define SYSTEM_BYTE unsigned char
|
||||
typedef int8_t SYSTEM_INT8;
|
||||
typedef int16_t SYSTEM_INT16;
|
||||
typedef int32_t SYSTEM_INT32;
|
||||
typedef int64_t SYSTEM_INT64;
|
||||
|
||||
/* runtime system routines */
|
||||
extern long SYSTEM_DIV();
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ uses double # as concatenation operator
|
|||
*/
|
||||
#include <stdlib.h>
|
||||
//#include <alloca.h>
|
||||
#include <stdint.h> /* for type sizes -- noch */
|
||||
//#include <string.h>
|
||||
|
||||
extern void *memcpy(void *dest, const void *src, unsigned long n);
|
||||
|
|
@ -52,6 +53,10 @@ typedef void *SYSTEM_PTR;
|
|||
//#define *SYSTEM_PTR void
|
||||
//typedef unsigned char SYSTEM_BYTE;
|
||||
#define SYSTEM_BYTE unsigned char
|
||||
typedef int8_t SYSTEM_INT8;
|
||||
typedef int16_t SYSTEM_INT16;
|
||||
typedef int32_t SYSTEM_INT32;
|
||||
typedef int64_t SYSTEM_INT64;
|
||||
|
||||
/* runtime system routines */
|
||||
extern long SYSTEM_DIV();
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ uses double # as concatenation operator
|
|||
*/
|
||||
|
||||
#include <alloca.h>
|
||||
#include <stdint.h> /* for type sizes -- noch */
|
||||
|
||||
//extern void *memcpy(void *dest, const void *src, long n);
|
||||
extern void *memcpy(void *dest, const void *src, size_t n);
|
||||
|
|
@ -37,6 +38,10 @@ typedef double LONGREAL;
|
|||
typedef unsigned long SET;
|
||||
typedef void *SYSTEM_PTR;
|
||||
typedef unsigned char SYSTEM_BYTE;
|
||||
typedef int8_t SYSTEM_INT8;
|
||||
typedef int16_t SYSTEM_INT16;
|
||||
typedef int32_t SYSTEM_INT32;
|
||||
typedef int64_t SYSTEM_INT64;
|
||||
|
||||
/* runtime system routines */
|
||||
extern long SYSTEM_DIV();
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ uses double # as concatenation operator
|
|||
*/
|
||||
|
||||
#include <alloca.h>
|
||||
#include <stdint.h> /* for type sizes -- noch */
|
||||
|
||||
//extern void *memcpy(void *dest, const void *src, long n);
|
||||
extern void *memcpy(void *dest, const void *src, size_t n);
|
||||
|
|
@ -37,6 +38,10 @@ typedef double LONGREAL;
|
|||
typedef unsigned long SET;
|
||||
typedef void *SYSTEM_PTR;
|
||||
typedef unsigned char SYSTEM_BYTE;
|
||||
typedef int8_t SYSTEM_INT8;
|
||||
typedef int16_t SYSTEM_INT16;
|
||||
typedef int32_t SYSTEM_INT32;
|
||||
typedef int64_t SYSTEM_INT64;
|
||||
|
||||
/* runtime system routines */
|
||||
extern long SYSTEM_DIV();
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ uses double # as concatenation operator
|
|||
*/
|
||||
|
||||
#include <alloca.h>
|
||||
#include <stdint.h> /* for type sizes -- noch */
|
||||
|
||||
//extern void *memcpy(void *dest, const void *src, long n);
|
||||
extern void *memcpy(void *dest, const void *src, size_t n);
|
||||
|
|
@ -37,6 +38,10 @@ typedef double LONGREAL;
|
|||
typedef unsigned long SET;
|
||||
typedef void *SYSTEM_PTR;
|
||||
typedef unsigned char SYSTEM_BYTE;
|
||||
typedef int8_t SYSTEM_INT8;
|
||||
typedef int16_t SYSTEM_INT16;
|
||||
typedef int32_t SYSTEM_INT32;
|
||||
typedef int64_t SYSTEM_INT64;
|
||||
|
||||
/* runtime system routines */
|
||||
extern long SYSTEM_DIV();
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ uses double # as concatenation operator
|
|||
*/
|
||||
|
||||
#include <alloca.h>
|
||||
#include <stdint.h> /* for type sizes -- noch */
|
||||
|
||||
extern void *memcpy(void *dest, const void *src, unsigned long n);
|
||||
extern void *malloc(unsigned long size);
|
||||
|
|
@ -51,6 +52,10 @@ typedef void *SYSTEM_PTR;
|
|||
//#define *SYSTEM_PTR void
|
||||
//typedef unsigned char SYSTEM_BYTE;
|
||||
#define SYSTEM_BYTE unsigned char
|
||||
typedef int8_t SYSTEM_INT8;
|
||||
typedef int16_t SYSTEM_INT16;
|
||||
typedef int32_t SYSTEM_INT32;
|
||||
typedef int64_t SYSTEM_INT64;
|
||||
|
||||
/* runtime system routines */
|
||||
extern long SYSTEM_DIV();
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ uses double # as concatenation operator
|
|||
*/
|
||||
|
||||
#include <alloca.h>
|
||||
#include <stdint.h> /* for type sizes -- noch */
|
||||
|
||||
//extern void *memcpy(void *dest, const void *src, long n);
|
||||
extern void *memcpy(void *dest, const void *src, size_t n);
|
||||
|
|
@ -37,6 +38,10 @@ typedef double LONGREAL;
|
|||
typedef unsigned long SET;
|
||||
typedef void *SYSTEM_PTR;
|
||||
typedef unsigned char SYSTEM_BYTE;
|
||||
typedef int8_t SYSTEM_INT8;
|
||||
typedef int16_t SYSTEM_INT16;
|
||||
typedef int32_t SYSTEM_INT32;
|
||||
typedef int64_t SYSTEM_INT64;
|
||||
|
||||
/* runtime system routines */
|
||||
extern long SYSTEM_DIV();
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ uses double # as concatenation operator
|
|||
*/
|
||||
|
||||
#include <alloca.h>
|
||||
#include <stdint.h> /* for type sizes -- noch */
|
||||
|
||||
//extern void *memcpy(void *dest, const void *src, long n);
|
||||
extern void *memcpy(void *dest, const void *src, size_t n);
|
||||
|
|
@ -37,6 +38,10 @@ typedef double LONGREAL;
|
|||
typedef unsigned long SET;
|
||||
typedef void *SYSTEM_PTR;
|
||||
typedef unsigned char SYSTEM_BYTE;
|
||||
typedef int8_t SYSTEM_INT8;
|
||||
typedef int16_t SYSTEM_INT16;
|
||||
typedef int32_t SYSTEM_INT32;
|
||||
typedef int64_t SYSTEM_INT64;
|
||||
|
||||
/* runtime system routines */
|
||||
extern long SYSTEM_DIV();
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ uses double # as concatenation operator
|
|||
*/
|
||||
|
||||
#include <alloca.h>
|
||||
#include <stdint.h> /* for type sizes -- noch */
|
||||
|
||||
//extern void *memcpy(void *dest, const void *src, long n);
|
||||
extern void *memcpy(void *dest, const void *src, size_t n);
|
||||
|
|
@ -37,6 +38,10 @@ typedef double LONGREAL;
|
|||
typedef unsigned long SET;
|
||||
typedef void *SYSTEM_PTR;
|
||||
typedef unsigned char SYSTEM_BYTE;
|
||||
typedef int8_t SYSTEM_INT8;
|
||||
typedef int16_t SYSTEM_INT16;
|
||||
typedef int32_t SYSTEM_INT32;
|
||||
typedef int64_t SYSTEM_INT64;
|
||||
|
||||
/* runtime system routines */
|
||||
extern long SYSTEM_DIV();
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ uses double # as concatenation operator
|
|||
*/
|
||||
|
||||
#include <alloca.h>
|
||||
#include <stdint.h> /* for type sizes -- noch */
|
||||
|
||||
extern void *memcpy(void *dest, const void *src, unsigned long n);
|
||||
extern void *malloc(unsigned long size);
|
||||
|
|
@ -51,6 +52,10 @@ typedef void *SYSTEM_PTR;
|
|||
//#define *SYSTEM_PTR void
|
||||
//typedef unsigned char SYSTEM_BYTE;
|
||||
#define SYSTEM_BYTE unsigned char
|
||||
typedef int8_t SYSTEM_INT8;
|
||||
typedef int16_t SYSTEM_INT16;
|
||||
typedef int32_t SYSTEM_INT32;
|
||||
typedef int64_t SYSTEM_INT64;
|
||||
|
||||
/* runtime system routines */
|
||||
extern long SYSTEM_DIV();
|
||||
|
|
|
|||
|
|
@ -10,3 +10,7 @@ PTR 4 4
|
|||
PROC 4 4
|
||||
RECORD 1 1
|
||||
ENDIAN 0 0
|
||||
SYSTEM.INT8 1 1
|
||||
SYSTEM.INT16 2 2
|
||||
SYSTEM.INT32 4 4
|
||||
SYSTEM.INT64 8 4
|
||||
|
|
|
|||
|
|
@ -10,3 +10,7 @@ PTR 8 8
|
|||
PROC 8 8
|
||||
RECORD 1 1
|
||||
ENDIAN 1 0
|
||||
SYSTEM.INT8 1 1
|
||||
SYSTEM.INT16 2 2
|
||||
SYSTEM.INT32 4 4
|
||||
SYSTEM.INT64 8 8
|
||||
|
|
|
|||
|
|
@ -10,3 +10,7 @@ PTR 4 4
|
|||
PROC 4 4
|
||||
RECORD 1 1
|
||||
ENDIAN 1 0
|
||||
SYSTEM.INT8 1 1
|
||||
SYSTEM.INT16 2 2
|
||||
SYSTEM.INT32 4 4
|
||||
SYSTEM.INT64 8 4
|
||||
|
|
|
|||
|
|
@ -10,3 +10,7 @@ PTR 4 4
|
|||
PROC 4 4
|
||||
RECORD 1 1
|
||||
ENDIAN 0 0
|
||||
SYSTEM.INT8 1 1
|
||||
SYSTEM.INT16 2 2
|
||||
SYSTEM.INT32 4 4
|
||||
SYSTEM.INT64 8 4
|
||||
|
|
|
|||
|
|
@ -10,3 +10,7 @@ PTR 4 4
|
|||
PROC 4 4
|
||||
RECORD 1 1
|
||||
ENDIAN 1 0
|
||||
SYSTEM.INT8 1 1
|
||||
SYSTEM.INT16 2 2
|
||||
SYSTEM.INT32 4 4
|
||||
SYSTEM.INT64 8 4
|
||||
|
|
|
|||
|
|
@ -10,3 +10,7 @@ PTR 8 8
|
|||
PROC 8 8
|
||||
RECORD 1 1
|
||||
ENDIAN 1 0
|
||||
SYSTEM.INT8 1 1
|
||||
SYSTEM.INT16 2 2
|
||||
SYSTEM.INT32 4 4
|
||||
SYSTEM.INT64 8 8
|
||||
|
|
|
|||
|
|
@ -14,6 +14,10 @@ struct {CHAR ch; BOOLEAN x;} b;
|
|||
struct {CHAR ch; SHORTINT x;} si;
|
||||
struct {CHAR ch; INTEGER x;} i;
|
||||
struct {CHAR ch; LONGINT x;} li;
|
||||
struct {CHAR ch; SYSTEM_INT8 x;} i8;
|
||||
struct {CHAR ch; SYSTEM_INT16 x;} i16;
|
||||
struct {CHAR ch; SYSTEM_INT32 x;} i32;
|
||||
struct {CHAR ch; SYSTEM_INT64 x;} i64;
|
||||
struct {CHAR ch; SET x;} s;
|
||||
struct {CHAR ch; REAL x;} r;
|
||||
struct {CHAR ch; LONGREAL x;} lr;
|
||||
|
|
@ -40,6 +44,11 @@ int main()
|
|||
printf("RECORD %d %lu\n", (sizeof rec2 == 65) == (sizeof rec0 == 1), sizeof rec2 - 64);
|
||||
x = 1;
|
||||
printf("ENDIAN %hhd %d\n", *(char*)&x, 0);
|
||||
printf("SYSTEM.INT8 %lu %lu\n", sizeof(SYSTEM_INT8), (char*)&i8.x - (char*)&i8);
|
||||
printf("SYSTEM.INT16 %lu %lu\n", sizeof(SYSTEM_INT16), (char*)&i16.x - (char*)&i16);
|
||||
printf("SYSTEM.INT32 %lu %lu\n", sizeof(SYSTEM_INT32), (char*)&i32.x - (char*)&i32);
|
||||
printf("SYSTEM.INT64 %lu %lu\n", sizeof(SYSTEM_INT64), (char*)&i64.x - (char*)&i64);
|
||||
|
||||
|
||||
if (sizeof(CHAR)!=1) printf("error: CHAR should have size 1\n");
|
||||
if (sizeof(BOOLEAN)!=1) printf("error: BOOLEAN should have size 1\n");
|
||||
|
|
|
|||
115
src/voc/OPB.Mod
115
src/voc/OPB.Mod
|
|
@ -1,7 +1,7 @@
|
|||
MODULE OPB; (* RC 6.3.89 / 21.2.94 *) (* object model 17.1.93 *)
|
||||
(* build parse tree *)
|
||||
|
||||
IMPORT OPT, OPS, OPM;
|
||||
IMPORT OPT, OPS, OPM, SYSTEM;
|
||||
|
||||
CONST
|
||||
(* symbol values or ops *)
|
||||
|
|
@ -18,10 +18,18 @@ MODULE OPB; (* RC 6.3.89 / 21.2.94 *) (* object model 17.1.93 *)
|
|||
SProc = 8; CProc = 9; IProc = 10; Mod = 11; Head = 12; TProc = 13;
|
||||
|
||||
(* Structure forms *)
|
||||
Undef = 0; Byte = 1; Bool = 2; Char = 3; SInt = 4; Int = 5; LInt = 6;
|
||||
Undef = 0; Byte = 1; Bool = 2; Char = 3;
|
||||
SInt = 4; Int = 5; LInt = 6;
|
||||
(*Int8 = 7; Int16 = 8; Int32 = 9; Int64 = 10;
|
||||
Real = 11; LReal = 12; Set = 13; String = 14; NilTyp = 15; NoTyp = 16;
|
||||
Pointer = 17; ProcTyp = 18;
|
||||
Comp = 19;*)
|
||||
Real = 7; LReal = 8; Set = 9; String = 10; NilTyp = 11; NoTyp = 12;
|
||||
Pointer = 13; ProcTyp = 14; Comp = 15;
|
||||
intSet = {SInt..LInt}; realSet = {Real, LReal};
|
||||
Pointer = 13; ProcTyp = 14;
|
||||
Int8 = 16; Int16 = 17; Int32 = 18; Int64 = 19;
|
||||
Comp = (*15*)20;
|
||||
|
||||
intSet = {SInt..LInt, Int8..Int64}; realSet = {Real, LReal};
|
||||
|
||||
(* composite structure forms *)
|
||||
Basic = 1; Array = 2; DynArr = 3; Record = 4;
|
||||
|
|
@ -151,12 +159,14 @@ MODULE OPB; (* RC 6.3.89 / 21.2.94 *) (* object model 17.1.93 *)
|
|||
END EmptySet;
|
||||
|
||||
PROCEDURE SetIntType(node: OPT.Node);
|
||||
VAR v: LONGINT;
|
||||
VAR v: LONGINT(*SYSTEM.INT64*);
|
||||
BEGIN v := node^.conval^.intval;
|
||||
IF (OPM.MinSInt <= v) & (v <= OPM.MaxSInt) THEN node^.typ := OPT.sinttyp
|
||||
ELSIF (OPM.MinInt <= v) & (v <= OPM.MaxInt) THEN node^.typ := OPT.inttyp
|
||||
IF (OPM.MinSInt <= SYSTEM.VAL(LONGINT, v)) & (SYSTEM.VAL(LONGINT, v) <= OPM.MaxSInt) THEN node^.typ := OPT.sinttyp
|
||||
ELSIF (OPM.MinInt <= SYSTEM.VAL(LONGINT, v)) & (SYSTEM.VAL(LONGINT, v) <= OPM.MaxInt) THEN node^.typ := OPT.inttyp
|
||||
ELSIF (OPM.MinLInt <= v) & (v <= OPM.MaxLInt) (*bootstrap or cross*) THEN
|
||||
node^.typ := OPT.linttyp
|
||||
(*ELSIF (OPM.MinInt64) <= v) & (v <= OPM.MaxInt64) THEN
|
||||
node^.typ := OPT.int64typ*)
|
||||
ELSE err(203); node^.typ := OPT.sinttyp; node^.conval^.intval := 1
|
||||
END
|
||||
END SetIntType;
|
||||
|
|
@ -405,6 +415,8 @@ MODULE OPB; (* RC 6.3.89 / 21.2.94 *) (* object model 17.1.93 *)
|
|||
ELSE err(69)
|
||||
END ;
|
||||
z^.typ := OPT.booltyp
|
||||
ELSE
|
||||
OPM.WriteString("/* this should not happen. handle this. OPB.MOp(); -- noch */"); OPM.WriteLn;
|
||||
END
|
||||
END ;
|
||||
x := z
|
||||
|
|
@ -476,7 +488,7 @@ MODULE OPB; (* RC 6.3.89 / 21.2.94 *) (* object model 17.1.93 *)
|
|||
CASE f OF
|
||||
Undef:
|
||||
res := eql
|
||||
| Byte, Char..LInt:
|
||||
| Byte, Char..LInt,Int8..Int64:
|
||||
IF xval^.intval < yval^.intval THEN res := lss
|
||||
ELSIF xval^.intval > yval^.intval THEN res := gtr
|
||||
ELSE res := eql
|
||||
|
|
@ -503,6 +515,8 @@ MODULE OPB; (* RC 6.3.89 / 21.2.94 *) (* object model 17.1.93 *)
|
|||
IF xval^.intval # yval^.intval THEN res := neq
|
||||
ELSE res := eql
|
||||
END
|
||||
ELSE
|
||||
OPM.LogWStr("/* this should not happen. handle this. OPB.ConstCmp(); -- noch */"); OPM.LogWLn;
|
||||
END ;
|
||||
x^.typ := OPT.booltyp; RETURN res
|
||||
END ConstCmp;
|
||||
|
|
@ -515,13 +529,13 @@ MODULE OPB; (* RC 6.3.89 / 21.2.94 *) (* object model 17.1.93 *)
|
|||
IF g = String THEN CharToString(x)
|
||||
ELSE err(100); y^.typ := x^.typ; yval^ := xval^
|
||||
END ;
|
||||
| SInt:
|
||||
| SInt, Int8:
|
||||
IF g IN intSet THEN x^.typ := y^.typ
|
||||
ELSIF g = Real THEN x^.typ := OPT.realtyp; xval^.realval := xval^.intval
|
||||
ELSIF g = LReal THEN x^.typ := OPT.lrltyp; xval^.realval := xval^.intval
|
||||
ELSE err(100); y^.typ := x^.typ; yval^ := xval^
|
||||
END
|
||||
| Int:
|
||||
| Int, Int16, Int32, Int64:
|
||||
IF g = SInt THEN y^.typ := OPT.inttyp
|
||||
ELSIF g IN intSet THEN x^.typ := y^.typ
|
||||
ELSIF g = Real THEN x^.typ := OPT.realtyp; xval^.realval := xval^.intval
|
||||
|
|
@ -676,6 +690,8 @@ MODULE OPB; (* RC 6.3.89 / 21.2.94 *) (* object model 17.1.93 *)
|
|||
IF f IN {Bool, Set, NilTyp, Pointer} THEN err(108)
|
||||
ELSE xval^.intval := BoolToInt(ConstCmp() # lss)
|
||||
END
|
||||
ELSE
|
||||
OPM.LogWStr("this should not happen. handle this. OPB.ConstOp(); -- noch "); OPM.LogWLn;
|
||||
END
|
||||
END ConstOp;
|
||||
|
||||
|
|
@ -750,7 +766,7 @@ MODULE OPB; (* RC 6.3.89 / 21.2.94 *) (* object model 17.1.93 *)
|
|||
CASE z^.typ^.form OF
|
||||
Char:
|
||||
IF z^.class = Nconst THEN CharToString(z) ELSE err(100) END
|
||||
| SInt:
|
||||
| SInt, Int8:
|
||||
IF g IN intSet + realSet THEN Convert(z, y^.typ)
|
||||
ELSE err(100)
|
||||
END
|
||||
|
|
@ -759,7 +775,7 @@ MODULE OPB; (* RC 6.3.89 / 21.2.94 *) (* object model 17.1.93 *)
|
|||
ELSIF g IN intSet + realSet THEN Convert(z, y^.typ)
|
||||
ELSE err(100)
|
||||
END
|
||||
| LInt:
|
||||
| LInt, Int16, Int32, Int64:
|
||||
IF g IN intSet THEN Convert(y, z^.typ)
|
||||
ELSIF g IN realSet THEN Convert(z, y^.typ)
|
||||
ELSE err(100)
|
||||
|
|
@ -854,7 +870,7 @@ MODULE OPB; (* RC 6.3.89 / 21.2.94 *) (* object model 17.1.93 *)
|
|||
ELSIF f # Undef THEN err(94); z^.typ := OPT.undftyp
|
||||
END
|
||||
| plus:
|
||||
IF ~(f IN {Undef, SInt..Set}) THEN err(105); typ := OPT.undftyp END ;
|
||||
IF ~(f IN {Undef, SInt..Set, Int8..Int64}) THEN err(105); typ := OPT.undftyp END ;
|
||||
do := TRUE;
|
||||
IF f IN intSet THEN
|
||||
IF (z^.class = Nconst) & (z^.conval^.intval = 0) THEN do := FALSE; z := y END ;
|
||||
|
|
@ -862,7 +878,7 @@ MODULE OPB; (* RC 6.3.89 / 21.2.94 *) (* object model 17.1.93 *)
|
|||
END ;
|
||||
IF do THEN NewOp(op, typ, z, y) END
|
||||
| minus:
|
||||
IF ~(f IN {Undef, SInt..Set}) THEN err(106); typ := OPT.undftyp END ;
|
||||
IF ~(f IN {Undef, SInt..Set, Int8..Int64}) THEN err(106); typ := OPT.undftyp END ;
|
||||
IF ~(f IN intSet) OR (y^.class # Nconst) OR (y^.conval^.intval # 0) THEN NewOp(op, typ, z, y) END
|
||||
| or:
|
||||
IF f = Bool THEN
|
||||
|
|
@ -876,15 +892,19 @@ MODULE OPB; (* RC 6.3.89 / 21.2.94 *) (* object model 17.1.93 *)
|
|||
ELSIF f # Undef THEN err(95); z^.typ := OPT.undftyp
|
||||
END
|
||||
| eql, neq:
|
||||
IF (f IN {Undef..Set, NilTyp, Pointer, ProcTyp}) OR strings(z, y) THEN typ := OPT.booltyp
|
||||
IF (f IN {Undef..Set, NilTyp, Pointer, ProcTyp, Int8..Int64}) OR strings(z, y) THEN typ := OPT.booltyp
|
||||
ELSE err(107); typ := OPT.undftyp
|
||||
END ;
|
||||
NewOp(op, typ, z, y)
|
||||
| lss, leq, gtr, geq:
|
||||
IF (f IN {Undef, Char..LReal}) OR strings(z, y) THEN typ := OPT.booltyp
|
||||
ELSE err(108); typ := OPT.undftyp
|
||||
IF (f IN {Undef, Char..LReal, Int8..Int64}) OR strings(z, y) THEN typ := OPT.booltyp
|
||||
ELSE
|
||||
OPM.LogWLn; OPM.LogWStr("ELSE in Op()"); OPM.LogWLn;
|
||||
err(108); typ := OPT.undftyp
|
||||
END ;
|
||||
NewOp(op, typ, z, y)
|
||||
ELSE
|
||||
OPM.LogWStr(" OPB.Op(), not handled case possibility; -- noch"); OPM.LogWLn;
|
||||
END
|
||||
END ;
|
||||
x := z
|
||||
|
|
@ -935,10 +955,39 @@ MODULE OPB; (* RC 6.3.89 / 21.2.94 *) (* object model 17.1.93 *)
|
|||
PROCEDURE CheckAssign(x: OPT.Struct; ynode: OPT.Node); (* x := y *)
|
||||
VAR f, g: INTEGER; y, p, q: OPT.Struct;
|
||||
BEGIN
|
||||
IF OPM.Verbose THEN
|
||||
OPM.LogWLn; OPM.LogWStr("PROCEDURE CheckAssign"); OPM.LogWLn;
|
||||
END;
|
||||
y := ynode^.typ; f := x^.form; g := y^.form;
|
||||
IF OPM.Verbose THEN
|
||||
OPM.LogWStr("y.form = "); OPM.LogWNum(y.form, 0); OPM.LogWLn;
|
||||
OPM.LogWStr("f = "); OPM.LogWNum(f, 0); OPM.LogWLn;
|
||||
OPM.LogWStr("g = "); OPM.LogWNum(g, 0); OPM.LogWLn;
|
||||
OPM.LogWStr("ynode.typ.syze = "); OPM.LogWNum(ynode.typ.size, 0); OPM.LogWLn;
|
||||
END;
|
||||
IF (ynode^.class = Ntype) OR (ynode^.class = Nproc) & (f # ProcTyp) THEN err(126) END ;
|
||||
CASE f OF
|
||||
Undef, String:
|
||||
| Int8:
|
||||
IF (ynode.typ.size > OPM.Int8Size) THEN
|
||||
IF OPM.Verbose THEN OPM.LogWStr("f of int8"); OPM.LogWLn END;
|
||||
err(113)
|
||||
END
|
||||
| Int16:
|
||||
IF (ynode.typ.size > OPM.Int16Size) THEN
|
||||
IF OPM.Verbose THEN OPM.LogWStr("f of int16"); OPM.LogWLn END;
|
||||
err(113)
|
||||
END
|
||||
| Int32:
|
||||
IF (ynode.typ.size > OPM.Int32Size) THEN
|
||||
IF OPM.Verbose THEN OPM.LogWStr("f of int32"); OPM.LogWLn END;
|
||||
err(113)
|
||||
END
|
||||
| Int64:
|
||||
IF ynode.typ.size > OPM.Int64Size THEN
|
||||
IF OPM.Verbose THEN OPM.LogWStr("f of int64"); OPM.LogWLn END;
|
||||
err(113)
|
||||
END
|
||||
| Byte:
|
||||
IF ~(g IN {Byte, Char, SInt}) THEN err(113) END
|
||||
| Bool, Char, SInt, Set:
|
||||
|
|
@ -946,7 +995,11 @@ MODULE OPB; (* RC 6.3.89 / 21.2.94 *) (* object model 17.1.93 *)
|
|||
| Int:
|
||||
IF ~(g IN {SInt, Int}) THEN err(113) END
|
||||
| LInt:
|
||||
IF ~(g IN intSet) THEN err(113) END
|
||||
IF OPM.LIntSize = 4 THEN
|
||||
IF ~(g IN {SInt, Int, LInt, Int8, Int16, Int32}) THEN err(113) END
|
||||
ELSE (* assume OPM.LIntSize = 8 *)
|
||||
IF ~(g IN {SInt, Int, LInt, Int8, Int16, Int32, Int64}) THEN err(113) END
|
||||
END;
|
||||
| Real:
|
||||
IF ~(g IN {SInt..Real}) THEN err(113) END
|
||||
| LReal:
|
||||
|
|
@ -988,6 +1041,8 @@ MODULE OPB; (* RC 6.3.89 / 21.2.94 *) (* object model 17.1.93 *)
|
|||
END
|
||||
ELSE (*DynArr*) err(113)
|
||||
END
|
||||
ELSE (* In case of not estimated f it would crash -- noch *)
|
||||
OPM.WriteString("/* this should not happen. handle this. OPB.CheckAssign function -- noch */"); OPM.WriteLn;
|
||||
END ;
|
||||
IF (ynode^.class = Nconst) & (g < f) & (g IN {SInt..Real}) & (f IN {Int..LReal}) THEN
|
||||
Convert(ynode, x)
|
||||
|
|
@ -1059,6 +1114,10 @@ avoid unnecessary intermediate variables in voc
|
|||
| SInt: x := NewIntConst(OPM.MinSInt)
|
||||
| Int: x := NewIntConst(OPM.MinInt)
|
||||
| LInt: x := NewIntConst(OPM.MinLInt)
|
||||
| Int8: x := NewIntConst(OPM.MinInt8)
|
||||
| Int16: x := NewIntConst(OPM.MinInt16)
|
||||
| Int32: x := NewIntConst(OPM.MinInt32)
|
||||
| Int64: err(111)(*x := NewIntConst(OPM.MinInt64)*) (* int64 constants not implemented yet *)
|
||||
| Set: x := NewIntConst(0); x^.typ := OPT.inttyp
|
||||
| Real: x := NewRealConst(OPM.MinReal, OPT.realtyp)
|
||||
| LReal: x := NewRealConst(OPM.MinLReal, OPT.lrltyp)
|
||||
|
|
@ -1074,6 +1133,10 @@ avoid unnecessary intermediate variables in voc
|
|||
| SInt: x := NewIntConst(OPM.MaxSInt)
|
||||
| Int: x := NewIntConst(OPM.MaxInt)
|
||||
| LInt: x := NewIntConst(OPM.MaxLInt)
|
||||
| Int8: x := NewIntConst(OPM.MaxInt8)
|
||||
| Int16: x := NewIntConst(OPM.MaxInt16)
|
||||
| Int32: x := NewIntConst(OPM.MaxInt32)
|
||||
| Int64: err(111); (*x := NewIntConst(OPM.MaxInt64)*) (* int64 contstants not implemented yet *)
|
||||
| Set: x := NewIntConst(OPM.MaxSet); x^.typ := OPT.inttyp
|
||||
| Real: x := NewRealConst(OPM.MaxReal, OPT.realtyp)
|
||||
| LReal: x := NewRealConst(OPM.MaxLReal, OPT.lrltyp)
|
||||
|
|
@ -1083,13 +1146,16 @@ avoid unnecessary intermediate variables in voc
|
|||
END
|
||||
| chrfn: (*CHR*)
|
||||
IF (x^.class = Ntype) OR (x^.class = Nproc) THEN err(126)
|
||||
ELSIF f IN {Undef, SInt..LInt} THEN Convert(x, OPT.chartyp)
|
||||
ELSIF f IN {Undef, SInt..LInt, Int8..Int64} THEN Convert(x, OPT.chartyp)
|
||||
ELSE err(111); x^.typ := OPT.chartyp
|
||||
END
|
||||
| shortfn: (*SHORT*)
|
||||
IF (x^.class = Ntype) OR (x^.class = Nproc) THEN err(126)
|
||||
ELSIF f = Int THEN Convert(x, OPT.sinttyp)
|
||||
ELSIF f = LInt THEN Convert(x, OPT.inttyp)
|
||||
ELSIF f = Int64 THEN Convert(x, OPT.int32typ)
|
||||
ELSIF f = Int32 THEN Convert(x, OPT.int16typ)
|
||||
ELSIF f = Int16 THEN Convert(x, OPT.int8typ)
|
||||
ELSIF f = LReal THEN Convert(x, OPT.realtyp)
|
||||
ELSE err(111)
|
||||
END
|
||||
|
|
@ -1097,6 +1163,9 @@ avoid unnecessary intermediate variables in voc
|
|||
IF (x^.class = Ntype) OR (x^.class = Nproc) THEN err(126)
|
||||
ELSIF f = SInt THEN Convert(x, OPT.inttyp)
|
||||
ELSIF f = Int THEN Convert(x, OPT.linttyp)
|
||||
ELSIF f = Int8 THEN Convert(x, OPT.int16typ)
|
||||
ELSIF f = Int16 THEN Convert(x, OPT.int32typ)
|
||||
ELSIF f = Int32 THEN Convert(x, OPT.int64typ)
|
||||
ELSIF f = Real THEN Convert(x, OPT.lrltyp)
|
||||
ELSIF f = Char THEN Convert(x, OPT.linttyp)
|
||||
ELSE err(111)
|
||||
|
|
@ -1129,7 +1198,7 @@ avoid unnecessary intermediate variables in voc
|
|||
CheckLeaf(x, FALSE); MOp(adr, x)
|
||||
| sizefn: (*SIZE*)
|
||||
IF x^.class # Ntype THEN err(110); x := NewIntConst(1)
|
||||
ELSIF (f IN {Byte..Set, Pointer, ProcTyp}) OR (x^.typ^.comp IN {Array, Record}) THEN
|
||||
ELSIF (f IN {Byte..Set, Int8..Int64, Pointer, ProcTyp}) OR (x^.typ^.comp IN {Array, Record}) THEN
|
||||
typSize(x^.typ); x^.typ^.pvused := TRUE; x := NewIntConst(x^.typ^.size)
|
||||
ELSE err(111); x := NewIntConst(1)
|
||||
END
|
||||
|
|
@ -1137,7 +1206,7 @@ avoid unnecessary intermediate variables in voc
|
|||
MOp(cc, x)
|
||||
| lshfn, rotfn: (*SYSTEM.LSH, SYSTEM.ROT*)
|
||||
IF (x^.class = Ntype) OR (x^.class = Nproc) THEN err(126)
|
||||
ELSIF ~(f IN intSet + {Byte, Char, Set}) THEN err(111)
|
||||
ELSIF ~(f IN intSet + {Byte, Char, Set, Int8, Int16, Int32, Int64}) THEN err(111)
|
||||
END
|
||||
| getfn, putfn, bitfn, movefn: (*SYSTEM.GET, SYSTEM.PUT, SYSTEM.BIT, SYSTEM.MOVE*)
|
||||
IF (x^.class = Ntype) OR (x^.class = Nproc) THEN err(126)
|
||||
|
|
@ -1164,6 +1233,8 @@ avoid unnecessary intermediate variables in voc
|
|||
ELSIF f # Bool THEN err(120); x := NewBoolConst(FALSE)
|
||||
ELSE MOp(not, x)
|
||||
END
|
||||
ELSE
|
||||
OPM.WriteString("/* this should not happen, needs to be handled. procedure StPar0; -- noch */"); OPM.WriteLn;
|
||||
END ;
|
||||
par0 := x
|
||||
END StPar0;
|
||||
|
|
@ -1393,7 +1464,7 @@ avoid unnecessary intermediate variables in voc
|
|||
BEGIN (* ftyp^.comp = DynArr *)
|
||||
f := atyp^.comp; ftyp := ftyp^.BaseTyp; atyp := atyp^.BaseTyp;
|
||||
IF fvarpar & (ftyp = OPT.bytetyp) THEN (* ok, but ... *)
|
||||
IF ~(f IN {Array, DynArr}) OR ~(atyp^.form IN {Byte..SInt}) THEN err(-301) END (* ... warning 301 *)
|
||||
IF ~(f IN {Array, DynArr}) OR ~(atyp^.form IN {Byte..SInt, Int8..Int64}) THEN err(-301) END (* ... warning 301 *)
|
||||
ELSIF f IN {Array, DynArr} THEN
|
||||
IF ftyp^.comp = DynArr THEN DynArrParCheck(ftyp, atyp, fvarpar)
|
||||
ELSIF ftyp # atyp THEN
|
||||
|
|
|
|||
|
|
@ -11,9 +11,16 @@ MODULE OPC; (* copyright (c) J. Templ 12.7.95 / 3.7.96 *)
|
|||
|
||||
CONST
|
||||
(* structure forms *)
|
||||
Byte = 1; Bool = 2; Char = 3; SInt = 4; Int = 5; LInt = 6;
|
||||
Byte = 1; Bool = 2; Char = 3;
|
||||
SInt = 4; Int = 5; LInt = 6;
|
||||
(*Int8 = 7; Int16 = 8; Int32 = 9; Int64 = 10;
|
||||
Real = 11; LReal = 12; Set = 13; String = 14; NilTyp = 15; NoTyp = 16;
|
||||
Pointer = 17; ProcTyp = 18;
|
||||
Comp = 19;*)
|
||||
Real = 7; LReal = 8; Set = 9; String = 10; NilTyp = 11; NoTyp = 12;
|
||||
Pointer = 13; ProcTyp = 14; Comp = 15;
|
||||
Pointer = 13; ProcTyp = 14;
|
||||
Int8 = 16; Int16 = 17; Int32 = 18; Int64 = 19;
|
||||
Comp = (*15*)20;
|
||||
|
||||
(* composite structure forms *)
|
||||
Array = 2; DynArr = 3; Record = 4;
|
||||
|
|
@ -170,8 +177,9 @@ MODULE OPC; (* copyright (c) J. Templ 12.7.95 / 3.7.96 *)
|
|||
ELSE OPM.WriteStringVar(OPM.modName)
|
||||
END ;
|
||||
OPM.Write(Underscore)
|
||||
ELSIF (obj = OPT.sysptrtyp^.strobj) OR (obj = OPT.bytetyp^.strobj) THEN
|
||||
ELSIF (obj = OPT.sysptrtyp^.strobj) OR (obj = OPT.bytetyp^.strobj) OR (obj = OPT.int8typ^.strobj) OR (obj = OPT.int16typ^.strobj) OR (obj = OPT.int32typ^.strobj) OR (obj = OPT.int64typ^.strobj) THEN
|
||||
OPM.WriteString("SYSTEM_")
|
||||
|
||||
END ;
|
||||
OPM.WriteStringVar(obj^.name)
|
||||
END
|
||||
|
|
@ -614,6 +622,10 @@ MODULE OPC; (* copyright (c) J. Templ 12.7.95 / 3.7.96 *)
|
|||
| SInt: RETURN OPM.SIntAlign
|
||||
| Int: RETURN OPM.IntAlign
|
||||
| LInt: RETURN OPM.LIntAlign
|
||||
| Int8: RETURN OPM.Int8Align
|
||||
| Int16: RETURN OPM.Int16Align
|
||||
| Int32: RETURN OPM.Int32Align
|
||||
| Int64: RETURN OPM.Int64Align
|
||||
| Real: RETURN OPM.RealAlign
|
||||
| LReal: RETURN OPM.LRealAlign
|
||||
| Set: RETURN OPM.SetAlign
|
||||
|
|
@ -857,6 +869,7 @@ MODULE OPC; (* copyright (c) J. Templ 12.7.95 / 3.7.96 *)
|
|||
| OPM.mainlinkstat: OPM.Write("M")
|
||||
| OPM.notcoloroutput: OPM.Write("f")
|
||||
| OPM.forcenewsym: OPM.Write("F")
|
||||
| OPM.verbose: OPM.Write("v")
|
||||
ELSE
|
||||
(* this else is necessary cause
|
||||
if someone defined a new option in OPM module
|
||||
|
|
@ -1283,6 +1296,9 @@ MODULE OPC; (* copyright (c) J. Templ 12.7.95 / 3.7.96 *)
|
|||
END
|
||||
| SInt, Int, LInt:
|
||||
OPM.WriteInt(con^.intval)
|
||||
| Int8, Int16, Int32, Int64:
|
||||
OPM.WriteInt(con^.intval)
|
||||
|
||||
| Real:
|
||||
OPM.WriteReal(con^.realval, "f")
|
||||
| LReal:
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
|
|||
mainlinkstat* = 15; (* generate code for main module and then link object file statically *)
|
||||
notcoloroutput* = 16; (* turn off color output *)
|
||||
forcenewsym* = 17; (* force new symbol file *)
|
||||
verbose* = 18; (* verbose *)
|
||||
defopt* = {inxchk, typchk, ptrinit, ansi, assert}; (* default options *)
|
||||
|
||||
nilval* = 0;
|
||||
|
|
@ -96,10 +97,14 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
|
|||
SourceFileName : ARRAY 256 OF CHAR;
|
||||
ByteSize*, CharSize*, BoolSize*, SIntSize*, IntSize*,
|
||||
LIntSize*, SetSize*, RealSize*, LRealSize*, PointerSize*, ProcSize*, RecSize*,
|
||||
Int8Size*, Int16Size*, Int32Size*, Int64Size*, (* these are constants actually, we need it to pass to GetProperty function; -- noch *)
|
||||
CharAlign*, BoolAlign*, SIntAlign*, IntAlign*,
|
||||
Int8Align*, Int16Align*, Int32Align*, Int64Align*, (* need this for SYSTEM types; -- noch *)
|
||||
LIntAlign*, SetAlign*, RealAlign*, LRealAlign*, PointerAlign*, ProcAlign*, RecAlign*,
|
||||
ByteOrder*, BitOrder*, MaxSet*: INTEGER;
|
||||
MinSInt*, MinInt*, MinLInt*, MaxSInt*, MaxInt*, MaxLInt*, MaxIndex*: LONGINT;
|
||||
MinInt8*, MaxInt8*, MinInt16*, MaxInt16*, MinInt32*, MaxInt32* : LONGINT;
|
||||
MinInt64*, MaxInt64* : SYSTEM.INT64;
|
||||
MinReal*, MaxReal*, MinLReal*, MaxLReal*: LONGREAL;
|
||||
|
||||
noerr*: BOOLEAN;
|
||||
|
|
@ -122,7 +127,7 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
|
|||
oldSFile, newSFile, HFile, BFile, HIFile: Files.File;
|
||||
|
||||
S: INTEGER;
|
||||
stop, useLineNo, useParFile, dontAsm-, dontLink-, mainProg-, mainLinkStat-, notColorOutput-, forceNewSym-: BOOLEAN;
|
||||
stop, useLineNo, useParFile, dontAsm-, dontLink-, mainProg-, mainLinkStat-, notColorOutput-, forceNewSym-, Verbose-: BOOLEAN;
|
||||
|
||||
|
||||
(* ------------------------- Log Output ------------------------- *)
|
||||
|
|
@ -170,6 +175,7 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
|
|||
| "M": opt := opt / {mainlinkstat}
|
||||
| "f": opt := opt / {notcoloroutput}
|
||||
| "F": opt := opt / {forcenewsym}
|
||||
| "V": opt := opt / {verbose}
|
||||
ELSE LogWStr(" warning: option "); LogW(OptionChar); LogW(s[i]); LogWStr(" ignored"); LogWLn
|
||||
END ;
|
||||
INC(i)
|
||||
|
|
@ -192,7 +198,7 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
|
|||
Console.Ln;
|
||||
Console.String(' command = "voc" options {file options}.'); Console.Ln;
|
||||
Console.String(' options = ["-" {option} ].'); Console.Ln;
|
||||
Console.String(' option = "m" | "M" | "s" | "e" | "i" | "l" | "k" | "r" | "x" | "a" | "p" | "t" | "P" | "S" | "c" | "f" | "F" .'); Console.Ln;
|
||||
Console.String(' option = "m" | "M" | "s" | "e" | "i" | "l" | "k" | "r" | "x" | "a" | "p" | "t" | "P" | "S" | "c" | "f" | "F" | "V" .'); Console.Ln;
|
||||
Console.Ln;
|
||||
Console.String(" m - generate code for main module"); Console.Ln;
|
||||
Console.String(" M - generate code for main module and link object statically"); Console.Ln;
|
||||
|
|
@ -210,6 +216,7 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
|
|||
Console.String(" c - don't call linker"); Console.Ln;
|
||||
Console.String(" f - don't use color output"); Console.Ln;
|
||||
Console.String(" F - force writing new symbol file"); Console.Ln;
|
||||
Console.String(" V - verbose output"); Console.Ln;
|
||||
Console.Ln;
|
||||
ELSE
|
||||
glbopt := defopt; S := 1; s := "";
|
||||
|
|
@ -228,6 +235,7 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
|
|||
IF mainlinkstat IN glbopt THEN INCL(glbopt, mainprog); mainLinkStat := TRUE ELSE mainLinkStat := FALSE END;
|
||||
IF notcoloroutput IN glbopt THEN notColorOutput := TRUE ELSE notColorOutput := FALSE END;
|
||||
IF forcenewsym IN glbopt THEN forceNewSym := TRUE ELSE forceNewSym := FALSE END;
|
||||
IF verbose IN glbopt THEN Verbose := TRUE ELSE Verbose := FALSE END;
|
||||
GetProperties; (* GetProperties moved here in order to call it after ScanOptions because we have an option whether to use par file or not, noch *)
|
||||
|
||||
END;
|
||||
|
|
@ -248,6 +256,7 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
|
|||
IF mainprog IN opt THEN mainProg := TRUE ELSE mainProg := FALSE END;
|
||||
IF mainlinkstat IN opt THEN INCL(glbopt, mainprog); mainLinkStat := TRUE ELSE mainLinkStat := FALSE END;
|
||||
IF forcenewsym IN glbopt THEN forceNewSym := TRUE ELSE forceNewSym := FALSE END;
|
||||
IF verbose IN glbopt THEN Verbose := TRUE ELSE Verbose := FALSE END;
|
||||
END InitOptions;
|
||||
|
||||
PROCEDURE Init*(VAR done: BOOLEAN; VAR mname : ARRAY OF CHAR); (* get the source for one translation *)
|
||||
|
|
@ -588,6 +597,41 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
|
|||
RETURN p;
|
||||
END power0;
|
||||
|
||||
PROCEDURE VerboseListSizes;
|
||||
BEGIN
|
||||
Console.String("Type Size Alignement"); Console.Ln;
|
||||
Console.String("CHAR "); Console.Int(CharSize, 0); Console.Int(CharAlign, 5); Console.Ln;
|
||||
Console.String("BOOLEAN "); Console.Int(BoolSize, 0); Console.Int(BoolAlign, 5); Console.Ln;
|
||||
Console.String("SHORTINT "); Console.Int(SIntSize, 0); Console.Int(SIntAlign, 5); Console.Ln;
|
||||
Console.String("INTEGER "); Console.Int(IntSize, 0); Console.Int(IntAlign, 5); Console.Ln;
|
||||
Console.String("LONGINT "); Console.Int(LIntSize, 0); Console.Int(LIntAlign, 5); Console.Ln;
|
||||
Console.String("SET "); Console.Int(SetSize, 0); Console.Int(SetAlign, 5); Console.Ln;
|
||||
Console.String("REAL "); Console.Int(RealSize, 0); Console.Int(RealAlign, 5); Console.Ln;
|
||||
Console.String("LONGREAL "); Console.Int(LRealSize, 0); Console.Int(LRealAlign, 5); Console.Ln;
|
||||
Console.String("PTR "); Console.Int(PointerSize, 0); Console.Int(PointerAlign, 5); Console.Ln;
|
||||
Console.String("PROC "); Console.Int(ProcSize, 0); Console.Int(ProcAlign, 5); Console.Ln;
|
||||
Console.String("RECORD "); Console.Int(RecSize, 0); Console.Int(RecAlign, 5); Console.Ln;
|
||||
Console.String("ENDIAN "); Console.Int(ByteOrder, 0); Console.Int(BitOrder, 5); Console.Ln;
|
||||
Console.String("SYSTEM.INT8 "); Console.Int(Int8Size, 0); Console.Int(Int8Align, 5); Console.Ln;
|
||||
Console.String("SYSTEM.INT16 "); Console.Int(Int16Size, 0); Console.Int(Int16Align, 5); Console.Ln;
|
||||
Console.String("SYSTEM.INT32 "); Console.Int(Int32Size, 0); Console.Int(Int32Align, 5); Console.Ln;
|
||||
Console.String("SYSTEM.INT64 "); Console.Int(Int64Size, 0); Console.Int(Int64Align, 5); Console.Ln;
|
||||
Console.Ln;
|
||||
Console.String("Min shortint "); Console.Int(MinSInt, 0); Console.Ln;
|
||||
Console.String("Max shortint "); Console.Int(MaxSInt, 0); Console.Ln;
|
||||
Console.String("Min integer "); Console.Int(MinInt, 0); Console.Ln;
|
||||
Console.String("Max integer "); Console.Int(MaxInt, 0); Console.Ln;
|
||||
Console.String("Min longint "); Console.Int(MinLInt, 0); Console.Ln;
|
||||
Console.String("Max longint "); Console.Int(MaxLInt, 0); Console.Ln;
|
||||
Console.String("Min int8 "); Console.Int(MinInt8, 0); Console.Ln;
|
||||
Console.String("Max int8 "); Console.Int(MaxInt8, 0); Console.Ln;
|
||||
Console.String("Min int16 "); Console.Int(MinInt16, 0); Console.Ln;
|
||||
Console.String("Max int16 "); Console.Int(MaxInt16, 0); Console.Ln;
|
||||
Console.String("Min int32 "); Console.Int(MinInt32, 0); Console.Ln;
|
||||
Console.String("Max int32 "); Console.Int(MaxInt32, 0); Console.Ln;
|
||||
|
||||
|
||||
END VerboseListSizes;
|
||||
|
||||
PROCEDURE GetProperties();
|
||||
VAR T: Texts.Text; S: Texts.Scanner;
|
||||
|
|
@ -601,6 +645,7 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
|
|||
ByteSize := 1; CharSize := 1; BoolSize := 1; SIntSize := 1; IntSize := 4; LIntSize := 8;
|
||||
SetSize := 8; RealSize := 4; LRealSize := 8; ProcSize := 8; PointerSize := 8; RecSize := 1;
|
||||
CharAlign := 1; BoolAlign := 1; SIntAlign := 1; IntAlign := 4; LIntAlign := 8;
|
||||
Int8Align := 1; Int16Align := 2; Int32Align := 4; Int64Align := 8;
|
||||
SetAlign := 8; RealAlign := 4; LRealAlign := 8; ProcAlign := 8; PointerAlign := 8; RecAlign := 1;
|
||||
(* not necessary, we will calculate values later
|
||||
MinSInt := -80H; MaxSInt := 7FH;
|
||||
|
|
@ -617,6 +662,7 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
|
|||
ByteSize := 1; CharSize := 1; BoolSize := 1; SIntSize := 1; IntSize := 2; LIntSize := 4;
|
||||
SetSize := 4; RealSize := 4; LRealSize := 8; ProcSize := 4; PointerSize := 4; RecSize := 1;
|
||||
CharAlign := 1; BoolAlign := 1; SIntAlign := 1; IntAlign := 2; LIntAlign := 4;
|
||||
Int8Align := 1; Int16Align := 2; Int32Align := 4; Int64Align := 4;
|
||||
SetAlign := 4; RealAlign := 4; LRealAlign := 8; ProcAlign := 4; PointerAlign := 4; RecAlign := 1;
|
||||
|
||||
(* not necessary, we will calculate values later
|
||||
|
|
@ -630,6 +676,8 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
|
|||
ByteSize := 1; CharSize := 1; BoolSize := 1; SIntSize := 1; IntSize := 2; LIntSize := 4;
|
||||
SetSize := 4; RealSize := 4; LRealSize := 8; ProcSize := 4; PointerSize := 4; RecSize := 1;
|
||||
CharAlign := 1; BoolAlign := 1; SIntAlign := 1; IntAlign := 2; LIntAlign := 4;
|
||||
|
||||
Int8Align := 1; Int16Align := 2; Int32Align := 4; Int64Align := 4;
|
||||
SetAlign := 4; RealAlign := 4; LRealAlign := 8; ProcAlign := 4; PointerAlign := 4; RecAlign := 1;
|
||||
|
||||
|
||||
|
|
@ -638,6 +686,8 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
|
|||
ByteSize := 1; CharSize := 1; BoolSize := 1; SIntSize := 1; IntSize := 2; LIntSize := 4;
|
||||
SetSize := 4; RealSize := 4; LRealSize := 8; ProcSize := 4; PointerSize := 4; RecSize := 1;
|
||||
CharAlign := 1; BoolAlign := 1; SIntAlign := 1; IntAlign := 2; LIntAlign := 4;
|
||||
|
||||
Int8Align := 1; Int16Align := 2; Int32Align := 4; Int64Align := 4;
|
||||
SetAlign := 4; RealAlign := 4; LRealAlign := 4; ProcAlign := 4; PointerAlign := 4; RecAlign := 1;
|
||||
|
||||
ELSE (* this should suite any gnu x86 system *)
|
||||
|
|
@ -645,6 +695,8 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
|
|||
ByteSize := 1; CharSize := 1; BoolSize := 1; SIntSize := 1; IntSize := 2; LIntSize := 4;
|
||||
SetSize := 4; RealSize := 4; LRealSize := 8; ProcSize := 4; PointerSize := 4; RecSize := 1;
|
||||
CharAlign := 1; BoolAlign := 1; SIntAlign := 1; IntAlign := 2; LIntAlign := 4;
|
||||
|
||||
Int8Align := 1; Int16Align := 2; Int32Align := 4; Int64Align := 4;
|
||||
SetAlign := 4; RealAlign := 4; LRealAlign := 4; ProcAlign := 4; PointerAlign := 4; RecAlign := 1;
|
||||
(* LRealAlign should be checked and confirmed *)
|
||||
(* not necessary, will be calculated later
|
||||
|
|
@ -658,7 +710,7 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
|
|||
(* read voc.par *)
|
||||
|
||||
IF useParFile THEN (* noch *)
|
||||
Console.String ("loading type sizes from voc.par"); Console.Ln;
|
||||
IF Verbose THEN Console.String ("loading type sizes from voc.par"); Console.Ln; END;
|
||||
NEW(T); Texts.Open(T, "voc.par");
|
||||
IF T.len # 0 THEN
|
||||
Texts.OpenScanner(S, T, 0); Texts.Scan(S);
|
||||
|
|
@ -677,13 +729,24 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
|
|||
Size = 1; size and alignment follows from field types but at least RecAlign; e.g, SPARC, MIPS, PowerPC
|
||||
*)
|
||||
GetProperty(S, "ENDIAN", ByteOrder, BitOrder); (*currently not used*)
|
||||
|
||||
GetProperty(S, "SYSTEM.INT8", Int8Size, Int8Align);
|
||||
GetProperty(S, "SYSTEM.INT16", Int16Size, Int16Align);
|
||||
GetProperty(S, "SYSTEM.INT32", Int32Size, Int32Align);
|
||||
GetProperty(S, "SYSTEM.INT64", Int64Size, Int64Align);
|
||||
(* add here Max and Min sizes, noch *)
|
||||
ByteSize := CharSize;
|
||||
|
||||
ELSE Mark(-156, -1)
|
||||
END ;
|
||||
ELSE Console.String ("not using voc.par file"); Console.Ln;
|
||||
ELSE
|
||||
IF Verbose THEN
|
||||
Console.String ("not using voc.par file"); Console.Ln
|
||||
END
|
||||
END; (* if useParFile , noch *)
|
||||
|
||||
Int8Size := 1; Int16Size := 2; Int32Size := 4; Int64Size := 8;
|
||||
|
||||
(* commenting this by replacing with faster way; -- noch *
|
||||
MinSInt := power0(-2, (SIntSize*8-1)); (* -2^(SIntSize*8-1)*)
|
||||
(*MaxSInt := -(MinSint + 1);; may be optimized?*)
|
||||
|
|
@ -708,15 +771,11 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
|
|||
MinLInt := ASH(base, LIntSize*8-2);
|
||||
MaxLInt := minus(MinLInt +1);
|
||||
|
||||
(*
|
||||
Console.Int(MinSInt, 0); Console.Ln;
|
||||
Console.Int(MaxSInt, 0); Console.Ln;
|
||||
Console.Int(MinInt, 0); Console.Ln;
|
||||
Console.Int(MaxInt, 0); Console.Ln;
|
||||
Console.Int(MinLInt, 0); Console.Ln;
|
||||
Console.Int(MaxLInt, 0); Console.Ln;
|
||||
*)
|
||||
MinInt8 := -80H; MinInt16 := -8000H; MinInt32 := 80000000H; (*-2147483648*)
|
||||
MaxInt8 := 7FH; MaxInt16 := 7FFFH; MaxInt32 := 7FFFFFFFH; (*2147483647*)
|
||||
|
||||
MinInt64 := ASH(base, Int64Size*8-2);
|
||||
MaxInt64 := minus(ASH(base, Int64Size*8-2) + 1);
|
||||
|
||||
IF RealSize = 4 THEN MaxReal := 3.40282346D38
|
||||
ELSIF RealSize = 8 THEN MaxReal := 1.7976931348623157D307 * 9.999999
|
||||
|
|
@ -733,6 +792,10 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
|
|||
(*IF IntSize = 4 THEN MinLInt := MinInt; MaxLInt := MaxInt END ;*)
|
||||
MaxSet := SetSize * 8 - 1;
|
||||
MaxIndex := MaxLInt; (* shouldn't it be like max(int)? so that for loop will be safe, noch *)
|
||||
IF Verbose THEN
|
||||
VerboseListSizes
|
||||
END;
|
||||
|
||||
|
||||
END GetProperties;
|
||||
|
||||
|
|
|
|||
|
|
@ -27,10 +27,18 @@ MODULE OPP; (* NW, RC 6.3.89 / 10.2.94 *) (* object model 4.12.93 *)
|
|||
SProc = 8; CProc = 9; IProc = 10; Mod = 11; Head = 12; TProc = 13;
|
||||
|
||||
(* Structure forms *)
|
||||
Undef = 0; Byte = 1; Bool = 2; Char = 3; SInt = 4; Int = 5; LInt = 6;
|
||||
Undef = 0; Byte = 1; Bool = 2; Char = 3;
|
||||
SInt = 4; Int = 5; LInt = 6;
|
||||
(*Int8 = 7; Int16 = 8; Int32 = 9; Int64 = 10;
|
||||
Real = 11; LReal = 12; Set = 13; String = 14; NilTyp = 15; NoTyp = 16;
|
||||
Pointer = 17; ProcTyp = 18;
|
||||
Comp = 19;*)
|
||||
Real = 7; LReal = 8; Set = 9; String = 10; NilTyp = 11; NoTyp = 12;
|
||||
Pointer = 13; ProcTyp = 14; Comp = 15;
|
||||
intSet = {SInt..LInt};
|
||||
Pointer = 13; ProcTyp = 14;
|
||||
Int8 = 16; Int16 = 17; Int32 = 18; Int64 = 19;
|
||||
Comp = (*15*)20;
|
||||
|
||||
intSet = {SInt..LInt, Int8..Int64};
|
||||
|
||||
(* composite structure forms *)
|
||||
Basic = 1; Array = 2; DynArr = 3; Record = 4;
|
||||
|
|
@ -281,7 +289,7 @@ MODULE OPP; (* NW, RC 6.3.89 / 10.2.94 *) (* object model 4.12.93 *)
|
|||
OPS.Get(sym); resTyp := OPT.undftyp;
|
||||
IF sym = ident THEN qualident(res);
|
||||
IF res^.mode = Typ THEN
|
||||
IF res^.typ^.form < Comp THEN resTyp := res^.typ
|
||||
IF (res^.typ^.form < Comp) OR (res^.typ^.form >= Int8) & (res^.typ^.form <= Int64) THEN resTyp := res^.typ;
|
||||
ELSE err(54)
|
||||
END
|
||||
ELSE err(52)
|
||||
|
|
|
|||
1128
src/voc/OPT.Mod
1128
src/voc/OPT.Mod
File diff suppressed because it is too large
Load diff
|
|
@ -22,8 +22,15 @@ MODULE OPV; (* J. Templ 16.2.95 / 3.7.96
|
|||
adr = 24; cc = 25; bit = 26; lsh = 27; rot = 28; val = 29;
|
||||
|
||||
(* structure forms *)
|
||||
Byte = 1; Bool = 2; Char = 3; SInt = 4; Int = 5; LInt = 6;
|
||||
Real = 7; LReal = 8; Set = 9; String = 10; NilTyp = 11; Pointer = 13; ProcTyp = 14; Comp = 15;
|
||||
Byte = 1; Bool = 2; Char = 3;
|
||||
SInt = 4; Int = 5; LInt = 6;
|
||||
(*Int8 = 7; Int16 = 8; Int32 = 9; Int64 = 10;
|
||||
Real = 11; LReal = 12; Set = 13; String = 14; NilTyp = 15; NoTyp = 16;
|
||||
Pointer = 17; ProcTyp = 18;
|
||||
Comp = 19;*)
|
||||
Real = 7; LReal = 8; Set = 9; String = 10; NilTyp = 11; Pointer = 13; ProcTyp = 14;
|
||||
Int8 = 16; Int16 = 17; Int32 = 18; Int64 = 19;
|
||||
Comp = (*15*)20;
|
||||
|
||||
(* composite structure forms *)
|
||||
Array = 2; DynArr = 3; Record = 4;
|
||||
|
|
@ -249,6 +256,10 @@ MODULE OPV; (* J. Templ 16.2.95 / 3.7.96
|
|||
OPT.sinttyp^.strobj^.linkadr := PredefinedType;
|
||||
OPT.booltyp^.strobj^.linkadr := PredefinedType;
|
||||
OPT.bytetyp^.strobj^.linkadr := PredefinedType;
|
||||
OPT.int8typ^.strobj^.linkadr := PredefinedType;
|
||||
OPT.int16typ^.strobj^.linkadr := PredefinedType;
|
||||
OPT.int32typ^.strobj^.linkadr := PredefinedType;
|
||||
OPT.int64typ^.strobj^.linkadr := PredefinedType;
|
||||
OPT.sysptrtyp^.strobj^.linkadr := PredefinedType;
|
||||
END AdrAndSize;
|
||||
|
||||
|
|
@ -336,6 +347,9 @@ MODULE OPV; (* J. Templ 16.2.95 / 3.7.96
|
|||
ELSIF form = LInt THEN
|
||||
IF from < LInt THEN OPM.WriteString("(LONGINT)") END ;
|
||||
Entier(n, 9)
|
||||
ELSIF form = Int64 THEN
|
||||
IF (from >= SInt) & (from <= LInt) OR (from >= Int8) & (from < Int64) THEN OPM.WriteString("(SYSTEM_INT64)") END;
|
||||
Entier(n, 9);
|
||||
ELSIF form = Int THEN
|
||||
IF from < Int THEN OPM.WriteString("(int)"); expr(n, 9)
|
||||
ELSE
|
||||
|
|
@ -509,10 +523,12 @@ MODULE OPV; (* J. Templ 16.2.95 / 3.7.96
|
|||
OPM.WriteString("(void*)") (* type extension *)
|
||||
END
|
||||
ELSE
|
||||
IF (form IN {Real, LReal}) & (n^.typ^.form IN {SInt, Int, LInt}) THEN (* real promotion *)
|
||||
IF (form IN {Real, LReal}) & (n^.typ^.form IN {SInt, Int, LInt, Int8, Int16, Int32, Int64}) THEN (* real promotion *)
|
||||
OPM.WriteString("(double)"); prec := 9
|
||||
ELSIF (form = LInt) & (n^.typ^.form < LInt) THEN (* integral promotion *)
|
||||
OPM.WriteString("(LONGINT)"); prec := 9
|
||||
ELSIF (form = Int64) & (n^.typ^.form < Int64) THEN
|
||||
OPM.WriteString("(SYSTEM_INT64)"); prec := 9;
|
||||
END
|
||||
END
|
||||
ELSIF ansi THEN
|
||||
|
|
@ -708,7 +724,7 @@ MODULE OPV; (* J. Templ 16.2.95 / 3.7.96
|
|||
| slash:
|
||||
IF form = Set THEN OPM.WriteString(" ^ ")
|
||||
ELSE OPM.WriteString(" / ");
|
||||
IF (r^.obj = NIL) OR (r^.obj^.typ^.form IN {SInt, Int, LInt}) THEN
|
||||
IF (r^.obj = NIL) OR (r^.obj^.typ^.form IN {SInt, Int, LInt, Int8, Int16, Int32, Int64}) THEN
|
||||
OPM.Write(OpenParen); OPC.Ident(n^.typ^.strobj); OPM.Write(CloseParen)
|
||||
END
|
||||
END
|
||||
|
|
|
|||
|
|
@ -80,6 +80,10 @@ VAR mname : ARRAY 256 OF CHAR; (* noch *)
|
|||
modulesobj := "";
|
||||
OPM.OpenPar; (* gclock(); slightly faste rtranslation but may lead to opening "too many files" *)
|
||||
OPT.bytetyp.size := OPM.ByteSize;
|
||||
OPT.int8typ.size := 1;
|
||||
OPT.int16typ.size := 2;
|
||||
OPT.int32typ.size := 4;
|
||||
OPT.int64typ.size := 8;
|
||||
OPT.sysptrtyp.size := OPM.PointerSize;
|
||||
OPT.chartyp.size := OPM.CharSize;
|
||||
OPT.settyp.size := OPM.SetSize;
|
||||
|
|
|
|||
BIN
voc
BIN
voc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue