Fix import of SYSTEM.INT64 type on 32 bit platforms.

This commit is contained in:
David Brown 2016-09-15 17:39:30 +01:00
parent dc699db9f5
commit 21964471d8
13 changed files with 53 additions and 36 deletions

View file

@ -17,7 +17,7 @@ typedef
export OPS_Name OPS_name; export OPS_Name OPS_name;
export OPS_String OPS_str; export OPS_String OPS_str;
export int16 OPS_numtyp; export int16 OPS_numtyp;
export int64 OPS_intval; export int32 OPS_intval;
export REAL OPS_realval; export REAL OPS_realval;
export LONGREAL OPS_lrlval; export LONGREAL OPS_lrlval;
static CHAR OPS_ch; static CHAR OPS_ch;
@ -178,7 +178,7 @@ static void OPS_Number (void)
OPS_numtyp = 1; OPS_numtyp = 1;
if (n <= 2) { if (n <= 2) {
while (i < n) { 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; i += 1;
} }
} else { } else {
@ -192,7 +192,7 @@ static void OPS_Number (void)
OPS_intval = -1; OPS_intval = -1;
} }
while (i < n) { 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; i += 1;
} }
} else { } else {
@ -203,8 +203,8 @@ static void OPS_Number (void)
while (i < n) { while (i < n) {
d = Ord__7(dig[i], 0); d = Ord__7(dig[i], 0);
i += 1; i += 1;
if (OPS_intval <= (int64)__DIV(9223372036854775807 - d, 10)) { if ((int64)OPS_intval <= __DIV(9223372036854775807 - (int64)d, 10)) {
OPS_intval = OPS_intval * 10 + (int64)d; OPS_intval = OPS_intval * 10 + d;
} else { } else {
OPS_err(203); OPS_err(203);
} }

View file

@ -15,7 +15,7 @@ typedef
import OPS_Name OPS_name; import OPS_Name OPS_name;
import OPS_String OPS_str; import OPS_String OPS_str;
import int16 OPS_numtyp; import int16 OPS_numtyp;
import int64 OPS_intval; import int32 OPS_intval;
import REAL OPS_realval; import REAL OPS_realval;
import LONGREAL OPS_lrlval; import LONGREAL OPS_lrlval;

View file

@ -167,12 +167,15 @@ OPT_Struct OPT_IntType (int32 size)
OPT_Struct _o_result; OPT_Struct _o_result;
int16 i; int16 i;
i = 1; i = 1;
while ((OPT_IntTypes[__X(i, 20)]->size < size && OPT_IntTypes[__X(i + 1, 20)] != NIL)) { while (i < 19) {
i += 1; if ((OPT_IntTypes[__X(i, 20)] != NIL && OPT_IntTypes[__X(i, 20)]->size >= size)) {
}
_o_result = OPT_IntTypes[__X(i, 20)]; _o_result = OPT_IntTypes[__X(i, 20)];
return _o_result; return _o_result;
} }
i += 1;
}
__RETCHK;
}
OPT_Struct OPT_ShorterOrLongerType (OPT_Struct x, int16 dir) OPT_Struct OPT_ShorterOrLongerType (OPT_Struct x, int16 dir)
{ {

View file

@ -17,7 +17,7 @@ typedef
export OPS_Name OPS_name; export OPS_Name OPS_name;
export OPS_String OPS_str; export OPS_String OPS_str;
export int16 OPS_numtyp; export int16 OPS_numtyp;
export int64 OPS_intval; export int32 OPS_intval;
export REAL OPS_realval; export REAL OPS_realval;
export LONGREAL OPS_lrlval; export LONGREAL OPS_lrlval;
static CHAR OPS_ch; static CHAR OPS_ch;
@ -178,7 +178,7 @@ static void OPS_Number (void)
OPS_numtyp = 1; OPS_numtyp = 1;
if (n <= 2) { if (n <= 2) {
while (i < n) { 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; i += 1;
} }
} else { } else {
@ -192,7 +192,7 @@ static void OPS_Number (void)
OPS_intval = -1; OPS_intval = -1;
} }
while (i < n) { 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; i += 1;
} }
} else { } else {
@ -203,8 +203,8 @@ static void OPS_Number (void)
while (i < n) { while (i < n) {
d = Ord__7(dig[i], 0); d = Ord__7(dig[i], 0);
i += 1; i += 1;
if (OPS_intval <= (int64)__DIV(9223372036854775807 - d, 10)) { if ((int64)OPS_intval <= __DIV(9223372036854775807 - (int64)d, 10)) {
OPS_intval = OPS_intval * 10 + (int64)d; OPS_intval = OPS_intval * 10 + d;
} else { } else {
OPS_err(203); OPS_err(203);
} }

View file

@ -15,7 +15,7 @@ typedef
import OPS_Name OPS_name; import OPS_Name OPS_name;
import OPS_String OPS_str; import OPS_String OPS_str;
import int16 OPS_numtyp; import int16 OPS_numtyp;
import int64 OPS_intval; import int32 OPS_intval;
import REAL OPS_realval; import REAL OPS_realval;
import LONGREAL OPS_lrlval; import LONGREAL OPS_lrlval;

View file

@ -167,12 +167,15 @@ OPT_Struct OPT_IntType (int32 size)
OPT_Struct _o_result; OPT_Struct _o_result;
int16 i; int16 i;
i = 1; i = 1;
while ((OPT_IntTypes[__X(i, 20)]->size < size && OPT_IntTypes[__X(i + 1, 20)] != NIL)) { while (i < 19) {
i += 1; if ((OPT_IntTypes[__X(i, 20)] != NIL && OPT_IntTypes[__X(i, 20)]->size >= size)) {
}
_o_result = OPT_IntTypes[__X(i, 20)]; _o_result = OPT_IntTypes[__X(i, 20)];
return _o_result; return _o_result;
} }
i += 1;
}
__RETCHK;
}
OPT_Struct OPT_ShorterOrLongerType (OPT_Struct x, int16 dir) OPT_Struct OPT_ShorterOrLongerType (OPT_Struct x, int16 dir)
{ {

View file

@ -167,12 +167,15 @@ OPT_Struct OPT_IntType (int64 size)
OPT_Struct _o_result; OPT_Struct _o_result;
int32 i; int32 i;
i = 1; i = 1;
while ((OPT_IntTypes[__X(i, 20)]->size < size && OPT_IntTypes[__X(i + 1, 20)] != NIL)) { while (i < 19) {
i += 1; if ((OPT_IntTypes[__X(i, 20)] != NIL && OPT_IntTypes[__X(i, 20)]->size >= size)) {
}
_o_result = OPT_IntTypes[__X(i, 20)]; _o_result = OPT_IntTypes[__X(i, 20)];
return _o_result; return _o_result;
} }
i += 1;
}
__RETCHK;
}
OPT_Struct OPT_ShorterOrLongerType (OPT_Struct x, int32 dir) OPT_Struct OPT_ShorterOrLongerType (OPT_Struct x, int32 dir)
{ {

View file

@ -17,7 +17,7 @@ typedef
export OPS_Name OPS_name; export OPS_Name OPS_name;
export OPS_String OPS_str; export OPS_String OPS_str;
export int16 OPS_numtyp; export int16 OPS_numtyp;
export int64 OPS_intval; export int32 OPS_intval;
export REAL OPS_realval; export REAL OPS_realval;
export LONGREAL OPS_lrlval; export LONGREAL OPS_lrlval;
static CHAR OPS_ch; static CHAR OPS_ch;
@ -178,7 +178,7 @@ static void OPS_Number (void)
OPS_numtyp = 1; OPS_numtyp = 1;
if (n <= 2) { if (n <= 2) {
while (i < n) { 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; i += 1;
} }
} else { } else {
@ -192,7 +192,7 @@ static void OPS_Number (void)
OPS_intval = -1; OPS_intval = -1;
} }
while (i < n) { 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; i += 1;
} }
} else { } else {
@ -203,8 +203,8 @@ static void OPS_Number (void)
while (i < n) { while (i < n) {
d = Ord__7(dig[i], 0); d = Ord__7(dig[i], 0);
i += 1; i += 1;
if (OPS_intval <= (int64)__DIV(9223372036854775807 - d, 10)) { if ((int64)OPS_intval <= __DIV(9223372036854775807 - (int64)d, 10)) {
OPS_intval = OPS_intval * 10 + (int64)d; OPS_intval = OPS_intval * 10 + d;
} else { } else {
OPS_err(203); OPS_err(203);
} }

View file

@ -15,7 +15,7 @@ typedef
import OPS_Name OPS_name; import OPS_Name OPS_name;
import OPS_String OPS_str; import OPS_String OPS_str;
import int16 OPS_numtyp; import int16 OPS_numtyp;
import int64 OPS_intval; import int32 OPS_intval;
import REAL OPS_realval; import REAL OPS_realval;
import LONGREAL OPS_lrlval; import LONGREAL OPS_lrlval;

View file

@ -167,12 +167,15 @@ OPT_Struct OPT_IntType (int32 size)
OPT_Struct _o_result; OPT_Struct _o_result;
int16 i; int16 i;
i = 1; i = 1;
while ((OPT_IntTypes[__X(i, 20)]->size < size && OPT_IntTypes[__X(i + 1, 20)] != NIL)) { while (i < 19) {
i += 1; if ((OPT_IntTypes[__X(i, 20)] != NIL && OPT_IntTypes[__X(i, 20)]->size >= size)) {
}
_o_result = OPT_IntTypes[__X(i, 20)]; _o_result = OPT_IntTypes[__X(i, 20)];
return _o_result; return _o_result;
} }
i += 1;
}
__RETCHK;
}
OPT_Struct OPT_ShorterOrLongerType (OPT_Struct x, int16 dir) OPT_Struct OPT_ShorterOrLongerType (OPT_Struct x, int16 dir)
{ {

View file

@ -167,12 +167,15 @@ OPT_Struct OPT_IntType (int64 size)
OPT_Struct _o_result; OPT_Struct _o_result;
int32 i; int32 i;
i = 1; i = 1;
while ((OPT_IntTypes[__X(i, 20)]->size < size && OPT_IntTypes[__X(i + 1, 20)] != NIL)) { while (i < 19) {
i += 1; if ((OPT_IntTypes[__X(i, 20)] != NIL && OPT_IntTypes[__X(i, 20)]->size >= size)) {
}
_o_result = OPT_IntTypes[__X(i, 20)]; _o_result = OPT_IntTypes[__X(i, 20)];
return _o_result; return _o_result;
} }
i += 1;
}
__RETCHK;
}
OPT_Struct OPT_ShorterOrLongerType (OPT_Struct x, int32 dir) OPT_Struct OPT_ShorterOrLongerType (OPT_Struct x, int32 dir)
{ {

View file

@ -52,7 +52,7 @@ MODULE OPS; (* NW, RC 6.3.89 / 18.10.92 *) (* object model 3.6.92 *)
name*: Name; name*: Name;
str*: String; str*: String;
numtyp*: INTEGER; (* 1 = char, 2 = integer, 3 = real, 4 = longreal *) 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; realval*: REAL;
lrlval*: LONGREAL; lrlval*: LONGREAL;

View file

@ -217,8 +217,10 @@ PROCEDURE IntType*(size: LONGINT): Struct;
(* Selects smallest standard integer type for given size in bytes *) (* Selects smallest standard integer type for given size in bytes *)
VAR i: INTEGER; VAR i: INTEGER;
BEGIN BEGIN
i := 1; WHILE (IntTypes[i].size < size) & (IntTypes[i+1] # NIL) DO INC(i) END; i := 1; WHILE i < LEN(IntTypes) - 1 DO (* First and last entries are always NIL *)
RETURN IntTypes[i]; IF (IntTypes[i] # NIL) & (IntTypes[i].size >= size) THEN RETURN IntTypes[i] END;
INC(i)
END;
END IntType; END IntType;
PROCEDURE ShorterOrLongerType*(x: Struct; dir: INTEGER): Struct; PROCEDURE ShorterOrLongerType*(x: Struct; dir: INTEGER): Struct;