Fix import of SYSTEM.INT64 on 32 bit builds.

This commit is contained in:
David Brown 2016-09-18 10:55:14 +01:00
parent 21964471d8
commit 636c128d14
198 changed files with 823 additions and 573 deletions

View file

@ -160,18 +160,18 @@ VAR
realtyp*, lrltyp*, settyp*, stringtyp*,
niltyp*, notyp*, sysptrtyp*: Struct;
sintobj*, intobj*, lintobj*: Object;
nofGmod*: SHORTINT; (*nof imports*)
GlbMod*: ARRAY maxImps OF Object; (* ^.right = first object, ^.name = module import name (not alias) *)
SelfName*: OPS.Name; (* name of module being compiled *)
SYSimported*: BOOLEAN;
IntTypes: ARRAY 20 OF Struct; (* Lists integer types in SHORT/LONG ordering *)
CONST
(* Symbol file items *)
Smname* = 16; Send* = 18; Stype* = 19; Salias* = 20; Svar* = 21;
Srvar* = 22; Svalpar* = 23; Svarpar* = 24; Sfld* = 25; Srfld* = 26;
@ -209,34 +209,36 @@ VAR
PROCEDURE err(n: INTEGER);
BEGIN OPM.err(n)
END err;
PROCEDURE err(n: INTEGER); BEGIN OPM.err(n) END err;
PROCEDURE IntType*(size: LONGINT): Struct;
(* Selects smallest standard integer type for given size in bytes *)
VAR i: INTEGER;
BEGIN
i := 1; WHILE i < LEN(IntTypes) - 1 DO (* First and last entries are always NIL *)
IF (IntTypes[i] # NIL) & (IntTypes[i].size >= size) THEN RETURN IntTypes[i] END;
INC(i)
END;
IF size <= int8typ.size THEN RETURN int8typ END;
IF size <= int16typ.size THEN RETURN int16typ END;
IF size <= int32typ.size THEN RETURN int32typ END;
RETURN int64typ
END IntType;
PROCEDURE ShorterOrLongerType*(x: Struct; dir: INTEGER): Struct;
VAR i: INTEGER;
BEGIN
ASSERT(x.form = Int);
ASSERT((dir = 1) OR (dir = -1));
(* Not sure if StPar0 (which calls this) always gets the baseiest type. This
ASSERT will tell me. *)
ASSERT(x.BaseTyp = undftyp);
(*
WHILE x.BaseTyp # undftyp DO ASSERT(x # x.BaseTyp); ASSERT(x.BaseTyp # NIL); x := x.BaseTyp END;
*)
i := 0; WHILE (IntTypes[i] # x) & (i < LEN(IntTypes)) DO INC(i) END;
ASSERT(i < LEN(IntTypes)-1);
RETURN IntTypes[i+dir]
ASSERT((dir = 1) OR (dir = -1));
IF dir > 0 THEN
IF x.size < sinttyp.size THEN RETURN sinttyp END;
IF x.size < inttyp.size THEN RETURN inttyp END;
IF x.size < linttyp.size THEN RETURN linttyp END;
RETURN int64typ
ELSE
IF x.size > linttyp.size THEN RETURN linttyp END;
IF x.size > inttyp.size THEN RETURN inttyp END;
IF x.size > sinttyp.size THEN RETURN sinttyp END;
RETURN int8typ
END
END ShorterOrLongerType;
@ -1175,12 +1177,21 @@ END Import;
typ^.idfp := form; typ^.idfpdone := TRUE; res := typ
END EnterTyp;
PROCEDURE EnterTypeAlias(name: OPS.Name; VAR res: Object);
VAR obj: Object;
BEGIN
Insert(name, obj); obj^.mode := Typ; obj^.typ := NIL; obj^.vis := external;
res := obj
END EnterTypeAlias;
PROCEDURE EnterProc(name: OPS.Name; num: INTEGER);
VAR obj: Object;
BEGIN Insert(name, obj);
obj^.mode := SProc; obj^.typ := notyp; obj^.adr := num
END EnterProc;
BEGIN topScope := NIL; OpenScope(0, NIL); OPM.errpos := 0;
InitStruct(undftyp, Undef); undftyp^.BaseTyp := undftyp;
InitStruct(notyp, NoTyp);
@ -1195,6 +1206,7 @@ BEGIN topScope := NIL; OpenScope(0, NIL); OPM.errpos := 0;
EnterTyp("INT16", Int, 2, int16typ);
EnterTyp("INT32", Int, 4, int32typ);
EnterTyp("INT64", Int, 8, int64typ);
EnterProc("ADR", adrfn);
EnterProc("CC", ccfn);
EnterProc("LSH", lshfn);
@ -1207,17 +1219,20 @@ BEGIN topScope := NIL; OpenScope(0, NIL); OPM.errpos := 0;
EnterProc("VAL", valfn);
EnterProc("NEW", sysnewfn);
EnterProc("MOVE", movefn);
syslink := topScope^.right;
universe := topScope; topScope^.right := NIL;
EnterTyp("BOOLEAN", Bool, OPM.BoolSize, booltyp);
EnterTyp("CHAR", Char, OPM.CharSize, chartyp);
EnterTyp("SET", Set, OPM.SetSize, settyp);
EnterTyp("REAL", Real, OPM.RealSize, realtyp);
EnterTyp("INTEGER", Int, OPM.IntSize, inttyp);
EnterTyp("LONGINT", Int, OPM.LIntSize, linttyp);
EnterTyp("LONGREAL", LReal, OPM.LRealSize, lrltyp);
EnterTyp("SHORTINT", Int, OPM.SIntSize, sinttyp);
EnterTypeAlias("SHORTINT", sintobj);
EnterTypeAlias("INTEGER", intobj);
EnterTypeAlias("LONGINT", lintobj);
EnterBoolConst("FALSE", 0); (* 0 and 1 are compiler internal representation only *)
EnterBoolConst("TRUE", 1);
@ -1248,7 +1263,7 @@ BEGIN topScope := NIL; OpenScope(0, NIL); OPM.errpos := 0;
impCtxt.ref[Byte] := bytetyp;
impCtxt.ref[Bool] := booltyp;
impCtxt.ref[Char] := chartyp;
impCtxt.ref[Int] := inttyp;
impCtxt.ref[Int] := int32typ;
impCtxt.ref[Real] := realtyp;
impCtxt.ref[LReal] := lrltyp;
impCtxt.ref[Set] := settyp;
@ -1257,15 +1272,6 @@ BEGIN topScope := NIL; OpenScope(0, NIL); OPM.errpos := 0;
impCtxt.ref[NoTyp] := notyp;
impCtxt.ref[Pointer] := sysptrtyp;
IntTypes[1] := sinttyp;
IntTypes[2] := inttyp;
IntTypes[3] := linttyp;
IntTypes[5] := int8typ;
IntTypes[6] := int16typ;
IntTypes[7] := int32typ;
IntTypes[8] := int64typ
END OPT.
Objects:

View file

@ -181,6 +181,8 @@ MODULE OPV; (* J. Templ 16.2.95 / 3.7.96
PROCEDURE AdrAndSize* (topScope: OPT.Object);
BEGIN
ASSERT(OPT.sinttyp # NIL); ASSERT(OPT.inttyp # NIL); ASSERT(OPT.linttyp # NIL);
OPM.errpos := topScope^.adr; (* text position of scope used if error *)
topScope^.leaf := TRUE;
Traverse(topScope^.right, topScope, TRUE); (* first pass only on exported types and procedures *)
@ -189,15 +191,18 @@ MODULE OPV; (* J. Templ 16.2.95 / 3.7.96
OPT.chartyp^.strobj^.linkadr := PredefinedType;
OPT.settyp^.strobj^.linkadr := PredefinedType;
OPT.realtyp^.strobj^.linkadr := PredefinedType;
(* SHORTINT, INTEGER and LONGINT are alternate names for INT8, INT16, INT32 and INT64 and have not been set up yet.
OPT.sinttyp^.strobj^.linkadr := PredefinedType;
OPT.inttyp^.strobj^.linkadr := PredefinedType;
OPT.linttyp^.strobj^.linkadr := PredefinedType;
*)
OPT.adrtyp^.strobj^.linkadr := PredefinedType;
OPT.int8typ^.strobj^.linkadr := PredefinedType;
OPT.int16typ^.strobj^.linkadr := PredefinedType;
OPT.int32typ^.strobj^.linkadr := PredefinedType;
OPT.int64typ^.strobj^.linkadr := PredefinedType;
OPT.lrltyp^.strobj^.linkadr := PredefinedType;
OPT.sinttyp^.strobj^.linkadr := PredefinedType;
OPT.booltyp^.strobj^.linkadr := PredefinedType;
OPT.bytetyp^.strobj^.linkadr := PredefinedType;
OPT.sysptrtyp^.strobj^.linkadr := PredefinedType;

View file

@ -56,12 +56,21 @@ MODULE Vishap; (* J. Templ 3.2.95 *)
OPT.chartyp.size := OPM.CharSize;
OPT.settyp.size := OPM.SetSize;
OPT.realtyp.size := OPM.RealSize;
OPT.inttyp.size := OPM.IntSize;
OPT.linttyp.size := OPM.LIntSize;
OPT.adrtyp.size := OPM.PointerSize;
OPT.lrltyp.size := OPM.LRealSize;
OPT.sinttyp.size := OPM.SIntSize;
OPT.booltyp.size := OPM.BoolSize
OPT.booltyp.size := OPM.BoolSize;
OPT.sinttyp := OPT.int8typ;
IF OPM.IntSize = 2 THEN
OPT.inttyp := OPT.int16typ;
OPT.linttyp := OPT.int32typ
ELSE
OPT.inttyp := OPT.int32typ;
OPT.linttyp := OPT.int64typ
END;
OPT.sintobj.typ := OPT.sinttyp;
OPT.intobj.typ := OPT.inttyp;
OPT.lintobj.typ := OPT.linttyp
END PropagateElementaryTypeSizes;