From d344c9ce807581c6894eb5e87dc3f1ab10837fd9 Mon Sep 17 00:00:00 2001 From: David Brown Date: Fri, 30 Sep 2016 20:30:58 +0100 Subject: [PATCH] Set size testing and constant size propagation. --- bootstrap/unix-44/OPB.c | 26 ++++++++++++++------- bootstrap/unix-44/OPC.c | 4 ++-- bootstrap/unix-48/OPB.c | 26 ++++++++++++++------- bootstrap/unix-48/OPC.c | 4 ++-- bootstrap/unix-88/OPB.c | 26 ++++++++++++++------- bootstrap/unix-88/OPC.c | 4 ++-- bootstrap/windows-48/OPB.c | 26 ++++++++++++++------- bootstrap/windows-48/OPC.c | 4 ++-- bootstrap/windows-88/OPB.c | 26 ++++++++++++++------- bootstrap/windows-88/OPC.c | 4 ++-- src/compiler/OPB.Mod | 39 ++++++++++++++++++-------------- src/compiler/OPC.Mod | 4 ++-- src/tools/browser/BrowserCmd.Mod | 4 ++-- 13 files changed, 126 insertions(+), 71 deletions(-) diff --git a/bootstrap/unix-44/OPB.c b/bootstrap/unix-44/OPB.c index 43c9e328..61ddc369 100644 --- a/bootstrap/unix-44/OPB.c +++ b/bootstrap/unix-44/OPB.c @@ -468,7 +468,7 @@ void OPB_In (OPT_Node *x, OPT_Node y) } else if ((f == 4 && y->typ->form == 7)) { if ((*x)->class == 7) { k = (*x)->conval->intval; - if (k < 0 || k > (int64)OPM_MaxSet) { + if (k < 0 || k >= (int64)__ASHL(y->typ->size, 3)) { OPB_err(202); } else if (y->class == 7) { (*x)->conval->intval = OPB_BoolToInt(__IN(k, y->conval->setval, 64)); @@ -584,7 +584,11 @@ void OPB_MOp (int8 op, OPT_Node *x) } else if (__IN(f, 0x60, 32)) { z->conval->realval = -z->conval->realval; } else { - z->conval->setval = ~z->conval->setval; + if (z->typ->size == 8) { + z->conval->setval = ~z->conval->setval; + } else { + z->conval->setval = z->conval->setval ^ 0xffffffff; + } } z->obj = NIL; } else { @@ -959,6 +963,7 @@ static void OPB_ConstOp (int16 op, OPT_Node x, OPT_Node y) } } else if (f == 7) { xval->setval = (xval->setval & yval->setval); + OPB_SetSetType(x); } else if (f != 0) { OPB_err(101); } @@ -983,6 +988,7 @@ static void OPB_ConstOp (int16 op, OPT_Node x, OPT_Node y) } } else if (f == 7) { xval->setval = xval->setval ^ yval->setval; + OPB_SetSetType(x); } else if (f != 0) { OPB_err(102); } @@ -1037,6 +1043,7 @@ static void OPB_ConstOp (int16 op, OPT_Node x, OPT_Node y) } } else if (f == 7) { xval->setval = xval->setval | yval->setval; + OPB_SetSetType(x); } else if (f != 0) { OPB_err(105); } @@ -1059,6 +1066,7 @@ static void OPB_ConstOp (int16 op, OPT_Node x, OPT_Node y) } } else if (f == 7) { xval->setval = (xval->setval & ~yval->setval); + OPB_SetSetType(x); } else if (f != 0) { OPB_err(106); } @@ -1514,19 +1522,20 @@ void OPB_SetRange (OPT_Node *x, OPT_Node y) } else if (((*x)->typ->form == 4 && y->typ->form == 4)) { if ((*x)->class == 7) { k = (*x)->conval->intval; - if (0 > k || k > (int64)OPM_MaxSet) { + if (0 > k || k > 31) { OPB_err(202); } } if (y->class == 7) { l = y->conval->intval; - if (0 > l || l > (int64)OPM_MaxSet) { + if (0 > l || l > 31) { OPB_err(202); } } if (((*x)->class == 7 && y->class == 7)) { if (k <= l) { (*x)->conval->setval = __SETRNG(k, l, 32); + OPB_SetSetType(*x); } else { OPB_err(201); (*x)->conval->setval = __SETRNG(l, k, 32); @@ -1550,8 +1559,9 @@ void OPB_SetElem (OPT_Node *x) OPB_err(93); } else if ((*x)->class == 7) { k = (*x)->conval->intval; - if ((0 <= k && k <= (int64)OPM_MaxSet)) { + if ((0 <= k && k <= 31)) { (*x)->conval->setval = __SETOF(k,32); + OPB_SetSetType(*x); } else { OPB_err(202); } @@ -1581,13 +1591,13 @@ static void OPB_CheckAssign (OPT_Struct x, OPT_Node ynode) OPB_err(113); } break; - case 2: case 3: case 7: + case 2: case 3: if (g != f) { OPB_err(113); } break; - case 4: - if (g != 4 || x->size < y->size) { + case 4: case 7: + if (g != f || x->size < y->size) { OPB_err(113); } break; diff --git a/bootstrap/unix-44/OPC.c b/bootstrap/unix-44/OPC.c index 545deb33..5a228db9 100644 --- a/bootstrap/unix-44/OPC.c +++ b/bootstrap/unix-44/OPC.c @@ -1859,7 +1859,7 @@ void OPC_Len (OPT_Object obj, OPT_Struct array, int64 dim) void OPC_Constant (OPT_Const con, int16 form) { int16 i; - uint32 s; + uint64 s; int32 hex; BOOLEAN skipLeading; switch (form) { @@ -1891,7 +1891,7 @@ void OPC_Constant (OPT_Const con, int16 form) do { i -= 1; hex = __ASHL(hex, 1); - if (__IN(i, s, 32)) { + if (__IN(i, s, 64)) { hex += 1; } } while (!(__MASK(i, -8) == 0)); diff --git a/bootstrap/unix-48/OPB.c b/bootstrap/unix-48/OPB.c index 43c9e328..61ddc369 100644 --- a/bootstrap/unix-48/OPB.c +++ b/bootstrap/unix-48/OPB.c @@ -468,7 +468,7 @@ void OPB_In (OPT_Node *x, OPT_Node y) } else if ((f == 4 && y->typ->form == 7)) { if ((*x)->class == 7) { k = (*x)->conval->intval; - if (k < 0 || k > (int64)OPM_MaxSet) { + if (k < 0 || k >= (int64)__ASHL(y->typ->size, 3)) { OPB_err(202); } else if (y->class == 7) { (*x)->conval->intval = OPB_BoolToInt(__IN(k, y->conval->setval, 64)); @@ -584,7 +584,11 @@ void OPB_MOp (int8 op, OPT_Node *x) } else if (__IN(f, 0x60, 32)) { z->conval->realval = -z->conval->realval; } else { - z->conval->setval = ~z->conval->setval; + if (z->typ->size == 8) { + z->conval->setval = ~z->conval->setval; + } else { + z->conval->setval = z->conval->setval ^ 0xffffffff; + } } z->obj = NIL; } else { @@ -959,6 +963,7 @@ static void OPB_ConstOp (int16 op, OPT_Node x, OPT_Node y) } } else if (f == 7) { xval->setval = (xval->setval & yval->setval); + OPB_SetSetType(x); } else if (f != 0) { OPB_err(101); } @@ -983,6 +988,7 @@ static void OPB_ConstOp (int16 op, OPT_Node x, OPT_Node y) } } else if (f == 7) { xval->setval = xval->setval ^ yval->setval; + OPB_SetSetType(x); } else if (f != 0) { OPB_err(102); } @@ -1037,6 +1043,7 @@ static void OPB_ConstOp (int16 op, OPT_Node x, OPT_Node y) } } else if (f == 7) { xval->setval = xval->setval | yval->setval; + OPB_SetSetType(x); } else if (f != 0) { OPB_err(105); } @@ -1059,6 +1066,7 @@ static void OPB_ConstOp (int16 op, OPT_Node x, OPT_Node y) } } else if (f == 7) { xval->setval = (xval->setval & ~yval->setval); + OPB_SetSetType(x); } else if (f != 0) { OPB_err(106); } @@ -1514,19 +1522,20 @@ void OPB_SetRange (OPT_Node *x, OPT_Node y) } else if (((*x)->typ->form == 4 && y->typ->form == 4)) { if ((*x)->class == 7) { k = (*x)->conval->intval; - if (0 > k || k > (int64)OPM_MaxSet) { + if (0 > k || k > 31) { OPB_err(202); } } if (y->class == 7) { l = y->conval->intval; - if (0 > l || l > (int64)OPM_MaxSet) { + if (0 > l || l > 31) { OPB_err(202); } } if (((*x)->class == 7 && y->class == 7)) { if (k <= l) { (*x)->conval->setval = __SETRNG(k, l, 32); + OPB_SetSetType(*x); } else { OPB_err(201); (*x)->conval->setval = __SETRNG(l, k, 32); @@ -1550,8 +1559,9 @@ void OPB_SetElem (OPT_Node *x) OPB_err(93); } else if ((*x)->class == 7) { k = (*x)->conval->intval; - if ((0 <= k && k <= (int64)OPM_MaxSet)) { + if ((0 <= k && k <= 31)) { (*x)->conval->setval = __SETOF(k,32); + OPB_SetSetType(*x); } else { OPB_err(202); } @@ -1581,13 +1591,13 @@ static void OPB_CheckAssign (OPT_Struct x, OPT_Node ynode) OPB_err(113); } break; - case 2: case 3: case 7: + case 2: case 3: if (g != f) { OPB_err(113); } break; - case 4: - if (g != 4 || x->size < y->size) { + case 4: case 7: + if (g != f || x->size < y->size) { OPB_err(113); } break; diff --git a/bootstrap/unix-48/OPC.c b/bootstrap/unix-48/OPC.c index 545deb33..5a228db9 100644 --- a/bootstrap/unix-48/OPC.c +++ b/bootstrap/unix-48/OPC.c @@ -1859,7 +1859,7 @@ void OPC_Len (OPT_Object obj, OPT_Struct array, int64 dim) void OPC_Constant (OPT_Const con, int16 form) { int16 i; - uint32 s; + uint64 s; int32 hex; BOOLEAN skipLeading; switch (form) { @@ -1891,7 +1891,7 @@ void OPC_Constant (OPT_Const con, int16 form) do { i -= 1; hex = __ASHL(hex, 1); - if (__IN(i, s, 32)) { + if (__IN(i, s, 64)) { hex += 1; } } while (!(__MASK(i, -8) == 0)); diff --git a/bootstrap/unix-88/OPB.c b/bootstrap/unix-88/OPB.c index 43c9e328..61ddc369 100644 --- a/bootstrap/unix-88/OPB.c +++ b/bootstrap/unix-88/OPB.c @@ -468,7 +468,7 @@ void OPB_In (OPT_Node *x, OPT_Node y) } else if ((f == 4 && y->typ->form == 7)) { if ((*x)->class == 7) { k = (*x)->conval->intval; - if (k < 0 || k > (int64)OPM_MaxSet) { + if (k < 0 || k >= (int64)__ASHL(y->typ->size, 3)) { OPB_err(202); } else if (y->class == 7) { (*x)->conval->intval = OPB_BoolToInt(__IN(k, y->conval->setval, 64)); @@ -584,7 +584,11 @@ void OPB_MOp (int8 op, OPT_Node *x) } else if (__IN(f, 0x60, 32)) { z->conval->realval = -z->conval->realval; } else { - z->conval->setval = ~z->conval->setval; + if (z->typ->size == 8) { + z->conval->setval = ~z->conval->setval; + } else { + z->conval->setval = z->conval->setval ^ 0xffffffff; + } } z->obj = NIL; } else { @@ -959,6 +963,7 @@ static void OPB_ConstOp (int16 op, OPT_Node x, OPT_Node y) } } else if (f == 7) { xval->setval = (xval->setval & yval->setval); + OPB_SetSetType(x); } else if (f != 0) { OPB_err(101); } @@ -983,6 +988,7 @@ static void OPB_ConstOp (int16 op, OPT_Node x, OPT_Node y) } } else if (f == 7) { xval->setval = xval->setval ^ yval->setval; + OPB_SetSetType(x); } else if (f != 0) { OPB_err(102); } @@ -1037,6 +1043,7 @@ static void OPB_ConstOp (int16 op, OPT_Node x, OPT_Node y) } } else if (f == 7) { xval->setval = xval->setval | yval->setval; + OPB_SetSetType(x); } else if (f != 0) { OPB_err(105); } @@ -1059,6 +1066,7 @@ static void OPB_ConstOp (int16 op, OPT_Node x, OPT_Node y) } } else if (f == 7) { xval->setval = (xval->setval & ~yval->setval); + OPB_SetSetType(x); } else if (f != 0) { OPB_err(106); } @@ -1514,19 +1522,20 @@ void OPB_SetRange (OPT_Node *x, OPT_Node y) } else if (((*x)->typ->form == 4 && y->typ->form == 4)) { if ((*x)->class == 7) { k = (*x)->conval->intval; - if (0 > k || k > (int64)OPM_MaxSet) { + if (0 > k || k > 31) { OPB_err(202); } } if (y->class == 7) { l = y->conval->intval; - if (0 > l || l > (int64)OPM_MaxSet) { + if (0 > l || l > 31) { OPB_err(202); } } if (((*x)->class == 7 && y->class == 7)) { if (k <= l) { (*x)->conval->setval = __SETRNG(k, l, 32); + OPB_SetSetType(*x); } else { OPB_err(201); (*x)->conval->setval = __SETRNG(l, k, 32); @@ -1550,8 +1559,9 @@ void OPB_SetElem (OPT_Node *x) OPB_err(93); } else if ((*x)->class == 7) { k = (*x)->conval->intval; - if ((0 <= k && k <= (int64)OPM_MaxSet)) { + if ((0 <= k && k <= 31)) { (*x)->conval->setval = __SETOF(k,32); + OPB_SetSetType(*x); } else { OPB_err(202); } @@ -1581,13 +1591,13 @@ static void OPB_CheckAssign (OPT_Struct x, OPT_Node ynode) OPB_err(113); } break; - case 2: case 3: case 7: + case 2: case 3: if (g != f) { OPB_err(113); } break; - case 4: - if (g != 4 || x->size < y->size) { + case 4: case 7: + if (g != f || x->size < y->size) { OPB_err(113); } break; diff --git a/bootstrap/unix-88/OPC.c b/bootstrap/unix-88/OPC.c index 545deb33..5a228db9 100644 --- a/bootstrap/unix-88/OPC.c +++ b/bootstrap/unix-88/OPC.c @@ -1859,7 +1859,7 @@ void OPC_Len (OPT_Object obj, OPT_Struct array, int64 dim) void OPC_Constant (OPT_Const con, int16 form) { int16 i; - uint32 s; + uint64 s; int32 hex; BOOLEAN skipLeading; switch (form) { @@ -1891,7 +1891,7 @@ void OPC_Constant (OPT_Const con, int16 form) do { i -= 1; hex = __ASHL(hex, 1); - if (__IN(i, s, 32)) { + if (__IN(i, s, 64)) { hex += 1; } } while (!(__MASK(i, -8) == 0)); diff --git a/bootstrap/windows-48/OPB.c b/bootstrap/windows-48/OPB.c index 43c9e328..61ddc369 100644 --- a/bootstrap/windows-48/OPB.c +++ b/bootstrap/windows-48/OPB.c @@ -468,7 +468,7 @@ void OPB_In (OPT_Node *x, OPT_Node y) } else if ((f == 4 && y->typ->form == 7)) { if ((*x)->class == 7) { k = (*x)->conval->intval; - if (k < 0 || k > (int64)OPM_MaxSet) { + if (k < 0 || k >= (int64)__ASHL(y->typ->size, 3)) { OPB_err(202); } else if (y->class == 7) { (*x)->conval->intval = OPB_BoolToInt(__IN(k, y->conval->setval, 64)); @@ -584,7 +584,11 @@ void OPB_MOp (int8 op, OPT_Node *x) } else if (__IN(f, 0x60, 32)) { z->conval->realval = -z->conval->realval; } else { - z->conval->setval = ~z->conval->setval; + if (z->typ->size == 8) { + z->conval->setval = ~z->conval->setval; + } else { + z->conval->setval = z->conval->setval ^ 0xffffffff; + } } z->obj = NIL; } else { @@ -959,6 +963,7 @@ static void OPB_ConstOp (int16 op, OPT_Node x, OPT_Node y) } } else if (f == 7) { xval->setval = (xval->setval & yval->setval); + OPB_SetSetType(x); } else if (f != 0) { OPB_err(101); } @@ -983,6 +988,7 @@ static void OPB_ConstOp (int16 op, OPT_Node x, OPT_Node y) } } else if (f == 7) { xval->setval = xval->setval ^ yval->setval; + OPB_SetSetType(x); } else if (f != 0) { OPB_err(102); } @@ -1037,6 +1043,7 @@ static void OPB_ConstOp (int16 op, OPT_Node x, OPT_Node y) } } else if (f == 7) { xval->setval = xval->setval | yval->setval; + OPB_SetSetType(x); } else if (f != 0) { OPB_err(105); } @@ -1059,6 +1066,7 @@ static void OPB_ConstOp (int16 op, OPT_Node x, OPT_Node y) } } else if (f == 7) { xval->setval = (xval->setval & ~yval->setval); + OPB_SetSetType(x); } else if (f != 0) { OPB_err(106); } @@ -1514,19 +1522,20 @@ void OPB_SetRange (OPT_Node *x, OPT_Node y) } else if (((*x)->typ->form == 4 && y->typ->form == 4)) { if ((*x)->class == 7) { k = (*x)->conval->intval; - if (0 > k || k > (int64)OPM_MaxSet) { + if (0 > k || k > 31) { OPB_err(202); } } if (y->class == 7) { l = y->conval->intval; - if (0 > l || l > (int64)OPM_MaxSet) { + if (0 > l || l > 31) { OPB_err(202); } } if (((*x)->class == 7 && y->class == 7)) { if (k <= l) { (*x)->conval->setval = __SETRNG(k, l, 32); + OPB_SetSetType(*x); } else { OPB_err(201); (*x)->conval->setval = __SETRNG(l, k, 32); @@ -1550,8 +1559,9 @@ void OPB_SetElem (OPT_Node *x) OPB_err(93); } else if ((*x)->class == 7) { k = (*x)->conval->intval; - if ((0 <= k && k <= (int64)OPM_MaxSet)) { + if ((0 <= k && k <= 31)) { (*x)->conval->setval = __SETOF(k,32); + OPB_SetSetType(*x); } else { OPB_err(202); } @@ -1581,13 +1591,13 @@ static void OPB_CheckAssign (OPT_Struct x, OPT_Node ynode) OPB_err(113); } break; - case 2: case 3: case 7: + case 2: case 3: if (g != f) { OPB_err(113); } break; - case 4: - if (g != 4 || x->size < y->size) { + case 4: case 7: + if (g != f || x->size < y->size) { OPB_err(113); } break; diff --git a/bootstrap/windows-48/OPC.c b/bootstrap/windows-48/OPC.c index 545deb33..5a228db9 100644 --- a/bootstrap/windows-48/OPC.c +++ b/bootstrap/windows-48/OPC.c @@ -1859,7 +1859,7 @@ void OPC_Len (OPT_Object obj, OPT_Struct array, int64 dim) void OPC_Constant (OPT_Const con, int16 form) { int16 i; - uint32 s; + uint64 s; int32 hex; BOOLEAN skipLeading; switch (form) { @@ -1891,7 +1891,7 @@ void OPC_Constant (OPT_Const con, int16 form) do { i -= 1; hex = __ASHL(hex, 1); - if (__IN(i, s, 32)) { + if (__IN(i, s, 64)) { hex += 1; } } while (!(__MASK(i, -8) == 0)); diff --git a/bootstrap/windows-88/OPB.c b/bootstrap/windows-88/OPB.c index 43c9e328..61ddc369 100644 --- a/bootstrap/windows-88/OPB.c +++ b/bootstrap/windows-88/OPB.c @@ -468,7 +468,7 @@ void OPB_In (OPT_Node *x, OPT_Node y) } else if ((f == 4 && y->typ->form == 7)) { if ((*x)->class == 7) { k = (*x)->conval->intval; - if (k < 0 || k > (int64)OPM_MaxSet) { + if (k < 0 || k >= (int64)__ASHL(y->typ->size, 3)) { OPB_err(202); } else if (y->class == 7) { (*x)->conval->intval = OPB_BoolToInt(__IN(k, y->conval->setval, 64)); @@ -584,7 +584,11 @@ void OPB_MOp (int8 op, OPT_Node *x) } else if (__IN(f, 0x60, 32)) { z->conval->realval = -z->conval->realval; } else { - z->conval->setval = ~z->conval->setval; + if (z->typ->size == 8) { + z->conval->setval = ~z->conval->setval; + } else { + z->conval->setval = z->conval->setval ^ 0xffffffff; + } } z->obj = NIL; } else { @@ -959,6 +963,7 @@ static void OPB_ConstOp (int16 op, OPT_Node x, OPT_Node y) } } else if (f == 7) { xval->setval = (xval->setval & yval->setval); + OPB_SetSetType(x); } else if (f != 0) { OPB_err(101); } @@ -983,6 +988,7 @@ static void OPB_ConstOp (int16 op, OPT_Node x, OPT_Node y) } } else if (f == 7) { xval->setval = xval->setval ^ yval->setval; + OPB_SetSetType(x); } else if (f != 0) { OPB_err(102); } @@ -1037,6 +1043,7 @@ static void OPB_ConstOp (int16 op, OPT_Node x, OPT_Node y) } } else if (f == 7) { xval->setval = xval->setval | yval->setval; + OPB_SetSetType(x); } else if (f != 0) { OPB_err(105); } @@ -1059,6 +1066,7 @@ static void OPB_ConstOp (int16 op, OPT_Node x, OPT_Node y) } } else if (f == 7) { xval->setval = (xval->setval & ~yval->setval); + OPB_SetSetType(x); } else if (f != 0) { OPB_err(106); } @@ -1514,19 +1522,20 @@ void OPB_SetRange (OPT_Node *x, OPT_Node y) } else if (((*x)->typ->form == 4 && y->typ->form == 4)) { if ((*x)->class == 7) { k = (*x)->conval->intval; - if (0 > k || k > (int64)OPM_MaxSet) { + if (0 > k || k > 31) { OPB_err(202); } } if (y->class == 7) { l = y->conval->intval; - if (0 > l || l > (int64)OPM_MaxSet) { + if (0 > l || l > 31) { OPB_err(202); } } if (((*x)->class == 7 && y->class == 7)) { if (k <= l) { (*x)->conval->setval = __SETRNG(k, l, 32); + OPB_SetSetType(*x); } else { OPB_err(201); (*x)->conval->setval = __SETRNG(l, k, 32); @@ -1550,8 +1559,9 @@ void OPB_SetElem (OPT_Node *x) OPB_err(93); } else if ((*x)->class == 7) { k = (*x)->conval->intval; - if ((0 <= k && k <= (int64)OPM_MaxSet)) { + if ((0 <= k && k <= 31)) { (*x)->conval->setval = __SETOF(k,32); + OPB_SetSetType(*x); } else { OPB_err(202); } @@ -1581,13 +1591,13 @@ static void OPB_CheckAssign (OPT_Struct x, OPT_Node ynode) OPB_err(113); } break; - case 2: case 3: case 7: + case 2: case 3: if (g != f) { OPB_err(113); } break; - case 4: - if (g != 4 || x->size < y->size) { + case 4: case 7: + if (g != f || x->size < y->size) { OPB_err(113); } break; diff --git a/bootstrap/windows-88/OPC.c b/bootstrap/windows-88/OPC.c index 545deb33..5a228db9 100644 --- a/bootstrap/windows-88/OPC.c +++ b/bootstrap/windows-88/OPC.c @@ -1859,7 +1859,7 @@ void OPC_Len (OPT_Object obj, OPT_Struct array, int64 dim) void OPC_Constant (OPT_Const con, int16 form) { int16 i; - uint32 s; + uint64 s; int32 hex; BOOLEAN skipLeading; switch (form) { @@ -1891,7 +1891,7 @@ void OPC_Constant (OPT_Const con, int16 form) do { i -= 1; hex = __ASHL(hex, 1); - if (__IN(i, s, 32)) { + if (__IN(i, s, 64)) { hex += 1; } } while (!(__MASK(i, -8) == 0)); diff --git a/src/compiler/OPB.Mod b/src/compiler/OPB.Mod index c1a317d2..17b4be1b 100644 --- a/src/compiler/OPB.Mod +++ b/src/compiler/OPB.Mod @@ -243,7 +243,7 @@ MODULE OPB; (* RC 6.3.89 / 21.2.94 *) (* object model 17.1.93 *) ELSIF (f = OPT.Int) & (y^.typ^.form = OPT.Set) THEN IF x^.class = OPT.Nconst THEN k := x^.conval^.intval; - IF (k < 0) OR (k > OPM.MaxSet) THEN err(202) + IF (k < 0) OR (k >= y.typ.size*8) THEN err(202) ELSIF y^.class = OPT.Nconst THEN x^.conval^.intval := BoolToInt(k IN y^.conval^.setval); x^.obj := NIL ELSE BindNodes(OPT.Ndop, OPT.booltyp, x, y); x^.subcl := OPS.in END @@ -305,8 +305,13 @@ MODULE OPB; (* RC 6.3.89 / 21.2.94 *) (* object model 17.1.93 *) ELSE z^.conval^.intval := -z^.conval^.intval; SetIntType(z) END ELSIF f IN OPT.realSet THEN z^.conval^.realval := -z^.conval^.realval - ELSE z^.conval^.setval := -z^.conval^.setval - END ; + ELSE + IF z.typ.size = 8 THEN + z^.conval^.setval := -z^.conval^.setval + ELSE + z.conval.setval := z.conval.setval / {0..31} + END + END; z^.obj := NIL ELSE z := NewOp(op, typ, z) END @@ -503,7 +508,7 @@ MODULE OPB; (* RC 6.3.89 / 21.2.94 *) (* object model 17.1.93 *) ELSE err(204) END ELSIF f = OPT.Set THEN - xval^.setval := xval^.setval * yval^.setval + xval^.setval := xval^.setval * yval^.setval; SetSetType(x) ELSIF f # OPT.Undef THEN err(101) END |OPS.slash: IF f = OPT.Int THEN @@ -519,7 +524,7 @@ MODULE OPB; (* RC 6.3.89 / 21.2.94 *) (* object model 17.1.93 *) ELSE err(205) END ELSIF f = OPT.Set THEN - xval^.setval := xval^.setval / yval^.setval + xval^.setval := xval^.setval / yval^.setval; SetSetType(x) ELSIF f # OPT.Undef THEN err(102) END |OPS.div: IF f = OPT.Int THEN @@ -553,7 +558,7 @@ MODULE OPB; (* RC 6.3.89 / 21.2.94 *) (* object model 17.1.93 *) ELSE err(206) END ELSIF f = OPT.Set THEN - xval^.setval := xval^.setval + yval^.setval + xval^.setval := xval^.setval + yval^.setval; SetSetType(x) ELSIF f # OPT.Undef THEN err(105) END |OPS.minus: IF f = OPT.Int THEN @@ -569,7 +574,7 @@ MODULE OPB; (* RC 6.3.89 / 21.2.94 *) (* object model 17.1.93 *) ELSE err(207) END ELSIF f = OPT.Set THEN - xval^.setval := xval^.setval - yval^.setval + xval^.setval := xval^.setval - yval^.setval; SetSetType(x) ELSIF f # OPT.Undef THEN err(106) END |OPS.or: IF f = OPT.Bool THEN @@ -799,23 +804,23 @@ MODULE OPB; (* RC 6.3.89 / 21.2.94 *) (* object model 17.1.93 *) ELSIF (x^.typ^.form = OPT.Int) & (y^.typ^.form = OPT.Int) THEN IF x^.class = OPT.Nconst THEN k := x^.conval^.intval; - IF (0 > k) OR (k > OPM.MaxSet) THEN err(202) END + IF (0 > k) OR (k > MAX(SYSTEM.SET64)) THEN err(202) END END ; IF y^.class = OPT.Nconst THEN l := y^.conval^.intval; - IF (0 > l) OR (l > OPM.MaxSet) THEN err(202) END + IF (0 > l) OR (l > MAX(SYSTEM.SET64)) THEN err(202) END END ; IF (x^.class = OPT.Nconst) & (y^.class = OPT.Nconst) THEN IF k <= l THEN - x^.conval^.setval := {k..l} + x^.conval^.setval := {k..l}; SetSetType(x) ELSE err(201); x^.conval^.setval := {l..k} END ; x^.obj := NIL - ELSE BindNodes(OPT.Nupto, OPT.settyp, x, y) (* todo choose appropriate set type ? *) + ELSE BindNodes(OPT.Nupto, OPT.settyp, x, y) END ELSE err(93) END ; - x^.typ := OPT.settyp (* todo choose appropriate set type ? *) + x^.typ := OPT.settyp (* todo: syntax for specifying set type e.g. SYSTEM.SET64{n1..n2} *) END SetRange; PROCEDURE SetElem*(VAR x: OPT.Node); @@ -825,12 +830,12 @@ MODULE OPB; (* RC 6.3.89 / 21.2.94 *) (* object model 17.1.93 *) ELSIF x^.typ^.form # OPT.Int THEN err(93) ELSIF x^.class = OPT.Nconst THEN k := x^.conval^.intval; - IF (0 <= k) & (k <= OPM.MaxSet) THEN x^.conval^.setval := {k} + IF (0 <= k) & (k <= MAX(SYSTEM.SET64)) THEN x^.conval^.setval := {k}; SetSetType(x) ELSE err(202) END ; x^.obj := NIL ELSE Convert(x, OPT.settyp) (* todo choose appropriate set type ? *) - END ; + END; x^.typ := OPT.settyp (* todo choose appropriate set type ? *) END SetElem; @@ -859,9 +864,9 @@ MODULE OPB; (* RC 6.3.89 / 21.2.94 *) (* object model 17.1.93 *) OPT.String: | OPT.Byte: IF ~((g IN {OPT.Byte, OPT.Char, OPT.Int}) & (y.size = 1)) THEN err(113) END | OPT.Bool, - OPT.Char, - OPT.Set: IF g # f THEN err(113) END - | OPT.Int: IF (g # OPT.Int) OR (x.size < y.size) THEN err(113) END + OPT.Char: IF g # f THEN err(113) END + | OPT.Int, + OPT.Set: IF (g # f) OR (x.size < y.size) THEN err(113) END | OPT.Real: IF ~(g IN {OPT.Int..OPT.Real}) THEN err(113) END | OPT.LReal: IF ~(g IN {OPT.Int..OPT.LReal}) THEN err(113) END | OPT.Pointer: IF (x = y) OR (g = OPT.NilTyp) OR (x = OPT.sysptrtyp) & (g = OPT.Pointer) THEN (* ok *) diff --git a/src/compiler/OPC.Mod b/src/compiler/OPC.Mod index e601db3a..06252183 100644 --- a/src/compiler/OPC.Mod +++ b/src/compiler/OPC.Mod @@ -1227,7 +1227,7 @@ MODULE OPC; (* copyright (c) J. Templ 12.7.95 / 3.7.96 *) END Len; PROCEDURE Constant* (con: OPT.Const; form: INTEGER); - VAR i: INTEGER; s: SET; + VAR i: INTEGER; s: SYSTEM.SET64; hex: LONGINT; skipLeading: BOOLEAN; BEGIN CASE form OF @@ -1239,7 +1239,7 @@ MODULE OPC; (* copyright (c) J. Templ 12.7.95 / 3.7.96 *) | OPT.LReal: OPM.WriteReal(con^.realval, 0X) | OPT.Set: OPM.WriteString("0x"); skipLeading := TRUE; - s := con^.setval; i := MAX(SET) + 1; + s := con^.setval; i := MAX(SYSTEM.SET64) + 1; REPEAT hex := 0; REPEAT diff --git a/src/tools/browser/BrowserCmd.Mod b/src/tools/browser/BrowserCmd.Mod index 28573293..b017c028 100644 --- a/src/tools/browser/BrowserCmd.Mod +++ b/src/tools/browser/BrowserCmd.Mod @@ -41,7 +41,7 @@ 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: SYSTEM.INT64; m: INTEGER; s: SET; ext: OPT.ConstExt; + VAR i: SYSTEM.INT64; m: INTEGER; s: SYSTEM.SET64; ext: OPT.ConstExt; BEGIN IF obj # NIL THEN Objects(obj^.left, mode); @@ -61,7 +61,7 @@ MODULE BrowserCmd; (* RC 29.10.93 *) (* object model 4.12.93, command line ver END |OPT.Int: Wi(obj^.conval^.intval) |OPT.Set: Wch("{"); i := 0; s := obj^.conval^.setval; - WHILE i <= MAX(SET) DO + WHILE i <= MAX(SYSTEM.SET64) DO IF i IN s THEN Wi(i); EXCL(s, i); IF s # {} THEN Ws(", ") END END ;