mirror of
https://github.com/vishapoberon/compiler.git
synced 2026-04-06 04:02:25 +00:00
Better set constant checking.
This commit is contained in:
parent
d344c9ce80
commit
c924a33a05
4 changed files with 9 additions and 9 deletions
|
|
@ -830,13 +830,14 @@ MODULE OPB; (* RC 6.3.89 / 21.2.94 *) (* object model 17.1.93 *)
|
|||
ELSIF x^.typ^.form # OPT.Int THEN err(93)
|
||||
ELSIF x^.class = OPT.Nconst THEN
|
||||
k := x^.conval^.intval;
|
||||
IF (0 <= k) & (k <= MAX(SYSTEM.SET64)) THEN x^.conval^.setval := {k}; SetSetType(x)
|
||||
IF (0 <= k) & (k <= MAX(SYSTEM.SET64)) THEN
|
||||
x^.conval^.setval := {}; INCL(x.conval.setval, k);
|
||||
ELSE err(202)
|
||||
END ;
|
||||
x^.obj := NIL
|
||||
ELSE Convert(x, OPT.settyp) (* todo choose appropriate set type ? *)
|
||||
END;
|
||||
SetSetType(x); x^.obj := NIL
|
||||
ELSE
|
||||
Convert(x, OPT.settyp); x^.typ := OPT.settyp
|
||||
END;
|
||||
x^.typ := OPT.settyp (* todo choose appropriate set type ? *)
|
||||
END SetElem;
|
||||
|
||||
PROCEDURE CheckAssign(x: OPT.Struct; ynode: OPT.Node); (* x := y *)
|
||||
|
|
@ -994,7 +995,7 @@ MODULE OPB; (* RC 6.3.89 / 21.2.94 *) (* object model 17.1.93 *)
|
|||
OPT.Bool: x := NewBoolConst(TRUE)
|
||||
| OPT.Char: x := NewIntConst(0FFH); x^.typ := OPT.chartyp
|
||||
| OPT.Int: x := NewIntConst(OPM.SignedMaximum(x.typ.size))
|
||||
| OPT.Set: x := NewIntConst(OPM.MaxSet); x^.typ := OPT.inttyp
|
||||
| OPT.Set: x := NewIntConst(x.typ.size*8-1); x^.typ := OPT.inttyp
|
||||
| OPT.Real: x := NewRealConst(OPM.MaxReal, OPT.realtyp)
|
||||
| OPT.LReal: x := NewRealConst(OPM.MaxLReal, OPT.lrltyp)
|
||||
ELSE err(111)
|
||||
|
|
|
|||
|
|
@ -1228,7 +1228,7 @@ MODULE OPC; (* copyright (c) J. Templ 12.7.95 / 3.7.96 *)
|
|||
|
||||
PROCEDURE Constant* (con: OPT.Const; form: INTEGER);
|
||||
VAR i: INTEGER; s: SYSTEM.SET64;
|
||||
hex: LONGINT; skipLeading: BOOLEAN;
|
||||
hex: SYSTEM.INT64; skipLeading: BOOLEAN;
|
||||
BEGIN
|
||||
CASE form OF
|
||||
| OPT.Byte: OPM.WriteInt(con^.intval)
|
||||
|
|
|
|||
|
|
@ -93,7 +93,6 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
|
|||
|
||||
ShortintSize*, IntegerSize*, LongintSize*, SetSize*: INTEGER;
|
||||
|
||||
MaxSet*: INTEGER;
|
||||
MaxIndex*: SYSTEM.INT64;
|
||||
|
||||
MinReal*, MaxReal*, MinLReal*, MaxLReal*: LONGREAL;
|
||||
|
|
@ -344,7 +343,6 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
|
|||
|'V': ShortintSize := 1; IntegerSize := 4; LongintSize := 8; SetSize := 8
|
||||
ELSE ShortintSize := 1; IntegerSize := 2; LongintSize := 4; SetSize := 4
|
||||
END;
|
||||
MaxSet := SetSize * 8 - 1;
|
||||
|
||||
IF verbose IN Options THEN VerboseListSizes END;
|
||||
|
||||
|
|
|
|||
|
|
@ -229,6 +229,7 @@ static inline double SYSTEM_ABSD(double i) {return i >= 0.0 ? i : -i;}
|
|||
#define __ODD(x) ((x)&1)
|
||||
|
||||
#define __IN(x, s, size) (((unsigned int)(x))<size && ((((uint##size)(s))>>(x))&1))
|
||||
// todo tested versions of SETOF and SETRNG: check that x, l and h fit size
|
||||
#define __SETOF(x, size) ((uint##size)1<<(x))
|
||||
#define __SETRNG(l, h, size) ((~(uint##size)0<<(l))&~(uint##size)0>>(size-1-(h)))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue