mirror of
https://github.com/vishapoberon/compiler.git
synced 2026-04-05 22:12:24 +00:00
typ.size aware OPV.Convert
This commit is contained in:
parent
731f2215aa
commit
02803ae1fb
16 changed files with 96 additions and 232 deletions
|
|
@ -1201,7 +1201,7 @@ static void OPB_Convert (OPT_Node *x, OPT_Struct typ)
|
|||
OPB_err(203);
|
||||
r = (LONGREAL)1;
|
||||
}
|
||||
(*x)->conval->intval = __ENTIER(r);
|
||||
(*x)->conval->intval = (LONGINT)__ENTIER(r);
|
||||
OPB_SetIntType(*x);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -872,13 +872,13 @@ void OPM_WriteReal (LONGREAL r, CHAR suffx)
|
|||
CHAR s[32];
|
||||
CHAR ch;
|
||||
INTEGER i;
|
||||
if ((((r < OPM_SignedMaximum(OPM_LIntSize) && r > OPM_SignedMinimum(OPM_LIntSize))) && r == (__ENTIER(r)))) {
|
||||
if ((((r < OPM_SignedMaximum(OPM_LIntSize) && r > OPM_SignedMinimum(OPM_LIntSize))) && r == ((LONGINT)__ENTIER(r)))) {
|
||||
if (suffx == 'f') {
|
||||
OPM_WriteString((CHAR*)"(REAL)", (LONGINT)7);
|
||||
} else {
|
||||
OPM_WriteString((CHAR*)"(LONGREAL)", (LONGINT)11);
|
||||
}
|
||||
OPM_WriteInt(__ENTIER(r));
|
||||
OPM_WriteInt((LONGINT)__ENTIER(r));
|
||||
} else {
|
||||
Texts_OpenWriter(&W, Texts_Writer__typ);
|
||||
if (suffx == 'f') {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ export LONGINT *OPV_ExitInfo__typ;
|
|||
static void OPV_ActualPar (OPT_Node n, OPT_Object fp);
|
||||
export void OPV_AdrAndSize (OPT_Object topScope);
|
||||
static void OPV_CaseStat (OPT_Node n, OPT_Object outerProc);
|
||||
static void OPV_Convert (OPT_Node n, OPT_Struct typ, INTEGER prec);
|
||||
static void OPV_Convert (OPT_Node n, OPT_Struct newtype, INTEGER prec);
|
||||
static void OPV_DefineTDescs (OPT_Node n);
|
||||
static void OPV_Entier (OPT_Node n, INTEGER prec);
|
||||
static void OPV_GetTProcNum (OPT_Object obj);
|
||||
|
|
@ -469,50 +469,27 @@ static void OPV_Entier (OPT_Node n, INTEGER prec)
|
|||
static void OPV_SizeCast (LONGINT size)
|
||||
{
|
||||
if (size <= (LONGINT)OPM_SIntSize) {
|
||||
OPM_WriteString((CHAR*)"(SHORTINT)", (LONGINT)11);
|
||||
OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
|
||||
} else if (size <= (LONGINT)OPM_IntSize) {
|
||||
OPM_WriteString((CHAR*)"(INTEGER)", (LONGINT)10);
|
||||
OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
|
||||
} else {
|
||||
OPM_WriteString((CHAR*)"(LONGINT)", (LONGINT)10);
|
||||
}
|
||||
}
|
||||
|
||||
static void OPV_Convert (OPT_Node n, OPT_Struct typ, INTEGER prec)
|
||||
static void OPV_Convert (OPT_Node n, OPT_Struct newtype, INTEGER prec)
|
||||
{
|
||||
INTEGER from, to;
|
||||
from = n->typ->form;
|
||||
to = typ->form;
|
||||
to = newtype->form;
|
||||
if (to == 9) {
|
||||
OPM_WriteString((CHAR*)"__SETOF(", (LONGINT)9);
|
||||
OPV_Entier(n, -1);
|
||||
OPM_Write(')');
|
||||
} else if (to == 6) {
|
||||
if (from < 6) {
|
||||
OPM_WriteString((CHAR*)"(LONGINT)", (LONGINT)10);
|
||||
}
|
||||
OPV_Entier(n, 9);
|
||||
} else if (to == 5) {
|
||||
if (from < 5) {
|
||||
OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
|
||||
OPV_expr(n, 9);
|
||||
} else {
|
||||
if (__IN(2, OPM_opt)) {
|
||||
OPM_WriteString((CHAR*)"__SHORT", (LONGINT)8);
|
||||
if (OPV_SideEffects(n)) {
|
||||
OPM_Write('F');
|
||||
}
|
||||
OPM_Write('(');
|
||||
OPV_Entier(n, -1);
|
||||
OPM_WriteString((CHAR*)", ", (LONGINT)3);
|
||||
OPM_WriteInt(OPM_SignedMaximum(OPM_IntSize) + 1);
|
||||
OPM_Write(')');
|
||||
} else {
|
||||
OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
|
||||
OPV_Entier(n, 9);
|
||||
}
|
||||
}
|
||||
} else if (to == 4) {
|
||||
if (__IN(2, OPM_opt)) {
|
||||
} else if (__IN(to, 0x70)) {
|
||||
__ASSERT(newtype->size > 0, 0);
|
||||
__ASSERT(n->typ->size > 0, 0);
|
||||
if ((newtype->size < n->typ->size && __IN(2, OPM_opt))) {
|
||||
OPM_WriteString((CHAR*)"__SHORT", (LONGINT)8);
|
||||
if (OPV_SideEffects(n)) {
|
||||
OPM_Write('F');
|
||||
|
|
@ -520,10 +497,12 @@ static void OPV_Convert (OPT_Node n, OPT_Struct typ, INTEGER prec)
|
|||
OPM_Write('(');
|
||||
OPV_Entier(n, -1);
|
||||
OPM_WriteString((CHAR*)", ", (LONGINT)3);
|
||||
OPM_WriteInt(OPM_SignedMaximum(OPM_SIntSize) + 1);
|
||||
OPM_WriteInt(OPM_SignedMaximum(newtype->size) + 1);
|
||||
OPM_Write(')');
|
||||
} else {
|
||||
OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
|
||||
if (newtype->size != n->typ->size) {
|
||||
OPV_SizeCast(newtype->size);
|
||||
}
|
||||
OPV_Entier(n, 9);
|
||||
}
|
||||
} else if (to == 3) {
|
||||
|
|
|
|||
|
|
@ -89,8 +89,8 @@ void Reals_ConvertL (LONGREAL x, INTEGER n, CHAR *d, LONGINT d__len)
|
|||
}
|
||||
k = 0;
|
||||
if (n > 9) {
|
||||
i = __ENTIER(x / (LONGREAL)(LONGREAL)1000000000);
|
||||
j = __ENTIER(x - i * (LONGREAL)1000000000);
|
||||
i = (LONGINT)__ENTIER(x / (LONGREAL)(LONGREAL)1000000000);
|
||||
j = (LONGINT)__ENTIER(x - i * (LONGREAL)1000000000);
|
||||
if (j < 0) {
|
||||
j = 0;
|
||||
}
|
||||
|
|
@ -100,7 +100,7 @@ void Reals_ConvertL (LONGREAL x, INTEGER n, CHAR *d, LONGINT d__len)
|
|||
k += 1;
|
||||
}
|
||||
} else {
|
||||
i = __ENTIER(x);
|
||||
i = (LONGINT)__ENTIER(x);
|
||||
}
|
||||
while (k < (LONGINT)n) {
|
||||
d[__X(k, d__len)] = (CHAR)(__MOD(i, 10) + 48);
|
||||
|
|
|
|||
|
|
@ -1201,7 +1201,7 @@ static void OPB_Convert (OPT_Node *x, OPT_Struct typ)
|
|||
OPB_err(203);
|
||||
r = (LONGREAL)1;
|
||||
}
|
||||
(*x)->conval->intval = __ENTIER(r);
|
||||
(*x)->conval->intval = (LONGINT)__ENTIER(r);
|
||||
OPB_SetIntType(*x);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -872,13 +872,13 @@ void OPM_WriteReal (LONGREAL r, CHAR suffx)
|
|||
CHAR s[32];
|
||||
CHAR ch;
|
||||
INTEGER i;
|
||||
if ((((r < OPM_SignedMaximum(OPM_LIntSize) && r > OPM_SignedMinimum(OPM_LIntSize))) && r == (__ENTIER(r)))) {
|
||||
if ((((r < OPM_SignedMaximum(OPM_LIntSize) && r > OPM_SignedMinimum(OPM_LIntSize))) && r == ((LONGINT)__ENTIER(r)))) {
|
||||
if (suffx == 'f') {
|
||||
OPM_WriteString((CHAR*)"(REAL)", (LONGINT)7);
|
||||
} else {
|
||||
OPM_WriteString((CHAR*)"(LONGREAL)", (LONGINT)11);
|
||||
}
|
||||
OPM_WriteInt(__ENTIER(r));
|
||||
OPM_WriteInt((LONGINT)__ENTIER(r));
|
||||
} else {
|
||||
Texts_OpenWriter(&W, Texts_Writer__typ);
|
||||
if (suffx == 'f') {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ export LONGINT *OPV_ExitInfo__typ;
|
|||
static void OPV_ActualPar (OPT_Node n, OPT_Object fp);
|
||||
export void OPV_AdrAndSize (OPT_Object topScope);
|
||||
static void OPV_CaseStat (OPT_Node n, OPT_Object outerProc);
|
||||
static void OPV_Convert (OPT_Node n, OPT_Struct typ, INTEGER prec);
|
||||
static void OPV_Convert (OPT_Node n, OPT_Struct newtype, INTEGER prec);
|
||||
static void OPV_DefineTDescs (OPT_Node n);
|
||||
static void OPV_Entier (OPT_Node n, INTEGER prec);
|
||||
static void OPV_GetTProcNum (OPT_Object obj);
|
||||
|
|
@ -469,50 +469,27 @@ static void OPV_Entier (OPT_Node n, INTEGER prec)
|
|||
static void OPV_SizeCast (LONGINT size)
|
||||
{
|
||||
if (size <= (LONGINT)OPM_SIntSize) {
|
||||
OPM_WriteString((CHAR*)"(SHORTINT)", (LONGINT)11);
|
||||
OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
|
||||
} else if (size <= (LONGINT)OPM_IntSize) {
|
||||
OPM_WriteString((CHAR*)"(INTEGER)", (LONGINT)10);
|
||||
OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
|
||||
} else {
|
||||
OPM_WriteString((CHAR*)"(LONGINT)", (LONGINT)10);
|
||||
}
|
||||
}
|
||||
|
||||
static void OPV_Convert (OPT_Node n, OPT_Struct typ, INTEGER prec)
|
||||
static void OPV_Convert (OPT_Node n, OPT_Struct newtype, INTEGER prec)
|
||||
{
|
||||
INTEGER from, to;
|
||||
from = n->typ->form;
|
||||
to = typ->form;
|
||||
to = newtype->form;
|
||||
if (to == 9) {
|
||||
OPM_WriteString((CHAR*)"__SETOF(", (LONGINT)9);
|
||||
OPV_Entier(n, -1);
|
||||
OPM_Write(')');
|
||||
} else if (to == 6) {
|
||||
if (from < 6) {
|
||||
OPM_WriteString((CHAR*)"(LONGINT)", (LONGINT)10);
|
||||
}
|
||||
OPV_Entier(n, 9);
|
||||
} else if (to == 5) {
|
||||
if (from < 5) {
|
||||
OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
|
||||
OPV_expr(n, 9);
|
||||
} else {
|
||||
if (__IN(2, OPM_opt)) {
|
||||
OPM_WriteString((CHAR*)"__SHORT", (LONGINT)8);
|
||||
if (OPV_SideEffects(n)) {
|
||||
OPM_Write('F');
|
||||
}
|
||||
OPM_Write('(');
|
||||
OPV_Entier(n, -1);
|
||||
OPM_WriteString((CHAR*)", ", (LONGINT)3);
|
||||
OPM_WriteInt(OPM_SignedMaximum(OPM_IntSize) + 1);
|
||||
OPM_Write(')');
|
||||
} else {
|
||||
OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
|
||||
OPV_Entier(n, 9);
|
||||
}
|
||||
}
|
||||
} else if (to == 4) {
|
||||
if (__IN(2, OPM_opt)) {
|
||||
} else if (__IN(to, 0x70)) {
|
||||
__ASSERT(newtype->size > 0, 0);
|
||||
__ASSERT(n->typ->size > 0, 0);
|
||||
if ((newtype->size < n->typ->size && __IN(2, OPM_opt))) {
|
||||
OPM_WriteString((CHAR*)"__SHORT", (LONGINT)8);
|
||||
if (OPV_SideEffects(n)) {
|
||||
OPM_Write('F');
|
||||
|
|
@ -520,10 +497,12 @@ static void OPV_Convert (OPT_Node n, OPT_Struct typ, INTEGER prec)
|
|||
OPM_Write('(');
|
||||
OPV_Entier(n, -1);
|
||||
OPM_WriteString((CHAR*)", ", (LONGINT)3);
|
||||
OPM_WriteInt(OPM_SignedMaximum(OPM_SIntSize) + 1);
|
||||
OPM_WriteInt(OPM_SignedMaximum(newtype->size) + 1);
|
||||
OPM_Write(')');
|
||||
} else {
|
||||
OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
|
||||
if (newtype->size != n->typ->size) {
|
||||
OPV_SizeCast(newtype->size);
|
||||
}
|
||||
OPV_Entier(n, 9);
|
||||
}
|
||||
} else if (to == 3) {
|
||||
|
|
|
|||
|
|
@ -89,8 +89,8 @@ void Reals_ConvertL (LONGREAL x, INTEGER n, CHAR *d, LONGINT d__len)
|
|||
}
|
||||
k = 0;
|
||||
if (n > 9) {
|
||||
i = __ENTIER(x / (LONGREAL)(LONGREAL)1000000000);
|
||||
j = __ENTIER(x - i * (LONGREAL)1000000000);
|
||||
i = (LONGINT)__ENTIER(x / (LONGREAL)(LONGREAL)1000000000);
|
||||
j = (LONGINT)__ENTIER(x - i * (LONGREAL)1000000000);
|
||||
if (j < 0) {
|
||||
j = 0;
|
||||
}
|
||||
|
|
@ -100,7 +100,7 @@ void Reals_ConvertL (LONGREAL x, INTEGER n, CHAR *d, LONGINT d__len)
|
|||
k += 1;
|
||||
}
|
||||
} else {
|
||||
i = __ENTIER(x);
|
||||
i = (LONGINT)__ENTIER(x);
|
||||
}
|
||||
while (k < (LONGINT)n) {
|
||||
d[__X(k, d__len)] = (CHAR)(__MOD(i, 10) + 48);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ export LONGINT *OPV_ExitInfo__typ;
|
|||
static void OPV_ActualPar (OPT_Node n, OPT_Object fp);
|
||||
export void OPV_AdrAndSize (OPT_Object topScope);
|
||||
static void OPV_CaseStat (OPT_Node n, OPT_Object outerProc);
|
||||
static void OPV_Convert (OPT_Node n, OPT_Struct typ, INTEGER prec);
|
||||
static void OPV_Convert (OPT_Node n, OPT_Struct newtype, INTEGER prec);
|
||||
static void OPV_DefineTDescs (OPT_Node n);
|
||||
static void OPV_Entier (OPT_Node n, INTEGER prec);
|
||||
static void OPV_GetTProcNum (OPT_Object obj);
|
||||
|
|
@ -470,50 +470,27 @@ static void OPV_Entier (OPT_Node n, INTEGER prec)
|
|||
static void OPV_SizeCast (LONGINT size)
|
||||
{
|
||||
if (size <= (LONGINT)OPM_SIntSize) {
|
||||
OPM_WriteString((CHAR*)"(SHORTINT)", (LONGINT)11);
|
||||
OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
|
||||
} else if (size <= (LONGINT)OPM_IntSize) {
|
||||
OPM_WriteString((CHAR*)"(INTEGER)", (LONGINT)10);
|
||||
OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
|
||||
} else {
|
||||
OPM_WriteString((CHAR*)"(LONGINT)", (LONGINT)10);
|
||||
}
|
||||
}
|
||||
|
||||
static void OPV_Convert (OPT_Node n, OPT_Struct typ, INTEGER prec)
|
||||
static void OPV_Convert (OPT_Node n, OPT_Struct newtype, INTEGER prec)
|
||||
{
|
||||
INTEGER from, to;
|
||||
from = n->typ->form;
|
||||
to = typ->form;
|
||||
to = newtype->form;
|
||||
if (to == 9) {
|
||||
OPM_WriteString((CHAR*)"__SETOF(", (LONGINT)9);
|
||||
OPV_Entier(n, -1);
|
||||
OPM_Write(')');
|
||||
} else if (to == 6) {
|
||||
if (from < 6) {
|
||||
OPM_WriteString((CHAR*)"(LONGINT)", (LONGINT)10);
|
||||
}
|
||||
OPV_Entier(n, 9);
|
||||
} else if (to == 5) {
|
||||
if (from < 5) {
|
||||
OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
|
||||
OPV_expr(n, 9);
|
||||
} else {
|
||||
if (__IN(2, OPM_opt)) {
|
||||
OPM_WriteString((CHAR*)"__SHORT", (LONGINT)8);
|
||||
if (OPV_SideEffects(n)) {
|
||||
OPM_Write('F');
|
||||
}
|
||||
OPM_Write('(');
|
||||
OPV_Entier(n, -1);
|
||||
OPM_WriteString((CHAR*)", ", (LONGINT)3);
|
||||
OPM_WriteInt(OPM_SignedMaximum(OPM_IntSize) + 1);
|
||||
OPM_Write(')');
|
||||
} else {
|
||||
OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
|
||||
OPV_Entier(n, 9);
|
||||
}
|
||||
}
|
||||
} else if (to == 4) {
|
||||
if (__IN(2, OPM_opt)) {
|
||||
} else if (__IN(to, 0x70)) {
|
||||
__ASSERT(newtype->size > 0, 0);
|
||||
__ASSERT(n->typ->size > 0, 0);
|
||||
if ((newtype->size < n->typ->size && __IN(2, OPM_opt))) {
|
||||
OPM_WriteString((CHAR*)"__SHORT", (LONGINT)8);
|
||||
if (OPV_SideEffects(n)) {
|
||||
OPM_Write('F');
|
||||
|
|
@ -521,10 +498,12 @@ static void OPV_Convert (OPT_Node n, OPT_Struct typ, INTEGER prec)
|
|||
OPM_Write('(');
|
||||
OPV_Entier(n, -1);
|
||||
OPM_WriteString((CHAR*)", ", (LONGINT)3);
|
||||
OPM_WriteInt(OPM_SignedMaximum(OPM_SIntSize) + 1);
|
||||
OPM_WriteInt(OPM_SignedMaximum(newtype->size) + 1);
|
||||
OPM_Write(')');
|
||||
} else {
|
||||
OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
|
||||
if (newtype->size != n->typ->size) {
|
||||
OPV_SizeCast(newtype->size);
|
||||
}
|
||||
OPV_Entier(n, 9);
|
||||
}
|
||||
} else if (to == 3) {
|
||||
|
|
|
|||
|
|
@ -1201,7 +1201,7 @@ static void OPB_Convert (OPT_Node *x, OPT_Struct typ)
|
|||
OPB_err(203);
|
||||
r = (LONGREAL)1;
|
||||
}
|
||||
(*x)->conval->intval = __ENTIER(r);
|
||||
(*x)->conval->intval = (LONGINT)__ENTIER(r);
|
||||
OPB_SetIntType(*x);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -872,13 +872,13 @@ void OPM_WriteReal (LONGREAL r, CHAR suffx)
|
|||
CHAR s[32];
|
||||
CHAR ch;
|
||||
INTEGER i;
|
||||
if ((((r < OPM_SignedMaximum(OPM_LIntSize) && r > OPM_SignedMinimum(OPM_LIntSize))) && r == (__ENTIER(r)))) {
|
||||
if ((((r < OPM_SignedMaximum(OPM_LIntSize) && r > OPM_SignedMinimum(OPM_LIntSize))) && r == ((LONGINT)__ENTIER(r)))) {
|
||||
if (suffx == 'f') {
|
||||
OPM_WriteString((CHAR*)"(REAL)", (LONGINT)7);
|
||||
} else {
|
||||
OPM_WriteString((CHAR*)"(LONGREAL)", (LONGINT)11);
|
||||
}
|
||||
OPM_WriteInt(__ENTIER(r));
|
||||
OPM_WriteInt((LONGINT)__ENTIER(r));
|
||||
} else {
|
||||
Texts_OpenWriter(&W, Texts_Writer__typ);
|
||||
if (suffx == 'f') {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ export LONGINT *OPV_ExitInfo__typ;
|
|||
static void OPV_ActualPar (OPT_Node n, OPT_Object fp);
|
||||
export void OPV_AdrAndSize (OPT_Object topScope);
|
||||
static void OPV_CaseStat (OPT_Node n, OPT_Object outerProc);
|
||||
static void OPV_Convert (OPT_Node n, OPT_Struct typ, INTEGER prec);
|
||||
static void OPV_Convert (OPT_Node n, OPT_Struct newtype, INTEGER prec);
|
||||
static void OPV_DefineTDescs (OPT_Node n);
|
||||
static void OPV_Entier (OPT_Node n, INTEGER prec);
|
||||
static void OPV_GetTProcNum (OPT_Object obj);
|
||||
|
|
@ -469,50 +469,27 @@ static void OPV_Entier (OPT_Node n, INTEGER prec)
|
|||
static void OPV_SizeCast (LONGINT size)
|
||||
{
|
||||
if (size <= (LONGINT)OPM_SIntSize) {
|
||||
OPM_WriteString((CHAR*)"(SHORTINT)", (LONGINT)11);
|
||||
OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
|
||||
} else if (size <= (LONGINT)OPM_IntSize) {
|
||||
OPM_WriteString((CHAR*)"(INTEGER)", (LONGINT)10);
|
||||
OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
|
||||
} else {
|
||||
OPM_WriteString((CHAR*)"(LONGINT)", (LONGINT)10);
|
||||
}
|
||||
}
|
||||
|
||||
static void OPV_Convert (OPT_Node n, OPT_Struct typ, INTEGER prec)
|
||||
static void OPV_Convert (OPT_Node n, OPT_Struct newtype, INTEGER prec)
|
||||
{
|
||||
INTEGER from, to;
|
||||
from = n->typ->form;
|
||||
to = typ->form;
|
||||
to = newtype->form;
|
||||
if (to == 9) {
|
||||
OPM_WriteString((CHAR*)"__SETOF(", (LONGINT)9);
|
||||
OPV_Entier(n, -1);
|
||||
OPM_Write(')');
|
||||
} else if (to == 6) {
|
||||
if (from < 6) {
|
||||
OPM_WriteString((CHAR*)"(LONGINT)", (LONGINT)10);
|
||||
}
|
||||
OPV_Entier(n, 9);
|
||||
} else if (to == 5) {
|
||||
if (from < 5) {
|
||||
OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
|
||||
OPV_expr(n, 9);
|
||||
} else {
|
||||
if (__IN(2, OPM_opt)) {
|
||||
OPM_WriteString((CHAR*)"__SHORT", (LONGINT)8);
|
||||
if (OPV_SideEffects(n)) {
|
||||
OPM_Write('F');
|
||||
}
|
||||
OPM_Write('(');
|
||||
OPV_Entier(n, -1);
|
||||
OPM_WriteString((CHAR*)", ", (LONGINT)3);
|
||||
OPM_WriteInt(OPM_SignedMaximum(OPM_IntSize) + 1);
|
||||
OPM_Write(')');
|
||||
} else {
|
||||
OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
|
||||
OPV_Entier(n, 9);
|
||||
}
|
||||
}
|
||||
} else if (to == 4) {
|
||||
if (__IN(2, OPM_opt)) {
|
||||
} else if (__IN(to, 0x70)) {
|
||||
__ASSERT(newtype->size > 0, 0);
|
||||
__ASSERT(n->typ->size > 0, 0);
|
||||
if ((newtype->size < n->typ->size && __IN(2, OPM_opt))) {
|
||||
OPM_WriteString((CHAR*)"__SHORT", (LONGINT)8);
|
||||
if (OPV_SideEffects(n)) {
|
||||
OPM_Write('F');
|
||||
|
|
@ -520,10 +497,12 @@ static void OPV_Convert (OPT_Node n, OPT_Struct typ, INTEGER prec)
|
|||
OPM_Write('(');
|
||||
OPV_Entier(n, -1);
|
||||
OPM_WriteString((CHAR*)", ", (LONGINT)3);
|
||||
OPM_WriteInt(OPM_SignedMaximum(OPM_SIntSize) + 1);
|
||||
OPM_WriteInt(OPM_SignedMaximum(newtype->size) + 1);
|
||||
OPM_Write(')');
|
||||
} else {
|
||||
OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
|
||||
if (newtype->size != n->typ->size) {
|
||||
OPV_SizeCast(newtype->size);
|
||||
}
|
||||
OPV_Entier(n, 9);
|
||||
}
|
||||
} else if (to == 3) {
|
||||
|
|
|
|||
|
|
@ -89,8 +89,8 @@ void Reals_ConvertL (LONGREAL x, INTEGER n, CHAR *d, LONGINT d__len)
|
|||
}
|
||||
k = 0;
|
||||
if (n > 9) {
|
||||
i = __ENTIER(x / (LONGREAL)(LONGREAL)1000000000);
|
||||
j = __ENTIER(x - i * (LONGREAL)1000000000);
|
||||
i = (LONGINT)__ENTIER(x / (LONGREAL)(LONGREAL)1000000000);
|
||||
j = (LONGINT)__ENTIER(x - i * (LONGREAL)1000000000);
|
||||
if (j < 0) {
|
||||
j = 0;
|
||||
}
|
||||
|
|
@ -100,7 +100,7 @@ void Reals_ConvertL (LONGREAL x, INTEGER n, CHAR *d, LONGINT d__len)
|
|||
k += 1;
|
||||
}
|
||||
} else {
|
||||
i = __ENTIER(x);
|
||||
i = (LONGINT)__ENTIER(x);
|
||||
}
|
||||
while (k < (LONGINT)n) {
|
||||
d[__X(k, d__len)] = (CHAR)(__MOD(i, 10) + 48);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ export LONGINT *OPV_ExitInfo__typ;
|
|||
static void OPV_ActualPar (OPT_Node n, OPT_Object fp);
|
||||
export void OPV_AdrAndSize (OPT_Object topScope);
|
||||
static void OPV_CaseStat (OPT_Node n, OPT_Object outerProc);
|
||||
static void OPV_Convert (OPT_Node n, OPT_Struct typ, INTEGER prec);
|
||||
static void OPV_Convert (OPT_Node n, OPT_Struct newtype, INTEGER prec);
|
||||
static void OPV_DefineTDescs (OPT_Node n);
|
||||
static void OPV_Entier (OPT_Node n, INTEGER prec);
|
||||
static void OPV_GetTProcNum (OPT_Object obj);
|
||||
|
|
@ -470,50 +470,27 @@ static void OPV_Entier (OPT_Node n, INTEGER prec)
|
|||
static void OPV_SizeCast (LONGINT size)
|
||||
{
|
||||
if (size <= (LONGINT)OPM_SIntSize) {
|
||||
OPM_WriteString((CHAR*)"(SHORTINT)", (LONGINT)11);
|
||||
OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
|
||||
} else if (size <= (LONGINT)OPM_IntSize) {
|
||||
OPM_WriteString((CHAR*)"(INTEGER)", (LONGINT)10);
|
||||
OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
|
||||
} else {
|
||||
OPM_WriteString((CHAR*)"(LONGINT)", (LONGINT)10);
|
||||
}
|
||||
}
|
||||
|
||||
static void OPV_Convert (OPT_Node n, OPT_Struct typ, INTEGER prec)
|
||||
static void OPV_Convert (OPT_Node n, OPT_Struct newtype, INTEGER prec)
|
||||
{
|
||||
INTEGER from, to;
|
||||
from = n->typ->form;
|
||||
to = typ->form;
|
||||
to = newtype->form;
|
||||
if (to == 9) {
|
||||
OPM_WriteString((CHAR*)"__SETOF(", (LONGINT)9);
|
||||
OPV_Entier(n, -1);
|
||||
OPM_Write(')');
|
||||
} else if (to == 6) {
|
||||
if (from < 6) {
|
||||
OPM_WriteString((CHAR*)"(LONGINT)", (LONGINT)10);
|
||||
}
|
||||
OPV_Entier(n, 9);
|
||||
} else if (to == 5) {
|
||||
if (from < 5) {
|
||||
OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
|
||||
OPV_expr(n, 9);
|
||||
} else {
|
||||
if (__IN(2, OPM_opt)) {
|
||||
OPM_WriteString((CHAR*)"__SHORT", (LONGINT)8);
|
||||
if (OPV_SideEffects(n)) {
|
||||
OPM_Write('F');
|
||||
}
|
||||
OPM_Write('(');
|
||||
OPV_Entier(n, -1);
|
||||
OPM_WriteString((CHAR*)", ", (LONGINT)3);
|
||||
OPM_WriteInt(OPM_SignedMaximum(OPM_IntSize) + 1);
|
||||
OPM_Write(')');
|
||||
} else {
|
||||
OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
|
||||
OPV_Entier(n, 9);
|
||||
}
|
||||
}
|
||||
} else if (to == 4) {
|
||||
if (__IN(2, OPM_opt)) {
|
||||
} else if (__IN(to, 0x70)) {
|
||||
__ASSERT(newtype->size > 0, 0);
|
||||
__ASSERT(n->typ->size > 0, 0);
|
||||
if ((newtype->size < n->typ->size && __IN(2, OPM_opt))) {
|
||||
OPM_WriteString((CHAR*)"__SHORT", (LONGINT)8);
|
||||
if (OPV_SideEffects(n)) {
|
||||
OPM_Write('F');
|
||||
|
|
@ -521,10 +498,12 @@ static void OPV_Convert (OPT_Node n, OPT_Struct typ, INTEGER prec)
|
|||
OPM_Write('(');
|
||||
OPV_Entier(n, -1);
|
||||
OPM_WriteString((CHAR*)", ", (LONGINT)3);
|
||||
OPM_WriteInt(OPM_SignedMaximum(OPM_SIntSize) + 1);
|
||||
OPM_WriteInt(OPM_SignedMaximum(newtype->size) + 1);
|
||||
OPM_Write(')');
|
||||
} else {
|
||||
OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
|
||||
if (newtype->size != n->typ->size) {
|
||||
OPV_SizeCast(newtype->size);
|
||||
}
|
||||
OPV_Entier(n, 9);
|
||||
}
|
||||
} else if (to == 3) {
|
||||
|
|
|
|||
4
makefile
4
makefile
|
|
@ -166,6 +166,10 @@ compiler: configuration
|
|||
|
||||
|
||||
|
||||
# Report changes to compiler source relative to bootstrap compiler
|
||||
sourcechanges:
|
||||
@make -f src/tools/make/vishap.make -s sourcechanges
|
||||
|
||||
|
||||
# browsercmd: build the 'showdef' command
|
||||
browsercmd: configuration
|
||||
|
|
|
|||
|
|
@ -292,60 +292,25 @@ MODULE OPV; (* J. Templ 16.2.95 / 3.7.96
|
|||
|
||||
PROCEDURE SizeCast(size: LONGINT);
|
||||
BEGIN
|
||||
IF size <= OPM.SIntSize THEN OPM.WriteString("(SHORTINT)")
|
||||
ELSIF size <= OPM.IntSize THEN OPM.WriteString("(INTEGER)")
|
||||
IF size <= OPM.SIntSize THEN OPM.WriteString("(int)") (* TODO: int for temporary source comparison only. *)
|
||||
ELSIF size <= OPM.IntSize THEN OPM.WriteString("(int)") (* TODO: int for temporary source comparison only. *)
|
||||
ELSE OPM.WriteString("(LONGINT)")
|
||||
END
|
||||
END SizeCast;
|
||||
|
||||
PROCEDURE Convert(n: OPT.Node; typ: OPT.Struct; prec: INTEGER);
|
||||
PROCEDURE Convert(n: OPT.Node; newtype: OPT.Struct; prec: INTEGER);
|
||||
VAR from, to: INTEGER;
|
||||
BEGIN from := n^.typ^.form; to := typ.form;
|
||||
BEGIN from := n^.typ^.form; to := newtype.form;
|
||||
IF to = OPM.Set THEN OPM.WriteString(SetOfFunc); Entier(n, MinPrec); OPM.Write(CloseParen)
|
||||
|
||||
ELSIF to = OPM.LInt THEN
|
||||
IF from < OPM.LInt THEN OPM.WriteString("(LONGINT)") END ;
|
||||
Entier(n, 9)
|
||||
ELSIF to = OPM.Int THEN
|
||||
IF from < OPM.Int THEN OPM.WriteString("(int)"); expr(n, 9)
|
||||
ELSE
|
||||
IF OPM.ranchk IN OPM.opt THEN OPM.WriteString("__SHORT");
|
||||
IF SideEffects(n) THEN OPM.Write("F") END ;
|
||||
OPM.Write(OpenParen); Entier(n, MinPrec);
|
||||
OPM.WriteString(Comma); OPM.WriteInt(OPM.SignedMaximum(OPM.IntSize) + 1); OPM.Write(CloseParen)
|
||||
ELSE OPM.WriteString("(int)"); Entier(n, 9)
|
||||
END
|
||||
END
|
||||
ELSIF to = OPM.SInt THEN
|
||||
IF OPM.ranchk IN OPM.opt THEN OPM.WriteString("__SHORT");
|
||||
IF SideEffects(n) THEN OPM.Write("F") END ;
|
||||
OPM.Write(OpenParen); Entier(n, MinPrec);
|
||||
OPM.WriteString(Comma); OPM.WriteInt(OPM.SignedMaximum(OPM.SIntSize) + 1); OPM.Write(CloseParen)
|
||||
ELSE OPM.WriteString("(int)"); Entier(n, 9)
|
||||
END
|
||||
|
||||
(*
|
||||
ELSIF to IN OPM.intSet THEN
|
||||
IF from IN OPM.intSet
|
||||
IF typ.size > n.typ.size (* Result is larger *)
|
||||
SizeCast(typ.size); Entier(n, 9)
|
||||
ELSIF typ.size = n.typ.size THEN
|
||||
Entier(n, 9)
|
||||
ELSE (* Result is smaller *)
|
||||
IF OPM.ranchk IN OPM.opt THEN
|
||||
OPM.WriteString("__SHORT"); IF SideEffects(n) THEN OPM.Write("F") END;
|
||||
OPM.Write(OpenParen); Entier(n, MinPrec); OPM.WriteString(Comma);
|
||||
OPM.WriteInt(OPM.SignedMaximum(typ.size) + 1); OPM.Write(CloseParen)
|
||||
ELSE
|
||||
SizeCast(typ.size); Entier(n, 9)
|
||||
END
|
||||
END
|
||||
IF (newtype.size < n.typ.size) & (OPM.ranchk IN OPM.opt) THEN
|
||||
OPM.WriteString("__SHORT"); IF SideEffects(n) THEN OPM.Write("F") END;
|
||||
OPM.Write(OpenParen); Entier(n, MinPrec); OPM.WriteString(Comma);
|
||||
OPM.WriteInt(OPM.SignedMaximum(newtype.size) + 1); OPM.Write(CloseParen)
|
||||
ELSE
|
||||
IF (from < OPM.SInt) & (typ.size > OPM.SIntSize) THEN SizeCast(typ.size) END;
|
||||
IF newtype.size # n.typ.size THEN SizeCast(newtype.size) END;
|
||||
Entier(n, 9)
|
||||
END
|
||||
*)
|
||||
|
||||
ELSIF to = OPM.Char THEN
|
||||
IF OPM.ranchk IN OPM.opt THEN OPM.WriteString("__CHR");
|
||||
IF SideEffects(n) THEN OPM.Write("F") END ;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue