diff --git a/bootstrap/unix-44/OPS.c b/bootstrap/unix-44/OPS.c index 5243ea65..29ea2414 100644 --- a/bootstrap/unix-44/OPS.c +++ b/bootstrap/unix-44/OPS.c @@ -17,7 +17,7 @@ typedef export OPS_Name OPS_name; export OPS_String OPS_str; export int16 OPS_numtyp; -export int64 OPS_intval; +export int32 OPS_intval; export REAL OPS_realval; export LONGREAL OPS_lrlval; static CHAR OPS_ch; @@ -178,7 +178,7 @@ static void OPS_Number (void) OPS_numtyp = 1; if (n <= 2) { while (i < n) { - OPS_intval = __ASHL(OPS_intval, 4) + (int64)Ord__7(dig[i], 1); + OPS_intval = __ASHL(OPS_intval, 4) + Ord__7(dig[i], 1); i += 1; } } else { @@ -192,7 +192,7 @@ static void OPS_Number (void) OPS_intval = -1; } while (i < n) { - OPS_intval = __ASHL(OPS_intval, 4) + (int64)Ord__7(dig[i], 1); + OPS_intval = __ASHL(OPS_intval, 4) + Ord__7(dig[i], 1); i += 1; } } else { @@ -203,8 +203,8 @@ static void OPS_Number (void) while (i < n) { d = Ord__7(dig[i], 0); i += 1; - if (OPS_intval <= (int64)__DIV(9223372036854775807 - d, 10)) { - OPS_intval = OPS_intval * 10 + (int64)d; + if ((int64)OPS_intval <= __DIV(9223372036854775807 - (int64)d, 10)) { + OPS_intval = OPS_intval * 10 + d; } else { OPS_err(203); } diff --git a/bootstrap/unix-44/OPS.h b/bootstrap/unix-44/OPS.h index af53d634..57cf06d3 100644 --- a/bootstrap/unix-44/OPS.h +++ b/bootstrap/unix-44/OPS.h @@ -15,7 +15,7 @@ typedef import OPS_Name OPS_name; import OPS_String OPS_str; import int16 OPS_numtyp; -import int64 OPS_intval; +import int32 OPS_intval; import REAL OPS_realval; import LONGREAL OPS_lrlval; diff --git a/bootstrap/unix-44/OPT.c b/bootstrap/unix-44/OPT.c index a12c1a7f..62ff8882 100644 --- a/bootstrap/unix-44/OPT.c +++ b/bootstrap/unix-44/OPT.c @@ -167,11 +167,14 @@ OPT_Struct OPT_IntType (int32 size) OPT_Struct _o_result; int16 i; i = 1; - while ((OPT_IntTypes[__X(i, 20)]->size < size && OPT_IntTypes[__X(i + 1, 20)] != NIL)) { + while (i < 19) { + if ((OPT_IntTypes[__X(i, 20)] != NIL && OPT_IntTypes[__X(i, 20)]->size >= size)) { + _o_result = OPT_IntTypes[__X(i, 20)]; + return _o_result; + } i += 1; } - _o_result = OPT_IntTypes[__X(i, 20)]; - return _o_result; + __RETCHK; } OPT_Struct OPT_ShorterOrLongerType (OPT_Struct x, int16 dir) diff --git a/bootstrap/unix-48/OPS.c b/bootstrap/unix-48/OPS.c index 5243ea65..29ea2414 100644 --- a/bootstrap/unix-48/OPS.c +++ b/bootstrap/unix-48/OPS.c @@ -17,7 +17,7 @@ typedef export OPS_Name OPS_name; export OPS_String OPS_str; export int16 OPS_numtyp; -export int64 OPS_intval; +export int32 OPS_intval; export REAL OPS_realval; export LONGREAL OPS_lrlval; static CHAR OPS_ch; @@ -178,7 +178,7 @@ static void OPS_Number (void) OPS_numtyp = 1; if (n <= 2) { while (i < n) { - OPS_intval = __ASHL(OPS_intval, 4) + (int64)Ord__7(dig[i], 1); + OPS_intval = __ASHL(OPS_intval, 4) + Ord__7(dig[i], 1); i += 1; } } else { @@ -192,7 +192,7 @@ static void OPS_Number (void) OPS_intval = -1; } while (i < n) { - OPS_intval = __ASHL(OPS_intval, 4) + (int64)Ord__7(dig[i], 1); + OPS_intval = __ASHL(OPS_intval, 4) + Ord__7(dig[i], 1); i += 1; } } else { @@ -203,8 +203,8 @@ static void OPS_Number (void) while (i < n) { d = Ord__7(dig[i], 0); i += 1; - if (OPS_intval <= (int64)__DIV(9223372036854775807 - d, 10)) { - OPS_intval = OPS_intval * 10 + (int64)d; + if ((int64)OPS_intval <= __DIV(9223372036854775807 - (int64)d, 10)) { + OPS_intval = OPS_intval * 10 + d; } else { OPS_err(203); } diff --git a/bootstrap/unix-48/OPS.h b/bootstrap/unix-48/OPS.h index af53d634..57cf06d3 100644 --- a/bootstrap/unix-48/OPS.h +++ b/bootstrap/unix-48/OPS.h @@ -15,7 +15,7 @@ typedef import OPS_Name OPS_name; import OPS_String OPS_str; import int16 OPS_numtyp; -import int64 OPS_intval; +import int32 OPS_intval; import REAL OPS_realval; import LONGREAL OPS_lrlval; diff --git a/bootstrap/unix-48/OPT.c b/bootstrap/unix-48/OPT.c index a12c1a7f..62ff8882 100644 --- a/bootstrap/unix-48/OPT.c +++ b/bootstrap/unix-48/OPT.c @@ -167,11 +167,14 @@ OPT_Struct OPT_IntType (int32 size) OPT_Struct _o_result; int16 i; i = 1; - while ((OPT_IntTypes[__X(i, 20)]->size < size && OPT_IntTypes[__X(i + 1, 20)] != NIL)) { + while (i < 19) { + if ((OPT_IntTypes[__X(i, 20)] != NIL && OPT_IntTypes[__X(i, 20)]->size >= size)) { + _o_result = OPT_IntTypes[__X(i, 20)]; + return _o_result; + } i += 1; } - _o_result = OPT_IntTypes[__X(i, 20)]; - return _o_result; + __RETCHK; } OPT_Struct OPT_ShorterOrLongerType (OPT_Struct x, int16 dir) diff --git a/bootstrap/unix-88/OPT.c b/bootstrap/unix-88/OPT.c index 82c2df59..d9b211df 100644 --- a/bootstrap/unix-88/OPT.c +++ b/bootstrap/unix-88/OPT.c @@ -167,11 +167,14 @@ OPT_Struct OPT_IntType (int64 size) OPT_Struct _o_result; int32 i; i = 1; - while ((OPT_IntTypes[__X(i, 20)]->size < size && OPT_IntTypes[__X(i + 1, 20)] != NIL)) { + while (i < 19) { + if ((OPT_IntTypes[__X(i, 20)] != NIL && OPT_IntTypes[__X(i, 20)]->size >= size)) { + _o_result = OPT_IntTypes[__X(i, 20)]; + return _o_result; + } i += 1; } - _o_result = OPT_IntTypes[__X(i, 20)]; - return _o_result; + __RETCHK; } OPT_Struct OPT_ShorterOrLongerType (OPT_Struct x, int32 dir) diff --git a/bootstrap/windows-48/OPS.c b/bootstrap/windows-48/OPS.c index 5243ea65..29ea2414 100644 --- a/bootstrap/windows-48/OPS.c +++ b/bootstrap/windows-48/OPS.c @@ -17,7 +17,7 @@ typedef export OPS_Name OPS_name; export OPS_String OPS_str; export int16 OPS_numtyp; -export int64 OPS_intval; +export int32 OPS_intval; export REAL OPS_realval; export LONGREAL OPS_lrlval; static CHAR OPS_ch; @@ -178,7 +178,7 @@ static void OPS_Number (void) OPS_numtyp = 1; if (n <= 2) { while (i < n) { - OPS_intval = __ASHL(OPS_intval, 4) + (int64)Ord__7(dig[i], 1); + OPS_intval = __ASHL(OPS_intval, 4) + Ord__7(dig[i], 1); i += 1; } } else { @@ -192,7 +192,7 @@ static void OPS_Number (void) OPS_intval = -1; } while (i < n) { - OPS_intval = __ASHL(OPS_intval, 4) + (int64)Ord__7(dig[i], 1); + OPS_intval = __ASHL(OPS_intval, 4) + Ord__7(dig[i], 1); i += 1; } } else { @@ -203,8 +203,8 @@ static void OPS_Number (void) while (i < n) { d = Ord__7(dig[i], 0); i += 1; - if (OPS_intval <= (int64)__DIV(9223372036854775807 - d, 10)) { - OPS_intval = OPS_intval * 10 + (int64)d; + if ((int64)OPS_intval <= __DIV(9223372036854775807 - (int64)d, 10)) { + OPS_intval = OPS_intval * 10 + d; } else { OPS_err(203); } diff --git a/bootstrap/windows-48/OPS.h b/bootstrap/windows-48/OPS.h index af53d634..57cf06d3 100644 --- a/bootstrap/windows-48/OPS.h +++ b/bootstrap/windows-48/OPS.h @@ -15,7 +15,7 @@ typedef import OPS_Name OPS_name; import OPS_String OPS_str; import int16 OPS_numtyp; -import int64 OPS_intval; +import int32 OPS_intval; import REAL OPS_realval; import LONGREAL OPS_lrlval; diff --git a/bootstrap/windows-48/OPT.c b/bootstrap/windows-48/OPT.c index a12c1a7f..62ff8882 100644 --- a/bootstrap/windows-48/OPT.c +++ b/bootstrap/windows-48/OPT.c @@ -167,11 +167,14 @@ OPT_Struct OPT_IntType (int32 size) OPT_Struct _o_result; int16 i; i = 1; - while ((OPT_IntTypes[__X(i, 20)]->size < size && OPT_IntTypes[__X(i + 1, 20)] != NIL)) { + while (i < 19) { + if ((OPT_IntTypes[__X(i, 20)] != NIL && OPT_IntTypes[__X(i, 20)]->size >= size)) { + _o_result = OPT_IntTypes[__X(i, 20)]; + return _o_result; + } i += 1; } - _o_result = OPT_IntTypes[__X(i, 20)]; - return _o_result; + __RETCHK; } OPT_Struct OPT_ShorterOrLongerType (OPT_Struct x, int16 dir) diff --git a/bootstrap/windows-88/OPT.c b/bootstrap/windows-88/OPT.c index 82c2df59..d9b211df 100644 --- a/bootstrap/windows-88/OPT.c +++ b/bootstrap/windows-88/OPT.c @@ -167,11 +167,14 @@ OPT_Struct OPT_IntType (int64 size) OPT_Struct _o_result; int32 i; i = 1; - while ((OPT_IntTypes[__X(i, 20)]->size < size && OPT_IntTypes[__X(i + 1, 20)] != NIL)) { + while (i < 19) { + if ((OPT_IntTypes[__X(i, 20)] != NIL && OPT_IntTypes[__X(i, 20)]->size >= size)) { + _o_result = OPT_IntTypes[__X(i, 20)]; + return _o_result; + } i += 1; } - _o_result = OPT_IntTypes[__X(i, 20)]; - return _o_result; + __RETCHK; } OPT_Struct OPT_ShorterOrLongerType (OPT_Struct x, int32 dir) diff --git a/src/compiler/OPS.Mod b/src/compiler/OPS.Mod index 909cdee2..e386e538 100644 --- a/src/compiler/OPS.Mod +++ b/src/compiler/OPS.Mod @@ -52,7 +52,7 @@ MODULE OPS; (* NW, RC 6.3.89 / 18.10.92 *) (* object model 3.6.92 *) name*: Name; str*: String; numtyp*: INTEGER; (* 1 = char, 2 = integer, 3 = real, 4 = longreal *) - intval*: SYSTEM.INT64; (* integer value or string length *) + intval*: LONGINT (* todo SYSTEM.INT64 *); (* integer value or string length *) realval*: REAL; lrlval*: LONGREAL; diff --git a/src/compiler/OPT.Mod b/src/compiler/OPT.Mod index 8b21b9a5..cd1eae8b 100644 --- a/src/compiler/OPT.Mod +++ b/src/compiler/OPT.Mod @@ -217,8 +217,10 @@ PROCEDURE IntType*(size: LONGINT): Struct; (* Selects smallest standard integer type for given size in bytes *) VAR i: INTEGER; BEGIN - i := 1; WHILE (IntTypes[i].size < size) & (IntTypes[i+1] # NIL) DO INC(i) END; - RETURN IntTypes[i]; + 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; END IntType; PROCEDURE ShorterOrLongerType*(x: Struct; dir: INTEGER): Struct;