diff --git a/bootstrap/unix-44/Console.c b/bootstrap/unix-44/Console.c index 168abb08..10d0a39b 100644 --- a/bootstrap/unix-44/Console.c +++ b/bootstrap/unix-44/Console.c @@ -16,7 +16,7 @@ export void Console_Bool (BOOLEAN b); export void Console_Char (CHAR ch); export void Console_Flush (void); export void Console_Hex (int32 i); -export void Console_Int (int32 i, int32 n); +export void Console_Int (int64 i, int64 n); export void Console_Ln (void); export void Console_Read (CHAR *ch); export void Console_ReadLine (CHAR *line, LONGINT line__len); @@ -54,15 +54,15 @@ void Console_String (CHAR *s, LONGINT s__len) __DEL(s); } -void Console_Int (int32 i, int32 n) +void Console_Int (int64 i, int64 n) { CHAR s[32]; int32 i1, k; - if (i == __LSHL(1, 31, 32)) { + if (i == (int64)__LSHL(1, 31, 32)) { __MOVE("8463847412", s, 11); k = 10; } else { - i1 = __ABS(i); + i1 = __ABS(__VAL(int32, i)); s[0] = (CHAR)((int)__MOD(i1, 10) + 48); i1 = __DIV(i1, 10); k = 1; @@ -76,7 +76,7 @@ void Console_Int (int32 i, int32 n) s[__X(k, 32)] = '-'; k += 1; } - while (n > k) { + while (n > (int64)k) { Console_Char(' '); n -= 1; } diff --git a/bootstrap/unix-44/Console.h b/bootstrap/unix-44/Console.h index cca2c91e..e5dc1566 100644 --- a/bootstrap/unix-44/Console.h +++ b/bootstrap/unix-44/Console.h @@ -12,7 +12,7 @@ import void Console_Bool (BOOLEAN b); import void Console_Char (CHAR ch); import void Console_Flush (void); import void Console_Hex (int32 i); -import void Console_Int (int32 i, int32 n); +import void Console_Int (int64 i, int64 n); import void Console_Ln (void); import void Console_Read (CHAR *ch); import void Console_ReadLine (CHAR *line, LONGINT line__len); diff --git a/bootstrap/unix-44/Files.c b/bootstrap/unix-44/Files.c index a37ffdd3..6c934210 100644 --- a/bootstrap/unix-44/Files.c +++ b/bootstrap/unix-44/Files.c @@ -90,6 +90,7 @@ export void Files_ReadLInt (Files_Rider *R, LONGINT *R__typ, int32 *x); export void Files_ReadLReal (Files_Rider *R, LONGINT *R__typ, LONGREAL *x); export void Files_ReadLine (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len); export void Files_ReadNum (Files_Rider *R, LONGINT *R__typ, int32 *x); +export void Files_ReadNum64 (Files_Rider *R, LONGINT *R__typ, int64 *x); export void Files_ReadReal (Files_Rider *R, LONGINT *R__typ, REAL *x); export void Files_ReadSet (Files_Rider *R, LONGINT *R__typ, SET *x); export void Files_ReadString (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len); @@ -105,6 +106,7 @@ export void Files_WriteInt (Files_Rider *R, LONGINT *R__typ, int16 x); export void Files_WriteLInt (Files_Rider *R, LONGINT *R__typ, int32 x); export void Files_WriteLReal (Files_Rider *R, LONGINT *R__typ, LONGREAL x); export void Files_WriteNum (Files_Rider *R, LONGINT *R__typ, int32 x); +export void Files_WriteNum64 (Files_Rider *R, LONGINT *R__typ, int64 x); export void Files_WriteReal (Files_Rider *R, LONGINT *R__typ, REAL x); export void Files_WriteSet (Files_Rider *R, LONGINT *R__typ, SET x); export void Files_WriteString (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len); @@ -936,6 +938,13 @@ void Files_ReadNum (Files_Rider *R, LONGINT *R__typ, int32 *x) *x = n; } +void Files_ReadNum64 (Files_Rider *R, LONGINT *R__typ, int64 *x) +{ + int32 n; + Files_ReadNum(&*R, R__typ, &n); + *x = n; +} + void Files_WriteBool (Files_Rider *R, LONGINT *R__typ, BOOLEAN x) { Files_Write(&*R, R__typ, __VAL(CHAR, x)); @@ -1004,6 +1013,15 @@ void Files_WriteNum (Files_Rider *R, LONGINT *R__typ, int32 x) Files_Write(&*R, R__typ, (CHAR)__MASK(x, -128)); } +void Files_WriteNum64 (Files_Rider *R, LONGINT *R__typ, int64 x) +{ + while (x < -64 || x > 63) { + Files_Write(&*R, R__typ, (CHAR)(__MASK(x, -128) + 128)); + x = __ASHR(x, 7); + } + Files_Write(&*R, R__typ, (CHAR)__MASK(x, -128)); +} + void Files_GetName (Files_File f, CHAR *name, LONGINT name__len) { __COPY(f->workName, name, name__len); diff --git a/bootstrap/unix-44/Files.h b/bootstrap/unix-44/Files.h index c86d1186..0187d33f 100644 --- a/bootstrap/unix-44/Files.h +++ b/bootstrap/unix-44/Files.h @@ -47,6 +47,7 @@ import void Files_ReadLInt (Files_Rider *R, LONGINT *R__typ, int32 *x); import void Files_ReadLReal (Files_Rider *R, LONGINT *R__typ, LONGREAL *x); import void Files_ReadLine (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len); import void Files_ReadNum (Files_Rider *R, LONGINT *R__typ, int32 *x); +import void Files_ReadNum64 (Files_Rider *R, LONGINT *R__typ, int64 *x); import void Files_ReadReal (Files_Rider *R, LONGINT *R__typ, REAL *x); import void Files_ReadSet (Files_Rider *R, LONGINT *R__typ, SET *x); import void Files_ReadString (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len); @@ -61,6 +62,7 @@ import void Files_WriteInt (Files_Rider *R, LONGINT *R__typ, int16 x); import void Files_WriteLInt (Files_Rider *R, LONGINT *R__typ, int32 x); import void Files_WriteLReal (Files_Rider *R, LONGINT *R__typ, LONGREAL x); import void Files_WriteNum (Files_Rider *R, LONGINT *R__typ, int32 x); +import void Files_WriteNum64 (Files_Rider *R, LONGINT *R__typ, int64 x); import void Files_WriteReal (Files_Rider *R, LONGINT *R__typ, REAL x); import void Files_WriteSet (Files_Rider *R, LONGINT *R__typ, SET x); import void Files_WriteString (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len); diff --git a/bootstrap/unix-44/OPB.c b/bootstrap/unix-44/OPB.c index 90e93aed..47f2de21 100644 --- a/bootstrap/unix-44/OPB.c +++ b/bootstrap/unix-44/OPB.c @@ -12,7 +12,7 @@ export void (*OPB_typSize)(OPT_Struct); static int16 OPB_exp; -static int32 OPB_maxExp; +static int64 OPB_maxExp; export void OPB_Assign (OPT_Node *x, OPT_Node y); @@ -38,14 +38,14 @@ export void OPB_Field (OPT_Node *x, OPT_Object y); export void OPB_In (OPT_Node *x, OPT_Node y); export void OPB_Index (OPT_Node *x, OPT_Node y); export void OPB_Inittd (OPT_Node *inittd, OPT_Node *last, OPT_Struct typ); -static BOOLEAN OPB_IntToBool (int32 i); +static BOOLEAN OPB_IntToBool (int64 i); export void OPB_Link (OPT_Node *x, OPT_Node *last, OPT_Node y); export void OPB_MOp (int8 op, OPT_Node *x); export OPT_Node OPB_NewBoolConst (BOOLEAN boolval); -export OPT_Node OPB_NewIntConst (int32 intval); +export OPT_Node OPB_NewIntConst (int64 intval); export OPT_Node OPB_NewLeaf (OPT_Object obj); export OPT_Node OPB_NewRealConst (LONGREAL realval, OPT_Struct typ); -export OPT_Node OPB_NewString (OPS_String str, int32 len); +export OPT_Node OPB_NewString (OPS_String str, int64 len); export OPT_Node OPB_Nil (void); static BOOLEAN OPB_NotVar (OPT_Node x); export void OPB_Op (int8 op, OPT_Node *x, OPT_Node y); @@ -63,7 +63,7 @@ export void OPB_StParN (OPT_Node *par0, OPT_Node x, int16 fctno, int16 n); export void OPB_StaticLink (int8 dlev); export void OPB_TypTest (OPT_Node *x, OPT_Object obj, BOOLEAN guard); static void OPB_err (int16 n); -static int32 OPB_log (int32 x); +static int64 OPB_log (int64 x); static void OPB_err (int16 n) @@ -141,17 +141,11 @@ static int32 OPB_BoolToInt (BOOLEAN b) __RETCHK; } -static BOOLEAN OPB_IntToBool (int32 i) +static BOOLEAN OPB_IntToBool (int64 i) { BOOLEAN _o_result; - if (i == 0) { - _o_result = 0; - return _o_result; - } else { - _o_result = 1; - return _o_result; - } - __RETCHK; + _o_result = i != 0; + return _o_result; } OPT_Node OPB_NewBoolConst (BOOLEAN boolval) @@ -228,7 +222,7 @@ OPT_Node OPB_EmptySet (void) static void OPB_SetIntType (OPT_Node node) { int16 b; - int32 n; + int64 n; if (node->conval->intval >= 0) { n = node->conval->intval; } else { @@ -241,7 +235,7 @@ static void OPB_SetIntType (OPT_Node node) node->typ = OPT_IntType(b); } -OPT_Node OPB_NewIntConst (int32 intval) +OPT_Node OPB_NewIntConst (int64 intval) { OPT_Node _o_result; OPT_Node x = NIL; @@ -266,7 +260,7 @@ OPT_Node OPB_NewRealConst (LONGREAL realval, OPT_Struct typ) return _o_result; } -OPT_Node OPB_NewString (OPS_String str, int32 len) +OPT_Node OPB_NewString (OPS_String str, int64 len) { OPT_Node _o_result; OPT_Node x = NIL; @@ -274,7 +268,7 @@ OPT_Node OPB_NewString (OPS_String str, int32 len) x->conval = OPT_NewConst(); x->typ = OPT_stringtyp; x->conval->intval = -1; - x->conval->intval2 = len; + x->conval->intval2 = OPM_Longint(len); x->conval->ext = OPT_NewExt(); __COPY(str, *x->conval->ext, 256); _o_result = x; @@ -351,7 +345,7 @@ void OPB_Index (OPT_Node *x, OPT_Node y) } if ((*x)->typ->comp == 2) { typ = (*x)->typ->BaseTyp; - if ((y->class == 7 && (y->conval->intval < 0 || y->conval->intval >= (*x)->typ->n))) { + if ((y->class == 7 && (y->conval->intval < 0 || y->conval->intval >= (int64)(*x)->typ->n))) { OPB_err(81); } } else if ((*x)->typ->comp == 3) { @@ -466,14 +460,14 @@ void OPB_TypTest (OPT_Node *x, OPT_Object obj, BOOLEAN guard) void OPB_In (OPT_Node *x, OPT_Node y) { int16 f; - int32 k; + int64 k; f = (*x)->typ->form; if ((((*x)->class == 8 || (*x)->class == 9) || y->class == 8) || y->class == 9) { OPB_err(126); } else if ((f == 4 && y->typ->form == 7)) { if ((*x)->class == 7) { k = (*x)->conval->intval; - if (k < 0 || k > OPM_MaxSet) { + if (k < 0 || k > (int64)OPM_MaxSet) { OPB_err(202); } else if (y->class == 7) { (*x)->conval->intval = OPB_BoolToInt(__IN(k, y->conval->setval, 32)); @@ -492,9 +486,9 @@ void OPB_In (OPT_Node *x, OPT_Node y) (*x)->typ = OPT_booltyp; } -static int32 OPB_log (int32 x) +static int64 OPB_log (int64 x) { - int32 _o_result; + int64 _o_result; OPB_exp = 0; if (x > 0) { while (!__ODD(x)) { @@ -580,7 +574,7 @@ void OPB_MOp (int8 op, OPT_Node *x) if (__IN(f, 0xf0, 32)) { if (z->class == 7) { if (f == 4) { - if (z->conval->intval == (-2147483647-1)) { + if (z->conval->intval == (-9223372036854775807-1)) { OPB_err(203); } else { z->conval->intval = -z->conval->intval; @@ -603,7 +597,7 @@ void OPB_MOp (int8 op, OPT_Node *x) if (__IN(f, 0x70, 32)) { if (z->class == 7) { if (f == 4) { - if (z->conval->intval == (-2147483647-1)) { + if (z->conval->intval == (-9223372036854775807-1)) { OPB_err(203); } else { z->conval->intval = __ABS(z->conval->intval); @@ -845,7 +839,7 @@ static void OPB_ConstOp (int16 op, OPT_Node x, OPT_Node y) { int16 f, g; OPT_Const xval = NIL, yval = NIL; - int32 xv, yv; + int64 xv, yv; BOOLEAN temp; struct ConstOp__13 _s; _s.x = &x; @@ -1007,7 +1001,7 @@ static void OPB_ConstOp (int16 op, OPT_Node x, OPT_Node y) case 4: if (f == 4) { if (yval->intval != 0) { - xval->intval = (int)__MOD(xval->intval, yval->intval); + xval->intval = __MOD(xval->intval, yval->intval); OPB_SetIntType(x); } else { OPB_err(205); @@ -1122,7 +1116,7 @@ static void OPB_Convert (OPT_Node *x, OPT_Struct typ) { OPT_Node node = NIL; int16 f, g; - int32 k; + int64 k; LONGREAL r; f = (*x)->typ->form; g = typ->form; @@ -1229,7 +1223,7 @@ void OPB_Op (int8 op, OPT_Node *x, OPT_Node y) OPT_Node t = NIL, z = NIL; OPT_Struct typ = NIL; BOOLEAN do_; - int32 val; + int64 val; struct Op__38 _s; _s.f = &f; _s.g = &g; @@ -1500,19 +1494,19 @@ void OPB_Op (int8 op, OPT_Node *x, OPT_Node y) void OPB_SetRange (OPT_Node *x, OPT_Node y) { - int32 k, l; + int64 k, l; if ((((*x)->class == 8 || (*x)->class == 9) || y->class == 8) || y->class == 9) { OPB_err(126); } else if (((*x)->typ->form == 4 && y->typ->form == 4)) { if ((*x)->class == 7) { k = (*x)->conval->intval; - if (0 > k || k > OPM_MaxSet) { + if (0 > k || k > (int64)OPM_MaxSet) { OPB_err(202); } } if (y->class == 7) { l = y->conval->intval; - if (0 > l || l > OPM_MaxSet) { + if (0 > l || l > (int64)OPM_MaxSet) { OPB_err(202); } } @@ -1535,14 +1529,14 @@ void OPB_SetRange (OPT_Node *x, OPT_Node y) void OPB_SetElem (OPT_Node *x) { - int32 k; + int64 k; if ((*x)->class == 8 || (*x)->class == 9) { OPB_err(126); } else if ((*x)->typ->form != 4) { OPB_err(93); } else if ((*x)->class == 7) { k = (*x)->conval->intval; - if ((0 <= k && k <= OPM_MaxSet)) { + if ((0 <= k && k <= (int64)OPM_MaxSet)) { (*x)->conval->setval = __SETOF(k,32); } else { OPB_err(202); @@ -1917,7 +1911,7 @@ void OPB_StPar0 (OPT_Node *par0, int16 fctno) if (x->class == 8 || x->class == 9) { OPB_err(126); } else if (f == 4) { - if (x->typ->size != OPT_linttyp->size) { + if (x->typ->size < OPT_linttyp->size) { OPB_Convert(&x, OPT_linttyp); } } else { @@ -2055,7 +2049,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, int8 fctno) if (x->class == 8 || x->class == 9) { OPB_err(126); } else if (f == 4) { - if ((x->class == 7 && (0 > x->conval->intval || x->conval->intval > OPM_MaxSet))) { + if ((x->class == 7 && (0 > x->conval->intval || x->conval->intval > (int64)OPM_MaxSet))) { OPB_err(202); } p = NewOp__53(19, fctno, p, x); @@ -2068,7 +2062,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, int8 fctno) if (!(f == 4) || x->class != 7) { OPB_err(69); } else if (x->typ->size == 1) { - L = (int16)x->conval->intval; + L = OPM_Integer(x->conval->intval); typ = p->typ; while ((L > 0 && __IN(typ->comp, 0x0c, 32))) { typ = typ->BaseTyp; @@ -2120,8 +2114,8 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, int8 fctno) OPB_err(208); p->conval->intval = 1; } else if (x->conval->intval >= 0) { - if (__ABS(p->conval->intval) <= __DIV(2147483647, __ASH(1, x->conval->intval))) { - p->conval->intval = p->conval->intval * __ASH(1, x->conval->intval); + if (__ABS(p->conval->intval) <= __DIV(9223372036854775807, (int64)__ASH(1, x->conval->intval))) { + p->conval->intval = p->conval->intval * (int64)__ASH(1, x->conval->intval); } else { OPB_err(208); p->conval->intval = 1; @@ -2132,7 +2126,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, int8 fctno) p->obj = NIL; } else { p = NewOp__53(12, 17, p, x); - p->typ = OPT_linttyp; + p->typ = p->left->typ; } } else { OPB_err(111); @@ -2143,7 +2137,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, int8 fctno) OPB_err(126); } else if (p->typ->comp == 3) { if (f == 4) { - if ((x->class == 7 && (x->conval->intval <= 0 || x->conval->intval > OPM_MaxIndex))) { + if ((x->class == 7 && (x->conval->intval <= 0 || x->conval->intval > (int64)OPM_MaxIndex))) { OPB_err(63); } } else { @@ -2281,7 +2275,7 @@ void OPB_StParN (OPT_Node *par0, OPT_Node x, int16 fctno, int16 n) } else if (p->typ->comp != 3) { OPB_err(64); } else if (f == 4) { - if ((x->class == 7 && (x->conval->intval <= 0 || x->conval->intval > OPM_MaxIndex))) { + if ((x->class == 7 && (x->conval->intval <= 0 || x->conval->intval > (int64)OPM_MaxIndex))) { OPB_err(63); } node = p->right; @@ -2622,7 +2616,7 @@ export void *OPB__init(void) __MODULE_IMPORT(OPT); __REGMOD("OPB", 0); /* BEGIN */ - OPB_maxExp = OPB_log(1073741824); + OPB_maxExp = OPB_log(4611686018427387904); OPB_maxExp = OPB_exp; __ENDMOD; } diff --git a/bootstrap/unix-44/OPB.h b/bootstrap/unix-44/OPB.h index 183a5f32..08d025bf 100644 --- a/bootstrap/unix-44/OPB.h +++ b/bootstrap/unix-44/OPB.h @@ -25,10 +25,10 @@ import void OPB_Inittd (OPT_Node *inittd, OPT_Node *last, OPT_Struct typ); import void OPB_Link (OPT_Node *x, OPT_Node *last, OPT_Node y); import void OPB_MOp (int8 op, OPT_Node *x); import OPT_Node OPB_NewBoolConst (BOOLEAN boolval); -import OPT_Node OPB_NewIntConst (int32 intval); +import OPT_Node OPB_NewIntConst (int64 intval); import OPT_Node OPB_NewLeaf (OPT_Object obj); import OPT_Node OPB_NewRealConst (LONGREAL realval, OPT_Struct typ); -import OPT_Node OPB_NewString (OPS_String str, int32 len); +import OPT_Node OPB_NewString (OPS_String str, int64 len); import OPT_Node OPB_Nil (void); import void OPB_Op (int8 op, OPT_Node *x, OPT_Node y); import void OPB_OptIf (OPT_Node *x); diff --git a/bootstrap/unix-44/OPC.c b/bootstrap/unix-44/OPC.c index 17690465..c21e44a4 100644 --- a/bootstrap/unix-44/OPC.c +++ b/bootstrap/unix-44/OPC.c @@ -26,8 +26,8 @@ export OPT_Object OPC_BaseTProc (OPT_Object obj); export void OPC_BegBlk (void); export void OPC_BegStat (void); static void OPC_CProcDefs (OPT_Object obj, int16 vis); -export void OPC_Case (int32 caseVal, int16 form); -static void OPC_CharacterLiteral (int32 c); +export void OPC_Case (int64 caseVal, int16 form); +static void OPC_CharacterLiteral (int64 c); export void OPC_Cmp (int16 rel); export void OPC_CompleteIdent (OPT_Object obj); export void OPC_Constant (OPT_Const con, int16 form); @@ -67,8 +67,8 @@ static void OPC_InitImports (OPT_Object obj); static void OPC_InitKeywords (void); export void OPC_InitTDesc (OPT_Struct typ); static void OPC_InitTProcs (OPT_Object typ, OPT_Object obj); -export void OPC_IntLiteral (int32 n, int32 size); -export void OPC_Len (OPT_Object obj, OPT_Struct array, int32 dim); +export void OPC_IntLiteral (int64 n, int32 size); +export void OPC_Len (OPT_Object obj, OPT_Struct array, int64 dim); static void OPC_LenList (OPT_Object par, BOOLEAN ansiDefine, BOOLEAN showParamName); static int16 OPC_Length (CHAR *s, LONGINT s__len); export int32 OPC_NofPtrs (OPT_Struct typ); @@ -1851,7 +1851,7 @@ void OPC_Cmp (int16 rel) } } -static void OPC_CharacterLiteral (int32 c) +static void OPC_CharacterLiteral (int64 c) { if (c < 32 || c > 126) { OPM_WriteString((CHAR*)"0x", 3); @@ -1894,7 +1894,7 @@ static void OPC_StringLiteral (CHAR *s, LONGINT s__len, int32 l) __DEL(s); } -void OPC_Case (int32 caseVal, int16 form) +void OPC_Case (int64 caseVal, int16 form) { CHAR ch; OPM_WriteString((CHAR*)"case ", 6); @@ -1937,7 +1937,7 @@ void OPC_Halt (int32 n) OPC_Str1((CHAR*)"__HALT(#)", 10, n); } -void OPC_IntLiteral (int32 n, int32 size) +void OPC_IntLiteral (int64 n, int32 size) { if ((((size > 4 && n <= 2147483647)) && n > (-2147483647-1))) { OPM_WriteString((CHAR*)"((int", 6); @@ -1950,7 +1950,7 @@ void OPC_IntLiteral (int32 n, int32 size) } } -void OPC_Len (OPT_Object obj, OPT_Struct array, int32 dim) +void OPC_Len (OPT_Object obj, OPT_Struct array, int64 dim) { if (array->comp == 3) { OPC_CompleteIdent(obj); diff --git a/bootstrap/unix-44/OPC.h b/bootstrap/unix-44/OPC.h index 34d9ebc2..9e1ec652 100644 --- a/bootstrap/unix-44/OPC.h +++ b/bootstrap/unix-44/OPC.h @@ -15,7 +15,7 @@ import int32 OPC_BaseAlignment (OPT_Struct typ); import OPT_Object OPC_BaseTProc (OPT_Object obj); import void OPC_BegBlk (void); import void OPC_BegStat (void); -import void OPC_Case (int32 caseVal, int16 form); +import void OPC_Case (int64 caseVal, int16 form); import void OPC_Cmp (int16 rel); import void OPC_CompleteIdent (OPT_Object obj); import void OPC_Constant (OPT_Const con, int16 form); @@ -37,8 +37,8 @@ import void OPC_Increment (BOOLEAN decrement); import void OPC_Indent (int16 count); import void OPC_Init (void); import void OPC_InitTDesc (OPT_Struct typ); -import void OPC_IntLiteral (int32 n, int32 size); -import void OPC_Len (OPT_Object obj, OPT_Struct array, int32 dim); +import void OPC_IntLiteral (int64 n, int32 size); +import void OPC_Len (OPT_Object obj, OPT_Struct array, int64 dim); import int32 OPC_NofPtrs (OPT_Struct typ); import void OPC_SetInclude (BOOLEAN exclude); import int32 OPC_SizeAlignment (int32 size); diff --git a/bootstrap/unix-44/OPM.c b/bootstrap/unix-44/OPM.c index 18478d1e..ba86c00a 100644 --- a/bootstrap/unix-44/OPM.c +++ b/bootstrap/unix-44/OPM.c @@ -28,7 +28,8 @@ export int16 OPM_currFile, OPM_level, OPM_pc, OPM_entno; export CHAR OPM_modName[32]; export CHAR OPM_objname[64]; export SET OPM_opt, OPM_glbopt; -static int32 OPM_ErrorLineStartPos, OPM_ErrorLineLimitPos, OPM_ErrorLineNumber, OPM_lasterrpos; +static int32 OPM_ErrorLineStartPos, OPM_ErrorLineLimitPos, OPM_ErrorLineNumber; +static int64 OPM_lasterrpos; static Texts_Reader OPM_inR; static Texts_Text OPM_Log; static Texts_Writer OPM_W; @@ -45,46 +46,49 @@ static void OPM_Append (Files_Rider *R, LONGINT *R__typ, Files_File F); export void OPM_CloseFiles (void); export void OPM_CloseOldSym (void); export void OPM_DeleteNewSym (void); -export void OPM_FPrint (int32 *fp, int32 val); +export void OPM_FPrint (int32 *fp, int64 val); export void OPM_FPrintLReal (int32 *fp, LONGREAL lr); export void OPM_FPrintReal (int32 *fp, REAL real); export void OPM_FPrintSet (int32 *fp, SET set); -static void OPM_FindLine (Files_File f, Files_Rider *r, LONGINT *r__typ, int32 pos); +static void OPM_FindLine (Files_File f, Files_Rider *r, LONGINT *r__typ, int64 pos); export void OPM_Get (CHAR *ch); static void OPM_GetProperties (void); static void OPM_GetProperty (Texts_Scanner *S, LONGINT *S__typ, CHAR *name, LONGINT name__len, int16 *size, int16 *align); export void OPM_Init (BOOLEAN *done, CHAR *mname, LONGINT mname__len); export void OPM_InitOptions (void); +export int16 OPM_Integer (int64 n); static void OPM_LogErrMsg (int16 n); export void OPM_LogW (CHAR ch); export void OPM_LogWLn (void); -export void OPM_LogWNum (int32 i, int32 len); +export void OPM_LogWNum (int64 i, int64 len); export void OPM_LogWStr (CHAR *s, LONGINT s__len); +export int32 OPM_Longint (int64 n); static void OPM_MakeFileName (CHAR *name, LONGINT name__len, CHAR *FName, LONGINT FName__len, CHAR *ext, LONGINT ext__len); -export void OPM_Mark (int16 n, int32 pos); +export void OPM_Mark (int16 n, int64 pos); export void OPM_NewSym (CHAR *modName, LONGINT modName__len); export void OPM_OldSym (CHAR *modName, LONGINT modName__len, BOOLEAN *done); export void OPM_OpenFiles (CHAR *moduleName, LONGINT moduleName__len); export BOOLEAN OPM_OpenPar (void); export void OPM_RegisterNewSym (void); static void OPM_ScanOptions (CHAR *s, LONGINT s__len, SET *opt); -static void OPM_ShowLine (int32 pos); +static void OPM_ShowLine (int64 pos); export int32 OPM_SignedMaximum (int32 bytecount); export int32 OPM_SignedMinimum (int32 bytecount); export void OPM_SymRCh (CHAR *ch); export int32 OPM_SymRInt (void); +export int64 OPM_SymRInt64 (void); export void OPM_SymRLReal (LONGREAL *lr); export void OPM_SymRReal (REAL *r); export void OPM_SymRSet (SET *s); export void OPM_SymWCh (CHAR ch); -export void OPM_SymWInt (int32 i); +export void OPM_SymWInt (int64 i); export void OPM_SymWLReal (LONGREAL lr); export void OPM_SymWReal (REAL r); export void OPM_SymWSet (SET s); static void OPM_VerboseListSizes (void); export void OPM_Write (CHAR ch); -export void OPM_WriteHex (int32 i); -export void OPM_WriteInt (int32 i); +export void OPM_WriteHex (int64 i); +export void OPM_WriteInt (int64 i); export void OPM_WriteLn (void); export void OPM_WriteReal (LONGREAL r, CHAR suffx); export void OPM_WriteString (CHAR *s, LONGINT s__len); @@ -107,7 +111,7 @@ void OPM_LogWStr (CHAR *s, LONGINT s__len) __DEL(s); } -void OPM_LogWNum (int32 i, int32 len) +void OPM_LogWNum (int64 i, int64 len) { Console_Int(i, len); } @@ -117,6 +121,20 @@ void OPM_LogWLn (void) Console_Ln(); } +int32 OPM_Longint (int64 n) +{ + int32 _o_result; + _o_result = __VAL(int32, n); + return _o_result; +} + +int16 OPM_Integer (int64 n) +{ + int16 _o_result; + _o_result = __VAL(int16, n); + return _o_result; +} + static void OPM_ScanOptions (CHAR *s, LONGINT s__len, SET *opt) { int16 i; @@ -404,21 +422,21 @@ static void OPM_LogErrMsg (int16 n) OPM_LogWStr(errors_errors[__X(n, 350)], 128); } -static void OPM_FindLine (Files_File f, Files_Rider *r, LONGINT *r__typ, int32 pos) +static void OPM_FindLine (Files_File f, Files_Rider *r, LONGINT *r__typ, int64 pos) { CHAR ch, cheol; - if (pos < OPM_ErrorLineStartPos) { + if (pos < (int64)OPM_ErrorLineStartPos) { OPM_ErrorLineStartPos = 0; OPM_ErrorLineLimitPos = 0; OPM_ErrorLineNumber = 0; } - if (pos < OPM_ErrorLineLimitPos) { + if (pos < (int64)OPM_ErrorLineLimitPos) { Files_Set(&*r, r__typ, f, OPM_ErrorLineStartPos); return; } Files_Set(&*r, r__typ, f, OPM_ErrorLineLimitPos); Files_Read(&*r, r__typ, (void*)&ch); - while ((OPM_ErrorLineLimitPos < pos && !(*r).eof)) { + while (((int64)OPM_ErrorLineLimitPos < pos && !(*r).eof)) { OPM_ErrorLineStartPos = OPM_ErrorLineLimitPos; OPM_ErrorLineNumber += 1; while ((((ch != 0x00 && ch != 0x0d)) && ch != 0x0a)) { @@ -436,7 +454,7 @@ static void OPM_FindLine (Files_File f, Files_Rider *r, LONGINT *r__typ, int32 p Files_Set(&*r, r__typ, f, OPM_ErrorLineStartPos); } -static void OPM_ShowLine (int32 pos) +static void OPM_ShowLine (int64 pos) { Files_File f = NIL; Files_Rider r; @@ -460,10 +478,10 @@ static void OPM_ShowLine (int32 pos) OPM_LogWStr(line, 1023); OPM_LogWLn(); OPM_LogWStr((CHAR*)" ", 7); - if (pos >= OPM_ErrorLineLimitPos) { + if (pos >= (int64)OPM_ErrorLineLimitPos) { pos = OPM_ErrorLineLimitPos - 1; } - i = (int16)(pos - OPM_ErrorLineStartPos); + i = (int16)OPM_Longint(pos - (int64)OPM_ErrorLineStartPos); while (i > 0) { OPM_LogW(' '); i -= 1; @@ -478,7 +496,7 @@ static void OPM_ShowLine (int32 pos) Files_Close(f); } -void OPM_Mark (int16 n, int32 pos) +void OPM_Mark (int16 n, int64 pos) { if (pos == -1) { pos = 0; @@ -535,9 +553,9 @@ void OPM_err (int16 n) OPM_Mark(n, OPM_errpos); } -void OPM_FPrint (int32 *fp, int32 val) +void OPM_FPrint (int32 *fp, int64 val) { - *fp = __ROTL((int32)((SET)*fp ^ (SET)val), 1, 32); + *fp = __ROTL((int32)((SET)*fp ^ __VAL(SET, val)), 1, 32); } void OPM_FPrintSet (int32 *fp, SET set) @@ -702,6 +720,15 @@ int32 OPM_SymRInt (void) return _o_result; } +int64 OPM_SymRInt64 (void) +{ + int64 _o_result; + int64 k; + Files_ReadNum64(&OPM_oldSF, Files_Rider__typ, &k); + _o_result = k; + return _o_result; +} + void OPM_SymRSet (SET *s) { Files_ReadNum(&OPM_oldSF, Files_Rider__typ, (int32*)&*s); @@ -751,9 +778,9 @@ void OPM_SymWCh (CHAR ch) Files_Write(&OPM_newSF, Files_Rider__typ, ch); } -void OPM_SymWInt (int32 i) +void OPM_SymWInt (int64 i) { - Files_WriteNum(&OPM_newSF, Files_Rider__typ, i); + Files_WriteNum64(&OPM_newSF, Files_Rider__typ, i); } void OPM_SymWSet (SET s) @@ -820,17 +847,17 @@ void OPM_WriteStringVar (CHAR *s, LONGINT s__len) Files_WriteBytes(&OPM_R[__X(OPM_currFile, 3)], Files_Rider__typ, (void*)s, s__len * 1, i); } -void OPM_WriteHex (int32 i) +void OPM_WriteHex (int64 i) { CHAR s[3]; - int16 digit; - digit = __ASHR((int16)i, 4); + int32 digit; + digit = __ASHR((int32)i, 4); if (digit < 10) { s[0] = (CHAR)(48 + digit); } else { s[0] = (CHAR)(87 + digit); } - digit = __MASK((int16)i, -16); + digit = __MASK((int32)i, -16); if (digit < 10) { s[1] = (CHAR)(48 + digit); } else { @@ -840,31 +867,31 @@ void OPM_WriteHex (int32 i) OPM_WriteString(s, 3); } -void OPM_WriteInt (int32 i) +void OPM_WriteInt (int64 i) { - CHAR s[20]; - int32 i1, k; - if (i == OPM_SignedMinimum(OPM_IntSize) || i == OPM_SignedMinimum(OPM_LIntSize)) { + CHAR s[24]; + int64 i1, k; + if ((i == (int64)OPM_SignedMinimum(OPM_IntSize) || i == (int64)OPM_SignedMinimum(OPM_LIntSize)) || i == (int64)OPM_SignedMinimum(8)) { OPM_Write('('); OPM_WriteInt(i + 1); OPM_WriteString((CHAR*)"-1)", 4); } else { i1 = __ABS(i); - s[0] = (CHAR)((int)__MOD(i1, 10) + 48); + s[0] = (CHAR)(__MOD(i1, 10) + 48); i1 = __DIV(i1, 10); k = 1; while (i1 > 0) { - s[__X(k, 20)] = (CHAR)((int)__MOD(i1, 10) + 48); + s[__X(k, 24)] = (CHAR)(__MOD(i1, 10) + 48); i1 = __DIV(i1, 10); k += 1; } if (i < 0) { - s[__X(k, 20)] = '-'; + s[__X(k, 24)] = '-'; k += 1; } while (k > 0) { k -= 1; - OPM_Write(s[__X(k, 20)]); + OPM_Write(s[__X(k, 24)]); } } } diff --git a/bootstrap/unix-44/OPM.h b/bootstrap/unix-44/OPM.h index a36522a1..504519da 100644 --- a/bootstrap/unix-44/OPM.h +++ b/bootstrap/unix-44/OPM.h @@ -21,18 +21,20 @@ import BOOLEAN OPM_dontAsm, OPM_dontLink, OPM_mainProg, OPM_mainLinkStat, OPM_no import void OPM_CloseFiles (void); import void OPM_CloseOldSym (void); import void OPM_DeleteNewSym (void); -import void OPM_FPrint (int32 *fp, int32 val); +import void OPM_FPrint (int32 *fp, int64 val); import void OPM_FPrintLReal (int32 *fp, LONGREAL lr); import void OPM_FPrintReal (int32 *fp, REAL real); import void OPM_FPrintSet (int32 *fp, SET set); import void OPM_Get (CHAR *ch); import void OPM_Init (BOOLEAN *done, CHAR *mname, LONGINT mname__len); import void OPM_InitOptions (void); +import int16 OPM_Integer (int64 n); import void OPM_LogW (CHAR ch); import void OPM_LogWLn (void); -import void OPM_LogWNum (int32 i, int32 len); +import void OPM_LogWNum (int64 i, int64 len); import void OPM_LogWStr (CHAR *s, LONGINT s__len); -import void OPM_Mark (int16 n, int32 pos); +import int32 OPM_Longint (int64 n); +import void OPM_Mark (int16 n, int64 pos); import void OPM_NewSym (CHAR *modName, LONGINT modName__len); import void OPM_OldSym (CHAR *modName, LONGINT modName__len, BOOLEAN *done); import void OPM_OpenFiles (CHAR *moduleName, LONGINT moduleName__len); @@ -42,17 +44,18 @@ import int32 OPM_SignedMaximum (int32 bytecount); import int32 OPM_SignedMinimum (int32 bytecount); import void OPM_SymRCh (CHAR *ch); import int32 OPM_SymRInt (void); +import int64 OPM_SymRInt64 (void); import void OPM_SymRLReal (LONGREAL *lr); import void OPM_SymRReal (REAL *r); import void OPM_SymRSet (SET *s); import void OPM_SymWCh (CHAR ch); -import void OPM_SymWInt (int32 i); +import void OPM_SymWInt (int64 i); import void OPM_SymWLReal (LONGREAL lr); import void OPM_SymWReal (REAL r); import void OPM_SymWSet (SET s); import void OPM_Write (CHAR ch); -import void OPM_WriteHex (int32 i); -import void OPM_WriteInt (int32 i); +import void OPM_WriteHex (int64 i); +import void OPM_WriteInt (int64 i); import void OPM_WriteLn (void); import void OPM_WriteReal (LONGREAL r, CHAR suffx); import void OPM_WriteString (CHAR *s, LONGINT s__len); diff --git a/bootstrap/unix-44/OPP.c b/bootstrap/unix-44/OPP.c index 8db5ef60..44ce8ff1 100644 --- a/bootstrap/unix-44/OPP.c +++ b/bootstrap/unix-44/OPP.c @@ -134,7 +134,7 @@ static void OPP_CheckMark (int8 *vis) static void OPP_CheckSysFlag (int16 *sysflag, int16 default_) { OPT_Node x = NIL; - int32 sf; + int64 sf; if (OPP_sym == 31) { OPS_Get(&OPP_sym); if (!OPT_SYSimported) { @@ -151,7 +151,7 @@ static void OPP_CheckSysFlag (int16 *sysflag, int16 default_) OPP_err(51); sf = 0; } - *sysflag = (int16)sf; + *sysflag = OPM_Integer(sf); OPP_CheckSym(23); } else { *sysflag = default_; @@ -254,7 +254,7 @@ static void OPP_RecordType (OPT_Struct *typ, OPT_Struct *banned) static void OPP_ArrayType (OPT_Struct *typ, OPT_Struct *banned) { OPT_Node x = NIL; - int32 n; + int64 n; int16 sysflag; OPP_CheckSysFlag(&sysflag, 0); if (OPP_sym == 25) { @@ -275,7 +275,7 @@ static void OPP_ArrayType (OPT_Struct *typ, OPT_Struct *banned) OPP_ConstExpression(&x); if (x->typ->form == 4) { n = x->conval->intval; - if (n <= 0 || n > OPM_MaxIndex) { + if (n <= 0 || n > (int64)OPM_MaxIndex) { OPP_err(63); n = 1; } @@ -283,7 +283,7 @@ static void OPP_ArrayType (OPT_Struct *typ, OPT_Struct *banned) OPP_err(51); n = 1; } - (*typ)->n = n; + (*typ)->n = OPM_Longint(n); if (OPP_sym == 25) { OPS_Get(&OPP_sym); OPP_Type(&(*typ)->BaseTyp, &*banned); @@ -932,7 +932,7 @@ static void GetCode__19 (void) { OPT_ConstExt ext = NIL; int16 n; - int32 c; + int64 c; ext = OPT_NewExt(); (*ProcedureDeclaration__16_s->proc)->conval->ext = ext; n = 0; @@ -1179,7 +1179,7 @@ static void OPP_CaseLabelList (OPT_Node *lab, OPT_Struct LabelTyp, int16 *n, OPP OPP_ConstExpression(&x); f = x->typ->form; if (__IN(f, 0x18, 32)) { - xval = x->conval->intval; + xval = OPM_Longint(x->conval->intval); } else { OPP_err(61); xval = 1; @@ -1194,7 +1194,7 @@ static void OPP_CaseLabelList (OPT_Node *lab, OPT_Struct LabelTyp, int16 *n, OPP if (OPP_sym == 21) { OPS_Get(&OPP_sym); OPP_ConstExpression(&y); - yval = y->conval->intval; + yval = OPM_Longint(y->conval->intval); if (((int16)y->typ->form != f && !((f == 4 && y->typ->form == 4)))) { OPP_err(60); } diff --git a/bootstrap/unix-44/OPS.c b/bootstrap/unix-44/OPS.c index fb0f2237..f80ca2b1 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 int32 OPS_intval; +export int64 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) + Ord__7(dig[i], 1); + OPS_intval = __ASHL(OPS_intval, 4) + (int64)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) + Ord__7(dig[i], 1); + OPS_intval = __ASHL(OPS_intval, 4) + (int64)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 ((int64)OPS_intval <= __DIV(9223372036854775807 - (int64)d, 10)) { - OPS_intval = OPS_intval * 10 + d; + if (OPS_intval <= __DIV(9223372036854775807 - (int64)d, 10)) { + OPS_intval = OPS_intval * 10 + (int64)d; } else { OPS_err(203); } diff --git a/bootstrap/unix-44/OPS.h b/bootstrap/unix-44/OPS.h index d2b5dfb4..d33103c1 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 int32 OPS_intval; +import int64 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 83a2652b..c7f21138 100644 --- a/bootstrap/unix-44/OPT.c +++ b/bootstrap/unix-44/OPT.c @@ -17,7 +17,8 @@ typedef typedef struct OPT_ConstDesc { OPT_ConstExt ext; - int32 intval, intval2; + int64 intval; + int32 intval2; SET setval; LONGREAL realval; } OPT_ConstDesc; @@ -1838,7 +1839,7 @@ static void EnumPtrs(void (*P)(void*)) __ENUMR(&OPT_impCtxt, OPT_ImpCtxt__typ, 3140, 1, P); } -__TDESC(OPT_ConstDesc, 1, 1) = {__TDFLDS("ConstDesc", 24), {0, -8}}; +__TDESC(OPT_ConstDesc, 1, 1) = {__TDFLDS("ConstDesc", 28), {0, -8}}; __TDESC(OPT_ObjDesc, 1, 6) = {__TDFLDS("ObjDesc", 304), {0, 4, 8, 12, 284, 288, -28}}; __TDESC(OPT_StrDesc, 1, 3) = {__TDFLDS("StrDesc", 56), {44, 48, 52, -16}}; __TDESC(OPT_NodeDesc, 1, 6) = {__TDFLDS("NodeDesc", 28), {0, 4, 8, 16, 20, 24, -28}}; diff --git a/bootstrap/unix-44/OPT.h b/bootstrap/unix-44/OPT.h index d4b49da8..b6566702 100644 --- a/bootstrap/unix-44/OPT.h +++ b/bootstrap/unix-44/OPT.h @@ -15,7 +15,8 @@ typedef typedef struct OPT_ConstDesc { OPT_ConstExt ext; - int32 intval, intval2; + int64 intval; + int32 intval2; SET setval; LONGREAL realval; } OPT_ConstDesc; diff --git a/bootstrap/unix-44/OPV.c b/bootstrap/unix-44/OPV.c index a32351aa..cddb737c 100644 --- a/bootstrap/unix-44/OPV.c +++ b/bootstrap/unix-44/OPV.c @@ -36,10 +36,10 @@ static BOOLEAN OPV_ImplicitReturn (OPT_Node n); static void OPV_Index (OPT_Node n, OPT_Node d, int16 prec, int16 dim); export void OPV_Init (void); static void OPV_InitTDescs (OPT_Node n); -static void OPV_Len (OPT_Node n, int32 dim); +static void OPV_Len (OPT_Node n, int64 dim); export void OPV_Module (OPT_Node prog); static void OPV_NewArr (OPT_Node d, OPT_Node x); -static void OPV_ParIntLiteral (int32 n, int32 size); +static void OPV_ParIntLiteral (int64 n, int32 size); static int16 OPV_Precedence (int16 class, int16 subclass, int16 form, int16 comp); static BOOLEAN OPV_SideEffects (OPT_Node n); static void OPV_SizeCast (int32 from, int32 to); @@ -414,7 +414,7 @@ static int16 OPV_Precedence (int16 class, int16 subclass, int16 form, int16 comp __RETCHK; } -static void OPV_Len (OPT_Node n, int32 dim) +static void OPV_Len (OPT_Node n, int64 dim) { while ((n->class == 4 && n->typ->comp == 3)) { dim += 1; @@ -725,7 +725,7 @@ static void OPV_design (OPT_Node n, int16 prec) } } -static void OPV_ParIntLiteral (int32 n, int32 size) +static void OPV_ParIntLiteral (int64 n, int32 size) { if (OPV_ansi) { OPM_WriteInt(n); @@ -1210,7 +1210,7 @@ static void OPV_IfStat (OPT_Node n, BOOLEAN withtrap, OPT_Object outerProc) static void OPV_CaseStat (OPT_Node n, OPT_Object outerProc) { OPT_Node switchCase = NIL, label = NIL; - int32 low, high; + int64 low, high; int16 form, i; OPM_WriteString((CHAR*)"switch ", 8); OPV_expr(n->left, 12); @@ -1351,7 +1351,7 @@ static void OPV_stat (OPT_Node n, OPT_Object outerProc) OPV_ExitInfo saved; OPT_Node l = NIL, r = NIL; while ((n != NIL && OPM_noerr)) { - OPM_errpos = n->conval->intval; + OPM_errpos = OPM_Longint(n->conval->intval); if (n->class != 14) { OPC_BegStat(); } @@ -1625,7 +1625,7 @@ static void OPV_stat (OPT_Node n, OPT_Object outerProc) OPV_IfStat(n, n->subcl == 0, outerProc); break; case 28: - OPC_Halt(n->right->conval->intval); + OPC_Halt(OPM_Longint(n->right->conval->intval)); break; default: OPM_LogWStr((CHAR*)"unhandled case in OPV.expr, n^.class = ", 40); diff --git a/bootstrap/unix-48/Console.c b/bootstrap/unix-48/Console.c index 168abb08..10d0a39b 100644 --- a/bootstrap/unix-48/Console.c +++ b/bootstrap/unix-48/Console.c @@ -16,7 +16,7 @@ export void Console_Bool (BOOLEAN b); export void Console_Char (CHAR ch); export void Console_Flush (void); export void Console_Hex (int32 i); -export void Console_Int (int32 i, int32 n); +export void Console_Int (int64 i, int64 n); export void Console_Ln (void); export void Console_Read (CHAR *ch); export void Console_ReadLine (CHAR *line, LONGINT line__len); @@ -54,15 +54,15 @@ void Console_String (CHAR *s, LONGINT s__len) __DEL(s); } -void Console_Int (int32 i, int32 n) +void Console_Int (int64 i, int64 n) { CHAR s[32]; int32 i1, k; - if (i == __LSHL(1, 31, 32)) { + if (i == (int64)__LSHL(1, 31, 32)) { __MOVE("8463847412", s, 11); k = 10; } else { - i1 = __ABS(i); + i1 = __ABS(__VAL(int32, i)); s[0] = (CHAR)((int)__MOD(i1, 10) + 48); i1 = __DIV(i1, 10); k = 1; @@ -76,7 +76,7 @@ void Console_Int (int32 i, int32 n) s[__X(k, 32)] = '-'; k += 1; } - while (n > k) { + while (n > (int64)k) { Console_Char(' '); n -= 1; } diff --git a/bootstrap/unix-48/Console.h b/bootstrap/unix-48/Console.h index cca2c91e..e5dc1566 100644 --- a/bootstrap/unix-48/Console.h +++ b/bootstrap/unix-48/Console.h @@ -12,7 +12,7 @@ import void Console_Bool (BOOLEAN b); import void Console_Char (CHAR ch); import void Console_Flush (void); import void Console_Hex (int32 i); -import void Console_Int (int32 i, int32 n); +import void Console_Int (int64 i, int64 n); import void Console_Ln (void); import void Console_Read (CHAR *ch); import void Console_ReadLine (CHAR *line, LONGINT line__len); diff --git a/bootstrap/unix-48/Files.c b/bootstrap/unix-48/Files.c index a37ffdd3..6c934210 100644 --- a/bootstrap/unix-48/Files.c +++ b/bootstrap/unix-48/Files.c @@ -90,6 +90,7 @@ export void Files_ReadLInt (Files_Rider *R, LONGINT *R__typ, int32 *x); export void Files_ReadLReal (Files_Rider *R, LONGINT *R__typ, LONGREAL *x); export void Files_ReadLine (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len); export void Files_ReadNum (Files_Rider *R, LONGINT *R__typ, int32 *x); +export void Files_ReadNum64 (Files_Rider *R, LONGINT *R__typ, int64 *x); export void Files_ReadReal (Files_Rider *R, LONGINT *R__typ, REAL *x); export void Files_ReadSet (Files_Rider *R, LONGINT *R__typ, SET *x); export void Files_ReadString (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len); @@ -105,6 +106,7 @@ export void Files_WriteInt (Files_Rider *R, LONGINT *R__typ, int16 x); export void Files_WriteLInt (Files_Rider *R, LONGINT *R__typ, int32 x); export void Files_WriteLReal (Files_Rider *R, LONGINT *R__typ, LONGREAL x); export void Files_WriteNum (Files_Rider *R, LONGINT *R__typ, int32 x); +export void Files_WriteNum64 (Files_Rider *R, LONGINT *R__typ, int64 x); export void Files_WriteReal (Files_Rider *R, LONGINT *R__typ, REAL x); export void Files_WriteSet (Files_Rider *R, LONGINT *R__typ, SET x); export void Files_WriteString (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len); @@ -936,6 +938,13 @@ void Files_ReadNum (Files_Rider *R, LONGINT *R__typ, int32 *x) *x = n; } +void Files_ReadNum64 (Files_Rider *R, LONGINT *R__typ, int64 *x) +{ + int32 n; + Files_ReadNum(&*R, R__typ, &n); + *x = n; +} + void Files_WriteBool (Files_Rider *R, LONGINT *R__typ, BOOLEAN x) { Files_Write(&*R, R__typ, __VAL(CHAR, x)); @@ -1004,6 +1013,15 @@ void Files_WriteNum (Files_Rider *R, LONGINT *R__typ, int32 x) Files_Write(&*R, R__typ, (CHAR)__MASK(x, -128)); } +void Files_WriteNum64 (Files_Rider *R, LONGINT *R__typ, int64 x) +{ + while (x < -64 || x > 63) { + Files_Write(&*R, R__typ, (CHAR)(__MASK(x, -128) + 128)); + x = __ASHR(x, 7); + } + Files_Write(&*R, R__typ, (CHAR)__MASK(x, -128)); +} + void Files_GetName (Files_File f, CHAR *name, LONGINT name__len) { __COPY(f->workName, name, name__len); diff --git a/bootstrap/unix-48/Files.h b/bootstrap/unix-48/Files.h index c86d1186..0187d33f 100644 --- a/bootstrap/unix-48/Files.h +++ b/bootstrap/unix-48/Files.h @@ -47,6 +47,7 @@ import void Files_ReadLInt (Files_Rider *R, LONGINT *R__typ, int32 *x); import void Files_ReadLReal (Files_Rider *R, LONGINT *R__typ, LONGREAL *x); import void Files_ReadLine (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len); import void Files_ReadNum (Files_Rider *R, LONGINT *R__typ, int32 *x); +import void Files_ReadNum64 (Files_Rider *R, LONGINT *R__typ, int64 *x); import void Files_ReadReal (Files_Rider *R, LONGINT *R__typ, REAL *x); import void Files_ReadSet (Files_Rider *R, LONGINT *R__typ, SET *x); import void Files_ReadString (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len); @@ -61,6 +62,7 @@ import void Files_WriteInt (Files_Rider *R, LONGINT *R__typ, int16 x); import void Files_WriteLInt (Files_Rider *R, LONGINT *R__typ, int32 x); import void Files_WriteLReal (Files_Rider *R, LONGINT *R__typ, LONGREAL x); import void Files_WriteNum (Files_Rider *R, LONGINT *R__typ, int32 x); +import void Files_WriteNum64 (Files_Rider *R, LONGINT *R__typ, int64 x); import void Files_WriteReal (Files_Rider *R, LONGINT *R__typ, REAL x); import void Files_WriteSet (Files_Rider *R, LONGINT *R__typ, SET x); import void Files_WriteString (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len); diff --git a/bootstrap/unix-48/OPB.c b/bootstrap/unix-48/OPB.c index 90e93aed..47f2de21 100644 --- a/bootstrap/unix-48/OPB.c +++ b/bootstrap/unix-48/OPB.c @@ -12,7 +12,7 @@ export void (*OPB_typSize)(OPT_Struct); static int16 OPB_exp; -static int32 OPB_maxExp; +static int64 OPB_maxExp; export void OPB_Assign (OPT_Node *x, OPT_Node y); @@ -38,14 +38,14 @@ export void OPB_Field (OPT_Node *x, OPT_Object y); export void OPB_In (OPT_Node *x, OPT_Node y); export void OPB_Index (OPT_Node *x, OPT_Node y); export void OPB_Inittd (OPT_Node *inittd, OPT_Node *last, OPT_Struct typ); -static BOOLEAN OPB_IntToBool (int32 i); +static BOOLEAN OPB_IntToBool (int64 i); export void OPB_Link (OPT_Node *x, OPT_Node *last, OPT_Node y); export void OPB_MOp (int8 op, OPT_Node *x); export OPT_Node OPB_NewBoolConst (BOOLEAN boolval); -export OPT_Node OPB_NewIntConst (int32 intval); +export OPT_Node OPB_NewIntConst (int64 intval); export OPT_Node OPB_NewLeaf (OPT_Object obj); export OPT_Node OPB_NewRealConst (LONGREAL realval, OPT_Struct typ); -export OPT_Node OPB_NewString (OPS_String str, int32 len); +export OPT_Node OPB_NewString (OPS_String str, int64 len); export OPT_Node OPB_Nil (void); static BOOLEAN OPB_NotVar (OPT_Node x); export void OPB_Op (int8 op, OPT_Node *x, OPT_Node y); @@ -63,7 +63,7 @@ export void OPB_StParN (OPT_Node *par0, OPT_Node x, int16 fctno, int16 n); export void OPB_StaticLink (int8 dlev); export void OPB_TypTest (OPT_Node *x, OPT_Object obj, BOOLEAN guard); static void OPB_err (int16 n); -static int32 OPB_log (int32 x); +static int64 OPB_log (int64 x); static void OPB_err (int16 n) @@ -141,17 +141,11 @@ static int32 OPB_BoolToInt (BOOLEAN b) __RETCHK; } -static BOOLEAN OPB_IntToBool (int32 i) +static BOOLEAN OPB_IntToBool (int64 i) { BOOLEAN _o_result; - if (i == 0) { - _o_result = 0; - return _o_result; - } else { - _o_result = 1; - return _o_result; - } - __RETCHK; + _o_result = i != 0; + return _o_result; } OPT_Node OPB_NewBoolConst (BOOLEAN boolval) @@ -228,7 +222,7 @@ OPT_Node OPB_EmptySet (void) static void OPB_SetIntType (OPT_Node node) { int16 b; - int32 n; + int64 n; if (node->conval->intval >= 0) { n = node->conval->intval; } else { @@ -241,7 +235,7 @@ static void OPB_SetIntType (OPT_Node node) node->typ = OPT_IntType(b); } -OPT_Node OPB_NewIntConst (int32 intval) +OPT_Node OPB_NewIntConst (int64 intval) { OPT_Node _o_result; OPT_Node x = NIL; @@ -266,7 +260,7 @@ OPT_Node OPB_NewRealConst (LONGREAL realval, OPT_Struct typ) return _o_result; } -OPT_Node OPB_NewString (OPS_String str, int32 len) +OPT_Node OPB_NewString (OPS_String str, int64 len) { OPT_Node _o_result; OPT_Node x = NIL; @@ -274,7 +268,7 @@ OPT_Node OPB_NewString (OPS_String str, int32 len) x->conval = OPT_NewConst(); x->typ = OPT_stringtyp; x->conval->intval = -1; - x->conval->intval2 = len; + x->conval->intval2 = OPM_Longint(len); x->conval->ext = OPT_NewExt(); __COPY(str, *x->conval->ext, 256); _o_result = x; @@ -351,7 +345,7 @@ void OPB_Index (OPT_Node *x, OPT_Node y) } if ((*x)->typ->comp == 2) { typ = (*x)->typ->BaseTyp; - if ((y->class == 7 && (y->conval->intval < 0 || y->conval->intval >= (*x)->typ->n))) { + if ((y->class == 7 && (y->conval->intval < 0 || y->conval->intval >= (int64)(*x)->typ->n))) { OPB_err(81); } } else if ((*x)->typ->comp == 3) { @@ -466,14 +460,14 @@ void OPB_TypTest (OPT_Node *x, OPT_Object obj, BOOLEAN guard) void OPB_In (OPT_Node *x, OPT_Node y) { int16 f; - int32 k; + int64 k; f = (*x)->typ->form; if ((((*x)->class == 8 || (*x)->class == 9) || y->class == 8) || y->class == 9) { OPB_err(126); } else if ((f == 4 && y->typ->form == 7)) { if ((*x)->class == 7) { k = (*x)->conval->intval; - if (k < 0 || k > OPM_MaxSet) { + if (k < 0 || k > (int64)OPM_MaxSet) { OPB_err(202); } else if (y->class == 7) { (*x)->conval->intval = OPB_BoolToInt(__IN(k, y->conval->setval, 32)); @@ -492,9 +486,9 @@ void OPB_In (OPT_Node *x, OPT_Node y) (*x)->typ = OPT_booltyp; } -static int32 OPB_log (int32 x) +static int64 OPB_log (int64 x) { - int32 _o_result; + int64 _o_result; OPB_exp = 0; if (x > 0) { while (!__ODD(x)) { @@ -580,7 +574,7 @@ void OPB_MOp (int8 op, OPT_Node *x) if (__IN(f, 0xf0, 32)) { if (z->class == 7) { if (f == 4) { - if (z->conval->intval == (-2147483647-1)) { + if (z->conval->intval == (-9223372036854775807-1)) { OPB_err(203); } else { z->conval->intval = -z->conval->intval; @@ -603,7 +597,7 @@ void OPB_MOp (int8 op, OPT_Node *x) if (__IN(f, 0x70, 32)) { if (z->class == 7) { if (f == 4) { - if (z->conval->intval == (-2147483647-1)) { + if (z->conval->intval == (-9223372036854775807-1)) { OPB_err(203); } else { z->conval->intval = __ABS(z->conval->intval); @@ -845,7 +839,7 @@ static void OPB_ConstOp (int16 op, OPT_Node x, OPT_Node y) { int16 f, g; OPT_Const xval = NIL, yval = NIL; - int32 xv, yv; + int64 xv, yv; BOOLEAN temp; struct ConstOp__13 _s; _s.x = &x; @@ -1007,7 +1001,7 @@ static void OPB_ConstOp (int16 op, OPT_Node x, OPT_Node y) case 4: if (f == 4) { if (yval->intval != 0) { - xval->intval = (int)__MOD(xval->intval, yval->intval); + xval->intval = __MOD(xval->intval, yval->intval); OPB_SetIntType(x); } else { OPB_err(205); @@ -1122,7 +1116,7 @@ static void OPB_Convert (OPT_Node *x, OPT_Struct typ) { OPT_Node node = NIL; int16 f, g; - int32 k; + int64 k; LONGREAL r; f = (*x)->typ->form; g = typ->form; @@ -1229,7 +1223,7 @@ void OPB_Op (int8 op, OPT_Node *x, OPT_Node y) OPT_Node t = NIL, z = NIL; OPT_Struct typ = NIL; BOOLEAN do_; - int32 val; + int64 val; struct Op__38 _s; _s.f = &f; _s.g = &g; @@ -1500,19 +1494,19 @@ void OPB_Op (int8 op, OPT_Node *x, OPT_Node y) void OPB_SetRange (OPT_Node *x, OPT_Node y) { - int32 k, l; + int64 k, l; if ((((*x)->class == 8 || (*x)->class == 9) || y->class == 8) || y->class == 9) { OPB_err(126); } else if (((*x)->typ->form == 4 && y->typ->form == 4)) { if ((*x)->class == 7) { k = (*x)->conval->intval; - if (0 > k || k > OPM_MaxSet) { + if (0 > k || k > (int64)OPM_MaxSet) { OPB_err(202); } } if (y->class == 7) { l = y->conval->intval; - if (0 > l || l > OPM_MaxSet) { + if (0 > l || l > (int64)OPM_MaxSet) { OPB_err(202); } } @@ -1535,14 +1529,14 @@ void OPB_SetRange (OPT_Node *x, OPT_Node y) void OPB_SetElem (OPT_Node *x) { - int32 k; + int64 k; if ((*x)->class == 8 || (*x)->class == 9) { OPB_err(126); } else if ((*x)->typ->form != 4) { OPB_err(93); } else if ((*x)->class == 7) { k = (*x)->conval->intval; - if ((0 <= k && k <= OPM_MaxSet)) { + if ((0 <= k && k <= (int64)OPM_MaxSet)) { (*x)->conval->setval = __SETOF(k,32); } else { OPB_err(202); @@ -1917,7 +1911,7 @@ void OPB_StPar0 (OPT_Node *par0, int16 fctno) if (x->class == 8 || x->class == 9) { OPB_err(126); } else if (f == 4) { - if (x->typ->size != OPT_linttyp->size) { + if (x->typ->size < OPT_linttyp->size) { OPB_Convert(&x, OPT_linttyp); } } else { @@ -2055,7 +2049,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, int8 fctno) if (x->class == 8 || x->class == 9) { OPB_err(126); } else if (f == 4) { - if ((x->class == 7 && (0 > x->conval->intval || x->conval->intval > OPM_MaxSet))) { + if ((x->class == 7 && (0 > x->conval->intval || x->conval->intval > (int64)OPM_MaxSet))) { OPB_err(202); } p = NewOp__53(19, fctno, p, x); @@ -2068,7 +2062,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, int8 fctno) if (!(f == 4) || x->class != 7) { OPB_err(69); } else if (x->typ->size == 1) { - L = (int16)x->conval->intval; + L = OPM_Integer(x->conval->intval); typ = p->typ; while ((L > 0 && __IN(typ->comp, 0x0c, 32))) { typ = typ->BaseTyp; @@ -2120,8 +2114,8 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, int8 fctno) OPB_err(208); p->conval->intval = 1; } else if (x->conval->intval >= 0) { - if (__ABS(p->conval->intval) <= __DIV(2147483647, __ASH(1, x->conval->intval))) { - p->conval->intval = p->conval->intval * __ASH(1, x->conval->intval); + if (__ABS(p->conval->intval) <= __DIV(9223372036854775807, (int64)__ASH(1, x->conval->intval))) { + p->conval->intval = p->conval->intval * (int64)__ASH(1, x->conval->intval); } else { OPB_err(208); p->conval->intval = 1; @@ -2132,7 +2126,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, int8 fctno) p->obj = NIL; } else { p = NewOp__53(12, 17, p, x); - p->typ = OPT_linttyp; + p->typ = p->left->typ; } } else { OPB_err(111); @@ -2143,7 +2137,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, int8 fctno) OPB_err(126); } else if (p->typ->comp == 3) { if (f == 4) { - if ((x->class == 7 && (x->conval->intval <= 0 || x->conval->intval > OPM_MaxIndex))) { + if ((x->class == 7 && (x->conval->intval <= 0 || x->conval->intval > (int64)OPM_MaxIndex))) { OPB_err(63); } } else { @@ -2281,7 +2275,7 @@ void OPB_StParN (OPT_Node *par0, OPT_Node x, int16 fctno, int16 n) } else if (p->typ->comp != 3) { OPB_err(64); } else if (f == 4) { - if ((x->class == 7 && (x->conval->intval <= 0 || x->conval->intval > OPM_MaxIndex))) { + if ((x->class == 7 && (x->conval->intval <= 0 || x->conval->intval > (int64)OPM_MaxIndex))) { OPB_err(63); } node = p->right; @@ -2622,7 +2616,7 @@ export void *OPB__init(void) __MODULE_IMPORT(OPT); __REGMOD("OPB", 0); /* BEGIN */ - OPB_maxExp = OPB_log(1073741824); + OPB_maxExp = OPB_log(4611686018427387904); OPB_maxExp = OPB_exp; __ENDMOD; } diff --git a/bootstrap/unix-48/OPB.h b/bootstrap/unix-48/OPB.h index 183a5f32..08d025bf 100644 --- a/bootstrap/unix-48/OPB.h +++ b/bootstrap/unix-48/OPB.h @@ -25,10 +25,10 @@ import void OPB_Inittd (OPT_Node *inittd, OPT_Node *last, OPT_Struct typ); import void OPB_Link (OPT_Node *x, OPT_Node *last, OPT_Node y); import void OPB_MOp (int8 op, OPT_Node *x); import OPT_Node OPB_NewBoolConst (BOOLEAN boolval); -import OPT_Node OPB_NewIntConst (int32 intval); +import OPT_Node OPB_NewIntConst (int64 intval); import OPT_Node OPB_NewLeaf (OPT_Object obj); import OPT_Node OPB_NewRealConst (LONGREAL realval, OPT_Struct typ); -import OPT_Node OPB_NewString (OPS_String str, int32 len); +import OPT_Node OPB_NewString (OPS_String str, int64 len); import OPT_Node OPB_Nil (void); import void OPB_Op (int8 op, OPT_Node *x, OPT_Node y); import void OPB_OptIf (OPT_Node *x); diff --git a/bootstrap/unix-48/OPC.c b/bootstrap/unix-48/OPC.c index 17690465..c21e44a4 100644 --- a/bootstrap/unix-48/OPC.c +++ b/bootstrap/unix-48/OPC.c @@ -26,8 +26,8 @@ export OPT_Object OPC_BaseTProc (OPT_Object obj); export void OPC_BegBlk (void); export void OPC_BegStat (void); static void OPC_CProcDefs (OPT_Object obj, int16 vis); -export void OPC_Case (int32 caseVal, int16 form); -static void OPC_CharacterLiteral (int32 c); +export void OPC_Case (int64 caseVal, int16 form); +static void OPC_CharacterLiteral (int64 c); export void OPC_Cmp (int16 rel); export void OPC_CompleteIdent (OPT_Object obj); export void OPC_Constant (OPT_Const con, int16 form); @@ -67,8 +67,8 @@ static void OPC_InitImports (OPT_Object obj); static void OPC_InitKeywords (void); export void OPC_InitTDesc (OPT_Struct typ); static void OPC_InitTProcs (OPT_Object typ, OPT_Object obj); -export void OPC_IntLiteral (int32 n, int32 size); -export void OPC_Len (OPT_Object obj, OPT_Struct array, int32 dim); +export void OPC_IntLiteral (int64 n, int32 size); +export void OPC_Len (OPT_Object obj, OPT_Struct array, int64 dim); static void OPC_LenList (OPT_Object par, BOOLEAN ansiDefine, BOOLEAN showParamName); static int16 OPC_Length (CHAR *s, LONGINT s__len); export int32 OPC_NofPtrs (OPT_Struct typ); @@ -1851,7 +1851,7 @@ void OPC_Cmp (int16 rel) } } -static void OPC_CharacterLiteral (int32 c) +static void OPC_CharacterLiteral (int64 c) { if (c < 32 || c > 126) { OPM_WriteString((CHAR*)"0x", 3); @@ -1894,7 +1894,7 @@ static void OPC_StringLiteral (CHAR *s, LONGINT s__len, int32 l) __DEL(s); } -void OPC_Case (int32 caseVal, int16 form) +void OPC_Case (int64 caseVal, int16 form) { CHAR ch; OPM_WriteString((CHAR*)"case ", 6); @@ -1937,7 +1937,7 @@ void OPC_Halt (int32 n) OPC_Str1((CHAR*)"__HALT(#)", 10, n); } -void OPC_IntLiteral (int32 n, int32 size) +void OPC_IntLiteral (int64 n, int32 size) { if ((((size > 4 && n <= 2147483647)) && n > (-2147483647-1))) { OPM_WriteString((CHAR*)"((int", 6); @@ -1950,7 +1950,7 @@ void OPC_IntLiteral (int32 n, int32 size) } } -void OPC_Len (OPT_Object obj, OPT_Struct array, int32 dim) +void OPC_Len (OPT_Object obj, OPT_Struct array, int64 dim) { if (array->comp == 3) { OPC_CompleteIdent(obj); diff --git a/bootstrap/unix-48/OPC.h b/bootstrap/unix-48/OPC.h index 34d9ebc2..9e1ec652 100644 --- a/bootstrap/unix-48/OPC.h +++ b/bootstrap/unix-48/OPC.h @@ -15,7 +15,7 @@ import int32 OPC_BaseAlignment (OPT_Struct typ); import OPT_Object OPC_BaseTProc (OPT_Object obj); import void OPC_BegBlk (void); import void OPC_BegStat (void); -import void OPC_Case (int32 caseVal, int16 form); +import void OPC_Case (int64 caseVal, int16 form); import void OPC_Cmp (int16 rel); import void OPC_CompleteIdent (OPT_Object obj); import void OPC_Constant (OPT_Const con, int16 form); @@ -37,8 +37,8 @@ import void OPC_Increment (BOOLEAN decrement); import void OPC_Indent (int16 count); import void OPC_Init (void); import void OPC_InitTDesc (OPT_Struct typ); -import void OPC_IntLiteral (int32 n, int32 size); -import void OPC_Len (OPT_Object obj, OPT_Struct array, int32 dim); +import void OPC_IntLiteral (int64 n, int32 size); +import void OPC_Len (OPT_Object obj, OPT_Struct array, int64 dim); import int32 OPC_NofPtrs (OPT_Struct typ); import void OPC_SetInclude (BOOLEAN exclude); import int32 OPC_SizeAlignment (int32 size); diff --git a/bootstrap/unix-48/OPM.c b/bootstrap/unix-48/OPM.c index 18478d1e..ba86c00a 100644 --- a/bootstrap/unix-48/OPM.c +++ b/bootstrap/unix-48/OPM.c @@ -28,7 +28,8 @@ export int16 OPM_currFile, OPM_level, OPM_pc, OPM_entno; export CHAR OPM_modName[32]; export CHAR OPM_objname[64]; export SET OPM_opt, OPM_glbopt; -static int32 OPM_ErrorLineStartPos, OPM_ErrorLineLimitPos, OPM_ErrorLineNumber, OPM_lasterrpos; +static int32 OPM_ErrorLineStartPos, OPM_ErrorLineLimitPos, OPM_ErrorLineNumber; +static int64 OPM_lasterrpos; static Texts_Reader OPM_inR; static Texts_Text OPM_Log; static Texts_Writer OPM_W; @@ -45,46 +46,49 @@ static void OPM_Append (Files_Rider *R, LONGINT *R__typ, Files_File F); export void OPM_CloseFiles (void); export void OPM_CloseOldSym (void); export void OPM_DeleteNewSym (void); -export void OPM_FPrint (int32 *fp, int32 val); +export void OPM_FPrint (int32 *fp, int64 val); export void OPM_FPrintLReal (int32 *fp, LONGREAL lr); export void OPM_FPrintReal (int32 *fp, REAL real); export void OPM_FPrintSet (int32 *fp, SET set); -static void OPM_FindLine (Files_File f, Files_Rider *r, LONGINT *r__typ, int32 pos); +static void OPM_FindLine (Files_File f, Files_Rider *r, LONGINT *r__typ, int64 pos); export void OPM_Get (CHAR *ch); static void OPM_GetProperties (void); static void OPM_GetProperty (Texts_Scanner *S, LONGINT *S__typ, CHAR *name, LONGINT name__len, int16 *size, int16 *align); export void OPM_Init (BOOLEAN *done, CHAR *mname, LONGINT mname__len); export void OPM_InitOptions (void); +export int16 OPM_Integer (int64 n); static void OPM_LogErrMsg (int16 n); export void OPM_LogW (CHAR ch); export void OPM_LogWLn (void); -export void OPM_LogWNum (int32 i, int32 len); +export void OPM_LogWNum (int64 i, int64 len); export void OPM_LogWStr (CHAR *s, LONGINT s__len); +export int32 OPM_Longint (int64 n); static void OPM_MakeFileName (CHAR *name, LONGINT name__len, CHAR *FName, LONGINT FName__len, CHAR *ext, LONGINT ext__len); -export void OPM_Mark (int16 n, int32 pos); +export void OPM_Mark (int16 n, int64 pos); export void OPM_NewSym (CHAR *modName, LONGINT modName__len); export void OPM_OldSym (CHAR *modName, LONGINT modName__len, BOOLEAN *done); export void OPM_OpenFiles (CHAR *moduleName, LONGINT moduleName__len); export BOOLEAN OPM_OpenPar (void); export void OPM_RegisterNewSym (void); static void OPM_ScanOptions (CHAR *s, LONGINT s__len, SET *opt); -static void OPM_ShowLine (int32 pos); +static void OPM_ShowLine (int64 pos); export int32 OPM_SignedMaximum (int32 bytecount); export int32 OPM_SignedMinimum (int32 bytecount); export void OPM_SymRCh (CHAR *ch); export int32 OPM_SymRInt (void); +export int64 OPM_SymRInt64 (void); export void OPM_SymRLReal (LONGREAL *lr); export void OPM_SymRReal (REAL *r); export void OPM_SymRSet (SET *s); export void OPM_SymWCh (CHAR ch); -export void OPM_SymWInt (int32 i); +export void OPM_SymWInt (int64 i); export void OPM_SymWLReal (LONGREAL lr); export void OPM_SymWReal (REAL r); export void OPM_SymWSet (SET s); static void OPM_VerboseListSizes (void); export void OPM_Write (CHAR ch); -export void OPM_WriteHex (int32 i); -export void OPM_WriteInt (int32 i); +export void OPM_WriteHex (int64 i); +export void OPM_WriteInt (int64 i); export void OPM_WriteLn (void); export void OPM_WriteReal (LONGREAL r, CHAR suffx); export void OPM_WriteString (CHAR *s, LONGINT s__len); @@ -107,7 +111,7 @@ void OPM_LogWStr (CHAR *s, LONGINT s__len) __DEL(s); } -void OPM_LogWNum (int32 i, int32 len) +void OPM_LogWNum (int64 i, int64 len) { Console_Int(i, len); } @@ -117,6 +121,20 @@ void OPM_LogWLn (void) Console_Ln(); } +int32 OPM_Longint (int64 n) +{ + int32 _o_result; + _o_result = __VAL(int32, n); + return _o_result; +} + +int16 OPM_Integer (int64 n) +{ + int16 _o_result; + _o_result = __VAL(int16, n); + return _o_result; +} + static void OPM_ScanOptions (CHAR *s, LONGINT s__len, SET *opt) { int16 i; @@ -404,21 +422,21 @@ static void OPM_LogErrMsg (int16 n) OPM_LogWStr(errors_errors[__X(n, 350)], 128); } -static void OPM_FindLine (Files_File f, Files_Rider *r, LONGINT *r__typ, int32 pos) +static void OPM_FindLine (Files_File f, Files_Rider *r, LONGINT *r__typ, int64 pos) { CHAR ch, cheol; - if (pos < OPM_ErrorLineStartPos) { + if (pos < (int64)OPM_ErrorLineStartPos) { OPM_ErrorLineStartPos = 0; OPM_ErrorLineLimitPos = 0; OPM_ErrorLineNumber = 0; } - if (pos < OPM_ErrorLineLimitPos) { + if (pos < (int64)OPM_ErrorLineLimitPos) { Files_Set(&*r, r__typ, f, OPM_ErrorLineStartPos); return; } Files_Set(&*r, r__typ, f, OPM_ErrorLineLimitPos); Files_Read(&*r, r__typ, (void*)&ch); - while ((OPM_ErrorLineLimitPos < pos && !(*r).eof)) { + while (((int64)OPM_ErrorLineLimitPos < pos && !(*r).eof)) { OPM_ErrorLineStartPos = OPM_ErrorLineLimitPos; OPM_ErrorLineNumber += 1; while ((((ch != 0x00 && ch != 0x0d)) && ch != 0x0a)) { @@ -436,7 +454,7 @@ static void OPM_FindLine (Files_File f, Files_Rider *r, LONGINT *r__typ, int32 p Files_Set(&*r, r__typ, f, OPM_ErrorLineStartPos); } -static void OPM_ShowLine (int32 pos) +static void OPM_ShowLine (int64 pos) { Files_File f = NIL; Files_Rider r; @@ -460,10 +478,10 @@ static void OPM_ShowLine (int32 pos) OPM_LogWStr(line, 1023); OPM_LogWLn(); OPM_LogWStr((CHAR*)" ", 7); - if (pos >= OPM_ErrorLineLimitPos) { + if (pos >= (int64)OPM_ErrorLineLimitPos) { pos = OPM_ErrorLineLimitPos - 1; } - i = (int16)(pos - OPM_ErrorLineStartPos); + i = (int16)OPM_Longint(pos - (int64)OPM_ErrorLineStartPos); while (i > 0) { OPM_LogW(' '); i -= 1; @@ -478,7 +496,7 @@ static void OPM_ShowLine (int32 pos) Files_Close(f); } -void OPM_Mark (int16 n, int32 pos) +void OPM_Mark (int16 n, int64 pos) { if (pos == -1) { pos = 0; @@ -535,9 +553,9 @@ void OPM_err (int16 n) OPM_Mark(n, OPM_errpos); } -void OPM_FPrint (int32 *fp, int32 val) +void OPM_FPrint (int32 *fp, int64 val) { - *fp = __ROTL((int32)((SET)*fp ^ (SET)val), 1, 32); + *fp = __ROTL((int32)((SET)*fp ^ __VAL(SET, val)), 1, 32); } void OPM_FPrintSet (int32 *fp, SET set) @@ -702,6 +720,15 @@ int32 OPM_SymRInt (void) return _o_result; } +int64 OPM_SymRInt64 (void) +{ + int64 _o_result; + int64 k; + Files_ReadNum64(&OPM_oldSF, Files_Rider__typ, &k); + _o_result = k; + return _o_result; +} + void OPM_SymRSet (SET *s) { Files_ReadNum(&OPM_oldSF, Files_Rider__typ, (int32*)&*s); @@ -751,9 +778,9 @@ void OPM_SymWCh (CHAR ch) Files_Write(&OPM_newSF, Files_Rider__typ, ch); } -void OPM_SymWInt (int32 i) +void OPM_SymWInt (int64 i) { - Files_WriteNum(&OPM_newSF, Files_Rider__typ, i); + Files_WriteNum64(&OPM_newSF, Files_Rider__typ, i); } void OPM_SymWSet (SET s) @@ -820,17 +847,17 @@ void OPM_WriteStringVar (CHAR *s, LONGINT s__len) Files_WriteBytes(&OPM_R[__X(OPM_currFile, 3)], Files_Rider__typ, (void*)s, s__len * 1, i); } -void OPM_WriteHex (int32 i) +void OPM_WriteHex (int64 i) { CHAR s[3]; - int16 digit; - digit = __ASHR((int16)i, 4); + int32 digit; + digit = __ASHR((int32)i, 4); if (digit < 10) { s[0] = (CHAR)(48 + digit); } else { s[0] = (CHAR)(87 + digit); } - digit = __MASK((int16)i, -16); + digit = __MASK((int32)i, -16); if (digit < 10) { s[1] = (CHAR)(48 + digit); } else { @@ -840,31 +867,31 @@ void OPM_WriteHex (int32 i) OPM_WriteString(s, 3); } -void OPM_WriteInt (int32 i) +void OPM_WriteInt (int64 i) { - CHAR s[20]; - int32 i1, k; - if (i == OPM_SignedMinimum(OPM_IntSize) || i == OPM_SignedMinimum(OPM_LIntSize)) { + CHAR s[24]; + int64 i1, k; + if ((i == (int64)OPM_SignedMinimum(OPM_IntSize) || i == (int64)OPM_SignedMinimum(OPM_LIntSize)) || i == (int64)OPM_SignedMinimum(8)) { OPM_Write('('); OPM_WriteInt(i + 1); OPM_WriteString((CHAR*)"-1)", 4); } else { i1 = __ABS(i); - s[0] = (CHAR)((int)__MOD(i1, 10) + 48); + s[0] = (CHAR)(__MOD(i1, 10) + 48); i1 = __DIV(i1, 10); k = 1; while (i1 > 0) { - s[__X(k, 20)] = (CHAR)((int)__MOD(i1, 10) + 48); + s[__X(k, 24)] = (CHAR)(__MOD(i1, 10) + 48); i1 = __DIV(i1, 10); k += 1; } if (i < 0) { - s[__X(k, 20)] = '-'; + s[__X(k, 24)] = '-'; k += 1; } while (k > 0) { k -= 1; - OPM_Write(s[__X(k, 20)]); + OPM_Write(s[__X(k, 24)]); } } } diff --git a/bootstrap/unix-48/OPM.h b/bootstrap/unix-48/OPM.h index a36522a1..504519da 100644 --- a/bootstrap/unix-48/OPM.h +++ b/bootstrap/unix-48/OPM.h @@ -21,18 +21,20 @@ import BOOLEAN OPM_dontAsm, OPM_dontLink, OPM_mainProg, OPM_mainLinkStat, OPM_no import void OPM_CloseFiles (void); import void OPM_CloseOldSym (void); import void OPM_DeleteNewSym (void); -import void OPM_FPrint (int32 *fp, int32 val); +import void OPM_FPrint (int32 *fp, int64 val); import void OPM_FPrintLReal (int32 *fp, LONGREAL lr); import void OPM_FPrintReal (int32 *fp, REAL real); import void OPM_FPrintSet (int32 *fp, SET set); import void OPM_Get (CHAR *ch); import void OPM_Init (BOOLEAN *done, CHAR *mname, LONGINT mname__len); import void OPM_InitOptions (void); +import int16 OPM_Integer (int64 n); import void OPM_LogW (CHAR ch); import void OPM_LogWLn (void); -import void OPM_LogWNum (int32 i, int32 len); +import void OPM_LogWNum (int64 i, int64 len); import void OPM_LogWStr (CHAR *s, LONGINT s__len); -import void OPM_Mark (int16 n, int32 pos); +import int32 OPM_Longint (int64 n); +import void OPM_Mark (int16 n, int64 pos); import void OPM_NewSym (CHAR *modName, LONGINT modName__len); import void OPM_OldSym (CHAR *modName, LONGINT modName__len, BOOLEAN *done); import void OPM_OpenFiles (CHAR *moduleName, LONGINT moduleName__len); @@ -42,17 +44,18 @@ import int32 OPM_SignedMaximum (int32 bytecount); import int32 OPM_SignedMinimum (int32 bytecount); import void OPM_SymRCh (CHAR *ch); import int32 OPM_SymRInt (void); +import int64 OPM_SymRInt64 (void); import void OPM_SymRLReal (LONGREAL *lr); import void OPM_SymRReal (REAL *r); import void OPM_SymRSet (SET *s); import void OPM_SymWCh (CHAR ch); -import void OPM_SymWInt (int32 i); +import void OPM_SymWInt (int64 i); import void OPM_SymWLReal (LONGREAL lr); import void OPM_SymWReal (REAL r); import void OPM_SymWSet (SET s); import void OPM_Write (CHAR ch); -import void OPM_WriteHex (int32 i); -import void OPM_WriteInt (int32 i); +import void OPM_WriteHex (int64 i); +import void OPM_WriteInt (int64 i); import void OPM_WriteLn (void); import void OPM_WriteReal (LONGREAL r, CHAR suffx); import void OPM_WriteString (CHAR *s, LONGINT s__len); diff --git a/bootstrap/unix-48/OPP.c b/bootstrap/unix-48/OPP.c index 8db5ef60..44ce8ff1 100644 --- a/bootstrap/unix-48/OPP.c +++ b/bootstrap/unix-48/OPP.c @@ -134,7 +134,7 @@ static void OPP_CheckMark (int8 *vis) static void OPP_CheckSysFlag (int16 *sysflag, int16 default_) { OPT_Node x = NIL; - int32 sf; + int64 sf; if (OPP_sym == 31) { OPS_Get(&OPP_sym); if (!OPT_SYSimported) { @@ -151,7 +151,7 @@ static void OPP_CheckSysFlag (int16 *sysflag, int16 default_) OPP_err(51); sf = 0; } - *sysflag = (int16)sf; + *sysflag = OPM_Integer(sf); OPP_CheckSym(23); } else { *sysflag = default_; @@ -254,7 +254,7 @@ static void OPP_RecordType (OPT_Struct *typ, OPT_Struct *banned) static void OPP_ArrayType (OPT_Struct *typ, OPT_Struct *banned) { OPT_Node x = NIL; - int32 n; + int64 n; int16 sysflag; OPP_CheckSysFlag(&sysflag, 0); if (OPP_sym == 25) { @@ -275,7 +275,7 @@ static void OPP_ArrayType (OPT_Struct *typ, OPT_Struct *banned) OPP_ConstExpression(&x); if (x->typ->form == 4) { n = x->conval->intval; - if (n <= 0 || n > OPM_MaxIndex) { + if (n <= 0 || n > (int64)OPM_MaxIndex) { OPP_err(63); n = 1; } @@ -283,7 +283,7 @@ static void OPP_ArrayType (OPT_Struct *typ, OPT_Struct *banned) OPP_err(51); n = 1; } - (*typ)->n = n; + (*typ)->n = OPM_Longint(n); if (OPP_sym == 25) { OPS_Get(&OPP_sym); OPP_Type(&(*typ)->BaseTyp, &*banned); @@ -932,7 +932,7 @@ static void GetCode__19 (void) { OPT_ConstExt ext = NIL; int16 n; - int32 c; + int64 c; ext = OPT_NewExt(); (*ProcedureDeclaration__16_s->proc)->conval->ext = ext; n = 0; @@ -1179,7 +1179,7 @@ static void OPP_CaseLabelList (OPT_Node *lab, OPT_Struct LabelTyp, int16 *n, OPP OPP_ConstExpression(&x); f = x->typ->form; if (__IN(f, 0x18, 32)) { - xval = x->conval->intval; + xval = OPM_Longint(x->conval->intval); } else { OPP_err(61); xval = 1; @@ -1194,7 +1194,7 @@ static void OPP_CaseLabelList (OPT_Node *lab, OPT_Struct LabelTyp, int16 *n, OPP if (OPP_sym == 21) { OPS_Get(&OPP_sym); OPP_ConstExpression(&y); - yval = y->conval->intval; + yval = OPM_Longint(y->conval->intval); if (((int16)y->typ->form != f && !((f == 4 && y->typ->form == 4)))) { OPP_err(60); } diff --git a/bootstrap/unix-48/OPS.c b/bootstrap/unix-48/OPS.c index fb0f2237..f80ca2b1 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 int32 OPS_intval; +export int64 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) + Ord__7(dig[i], 1); + OPS_intval = __ASHL(OPS_intval, 4) + (int64)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) + Ord__7(dig[i], 1); + OPS_intval = __ASHL(OPS_intval, 4) + (int64)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 ((int64)OPS_intval <= __DIV(9223372036854775807 - (int64)d, 10)) { - OPS_intval = OPS_intval * 10 + d; + if (OPS_intval <= __DIV(9223372036854775807 - (int64)d, 10)) { + OPS_intval = OPS_intval * 10 + (int64)d; } else { OPS_err(203); } diff --git a/bootstrap/unix-48/OPS.h b/bootstrap/unix-48/OPS.h index d2b5dfb4..d33103c1 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 int32 OPS_intval; +import int64 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 83a2652b..fa5401ee 100644 --- a/bootstrap/unix-48/OPT.c +++ b/bootstrap/unix-48/OPT.c @@ -17,7 +17,8 @@ typedef typedef struct OPT_ConstDesc { OPT_ConstExt ext; - int32 intval, intval2; + int64 intval; + int32 intval2; SET setval; LONGREAL realval; } OPT_ConstDesc; @@ -1838,7 +1839,7 @@ static void EnumPtrs(void (*P)(void*)) __ENUMR(&OPT_impCtxt, OPT_ImpCtxt__typ, 3140, 1, P); } -__TDESC(OPT_ConstDesc, 1, 1) = {__TDFLDS("ConstDesc", 24), {0, -8}}; +__TDESC(OPT_ConstDesc, 1, 1) = {__TDFLDS("ConstDesc", 32), {0, -8}}; __TDESC(OPT_ObjDesc, 1, 6) = {__TDFLDS("ObjDesc", 304), {0, 4, 8, 12, 284, 288, -28}}; __TDESC(OPT_StrDesc, 1, 3) = {__TDFLDS("StrDesc", 56), {44, 48, 52, -16}}; __TDESC(OPT_NodeDesc, 1, 6) = {__TDFLDS("NodeDesc", 28), {0, 4, 8, 16, 20, 24, -28}}; diff --git a/bootstrap/unix-48/OPT.h b/bootstrap/unix-48/OPT.h index d4b49da8..b6566702 100644 --- a/bootstrap/unix-48/OPT.h +++ b/bootstrap/unix-48/OPT.h @@ -15,7 +15,8 @@ typedef typedef struct OPT_ConstDesc { OPT_ConstExt ext; - int32 intval, intval2; + int64 intval; + int32 intval2; SET setval; LONGREAL realval; } OPT_ConstDesc; diff --git a/bootstrap/unix-48/OPV.c b/bootstrap/unix-48/OPV.c index a32351aa..cddb737c 100644 --- a/bootstrap/unix-48/OPV.c +++ b/bootstrap/unix-48/OPV.c @@ -36,10 +36,10 @@ static BOOLEAN OPV_ImplicitReturn (OPT_Node n); static void OPV_Index (OPT_Node n, OPT_Node d, int16 prec, int16 dim); export void OPV_Init (void); static void OPV_InitTDescs (OPT_Node n); -static void OPV_Len (OPT_Node n, int32 dim); +static void OPV_Len (OPT_Node n, int64 dim); export void OPV_Module (OPT_Node prog); static void OPV_NewArr (OPT_Node d, OPT_Node x); -static void OPV_ParIntLiteral (int32 n, int32 size); +static void OPV_ParIntLiteral (int64 n, int32 size); static int16 OPV_Precedence (int16 class, int16 subclass, int16 form, int16 comp); static BOOLEAN OPV_SideEffects (OPT_Node n); static void OPV_SizeCast (int32 from, int32 to); @@ -414,7 +414,7 @@ static int16 OPV_Precedence (int16 class, int16 subclass, int16 form, int16 comp __RETCHK; } -static void OPV_Len (OPT_Node n, int32 dim) +static void OPV_Len (OPT_Node n, int64 dim) { while ((n->class == 4 && n->typ->comp == 3)) { dim += 1; @@ -725,7 +725,7 @@ static void OPV_design (OPT_Node n, int16 prec) } } -static void OPV_ParIntLiteral (int32 n, int32 size) +static void OPV_ParIntLiteral (int64 n, int32 size) { if (OPV_ansi) { OPM_WriteInt(n); @@ -1210,7 +1210,7 @@ static void OPV_IfStat (OPT_Node n, BOOLEAN withtrap, OPT_Object outerProc) static void OPV_CaseStat (OPT_Node n, OPT_Object outerProc) { OPT_Node switchCase = NIL, label = NIL; - int32 low, high; + int64 low, high; int16 form, i; OPM_WriteString((CHAR*)"switch ", 8); OPV_expr(n->left, 12); @@ -1351,7 +1351,7 @@ static void OPV_stat (OPT_Node n, OPT_Object outerProc) OPV_ExitInfo saved; OPT_Node l = NIL, r = NIL; while ((n != NIL && OPM_noerr)) { - OPM_errpos = n->conval->intval; + OPM_errpos = OPM_Longint(n->conval->intval); if (n->class != 14) { OPC_BegStat(); } @@ -1625,7 +1625,7 @@ static void OPV_stat (OPT_Node n, OPT_Object outerProc) OPV_IfStat(n, n->subcl == 0, outerProc); break; case 28: - OPC_Halt(n->right->conval->intval); + OPC_Halt(OPM_Longint(n->right->conval->intval)); break; default: OPM_LogWStr((CHAR*)"unhandled case in OPV.expr, n^.class = ", 40); diff --git a/bootstrap/unix-88/Console.c b/bootstrap/unix-88/Console.c index f7769827..845cce11 100644 --- a/bootstrap/unix-88/Console.c +++ b/bootstrap/unix-88/Console.c @@ -62,7 +62,7 @@ void Console_Int (int64 i, int64 n) __MOVE("8085774586302733229", s, 20); k = 19; } else { - i1 = __ABS(i); + i1 = __ABS((int64)i); s[0] = (CHAR)(__MOD(i1, 10) + 48); i1 = __DIV(i1, 10); k = 1; diff --git a/bootstrap/unix-88/Files.c b/bootstrap/unix-88/Files.c index 4c6982cc..2b23754f 100644 --- a/bootstrap/unix-88/Files.c +++ b/bootstrap/unix-88/Files.c @@ -90,6 +90,7 @@ export void Files_ReadLInt (Files_Rider *R, LONGINT *R__typ, int64 *x); export void Files_ReadLReal (Files_Rider *R, LONGINT *R__typ, LONGREAL *x); export void Files_ReadLine (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len); export void Files_ReadNum (Files_Rider *R, LONGINT *R__typ, int64 *x); +export void Files_ReadNum64 (Files_Rider *R, LONGINT *R__typ, int64 *x); export void Files_ReadReal (Files_Rider *R, LONGINT *R__typ, REAL *x); export void Files_ReadSet (Files_Rider *R, LONGINT *R__typ, SET *x); export void Files_ReadString (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len); @@ -105,6 +106,7 @@ export void Files_WriteInt (Files_Rider *R, LONGINT *R__typ, int32 x); export void Files_WriteLInt (Files_Rider *R, LONGINT *R__typ, int64 x); export void Files_WriteLReal (Files_Rider *R, LONGINT *R__typ, LONGREAL x); export void Files_WriteNum (Files_Rider *R, LONGINT *R__typ, int64 x); +export void Files_WriteNum64 (Files_Rider *R, LONGINT *R__typ, int64 x); export void Files_WriteReal (Files_Rider *R, LONGINT *R__typ, REAL x); export void Files_WriteSet (Files_Rider *R, LONGINT *R__typ, SET x); export void Files_WriteString (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len); @@ -936,6 +938,13 @@ void Files_ReadNum (Files_Rider *R, LONGINT *R__typ, int64 *x) *x = n; } +void Files_ReadNum64 (Files_Rider *R, LONGINT *R__typ, int64 *x) +{ + int64 n; + Files_ReadNum(&*R, R__typ, &n); + *x = n; +} + void Files_WriteBool (Files_Rider *R, LONGINT *R__typ, BOOLEAN x) { Files_Write(&*R, R__typ, __VAL(CHAR, x)); @@ -1004,6 +1013,15 @@ void Files_WriteNum (Files_Rider *R, LONGINT *R__typ, int64 x) Files_Write(&*R, R__typ, (CHAR)__MASK(x, -128)); } +void Files_WriteNum64 (Files_Rider *R, LONGINT *R__typ, int64 x) +{ + while (x < -64 || x > 63) { + Files_Write(&*R, R__typ, (CHAR)(__MASK(x, -128) + 128)); + x = __ASHR(x, 7); + } + Files_Write(&*R, R__typ, (CHAR)__MASK(x, -128)); +} + void Files_GetName (Files_File f, CHAR *name, LONGINT name__len) { __COPY(f->workName, name, name__len); diff --git a/bootstrap/unix-88/Files.h b/bootstrap/unix-88/Files.h index a5641b0c..51065265 100644 --- a/bootstrap/unix-88/Files.h +++ b/bootstrap/unix-88/Files.h @@ -47,6 +47,7 @@ import void Files_ReadLInt (Files_Rider *R, LONGINT *R__typ, int64 *x); import void Files_ReadLReal (Files_Rider *R, LONGINT *R__typ, LONGREAL *x); import void Files_ReadLine (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len); import void Files_ReadNum (Files_Rider *R, LONGINT *R__typ, int64 *x); +import void Files_ReadNum64 (Files_Rider *R, LONGINT *R__typ, int64 *x); import void Files_ReadReal (Files_Rider *R, LONGINT *R__typ, REAL *x); import void Files_ReadSet (Files_Rider *R, LONGINT *R__typ, SET *x); import void Files_ReadString (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len); @@ -61,6 +62,7 @@ import void Files_WriteInt (Files_Rider *R, LONGINT *R__typ, int32 x); import void Files_WriteLInt (Files_Rider *R, LONGINT *R__typ, int64 x); import void Files_WriteLReal (Files_Rider *R, LONGINT *R__typ, LONGREAL x); import void Files_WriteNum (Files_Rider *R, LONGINT *R__typ, int64 x); +import void Files_WriteNum64 (Files_Rider *R, LONGINT *R__typ, int64 x); import void Files_WriteReal (Files_Rider *R, LONGINT *R__typ, REAL x); import void Files_WriteSet (Files_Rider *R, LONGINT *R__typ, SET x); import void Files_WriteString (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len); diff --git a/bootstrap/unix-88/OPB.c b/bootstrap/unix-88/OPB.c index 2f005fc6..b271fa53 100644 --- a/bootstrap/unix-88/OPB.c +++ b/bootstrap/unix-88/OPB.c @@ -144,14 +144,8 @@ static int64 OPB_BoolToInt (BOOLEAN b) static BOOLEAN OPB_IntToBool (int64 i) { BOOLEAN _o_result; - if (i == 0) { - _o_result = 0; - return _o_result; - } else { - _o_result = 1; - return _o_result; - } - __RETCHK; + _o_result = i != 0; + return _o_result; } OPT_Node OPB_NewBoolConst (BOOLEAN boolval) @@ -274,7 +268,7 @@ OPT_Node OPB_NewString (OPS_String str, int64 len) x->conval = OPT_NewConst(); x->typ = OPT_stringtyp; x->conval->intval = -1; - x->conval->intval2 = len; + x->conval->intval2 = OPM_Longint(len); x->conval->ext = OPT_NewExt(); __COPY(str, *x->conval->ext, 256); _o_result = x; @@ -1917,7 +1911,7 @@ void OPB_StPar0 (OPT_Node *par0, int32 fctno) if (x->class == 8 || x->class == 9) { OPB_err(126); } else if (f == 4) { - if (x->typ->size != OPT_linttyp->size) { + if (x->typ->size < OPT_linttyp->size) { OPB_Convert(&x, OPT_linttyp); } } else { @@ -2068,7 +2062,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, int8 fctno) if (!(f == 4) || x->class != 7) { OPB_err(69); } else if (x->typ->size == 1) { - L = (int32)x->conval->intval; + L = OPM_Integer(x->conval->intval); typ = p->typ; while ((L > 0 && __IN(typ->comp, 0x0c, 64))) { typ = typ->BaseTyp; @@ -2132,7 +2126,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, int8 fctno) p->obj = NIL; } else { p = NewOp__53(12, 17, p, x); - p->typ = OPT_linttyp; + p->typ = p->left->typ; } } else { OPB_err(111); diff --git a/bootstrap/unix-88/OPM.c b/bootstrap/unix-88/OPM.c index 23017356..47c8a9be 100644 --- a/bootstrap/unix-88/OPM.c +++ b/bootstrap/unix-88/OPM.c @@ -55,11 +55,13 @@ static void OPM_GetProperties (void); static void OPM_GetProperty (Texts_Scanner *S, LONGINT *S__typ, CHAR *name, LONGINT name__len, int32 *size, int32 *align); export void OPM_Init (BOOLEAN *done, CHAR *mname, LONGINT mname__len); export void OPM_InitOptions (void); +export int32 OPM_Integer (int64 n); static void OPM_LogErrMsg (int32 n); export void OPM_LogW (CHAR ch); export void OPM_LogWLn (void); export void OPM_LogWNum (int64 i, int64 len); export void OPM_LogWStr (CHAR *s, LONGINT s__len); +export int64 OPM_Longint (int64 n); static void OPM_MakeFileName (CHAR *name, LONGINT name__len, CHAR *FName, LONGINT FName__len, CHAR *ext, LONGINT ext__len); export void OPM_Mark (int32 n, int64 pos); export void OPM_NewSym (CHAR *modName, LONGINT modName__len); @@ -73,6 +75,7 @@ export int64 OPM_SignedMaximum (int64 bytecount); export int64 OPM_SignedMinimum (int64 bytecount); export void OPM_SymRCh (CHAR *ch); export int64 OPM_SymRInt (void); +export int64 OPM_SymRInt64 (void); export void OPM_SymRLReal (LONGREAL *lr); export void OPM_SymRReal (REAL *r); export void OPM_SymRSet (SET *s); @@ -117,6 +120,20 @@ void OPM_LogWLn (void) Console_Ln(); } +int64 OPM_Longint (int64 n) +{ + int64 _o_result; + _o_result = (int64)n; + return _o_result; +} + +int32 OPM_Integer (int64 n) +{ + int32 _o_result; + _o_result = __VAL(int32, n); + return _o_result; +} + static void OPM_ScanOptions (CHAR *s, LONGINT s__len, SET *opt) { int32 i; @@ -463,7 +480,7 @@ static void OPM_ShowLine (int64 pos) if (pos >= OPM_ErrorLineLimitPos) { pos = OPM_ErrorLineLimitPos - 1; } - i = (int32)(pos - OPM_ErrorLineStartPos); + i = (int32)OPM_Longint(pos - OPM_ErrorLineStartPos); while (i > 0) { OPM_LogW(' '); i -= 1; @@ -700,6 +717,15 @@ int64 OPM_SymRInt (void) return _o_result; } +int64 OPM_SymRInt64 (void) +{ + int64 _o_result; + int64 k; + Files_ReadNum64(&OPM_oldSF, Files_Rider__typ, &k); + _o_result = k; + return _o_result; +} + void OPM_SymRSet (SET *s) { Files_ReadNum(&OPM_oldSF, Files_Rider__typ, (int64*)&*s); @@ -751,7 +777,7 @@ void OPM_SymWCh (CHAR ch) void OPM_SymWInt (int64 i) { - Files_WriteNum(&OPM_newSF, Files_Rider__typ, i); + Files_WriteNum64(&OPM_newSF, Files_Rider__typ, i); } void OPM_SymWSet (SET s) @@ -840,9 +866,9 @@ void OPM_WriteHex (int64 i) void OPM_WriteInt (int64 i) { - CHAR s[20]; + CHAR s[24]; int64 i1, k; - if (i == OPM_SignedMinimum(OPM_IntSize) || i == OPM_SignedMinimum(OPM_LIntSize)) { + if ((i == OPM_SignedMinimum(OPM_IntSize) || i == OPM_SignedMinimum(OPM_LIntSize)) || i == OPM_SignedMinimum(8)) { OPM_Write('('); OPM_WriteInt(i + 1); OPM_WriteString((CHAR*)"-1)", 4); @@ -852,17 +878,17 @@ void OPM_WriteInt (int64 i) i1 = __DIV(i1, 10); k = 1; while (i1 > 0) { - s[__X(k, 20)] = (CHAR)(__MOD(i1, 10) + 48); + s[__X(k, 24)] = (CHAR)(__MOD(i1, 10) + 48); i1 = __DIV(i1, 10); k += 1; } if (i < 0) { - s[__X(k, 20)] = '-'; + s[__X(k, 24)] = '-'; k += 1; } while (k > 0) { k -= 1; - OPM_Write(s[__X(k, 20)]); + OPM_Write(s[__X(k, 24)]); } } } diff --git a/bootstrap/unix-88/OPM.h b/bootstrap/unix-88/OPM.h index 7472bed7..9d977ff8 100644 --- a/bootstrap/unix-88/OPM.h +++ b/bootstrap/unix-88/OPM.h @@ -28,10 +28,12 @@ import void OPM_FPrintSet (int64 *fp, SET set); import void OPM_Get (CHAR *ch); import void OPM_Init (BOOLEAN *done, CHAR *mname, LONGINT mname__len); import void OPM_InitOptions (void); +import int32 OPM_Integer (int64 n); import void OPM_LogW (CHAR ch); import void OPM_LogWLn (void); import void OPM_LogWNum (int64 i, int64 len); import void OPM_LogWStr (CHAR *s, LONGINT s__len); +import int64 OPM_Longint (int64 n); import void OPM_Mark (int32 n, int64 pos); import void OPM_NewSym (CHAR *modName, LONGINT modName__len); import void OPM_OldSym (CHAR *modName, LONGINT modName__len, BOOLEAN *done); @@ -42,6 +44,7 @@ import int64 OPM_SignedMaximum (int64 bytecount); import int64 OPM_SignedMinimum (int64 bytecount); import void OPM_SymRCh (CHAR *ch); import int64 OPM_SymRInt (void); +import int64 OPM_SymRInt64 (void); import void OPM_SymRLReal (LONGREAL *lr); import void OPM_SymRReal (REAL *r); import void OPM_SymRSet (SET *s); diff --git a/bootstrap/unix-88/OPP.c b/bootstrap/unix-88/OPP.c index 63191e02..5150cdbe 100644 --- a/bootstrap/unix-88/OPP.c +++ b/bootstrap/unix-88/OPP.c @@ -151,7 +151,7 @@ static void OPP_CheckSysFlag (int32 *sysflag, int32 default_) OPP_err(51); sf = 0; } - *sysflag = (int32)sf; + *sysflag = OPM_Integer(sf); OPP_CheckSym(23); } else { *sysflag = default_; @@ -283,7 +283,7 @@ static void OPP_ArrayType (OPT_Struct *typ, OPT_Struct *banned) OPP_err(51); n = 1; } - (*typ)->n = n; + (*typ)->n = OPM_Longint(n); if (OPP_sym == 25) { OPS_Get(&OPP_sym); OPP_Type(&(*typ)->BaseTyp, &*banned); @@ -1179,7 +1179,7 @@ static void OPP_CaseLabelList (OPT_Node *lab, OPT_Struct LabelTyp, int32 *n, OPP OPP_ConstExpression(&x); f = x->typ->form; if (__IN(f, 0x18, 64)) { - xval = x->conval->intval; + xval = OPM_Longint(x->conval->intval); } else { OPP_err(61); xval = 1; @@ -1194,7 +1194,7 @@ static void OPP_CaseLabelList (OPT_Node *lab, OPT_Struct LabelTyp, int32 *n, OPP if (OPP_sym == 21) { OPS_Get(&OPP_sym); OPP_ConstExpression(&y); - yval = y->conval->intval; + yval = OPM_Longint(y->conval->intval); if ((y->typ->form != f && !((f == 4 && y->typ->form == 4)))) { OPP_err(60); } diff --git a/bootstrap/unix-88/OPV.c b/bootstrap/unix-88/OPV.c index 46abf128..04c24f09 100644 --- a/bootstrap/unix-88/OPV.c +++ b/bootstrap/unix-88/OPV.c @@ -1351,7 +1351,7 @@ static void OPV_stat (OPT_Node n, OPT_Object outerProc) OPV_ExitInfo saved; OPT_Node l = NIL, r = NIL; while ((n != NIL && OPM_noerr)) { - OPM_errpos = n->conval->intval; + OPM_errpos = OPM_Longint(n->conval->intval); if (n->class != 14) { OPC_BegStat(); } @@ -1625,7 +1625,7 @@ static void OPV_stat (OPT_Node n, OPT_Object outerProc) OPV_IfStat(n, n->subcl == 0, outerProc); break; case 28: - OPC_Halt(n->right->conval->intval); + OPC_Halt(OPM_Longint(n->right->conval->intval)); break; default: OPM_LogWStr((CHAR*)"unhandled case in OPV.expr, n^.class = ", 40); diff --git a/bootstrap/windows-48/Console.c b/bootstrap/windows-48/Console.c index f1978da4..ebbcbb49 100644 --- a/bootstrap/windows-48/Console.c +++ b/bootstrap/windows-48/Console.c @@ -16,7 +16,7 @@ export void Console_Bool (BOOLEAN b); export void Console_Char (CHAR ch); export void Console_Flush (void); export void Console_Hex (int32 i); -export void Console_Int (int32 i, int32 n); +export void Console_Int (int64 i, int64 n); export void Console_Ln (void); export void Console_Read (CHAR *ch); export void Console_ReadLine (CHAR *line, LONGINT line__len); @@ -54,15 +54,15 @@ void Console_String (CHAR *s, LONGINT s__len) __DEL(s); } -void Console_Int (int32 i, int32 n) +void Console_Int (int64 i, int64 n) { CHAR s[32]; int32 i1, k; - if (i == __LSHL(1, 31, 32)) { + if (i == (int64)__LSHL(1, 31, 32)) { __MOVE("8463847412", s, 11); k = 10; } else { - i1 = __ABS(i); + i1 = __ABS(__VAL(int32, i)); s[0] = (CHAR)((int)__MOD(i1, 10) + 48); i1 = __DIV(i1, 10); k = 1; @@ -76,7 +76,7 @@ void Console_Int (int32 i, int32 n) s[__X(k, 32)] = '-'; k += 1; } - while (n > k) { + while (n > (int64)k) { Console_Char(' '); n -= 1; } diff --git a/bootstrap/windows-48/Console.h b/bootstrap/windows-48/Console.h index cca2c91e..e5dc1566 100644 --- a/bootstrap/windows-48/Console.h +++ b/bootstrap/windows-48/Console.h @@ -12,7 +12,7 @@ import void Console_Bool (BOOLEAN b); import void Console_Char (CHAR ch); import void Console_Flush (void); import void Console_Hex (int32 i); -import void Console_Int (int32 i, int32 n); +import void Console_Int (int64 i, int64 n); import void Console_Ln (void); import void Console_Read (CHAR *ch); import void Console_ReadLine (CHAR *line, LONGINT line__len); diff --git a/bootstrap/windows-48/Files.c b/bootstrap/windows-48/Files.c index 8c0d8fd5..25e50dd9 100644 --- a/bootstrap/windows-48/Files.c +++ b/bootstrap/windows-48/Files.c @@ -90,6 +90,7 @@ export void Files_ReadLInt (Files_Rider *R, LONGINT *R__typ, int32 *x); export void Files_ReadLReal (Files_Rider *R, LONGINT *R__typ, LONGREAL *x); export void Files_ReadLine (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len); export void Files_ReadNum (Files_Rider *R, LONGINT *R__typ, int32 *x); +export void Files_ReadNum64 (Files_Rider *R, LONGINT *R__typ, int64 *x); export void Files_ReadReal (Files_Rider *R, LONGINT *R__typ, REAL *x); export void Files_ReadSet (Files_Rider *R, LONGINT *R__typ, SET *x); export void Files_ReadString (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len); @@ -105,6 +106,7 @@ export void Files_WriteInt (Files_Rider *R, LONGINT *R__typ, int16 x); export void Files_WriteLInt (Files_Rider *R, LONGINT *R__typ, int32 x); export void Files_WriteLReal (Files_Rider *R, LONGINT *R__typ, LONGREAL x); export void Files_WriteNum (Files_Rider *R, LONGINT *R__typ, int32 x); +export void Files_WriteNum64 (Files_Rider *R, LONGINT *R__typ, int64 x); export void Files_WriteReal (Files_Rider *R, LONGINT *R__typ, REAL x); export void Files_WriteSet (Files_Rider *R, LONGINT *R__typ, SET x); export void Files_WriteString (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len); @@ -936,6 +938,13 @@ void Files_ReadNum (Files_Rider *R, LONGINT *R__typ, int32 *x) *x = n; } +void Files_ReadNum64 (Files_Rider *R, LONGINT *R__typ, int64 *x) +{ + int32 n; + Files_ReadNum(&*R, R__typ, &n); + *x = n; +} + void Files_WriteBool (Files_Rider *R, LONGINT *R__typ, BOOLEAN x) { Files_Write(&*R, R__typ, __VAL(CHAR, x)); @@ -1004,6 +1013,15 @@ void Files_WriteNum (Files_Rider *R, LONGINT *R__typ, int32 x) Files_Write(&*R, R__typ, (CHAR)__MASK(x, -128)); } +void Files_WriteNum64 (Files_Rider *R, LONGINT *R__typ, int64 x) +{ + while (x < -64 || x > 63) { + Files_Write(&*R, R__typ, (CHAR)(__MASK(x, -128) + 128)); + x = __ASHR(x, 7); + } + Files_Write(&*R, R__typ, (CHAR)__MASK(x, -128)); +} + void Files_GetName (Files_File f, CHAR *name, LONGINT name__len) { __COPY(f->workName, name, name__len); diff --git a/bootstrap/windows-48/Files.h b/bootstrap/windows-48/Files.h index 4a28825a..b499ee0a 100644 --- a/bootstrap/windows-48/Files.h +++ b/bootstrap/windows-48/Files.h @@ -47,6 +47,7 @@ import void Files_ReadLInt (Files_Rider *R, LONGINT *R__typ, int32 *x); import void Files_ReadLReal (Files_Rider *R, LONGINT *R__typ, LONGREAL *x); import void Files_ReadLine (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len); import void Files_ReadNum (Files_Rider *R, LONGINT *R__typ, int32 *x); +import void Files_ReadNum64 (Files_Rider *R, LONGINT *R__typ, int64 *x); import void Files_ReadReal (Files_Rider *R, LONGINT *R__typ, REAL *x); import void Files_ReadSet (Files_Rider *R, LONGINT *R__typ, SET *x); import void Files_ReadString (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len); @@ -61,6 +62,7 @@ import void Files_WriteInt (Files_Rider *R, LONGINT *R__typ, int16 x); import void Files_WriteLInt (Files_Rider *R, LONGINT *R__typ, int32 x); import void Files_WriteLReal (Files_Rider *R, LONGINT *R__typ, LONGREAL x); import void Files_WriteNum (Files_Rider *R, LONGINT *R__typ, int32 x); +import void Files_WriteNum64 (Files_Rider *R, LONGINT *R__typ, int64 x); import void Files_WriteReal (Files_Rider *R, LONGINT *R__typ, REAL x); import void Files_WriteSet (Files_Rider *R, LONGINT *R__typ, SET x); import void Files_WriteString (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len); diff --git a/bootstrap/windows-48/OPB.c b/bootstrap/windows-48/OPB.c index 90e93aed..47f2de21 100644 --- a/bootstrap/windows-48/OPB.c +++ b/bootstrap/windows-48/OPB.c @@ -12,7 +12,7 @@ export void (*OPB_typSize)(OPT_Struct); static int16 OPB_exp; -static int32 OPB_maxExp; +static int64 OPB_maxExp; export void OPB_Assign (OPT_Node *x, OPT_Node y); @@ -38,14 +38,14 @@ export void OPB_Field (OPT_Node *x, OPT_Object y); export void OPB_In (OPT_Node *x, OPT_Node y); export void OPB_Index (OPT_Node *x, OPT_Node y); export void OPB_Inittd (OPT_Node *inittd, OPT_Node *last, OPT_Struct typ); -static BOOLEAN OPB_IntToBool (int32 i); +static BOOLEAN OPB_IntToBool (int64 i); export void OPB_Link (OPT_Node *x, OPT_Node *last, OPT_Node y); export void OPB_MOp (int8 op, OPT_Node *x); export OPT_Node OPB_NewBoolConst (BOOLEAN boolval); -export OPT_Node OPB_NewIntConst (int32 intval); +export OPT_Node OPB_NewIntConst (int64 intval); export OPT_Node OPB_NewLeaf (OPT_Object obj); export OPT_Node OPB_NewRealConst (LONGREAL realval, OPT_Struct typ); -export OPT_Node OPB_NewString (OPS_String str, int32 len); +export OPT_Node OPB_NewString (OPS_String str, int64 len); export OPT_Node OPB_Nil (void); static BOOLEAN OPB_NotVar (OPT_Node x); export void OPB_Op (int8 op, OPT_Node *x, OPT_Node y); @@ -63,7 +63,7 @@ export void OPB_StParN (OPT_Node *par0, OPT_Node x, int16 fctno, int16 n); export void OPB_StaticLink (int8 dlev); export void OPB_TypTest (OPT_Node *x, OPT_Object obj, BOOLEAN guard); static void OPB_err (int16 n); -static int32 OPB_log (int32 x); +static int64 OPB_log (int64 x); static void OPB_err (int16 n) @@ -141,17 +141,11 @@ static int32 OPB_BoolToInt (BOOLEAN b) __RETCHK; } -static BOOLEAN OPB_IntToBool (int32 i) +static BOOLEAN OPB_IntToBool (int64 i) { BOOLEAN _o_result; - if (i == 0) { - _o_result = 0; - return _o_result; - } else { - _o_result = 1; - return _o_result; - } - __RETCHK; + _o_result = i != 0; + return _o_result; } OPT_Node OPB_NewBoolConst (BOOLEAN boolval) @@ -228,7 +222,7 @@ OPT_Node OPB_EmptySet (void) static void OPB_SetIntType (OPT_Node node) { int16 b; - int32 n; + int64 n; if (node->conval->intval >= 0) { n = node->conval->intval; } else { @@ -241,7 +235,7 @@ static void OPB_SetIntType (OPT_Node node) node->typ = OPT_IntType(b); } -OPT_Node OPB_NewIntConst (int32 intval) +OPT_Node OPB_NewIntConst (int64 intval) { OPT_Node _o_result; OPT_Node x = NIL; @@ -266,7 +260,7 @@ OPT_Node OPB_NewRealConst (LONGREAL realval, OPT_Struct typ) return _o_result; } -OPT_Node OPB_NewString (OPS_String str, int32 len) +OPT_Node OPB_NewString (OPS_String str, int64 len) { OPT_Node _o_result; OPT_Node x = NIL; @@ -274,7 +268,7 @@ OPT_Node OPB_NewString (OPS_String str, int32 len) x->conval = OPT_NewConst(); x->typ = OPT_stringtyp; x->conval->intval = -1; - x->conval->intval2 = len; + x->conval->intval2 = OPM_Longint(len); x->conval->ext = OPT_NewExt(); __COPY(str, *x->conval->ext, 256); _o_result = x; @@ -351,7 +345,7 @@ void OPB_Index (OPT_Node *x, OPT_Node y) } if ((*x)->typ->comp == 2) { typ = (*x)->typ->BaseTyp; - if ((y->class == 7 && (y->conval->intval < 0 || y->conval->intval >= (*x)->typ->n))) { + if ((y->class == 7 && (y->conval->intval < 0 || y->conval->intval >= (int64)(*x)->typ->n))) { OPB_err(81); } } else if ((*x)->typ->comp == 3) { @@ -466,14 +460,14 @@ void OPB_TypTest (OPT_Node *x, OPT_Object obj, BOOLEAN guard) void OPB_In (OPT_Node *x, OPT_Node y) { int16 f; - int32 k; + int64 k; f = (*x)->typ->form; if ((((*x)->class == 8 || (*x)->class == 9) || y->class == 8) || y->class == 9) { OPB_err(126); } else if ((f == 4 && y->typ->form == 7)) { if ((*x)->class == 7) { k = (*x)->conval->intval; - if (k < 0 || k > OPM_MaxSet) { + if (k < 0 || k > (int64)OPM_MaxSet) { OPB_err(202); } else if (y->class == 7) { (*x)->conval->intval = OPB_BoolToInt(__IN(k, y->conval->setval, 32)); @@ -492,9 +486,9 @@ void OPB_In (OPT_Node *x, OPT_Node y) (*x)->typ = OPT_booltyp; } -static int32 OPB_log (int32 x) +static int64 OPB_log (int64 x) { - int32 _o_result; + int64 _o_result; OPB_exp = 0; if (x > 0) { while (!__ODD(x)) { @@ -580,7 +574,7 @@ void OPB_MOp (int8 op, OPT_Node *x) if (__IN(f, 0xf0, 32)) { if (z->class == 7) { if (f == 4) { - if (z->conval->intval == (-2147483647-1)) { + if (z->conval->intval == (-9223372036854775807-1)) { OPB_err(203); } else { z->conval->intval = -z->conval->intval; @@ -603,7 +597,7 @@ void OPB_MOp (int8 op, OPT_Node *x) if (__IN(f, 0x70, 32)) { if (z->class == 7) { if (f == 4) { - if (z->conval->intval == (-2147483647-1)) { + if (z->conval->intval == (-9223372036854775807-1)) { OPB_err(203); } else { z->conval->intval = __ABS(z->conval->intval); @@ -845,7 +839,7 @@ static void OPB_ConstOp (int16 op, OPT_Node x, OPT_Node y) { int16 f, g; OPT_Const xval = NIL, yval = NIL; - int32 xv, yv; + int64 xv, yv; BOOLEAN temp; struct ConstOp__13 _s; _s.x = &x; @@ -1007,7 +1001,7 @@ static void OPB_ConstOp (int16 op, OPT_Node x, OPT_Node y) case 4: if (f == 4) { if (yval->intval != 0) { - xval->intval = (int)__MOD(xval->intval, yval->intval); + xval->intval = __MOD(xval->intval, yval->intval); OPB_SetIntType(x); } else { OPB_err(205); @@ -1122,7 +1116,7 @@ static void OPB_Convert (OPT_Node *x, OPT_Struct typ) { OPT_Node node = NIL; int16 f, g; - int32 k; + int64 k; LONGREAL r; f = (*x)->typ->form; g = typ->form; @@ -1229,7 +1223,7 @@ void OPB_Op (int8 op, OPT_Node *x, OPT_Node y) OPT_Node t = NIL, z = NIL; OPT_Struct typ = NIL; BOOLEAN do_; - int32 val; + int64 val; struct Op__38 _s; _s.f = &f; _s.g = &g; @@ -1500,19 +1494,19 @@ void OPB_Op (int8 op, OPT_Node *x, OPT_Node y) void OPB_SetRange (OPT_Node *x, OPT_Node y) { - int32 k, l; + int64 k, l; if ((((*x)->class == 8 || (*x)->class == 9) || y->class == 8) || y->class == 9) { OPB_err(126); } else if (((*x)->typ->form == 4 && y->typ->form == 4)) { if ((*x)->class == 7) { k = (*x)->conval->intval; - if (0 > k || k > OPM_MaxSet) { + if (0 > k || k > (int64)OPM_MaxSet) { OPB_err(202); } } if (y->class == 7) { l = y->conval->intval; - if (0 > l || l > OPM_MaxSet) { + if (0 > l || l > (int64)OPM_MaxSet) { OPB_err(202); } } @@ -1535,14 +1529,14 @@ void OPB_SetRange (OPT_Node *x, OPT_Node y) void OPB_SetElem (OPT_Node *x) { - int32 k; + int64 k; if ((*x)->class == 8 || (*x)->class == 9) { OPB_err(126); } else if ((*x)->typ->form != 4) { OPB_err(93); } else if ((*x)->class == 7) { k = (*x)->conval->intval; - if ((0 <= k && k <= OPM_MaxSet)) { + if ((0 <= k && k <= (int64)OPM_MaxSet)) { (*x)->conval->setval = __SETOF(k,32); } else { OPB_err(202); @@ -1917,7 +1911,7 @@ void OPB_StPar0 (OPT_Node *par0, int16 fctno) if (x->class == 8 || x->class == 9) { OPB_err(126); } else if (f == 4) { - if (x->typ->size != OPT_linttyp->size) { + if (x->typ->size < OPT_linttyp->size) { OPB_Convert(&x, OPT_linttyp); } } else { @@ -2055,7 +2049,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, int8 fctno) if (x->class == 8 || x->class == 9) { OPB_err(126); } else if (f == 4) { - if ((x->class == 7 && (0 > x->conval->intval || x->conval->intval > OPM_MaxSet))) { + if ((x->class == 7 && (0 > x->conval->intval || x->conval->intval > (int64)OPM_MaxSet))) { OPB_err(202); } p = NewOp__53(19, fctno, p, x); @@ -2068,7 +2062,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, int8 fctno) if (!(f == 4) || x->class != 7) { OPB_err(69); } else if (x->typ->size == 1) { - L = (int16)x->conval->intval; + L = OPM_Integer(x->conval->intval); typ = p->typ; while ((L > 0 && __IN(typ->comp, 0x0c, 32))) { typ = typ->BaseTyp; @@ -2120,8 +2114,8 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, int8 fctno) OPB_err(208); p->conval->intval = 1; } else if (x->conval->intval >= 0) { - if (__ABS(p->conval->intval) <= __DIV(2147483647, __ASH(1, x->conval->intval))) { - p->conval->intval = p->conval->intval * __ASH(1, x->conval->intval); + if (__ABS(p->conval->intval) <= __DIV(9223372036854775807, (int64)__ASH(1, x->conval->intval))) { + p->conval->intval = p->conval->intval * (int64)__ASH(1, x->conval->intval); } else { OPB_err(208); p->conval->intval = 1; @@ -2132,7 +2126,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, int8 fctno) p->obj = NIL; } else { p = NewOp__53(12, 17, p, x); - p->typ = OPT_linttyp; + p->typ = p->left->typ; } } else { OPB_err(111); @@ -2143,7 +2137,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, int8 fctno) OPB_err(126); } else if (p->typ->comp == 3) { if (f == 4) { - if ((x->class == 7 && (x->conval->intval <= 0 || x->conval->intval > OPM_MaxIndex))) { + if ((x->class == 7 && (x->conval->intval <= 0 || x->conval->intval > (int64)OPM_MaxIndex))) { OPB_err(63); } } else { @@ -2281,7 +2275,7 @@ void OPB_StParN (OPT_Node *par0, OPT_Node x, int16 fctno, int16 n) } else if (p->typ->comp != 3) { OPB_err(64); } else if (f == 4) { - if ((x->class == 7 && (x->conval->intval <= 0 || x->conval->intval > OPM_MaxIndex))) { + if ((x->class == 7 && (x->conval->intval <= 0 || x->conval->intval > (int64)OPM_MaxIndex))) { OPB_err(63); } node = p->right; @@ -2622,7 +2616,7 @@ export void *OPB__init(void) __MODULE_IMPORT(OPT); __REGMOD("OPB", 0); /* BEGIN */ - OPB_maxExp = OPB_log(1073741824); + OPB_maxExp = OPB_log(4611686018427387904); OPB_maxExp = OPB_exp; __ENDMOD; } diff --git a/bootstrap/windows-48/OPB.h b/bootstrap/windows-48/OPB.h index 183a5f32..08d025bf 100644 --- a/bootstrap/windows-48/OPB.h +++ b/bootstrap/windows-48/OPB.h @@ -25,10 +25,10 @@ import void OPB_Inittd (OPT_Node *inittd, OPT_Node *last, OPT_Struct typ); import void OPB_Link (OPT_Node *x, OPT_Node *last, OPT_Node y); import void OPB_MOp (int8 op, OPT_Node *x); import OPT_Node OPB_NewBoolConst (BOOLEAN boolval); -import OPT_Node OPB_NewIntConst (int32 intval); +import OPT_Node OPB_NewIntConst (int64 intval); import OPT_Node OPB_NewLeaf (OPT_Object obj); import OPT_Node OPB_NewRealConst (LONGREAL realval, OPT_Struct typ); -import OPT_Node OPB_NewString (OPS_String str, int32 len); +import OPT_Node OPB_NewString (OPS_String str, int64 len); import OPT_Node OPB_Nil (void); import void OPB_Op (int8 op, OPT_Node *x, OPT_Node y); import void OPB_OptIf (OPT_Node *x); diff --git a/bootstrap/windows-48/OPC.c b/bootstrap/windows-48/OPC.c index 17690465..c21e44a4 100644 --- a/bootstrap/windows-48/OPC.c +++ b/bootstrap/windows-48/OPC.c @@ -26,8 +26,8 @@ export OPT_Object OPC_BaseTProc (OPT_Object obj); export void OPC_BegBlk (void); export void OPC_BegStat (void); static void OPC_CProcDefs (OPT_Object obj, int16 vis); -export void OPC_Case (int32 caseVal, int16 form); -static void OPC_CharacterLiteral (int32 c); +export void OPC_Case (int64 caseVal, int16 form); +static void OPC_CharacterLiteral (int64 c); export void OPC_Cmp (int16 rel); export void OPC_CompleteIdent (OPT_Object obj); export void OPC_Constant (OPT_Const con, int16 form); @@ -67,8 +67,8 @@ static void OPC_InitImports (OPT_Object obj); static void OPC_InitKeywords (void); export void OPC_InitTDesc (OPT_Struct typ); static void OPC_InitTProcs (OPT_Object typ, OPT_Object obj); -export void OPC_IntLiteral (int32 n, int32 size); -export void OPC_Len (OPT_Object obj, OPT_Struct array, int32 dim); +export void OPC_IntLiteral (int64 n, int32 size); +export void OPC_Len (OPT_Object obj, OPT_Struct array, int64 dim); static void OPC_LenList (OPT_Object par, BOOLEAN ansiDefine, BOOLEAN showParamName); static int16 OPC_Length (CHAR *s, LONGINT s__len); export int32 OPC_NofPtrs (OPT_Struct typ); @@ -1851,7 +1851,7 @@ void OPC_Cmp (int16 rel) } } -static void OPC_CharacterLiteral (int32 c) +static void OPC_CharacterLiteral (int64 c) { if (c < 32 || c > 126) { OPM_WriteString((CHAR*)"0x", 3); @@ -1894,7 +1894,7 @@ static void OPC_StringLiteral (CHAR *s, LONGINT s__len, int32 l) __DEL(s); } -void OPC_Case (int32 caseVal, int16 form) +void OPC_Case (int64 caseVal, int16 form) { CHAR ch; OPM_WriteString((CHAR*)"case ", 6); @@ -1937,7 +1937,7 @@ void OPC_Halt (int32 n) OPC_Str1((CHAR*)"__HALT(#)", 10, n); } -void OPC_IntLiteral (int32 n, int32 size) +void OPC_IntLiteral (int64 n, int32 size) { if ((((size > 4 && n <= 2147483647)) && n > (-2147483647-1))) { OPM_WriteString((CHAR*)"((int", 6); @@ -1950,7 +1950,7 @@ void OPC_IntLiteral (int32 n, int32 size) } } -void OPC_Len (OPT_Object obj, OPT_Struct array, int32 dim) +void OPC_Len (OPT_Object obj, OPT_Struct array, int64 dim) { if (array->comp == 3) { OPC_CompleteIdent(obj); diff --git a/bootstrap/windows-48/OPC.h b/bootstrap/windows-48/OPC.h index 34d9ebc2..9e1ec652 100644 --- a/bootstrap/windows-48/OPC.h +++ b/bootstrap/windows-48/OPC.h @@ -15,7 +15,7 @@ import int32 OPC_BaseAlignment (OPT_Struct typ); import OPT_Object OPC_BaseTProc (OPT_Object obj); import void OPC_BegBlk (void); import void OPC_BegStat (void); -import void OPC_Case (int32 caseVal, int16 form); +import void OPC_Case (int64 caseVal, int16 form); import void OPC_Cmp (int16 rel); import void OPC_CompleteIdent (OPT_Object obj); import void OPC_Constant (OPT_Const con, int16 form); @@ -37,8 +37,8 @@ import void OPC_Increment (BOOLEAN decrement); import void OPC_Indent (int16 count); import void OPC_Init (void); import void OPC_InitTDesc (OPT_Struct typ); -import void OPC_IntLiteral (int32 n, int32 size); -import void OPC_Len (OPT_Object obj, OPT_Struct array, int32 dim); +import void OPC_IntLiteral (int64 n, int32 size); +import void OPC_Len (OPT_Object obj, OPT_Struct array, int64 dim); import int32 OPC_NofPtrs (OPT_Struct typ); import void OPC_SetInclude (BOOLEAN exclude); import int32 OPC_SizeAlignment (int32 size); diff --git a/bootstrap/windows-48/OPM.c b/bootstrap/windows-48/OPM.c index 18478d1e..ba86c00a 100644 --- a/bootstrap/windows-48/OPM.c +++ b/bootstrap/windows-48/OPM.c @@ -28,7 +28,8 @@ export int16 OPM_currFile, OPM_level, OPM_pc, OPM_entno; export CHAR OPM_modName[32]; export CHAR OPM_objname[64]; export SET OPM_opt, OPM_glbopt; -static int32 OPM_ErrorLineStartPos, OPM_ErrorLineLimitPos, OPM_ErrorLineNumber, OPM_lasterrpos; +static int32 OPM_ErrorLineStartPos, OPM_ErrorLineLimitPos, OPM_ErrorLineNumber; +static int64 OPM_lasterrpos; static Texts_Reader OPM_inR; static Texts_Text OPM_Log; static Texts_Writer OPM_W; @@ -45,46 +46,49 @@ static void OPM_Append (Files_Rider *R, LONGINT *R__typ, Files_File F); export void OPM_CloseFiles (void); export void OPM_CloseOldSym (void); export void OPM_DeleteNewSym (void); -export void OPM_FPrint (int32 *fp, int32 val); +export void OPM_FPrint (int32 *fp, int64 val); export void OPM_FPrintLReal (int32 *fp, LONGREAL lr); export void OPM_FPrintReal (int32 *fp, REAL real); export void OPM_FPrintSet (int32 *fp, SET set); -static void OPM_FindLine (Files_File f, Files_Rider *r, LONGINT *r__typ, int32 pos); +static void OPM_FindLine (Files_File f, Files_Rider *r, LONGINT *r__typ, int64 pos); export void OPM_Get (CHAR *ch); static void OPM_GetProperties (void); static void OPM_GetProperty (Texts_Scanner *S, LONGINT *S__typ, CHAR *name, LONGINT name__len, int16 *size, int16 *align); export void OPM_Init (BOOLEAN *done, CHAR *mname, LONGINT mname__len); export void OPM_InitOptions (void); +export int16 OPM_Integer (int64 n); static void OPM_LogErrMsg (int16 n); export void OPM_LogW (CHAR ch); export void OPM_LogWLn (void); -export void OPM_LogWNum (int32 i, int32 len); +export void OPM_LogWNum (int64 i, int64 len); export void OPM_LogWStr (CHAR *s, LONGINT s__len); +export int32 OPM_Longint (int64 n); static void OPM_MakeFileName (CHAR *name, LONGINT name__len, CHAR *FName, LONGINT FName__len, CHAR *ext, LONGINT ext__len); -export void OPM_Mark (int16 n, int32 pos); +export void OPM_Mark (int16 n, int64 pos); export void OPM_NewSym (CHAR *modName, LONGINT modName__len); export void OPM_OldSym (CHAR *modName, LONGINT modName__len, BOOLEAN *done); export void OPM_OpenFiles (CHAR *moduleName, LONGINT moduleName__len); export BOOLEAN OPM_OpenPar (void); export void OPM_RegisterNewSym (void); static void OPM_ScanOptions (CHAR *s, LONGINT s__len, SET *opt); -static void OPM_ShowLine (int32 pos); +static void OPM_ShowLine (int64 pos); export int32 OPM_SignedMaximum (int32 bytecount); export int32 OPM_SignedMinimum (int32 bytecount); export void OPM_SymRCh (CHAR *ch); export int32 OPM_SymRInt (void); +export int64 OPM_SymRInt64 (void); export void OPM_SymRLReal (LONGREAL *lr); export void OPM_SymRReal (REAL *r); export void OPM_SymRSet (SET *s); export void OPM_SymWCh (CHAR ch); -export void OPM_SymWInt (int32 i); +export void OPM_SymWInt (int64 i); export void OPM_SymWLReal (LONGREAL lr); export void OPM_SymWReal (REAL r); export void OPM_SymWSet (SET s); static void OPM_VerboseListSizes (void); export void OPM_Write (CHAR ch); -export void OPM_WriteHex (int32 i); -export void OPM_WriteInt (int32 i); +export void OPM_WriteHex (int64 i); +export void OPM_WriteInt (int64 i); export void OPM_WriteLn (void); export void OPM_WriteReal (LONGREAL r, CHAR suffx); export void OPM_WriteString (CHAR *s, LONGINT s__len); @@ -107,7 +111,7 @@ void OPM_LogWStr (CHAR *s, LONGINT s__len) __DEL(s); } -void OPM_LogWNum (int32 i, int32 len) +void OPM_LogWNum (int64 i, int64 len) { Console_Int(i, len); } @@ -117,6 +121,20 @@ void OPM_LogWLn (void) Console_Ln(); } +int32 OPM_Longint (int64 n) +{ + int32 _o_result; + _o_result = __VAL(int32, n); + return _o_result; +} + +int16 OPM_Integer (int64 n) +{ + int16 _o_result; + _o_result = __VAL(int16, n); + return _o_result; +} + static void OPM_ScanOptions (CHAR *s, LONGINT s__len, SET *opt) { int16 i; @@ -404,21 +422,21 @@ static void OPM_LogErrMsg (int16 n) OPM_LogWStr(errors_errors[__X(n, 350)], 128); } -static void OPM_FindLine (Files_File f, Files_Rider *r, LONGINT *r__typ, int32 pos) +static void OPM_FindLine (Files_File f, Files_Rider *r, LONGINT *r__typ, int64 pos) { CHAR ch, cheol; - if (pos < OPM_ErrorLineStartPos) { + if (pos < (int64)OPM_ErrorLineStartPos) { OPM_ErrorLineStartPos = 0; OPM_ErrorLineLimitPos = 0; OPM_ErrorLineNumber = 0; } - if (pos < OPM_ErrorLineLimitPos) { + if (pos < (int64)OPM_ErrorLineLimitPos) { Files_Set(&*r, r__typ, f, OPM_ErrorLineStartPos); return; } Files_Set(&*r, r__typ, f, OPM_ErrorLineLimitPos); Files_Read(&*r, r__typ, (void*)&ch); - while ((OPM_ErrorLineLimitPos < pos && !(*r).eof)) { + while (((int64)OPM_ErrorLineLimitPos < pos && !(*r).eof)) { OPM_ErrorLineStartPos = OPM_ErrorLineLimitPos; OPM_ErrorLineNumber += 1; while ((((ch != 0x00 && ch != 0x0d)) && ch != 0x0a)) { @@ -436,7 +454,7 @@ static void OPM_FindLine (Files_File f, Files_Rider *r, LONGINT *r__typ, int32 p Files_Set(&*r, r__typ, f, OPM_ErrorLineStartPos); } -static void OPM_ShowLine (int32 pos) +static void OPM_ShowLine (int64 pos) { Files_File f = NIL; Files_Rider r; @@ -460,10 +478,10 @@ static void OPM_ShowLine (int32 pos) OPM_LogWStr(line, 1023); OPM_LogWLn(); OPM_LogWStr((CHAR*)" ", 7); - if (pos >= OPM_ErrorLineLimitPos) { + if (pos >= (int64)OPM_ErrorLineLimitPos) { pos = OPM_ErrorLineLimitPos - 1; } - i = (int16)(pos - OPM_ErrorLineStartPos); + i = (int16)OPM_Longint(pos - (int64)OPM_ErrorLineStartPos); while (i > 0) { OPM_LogW(' '); i -= 1; @@ -478,7 +496,7 @@ static void OPM_ShowLine (int32 pos) Files_Close(f); } -void OPM_Mark (int16 n, int32 pos) +void OPM_Mark (int16 n, int64 pos) { if (pos == -1) { pos = 0; @@ -535,9 +553,9 @@ void OPM_err (int16 n) OPM_Mark(n, OPM_errpos); } -void OPM_FPrint (int32 *fp, int32 val) +void OPM_FPrint (int32 *fp, int64 val) { - *fp = __ROTL((int32)((SET)*fp ^ (SET)val), 1, 32); + *fp = __ROTL((int32)((SET)*fp ^ __VAL(SET, val)), 1, 32); } void OPM_FPrintSet (int32 *fp, SET set) @@ -702,6 +720,15 @@ int32 OPM_SymRInt (void) return _o_result; } +int64 OPM_SymRInt64 (void) +{ + int64 _o_result; + int64 k; + Files_ReadNum64(&OPM_oldSF, Files_Rider__typ, &k); + _o_result = k; + return _o_result; +} + void OPM_SymRSet (SET *s) { Files_ReadNum(&OPM_oldSF, Files_Rider__typ, (int32*)&*s); @@ -751,9 +778,9 @@ void OPM_SymWCh (CHAR ch) Files_Write(&OPM_newSF, Files_Rider__typ, ch); } -void OPM_SymWInt (int32 i) +void OPM_SymWInt (int64 i) { - Files_WriteNum(&OPM_newSF, Files_Rider__typ, i); + Files_WriteNum64(&OPM_newSF, Files_Rider__typ, i); } void OPM_SymWSet (SET s) @@ -820,17 +847,17 @@ void OPM_WriteStringVar (CHAR *s, LONGINT s__len) Files_WriteBytes(&OPM_R[__X(OPM_currFile, 3)], Files_Rider__typ, (void*)s, s__len * 1, i); } -void OPM_WriteHex (int32 i) +void OPM_WriteHex (int64 i) { CHAR s[3]; - int16 digit; - digit = __ASHR((int16)i, 4); + int32 digit; + digit = __ASHR((int32)i, 4); if (digit < 10) { s[0] = (CHAR)(48 + digit); } else { s[0] = (CHAR)(87 + digit); } - digit = __MASK((int16)i, -16); + digit = __MASK((int32)i, -16); if (digit < 10) { s[1] = (CHAR)(48 + digit); } else { @@ -840,31 +867,31 @@ void OPM_WriteHex (int32 i) OPM_WriteString(s, 3); } -void OPM_WriteInt (int32 i) +void OPM_WriteInt (int64 i) { - CHAR s[20]; - int32 i1, k; - if (i == OPM_SignedMinimum(OPM_IntSize) || i == OPM_SignedMinimum(OPM_LIntSize)) { + CHAR s[24]; + int64 i1, k; + if ((i == (int64)OPM_SignedMinimum(OPM_IntSize) || i == (int64)OPM_SignedMinimum(OPM_LIntSize)) || i == (int64)OPM_SignedMinimum(8)) { OPM_Write('('); OPM_WriteInt(i + 1); OPM_WriteString((CHAR*)"-1)", 4); } else { i1 = __ABS(i); - s[0] = (CHAR)((int)__MOD(i1, 10) + 48); + s[0] = (CHAR)(__MOD(i1, 10) + 48); i1 = __DIV(i1, 10); k = 1; while (i1 > 0) { - s[__X(k, 20)] = (CHAR)((int)__MOD(i1, 10) + 48); + s[__X(k, 24)] = (CHAR)(__MOD(i1, 10) + 48); i1 = __DIV(i1, 10); k += 1; } if (i < 0) { - s[__X(k, 20)] = '-'; + s[__X(k, 24)] = '-'; k += 1; } while (k > 0) { k -= 1; - OPM_Write(s[__X(k, 20)]); + OPM_Write(s[__X(k, 24)]); } } } diff --git a/bootstrap/windows-48/OPM.h b/bootstrap/windows-48/OPM.h index a36522a1..504519da 100644 --- a/bootstrap/windows-48/OPM.h +++ b/bootstrap/windows-48/OPM.h @@ -21,18 +21,20 @@ import BOOLEAN OPM_dontAsm, OPM_dontLink, OPM_mainProg, OPM_mainLinkStat, OPM_no import void OPM_CloseFiles (void); import void OPM_CloseOldSym (void); import void OPM_DeleteNewSym (void); -import void OPM_FPrint (int32 *fp, int32 val); +import void OPM_FPrint (int32 *fp, int64 val); import void OPM_FPrintLReal (int32 *fp, LONGREAL lr); import void OPM_FPrintReal (int32 *fp, REAL real); import void OPM_FPrintSet (int32 *fp, SET set); import void OPM_Get (CHAR *ch); import void OPM_Init (BOOLEAN *done, CHAR *mname, LONGINT mname__len); import void OPM_InitOptions (void); +import int16 OPM_Integer (int64 n); import void OPM_LogW (CHAR ch); import void OPM_LogWLn (void); -import void OPM_LogWNum (int32 i, int32 len); +import void OPM_LogWNum (int64 i, int64 len); import void OPM_LogWStr (CHAR *s, LONGINT s__len); -import void OPM_Mark (int16 n, int32 pos); +import int32 OPM_Longint (int64 n); +import void OPM_Mark (int16 n, int64 pos); import void OPM_NewSym (CHAR *modName, LONGINT modName__len); import void OPM_OldSym (CHAR *modName, LONGINT modName__len, BOOLEAN *done); import void OPM_OpenFiles (CHAR *moduleName, LONGINT moduleName__len); @@ -42,17 +44,18 @@ import int32 OPM_SignedMaximum (int32 bytecount); import int32 OPM_SignedMinimum (int32 bytecount); import void OPM_SymRCh (CHAR *ch); import int32 OPM_SymRInt (void); +import int64 OPM_SymRInt64 (void); import void OPM_SymRLReal (LONGREAL *lr); import void OPM_SymRReal (REAL *r); import void OPM_SymRSet (SET *s); import void OPM_SymWCh (CHAR ch); -import void OPM_SymWInt (int32 i); +import void OPM_SymWInt (int64 i); import void OPM_SymWLReal (LONGREAL lr); import void OPM_SymWReal (REAL r); import void OPM_SymWSet (SET s); import void OPM_Write (CHAR ch); -import void OPM_WriteHex (int32 i); -import void OPM_WriteInt (int32 i); +import void OPM_WriteHex (int64 i); +import void OPM_WriteInt (int64 i); import void OPM_WriteLn (void); import void OPM_WriteReal (LONGREAL r, CHAR suffx); import void OPM_WriteString (CHAR *s, LONGINT s__len); diff --git a/bootstrap/windows-48/OPP.c b/bootstrap/windows-48/OPP.c index 8db5ef60..44ce8ff1 100644 --- a/bootstrap/windows-48/OPP.c +++ b/bootstrap/windows-48/OPP.c @@ -134,7 +134,7 @@ static void OPP_CheckMark (int8 *vis) static void OPP_CheckSysFlag (int16 *sysflag, int16 default_) { OPT_Node x = NIL; - int32 sf; + int64 sf; if (OPP_sym == 31) { OPS_Get(&OPP_sym); if (!OPT_SYSimported) { @@ -151,7 +151,7 @@ static void OPP_CheckSysFlag (int16 *sysflag, int16 default_) OPP_err(51); sf = 0; } - *sysflag = (int16)sf; + *sysflag = OPM_Integer(sf); OPP_CheckSym(23); } else { *sysflag = default_; @@ -254,7 +254,7 @@ static void OPP_RecordType (OPT_Struct *typ, OPT_Struct *banned) static void OPP_ArrayType (OPT_Struct *typ, OPT_Struct *banned) { OPT_Node x = NIL; - int32 n; + int64 n; int16 sysflag; OPP_CheckSysFlag(&sysflag, 0); if (OPP_sym == 25) { @@ -275,7 +275,7 @@ static void OPP_ArrayType (OPT_Struct *typ, OPT_Struct *banned) OPP_ConstExpression(&x); if (x->typ->form == 4) { n = x->conval->intval; - if (n <= 0 || n > OPM_MaxIndex) { + if (n <= 0 || n > (int64)OPM_MaxIndex) { OPP_err(63); n = 1; } @@ -283,7 +283,7 @@ static void OPP_ArrayType (OPT_Struct *typ, OPT_Struct *banned) OPP_err(51); n = 1; } - (*typ)->n = n; + (*typ)->n = OPM_Longint(n); if (OPP_sym == 25) { OPS_Get(&OPP_sym); OPP_Type(&(*typ)->BaseTyp, &*banned); @@ -932,7 +932,7 @@ static void GetCode__19 (void) { OPT_ConstExt ext = NIL; int16 n; - int32 c; + int64 c; ext = OPT_NewExt(); (*ProcedureDeclaration__16_s->proc)->conval->ext = ext; n = 0; @@ -1179,7 +1179,7 @@ static void OPP_CaseLabelList (OPT_Node *lab, OPT_Struct LabelTyp, int16 *n, OPP OPP_ConstExpression(&x); f = x->typ->form; if (__IN(f, 0x18, 32)) { - xval = x->conval->intval; + xval = OPM_Longint(x->conval->intval); } else { OPP_err(61); xval = 1; @@ -1194,7 +1194,7 @@ static void OPP_CaseLabelList (OPT_Node *lab, OPT_Struct LabelTyp, int16 *n, OPP if (OPP_sym == 21) { OPS_Get(&OPP_sym); OPP_ConstExpression(&y); - yval = y->conval->intval; + yval = OPM_Longint(y->conval->intval); if (((int16)y->typ->form != f && !((f == 4 && y->typ->form == 4)))) { OPP_err(60); } diff --git a/bootstrap/windows-48/OPS.c b/bootstrap/windows-48/OPS.c index fb0f2237..f80ca2b1 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 int32 OPS_intval; +export int64 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) + Ord__7(dig[i], 1); + OPS_intval = __ASHL(OPS_intval, 4) + (int64)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) + Ord__7(dig[i], 1); + OPS_intval = __ASHL(OPS_intval, 4) + (int64)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 ((int64)OPS_intval <= __DIV(9223372036854775807 - (int64)d, 10)) { - OPS_intval = OPS_intval * 10 + d; + if (OPS_intval <= __DIV(9223372036854775807 - (int64)d, 10)) { + OPS_intval = OPS_intval * 10 + (int64)d; } else { OPS_err(203); } diff --git a/bootstrap/windows-48/OPS.h b/bootstrap/windows-48/OPS.h index d2b5dfb4..d33103c1 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 int32 OPS_intval; +import int64 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 83a2652b..fa5401ee 100644 --- a/bootstrap/windows-48/OPT.c +++ b/bootstrap/windows-48/OPT.c @@ -17,7 +17,8 @@ typedef typedef struct OPT_ConstDesc { OPT_ConstExt ext; - int32 intval, intval2; + int64 intval; + int32 intval2; SET setval; LONGREAL realval; } OPT_ConstDesc; @@ -1838,7 +1839,7 @@ static void EnumPtrs(void (*P)(void*)) __ENUMR(&OPT_impCtxt, OPT_ImpCtxt__typ, 3140, 1, P); } -__TDESC(OPT_ConstDesc, 1, 1) = {__TDFLDS("ConstDesc", 24), {0, -8}}; +__TDESC(OPT_ConstDesc, 1, 1) = {__TDFLDS("ConstDesc", 32), {0, -8}}; __TDESC(OPT_ObjDesc, 1, 6) = {__TDFLDS("ObjDesc", 304), {0, 4, 8, 12, 284, 288, -28}}; __TDESC(OPT_StrDesc, 1, 3) = {__TDFLDS("StrDesc", 56), {44, 48, 52, -16}}; __TDESC(OPT_NodeDesc, 1, 6) = {__TDFLDS("NodeDesc", 28), {0, 4, 8, 16, 20, 24, -28}}; diff --git a/bootstrap/windows-48/OPT.h b/bootstrap/windows-48/OPT.h index d4b49da8..b6566702 100644 --- a/bootstrap/windows-48/OPT.h +++ b/bootstrap/windows-48/OPT.h @@ -15,7 +15,8 @@ typedef typedef struct OPT_ConstDesc { OPT_ConstExt ext; - int32 intval, intval2; + int64 intval; + int32 intval2; SET setval; LONGREAL realval; } OPT_ConstDesc; diff --git a/bootstrap/windows-48/OPV.c b/bootstrap/windows-48/OPV.c index a32351aa..cddb737c 100644 --- a/bootstrap/windows-48/OPV.c +++ b/bootstrap/windows-48/OPV.c @@ -36,10 +36,10 @@ static BOOLEAN OPV_ImplicitReturn (OPT_Node n); static void OPV_Index (OPT_Node n, OPT_Node d, int16 prec, int16 dim); export void OPV_Init (void); static void OPV_InitTDescs (OPT_Node n); -static void OPV_Len (OPT_Node n, int32 dim); +static void OPV_Len (OPT_Node n, int64 dim); export void OPV_Module (OPT_Node prog); static void OPV_NewArr (OPT_Node d, OPT_Node x); -static void OPV_ParIntLiteral (int32 n, int32 size); +static void OPV_ParIntLiteral (int64 n, int32 size); static int16 OPV_Precedence (int16 class, int16 subclass, int16 form, int16 comp); static BOOLEAN OPV_SideEffects (OPT_Node n); static void OPV_SizeCast (int32 from, int32 to); @@ -414,7 +414,7 @@ static int16 OPV_Precedence (int16 class, int16 subclass, int16 form, int16 comp __RETCHK; } -static void OPV_Len (OPT_Node n, int32 dim) +static void OPV_Len (OPT_Node n, int64 dim) { while ((n->class == 4 && n->typ->comp == 3)) { dim += 1; @@ -725,7 +725,7 @@ static void OPV_design (OPT_Node n, int16 prec) } } -static void OPV_ParIntLiteral (int32 n, int32 size) +static void OPV_ParIntLiteral (int64 n, int32 size) { if (OPV_ansi) { OPM_WriteInt(n); @@ -1210,7 +1210,7 @@ static void OPV_IfStat (OPT_Node n, BOOLEAN withtrap, OPT_Object outerProc) static void OPV_CaseStat (OPT_Node n, OPT_Object outerProc) { OPT_Node switchCase = NIL, label = NIL; - int32 low, high; + int64 low, high; int16 form, i; OPM_WriteString((CHAR*)"switch ", 8); OPV_expr(n->left, 12); @@ -1351,7 +1351,7 @@ static void OPV_stat (OPT_Node n, OPT_Object outerProc) OPV_ExitInfo saved; OPT_Node l = NIL, r = NIL; while ((n != NIL && OPM_noerr)) { - OPM_errpos = n->conval->intval; + OPM_errpos = OPM_Longint(n->conval->intval); if (n->class != 14) { OPC_BegStat(); } @@ -1625,7 +1625,7 @@ static void OPV_stat (OPT_Node n, OPT_Object outerProc) OPV_IfStat(n, n->subcl == 0, outerProc); break; case 28: - OPC_Halt(n->right->conval->intval); + OPC_Halt(OPM_Longint(n->right->conval->intval)); break; default: OPM_LogWStr((CHAR*)"unhandled case in OPV.expr, n^.class = ", 40); diff --git a/bootstrap/windows-88/Console.c b/bootstrap/windows-88/Console.c index 32408370..1f28b96d 100644 --- a/bootstrap/windows-88/Console.c +++ b/bootstrap/windows-88/Console.c @@ -62,7 +62,7 @@ void Console_Int (int64 i, int64 n) __MOVE("8085774586302733229", s, 20); k = 19; } else { - i1 = __ABS(i); + i1 = __ABS((int64)i); s[0] = (CHAR)(__MOD(i1, 10) + 48); i1 = __DIV(i1, 10); k = 1; diff --git a/bootstrap/windows-88/Files.c b/bootstrap/windows-88/Files.c index c2097ffb..d94e42ad 100644 --- a/bootstrap/windows-88/Files.c +++ b/bootstrap/windows-88/Files.c @@ -90,6 +90,7 @@ export void Files_ReadLInt (Files_Rider *R, LONGINT *R__typ, int64 *x); export void Files_ReadLReal (Files_Rider *R, LONGINT *R__typ, LONGREAL *x); export void Files_ReadLine (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len); export void Files_ReadNum (Files_Rider *R, LONGINT *R__typ, int64 *x); +export void Files_ReadNum64 (Files_Rider *R, LONGINT *R__typ, int64 *x); export void Files_ReadReal (Files_Rider *R, LONGINT *R__typ, REAL *x); export void Files_ReadSet (Files_Rider *R, LONGINT *R__typ, SET *x); export void Files_ReadString (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len); @@ -105,6 +106,7 @@ export void Files_WriteInt (Files_Rider *R, LONGINT *R__typ, int32 x); export void Files_WriteLInt (Files_Rider *R, LONGINT *R__typ, int64 x); export void Files_WriteLReal (Files_Rider *R, LONGINT *R__typ, LONGREAL x); export void Files_WriteNum (Files_Rider *R, LONGINT *R__typ, int64 x); +export void Files_WriteNum64 (Files_Rider *R, LONGINT *R__typ, int64 x); export void Files_WriteReal (Files_Rider *R, LONGINT *R__typ, REAL x); export void Files_WriteSet (Files_Rider *R, LONGINT *R__typ, SET x); export void Files_WriteString (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len); @@ -936,6 +938,13 @@ void Files_ReadNum (Files_Rider *R, LONGINT *R__typ, int64 *x) *x = n; } +void Files_ReadNum64 (Files_Rider *R, LONGINT *R__typ, int64 *x) +{ + int64 n; + Files_ReadNum(&*R, R__typ, &n); + *x = n; +} + void Files_WriteBool (Files_Rider *R, LONGINT *R__typ, BOOLEAN x) { Files_Write(&*R, R__typ, __VAL(CHAR, x)); @@ -1004,6 +1013,15 @@ void Files_WriteNum (Files_Rider *R, LONGINT *R__typ, int64 x) Files_Write(&*R, R__typ, (CHAR)__MASK(x, -128)); } +void Files_WriteNum64 (Files_Rider *R, LONGINT *R__typ, int64 x) +{ + while (x < -64 || x > 63) { + Files_Write(&*R, R__typ, (CHAR)(__MASK(x, -128) + 128)); + x = __ASHR(x, 7); + } + Files_Write(&*R, R__typ, (CHAR)__MASK(x, -128)); +} + void Files_GetName (Files_File f, CHAR *name, LONGINT name__len) { __COPY(f->workName, name, name__len); diff --git a/bootstrap/windows-88/Files.h b/bootstrap/windows-88/Files.h index c98b006a..9ea6ac78 100644 --- a/bootstrap/windows-88/Files.h +++ b/bootstrap/windows-88/Files.h @@ -47,6 +47,7 @@ import void Files_ReadLInt (Files_Rider *R, LONGINT *R__typ, int64 *x); import void Files_ReadLReal (Files_Rider *R, LONGINT *R__typ, LONGREAL *x); import void Files_ReadLine (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len); import void Files_ReadNum (Files_Rider *R, LONGINT *R__typ, int64 *x); +import void Files_ReadNum64 (Files_Rider *R, LONGINT *R__typ, int64 *x); import void Files_ReadReal (Files_Rider *R, LONGINT *R__typ, REAL *x); import void Files_ReadSet (Files_Rider *R, LONGINT *R__typ, SET *x); import void Files_ReadString (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len); @@ -61,6 +62,7 @@ import void Files_WriteInt (Files_Rider *R, LONGINT *R__typ, int32 x); import void Files_WriteLInt (Files_Rider *R, LONGINT *R__typ, int64 x); import void Files_WriteLReal (Files_Rider *R, LONGINT *R__typ, LONGREAL x); import void Files_WriteNum (Files_Rider *R, LONGINT *R__typ, int64 x); +import void Files_WriteNum64 (Files_Rider *R, LONGINT *R__typ, int64 x); import void Files_WriteReal (Files_Rider *R, LONGINT *R__typ, REAL x); import void Files_WriteSet (Files_Rider *R, LONGINT *R__typ, SET x); import void Files_WriteString (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len); diff --git a/bootstrap/windows-88/OPB.c b/bootstrap/windows-88/OPB.c index 2f005fc6..b271fa53 100644 --- a/bootstrap/windows-88/OPB.c +++ b/bootstrap/windows-88/OPB.c @@ -144,14 +144,8 @@ static int64 OPB_BoolToInt (BOOLEAN b) static BOOLEAN OPB_IntToBool (int64 i) { BOOLEAN _o_result; - if (i == 0) { - _o_result = 0; - return _o_result; - } else { - _o_result = 1; - return _o_result; - } - __RETCHK; + _o_result = i != 0; + return _o_result; } OPT_Node OPB_NewBoolConst (BOOLEAN boolval) @@ -274,7 +268,7 @@ OPT_Node OPB_NewString (OPS_String str, int64 len) x->conval = OPT_NewConst(); x->typ = OPT_stringtyp; x->conval->intval = -1; - x->conval->intval2 = len; + x->conval->intval2 = OPM_Longint(len); x->conval->ext = OPT_NewExt(); __COPY(str, *x->conval->ext, 256); _o_result = x; @@ -1917,7 +1911,7 @@ void OPB_StPar0 (OPT_Node *par0, int32 fctno) if (x->class == 8 || x->class == 9) { OPB_err(126); } else if (f == 4) { - if (x->typ->size != OPT_linttyp->size) { + if (x->typ->size < OPT_linttyp->size) { OPB_Convert(&x, OPT_linttyp); } } else { @@ -2068,7 +2062,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, int8 fctno) if (!(f == 4) || x->class != 7) { OPB_err(69); } else if (x->typ->size == 1) { - L = (int32)x->conval->intval; + L = OPM_Integer(x->conval->intval); typ = p->typ; while ((L > 0 && __IN(typ->comp, 0x0c, 64))) { typ = typ->BaseTyp; @@ -2132,7 +2126,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, int8 fctno) p->obj = NIL; } else { p = NewOp__53(12, 17, p, x); - p->typ = OPT_linttyp; + p->typ = p->left->typ; } } else { OPB_err(111); diff --git a/bootstrap/windows-88/OPM.c b/bootstrap/windows-88/OPM.c index 23017356..47c8a9be 100644 --- a/bootstrap/windows-88/OPM.c +++ b/bootstrap/windows-88/OPM.c @@ -55,11 +55,13 @@ static void OPM_GetProperties (void); static void OPM_GetProperty (Texts_Scanner *S, LONGINT *S__typ, CHAR *name, LONGINT name__len, int32 *size, int32 *align); export void OPM_Init (BOOLEAN *done, CHAR *mname, LONGINT mname__len); export void OPM_InitOptions (void); +export int32 OPM_Integer (int64 n); static void OPM_LogErrMsg (int32 n); export void OPM_LogW (CHAR ch); export void OPM_LogWLn (void); export void OPM_LogWNum (int64 i, int64 len); export void OPM_LogWStr (CHAR *s, LONGINT s__len); +export int64 OPM_Longint (int64 n); static void OPM_MakeFileName (CHAR *name, LONGINT name__len, CHAR *FName, LONGINT FName__len, CHAR *ext, LONGINT ext__len); export void OPM_Mark (int32 n, int64 pos); export void OPM_NewSym (CHAR *modName, LONGINT modName__len); @@ -73,6 +75,7 @@ export int64 OPM_SignedMaximum (int64 bytecount); export int64 OPM_SignedMinimum (int64 bytecount); export void OPM_SymRCh (CHAR *ch); export int64 OPM_SymRInt (void); +export int64 OPM_SymRInt64 (void); export void OPM_SymRLReal (LONGREAL *lr); export void OPM_SymRReal (REAL *r); export void OPM_SymRSet (SET *s); @@ -117,6 +120,20 @@ void OPM_LogWLn (void) Console_Ln(); } +int64 OPM_Longint (int64 n) +{ + int64 _o_result; + _o_result = (int64)n; + return _o_result; +} + +int32 OPM_Integer (int64 n) +{ + int32 _o_result; + _o_result = __VAL(int32, n); + return _o_result; +} + static void OPM_ScanOptions (CHAR *s, LONGINT s__len, SET *opt) { int32 i; @@ -463,7 +480,7 @@ static void OPM_ShowLine (int64 pos) if (pos >= OPM_ErrorLineLimitPos) { pos = OPM_ErrorLineLimitPos - 1; } - i = (int32)(pos - OPM_ErrorLineStartPos); + i = (int32)OPM_Longint(pos - OPM_ErrorLineStartPos); while (i > 0) { OPM_LogW(' '); i -= 1; @@ -700,6 +717,15 @@ int64 OPM_SymRInt (void) return _o_result; } +int64 OPM_SymRInt64 (void) +{ + int64 _o_result; + int64 k; + Files_ReadNum64(&OPM_oldSF, Files_Rider__typ, &k); + _o_result = k; + return _o_result; +} + void OPM_SymRSet (SET *s) { Files_ReadNum(&OPM_oldSF, Files_Rider__typ, (int64*)&*s); @@ -751,7 +777,7 @@ void OPM_SymWCh (CHAR ch) void OPM_SymWInt (int64 i) { - Files_WriteNum(&OPM_newSF, Files_Rider__typ, i); + Files_WriteNum64(&OPM_newSF, Files_Rider__typ, i); } void OPM_SymWSet (SET s) @@ -840,9 +866,9 @@ void OPM_WriteHex (int64 i) void OPM_WriteInt (int64 i) { - CHAR s[20]; + CHAR s[24]; int64 i1, k; - if (i == OPM_SignedMinimum(OPM_IntSize) || i == OPM_SignedMinimum(OPM_LIntSize)) { + if ((i == OPM_SignedMinimum(OPM_IntSize) || i == OPM_SignedMinimum(OPM_LIntSize)) || i == OPM_SignedMinimum(8)) { OPM_Write('('); OPM_WriteInt(i + 1); OPM_WriteString((CHAR*)"-1)", 4); @@ -852,17 +878,17 @@ void OPM_WriteInt (int64 i) i1 = __DIV(i1, 10); k = 1; while (i1 > 0) { - s[__X(k, 20)] = (CHAR)(__MOD(i1, 10) + 48); + s[__X(k, 24)] = (CHAR)(__MOD(i1, 10) + 48); i1 = __DIV(i1, 10); k += 1; } if (i < 0) { - s[__X(k, 20)] = '-'; + s[__X(k, 24)] = '-'; k += 1; } while (k > 0) { k -= 1; - OPM_Write(s[__X(k, 20)]); + OPM_Write(s[__X(k, 24)]); } } } diff --git a/bootstrap/windows-88/OPM.h b/bootstrap/windows-88/OPM.h index 7472bed7..9d977ff8 100644 --- a/bootstrap/windows-88/OPM.h +++ b/bootstrap/windows-88/OPM.h @@ -28,10 +28,12 @@ import void OPM_FPrintSet (int64 *fp, SET set); import void OPM_Get (CHAR *ch); import void OPM_Init (BOOLEAN *done, CHAR *mname, LONGINT mname__len); import void OPM_InitOptions (void); +import int32 OPM_Integer (int64 n); import void OPM_LogW (CHAR ch); import void OPM_LogWLn (void); import void OPM_LogWNum (int64 i, int64 len); import void OPM_LogWStr (CHAR *s, LONGINT s__len); +import int64 OPM_Longint (int64 n); import void OPM_Mark (int32 n, int64 pos); import void OPM_NewSym (CHAR *modName, LONGINT modName__len); import void OPM_OldSym (CHAR *modName, LONGINT modName__len, BOOLEAN *done); @@ -42,6 +44,7 @@ import int64 OPM_SignedMaximum (int64 bytecount); import int64 OPM_SignedMinimum (int64 bytecount); import void OPM_SymRCh (CHAR *ch); import int64 OPM_SymRInt (void); +import int64 OPM_SymRInt64 (void); import void OPM_SymRLReal (LONGREAL *lr); import void OPM_SymRReal (REAL *r); import void OPM_SymRSet (SET *s); diff --git a/bootstrap/windows-88/OPP.c b/bootstrap/windows-88/OPP.c index 63191e02..5150cdbe 100644 --- a/bootstrap/windows-88/OPP.c +++ b/bootstrap/windows-88/OPP.c @@ -151,7 +151,7 @@ static void OPP_CheckSysFlag (int32 *sysflag, int32 default_) OPP_err(51); sf = 0; } - *sysflag = (int32)sf; + *sysflag = OPM_Integer(sf); OPP_CheckSym(23); } else { *sysflag = default_; @@ -283,7 +283,7 @@ static void OPP_ArrayType (OPT_Struct *typ, OPT_Struct *banned) OPP_err(51); n = 1; } - (*typ)->n = n; + (*typ)->n = OPM_Longint(n); if (OPP_sym == 25) { OPS_Get(&OPP_sym); OPP_Type(&(*typ)->BaseTyp, &*banned); @@ -1179,7 +1179,7 @@ static void OPP_CaseLabelList (OPT_Node *lab, OPT_Struct LabelTyp, int32 *n, OPP OPP_ConstExpression(&x); f = x->typ->form; if (__IN(f, 0x18, 64)) { - xval = x->conval->intval; + xval = OPM_Longint(x->conval->intval); } else { OPP_err(61); xval = 1; @@ -1194,7 +1194,7 @@ static void OPP_CaseLabelList (OPT_Node *lab, OPT_Struct LabelTyp, int32 *n, OPP if (OPP_sym == 21) { OPS_Get(&OPP_sym); OPP_ConstExpression(&y); - yval = y->conval->intval; + yval = OPM_Longint(y->conval->intval); if ((y->typ->form != f && !((f == 4 && y->typ->form == 4)))) { OPP_err(60); } diff --git a/bootstrap/windows-88/OPV.c b/bootstrap/windows-88/OPV.c index 46abf128..04c24f09 100644 --- a/bootstrap/windows-88/OPV.c +++ b/bootstrap/windows-88/OPV.c @@ -1351,7 +1351,7 @@ static void OPV_stat (OPT_Node n, OPT_Object outerProc) OPV_ExitInfo saved; OPT_Node l = NIL, r = NIL; while ((n != NIL && OPM_noerr)) { - OPM_errpos = n->conval->intval; + OPM_errpos = OPM_Longint(n->conval->intval); if (n->class != 14) { OPC_BegStat(); } @@ -1625,7 +1625,7 @@ static void OPV_stat (OPT_Node n, OPT_Object outerProc) OPV_IfStat(n, n->subcl == 0, outerProc); break; case 28: - OPC_Halt(n->right->conval->intval); + OPC_Halt(OPM_Longint(n->right->conval->intval)); break; default: OPM_LogWStr((CHAR*)"unhandled case in OPV.expr, n^.class = ", 40); diff --git a/src/library/s3/ethMD5.Mod b/src/library/s3/ethMD5.Mod index 57975454..32c31bd8 100644 --- a/src/library/s3/ethMD5.Mod +++ b/src/library/s3/ethMD5.Mod @@ -231,7 +231,7 @@ under a public-key cryptosystem such as RSA. *) SYSTEM.MOVE(SYSTEM.ADR(buf[beg]), SYSTEM.ADR(context.in[0]), 64); ByteReverse(context.in, in, 16); Transform(context.buf, in); - INC(beg, 64); DEC(len, 64) + INC(beg, 64); DEC(len, 64) END; IF len > 0 THEN SYSTEM.MOVE(SYSTEM.ADR(buf[beg]), SYSTEM.ADR(context.in[0]), len) diff --git a/src/library/v4/Texts.Mod b/src/library/v4/Texts.Mod index 26b13c81..ecca315d 100644 --- a/src/library/v4/Texts.Mod +++ b/src/library/v4/Texts.Mod @@ -1,6 +1,6 @@ MODULE Texts; (** CAS/HM 23.9.93 -- interface based on Texts by JG/NW 6.12.91**) (* << RC, MB, JT *) IMPORT - Files, Modules, Reals; + Files, Modules, Reals, SYSTEM; (*--- insert field e: Elem into Texts.Scanner and change Texts.Scan to set it in case of class=6 *) @@ -545,19 +545,13 @@ MODULE Texts; (** CAS/HM 23.9.93 -- interface based on Texts by JG/NW 6.12.91** WHILE s[i] >= " " DO Write(W, s[i]); INC(i) END END WriteString; - PROCEDURE WriteInt* (VAR W: Writer; x, n: LONGINT); + PROCEDURE WriteInt* (VAR W: Writer; x, n: SYSTEM.INT64); VAR - i: INTEGER; x0: LONGINT; - a: ARRAY 22 OF CHAR; + i: INTEGER; x0: SYSTEM.INT64; + a: ARRAY 24 OF CHAR; BEGIN i := 0; IF x < 0 THEN - IF x = MIN(LONGINT) THEN - IF SIZE(LONGINT) = 4 THEN - WriteString(W, " -2147483648") - ELSE - WriteString(W, " -9223372036854775808") - END; - RETURN + IF x = MIN(SYSTEM.INT64) THEN WriteString(W, " -9223372036854775808"); RETURN ELSE DEC(n); x0 := -x END ELSE x0 := x diff --git a/src/tools/browser/BrowserCmd.Mod b/src/tools/browser/BrowserCmd.Mod index 55b6c192..564b29b3 100644 --- a/src/tools/browser/BrowserCmd.Mod +++ b/src/tools/browser/BrowserCmd.Mod @@ -1,39 +1,20 @@ MODULE BrowserCmd; (* RC 29.10.93 *) (* object model 4.12.93, command line version jt 4.4.95 *) IMPORT - OPM, OPS, OPT, OPV, Texts, Console, Platform; + OPM, OPS, OPT, OPV, Texts, Console, Platform, SYSTEM; CONST OptionChar = "-"; - (* object modes *) - Var = 1; VarPar = 2; Con = 3; Fld = 4; Typ = 5; LProc = 6; XProc = 7; - 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; - Real = 7; LReal = 8; Set = 9; String = 10; NilTyp = 11; NoTyp = 12; - Pointer = 13; ProcTyp = 14; Comp = 15; - - (* composite structure forms *) - Basic = 1; Array = 2; DynArr = 3; Record = 4; - - (* module visibility of objects *) - internal = 0; external = 1; externalR = 2; - - (* symbol file items *) - Smname = 16; Send = 18; Stype = 19; Salias = 20; Svar = 21; Srvar = 22; - Svalpar = 23; Svarpar = 24; Sfld = 25; Srfld = 26; Shdptr = 27; Shdpro = 28; Stpro = 29; Shdtpro = 30; - Sxpro = 31; Sipro = 32; Scpro = 33; Sstruct = 34; Ssys = 35; Sptr = 36; Sarr = 37; Sdarr = 38; Srec = 39; Spro = 40; VAR W: Texts.Writer; option: CHAR; PROCEDURE Ws(s: ARRAY OF CHAR); BEGIN Texts.WriteString(W, s) END Ws; - PROCEDURE Wch(ch: CHAR); BEGIN Texts.Write(W, ch) END Wch; - PROCEDURE Wi(i: LONGINT); BEGIN Texts.WriteInt(W, i, 0) END Wi; - PROCEDURE Wln; BEGIN Texts.WriteLn(W) END Wln; + PROCEDURE Wch(ch: CHAR); BEGIN Texts.Write(W, ch) END Wch; + PROCEDURE Wi(i: SYSTEM.INT64); BEGIN Texts.WriteInt(W, i, 0) END Wi; + PROCEDURE Wln; BEGIN Texts.WriteLn(W) END Wln; PROCEDURE Indent(i: INTEGER); BEGIN WHILE i > 0 DO Wch(" "); Wch(" "); DEC(i) END @@ -51,7 +32,7 @@ MODULE BrowserCmd; (* RC 29.10.93 *) (* object model 4.12.93, command line ver WHILE par # NIL DO IF ~first THEN Ws("; ") ELSE first := FALSE END ; IF option = "x" THEN Wi(par^.adr); Wch(" ") END ; - IF par^.mode = VarPar THEN Ws("VAR ") END ; + IF par^.mode = OPT.VarPar THEN Ws("VAR ") END ; Ws(par^.name); Ws(": "); Wtype(par^.typ); par := par^.link END ; @@ -60,75 +41,65 @@ MODULE BrowserCmd; (* RC 29.10.93 *) (* object model 4.12.93, command line ver END Wsign; PROCEDURE Objects(obj: OPT.Object; mode: SET); - VAR i: LONGINT; m: INTEGER; s: SET; ext: OPT.ConstExt; + VAR i: SYSTEM.INT64; m: INTEGER; s: SET; ext: OPT.ConstExt; BEGIN IF obj # NIL THEN Objects(obj^.left, mode); IF obj^.mode IN mode THEN CASE obj^.mode OF - | Con: - Indent(2); Ws(obj^.name); Ws(" = "); - CASE obj^.typ^.form OF - | Bool: - IF obj^.conval^.intval = 1 THEN Ws("TRUE") ELSE Ws("FALSE") END - | Char: - IF (obj^.conval^.intval >= 32) & (obj^.conval^.intval <= 126) THEN - Wch(22X); Wch(CHR(obj^.conval^.intval)); Wch(22X) - ELSE - i := obj^.conval^.intval DIV 16; - IF i > 9 THEN Wch(CHR(55 + i)) ELSE Wch(CHR(48 + i)) END ; - i := obj^.conval^.intval MOD 16; - IF i > 9 THEN Wch(CHR(55 + i)) ELSE Wch(CHR(48 + i)) END ; - Wch("X") - END - | SInt, Int, LInt: - Wi(obj^.conval^.intval) - | Set: - Wch("{"); i := 0; s := obj^.conval^.setval; - WHILE i <= MAX(SET) DO - IF i IN s THEN Wi(i); EXCL(s, i); - IF s # {} THEN Ws(", ") END - END ; - INC(i) - END ; - Wch("}") - | Real: - Texts.WriteReal(W, SHORT(obj^.conval^.realval), 16) - | LReal: - Texts.WriteLongReal(W, obj^.conval^.realval, 23) - | String: - Ws(obj^.conval^.ext^) - | NilTyp: - Ws("NIL") - ELSE (* Ignore other forms *) - END ; - Wch(";"); Wln - | Typ: - IF obj^.name # "" THEN Indent(2); - IF obj^.typ^.strobj = obj THEN (* canonical name *) - Wtype(obj^.typ); Ws(" = "); Wstruct(obj^.typ) - ELSE (* alias *) - Ws(obj^.name); Ws(" = "); Wtype(obj^.typ) - END ; - Wch(";"); Wln - END - | Var: - Indent(2); Ws(obj^.name); - IF obj^.vis = externalR THEN Ws("-: ") ELSE Ws(": ") END ; - Wtype(obj^.typ); Wch(";"); Wln - | XProc, CProc, IProc: - Indent(1); Ws("PROCEDURE "); - IF obj^.mode = IProc THEN Wch("+") - ELSIF obj^.mode = CProc THEN Wch("-") - END ; - Ws(obj^.name); - Wsign(obj^.typ, obj^.link); - IF obj^.mode = CProc THEN - ext := obj^.conval^.ext; m := ORD(ext^[0]); i := 1; Ws(' "'); - WHILE i <= m DO Wch(ext^[i]); INC(i) END ; - Wch('"'); - END ; - Wch(";"); Wln + |OPT.Con: Indent(2); Ws(obj^.name); Ws(" = "); + CASE obj^.typ^.form OF + |OPT.Bool: IF obj^.conval^.intval = 1 THEN Ws("TRUE") ELSE Ws("FALSE") END + |OPT.Char: IF (obj^.conval^.intval >= 32) & (obj^.conval^.intval <= 126) THEN + Wch(22X); Wch(CHR(obj^.conval^.intval)); Wch(22X) + ELSE + i := obj^.conval^.intval DIV 16; + IF i > 9 THEN Wch(CHR(55 + i)) ELSE Wch(CHR(48 + i)) END ; + i := obj^.conval^.intval MOD 16; + IF i > 9 THEN Wch(CHR(55 + i)) ELSE Wch(CHR(48 + i)) END ; + Wch("X") + END + |OPT.Int: Wi(obj^.conval^.intval) + |OPT.Set: Wch("{"); i := 0; s := obj^.conval^.setval; + WHILE i <= MAX(SET) DO + IF i IN s THEN Wi(i); EXCL(s, i); + IF s # {} THEN Ws(", ") END + END ; + INC(i) + END ; + Wch("}") + |OPT.Real: Texts.WriteReal(W, SHORT(obj^.conval^.realval), 16) + |OPT.LReal: Texts.WriteLongReal(W, obj^.conval^.realval, 23) + |OPT.String: Ws(obj^.conval^.ext^) + |OPT.NilTyp: Ws("NIL") + ELSE (* Ignore other forms *) + END ; + Wch(";"); Wln + |OPT.Typ: IF obj^.name # "" THEN Indent(2); + IF obj^.typ^.strobj = obj THEN (* canonical name *) + Wtype(obj^.typ); Ws(" = "); Wstruct(obj^.typ) + ELSE (* alias *) + Ws(obj^.name); Ws(" = "); Wtype(obj^.typ) + END ; + Wch(";"); Wln + END + |OPT.Var: Indent(2); Ws(obj^.name); + IF obj^.vis = OPT.externalR THEN Ws("-: ") ELSE Ws(": ") END ; + Wtype(obj^.typ); Wch(";"); Wln + |OPT.XProc, + OPT.CProc, + OPT.IProc: Indent(1); Ws("PROCEDURE "); + IF obj^.mode = OPT.IProc THEN Wch("+") + ELSIF obj^.mode = OPT.CProc THEN Wch("-") + END ; + Ws(obj^.name); + Wsign(obj^.typ, obj^.link); + IF obj^.mode = OPT.CProc THEN + ext := obj^.conval^.ext; m := ORD(ext^[0]); i := 1; Ws(' "'); + WHILE i <= m DO Wch(ext^[i]); INC(i) END ; + Wch('"'); + END ; + Wch(";"); Wln ELSE (* Ignore other modes *) END END ; @@ -141,10 +112,10 @@ MODULE BrowserCmd; (* RC 29.10.93 *) (* object model 4.12.93, command line ver BEGIN IF obj # NIL THEN Wmthd(obj^.left); - IF (obj^.mode = TProc) & ((obj^.name # OPM.HdTProcName) OR (option = "x")) THEN + IF (obj^.mode = OPT.TProc) & ((obj^.name # OPM.HdTProcName) OR (option = "x")) THEN Indent(3); Ws("PROCEDURE ("); IF obj^.name # OPM.HdTProcName THEN - IF obj^.link^.mode = VarPar THEN Ws("VAR ") END ; + IF obj^.link^.mode = OPT.VarPar THEN Ws("VAR ") END ; Ws(obj^.link^.name); Ws(": "); Wtype(obj^.link^.typ) END ; Ws(") "); Ws(obj^.name); @@ -171,40 +142,33 @@ MODULE BrowserCmd; (* RC 29.10.93 *) (* object model 4.12.93, command line ver BEGIN CASE typ^.form OF - | Undef: - Ws("Undef") - | Pointer: - Ws("POINTER "); SysFlag; Ws("TO "); Wtype(typ^.BaseTyp) - | ProcTyp: - Ws("PROCEDURE "); SysFlag; Wsign(typ^.BaseTyp, typ^.link) - | Comp: - CASE typ^.comp OF - | Array: - Ws("ARRAY "); SysFlag; Wi(typ^.n); Ws(" OF "); Wtype(typ^.BaseTyp) - | DynArr: - Ws("ARRAY "); SysFlag; Ws("OF "); Wtype(typ^.BaseTyp) - | Record: - Ws("RECORD ");SysFlag; - IF typ^.BaseTyp # NIL THEN Wch("("); Wtype(typ^.BaseTyp); Wch(")") END ; - Wln; fld := typ^.link; - WHILE (fld # NIL) & (fld^.mode = Fld) DO - IF (option = "x") OR (fld^.name[0] # "@") THEN Indent(3); - IF option = "x" THEN Wi(fld^.adr); Wch(" ") END ; - Ws(fld^.name); - IF fld^.vis = externalR THEN Wch("-") END ; - Ws(": "); Wtype(fld^.typ); Wch(";"); - Wln - END ; - fld := fld^.link - END ; - Wmthd(typ^.link); - Indent(2); Ws("END "); - IF option = "x" THEN Indent(1); - Ws("(* size: "); Wi(typ^.size); Ws(" align: "); Wi(typ^.align); - Ws(" nofm: "); Wi(typ^.n); Ws(" *)") - END - ELSE (* Ignore other comps *) - END + |OPT.Undef: Ws("Undef") + |OPT.Pointer: Ws("POINTER "); SysFlag; Ws("TO "); Wtype(typ^.BaseTyp) + |OPT.ProcTyp: Ws("PROCEDURE "); SysFlag; Wsign(typ^.BaseTyp, typ^.link) + |OPT.Comp: CASE typ^.comp OF + |OPT.Array: Ws("ARRAY "); SysFlag; Wi(typ^.n); Ws(" OF "); Wtype(typ^.BaseTyp) + |OPT.DynArr: Ws("ARRAY "); SysFlag; Ws("OF "); Wtype(typ^.BaseTyp) + |OPT.Record: Ws("RECORD ");SysFlag; + IF typ^.BaseTyp # NIL THEN Wch("("); Wtype(typ^.BaseTyp); Wch(")") END ; + Wln; fld := typ^.link; + WHILE (fld # NIL) & (fld^.mode = OPT.Fld) DO + IF (option = "x") OR (fld^.name[0] # "@") THEN Indent(3); + IF option = "x" THEN Wi(fld^.adr); Wch(" ") END ; + Ws(fld^.name); + IF fld^.vis = OPT.externalR THEN Wch("-") END ; + Ws(": "); Wtype(fld^.typ); Wch(";"); + Wln + END ; + fld := fld^.link + END ; + Wmthd(typ^.link); + Indent(2); Ws("END "); + IF option = "x" THEN Indent(1); + Ws("(* size: "); Wi(typ^.size); Ws(" align: "); Wi(typ^.align); + Ws(" nofm: "); Wi(typ^.n); Ws(" *)") + END + ELSE (* Ignore other comps *) + END ELSE (* Ignore other froms *) END END Wstruct; @@ -216,7 +180,7 @@ MODULE BrowserCmd; (* RC 29.10.93 *) (* object model 4.12.93, command line ver IF obj^.name # "" THEN IF typ^.mno # 0 THEN Ws(OPT.GlbMod[typ^.mno].name); Wch(".") ELSIF (typ = OPT.bytetyp) OR (typ = OPT.sysptrtyp) THEN Ws("SYSTEM.") - ELSIF obj^.vis = internal THEN Wch("#") + ELSIF obj^.vis = OPT.internal THEN Wch("#") END ; Ws(obj^.name) ELSE @@ -242,7 +206,7 @@ MODULE BrowserCmd; (* RC 29.10.93 *) (* object model 4.12.93, command line ver ELSE Wln END END CheckHeader; - + BEGIN OPT.Import("@notself", name, done); IF done THEN @@ -255,10 +219,10 @@ MODULE BrowserCmd; (* RC 29.10.93 *) (* object model 4.12.93, command line ver END ; IF ~first THEN Wch(";"); Wln END ; CheckHeader; - Header("CONST"); Objects(OPT.GlbMod[0].right, {Con}); CheckHeader; - Header("TYPE"); Objects(OPT.GlbMod[0].right, {Typ}); CheckHeader; - Header("VAR"); Objects(OPT.GlbMod[0].right, {Var}); CheckHeader; - Objects(OPT.GlbMod[0].right, {XProc, IProc, CProc}); + Header("CONST"); Objects(OPT.GlbMod[0].right, {OPT.Con}); CheckHeader; + Header("TYPE"); Objects(OPT.GlbMod[0].right, {OPT.Typ}); CheckHeader; + Header("VAR"); Objects(OPT.GlbMod[0].right, {OPT.Var}); CheckHeader; + Objects(OPT.GlbMod[0].right, {OPT.XProc, OPT.IProc, OPT.CProc}); Wln; Ws("END "); Ws(name); Wch("."); Wln; Texts.Append(T, W.buf) ELSE @@ -266,7 +230,7 @@ MODULE BrowserCmd; (* RC 29.10.93 *) (* object model 4.12.93, command line ver Texts.WriteLn(W); Texts.Append(T, W.buf) END END WModule; - + PROCEDURE Ident(VAR name, first: ARRAY OF CHAR); VAR i, j: INTEGER; ch: CHAR; BEGIN i := 0; diff --git a/src/tools/make/vishap.make b/src/tools/make/vishap.make index faacf33f..008180cb 100644 --- a/src/tools/make/vishap.make +++ b/src/tools/make/vishap.make @@ -335,7 +335,7 @@ misc: s3: @printf "\nMaking s3 library\n" cd $(BUILDDIR); $(ROOTDIR)/$(VISHAP) -Ffs ../../src/library/s3/ethBTrees.Mod - cd $(BUILDDIR); $(ROOTDIR)/$(VISHAP) -Ffs ../../src/library/s3/ethMD5.Mod +# cd $(BUILDDIR); $(ROOTDIR)/$(VISHAP) -Ffs ../../src/library/s3/ethMD5.Mod cd $(BUILDDIR); $(ROOTDIR)/$(VISHAP) -Ffs ../../src/library/s3/ethSets.Mod cd $(BUILDDIR); $(ROOTDIR)/$(VISHAP) -Ffs ../../src/library/s3/ethZlib.Mod cd $(BUILDDIR); $(ROOTDIR)/$(VISHAP) -Ffs ../../src/library/s3/ethZlibBuffers.Mod