Replace alignment constants with calcualted alignment.

This commit is contained in:
David Brown 2016-08-20 23:41:49 +01:00
parent 899ab6ff3f
commit c1228e4ae0
34 changed files with 618 additions and 1084 deletions

View file

@ -55,8 +55,6 @@ static void OPB_SetIntType (OPT_Node node);
export void OPB_SetRange (OPT_Node *x, OPT_Node y); export void OPB_SetRange (OPT_Node *x, OPT_Node y);
static LONGINT OPB_ShorterSize (LONGINT i); static LONGINT OPB_ShorterSize (LONGINT i);
static INTEGER OPB_SignedByteSize (LONGINT n); static INTEGER OPB_SignedByteSize (LONGINT n);
static LONGINT OPB_SignedMaximum (LONGINT bytecount);
static LONGINT OPB_SignedMinimum (LONGINT bytecount);
export void OPB_StFct (OPT_Node *par0, SHORTINT fctno, INTEGER parno); export void OPB_StFct (OPT_Node *par0, SHORTINT fctno, INTEGER parno);
export void OPB_StPar0 (OPT_Node *par0, INTEGER fctno); export void OPB_StPar0 (OPT_Node *par0, INTEGER fctno);
export void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno); export void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno);
@ -226,23 +224,6 @@ OPT_Node OPB_EmptySet (void)
return _o_result; return _o_result;
} }
static LONGINT OPB_SignedMaximum (LONGINT bytecount)
{
LONGINT _o_result;
LONGINT result;
result = 1;
result = __LSH(result, __ASHL(bytecount, 3) - 1, LONGINT);
_o_result = result - 1;
return _o_result;
}
static LONGINT OPB_SignedMinimum (LONGINT bytecount)
{
LONGINT _o_result;
_o_result = -OPB_SignedMaximum(bytecount) - 1;
return _o_result;
}
static INTEGER OPB_SignedByteSize (LONGINT n) static INTEGER OPB_SignedByteSize (LONGINT n)
{ {
INTEGER _o_result; INTEGER _o_result;
@ -448,16 +429,16 @@ void OPB_Field (OPT_Node *x, OPT_Object y)
} }
} }
static struct TypTest__63 { static struct TypTest__61 {
OPT_Node *x; OPT_Node *x;
OPT_Object *obj; OPT_Object *obj;
BOOLEAN *guard; BOOLEAN *guard;
struct TypTest__63 *lnk; struct TypTest__61 *lnk;
} *TypTest__63_s; } *TypTest__61_s;
static void GTT__64 (OPT_Struct t0, OPT_Struct t1); static void GTT__62 (OPT_Struct t0, OPT_Struct t1);
static void GTT__64 (OPT_Struct t0, OPT_Struct t1) static void GTT__62 (OPT_Struct t0, OPT_Struct t1)
{ {
OPT_Node node = NIL; OPT_Node node = NIL;
OPT_Struct t = NIL; OPT_Struct t = NIL;
@ -470,54 +451,54 @@ static void GTT__64 (OPT_Struct t0, OPT_Struct t1)
t1 = t1->BaseTyp; t1 = t1->BaseTyp;
} }
if (t1 == t0 || t0->form == 0) { if (t1 == t0 || t0->form == 0) {
if (*TypTest__63_s->guard) { if (*TypTest__61_s->guard) {
OPB_BindNodes(5, NIL, &*TypTest__63_s->x, NIL); OPB_BindNodes(5, NIL, &*TypTest__61_s->x, NIL);
(*TypTest__63_s->x)->readonly = (*TypTest__63_s->x)->left->readonly; (*TypTest__61_s->x)->readonly = (*TypTest__61_s->x)->left->readonly;
} else { } else {
node = OPT_NewNode(11); node = OPT_NewNode(11);
node->subcl = 16; node->subcl = 16;
node->left = *TypTest__63_s->x; node->left = *TypTest__61_s->x;
node->obj = *TypTest__63_s->obj; node->obj = *TypTest__61_s->obj;
*TypTest__63_s->x = node; *TypTest__61_s->x = node;
} }
} else { } else {
OPB_err(85); OPB_err(85);
} }
} else if (t0 != t1) { } else if (t0 != t1) {
OPB_err(85); OPB_err(85);
} else if (!*TypTest__63_s->guard) { } else if (!*TypTest__61_s->guard) {
if ((*TypTest__63_s->x)->class == 5) { if ((*TypTest__61_s->x)->class == 5) {
node = OPT_NewNode(11); node = OPT_NewNode(11);
node->subcl = 16; node->subcl = 16;
node->left = *TypTest__63_s->x; node->left = *TypTest__61_s->x;
node->obj = *TypTest__63_s->obj; node->obj = *TypTest__61_s->obj;
*TypTest__63_s->x = node; *TypTest__61_s->x = node;
} else { } else {
*TypTest__63_s->x = OPB_NewBoolConst(1); *TypTest__61_s->x = OPB_NewBoolConst(1);
} }
} }
} }
void OPB_TypTest (OPT_Node *x, OPT_Object obj, BOOLEAN guard) void OPB_TypTest (OPT_Node *x, OPT_Object obj, BOOLEAN guard)
{ {
struct TypTest__63 _s; struct TypTest__61 _s;
_s.x = x; _s.x = x;
_s.obj = &obj; _s.obj = &obj;
_s.guard = &guard; _s.guard = &guard;
_s.lnk = TypTest__63_s; _s.lnk = TypTest__61_s;
TypTest__63_s = &_s; TypTest__61_s = &_s;
if (OPB_NotVar(*x)) { if (OPB_NotVar(*x)) {
OPB_err(112); OPB_err(112);
} else if ((*x)->typ->form == 13) { } else if ((*x)->typ->form == 13) {
if (((*x)->typ->BaseTyp->comp != 4 && (*x)->typ != OPT_sysptrtyp)) { if (((*x)->typ->BaseTyp->comp != 4 && (*x)->typ != OPT_sysptrtyp)) {
OPB_err(85); OPB_err(85);
} else if (obj->typ->form == 13) { } else if (obj->typ->form == 13) {
GTT__64((*x)->typ->BaseTyp, obj->typ->BaseTyp); GTT__62((*x)->typ->BaseTyp, obj->typ->BaseTyp);
} else { } else {
OPB_err(86); OPB_err(86);
} }
} else if (((((*x)->typ->comp == 4 && (*x)->class == 1)) && obj->typ->comp == 4)) { } else if (((((*x)->typ->comp == 4 && (*x)->class == 1)) && obj->typ->comp == 4)) {
GTT__64((*x)->typ, obj->typ); GTT__62((*x)->typ, obj->typ);
} else { } else {
OPB_err(87); OPB_err(87);
} }
@ -526,7 +507,7 @@ void OPB_TypTest (OPT_Node *x, OPT_Object obj, BOOLEAN guard)
} else { } else {
(*x)->typ = OPT_booltyp; (*x)->typ = OPT_booltyp;
} }
TypTest__63_s = _s.lnk; TypTest__61_s = _s.lnk;
} }
void OPB_In (OPT_Node *x, OPT_Node y) void OPB_In (OPT_Node *x, OPT_Node y)
@ -1849,7 +1830,7 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno)
x->typ = OPT_chartyp; x->typ = OPT_chartyp;
break; break;
case 4: case 5: case 6: case 4: case 5: case 6:
x = OPB_NewIntConst(OPB_SignedMinimum(x->typ->size)); x = OPB_NewIntConst(OPM_SignedMinimum(x->typ->size));
break; break;
case 9: case 9:
x = OPB_NewIntConst(((LONGINT)(0))); x = OPB_NewIntConst(((LONGINT)(0)));
@ -1880,7 +1861,7 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno)
x->typ = OPT_chartyp; x->typ = OPT_chartyp;
break; break;
case 4: case 5: case 6: case 4: case 5: case 6:
x = OPB_NewIntConst(OPB_SignedMaximum(x->typ->size)); x = OPB_NewIntConst(OPM_SignedMaximum(x->typ->size));
break; break;
case 9: case 9:
x = OPB_NewIntConst(OPM_MaxSet); x = OPB_NewIntConst(OPM_MaxSet);
@ -2062,13 +2043,13 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno)
*par0 = x; *par0 = x;
} }
static struct StPar1__58 { static struct StPar1__56 {
struct StPar1__58 *lnk; struct StPar1__56 *lnk;
} *StPar1__58_s; } *StPar1__56_s;
static OPT_Node NewOp__59 (SHORTINT class, SHORTINT subcl, OPT_Node left, OPT_Node right); static OPT_Node NewOp__57 (SHORTINT class, SHORTINT subcl, OPT_Node left, OPT_Node right);
static OPT_Node NewOp__59 (SHORTINT class, SHORTINT subcl, OPT_Node left, OPT_Node right) static OPT_Node NewOp__57 (SHORTINT class, SHORTINT subcl, OPT_Node left, OPT_Node right)
{ {
OPT_Node _o_result; OPT_Node _o_result;
OPT_Node node = NIL; OPT_Node node = NIL;
@ -2085,9 +2066,9 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
INTEGER f, L; INTEGER f, L;
OPT_Struct typ = NIL; OPT_Struct typ = NIL;
OPT_Node p = NIL, t = NIL; OPT_Node p = NIL, t = NIL;
struct StPar1__58 _s; struct StPar1__56 _s;
_s.lnk = StPar1__58_s; _s.lnk = StPar1__56_s;
StPar1__58_s = &_s; StPar1__56_s = &_s;
p = *par0; p = *par0;
f = x->typ->form; f = x->typ->form;
switch (fctno) { switch (fctno) {
@ -2103,7 +2084,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
OPB_err(111); OPB_err(111);
} }
} }
p = NewOp__59(19, fctno, p, x); p = NewOp__57(19, fctno, p, x);
p->typ = OPT_notyp; p->typ = OPT_notyp;
} }
break; break;
@ -2114,7 +2095,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
if ((x->class == 7 && (0 > x->conval->intval || x->conval->intval > (LONGINT)OPM_MaxSet))) { if ((x->class == 7 && (0 > x->conval->intval || x->conval->intval > (LONGINT)OPM_MaxSet))) {
OPB_err(202); OPB_err(202);
} }
p = NewOp__59(19, fctno, p, x); p = NewOp__57(19, fctno, p, x);
} else { } else {
OPB_err(111); OPB_err(111);
} }
@ -2139,7 +2120,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
p = p->left; p = p->left;
x->conval->intval += 1; x->conval->intval += 1;
} }
p = NewOp__59(12, 19, p, x); p = NewOp__57(12, 19, p, x);
p->typ = OPT_linttyp; p->typ = OPT_linttyp;
} else { } else {
p = x; p = x;
@ -2161,7 +2142,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
t = x; t = x;
x = p; x = p;
p = t; p = t;
p = NewOp__59(19, 18, p, x); p = NewOp__57(19, 18, p, x);
} else { } else {
OPB_err(111); OPB_err(111);
} }
@ -2187,7 +2168,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
} }
p->obj = NIL; p->obj = NIL;
} else { } else {
p = NewOp__59(12, 17, p, x); p = NewOp__57(12, 17, p, x);
p->typ = OPT_linttyp; p->typ = OPT_linttyp;
} }
} else { } else {
@ -2218,9 +2199,9 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
OPB_err(111); OPB_err(111);
} else { } else {
if (fctno == 22) { if (fctno == 22) {
p = NewOp__59(12, 27, p, x); p = NewOp__57(12, 27, p, x);
} else { } else {
p = NewOp__59(12, 28, p, x); p = NewOp__57(12, 28, p, x);
} }
p->typ = p->left->typ; p->typ = p->left->typ;
} }
@ -2237,7 +2218,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
x = p; x = p;
p = t; p = t;
} }
p = NewOp__59(19, fctno, p, x); p = NewOp__57(19, fctno, p, x);
} else { } else {
OPB_err(111); OPB_err(111);
} }
@ -2247,7 +2228,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
if (x->class == 8 || x->class == 9) { if (x->class == 8 || x->class == 9) {
OPB_err(126); OPB_err(126);
} else if (__IN(f, 0x70)) { } else if (__IN(f, 0x70)) {
p = NewOp__59(12, 26, p, x); p = NewOp__57(12, 26, p, x);
} else { } else {
OPB_err(111); OPB_err(111);
} }
@ -2271,7 +2252,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
if (x->class == 8 || x->class == 9) { if (x->class == 8 || x->class == 9) {
OPB_err(126); OPB_err(126);
} else if (__IN(f, 0x70)) { } else if (__IN(f, 0x70)) {
p = NewOp__59(19, 30, p, x); p = NewOp__57(19, 30, p, x);
} else { } else {
OPB_err(111); OPB_err(111);
} }
@ -2317,7 +2298,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
break; break;
} }
*par0 = p; *par0 = p;
StPar1__58_s = _s.lnk; StPar1__56_s = _s.lnk;
} }
void OPB_StParN (OPT_Node *par0, OPT_Node x, INTEGER fctno, INTEGER n) void OPB_StParN (OPT_Node *par0, OPT_Node x, INTEGER fctno, INTEGER n)

View file

@ -16,7 +16,7 @@ static CHAR OPC_BodyNameExt[13];
export void OPC_Align (LONGINT *adr, LONGINT base); export void OPC_Align (LONGINT *adr, LONGINT base);
export void OPC_Andent (OPT_Struct typ); export void OPC_Andent (OPT_Struct typ);
static void OPC_AnsiParamList (OPT_Object obj, BOOLEAN showParamNames); static void OPC_AnsiParamList (OPT_Object obj, BOOLEAN showParamNames);
export LONGINT OPC_Base (OPT_Struct typ); export LONGINT OPC_BaseAlignment (OPT_Struct typ);
export OPT_Object OPC_BaseTProc (OPT_Object obj); export OPT_Object OPC_BaseTProc (OPT_Object obj);
export void OPC_BegBlk (void); export void OPC_BegBlk (void);
export void OPC_BegStat (void); export void OPC_BegStat (void);
@ -74,6 +74,7 @@ static void OPC_PutBase (OPT_Struct typ);
static void OPC_PutPtrOffsets (OPT_Struct typ, LONGINT adr, LONGINT *cnt); static void OPC_PutPtrOffsets (OPT_Struct typ, LONGINT adr, LONGINT *cnt);
static void OPC_RegCmds (OPT_Object obj); static void OPC_RegCmds (OPT_Object obj);
export void OPC_SetInclude (BOOLEAN exclude); export void OPC_SetInclude (BOOLEAN exclude);
export LONGINT OPC_SizeAlignment (LONGINT size);
static void OPC_Stars (OPT_Struct typ, BOOLEAN *openClause); static void OPC_Stars (OPT_Struct typ, BOOLEAN *openClause);
static void OPC_Str1 (CHAR *s, LONGINT s__len, LONGINT x); static void OPC_Str1 (CHAR *s, LONGINT s__len, LONGINT x);
static void OPC_StringLiteral (CHAR *s, LONGINT s__len, LONGINT l); static void OPC_StringLiteral (CHAR *s, LONGINT s__len, LONGINT l);
@ -867,70 +868,37 @@ void OPC_Align (LONGINT *adr, LONGINT base)
} }
} }
LONGINT OPC_Base (OPT_Struct typ) LONGINT OPC_SizeAlignment (LONGINT size)
{ {
LONGINT _o_result; LONGINT _o_result;
switch (typ->form) { LONGINT alignment;
case 1: if (size < (LONGINT)OPM_Alignment) {
_o_result = 1; alignment = 1;
return _o_result; while (alignment < size) {
break; alignment = __ASHL(alignment, 1);
case 3: }
_o_result = OPM_CharAlign; } else {
return _o_result; alignment = OPM_Alignment;
break;
case 2:
_o_result = OPM_BoolAlign;
return _o_result;
break;
case 4:
_o_result = OPM_SIntAlign;
return _o_result;
break;
case 5:
_o_result = OPM_IntAlign;
return _o_result;
break;
case 6:
_o_result = OPM_LIntAlign;
return _o_result;
break;
case 7:
_o_result = OPM_RealAlign;
return _o_result;
break;
case 8:
_o_result = OPM_LRealAlign;
return _o_result;
break;
case 9:
_o_result = OPM_SetAlign;
return _o_result;
break;
case 13:
_o_result = OPM_PointerAlign;
return _o_result;
break;
case 14:
_o_result = OPM_ProcAlign;
return _o_result;
break;
case 15:
if (typ->comp == 4) {
_o_result = __MASK(typ->align, -65536);
return _o_result;
} else {
_o_result = OPC_Base(typ->BaseTyp);
return _o_result;
}
break;
default:
OPM_LogWStr((CHAR*)"unhandled case in OPC.Base, typ^form = ", (LONGINT)40);
OPM_LogWNum(typ->form, ((LONGINT)(0)));
OPM_LogWLn();
break;
} }
__RETCHK; _o_result = alignment;
return _o_result;
}
LONGINT OPC_BaseAlignment (OPT_Struct typ)
{
LONGINT _o_result;
LONGINT alignment;
if (typ->form == 15) {
if (typ->comp == 4) {
alignment = __MASK(typ->align, -65536);
} else {
alignment = OPC_BaseAlignment(typ->BaseTyp);
}
} else {
alignment = OPC_SizeAlignment(typ->size);
}
_o_result = alignment;
return _o_result;
} }
static void OPC_FillGap (LONGINT gap, LONGINT off, LONGINT align, LONGINT *n, LONGINT *curAlign) static void OPC_FillGap (LONGINT gap, LONGINT off, LONGINT align, LONGINT *n, LONGINT *curAlign)
@ -984,7 +952,7 @@ static void OPC_FieldList (OPT_Struct typ, BOOLEAN last, LONGINT *off, LONGINT *
} }
} else { } else {
adr = *off; adr = *off;
fldAlign = OPC_Base(fld->typ); fldAlign = OPC_BaseAlignment(fld->typ);
OPC_Align(&adr, fldAlign); OPC_Align(&adr, fldAlign);
gap = fld->adr - adr; gap = fld->adr - adr;
if (fldAlign > *curAlign) { if (fldAlign > *curAlign) {

View file

@ -11,7 +11,7 @@
import void OPC_Align (LONGINT *adr, LONGINT base); import void OPC_Align (LONGINT *adr, LONGINT base);
import void OPC_Andent (OPT_Struct typ); import void OPC_Andent (OPT_Struct typ);
import LONGINT OPC_Base (OPT_Struct typ); import LONGINT OPC_BaseAlignment (OPT_Struct typ);
import OPT_Object OPC_BaseTProc (OPT_Object obj); import OPT_Object OPC_BaseTProc (OPT_Object obj);
import void OPC_BegBlk (void); import void OPC_BegBlk (void);
import void OPC_BegStat (void); import void OPC_BegStat (void);
@ -40,6 +40,7 @@ import void OPC_InitTDesc (OPT_Struct typ);
import void OPC_Len (OPT_Object obj, OPT_Struct array, LONGINT dim); import void OPC_Len (OPT_Object obj, OPT_Struct array, LONGINT dim);
import LONGINT OPC_NofPtrs (OPT_Struct typ); import LONGINT OPC_NofPtrs (OPT_Struct typ);
import void OPC_SetInclude (BOOLEAN exclude); import void OPC_SetInclude (BOOLEAN exclude);
import LONGINT OPC_SizeAlignment (LONGINT size);
import void OPC_TDescDecl (OPT_Struct typ); import void OPC_TDescDecl (OPT_Struct typ);
import void OPC_TypeDefs (OPT_Object obj, INTEGER vis); import void OPC_TypeDefs (OPT_Object obj, INTEGER vis);
import void OPC_TypeOf (OPT_Object ap); import void OPC_TypeOf (OPT_Object ap);

View file

@ -14,8 +14,8 @@ typedef
static CHAR OPM_SourceFileName[256]; static CHAR OPM_SourceFileName[256];
export INTEGER OPM_Alignment, OPM_ByteSize, OPM_CharSize, OPM_BoolSize, OPM_SIntSize, OPM_IntSize, OPM_LIntSize, OPM_SetSize, OPM_RealSize, OPM_LRealSize, OPM_PointerSize, OPM_ProcSize, OPM_RecSize, OPM_CharAlign, OPM_BoolAlign, OPM_SIntAlign, OPM_IntAlign, OPM_LIntAlign, OPM_SetAlign, OPM_RealAlign, OPM_LRealAlign, OPM_PointerAlign, OPM_ProcAlign, OPM_RecAlign, OPM_MaxSet; export INTEGER OPM_Alignment, OPM_ByteSize, OPM_CharSize, OPM_BoolSize, OPM_SIntSize, OPM_IntSize, OPM_LIntSize, OPM_SetSize, OPM_RealSize, OPM_LRealSize, OPM_PointerSize, OPM_ProcSize, OPM_RecSize, OPM_MaxSet;
export LONGINT OPM_MinSInt, OPM_MinInt, OPM_MinLInt, OPM_MaxSInt, OPM_MaxInt, OPM_MaxLInt, OPM_MaxIndex; export LONGINT OPM_MaxIndex;
export LONGREAL OPM_MinReal, OPM_MaxReal, OPM_MinLReal, OPM_MaxLReal; export LONGREAL OPM_MinReal, OPM_MaxReal, OPM_MinLReal, OPM_MaxLReal;
export BOOLEAN OPM_noerr; export BOOLEAN OPM_noerr;
export LONGINT OPM_curpos, OPM_errpos, OPM_breakpc; export LONGINT OPM_curpos, OPM_errpos, OPM_breakpc;
@ -36,7 +36,6 @@ static CHAR OPM_OBERON[1024];
static CHAR OPM_MODULES[1024]; static CHAR OPM_MODULES[1024];
export INTEGER OPM_AlignSize (LONGINT size);
static void OPM_Append (Files_Rider *R, LONGINT *R__typ, Files_File F); static void OPM_Append (Files_Rider *R, LONGINT *R__typ, Files_File F);
export void OPM_CloseFiles (void); export void OPM_CloseFiles (void);
export void OPM_CloseOldSym (void); export void OPM_CloseOldSym (void);
@ -65,6 +64,8 @@ export BOOLEAN OPM_OpenPar (void);
export void OPM_RegisterNewSym (void); export void OPM_RegisterNewSym (void);
static void OPM_ScanOptions (CHAR *s, LONGINT s__len, SET *opt); static void OPM_ScanOptions (CHAR *s, LONGINT s__len, SET *opt);
static void OPM_ShowLine (LONGINT pos); static void OPM_ShowLine (LONGINT pos);
export LONGINT OPM_SignedMaximum (LONGINT bytecount);
export LONGINT OPM_SignedMinimum (LONGINT bytecount);
export void OPM_SymRCh (CHAR *ch); export void OPM_SymRCh (CHAR *ch);
export LONGINT OPM_SymRInt (void); export LONGINT OPM_SymRInt (void);
export void OPM_SymRLReal (LONGREAL *lr); export void OPM_SymRLReal (LONGREAL *lr);
@ -607,111 +608,62 @@ static void OPM_VerboseListSizes (void)
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"CHAR ", (LONGINT)14); OPM_LogWStr((CHAR*)"CHAR ", (LONGINT)14);
OPM_LogWNum(OPM_CharSize, ((LONGINT)(4))); OPM_LogWNum(OPM_CharSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_CharAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"BOOLEAN ", (LONGINT)14); OPM_LogWStr((CHAR*)"BOOLEAN ", (LONGINT)14);
OPM_LogWNum(OPM_BoolSize, ((LONGINT)(4))); OPM_LogWNum(OPM_BoolSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_BoolAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"SHORTINT ", (LONGINT)14); OPM_LogWStr((CHAR*)"SHORTINT ", (LONGINT)14);
OPM_LogWNum(OPM_SIntSize, ((LONGINT)(4))); OPM_LogWNum(OPM_SIntSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_SIntAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"INTEGER ", (LONGINT)14); OPM_LogWStr((CHAR*)"INTEGER ", (LONGINT)14);
OPM_LogWNum(OPM_IntSize, ((LONGINT)(4))); OPM_LogWNum(OPM_IntSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_IntAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"LONGINT ", (LONGINT)14); OPM_LogWStr((CHAR*)"LONGINT ", (LONGINT)14);
OPM_LogWNum(OPM_LIntSize, ((LONGINT)(4))); OPM_LogWNum(OPM_LIntSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_LIntAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"SET ", (LONGINT)14); OPM_LogWStr((CHAR*)"SET ", (LONGINT)14);
OPM_LogWNum(OPM_SetSize, ((LONGINT)(4))); OPM_LogWNum(OPM_SetSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_SetAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"REAL ", (LONGINT)14); OPM_LogWStr((CHAR*)"REAL ", (LONGINT)14);
OPM_LogWNum(OPM_RealSize, ((LONGINT)(4))); OPM_LogWNum(OPM_RealSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_RealAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"LONGREAL ", (LONGINT)14); OPM_LogWStr((CHAR*)"LONGREAL ", (LONGINT)14);
OPM_LogWNum(OPM_LRealSize, ((LONGINT)(4))); OPM_LogWNum(OPM_LRealSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_LRealAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"PTR ", (LONGINT)14); OPM_LogWStr((CHAR*)"PTR ", (LONGINT)14);
OPM_LogWNum(OPM_PointerSize, ((LONGINT)(4))); OPM_LogWNum(OPM_PointerSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_PointerAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"PROC ", (LONGINT)14); OPM_LogWStr((CHAR*)"PROC ", (LONGINT)14);
OPM_LogWNum(OPM_ProcSize, ((LONGINT)(4))); OPM_LogWNum(OPM_ProcSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_ProcAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"RECORD ", (LONGINT)14); OPM_LogWStr((CHAR*)"RECORD ", (LONGINT)14);
OPM_LogWNum(OPM_RecSize, ((LONGINT)(4))); OPM_LogWNum(OPM_RecSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_RecAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"Min shortint ", (LONGINT)14);
OPM_LogWNum(OPM_MinSInt, ((LONGINT)(4)));
OPM_LogWLn();
OPM_LogWStr((CHAR*)"Max shortint ", (LONGINT)14);
OPM_LogWNum(OPM_MaxSInt, ((LONGINT)(4)));
OPM_LogWLn();
OPM_LogWStr((CHAR*)"Min integer ", (LONGINT)14);
OPM_LogWNum(OPM_MinInt, ((LONGINT)(4)));
OPM_LogWLn();
OPM_LogWStr((CHAR*)"Max integer ", (LONGINT)14);
OPM_LogWNum(OPM_MaxInt, ((LONGINT)(4)));
OPM_LogWLn();
OPM_LogWStr((CHAR*)"Min longint ", (LONGINT)14);
OPM_LogWNum(OPM_MinLInt, ((LONGINT)(4)));
OPM_LogWLn();
} }
INTEGER OPM_AlignSize (LONGINT size) LONGINT OPM_SignedMaximum (LONGINT bytecount)
{ {
INTEGER _o_result; LONGINT _o_result;
INTEGER align; LONGINT result;
if (size < (LONGINT)OPM_Alignment) { result = 1;
if (size > 8) { result = __LSH(result, __ASHL(bytecount, 3) - 1, LONGINT);
align = 16; _o_result = result - 1;
} else if (size > 4) { return _o_result;
align = 8; }
} else if (size > 2) {
align = 4; LONGINT OPM_SignedMinimum (LONGINT bytecount)
} else { {
align = (int)size; LONGINT _o_result;
} _o_result = -OPM_SignedMaximum(bytecount) - 1;
} else {
align = OPM_Alignment;
}
_o_result = align;
return _o_result; return _o_result;
} }
static void OPM_GetProperties (void) static void OPM_GetProperties (void)
{ {
LONGINT base;
OPM_ProcSize = OPM_PointerSize; OPM_ProcSize = OPM_PointerSize;
OPM_LIntSize = __ASHL(OPM_IntSize, 1); OPM_LIntSize = __ASHL(OPM_IntSize, 1);
OPM_SetSize = OPM_LIntSize; OPM_SetSize = OPM_LIntSize;
OPM_CharAlign = OPM_AlignSize(OPM_CharSize);
OPM_BoolAlign = OPM_AlignSize(OPM_BoolSize);
OPM_SIntAlign = OPM_AlignSize(OPM_SIntSize);
OPM_RecAlign = OPM_AlignSize(OPM_RecSize);
OPM_RealAlign = OPM_AlignSize(OPM_RealSize);
OPM_LRealAlign = OPM_AlignSize(OPM_LRealSize);
OPM_PointerAlign = OPM_AlignSize(OPM_PointerSize);
OPM_ProcAlign = OPM_AlignSize(OPM_ProcSize);
OPM_IntAlign = OPM_AlignSize(OPM_IntSize);
OPM_LIntAlign = OPM_AlignSize(OPM_LIntSize);
OPM_SetAlign = OPM_AlignSize(OPM_SetSize);
base = -2;
OPM_MinSInt = __ASH(base, __ASHL(OPM_SIntSize, 3) - 2);
OPM_MaxSInt = OPM_minusop(OPM_MinSInt + 1);
OPM_MinInt = __ASH(base, __ASHL(OPM_IntSize, 3) - 2);
OPM_MaxInt = OPM_minusop(OPM_MinInt + 1);
OPM_MinLInt = __ASH(base, __ASHL(OPM_LIntSize, 3) - 2);
OPM_MaxLInt = OPM_minusop(OPM_MinLInt + 1);
if (OPM_RealSize == 4) { if (OPM_RealSize == 4) {
OPM_MaxReal = 3.40282346000000e+038; OPM_MaxReal = 3.40282346000000e+038;
} else if (OPM_RealSize == 8) { } else if (OPM_RealSize == 8) {
@ -725,7 +677,7 @@ static void OPM_GetProperties (void)
OPM_MinReal = -OPM_MaxReal; OPM_MinReal = -OPM_MaxReal;
OPM_MinLReal = -OPM_MaxLReal; OPM_MinLReal = -OPM_MaxLReal;
OPM_MaxSet = __ASHL(OPM_SetSize, 3) - 1; OPM_MaxSet = __ASHL(OPM_SetSize, 3) - 1;
OPM_MaxIndex = OPM_MaxLInt; OPM_MaxIndex = OPM_SignedMaximum(OPM_PointerSize);
if (OPM_Verbose) { if (OPM_Verbose) {
OPM_VerboseListSizes(); OPM_VerboseListSizes();
} }
@ -887,7 +839,7 @@ void OPM_WriteInt (LONGINT i)
{ {
CHAR s[20]; CHAR s[20];
LONGINT i1, k; LONGINT i1, k;
if (i == OPM_MinInt || i == OPM_MinLInt) { if (i == OPM_SignedMinimum(OPM_IntSize) || i == OPM_SignedMinimum(OPM_LIntSize)) {
OPM_Write('('); OPM_Write('(');
OPM_WriteInt(i + 1); OPM_WriteInt(i + 1);
OPM_WriteString((CHAR*)"-1)", (LONGINT)4); OPM_WriteString((CHAR*)"-1)", (LONGINT)4);
@ -920,7 +872,7 @@ void OPM_WriteReal (LONGREAL r, CHAR suffx)
CHAR s[32]; CHAR s[32];
CHAR ch; CHAR ch;
INTEGER i; INTEGER i;
if ((((r < OPM_MaxLInt && r > OPM_MinLInt)) && r == (__ENTIER(r)))) { if ((((r < OPM_SignedMaximum(OPM_LIntSize) && r > OPM_SignedMinimum(OPM_LIntSize))) && r == (__ENTIER(r)))) {
if (suffx == 'f') { if (suffx == 'f') {
OPM_WriteString((CHAR*)"(REAL)", (LONGINT)7); OPM_WriteString((CHAR*)"(REAL)", (LONGINT)7);
} else { } else {

View file

@ -6,8 +6,8 @@
#include "SYSTEM.h" #include "SYSTEM.h"
import INTEGER OPM_Alignment, OPM_ByteSize, OPM_CharSize, OPM_BoolSize, OPM_SIntSize, OPM_IntSize, OPM_LIntSize, OPM_SetSize, OPM_RealSize, OPM_LRealSize, OPM_PointerSize, OPM_ProcSize, OPM_RecSize, OPM_CharAlign, OPM_BoolAlign, OPM_SIntAlign, OPM_IntAlign, OPM_LIntAlign, OPM_SetAlign, OPM_RealAlign, OPM_LRealAlign, OPM_PointerAlign, OPM_ProcAlign, OPM_RecAlign, OPM_MaxSet; import INTEGER OPM_Alignment, OPM_ByteSize, OPM_CharSize, OPM_BoolSize, OPM_SIntSize, OPM_IntSize, OPM_LIntSize, OPM_SetSize, OPM_RealSize, OPM_LRealSize, OPM_PointerSize, OPM_ProcSize, OPM_RecSize, OPM_MaxSet;
import LONGINT OPM_MinSInt, OPM_MinInt, OPM_MinLInt, OPM_MaxSInt, OPM_MaxInt, OPM_MaxLInt, OPM_MaxIndex; import LONGINT OPM_MaxIndex;
import LONGREAL OPM_MinReal, OPM_MaxReal, OPM_MinLReal, OPM_MaxLReal; import LONGREAL OPM_MinReal, OPM_MaxReal, OPM_MinLReal, OPM_MaxLReal;
import BOOLEAN OPM_noerr; import BOOLEAN OPM_noerr;
import LONGINT OPM_curpos, OPM_errpos, OPM_breakpc; import LONGINT OPM_curpos, OPM_errpos, OPM_breakpc;
@ -18,7 +18,6 @@ import SET OPM_opt, OPM_glbopt;
import BOOLEAN OPM_dontAsm, OPM_dontLink, OPM_mainProg, OPM_mainLinkStat, OPM_notColorOutput, OPM_forceNewSym, OPM_Verbose; import BOOLEAN OPM_dontAsm, OPM_dontLink, OPM_mainProg, OPM_mainLinkStat, OPM_notColorOutput, OPM_forceNewSym, OPM_Verbose;
import INTEGER OPM_AlignSize (LONGINT size);
import void OPM_CloseFiles (void); import void OPM_CloseFiles (void);
import void OPM_CloseOldSym (void); import void OPM_CloseOldSym (void);
import void OPM_DeleteNewSym (void); import void OPM_DeleteNewSym (void);
@ -39,6 +38,8 @@ import void OPM_OldSym (CHAR *modName, LONGINT modName__len, BOOLEAN *done);
import void OPM_OpenFiles (CHAR *moduleName, LONGINT moduleName__len); import void OPM_OpenFiles (CHAR *moduleName, LONGINT moduleName__len);
import BOOLEAN OPM_OpenPar (void); import BOOLEAN OPM_OpenPar (void);
import void OPM_RegisterNewSym (void); import void OPM_RegisterNewSym (void);
import LONGINT OPM_SignedMaximum (LONGINT bytecount);
import LONGINT OPM_SignedMinimum (LONGINT bytecount);
import void OPM_SymRCh (CHAR *ch); import void OPM_SymRCh (CHAR *ch);
import LONGINT OPM_SymRInt (void); import LONGINT OPM_SymRInt (void);
import void OPM_SymRLReal (LONGREAL *lr); import void OPM_SymRLReal (LONGREAL *lr);

View file

@ -82,7 +82,7 @@ void OPV_TypSize (OPT_Struct typ)
btyp = typ->BaseTyp; btyp = typ->BaseTyp;
if (btyp == NIL) { if (btyp == NIL) {
offset = 0; offset = 0;
base = OPM_RecAlign; base = OPC_SizeAlignment(OPM_RecSize);
} else { } else {
OPV_TypSize(btyp); OPV_TypSize(btyp);
offset = btyp->size - (LONGINT)__ASHR(btyp->sysflag, 8); offset = btyp->size - (LONGINT)__ASHR(btyp->sysflag, 8);
@ -93,7 +93,7 @@ void OPV_TypSize (OPT_Struct typ)
btyp = fld->typ; btyp = fld->typ;
OPV_TypSize(btyp); OPV_TypSize(btyp);
size = btyp->size; size = btyp->size;
fbase = OPC_Base(btyp); fbase = OPC_BaseAlignment(btyp);
OPC_Align(&offset, fbase); OPC_Align(&offset, fbase);
fld->adr = offset; fld->adr = offset;
offset += size; offset += size;
@ -107,7 +107,7 @@ void OPV_TypSize (OPT_Struct typ)
offset = 1; offset = 1;
} }
if (OPM_RecSize == 0) { if (OPM_RecSize == 0) {
base = OPV_NaturalAlignment(offset, OPM_RecAlign); base = OPV_NaturalAlignment(offset, OPC_SizeAlignment(OPM_RecSize));
} }
OPC_Align(&offset, base); OPC_Align(&offset, base);
if ((typ->strobj == NIL && __MASK(typ->align, -65536) == 0)) { if ((typ->strobj == NIL && __MASK(typ->align, -65536) == 0)) {
@ -491,7 +491,7 @@ static void OPV_Convert (OPT_Node n, INTEGER form, INTEGER prec)
OPM_Write('('); OPM_Write('(');
OPV_Entier(n, -1); OPV_Entier(n, -1);
OPM_WriteString((CHAR*)", ", (LONGINT)3); OPM_WriteString((CHAR*)", ", (LONGINT)3);
OPM_WriteInt(OPM_MaxInt + 1); OPM_WriteInt(OPM_SignedMaximum(OPM_IntSize) + 1);
OPM_Write(')'); OPM_Write(')');
} else { } else {
OPM_WriteString((CHAR*)"(int)", (LONGINT)6); OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
@ -507,7 +507,7 @@ static void OPV_Convert (OPT_Node n, INTEGER form, INTEGER prec)
OPM_Write('('); OPM_Write('(');
OPV_Entier(n, -1); OPV_Entier(n, -1);
OPM_WriteString((CHAR*)", ", (LONGINT)3); OPM_WriteString((CHAR*)", ", (LONGINT)3);
OPM_WriteInt(OPM_MaxSInt + 1); OPM_WriteInt(OPM_SignedMaximum(OPM_SIntSize) + 1);
OPM_Write(')'); OPM_Write(')');
} else { } else {
OPM_WriteString((CHAR*)"(int)", (LONGINT)6); OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
@ -795,7 +795,7 @@ static void OPV_ActualPar (OPT_Node n, OPT_Object fp)
} }
if ((((mode == 2 && n->class == 11)) && n->subcl == 29)) { if ((((mode == 2 && n->class == 11)) && n->subcl == 29)) {
OPV_expr(n->left, prec); OPV_expr(n->left, prec);
} else if ((((((form == 6 && n->class == 7)) && n->conval->intval <= OPM_MaxInt)) && n->conval->intval >= OPM_MinInt)) { } else if ((((((form == 6 && n->class == 7)) && n->conval->intval <= OPM_SignedMaximum(OPM_IntSize))) && n->conval->intval >= OPM_SignedMinimum(OPM_IntSize))) {
OPM_WriteString((CHAR*)"((LONGINT)(", (LONGINT)12); OPM_WriteString((CHAR*)"((LONGINT)(", (LONGINT)12);
OPV_expr(n, prec); OPV_expr(n, prec);
OPM_WriteString((CHAR*)"))", (LONGINT)3); OPM_WriteString((CHAR*)"))", (LONGINT)3);
@ -1322,7 +1322,7 @@ static void OPV_NewArr (OPT_Node d, OPT_Node x)
OPM_WriteInt(base->size); OPM_WriteInt(base->size);
OPM_WriteString((CHAR*)"))", (LONGINT)3); OPM_WriteString((CHAR*)"))", (LONGINT)3);
OPM_WriteString((CHAR*)", ", (LONGINT)3); OPM_WriteString((CHAR*)", ", (LONGINT)3);
OPM_WriteInt(OPC_Base(base)); OPM_WriteInt(OPC_BaseAlignment(base));
OPM_WriteString((CHAR*)", ", (LONGINT)3); OPM_WriteString((CHAR*)", ", (LONGINT)3);
OPM_WriteInt(nofdim); OPM_WriteInt(nofdim);
OPM_WriteString((CHAR*)", ", (LONGINT)3); OPM_WriteString((CHAR*)", ", (LONGINT)3);

View file

@ -55,8 +55,6 @@ static void OPB_SetIntType (OPT_Node node);
export void OPB_SetRange (OPT_Node *x, OPT_Node y); export void OPB_SetRange (OPT_Node *x, OPT_Node y);
static LONGINT OPB_ShorterSize (LONGINT i); static LONGINT OPB_ShorterSize (LONGINT i);
static INTEGER OPB_SignedByteSize (LONGINT n); static INTEGER OPB_SignedByteSize (LONGINT n);
static LONGINT OPB_SignedMaximum (LONGINT bytecount);
static LONGINT OPB_SignedMinimum (LONGINT bytecount);
export void OPB_StFct (OPT_Node *par0, SHORTINT fctno, INTEGER parno); export void OPB_StFct (OPT_Node *par0, SHORTINT fctno, INTEGER parno);
export void OPB_StPar0 (OPT_Node *par0, INTEGER fctno); export void OPB_StPar0 (OPT_Node *par0, INTEGER fctno);
export void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno); export void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno);
@ -226,23 +224,6 @@ OPT_Node OPB_EmptySet (void)
return _o_result; return _o_result;
} }
static LONGINT OPB_SignedMaximum (LONGINT bytecount)
{
LONGINT _o_result;
LONGINT result;
result = 1;
result = __LSH(result, __ASHL(bytecount, 3) - 1, LONGINT);
_o_result = result - 1;
return _o_result;
}
static LONGINT OPB_SignedMinimum (LONGINT bytecount)
{
LONGINT _o_result;
_o_result = -OPB_SignedMaximum(bytecount) - 1;
return _o_result;
}
static INTEGER OPB_SignedByteSize (LONGINT n) static INTEGER OPB_SignedByteSize (LONGINT n)
{ {
INTEGER _o_result; INTEGER _o_result;
@ -448,16 +429,16 @@ void OPB_Field (OPT_Node *x, OPT_Object y)
} }
} }
static struct TypTest__63 { static struct TypTest__61 {
OPT_Node *x; OPT_Node *x;
OPT_Object *obj; OPT_Object *obj;
BOOLEAN *guard; BOOLEAN *guard;
struct TypTest__63 *lnk; struct TypTest__61 *lnk;
} *TypTest__63_s; } *TypTest__61_s;
static void GTT__64 (OPT_Struct t0, OPT_Struct t1); static void GTT__62 (OPT_Struct t0, OPT_Struct t1);
static void GTT__64 (OPT_Struct t0, OPT_Struct t1) static void GTT__62 (OPT_Struct t0, OPT_Struct t1)
{ {
OPT_Node node = NIL; OPT_Node node = NIL;
OPT_Struct t = NIL; OPT_Struct t = NIL;
@ -470,54 +451,54 @@ static void GTT__64 (OPT_Struct t0, OPT_Struct t1)
t1 = t1->BaseTyp; t1 = t1->BaseTyp;
} }
if (t1 == t0 || t0->form == 0) { if (t1 == t0 || t0->form == 0) {
if (*TypTest__63_s->guard) { if (*TypTest__61_s->guard) {
OPB_BindNodes(5, NIL, &*TypTest__63_s->x, NIL); OPB_BindNodes(5, NIL, &*TypTest__61_s->x, NIL);
(*TypTest__63_s->x)->readonly = (*TypTest__63_s->x)->left->readonly; (*TypTest__61_s->x)->readonly = (*TypTest__61_s->x)->left->readonly;
} else { } else {
node = OPT_NewNode(11); node = OPT_NewNode(11);
node->subcl = 16; node->subcl = 16;
node->left = *TypTest__63_s->x; node->left = *TypTest__61_s->x;
node->obj = *TypTest__63_s->obj; node->obj = *TypTest__61_s->obj;
*TypTest__63_s->x = node; *TypTest__61_s->x = node;
} }
} else { } else {
OPB_err(85); OPB_err(85);
} }
} else if (t0 != t1) { } else if (t0 != t1) {
OPB_err(85); OPB_err(85);
} else if (!*TypTest__63_s->guard) { } else if (!*TypTest__61_s->guard) {
if ((*TypTest__63_s->x)->class == 5) { if ((*TypTest__61_s->x)->class == 5) {
node = OPT_NewNode(11); node = OPT_NewNode(11);
node->subcl = 16; node->subcl = 16;
node->left = *TypTest__63_s->x; node->left = *TypTest__61_s->x;
node->obj = *TypTest__63_s->obj; node->obj = *TypTest__61_s->obj;
*TypTest__63_s->x = node; *TypTest__61_s->x = node;
} else { } else {
*TypTest__63_s->x = OPB_NewBoolConst(1); *TypTest__61_s->x = OPB_NewBoolConst(1);
} }
} }
} }
void OPB_TypTest (OPT_Node *x, OPT_Object obj, BOOLEAN guard) void OPB_TypTest (OPT_Node *x, OPT_Object obj, BOOLEAN guard)
{ {
struct TypTest__63 _s; struct TypTest__61 _s;
_s.x = x; _s.x = x;
_s.obj = &obj; _s.obj = &obj;
_s.guard = &guard; _s.guard = &guard;
_s.lnk = TypTest__63_s; _s.lnk = TypTest__61_s;
TypTest__63_s = &_s; TypTest__61_s = &_s;
if (OPB_NotVar(*x)) { if (OPB_NotVar(*x)) {
OPB_err(112); OPB_err(112);
} else if ((*x)->typ->form == 13) { } else if ((*x)->typ->form == 13) {
if (((*x)->typ->BaseTyp->comp != 4 && (*x)->typ != OPT_sysptrtyp)) { if (((*x)->typ->BaseTyp->comp != 4 && (*x)->typ != OPT_sysptrtyp)) {
OPB_err(85); OPB_err(85);
} else if (obj->typ->form == 13) { } else if (obj->typ->form == 13) {
GTT__64((*x)->typ->BaseTyp, obj->typ->BaseTyp); GTT__62((*x)->typ->BaseTyp, obj->typ->BaseTyp);
} else { } else {
OPB_err(86); OPB_err(86);
} }
} else if (((((*x)->typ->comp == 4 && (*x)->class == 1)) && obj->typ->comp == 4)) { } else if (((((*x)->typ->comp == 4 && (*x)->class == 1)) && obj->typ->comp == 4)) {
GTT__64((*x)->typ, obj->typ); GTT__62((*x)->typ, obj->typ);
} else { } else {
OPB_err(87); OPB_err(87);
} }
@ -526,7 +507,7 @@ void OPB_TypTest (OPT_Node *x, OPT_Object obj, BOOLEAN guard)
} else { } else {
(*x)->typ = OPT_booltyp; (*x)->typ = OPT_booltyp;
} }
TypTest__63_s = _s.lnk; TypTest__61_s = _s.lnk;
} }
void OPB_In (OPT_Node *x, OPT_Node y) void OPB_In (OPT_Node *x, OPT_Node y)
@ -1849,7 +1830,7 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno)
x->typ = OPT_chartyp; x->typ = OPT_chartyp;
break; break;
case 4: case 5: case 6: case 4: case 5: case 6:
x = OPB_NewIntConst(OPB_SignedMinimum(x->typ->size)); x = OPB_NewIntConst(OPM_SignedMinimum(x->typ->size));
break; break;
case 9: case 9:
x = OPB_NewIntConst(((LONGINT)(0))); x = OPB_NewIntConst(((LONGINT)(0)));
@ -1880,7 +1861,7 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno)
x->typ = OPT_chartyp; x->typ = OPT_chartyp;
break; break;
case 4: case 5: case 6: case 4: case 5: case 6:
x = OPB_NewIntConst(OPB_SignedMaximum(x->typ->size)); x = OPB_NewIntConst(OPM_SignedMaximum(x->typ->size));
break; break;
case 9: case 9:
x = OPB_NewIntConst(OPM_MaxSet); x = OPB_NewIntConst(OPM_MaxSet);
@ -2062,13 +2043,13 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno)
*par0 = x; *par0 = x;
} }
static struct StPar1__58 { static struct StPar1__56 {
struct StPar1__58 *lnk; struct StPar1__56 *lnk;
} *StPar1__58_s; } *StPar1__56_s;
static OPT_Node NewOp__59 (SHORTINT class, SHORTINT subcl, OPT_Node left, OPT_Node right); static OPT_Node NewOp__57 (SHORTINT class, SHORTINT subcl, OPT_Node left, OPT_Node right);
static OPT_Node NewOp__59 (SHORTINT class, SHORTINT subcl, OPT_Node left, OPT_Node right) static OPT_Node NewOp__57 (SHORTINT class, SHORTINT subcl, OPT_Node left, OPT_Node right)
{ {
OPT_Node _o_result; OPT_Node _o_result;
OPT_Node node = NIL; OPT_Node node = NIL;
@ -2085,9 +2066,9 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
INTEGER f, L; INTEGER f, L;
OPT_Struct typ = NIL; OPT_Struct typ = NIL;
OPT_Node p = NIL, t = NIL; OPT_Node p = NIL, t = NIL;
struct StPar1__58 _s; struct StPar1__56 _s;
_s.lnk = StPar1__58_s; _s.lnk = StPar1__56_s;
StPar1__58_s = &_s; StPar1__56_s = &_s;
p = *par0; p = *par0;
f = x->typ->form; f = x->typ->form;
switch (fctno) { switch (fctno) {
@ -2103,7 +2084,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
OPB_err(111); OPB_err(111);
} }
} }
p = NewOp__59(19, fctno, p, x); p = NewOp__57(19, fctno, p, x);
p->typ = OPT_notyp; p->typ = OPT_notyp;
} }
break; break;
@ -2114,7 +2095,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
if ((x->class == 7 && (0 > x->conval->intval || x->conval->intval > (LONGINT)OPM_MaxSet))) { if ((x->class == 7 && (0 > x->conval->intval || x->conval->intval > (LONGINT)OPM_MaxSet))) {
OPB_err(202); OPB_err(202);
} }
p = NewOp__59(19, fctno, p, x); p = NewOp__57(19, fctno, p, x);
} else { } else {
OPB_err(111); OPB_err(111);
} }
@ -2139,7 +2120,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
p = p->left; p = p->left;
x->conval->intval += 1; x->conval->intval += 1;
} }
p = NewOp__59(12, 19, p, x); p = NewOp__57(12, 19, p, x);
p->typ = OPT_linttyp; p->typ = OPT_linttyp;
} else { } else {
p = x; p = x;
@ -2161,7 +2142,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
t = x; t = x;
x = p; x = p;
p = t; p = t;
p = NewOp__59(19, 18, p, x); p = NewOp__57(19, 18, p, x);
} else { } else {
OPB_err(111); OPB_err(111);
} }
@ -2187,7 +2168,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
} }
p->obj = NIL; p->obj = NIL;
} else { } else {
p = NewOp__59(12, 17, p, x); p = NewOp__57(12, 17, p, x);
p->typ = OPT_linttyp; p->typ = OPT_linttyp;
} }
} else { } else {
@ -2218,9 +2199,9 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
OPB_err(111); OPB_err(111);
} else { } else {
if (fctno == 22) { if (fctno == 22) {
p = NewOp__59(12, 27, p, x); p = NewOp__57(12, 27, p, x);
} else { } else {
p = NewOp__59(12, 28, p, x); p = NewOp__57(12, 28, p, x);
} }
p->typ = p->left->typ; p->typ = p->left->typ;
} }
@ -2237,7 +2218,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
x = p; x = p;
p = t; p = t;
} }
p = NewOp__59(19, fctno, p, x); p = NewOp__57(19, fctno, p, x);
} else { } else {
OPB_err(111); OPB_err(111);
} }
@ -2247,7 +2228,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
if (x->class == 8 || x->class == 9) { if (x->class == 8 || x->class == 9) {
OPB_err(126); OPB_err(126);
} else if (__IN(f, 0x70)) { } else if (__IN(f, 0x70)) {
p = NewOp__59(12, 26, p, x); p = NewOp__57(12, 26, p, x);
} else { } else {
OPB_err(111); OPB_err(111);
} }
@ -2271,7 +2252,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
if (x->class == 8 || x->class == 9) { if (x->class == 8 || x->class == 9) {
OPB_err(126); OPB_err(126);
} else if (__IN(f, 0x70)) { } else if (__IN(f, 0x70)) {
p = NewOp__59(19, 30, p, x); p = NewOp__57(19, 30, p, x);
} else { } else {
OPB_err(111); OPB_err(111);
} }
@ -2317,7 +2298,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
break; break;
} }
*par0 = p; *par0 = p;
StPar1__58_s = _s.lnk; StPar1__56_s = _s.lnk;
} }
void OPB_StParN (OPT_Node *par0, OPT_Node x, INTEGER fctno, INTEGER n) void OPB_StParN (OPT_Node *par0, OPT_Node x, INTEGER fctno, INTEGER n)

View file

@ -16,7 +16,7 @@ static CHAR OPC_BodyNameExt[13];
export void OPC_Align (LONGINT *adr, LONGINT base); export void OPC_Align (LONGINT *adr, LONGINT base);
export void OPC_Andent (OPT_Struct typ); export void OPC_Andent (OPT_Struct typ);
static void OPC_AnsiParamList (OPT_Object obj, BOOLEAN showParamNames); static void OPC_AnsiParamList (OPT_Object obj, BOOLEAN showParamNames);
export LONGINT OPC_Base (OPT_Struct typ); export LONGINT OPC_BaseAlignment (OPT_Struct typ);
export OPT_Object OPC_BaseTProc (OPT_Object obj); export OPT_Object OPC_BaseTProc (OPT_Object obj);
export void OPC_BegBlk (void); export void OPC_BegBlk (void);
export void OPC_BegStat (void); export void OPC_BegStat (void);
@ -74,6 +74,7 @@ static void OPC_PutBase (OPT_Struct typ);
static void OPC_PutPtrOffsets (OPT_Struct typ, LONGINT adr, LONGINT *cnt); static void OPC_PutPtrOffsets (OPT_Struct typ, LONGINT adr, LONGINT *cnt);
static void OPC_RegCmds (OPT_Object obj); static void OPC_RegCmds (OPT_Object obj);
export void OPC_SetInclude (BOOLEAN exclude); export void OPC_SetInclude (BOOLEAN exclude);
export LONGINT OPC_SizeAlignment (LONGINT size);
static void OPC_Stars (OPT_Struct typ, BOOLEAN *openClause); static void OPC_Stars (OPT_Struct typ, BOOLEAN *openClause);
static void OPC_Str1 (CHAR *s, LONGINT s__len, LONGINT x); static void OPC_Str1 (CHAR *s, LONGINT s__len, LONGINT x);
static void OPC_StringLiteral (CHAR *s, LONGINT s__len, LONGINT l); static void OPC_StringLiteral (CHAR *s, LONGINT s__len, LONGINT l);
@ -867,70 +868,37 @@ void OPC_Align (LONGINT *adr, LONGINT base)
} }
} }
LONGINT OPC_Base (OPT_Struct typ) LONGINT OPC_SizeAlignment (LONGINT size)
{ {
LONGINT _o_result; LONGINT _o_result;
switch (typ->form) { LONGINT alignment;
case 1: if (size < (LONGINT)OPM_Alignment) {
_o_result = 1; alignment = 1;
return _o_result; while (alignment < size) {
break; alignment = __ASHL(alignment, 1);
case 3: }
_o_result = OPM_CharAlign; } else {
return _o_result; alignment = OPM_Alignment;
break;
case 2:
_o_result = OPM_BoolAlign;
return _o_result;
break;
case 4:
_o_result = OPM_SIntAlign;
return _o_result;
break;
case 5:
_o_result = OPM_IntAlign;
return _o_result;
break;
case 6:
_o_result = OPM_LIntAlign;
return _o_result;
break;
case 7:
_o_result = OPM_RealAlign;
return _o_result;
break;
case 8:
_o_result = OPM_LRealAlign;
return _o_result;
break;
case 9:
_o_result = OPM_SetAlign;
return _o_result;
break;
case 13:
_o_result = OPM_PointerAlign;
return _o_result;
break;
case 14:
_o_result = OPM_ProcAlign;
return _o_result;
break;
case 15:
if (typ->comp == 4) {
_o_result = __MASK(typ->align, -65536);
return _o_result;
} else {
_o_result = OPC_Base(typ->BaseTyp);
return _o_result;
}
break;
default:
OPM_LogWStr((CHAR*)"unhandled case in OPC.Base, typ^form = ", (LONGINT)40);
OPM_LogWNum(typ->form, ((LONGINT)(0)));
OPM_LogWLn();
break;
} }
__RETCHK; _o_result = alignment;
return _o_result;
}
LONGINT OPC_BaseAlignment (OPT_Struct typ)
{
LONGINT _o_result;
LONGINT alignment;
if (typ->form == 15) {
if (typ->comp == 4) {
alignment = __MASK(typ->align, -65536);
} else {
alignment = OPC_BaseAlignment(typ->BaseTyp);
}
} else {
alignment = OPC_SizeAlignment(typ->size);
}
_o_result = alignment;
return _o_result;
} }
static void OPC_FillGap (LONGINT gap, LONGINT off, LONGINT align, LONGINT *n, LONGINT *curAlign) static void OPC_FillGap (LONGINT gap, LONGINT off, LONGINT align, LONGINT *n, LONGINT *curAlign)
@ -984,7 +952,7 @@ static void OPC_FieldList (OPT_Struct typ, BOOLEAN last, LONGINT *off, LONGINT *
} }
} else { } else {
adr = *off; adr = *off;
fldAlign = OPC_Base(fld->typ); fldAlign = OPC_BaseAlignment(fld->typ);
OPC_Align(&adr, fldAlign); OPC_Align(&adr, fldAlign);
gap = fld->adr - adr; gap = fld->adr - adr;
if (fldAlign > *curAlign) { if (fldAlign > *curAlign) {

View file

@ -11,7 +11,7 @@
import void OPC_Align (LONGINT *adr, LONGINT base); import void OPC_Align (LONGINT *adr, LONGINT base);
import void OPC_Andent (OPT_Struct typ); import void OPC_Andent (OPT_Struct typ);
import LONGINT OPC_Base (OPT_Struct typ); import LONGINT OPC_BaseAlignment (OPT_Struct typ);
import OPT_Object OPC_BaseTProc (OPT_Object obj); import OPT_Object OPC_BaseTProc (OPT_Object obj);
import void OPC_BegBlk (void); import void OPC_BegBlk (void);
import void OPC_BegStat (void); import void OPC_BegStat (void);
@ -40,6 +40,7 @@ import void OPC_InitTDesc (OPT_Struct typ);
import void OPC_Len (OPT_Object obj, OPT_Struct array, LONGINT dim); import void OPC_Len (OPT_Object obj, OPT_Struct array, LONGINT dim);
import LONGINT OPC_NofPtrs (OPT_Struct typ); import LONGINT OPC_NofPtrs (OPT_Struct typ);
import void OPC_SetInclude (BOOLEAN exclude); import void OPC_SetInclude (BOOLEAN exclude);
import LONGINT OPC_SizeAlignment (LONGINT size);
import void OPC_TDescDecl (OPT_Struct typ); import void OPC_TDescDecl (OPT_Struct typ);
import void OPC_TypeDefs (OPT_Object obj, INTEGER vis); import void OPC_TypeDefs (OPT_Object obj, INTEGER vis);
import void OPC_TypeOf (OPT_Object ap); import void OPC_TypeOf (OPT_Object ap);

View file

@ -14,8 +14,8 @@ typedef
static CHAR OPM_SourceFileName[256]; static CHAR OPM_SourceFileName[256];
export INTEGER OPM_Alignment, OPM_ByteSize, OPM_CharSize, OPM_BoolSize, OPM_SIntSize, OPM_IntSize, OPM_LIntSize, OPM_SetSize, OPM_RealSize, OPM_LRealSize, OPM_PointerSize, OPM_ProcSize, OPM_RecSize, OPM_CharAlign, OPM_BoolAlign, OPM_SIntAlign, OPM_IntAlign, OPM_LIntAlign, OPM_SetAlign, OPM_RealAlign, OPM_LRealAlign, OPM_PointerAlign, OPM_ProcAlign, OPM_RecAlign, OPM_MaxSet; export INTEGER OPM_Alignment, OPM_ByteSize, OPM_CharSize, OPM_BoolSize, OPM_SIntSize, OPM_IntSize, OPM_LIntSize, OPM_SetSize, OPM_RealSize, OPM_LRealSize, OPM_PointerSize, OPM_ProcSize, OPM_RecSize, OPM_MaxSet;
export LONGINT OPM_MinSInt, OPM_MinInt, OPM_MinLInt, OPM_MaxSInt, OPM_MaxInt, OPM_MaxLInt, OPM_MaxIndex; export LONGINT OPM_MaxIndex;
export LONGREAL OPM_MinReal, OPM_MaxReal, OPM_MinLReal, OPM_MaxLReal; export LONGREAL OPM_MinReal, OPM_MaxReal, OPM_MinLReal, OPM_MaxLReal;
export BOOLEAN OPM_noerr; export BOOLEAN OPM_noerr;
export LONGINT OPM_curpos, OPM_errpos, OPM_breakpc; export LONGINT OPM_curpos, OPM_errpos, OPM_breakpc;
@ -36,7 +36,6 @@ static CHAR OPM_OBERON[1024];
static CHAR OPM_MODULES[1024]; static CHAR OPM_MODULES[1024];
export INTEGER OPM_AlignSize (LONGINT size);
static void OPM_Append (Files_Rider *R, LONGINT *R__typ, Files_File F); static void OPM_Append (Files_Rider *R, LONGINT *R__typ, Files_File F);
export void OPM_CloseFiles (void); export void OPM_CloseFiles (void);
export void OPM_CloseOldSym (void); export void OPM_CloseOldSym (void);
@ -65,6 +64,8 @@ export BOOLEAN OPM_OpenPar (void);
export void OPM_RegisterNewSym (void); export void OPM_RegisterNewSym (void);
static void OPM_ScanOptions (CHAR *s, LONGINT s__len, SET *opt); static void OPM_ScanOptions (CHAR *s, LONGINT s__len, SET *opt);
static void OPM_ShowLine (LONGINT pos); static void OPM_ShowLine (LONGINT pos);
export LONGINT OPM_SignedMaximum (LONGINT bytecount);
export LONGINT OPM_SignedMinimum (LONGINT bytecount);
export void OPM_SymRCh (CHAR *ch); export void OPM_SymRCh (CHAR *ch);
export LONGINT OPM_SymRInt (void); export LONGINT OPM_SymRInt (void);
export void OPM_SymRLReal (LONGREAL *lr); export void OPM_SymRLReal (LONGREAL *lr);
@ -607,111 +608,62 @@ static void OPM_VerboseListSizes (void)
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"CHAR ", (LONGINT)14); OPM_LogWStr((CHAR*)"CHAR ", (LONGINT)14);
OPM_LogWNum(OPM_CharSize, ((LONGINT)(4))); OPM_LogWNum(OPM_CharSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_CharAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"BOOLEAN ", (LONGINT)14); OPM_LogWStr((CHAR*)"BOOLEAN ", (LONGINT)14);
OPM_LogWNum(OPM_BoolSize, ((LONGINT)(4))); OPM_LogWNum(OPM_BoolSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_BoolAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"SHORTINT ", (LONGINT)14); OPM_LogWStr((CHAR*)"SHORTINT ", (LONGINT)14);
OPM_LogWNum(OPM_SIntSize, ((LONGINT)(4))); OPM_LogWNum(OPM_SIntSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_SIntAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"INTEGER ", (LONGINT)14); OPM_LogWStr((CHAR*)"INTEGER ", (LONGINT)14);
OPM_LogWNum(OPM_IntSize, ((LONGINT)(4))); OPM_LogWNum(OPM_IntSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_IntAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"LONGINT ", (LONGINT)14); OPM_LogWStr((CHAR*)"LONGINT ", (LONGINT)14);
OPM_LogWNum(OPM_LIntSize, ((LONGINT)(4))); OPM_LogWNum(OPM_LIntSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_LIntAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"SET ", (LONGINT)14); OPM_LogWStr((CHAR*)"SET ", (LONGINT)14);
OPM_LogWNum(OPM_SetSize, ((LONGINT)(4))); OPM_LogWNum(OPM_SetSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_SetAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"REAL ", (LONGINT)14); OPM_LogWStr((CHAR*)"REAL ", (LONGINT)14);
OPM_LogWNum(OPM_RealSize, ((LONGINT)(4))); OPM_LogWNum(OPM_RealSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_RealAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"LONGREAL ", (LONGINT)14); OPM_LogWStr((CHAR*)"LONGREAL ", (LONGINT)14);
OPM_LogWNum(OPM_LRealSize, ((LONGINT)(4))); OPM_LogWNum(OPM_LRealSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_LRealAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"PTR ", (LONGINT)14); OPM_LogWStr((CHAR*)"PTR ", (LONGINT)14);
OPM_LogWNum(OPM_PointerSize, ((LONGINT)(4))); OPM_LogWNum(OPM_PointerSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_PointerAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"PROC ", (LONGINT)14); OPM_LogWStr((CHAR*)"PROC ", (LONGINT)14);
OPM_LogWNum(OPM_ProcSize, ((LONGINT)(4))); OPM_LogWNum(OPM_ProcSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_ProcAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"RECORD ", (LONGINT)14); OPM_LogWStr((CHAR*)"RECORD ", (LONGINT)14);
OPM_LogWNum(OPM_RecSize, ((LONGINT)(4))); OPM_LogWNum(OPM_RecSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_RecAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"Min shortint ", (LONGINT)14);
OPM_LogWNum(OPM_MinSInt, ((LONGINT)(4)));
OPM_LogWLn();
OPM_LogWStr((CHAR*)"Max shortint ", (LONGINT)14);
OPM_LogWNum(OPM_MaxSInt, ((LONGINT)(4)));
OPM_LogWLn();
OPM_LogWStr((CHAR*)"Min integer ", (LONGINT)14);
OPM_LogWNum(OPM_MinInt, ((LONGINT)(4)));
OPM_LogWLn();
OPM_LogWStr((CHAR*)"Max integer ", (LONGINT)14);
OPM_LogWNum(OPM_MaxInt, ((LONGINT)(4)));
OPM_LogWLn();
OPM_LogWStr((CHAR*)"Min longint ", (LONGINT)14);
OPM_LogWNum(OPM_MinLInt, ((LONGINT)(4)));
OPM_LogWLn();
} }
INTEGER OPM_AlignSize (LONGINT size) LONGINT OPM_SignedMaximum (LONGINT bytecount)
{ {
INTEGER _o_result; LONGINT _o_result;
INTEGER align; LONGINT result;
if (size < (LONGINT)OPM_Alignment) { result = 1;
if (size > 8) { result = __LSH(result, __ASHL(bytecount, 3) - 1, LONGINT);
align = 16; _o_result = result - 1;
} else if (size > 4) { return _o_result;
align = 8; }
} else if (size > 2) {
align = 4; LONGINT OPM_SignedMinimum (LONGINT bytecount)
} else { {
align = (int)size; LONGINT _o_result;
} _o_result = -OPM_SignedMaximum(bytecount) - 1;
} else {
align = OPM_Alignment;
}
_o_result = align;
return _o_result; return _o_result;
} }
static void OPM_GetProperties (void) static void OPM_GetProperties (void)
{ {
LONGINT base;
OPM_ProcSize = OPM_PointerSize; OPM_ProcSize = OPM_PointerSize;
OPM_LIntSize = __ASHL(OPM_IntSize, 1); OPM_LIntSize = __ASHL(OPM_IntSize, 1);
OPM_SetSize = OPM_LIntSize; OPM_SetSize = OPM_LIntSize;
OPM_CharAlign = OPM_AlignSize(OPM_CharSize);
OPM_BoolAlign = OPM_AlignSize(OPM_BoolSize);
OPM_SIntAlign = OPM_AlignSize(OPM_SIntSize);
OPM_RecAlign = OPM_AlignSize(OPM_RecSize);
OPM_RealAlign = OPM_AlignSize(OPM_RealSize);
OPM_LRealAlign = OPM_AlignSize(OPM_LRealSize);
OPM_PointerAlign = OPM_AlignSize(OPM_PointerSize);
OPM_ProcAlign = OPM_AlignSize(OPM_ProcSize);
OPM_IntAlign = OPM_AlignSize(OPM_IntSize);
OPM_LIntAlign = OPM_AlignSize(OPM_LIntSize);
OPM_SetAlign = OPM_AlignSize(OPM_SetSize);
base = -2;
OPM_MinSInt = __ASH(base, __ASHL(OPM_SIntSize, 3) - 2);
OPM_MaxSInt = OPM_minusop(OPM_MinSInt + 1);
OPM_MinInt = __ASH(base, __ASHL(OPM_IntSize, 3) - 2);
OPM_MaxInt = OPM_minusop(OPM_MinInt + 1);
OPM_MinLInt = __ASH(base, __ASHL(OPM_LIntSize, 3) - 2);
OPM_MaxLInt = OPM_minusop(OPM_MinLInt + 1);
if (OPM_RealSize == 4) { if (OPM_RealSize == 4) {
OPM_MaxReal = 3.40282346000000e+038; OPM_MaxReal = 3.40282346000000e+038;
} else if (OPM_RealSize == 8) { } else if (OPM_RealSize == 8) {
@ -725,7 +677,7 @@ static void OPM_GetProperties (void)
OPM_MinReal = -OPM_MaxReal; OPM_MinReal = -OPM_MaxReal;
OPM_MinLReal = -OPM_MaxLReal; OPM_MinLReal = -OPM_MaxLReal;
OPM_MaxSet = __ASHL(OPM_SetSize, 3) - 1; OPM_MaxSet = __ASHL(OPM_SetSize, 3) - 1;
OPM_MaxIndex = OPM_MaxLInt; OPM_MaxIndex = OPM_SignedMaximum(OPM_PointerSize);
if (OPM_Verbose) { if (OPM_Verbose) {
OPM_VerboseListSizes(); OPM_VerboseListSizes();
} }
@ -887,7 +839,7 @@ void OPM_WriteInt (LONGINT i)
{ {
CHAR s[20]; CHAR s[20];
LONGINT i1, k; LONGINT i1, k;
if (i == OPM_MinInt || i == OPM_MinLInt) { if (i == OPM_SignedMinimum(OPM_IntSize) || i == OPM_SignedMinimum(OPM_LIntSize)) {
OPM_Write('('); OPM_Write('(');
OPM_WriteInt(i + 1); OPM_WriteInt(i + 1);
OPM_WriteString((CHAR*)"-1)", (LONGINT)4); OPM_WriteString((CHAR*)"-1)", (LONGINT)4);
@ -920,7 +872,7 @@ void OPM_WriteReal (LONGREAL r, CHAR suffx)
CHAR s[32]; CHAR s[32];
CHAR ch; CHAR ch;
INTEGER i; INTEGER i;
if ((((r < OPM_MaxLInt && r > OPM_MinLInt)) && r == (__ENTIER(r)))) { if ((((r < OPM_SignedMaximum(OPM_LIntSize) && r > OPM_SignedMinimum(OPM_LIntSize))) && r == (__ENTIER(r)))) {
if (suffx == 'f') { if (suffx == 'f') {
OPM_WriteString((CHAR*)"(REAL)", (LONGINT)7); OPM_WriteString((CHAR*)"(REAL)", (LONGINT)7);
} else { } else {

View file

@ -6,8 +6,8 @@
#include "SYSTEM.h" #include "SYSTEM.h"
import INTEGER OPM_Alignment, OPM_ByteSize, OPM_CharSize, OPM_BoolSize, OPM_SIntSize, OPM_IntSize, OPM_LIntSize, OPM_SetSize, OPM_RealSize, OPM_LRealSize, OPM_PointerSize, OPM_ProcSize, OPM_RecSize, OPM_CharAlign, OPM_BoolAlign, OPM_SIntAlign, OPM_IntAlign, OPM_LIntAlign, OPM_SetAlign, OPM_RealAlign, OPM_LRealAlign, OPM_PointerAlign, OPM_ProcAlign, OPM_RecAlign, OPM_MaxSet; import INTEGER OPM_Alignment, OPM_ByteSize, OPM_CharSize, OPM_BoolSize, OPM_SIntSize, OPM_IntSize, OPM_LIntSize, OPM_SetSize, OPM_RealSize, OPM_LRealSize, OPM_PointerSize, OPM_ProcSize, OPM_RecSize, OPM_MaxSet;
import LONGINT OPM_MinSInt, OPM_MinInt, OPM_MinLInt, OPM_MaxSInt, OPM_MaxInt, OPM_MaxLInt, OPM_MaxIndex; import LONGINT OPM_MaxIndex;
import LONGREAL OPM_MinReal, OPM_MaxReal, OPM_MinLReal, OPM_MaxLReal; import LONGREAL OPM_MinReal, OPM_MaxReal, OPM_MinLReal, OPM_MaxLReal;
import BOOLEAN OPM_noerr; import BOOLEAN OPM_noerr;
import LONGINT OPM_curpos, OPM_errpos, OPM_breakpc; import LONGINT OPM_curpos, OPM_errpos, OPM_breakpc;
@ -18,7 +18,6 @@ import SET OPM_opt, OPM_glbopt;
import BOOLEAN OPM_dontAsm, OPM_dontLink, OPM_mainProg, OPM_mainLinkStat, OPM_notColorOutput, OPM_forceNewSym, OPM_Verbose; import BOOLEAN OPM_dontAsm, OPM_dontLink, OPM_mainProg, OPM_mainLinkStat, OPM_notColorOutput, OPM_forceNewSym, OPM_Verbose;
import INTEGER OPM_AlignSize (LONGINT size);
import void OPM_CloseFiles (void); import void OPM_CloseFiles (void);
import void OPM_CloseOldSym (void); import void OPM_CloseOldSym (void);
import void OPM_DeleteNewSym (void); import void OPM_DeleteNewSym (void);
@ -39,6 +38,8 @@ import void OPM_OldSym (CHAR *modName, LONGINT modName__len, BOOLEAN *done);
import void OPM_OpenFiles (CHAR *moduleName, LONGINT moduleName__len); import void OPM_OpenFiles (CHAR *moduleName, LONGINT moduleName__len);
import BOOLEAN OPM_OpenPar (void); import BOOLEAN OPM_OpenPar (void);
import void OPM_RegisterNewSym (void); import void OPM_RegisterNewSym (void);
import LONGINT OPM_SignedMaximum (LONGINT bytecount);
import LONGINT OPM_SignedMinimum (LONGINT bytecount);
import void OPM_SymRCh (CHAR *ch); import void OPM_SymRCh (CHAR *ch);
import LONGINT OPM_SymRInt (void); import LONGINT OPM_SymRInt (void);
import void OPM_SymRLReal (LONGREAL *lr); import void OPM_SymRLReal (LONGREAL *lr);

View file

@ -82,7 +82,7 @@ void OPV_TypSize (OPT_Struct typ)
btyp = typ->BaseTyp; btyp = typ->BaseTyp;
if (btyp == NIL) { if (btyp == NIL) {
offset = 0; offset = 0;
base = OPM_RecAlign; base = OPC_SizeAlignment(OPM_RecSize);
} else { } else {
OPV_TypSize(btyp); OPV_TypSize(btyp);
offset = btyp->size - (LONGINT)__ASHR(btyp->sysflag, 8); offset = btyp->size - (LONGINT)__ASHR(btyp->sysflag, 8);
@ -93,7 +93,7 @@ void OPV_TypSize (OPT_Struct typ)
btyp = fld->typ; btyp = fld->typ;
OPV_TypSize(btyp); OPV_TypSize(btyp);
size = btyp->size; size = btyp->size;
fbase = OPC_Base(btyp); fbase = OPC_BaseAlignment(btyp);
OPC_Align(&offset, fbase); OPC_Align(&offset, fbase);
fld->adr = offset; fld->adr = offset;
offset += size; offset += size;
@ -107,7 +107,7 @@ void OPV_TypSize (OPT_Struct typ)
offset = 1; offset = 1;
} }
if (OPM_RecSize == 0) { if (OPM_RecSize == 0) {
base = OPV_NaturalAlignment(offset, OPM_RecAlign); base = OPV_NaturalAlignment(offset, OPC_SizeAlignment(OPM_RecSize));
} }
OPC_Align(&offset, base); OPC_Align(&offset, base);
if ((typ->strobj == NIL && __MASK(typ->align, -65536) == 0)) { if ((typ->strobj == NIL && __MASK(typ->align, -65536) == 0)) {
@ -491,7 +491,7 @@ static void OPV_Convert (OPT_Node n, INTEGER form, INTEGER prec)
OPM_Write('('); OPM_Write('(');
OPV_Entier(n, -1); OPV_Entier(n, -1);
OPM_WriteString((CHAR*)", ", (LONGINT)3); OPM_WriteString((CHAR*)", ", (LONGINT)3);
OPM_WriteInt(OPM_MaxInt + 1); OPM_WriteInt(OPM_SignedMaximum(OPM_IntSize) + 1);
OPM_Write(')'); OPM_Write(')');
} else { } else {
OPM_WriteString((CHAR*)"(int)", (LONGINT)6); OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
@ -507,7 +507,7 @@ static void OPV_Convert (OPT_Node n, INTEGER form, INTEGER prec)
OPM_Write('('); OPM_Write('(');
OPV_Entier(n, -1); OPV_Entier(n, -1);
OPM_WriteString((CHAR*)", ", (LONGINT)3); OPM_WriteString((CHAR*)", ", (LONGINT)3);
OPM_WriteInt(OPM_MaxSInt + 1); OPM_WriteInt(OPM_SignedMaximum(OPM_SIntSize) + 1);
OPM_Write(')'); OPM_Write(')');
} else { } else {
OPM_WriteString((CHAR*)"(int)", (LONGINT)6); OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
@ -795,7 +795,7 @@ static void OPV_ActualPar (OPT_Node n, OPT_Object fp)
} }
if ((((mode == 2 && n->class == 11)) && n->subcl == 29)) { if ((((mode == 2 && n->class == 11)) && n->subcl == 29)) {
OPV_expr(n->left, prec); OPV_expr(n->left, prec);
} else if ((((((form == 6 && n->class == 7)) && n->conval->intval <= OPM_MaxInt)) && n->conval->intval >= OPM_MinInt)) { } else if ((((((form == 6 && n->class == 7)) && n->conval->intval <= OPM_SignedMaximum(OPM_IntSize))) && n->conval->intval >= OPM_SignedMinimum(OPM_IntSize))) {
OPM_WriteString((CHAR*)"((LONGINT)(", (LONGINT)12); OPM_WriteString((CHAR*)"((LONGINT)(", (LONGINT)12);
OPV_expr(n, prec); OPV_expr(n, prec);
OPM_WriteString((CHAR*)"))", (LONGINT)3); OPM_WriteString((CHAR*)"))", (LONGINT)3);
@ -1322,7 +1322,7 @@ static void OPV_NewArr (OPT_Node d, OPT_Node x)
OPM_WriteInt(base->size); OPM_WriteInt(base->size);
OPM_WriteString((CHAR*)"))", (LONGINT)3); OPM_WriteString((CHAR*)"))", (LONGINT)3);
OPM_WriteString((CHAR*)", ", (LONGINT)3); OPM_WriteString((CHAR*)", ", (LONGINT)3);
OPM_WriteInt(OPC_Base(base)); OPM_WriteInt(OPC_BaseAlignment(base));
OPM_WriteString((CHAR*)", ", (LONGINT)3); OPM_WriteString((CHAR*)", ", (LONGINT)3);
OPM_WriteInt(nofdim); OPM_WriteInt(nofdim);
OPM_WriteString((CHAR*)", ", (LONGINT)3); OPM_WriteString((CHAR*)", ", (LONGINT)3);

View file

@ -56,8 +56,6 @@ static void OPB_SetIntType (OPT_Node node);
export void OPB_SetRange (OPT_Node *x, OPT_Node y); export void OPB_SetRange (OPT_Node *x, OPT_Node y);
static LONGINT OPB_ShorterSize (LONGINT i); static LONGINT OPB_ShorterSize (LONGINT i);
static INTEGER OPB_SignedByteSize (LONGINT n); static INTEGER OPB_SignedByteSize (LONGINT n);
static LONGINT OPB_SignedMaximum (LONGINT bytecount);
static LONGINT OPB_SignedMinimum (LONGINT bytecount);
export void OPB_StFct (OPT_Node *par0, SHORTINT fctno, INTEGER parno); export void OPB_StFct (OPT_Node *par0, SHORTINT fctno, INTEGER parno);
export void OPB_StPar0 (OPT_Node *par0, INTEGER fctno); export void OPB_StPar0 (OPT_Node *par0, INTEGER fctno);
export void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno); export void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno);
@ -227,23 +225,6 @@ OPT_Node OPB_EmptySet (void)
return _o_result; return _o_result;
} }
static LONGINT OPB_SignedMaximum (LONGINT bytecount)
{
LONGINT _o_result;
LONGINT result;
result = 1;
result = __LSH(result, __ASHL(bytecount, 3) - 1, LONGINT);
_o_result = result - 1;
return _o_result;
}
static LONGINT OPB_SignedMinimum (LONGINT bytecount)
{
LONGINT _o_result;
_o_result = -OPB_SignedMaximum(bytecount) - 1;
return _o_result;
}
static INTEGER OPB_SignedByteSize (LONGINT n) static INTEGER OPB_SignedByteSize (LONGINT n)
{ {
INTEGER _o_result; INTEGER _o_result;
@ -449,16 +430,16 @@ void OPB_Field (OPT_Node *x, OPT_Object y)
} }
} }
static struct TypTest__63 { static struct TypTest__61 {
OPT_Node *x; OPT_Node *x;
OPT_Object *obj; OPT_Object *obj;
BOOLEAN *guard; BOOLEAN *guard;
struct TypTest__63 *lnk; struct TypTest__61 *lnk;
} *TypTest__63_s; } *TypTest__61_s;
static void GTT__64 (OPT_Struct t0, OPT_Struct t1); static void GTT__62 (OPT_Struct t0, OPT_Struct t1);
static void GTT__64 (OPT_Struct t0, OPT_Struct t1) static void GTT__62 (OPT_Struct t0, OPT_Struct t1)
{ {
OPT_Node node = NIL; OPT_Node node = NIL;
OPT_Struct t = NIL; OPT_Struct t = NIL;
@ -471,54 +452,54 @@ static void GTT__64 (OPT_Struct t0, OPT_Struct t1)
t1 = t1->BaseTyp; t1 = t1->BaseTyp;
} }
if (t1 == t0 || t0->form == 0) { if (t1 == t0 || t0->form == 0) {
if (*TypTest__63_s->guard) { if (*TypTest__61_s->guard) {
OPB_BindNodes(5, NIL, &*TypTest__63_s->x, NIL); OPB_BindNodes(5, NIL, &*TypTest__61_s->x, NIL);
(*TypTest__63_s->x)->readonly = (*TypTest__63_s->x)->left->readonly; (*TypTest__61_s->x)->readonly = (*TypTest__61_s->x)->left->readonly;
} else { } else {
node = OPT_NewNode(11); node = OPT_NewNode(11);
node->subcl = 16; node->subcl = 16;
node->left = *TypTest__63_s->x; node->left = *TypTest__61_s->x;
node->obj = *TypTest__63_s->obj; node->obj = *TypTest__61_s->obj;
*TypTest__63_s->x = node; *TypTest__61_s->x = node;
} }
} else { } else {
OPB_err(85); OPB_err(85);
} }
} else if (t0 != t1) { } else if (t0 != t1) {
OPB_err(85); OPB_err(85);
} else if (!*TypTest__63_s->guard) { } else if (!*TypTest__61_s->guard) {
if ((*TypTest__63_s->x)->class == 5) { if ((*TypTest__61_s->x)->class == 5) {
node = OPT_NewNode(11); node = OPT_NewNode(11);
node->subcl = 16; node->subcl = 16;
node->left = *TypTest__63_s->x; node->left = *TypTest__61_s->x;
node->obj = *TypTest__63_s->obj; node->obj = *TypTest__61_s->obj;
*TypTest__63_s->x = node; *TypTest__61_s->x = node;
} else { } else {
*TypTest__63_s->x = OPB_NewBoolConst(1); *TypTest__61_s->x = OPB_NewBoolConst(1);
} }
} }
} }
void OPB_TypTest (OPT_Node *x, OPT_Object obj, BOOLEAN guard) void OPB_TypTest (OPT_Node *x, OPT_Object obj, BOOLEAN guard)
{ {
struct TypTest__63 _s; struct TypTest__61 _s;
_s.x = x; _s.x = x;
_s.obj = &obj; _s.obj = &obj;
_s.guard = &guard; _s.guard = &guard;
_s.lnk = TypTest__63_s; _s.lnk = TypTest__61_s;
TypTest__63_s = &_s; TypTest__61_s = &_s;
if (OPB_NotVar(*x)) { if (OPB_NotVar(*x)) {
OPB_err(112); OPB_err(112);
} else if ((*x)->typ->form == 13) { } else if ((*x)->typ->form == 13) {
if (((*x)->typ->BaseTyp->comp != 4 && (*x)->typ != OPT_sysptrtyp)) { if (((*x)->typ->BaseTyp->comp != 4 && (*x)->typ != OPT_sysptrtyp)) {
OPB_err(85); OPB_err(85);
} else if (obj->typ->form == 13) { } else if (obj->typ->form == 13) {
GTT__64((*x)->typ->BaseTyp, obj->typ->BaseTyp); GTT__62((*x)->typ->BaseTyp, obj->typ->BaseTyp);
} else { } else {
OPB_err(86); OPB_err(86);
} }
} else if (((((*x)->typ->comp == 4 && (*x)->class == 1)) && obj->typ->comp == 4)) { } else if (((((*x)->typ->comp == 4 && (*x)->class == 1)) && obj->typ->comp == 4)) {
GTT__64((*x)->typ, obj->typ); GTT__62((*x)->typ, obj->typ);
} else { } else {
OPB_err(87); OPB_err(87);
} }
@ -527,7 +508,7 @@ void OPB_TypTest (OPT_Node *x, OPT_Object obj, BOOLEAN guard)
} else { } else {
(*x)->typ = OPT_booltyp; (*x)->typ = OPT_booltyp;
} }
TypTest__63_s = _s.lnk; TypTest__61_s = _s.lnk;
} }
void OPB_In (OPT_Node *x, OPT_Node y) void OPB_In (OPT_Node *x, OPT_Node y)
@ -1850,7 +1831,7 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno)
x->typ = OPT_chartyp; x->typ = OPT_chartyp;
break; break;
case 4: case 5: case 6: case 4: case 5: case 6:
x = OPB_NewIntConst(OPB_SignedMinimum(x->typ->size)); x = OPB_NewIntConst(OPM_SignedMinimum(x->typ->size));
break; break;
case 9: case 9:
x = OPB_NewIntConst(((LONGINT)(0))); x = OPB_NewIntConst(((LONGINT)(0)));
@ -1881,7 +1862,7 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno)
x->typ = OPT_chartyp; x->typ = OPT_chartyp;
break; break;
case 4: case 5: case 6: case 4: case 5: case 6:
x = OPB_NewIntConst(OPB_SignedMaximum(x->typ->size)); x = OPB_NewIntConst(OPM_SignedMaximum(x->typ->size));
break; break;
case 9: case 9:
x = OPB_NewIntConst(OPM_MaxSet); x = OPB_NewIntConst(OPM_MaxSet);
@ -2063,13 +2044,13 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno)
*par0 = x; *par0 = x;
} }
static struct StPar1__58 { static struct StPar1__56 {
struct StPar1__58 *lnk; struct StPar1__56 *lnk;
} *StPar1__58_s; } *StPar1__56_s;
static OPT_Node NewOp__59 (SHORTINT class, SHORTINT subcl, OPT_Node left, OPT_Node right); static OPT_Node NewOp__57 (SHORTINT class, SHORTINT subcl, OPT_Node left, OPT_Node right);
static OPT_Node NewOp__59 (SHORTINT class, SHORTINT subcl, OPT_Node left, OPT_Node right) static OPT_Node NewOp__57 (SHORTINT class, SHORTINT subcl, OPT_Node left, OPT_Node right)
{ {
OPT_Node _o_result; OPT_Node _o_result;
OPT_Node node = NIL; OPT_Node node = NIL;
@ -2086,9 +2067,9 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
INTEGER f, L; INTEGER f, L;
OPT_Struct typ = NIL; OPT_Struct typ = NIL;
OPT_Node p = NIL, t = NIL; OPT_Node p = NIL, t = NIL;
struct StPar1__58 _s; struct StPar1__56 _s;
_s.lnk = StPar1__58_s; _s.lnk = StPar1__56_s;
StPar1__58_s = &_s; StPar1__56_s = &_s;
p = *par0; p = *par0;
f = x->typ->form; f = x->typ->form;
switch (fctno) { switch (fctno) {
@ -2104,7 +2085,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
OPB_err(111); OPB_err(111);
} }
} }
p = NewOp__59(19, fctno, p, x); p = NewOp__57(19, fctno, p, x);
p->typ = OPT_notyp; p->typ = OPT_notyp;
} }
break; break;
@ -2115,7 +2096,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
if ((x->class == 7 && (0 > x->conval->intval || x->conval->intval > (LONGINT)OPM_MaxSet))) { if ((x->class == 7 && (0 > x->conval->intval || x->conval->intval > (LONGINT)OPM_MaxSet))) {
OPB_err(202); OPB_err(202);
} }
p = NewOp__59(19, fctno, p, x); p = NewOp__57(19, fctno, p, x);
} else { } else {
OPB_err(111); OPB_err(111);
} }
@ -2140,7 +2121,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
p = p->left; p = p->left;
x->conval->intval += 1; x->conval->intval += 1;
} }
p = NewOp__59(12, 19, p, x); p = NewOp__57(12, 19, p, x);
p->typ = OPT_linttyp; p->typ = OPT_linttyp;
} else { } else {
p = x; p = x;
@ -2162,7 +2143,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
t = x; t = x;
x = p; x = p;
p = t; p = t;
p = NewOp__59(19, 18, p, x); p = NewOp__57(19, 18, p, x);
} else { } else {
OPB_err(111); OPB_err(111);
} }
@ -2188,7 +2169,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
} }
p->obj = NIL; p->obj = NIL;
} else { } else {
p = NewOp__59(12, 17, p, x); p = NewOp__57(12, 17, p, x);
p->typ = OPT_linttyp; p->typ = OPT_linttyp;
} }
} else { } else {
@ -2219,9 +2200,9 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
OPB_err(111); OPB_err(111);
} else { } else {
if (fctno == 22) { if (fctno == 22) {
p = NewOp__59(12, 27, p, x); p = NewOp__57(12, 27, p, x);
} else { } else {
p = NewOp__59(12, 28, p, x); p = NewOp__57(12, 28, p, x);
} }
p->typ = p->left->typ; p->typ = p->left->typ;
} }
@ -2238,7 +2219,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
x = p; x = p;
p = t; p = t;
} }
p = NewOp__59(19, fctno, p, x); p = NewOp__57(19, fctno, p, x);
} else { } else {
OPB_err(111); OPB_err(111);
} }
@ -2248,7 +2229,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
if (x->class == 8 || x->class == 9) { if (x->class == 8 || x->class == 9) {
OPB_err(126); OPB_err(126);
} else if (__IN(f, 0x70)) { } else if (__IN(f, 0x70)) {
p = NewOp__59(12, 26, p, x); p = NewOp__57(12, 26, p, x);
} else { } else {
OPB_err(111); OPB_err(111);
} }
@ -2272,7 +2253,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
if (x->class == 8 || x->class == 9) { if (x->class == 8 || x->class == 9) {
OPB_err(126); OPB_err(126);
} else if (__IN(f, 0x70)) { } else if (__IN(f, 0x70)) {
p = NewOp__59(19, 30, p, x); p = NewOp__57(19, 30, p, x);
} else { } else {
OPB_err(111); OPB_err(111);
} }
@ -2318,7 +2299,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
break; break;
} }
*par0 = p; *par0 = p;
StPar1__58_s = _s.lnk; StPar1__56_s = _s.lnk;
} }
void OPB_StParN (OPT_Node *par0, OPT_Node x, INTEGER fctno, INTEGER n) void OPB_StParN (OPT_Node *par0, OPT_Node x, INTEGER fctno, INTEGER n)

View file

@ -17,7 +17,7 @@ static CHAR OPC_BodyNameExt[13];
export void OPC_Align (LONGINT *adr, LONGINT base); export void OPC_Align (LONGINT *adr, LONGINT base);
export void OPC_Andent (OPT_Struct typ); export void OPC_Andent (OPT_Struct typ);
static void OPC_AnsiParamList (OPT_Object obj, BOOLEAN showParamNames); static void OPC_AnsiParamList (OPT_Object obj, BOOLEAN showParamNames);
export LONGINT OPC_Base (OPT_Struct typ); export LONGINT OPC_BaseAlignment (OPT_Struct typ);
export OPT_Object OPC_BaseTProc (OPT_Object obj); export OPT_Object OPC_BaseTProc (OPT_Object obj);
export void OPC_BegBlk (void); export void OPC_BegBlk (void);
export void OPC_BegStat (void); export void OPC_BegStat (void);
@ -75,6 +75,7 @@ static void OPC_PutBase (OPT_Struct typ);
static void OPC_PutPtrOffsets (OPT_Struct typ, LONGINT adr, LONGINT *cnt); static void OPC_PutPtrOffsets (OPT_Struct typ, LONGINT adr, LONGINT *cnt);
static void OPC_RegCmds (OPT_Object obj); static void OPC_RegCmds (OPT_Object obj);
export void OPC_SetInclude (BOOLEAN exclude); export void OPC_SetInclude (BOOLEAN exclude);
export LONGINT OPC_SizeAlignment (LONGINT size);
static void OPC_Stars (OPT_Struct typ, BOOLEAN *openClause); static void OPC_Stars (OPT_Struct typ, BOOLEAN *openClause);
static void OPC_Str1 (CHAR *s, LONGINT s__len, LONGINT x); static void OPC_Str1 (CHAR *s, LONGINT s__len, LONGINT x);
static void OPC_StringLiteral (CHAR *s, LONGINT s__len, LONGINT l); static void OPC_StringLiteral (CHAR *s, LONGINT s__len, LONGINT l);
@ -868,70 +869,37 @@ void OPC_Align (LONGINT *adr, LONGINT base)
} }
} }
LONGINT OPC_Base (OPT_Struct typ) LONGINT OPC_SizeAlignment (LONGINT size)
{ {
LONGINT _o_result; LONGINT _o_result;
switch (typ->form) { LONGINT alignment;
case 1: if (size < (LONGINT)OPM_Alignment) {
_o_result = 1; alignment = 1;
return _o_result; while (alignment < size) {
break; alignment = __ASHL(alignment, 1);
case 3: }
_o_result = OPM_CharAlign; } else {
return _o_result; alignment = OPM_Alignment;
break;
case 2:
_o_result = OPM_BoolAlign;
return _o_result;
break;
case 4:
_o_result = OPM_SIntAlign;
return _o_result;
break;
case 5:
_o_result = OPM_IntAlign;
return _o_result;
break;
case 6:
_o_result = OPM_LIntAlign;
return _o_result;
break;
case 7:
_o_result = OPM_RealAlign;
return _o_result;
break;
case 8:
_o_result = OPM_LRealAlign;
return _o_result;
break;
case 9:
_o_result = OPM_SetAlign;
return _o_result;
break;
case 13:
_o_result = OPM_PointerAlign;
return _o_result;
break;
case 14:
_o_result = OPM_ProcAlign;
return _o_result;
break;
case 15:
if (typ->comp == 4) {
_o_result = __MASK(typ->align, -65536);
return _o_result;
} else {
_o_result = OPC_Base(typ->BaseTyp);
return _o_result;
}
break;
default:
OPM_LogWStr((CHAR*)"unhandled case in OPC.Base, typ^form = ", (LONGINT)40);
OPM_LogWNum(typ->form, ((LONGINT)(0)));
OPM_LogWLn();
break;
} }
__RETCHK; _o_result = alignment;
return _o_result;
}
LONGINT OPC_BaseAlignment (OPT_Struct typ)
{
LONGINT _o_result;
LONGINT alignment;
if (typ->form == 15) {
if (typ->comp == 4) {
alignment = __MASK(typ->align, -65536);
} else {
alignment = OPC_BaseAlignment(typ->BaseTyp);
}
} else {
alignment = OPC_SizeAlignment(typ->size);
}
_o_result = alignment;
return _o_result;
} }
static void OPC_FillGap (LONGINT gap, LONGINT off, LONGINT align, LONGINT *n, LONGINT *curAlign) static void OPC_FillGap (LONGINT gap, LONGINT off, LONGINT align, LONGINT *n, LONGINT *curAlign)
@ -985,7 +953,7 @@ static void OPC_FieldList (OPT_Struct typ, BOOLEAN last, LONGINT *off, LONGINT *
} }
} else { } else {
adr = *off; adr = *off;
fldAlign = OPC_Base(fld->typ); fldAlign = OPC_BaseAlignment(fld->typ);
OPC_Align(&adr, fldAlign); OPC_Align(&adr, fldAlign);
gap = fld->adr - adr; gap = fld->adr - adr;
if (fldAlign > *curAlign) { if (fldAlign > *curAlign) {

View file

@ -12,7 +12,7 @@
import void OPC_Align (LONGINT *adr, LONGINT base); import void OPC_Align (LONGINT *adr, LONGINT base);
import void OPC_Andent (OPT_Struct typ); import void OPC_Andent (OPT_Struct typ);
import LONGINT OPC_Base (OPT_Struct typ); import LONGINT OPC_BaseAlignment (OPT_Struct typ);
import OPT_Object OPC_BaseTProc (OPT_Object obj); import OPT_Object OPC_BaseTProc (OPT_Object obj);
import void OPC_BegBlk (void); import void OPC_BegBlk (void);
import void OPC_BegStat (void); import void OPC_BegStat (void);
@ -41,6 +41,7 @@ import void OPC_InitTDesc (OPT_Struct typ);
import void OPC_Len (OPT_Object obj, OPT_Struct array, LONGINT dim); import void OPC_Len (OPT_Object obj, OPT_Struct array, LONGINT dim);
import LONGINT OPC_NofPtrs (OPT_Struct typ); import LONGINT OPC_NofPtrs (OPT_Struct typ);
import void OPC_SetInclude (BOOLEAN exclude); import void OPC_SetInclude (BOOLEAN exclude);
import LONGINT OPC_SizeAlignment (LONGINT size);
import void OPC_TDescDecl (OPT_Struct typ); import void OPC_TDescDecl (OPT_Struct typ);
import void OPC_TypeDefs (OPT_Object obj, INTEGER vis); import void OPC_TypeDefs (OPT_Object obj, INTEGER vis);
import void OPC_TypeOf (OPT_Object ap); import void OPC_TypeOf (OPT_Object ap);

View file

@ -15,8 +15,8 @@ typedef
static CHAR OPM_SourceFileName[256]; static CHAR OPM_SourceFileName[256];
export INTEGER OPM_Alignment, OPM_ByteSize, OPM_CharSize, OPM_BoolSize, OPM_SIntSize, OPM_IntSize, OPM_LIntSize, OPM_SetSize, OPM_RealSize, OPM_LRealSize, OPM_PointerSize, OPM_ProcSize, OPM_RecSize, OPM_CharAlign, OPM_BoolAlign, OPM_SIntAlign, OPM_IntAlign, OPM_LIntAlign, OPM_SetAlign, OPM_RealAlign, OPM_LRealAlign, OPM_PointerAlign, OPM_ProcAlign, OPM_RecAlign, OPM_MaxSet; export INTEGER OPM_Alignment, OPM_ByteSize, OPM_CharSize, OPM_BoolSize, OPM_SIntSize, OPM_IntSize, OPM_LIntSize, OPM_SetSize, OPM_RealSize, OPM_LRealSize, OPM_PointerSize, OPM_ProcSize, OPM_RecSize, OPM_MaxSet;
export LONGINT OPM_MinSInt, OPM_MinInt, OPM_MinLInt, OPM_MaxSInt, OPM_MaxInt, OPM_MaxLInt, OPM_MaxIndex; export LONGINT OPM_MaxIndex;
export LONGREAL OPM_MinReal, OPM_MaxReal, OPM_MinLReal, OPM_MaxLReal; export LONGREAL OPM_MinReal, OPM_MaxReal, OPM_MinLReal, OPM_MaxLReal;
export BOOLEAN OPM_noerr; export BOOLEAN OPM_noerr;
export LONGINT OPM_curpos, OPM_errpos, OPM_breakpc; export LONGINT OPM_curpos, OPM_errpos, OPM_breakpc;
@ -37,7 +37,6 @@ static CHAR OPM_OBERON[1024];
static CHAR OPM_MODULES[1024]; static CHAR OPM_MODULES[1024];
export INTEGER OPM_AlignSize (LONGINT size);
static void OPM_Append (Files_Rider *R, LONGINT *R__typ, Files_File F); static void OPM_Append (Files_Rider *R, LONGINT *R__typ, Files_File F);
export void OPM_CloseFiles (void); export void OPM_CloseFiles (void);
export void OPM_CloseOldSym (void); export void OPM_CloseOldSym (void);
@ -66,6 +65,8 @@ export BOOLEAN OPM_OpenPar (void);
export void OPM_RegisterNewSym (void); export void OPM_RegisterNewSym (void);
static void OPM_ScanOptions (CHAR *s, LONGINT s__len, SET *opt); static void OPM_ScanOptions (CHAR *s, LONGINT s__len, SET *opt);
static void OPM_ShowLine (LONGINT pos); static void OPM_ShowLine (LONGINT pos);
export LONGINT OPM_SignedMaximum (LONGINT bytecount);
export LONGINT OPM_SignedMinimum (LONGINT bytecount);
export void OPM_SymRCh (CHAR *ch); export void OPM_SymRCh (CHAR *ch);
export LONGINT OPM_SymRInt (void); export LONGINT OPM_SymRInt (void);
export void OPM_SymRLReal (LONGREAL *lr); export void OPM_SymRLReal (LONGREAL *lr);
@ -606,111 +607,62 @@ static void OPM_VerboseListSizes (void)
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"CHAR ", (LONGINT)14); OPM_LogWStr((CHAR*)"CHAR ", (LONGINT)14);
OPM_LogWNum(OPM_CharSize, ((LONGINT)(4))); OPM_LogWNum(OPM_CharSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_CharAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"BOOLEAN ", (LONGINT)14); OPM_LogWStr((CHAR*)"BOOLEAN ", (LONGINT)14);
OPM_LogWNum(OPM_BoolSize, ((LONGINT)(4))); OPM_LogWNum(OPM_BoolSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_BoolAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"SHORTINT ", (LONGINT)14); OPM_LogWStr((CHAR*)"SHORTINT ", (LONGINT)14);
OPM_LogWNum(OPM_SIntSize, ((LONGINT)(4))); OPM_LogWNum(OPM_SIntSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_SIntAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"INTEGER ", (LONGINT)14); OPM_LogWStr((CHAR*)"INTEGER ", (LONGINT)14);
OPM_LogWNum(OPM_IntSize, ((LONGINT)(4))); OPM_LogWNum(OPM_IntSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_IntAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"LONGINT ", (LONGINT)14); OPM_LogWStr((CHAR*)"LONGINT ", (LONGINT)14);
OPM_LogWNum(OPM_LIntSize, ((LONGINT)(4))); OPM_LogWNum(OPM_LIntSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_LIntAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"SET ", (LONGINT)14); OPM_LogWStr((CHAR*)"SET ", (LONGINT)14);
OPM_LogWNum(OPM_SetSize, ((LONGINT)(4))); OPM_LogWNum(OPM_SetSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_SetAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"REAL ", (LONGINT)14); OPM_LogWStr((CHAR*)"REAL ", (LONGINT)14);
OPM_LogWNum(OPM_RealSize, ((LONGINT)(4))); OPM_LogWNum(OPM_RealSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_RealAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"LONGREAL ", (LONGINT)14); OPM_LogWStr((CHAR*)"LONGREAL ", (LONGINT)14);
OPM_LogWNum(OPM_LRealSize, ((LONGINT)(4))); OPM_LogWNum(OPM_LRealSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_LRealAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"PTR ", (LONGINT)14); OPM_LogWStr((CHAR*)"PTR ", (LONGINT)14);
OPM_LogWNum(OPM_PointerSize, ((LONGINT)(4))); OPM_LogWNum(OPM_PointerSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_PointerAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"PROC ", (LONGINT)14); OPM_LogWStr((CHAR*)"PROC ", (LONGINT)14);
OPM_LogWNum(OPM_ProcSize, ((LONGINT)(4))); OPM_LogWNum(OPM_ProcSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_ProcAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"RECORD ", (LONGINT)14); OPM_LogWStr((CHAR*)"RECORD ", (LONGINT)14);
OPM_LogWNum(OPM_RecSize, ((LONGINT)(4))); OPM_LogWNum(OPM_RecSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_RecAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"Min shortint ", (LONGINT)14);
OPM_LogWNum(OPM_MinSInt, ((LONGINT)(4)));
OPM_LogWLn();
OPM_LogWStr((CHAR*)"Max shortint ", (LONGINT)14);
OPM_LogWNum(OPM_MaxSInt, ((LONGINT)(4)));
OPM_LogWLn();
OPM_LogWStr((CHAR*)"Min integer ", (LONGINT)14);
OPM_LogWNum(OPM_MinInt, ((LONGINT)(4)));
OPM_LogWLn();
OPM_LogWStr((CHAR*)"Max integer ", (LONGINT)14);
OPM_LogWNum(OPM_MaxInt, ((LONGINT)(4)));
OPM_LogWLn();
OPM_LogWStr((CHAR*)"Min longint ", (LONGINT)14);
OPM_LogWNum(OPM_MinLInt, ((LONGINT)(4)));
OPM_LogWLn();
} }
INTEGER OPM_AlignSize (LONGINT size) LONGINT OPM_SignedMaximum (LONGINT bytecount)
{ {
INTEGER _o_result; LONGINT _o_result;
INTEGER align; LONGINT result;
if (size < (LONGINT)OPM_Alignment) { result = 1;
if (size > 8) { result = __LSH(result, __ASHL(bytecount, 3) - 1, LONGINT);
align = 16; _o_result = result - 1;
} else if (size > 4) { return _o_result;
align = 8; }
} else if (size > 2) {
align = 4; LONGINT OPM_SignedMinimum (LONGINT bytecount)
} else { {
align = (int)size; LONGINT _o_result;
} _o_result = -OPM_SignedMaximum(bytecount) - 1;
} else {
align = OPM_Alignment;
}
_o_result = align;
return _o_result; return _o_result;
} }
static void OPM_GetProperties (void) static void OPM_GetProperties (void)
{ {
LONGINT base;
OPM_ProcSize = OPM_PointerSize; OPM_ProcSize = OPM_PointerSize;
OPM_LIntSize = __ASHL(OPM_IntSize, 1); OPM_LIntSize = __ASHL(OPM_IntSize, 1);
OPM_SetSize = OPM_LIntSize; OPM_SetSize = OPM_LIntSize;
OPM_CharAlign = OPM_AlignSize(OPM_CharSize);
OPM_BoolAlign = OPM_AlignSize(OPM_BoolSize);
OPM_SIntAlign = OPM_AlignSize(OPM_SIntSize);
OPM_RecAlign = OPM_AlignSize(OPM_RecSize);
OPM_RealAlign = OPM_AlignSize(OPM_RealSize);
OPM_LRealAlign = OPM_AlignSize(OPM_LRealSize);
OPM_PointerAlign = OPM_AlignSize(OPM_PointerSize);
OPM_ProcAlign = OPM_AlignSize(OPM_ProcSize);
OPM_IntAlign = OPM_AlignSize(OPM_IntSize);
OPM_LIntAlign = OPM_AlignSize(OPM_LIntSize);
OPM_SetAlign = OPM_AlignSize(OPM_SetSize);
base = -2;
OPM_MinSInt = __ASH(base, __ASHL(OPM_SIntSize, 3) - 2);
OPM_MaxSInt = OPM_minusop(OPM_MinSInt + 1);
OPM_MinInt = __ASH(base, __ASHL(OPM_IntSize, 3) - 2);
OPM_MaxInt = OPM_minusop(OPM_MinInt + 1);
OPM_MinLInt = __ASH(base, __ASHL(OPM_LIntSize, 3) - 2);
OPM_MaxLInt = OPM_minusop(OPM_MinLInt + 1);
if (OPM_RealSize == 4) { if (OPM_RealSize == 4) {
OPM_MaxReal = 3.40282346000000e+038; OPM_MaxReal = 3.40282346000000e+038;
} else if (OPM_RealSize == 8) { } else if (OPM_RealSize == 8) {
@ -724,7 +676,7 @@ static void OPM_GetProperties (void)
OPM_MinReal = -OPM_MaxReal; OPM_MinReal = -OPM_MaxReal;
OPM_MinLReal = -OPM_MaxLReal; OPM_MinLReal = -OPM_MaxLReal;
OPM_MaxSet = __ASHL(OPM_SetSize, 3) - 1; OPM_MaxSet = __ASHL(OPM_SetSize, 3) - 1;
OPM_MaxIndex = OPM_MaxLInt; OPM_MaxIndex = OPM_SignedMaximum(OPM_PointerSize);
if (OPM_Verbose) { if (OPM_Verbose) {
OPM_VerboseListSizes(); OPM_VerboseListSizes();
} }
@ -886,7 +838,7 @@ void OPM_WriteInt (LONGINT i)
{ {
CHAR s[20]; CHAR s[20];
LONGINT i1, k; LONGINT i1, k;
if (i == OPM_MinInt || i == OPM_MinLInt) { if (i == OPM_SignedMinimum(OPM_IntSize) || i == OPM_SignedMinimum(OPM_LIntSize)) {
OPM_Write('('); OPM_Write('(');
OPM_WriteInt(i + 1); OPM_WriteInt(i + 1);
OPM_WriteString((CHAR*)"-1)", (LONGINT)4); OPM_WriteString((CHAR*)"-1)", (LONGINT)4);
@ -919,7 +871,7 @@ void OPM_WriteReal (LONGREAL r, CHAR suffx)
CHAR s[32]; CHAR s[32];
CHAR ch; CHAR ch;
INTEGER i; INTEGER i;
if ((((r < OPM_MaxLInt && r > OPM_MinLInt)) && r == (__ENTIER(r)))) { if ((((r < OPM_SignedMaximum(OPM_LIntSize) && r > OPM_SignedMinimum(OPM_LIntSize))) && r == (__ENTIER(r)))) {
if (suffx == 'f') { if (suffx == 'f') {
OPM_WriteString((CHAR*)"(REAL)", (LONGINT)7); OPM_WriteString((CHAR*)"(REAL)", (LONGINT)7);
} else { } else {

View file

@ -7,8 +7,8 @@
#include "SYSTEM.h" #include "SYSTEM.h"
import INTEGER OPM_Alignment, OPM_ByteSize, OPM_CharSize, OPM_BoolSize, OPM_SIntSize, OPM_IntSize, OPM_LIntSize, OPM_SetSize, OPM_RealSize, OPM_LRealSize, OPM_PointerSize, OPM_ProcSize, OPM_RecSize, OPM_CharAlign, OPM_BoolAlign, OPM_SIntAlign, OPM_IntAlign, OPM_LIntAlign, OPM_SetAlign, OPM_RealAlign, OPM_LRealAlign, OPM_PointerAlign, OPM_ProcAlign, OPM_RecAlign, OPM_MaxSet; import INTEGER OPM_Alignment, OPM_ByteSize, OPM_CharSize, OPM_BoolSize, OPM_SIntSize, OPM_IntSize, OPM_LIntSize, OPM_SetSize, OPM_RealSize, OPM_LRealSize, OPM_PointerSize, OPM_ProcSize, OPM_RecSize, OPM_MaxSet;
import LONGINT OPM_MinSInt, OPM_MinInt, OPM_MinLInt, OPM_MaxSInt, OPM_MaxInt, OPM_MaxLInt, OPM_MaxIndex; import LONGINT OPM_MaxIndex;
import LONGREAL OPM_MinReal, OPM_MaxReal, OPM_MinLReal, OPM_MaxLReal; import LONGREAL OPM_MinReal, OPM_MaxReal, OPM_MinLReal, OPM_MaxLReal;
import BOOLEAN OPM_noerr; import BOOLEAN OPM_noerr;
import LONGINT OPM_curpos, OPM_errpos, OPM_breakpc; import LONGINT OPM_curpos, OPM_errpos, OPM_breakpc;
@ -19,7 +19,6 @@ import SET OPM_opt, OPM_glbopt;
import BOOLEAN OPM_dontAsm, OPM_dontLink, OPM_mainProg, OPM_mainLinkStat, OPM_notColorOutput, OPM_forceNewSym, OPM_Verbose; import BOOLEAN OPM_dontAsm, OPM_dontLink, OPM_mainProg, OPM_mainLinkStat, OPM_notColorOutput, OPM_forceNewSym, OPM_Verbose;
import INTEGER OPM_AlignSize (LONGINT size);
import void OPM_CloseFiles (void); import void OPM_CloseFiles (void);
import void OPM_CloseOldSym (void); import void OPM_CloseOldSym (void);
import void OPM_DeleteNewSym (void); import void OPM_DeleteNewSym (void);
@ -40,6 +39,8 @@ import void OPM_OldSym (CHAR *modName, LONGINT modName__len, BOOLEAN *done);
import void OPM_OpenFiles (CHAR *moduleName, LONGINT moduleName__len); import void OPM_OpenFiles (CHAR *moduleName, LONGINT moduleName__len);
import BOOLEAN OPM_OpenPar (void); import BOOLEAN OPM_OpenPar (void);
import void OPM_RegisterNewSym (void); import void OPM_RegisterNewSym (void);
import LONGINT OPM_SignedMaximum (LONGINT bytecount);
import LONGINT OPM_SignedMinimum (LONGINT bytecount);
import void OPM_SymRCh (CHAR *ch); import void OPM_SymRCh (CHAR *ch);
import LONGINT OPM_SymRInt (void); import LONGINT OPM_SymRInt (void);
import void OPM_SymRLReal (LONGREAL *lr); import void OPM_SymRLReal (LONGREAL *lr);

View file

@ -83,7 +83,7 @@ void OPV_TypSize (OPT_Struct typ)
btyp = typ->BaseTyp; btyp = typ->BaseTyp;
if (btyp == NIL) { if (btyp == NIL) {
offset = 0; offset = 0;
base = OPM_RecAlign; base = OPC_SizeAlignment(OPM_RecSize);
} else { } else {
OPV_TypSize(btyp); OPV_TypSize(btyp);
offset = btyp->size - (LONGINT)__ASHR(btyp->sysflag, 8); offset = btyp->size - (LONGINT)__ASHR(btyp->sysflag, 8);
@ -94,7 +94,7 @@ void OPV_TypSize (OPT_Struct typ)
btyp = fld->typ; btyp = fld->typ;
OPV_TypSize(btyp); OPV_TypSize(btyp);
size = btyp->size; size = btyp->size;
fbase = OPC_Base(btyp); fbase = OPC_BaseAlignment(btyp);
OPC_Align(&offset, fbase); OPC_Align(&offset, fbase);
fld->adr = offset; fld->adr = offset;
offset += size; offset += size;
@ -108,7 +108,7 @@ void OPV_TypSize (OPT_Struct typ)
offset = 1; offset = 1;
} }
if (OPM_RecSize == 0) { if (OPM_RecSize == 0) {
base = OPV_NaturalAlignment(offset, OPM_RecAlign); base = OPV_NaturalAlignment(offset, OPC_SizeAlignment(OPM_RecSize));
} }
OPC_Align(&offset, base); OPC_Align(&offset, base);
if ((typ->strobj == NIL && __MASK(typ->align, -65536) == 0)) { if ((typ->strobj == NIL && __MASK(typ->align, -65536) == 0)) {
@ -492,7 +492,7 @@ static void OPV_Convert (OPT_Node n, INTEGER form, INTEGER prec)
OPM_Write('('); OPM_Write('(');
OPV_Entier(n, -1); OPV_Entier(n, -1);
OPM_WriteString((CHAR*)", ", (LONGINT)3); OPM_WriteString((CHAR*)", ", (LONGINT)3);
OPM_WriteInt(OPM_MaxInt + 1); OPM_WriteInt(OPM_SignedMaximum(OPM_IntSize) + 1);
OPM_Write(')'); OPM_Write(')');
} else { } else {
OPM_WriteString((CHAR*)"(int)", (LONGINT)6); OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
@ -508,7 +508,7 @@ static void OPV_Convert (OPT_Node n, INTEGER form, INTEGER prec)
OPM_Write('('); OPM_Write('(');
OPV_Entier(n, -1); OPV_Entier(n, -1);
OPM_WriteString((CHAR*)", ", (LONGINT)3); OPM_WriteString((CHAR*)", ", (LONGINT)3);
OPM_WriteInt(OPM_MaxSInt + 1); OPM_WriteInt(OPM_SignedMaximum(OPM_SIntSize) + 1);
OPM_Write(')'); OPM_Write(')');
} else { } else {
OPM_WriteString((CHAR*)"(int)", (LONGINT)6); OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
@ -796,7 +796,7 @@ static void OPV_ActualPar (OPT_Node n, OPT_Object fp)
} }
if ((((mode == 2 && n->class == 11)) && n->subcl == 29)) { if ((((mode == 2 && n->class == 11)) && n->subcl == 29)) {
OPV_expr(n->left, prec); OPV_expr(n->left, prec);
} else if ((((((form == 6 && n->class == 7)) && n->conval->intval <= OPM_MaxInt)) && n->conval->intval >= OPM_MinInt)) { } else if ((((((form == 6 && n->class == 7)) && n->conval->intval <= OPM_SignedMaximum(OPM_IntSize))) && n->conval->intval >= OPM_SignedMinimum(OPM_IntSize))) {
OPM_WriteString((CHAR*)"((LONGINT)(", (LONGINT)12); OPM_WriteString((CHAR*)"((LONGINT)(", (LONGINT)12);
OPV_expr(n, prec); OPV_expr(n, prec);
OPM_WriteString((CHAR*)"))", (LONGINT)3); OPM_WriteString((CHAR*)"))", (LONGINT)3);
@ -1323,7 +1323,7 @@ static void OPV_NewArr (OPT_Node d, OPT_Node x)
OPM_WriteInt(base->size); OPM_WriteInt(base->size);
OPM_WriteString((CHAR*)"))", (LONGINT)3); OPM_WriteString((CHAR*)"))", (LONGINT)3);
OPM_WriteString((CHAR*)", ", (LONGINT)3); OPM_WriteString((CHAR*)", ", (LONGINT)3);
OPM_WriteInt(OPC_Base(base)); OPM_WriteInt(OPC_BaseAlignment(base));
OPM_WriteString((CHAR*)", ", (LONGINT)3); OPM_WriteString((CHAR*)", ", (LONGINT)3);
OPM_WriteInt(nofdim); OPM_WriteInt(nofdim);
OPM_WriteString((CHAR*)", ", (LONGINT)3); OPM_WriteString((CHAR*)", ", (LONGINT)3);

View file

@ -55,8 +55,6 @@ static void OPB_SetIntType (OPT_Node node);
export void OPB_SetRange (OPT_Node *x, OPT_Node y); export void OPB_SetRange (OPT_Node *x, OPT_Node y);
static LONGINT OPB_ShorterSize (LONGINT i); static LONGINT OPB_ShorterSize (LONGINT i);
static INTEGER OPB_SignedByteSize (LONGINT n); static INTEGER OPB_SignedByteSize (LONGINT n);
static LONGINT OPB_SignedMaximum (LONGINT bytecount);
static LONGINT OPB_SignedMinimum (LONGINT bytecount);
export void OPB_StFct (OPT_Node *par0, SHORTINT fctno, INTEGER parno); export void OPB_StFct (OPT_Node *par0, SHORTINT fctno, INTEGER parno);
export void OPB_StPar0 (OPT_Node *par0, INTEGER fctno); export void OPB_StPar0 (OPT_Node *par0, INTEGER fctno);
export void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno); export void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno);
@ -226,23 +224,6 @@ OPT_Node OPB_EmptySet (void)
return _o_result; return _o_result;
} }
static LONGINT OPB_SignedMaximum (LONGINT bytecount)
{
LONGINT _o_result;
LONGINT result;
result = 1;
result = __LSH(result, __ASHL(bytecount, 3) - 1, LONGINT);
_o_result = result - 1;
return _o_result;
}
static LONGINT OPB_SignedMinimum (LONGINT bytecount)
{
LONGINT _o_result;
_o_result = -OPB_SignedMaximum(bytecount) - 1;
return _o_result;
}
static INTEGER OPB_SignedByteSize (LONGINT n) static INTEGER OPB_SignedByteSize (LONGINT n)
{ {
INTEGER _o_result; INTEGER _o_result;
@ -448,16 +429,16 @@ void OPB_Field (OPT_Node *x, OPT_Object y)
} }
} }
static struct TypTest__63 { static struct TypTest__61 {
OPT_Node *x; OPT_Node *x;
OPT_Object *obj; OPT_Object *obj;
BOOLEAN *guard; BOOLEAN *guard;
struct TypTest__63 *lnk; struct TypTest__61 *lnk;
} *TypTest__63_s; } *TypTest__61_s;
static void GTT__64 (OPT_Struct t0, OPT_Struct t1); static void GTT__62 (OPT_Struct t0, OPT_Struct t1);
static void GTT__64 (OPT_Struct t0, OPT_Struct t1) static void GTT__62 (OPT_Struct t0, OPT_Struct t1)
{ {
OPT_Node node = NIL; OPT_Node node = NIL;
OPT_Struct t = NIL; OPT_Struct t = NIL;
@ -470,54 +451,54 @@ static void GTT__64 (OPT_Struct t0, OPT_Struct t1)
t1 = t1->BaseTyp; t1 = t1->BaseTyp;
} }
if (t1 == t0 || t0->form == 0) { if (t1 == t0 || t0->form == 0) {
if (*TypTest__63_s->guard) { if (*TypTest__61_s->guard) {
OPB_BindNodes(5, NIL, &*TypTest__63_s->x, NIL); OPB_BindNodes(5, NIL, &*TypTest__61_s->x, NIL);
(*TypTest__63_s->x)->readonly = (*TypTest__63_s->x)->left->readonly; (*TypTest__61_s->x)->readonly = (*TypTest__61_s->x)->left->readonly;
} else { } else {
node = OPT_NewNode(11); node = OPT_NewNode(11);
node->subcl = 16; node->subcl = 16;
node->left = *TypTest__63_s->x; node->left = *TypTest__61_s->x;
node->obj = *TypTest__63_s->obj; node->obj = *TypTest__61_s->obj;
*TypTest__63_s->x = node; *TypTest__61_s->x = node;
} }
} else { } else {
OPB_err(85); OPB_err(85);
} }
} else if (t0 != t1) { } else if (t0 != t1) {
OPB_err(85); OPB_err(85);
} else if (!*TypTest__63_s->guard) { } else if (!*TypTest__61_s->guard) {
if ((*TypTest__63_s->x)->class == 5) { if ((*TypTest__61_s->x)->class == 5) {
node = OPT_NewNode(11); node = OPT_NewNode(11);
node->subcl = 16; node->subcl = 16;
node->left = *TypTest__63_s->x; node->left = *TypTest__61_s->x;
node->obj = *TypTest__63_s->obj; node->obj = *TypTest__61_s->obj;
*TypTest__63_s->x = node; *TypTest__61_s->x = node;
} else { } else {
*TypTest__63_s->x = OPB_NewBoolConst(1); *TypTest__61_s->x = OPB_NewBoolConst(1);
} }
} }
} }
void OPB_TypTest (OPT_Node *x, OPT_Object obj, BOOLEAN guard) void OPB_TypTest (OPT_Node *x, OPT_Object obj, BOOLEAN guard)
{ {
struct TypTest__63 _s; struct TypTest__61 _s;
_s.x = x; _s.x = x;
_s.obj = &obj; _s.obj = &obj;
_s.guard = &guard; _s.guard = &guard;
_s.lnk = TypTest__63_s; _s.lnk = TypTest__61_s;
TypTest__63_s = &_s; TypTest__61_s = &_s;
if (OPB_NotVar(*x)) { if (OPB_NotVar(*x)) {
OPB_err(112); OPB_err(112);
} else if ((*x)->typ->form == 13) { } else if ((*x)->typ->form == 13) {
if (((*x)->typ->BaseTyp->comp != 4 && (*x)->typ != OPT_sysptrtyp)) { if (((*x)->typ->BaseTyp->comp != 4 && (*x)->typ != OPT_sysptrtyp)) {
OPB_err(85); OPB_err(85);
} else if (obj->typ->form == 13) { } else if (obj->typ->form == 13) {
GTT__64((*x)->typ->BaseTyp, obj->typ->BaseTyp); GTT__62((*x)->typ->BaseTyp, obj->typ->BaseTyp);
} else { } else {
OPB_err(86); OPB_err(86);
} }
} else if (((((*x)->typ->comp == 4 && (*x)->class == 1)) && obj->typ->comp == 4)) { } else if (((((*x)->typ->comp == 4 && (*x)->class == 1)) && obj->typ->comp == 4)) {
GTT__64((*x)->typ, obj->typ); GTT__62((*x)->typ, obj->typ);
} else { } else {
OPB_err(87); OPB_err(87);
} }
@ -526,7 +507,7 @@ void OPB_TypTest (OPT_Node *x, OPT_Object obj, BOOLEAN guard)
} else { } else {
(*x)->typ = OPT_booltyp; (*x)->typ = OPT_booltyp;
} }
TypTest__63_s = _s.lnk; TypTest__61_s = _s.lnk;
} }
void OPB_In (OPT_Node *x, OPT_Node y) void OPB_In (OPT_Node *x, OPT_Node y)
@ -1849,7 +1830,7 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno)
x->typ = OPT_chartyp; x->typ = OPT_chartyp;
break; break;
case 4: case 5: case 6: case 4: case 5: case 6:
x = OPB_NewIntConst(OPB_SignedMinimum(x->typ->size)); x = OPB_NewIntConst(OPM_SignedMinimum(x->typ->size));
break; break;
case 9: case 9:
x = OPB_NewIntConst(((LONGINT)(0))); x = OPB_NewIntConst(((LONGINT)(0)));
@ -1880,7 +1861,7 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno)
x->typ = OPT_chartyp; x->typ = OPT_chartyp;
break; break;
case 4: case 5: case 6: case 4: case 5: case 6:
x = OPB_NewIntConst(OPB_SignedMaximum(x->typ->size)); x = OPB_NewIntConst(OPM_SignedMaximum(x->typ->size));
break; break;
case 9: case 9:
x = OPB_NewIntConst(OPM_MaxSet); x = OPB_NewIntConst(OPM_MaxSet);
@ -2062,13 +2043,13 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno)
*par0 = x; *par0 = x;
} }
static struct StPar1__58 { static struct StPar1__56 {
struct StPar1__58 *lnk; struct StPar1__56 *lnk;
} *StPar1__58_s; } *StPar1__56_s;
static OPT_Node NewOp__59 (SHORTINT class, SHORTINT subcl, OPT_Node left, OPT_Node right); static OPT_Node NewOp__57 (SHORTINT class, SHORTINT subcl, OPT_Node left, OPT_Node right);
static OPT_Node NewOp__59 (SHORTINT class, SHORTINT subcl, OPT_Node left, OPT_Node right) static OPT_Node NewOp__57 (SHORTINT class, SHORTINT subcl, OPT_Node left, OPT_Node right)
{ {
OPT_Node _o_result; OPT_Node _o_result;
OPT_Node node = NIL; OPT_Node node = NIL;
@ -2085,9 +2066,9 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
INTEGER f, L; INTEGER f, L;
OPT_Struct typ = NIL; OPT_Struct typ = NIL;
OPT_Node p = NIL, t = NIL; OPT_Node p = NIL, t = NIL;
struct StPar1__58 _s; struct StPar1__56 _s;
_s.lnk = StPar1__58_s; _s.lnk = StPar1__56_s;
StPar1__58_s = &_s; StPar1__56_s = &_s;
p = *par0; p = *par0;
f = x->typ->form; f = x->typ->form;
switch (fctno) { switch (fctno) {
@ -2103,7 +2084,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
OPB_err(111); OPB_err(111);
} }
} }
p = NewOp__59(19, fctno, p, x); p = NewOp__57(19, fctno, p, x);
p->typ = OPT_notyp; p->typ = OPT_notyp;
} }
break; break;
@ -2114,7 +2095,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
if ((x->class == 7 && (0 > x->conval->intval || x->conval->intval > (LONGINT)OPM_MaxSet))) { if ((x->class == 7 && (0 > x->conval->intval || x->conval->intval > (LONGINT)OPM_MaxSet))) {
OPB_err(202); OPB_err(202);
} }
p = NewOp__59(19, fctno, p, x); p = NewOp__57(19, fctno, p, x);
} else { } else {
OPB_err(111); OPB_err(111);
} }
@ -2139,7 +2120,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
p = p->left; p = p->left;
x->conval->intval += 1; x->conval->intval += 1;
} }
p = NewOp__59(12, 19, p, x); p = NewOp__57(12, 19, p, x);
p->typ = OPT_linttyp; p->typ = OPT_linttyp;
} else { } else {
p = x; p = x;
@ -2161,7 +2142,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
t = x; t = x;
x = p; x = p;
p = t; p = t;
p = NewOp__59(19, 18, p, x); p = NewOp__57(19, 18, p, x);
} else { } else {
OPB_err(111); OPB_err(111);
} }
@ -2187,7 +2168,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
} }
p->obj = NIL; p->obj = NIL;
} else { } else {
p = NewOp__59(12, 17, p, x); p = NewOp__57(12, 17, p, x);
p->typ = OPT_linttyp; p->typ = OPT_linttyp;
} }
} else { } else {
@ -2218,9 +2199,9 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
OPB_err(111); OPB_err(111);
} else { } else {
if (fctno == 22) { if (fctno == 22) {
p = NewOp__59(12, 27, p, x); p = NewOp__57(12, 27, p, x);
} else { } else {
p = NewOp__59(12, 28, p, x); p = NewOp__57(12, 28, p, x);
} }
p->typ = p->left->typ; p->typ = p->left->typ;
} }
@ -2237,7 +2218,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
x = p; x = p;
p = t; p = t;
} }
p = NewOp__59(19, fctno, p, x); p = NewOp__57(19, fctno, p, x);
} else { } else {
OPB_err(111); OPB_err(111);
} }
@ -2247,7 +2228,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
if (x->class == 8 || x->class == 9) { if (x->class == 8 || x->class == 9) {
OPB_err(126); OPB_err(126);
} else if (__IN(f, 0x70)) { } else if (__IN(f, 0x70)) {
p = NewOp__59(12, 26, p, x); p = NewOp__57(12, 26, p, x);
} else { } else {
OPB_err(111); OPB_err(111);
} }
@ -2271,7 +2252,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
if (x->class == 8 || x->class == 9) { if (x->class == 8 || x->class == 9) {
OPB_err(126); OPB_err(126);
} else if (__IN(f, 0x70)) { } else if (__IN(f, 0x70)) {
p = NewOp__59(19, 30, p, x); p = NewOp__57(19, 30, p, x);
} else { } else {
OPB_err(111); OPB_err(111);
} }
@ -2317,7 +2298,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
break; break;
} }
*par0 = p; *par0 = p;
StPar1__58_s = _s.lnk; StPar1__56_s = _s.lnk;
} }
void OPB_StParN (OPT_Node *par0, OPT_Node x, INTEGER fctno, INTEGER n) void OPB_StParN (OPT_Node *par0, OPT_Node x, INTEGER fctno, INTEGER n)

View file

@ -16,7 +16,7 @@ static CHAR OPC_BodyNameExt[13];
export void OPC_Align (LONGINT *adr, LONGINT base); export void OPC_Align (LONGINT *adr, LONGINT base);
export void OPC_Andent (OPT_Struct typ); export void OPC_Andent (OPT_Struct typ);
static void OPC_AnsiParamList (OPT_Object obj, BOOLEAN showParamNames); static void OPC_AnsiParamList (OPT_Object obj, BOOLEAN showParamNames);
export LONGINT OPC_Base (OPT_Struct typ); export LONGINT OPC_BaseAlignment (OPT_Struct typ);
export OPT_Object OPC_BaseTProc (OPT_Object obj); export OPT_Object OPC_BaseTProc (OPT_Object obj);
export void OPC_BegBlk (void); export void OPC_BegBlk (void);
export void OPC_BegStat (void); export void OPC_BegStat (void);
@ -74,6 +74,7 @@ static void OPC_PutBase (OPT_Struct typ);
static void OPC_PutPtrOffsets (OPT_Struct typ, LONGINT adr, LONGINT *cnt); static void OPC_PutPtrOffsets (OPT_Struct typ, LONGINT adr, LONGINT *cnt);
static void OPC_RegCmds (OPT_Object obj); static void OPC_RegCmds (OPT_Object obj);
export void OPC_SetInclude (BOOLEAN exclude); export void OPC_SetInclude (BOOLEAN exclude);
export LONGINT OPC_SizeAlignment (LONGINT size);
static void OPC_Stars (OPT_Struct typ, BOOLEAN *openClause); static void OPC_Stars (OPT_Struct typ, BOOLEAN *openClause);
static void OPC_Str1 (CHAR *s, LONGINT s__len, LONGINT x); static void OPC_Str1 (CHAR *s, LONGINT s__len, LONGINT x);
static void OPC_StringLiteral (CHAR *s, LONGINT s__len, LONGINT l); static void OPC_StringLiteral (CHAR *s, LONGINT s__len, LONGINT l);
@ -867,70 +868,37 @@ void OPC_Align (LONGINT *adr, LONGINT base)
} }
} }
LONGINT OPC_Base (OPT_Struct typ) LONGINT OPC_SizeAlignment (LONGINT size)
{ {
LONGINT _o_result; LONGINT _o_result;
switch (typ->form) { LONGINT alignment;
case 1: if (size < (LONGINT)OPM_Alignment) {
_o_result = 1; alignment = 1;
return _o_result; while (alignment < size) {
break; alignment = __ASHL(alignment, 1);
case 3: }
_o_result = OPM_CharAlign; } else {
return _o_result; alignment = OPM_Alignment;
break;
case 2:
_o_result = OPM_BoolAlign;
return _o_result;
break;
case 4:
_o_result = OPM_SIntAlign;
return _o_result;
break;
case 5:
_o_result = OPM_IntAlign;
return _o_result;
break;
case 6:
_o_result = OPM_LIntAlign;
return _o_result;
break;
case 7:
_o_result = OPM_RealAlign;
return _o_result;
break;
case 8:
_o_result = OPM_LRealAlign;
return _o_result;
break;
case 9:
_o_result = OPM_SetAlign;
return _o_result;
break;
case 13:
_o_result = OPM_PointerAlign;
return _o_result;
break;
case 14:
_o_result = OPM_ProcAlign;
return _o_result;
break;
case 15:
if (typ->comp == 4) {
_o_result = __MASK(typ->align, -65536);
return _o_result;
} else {
_o_result = OPC_Base(typ->BaseTyp);
return _o_result;
}
break;
default:
OPM_LogWStr((CHAR*)"unhandled case in OPC.Base, typ^form = ", (LONGINT)40);
OPM_LogWNum(typ->form, ((LONGINT)(0)));
OPM_LogWLn();
break;
} }
__RETCHK; _o_result = alignment;
return _o_result;
}
LONGINT OPC_BaseAlignment (OPT_Struct typ)
{
LONGINT _o_result;
LONGINT alignment;
if (typ->form == 15) {
if (typ->comp == 4) {
alignment = __MASK(typ->align, -65536);
} else {
alignment = OPC_BaseAlignment(typ->BaseTyp);
}
} else {
alignment = OPC_SizeAlignment(typ->size);
}
_o_result = alignment;
return _o_result;
} }
static void OPC_FillGap (LONGINT gap, LONGINT off, LONGINT align, LONGINT *n, LONGINT *curAlign) static void OPC_FillGap (LONGINT gap, LONGINT off, LONGINT align, LONGINT *n, LONGINT *curAlign)
@ -984,7 +952,7 @@ static void OPC_FieldList (OPT_Struct typ, BOOLEAN last, LONGINT *off, LONGINT *
} }
} else { } else {
adr = *off; adr = *off;
fldAlign = OPC_Base(fld->typ); fldAlign = OPC_BaseAlignment(fld->typ);
OPC_Align(&adr, fldAlign); OPC_Align(&adr, fldAlign);
gap = fld->adr - adr; gap = fld->adr - adr;
if (fldAlign > *curAlign) { if (fldAlign > *curAlign) {

View file

@ -11,7 +11,7 @@
import void OPC_Align (LONGINT *adr, LONGINT base); import void OPC_Align (LONGINT *adr, LONGINT base);
import void OPC_Andent (OPT_Struct typ); import void OPC_Andent (OPT_Struct typ);
import LONGINT OPC_Base (OPT_Struct typ); import LONGINT OPC_BaseAlignment (OPT_Struct typ);
import OPT_Object OPC_BaseTProc (OPT_Object obj); import OPT_Object OPC_BaseTProc (OPT_Object obj);
import void OPC_BegBlk (void); import void OPC_BegBlk (void);
import void OPC_BegStat (void); import void OPC_BegStat (void);
@ -40,6 +40,7 @@ import void OPC_InitTDesc (OPT_Struct typ);
import void OPC_Len (OPT_Object obj, OPT_Struct array, LONGINT dim); import void OPC_Len (OPT_Object obj, OPT_Struct array, LONGINT dim);
import LONGINT OPC_NofPtrs (OPT_Struct typ); import LONGINT OPC_NofPtrs (OPT_Struct typ);
import void OPC_SetInclude (BOOLEAN exclude); import void OPC_SetInclude (BOOLEAN exclude);
import LONGINT OPC_SizeAlignment (LONGINT size);
import void OPC_TDescDecl (OPT_Struct typ); import void OPC_TDescDecl (OPT_Struct typ);
import void OPC_TypeDefs (OPT_Object obj, INTEGER vis); import void OPC_TypeDefs (OPT_Object obj, INTEGER vis);
import void OPC_TypeOf (OPT_Object ap); import void OPC_TypeOf (OPT_Object ap);

View file

@ -14,8 +14,8 @@ typedef
static CHAR OPM_SourceFileName[256]; static CHAR OPM_SourceFileName[256];
export INTEGER OPM_Alignment, OPM_ByteSize, OPM_CharSize, OPM_BoolSize, OPM_SIntSize, OPM_IntSize, OPM_LIntSize, OPM_SetSize, OPM_RealSize, OPM_LRealSize, OPM_PointerSize, OPM_ProcSize, OPM_RecSize, OPM_CharAlign, OPM_BoolAlign, OPM_SIntAlign, OPM_IntAlign, OPM_LIntAlign, OPM_SetAlign, OPM_RealAlign, OPM_LRealAlign, OPM_PointerAlign, OPM_ProcAlign, OPM_RecAlign, OPM_MaxSet; export INTEGER OPM_Alignment, OPM_ByteSize, OPM_CharSize, OPM_BoolSize, OPM_SIntSize, OPM_IntSize, OPM_LIntSize, OPM_SetSize, OPM_RealSize, OPM_LRealSize, OPM_PointerSize, OPM_ProcSize, OPM_RecSize, OPM_MaxSet;
export LONGINT OPM_MinSInt, OPM_MinInt, OPM_MinLInt, OPM_MaxSInt, OPM_MaxInt, OPM_MaxLInt, OPM_MaxIndex; export LONGINT OPM_MaxIndex;
export LONGREAL OPM_MinReal, OPM_MaxReal, OPM_MinLReal, OPM_MaxLReal; export LONGREAL OPM_MinReal, OPM_MaxReal, OPM_MinLReal, OPM_MaxLReal;
export BOOLEAN OPM_noerr; export BOOLEAN OPM_noerr;
export LONGINT OPM_curpos, OPM_errpos, OPM_breakpc; export LONGINT OPM_curpos, OPM_errpos, OPM_breakpc;
@ -36,7 +36,6 @@ static CHAR OPM_OBERON[1024];
static CHAR OPM_MODULES[1024]; static CHAR OPM_MODULES[1024];
export INTEGER OPM_AlignSize (LONGINT size);
static void OPM_Append (Files_Rider *R, LONGINT *R__typ, Files_File F); static void OPM_Append (Files_Rider *R, LONGINT *R__typ, Files_File F);
export void OPM_CloseFiles (void); export void OPM_CloseFiles (void);
export void OPM_CloseOldSym (void); export void OPM_CloseOldSym (void);
@ -65,6 +64,8 @@ export BOOLEAN OPM_OpenPar (void);
export void OPM_RegisterNewSym (void); export void OPM_RegisterNewSym (void);
static void OPM_ScanOptions (CHAR *s, LONGINT s__len, SET *opt); static void OPM_ScanOptions (CHAR *s, LONGINT s__len, SET *opt);
static void OPM_ShowLine (LONGINT pos); static void OPM_ShowLine (LONGINT pos);
export LONGINT OPM_SignedMaximum (LONGINT bytecount);
export LONGINT OPM_SignedMinimum (LONGINT bytecount);
export void OPM_SymRCh (CHAR *ch); export void OPM_SymRCh (CHAR *ch);
export LONGINT OPM_SymRInt (void); export LONGINT OPM_SymRInt (void);
export void OPM_SymRLReal (LONGREAL *lr); export void OPM_SymRLReal (LONGREAL *lr);
@ -607,111 +608,62 @@ static void OPM_VerboseListSizes (void)
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"CHAR ", (LONGINT)14); OPM_LogWStr((CHAR*)"CHAR ", (LONGINT)14);
OPM_LogWNum(OPM_CharSize, ((LONGINT)(4))); OPM_LogWNum(OPM_CharSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_CharAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"BOOLEAN ", (LONGINT)14); OPM_LogWStr((CHAR*)"BOOLEAN ", (LONGINT)14);
OPM_LogWNum(OPM_BoolSize, ((LONGINT)(4))); OPM_LogWNum(OPM_BoolSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_BoolAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"SHORTINT ", (LONGINT)14); OPM_LogWStr((CHAR*)"SHORTINT ", (LONGINT)14);
OPM_LogWNum(OPM_SIntSize, ((LONGINT)(4))); OPM_LogWNum(OPM_SIntSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_SIntAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"INTEGER ", (LONGINT)14); OPM_LogWStr((CHAR*)"INTEGER ", (LONGINT)14);
OPM_LogWNum(OPM_IntSize, ((LONGINT)(4))); OPM_LogWNum(OPM_IntSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_IntAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"LONGINT ", (LONGINT)14); OPM_LogWStr((CHAR*)"LONGINT ", (LONGINT)14);
OPM_LogWNum(OPM_LIntSize, ((LONGINT)(4))); OPM_LogWNum(OPM_LIntSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_LIntAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"SET ", (LONGINT)14); OPM_LogWStr((CHAR*)"SET ", (LONGINT)14);
OPM_LogWNum(OPM_SetSize, ((LONGINT)(4))); OPM_LogWNum(OPM_SetSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_SetAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"REAL ", (LONGINT)14); OPM_LogWStr((CHAR*)"REAL ", (LONGINT)14);
OPM_LogWNum(OPM_RealSize, ((LONGINT)(4))); OPM_LogWNum(OPM_RealSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_RealAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"LONGREAL ", (LONGINT)14); OPM_LogWStr((CHAR*)"LONGREAL ", (LONGINT)14);
OPM_LogWNum(OPM_LRealSize, ((LONGINT)(4))); OPM_LogWNum(OPM_LRealSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_LRealAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"PTR ", (LONGINT)14); OPM_LogWStr((CHAR*)"PTR ", (LONGINT)14);
OPM_LogWNum(OPM_PointerSize, ((LONGINT)(4))); OPM_LogWNum(OPM_PointerSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_PointerAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"PROC ", (LONGINT)14); OPM_LogWStr((CHAR*)"PROC ", (LONGINT)14);
OPM_LogWNum(OPM_ProcSize, ((LONGINT)(4))); OPM_LogWNum(OPM_ProcSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_ProcAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"RECORD ", (LONGINT)14); OPM_LogWStr((CHAR*)"RECORD ", (LONGINT)14);
OPM_LogWNum(OPM_RecSize, ((LONGINT)(4))); OPM_LogWNum(OPM_RecSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_RecAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"Min shortint ", (LONGINT)14);
OPM_LogWNum(OPM_MinSInt, ((LONGINT)(4)));
OPM_LogWLn();
OPM_LogWStr((CHAR*)"Max shortint ", (LONGINT)14);
OPM_LogWNum(OPM_MaxSInt, ((LONGINT)(4)));
OPM_LogWLn();
OPM_LogWStr((CHAR*)"Min integer ", (LONGINT)14);
OPM_LogWNum(OPM_MinInt, ((LONGINT)(4)));
OPM_LogWLn();
OPM_LogWStr((CHAR*)"Max integer ", (LONGINT)14);
OPM_LogWNum(OPM_MaxInt, ((LONGINT)(4)));
OPM_LogWLn();
OPM_LogWStr((CHAR*)"Min longint ", (LONGINT)14);
OPM_LogWNum(OPM_MinLInt, ((LONGINT)(4)));
OPM_LogWLn();
} }
INTEGER OPM_AlignSize (LONGINT size) LONGINT OPM_SignedMaximum (LONGINT bytecount)
{ {
INTEGER _o_result; LONGINT _o_result;
INTEGER align; LONGINT result;
if (size < (LONGINT)OPM_Alignment) { result = 1;
if (size > 8) { result = __LSH(result, __ASHL(bytecount, 3) - 1, LONGINT);
align = 16; _o_result = result - 1;
} else if (size > 4) { return _o_result;
align = 8; }
} else if (size > 2) {
align = 4; LONGINT OPM_SignedMinimum (LONGINT bytecount)
} else { {
align = (int)size; LONGINT _o_result;
} _o_result = -OPM_SignedMaximum(bytecount) - 1;
} else {
align = OPM_Alignment;
}
_o_result = align;
return _o_result; return _o_result;
} }
static void OPM_GetProperties (void) static void OPM_GetProperties (void)
{ {
LONGINT base;
OPM_ProcSize = OPM_PointerSize; OPM_ProcSize = OPM_PointerSize;
OPM_LIntSize = __ASHL(OPM_IntSize, 1); OPM_LIntSize = __ASHL(OPM_IntSize, 1);
OPM_SetSize = OPM_LIntSize; OPM_SetSize = OPM_LIntSize;
OPM_CharAlign = OPM_AlignSize(OPM_CharSize);
OPM_BoolAlign = OPM_AlignSize(OPM_BoolSize);
OPM_SIntAlign = OPM_AlignSize(OPM_SIntSize);
OPM_RecAlign = OPM_AlignSize(OPM_RecSize);
OPM_RealAlign = OPM_AlignSize(OPM_RealSize);
OPM_LRealAlign = OPM_AlignSize(OPM_LRealSize);
OPM_PointerAlign = OPM_AlignSize(OPM_PointerSize);
OPM_ProcAlign = OPM_AlignSize(OPM_ProcSize);
OPM_IntAlign = OPM_AlignSize(OPM_IntSize);
OPM_LIntAlign = OPM_AlignSize(OPM_LIntSize);
OPM_SetAlign = OPM_AlignSize(OPM_SetSize);
base = -2;
OPM_MinSInt = __ASH(base, __ASHL(OPM_SIntSize, 3) - 2);
OPM_MaxSInt = OPM_minusop(OPM_MinSInt + 1);
OPM_MinInt = __ASH(base, __ASHL(OPM_IntSize, 3) - 2);
OPM_MaxInt = OPM_minusop(OPM_MinInt + 1);
OPM_MinLInt = __ASH(base, __ASHL(OPM_LIntSize, 3) - 2);
OPM_MaxLInt = OPM_minusop(OPM_MinLInt + 1);
if (OPM_RealSize == 4) { if (OPM_RealSize == 4) {
OPM_MaxReal = 3.40282346000000e+038; OPM_MaxReal = 3.40282346000000e+038;
} else if (OPM_RealSize == 8) { } else if (OPM_RealSize == 8) {
@ -725,7 +677,7 @@ static void OPM_GetProperties (void)
OPM_MinReal = -OPM_MaxReal; OPM_MinReal = -OPM_MaxReal;
OPM_MinLReal = -OPM_MaxLReal; OPM_MinLReal = -OPM_MaxLReal;
OPM_MaxSet = __ASHL(OPM_SetSize, 3) - 1; OPM_MaxSet = __ASHL(OPM_SetSize, 3) - 1;
OPM_MaxIndex = OPM_MaxLInt; OPM_MaxIndex = OPM_SignedMaximum(OPM_PointerSize);
if (OPM_Verbose) { if (OPM_Verbose) {
OPM_VerboseListSizes(); OPM_VerboseListSizes();
} }
@ -887,7 +839,7 @@ void OPM_WriteInt (LONGINT i)
{ {
CHAR s[20]; CHAR s[20];
LONGINT i1, k; LONGINT i1, k;
if (i == OPM_MinInt || i == OPM_MinLInt) { if (i == OPM_SignedMinimum(OPM_IntSize) || i == OPM_SignedMinimum(OPM_LIntSize)) {
OPM_Write('('); OPM_Write('(');
OPM_WriteInt(i + 1); OPM_WriteInt(i + 1);
OPM_WriteString((CHAR*)"-1)", (LONGINT)4); OPM_WriteString((CHAR*)"-1)", (LONGINT)4);
@ -920,7 +872,7 @@ void OPM_WriteReal (LONGREAL r, CHAR suffx)
CHAR s[32]; CHAR s[32];
CHAR ch; CHAR ch;
INTEGER i; INTEGER i;
if ((((r < OPM_MaxLInt && r > OPM_MinLInt)) && r == (__ENTIER(r)))) { if ((((r < OPM_SignedMaximum(OPM_LIntSize) && r > OPM_SignedMinimum(OPM_LIntSize))) && r == (__ENTIER(r)))) {
if (suffx == 'f') { if (suffx == 'f') {
OPM_WriteString((CHAR*)"(REAL)", (LONGINT)7); OPM_WriteString((CHAR*)"(REAL)", (LONGINT)7);
} else { } else {

View file

@ -6,8 +6,8 @@
#include "SYSTEM.h" #include "SYSTEM.h"
import INTEGER OPM_Alignment, OPM_ByteSize, OPM_CharSize, OPM_BoolSize, OPM_SIntSize, OPM_IntSize, OPM_LIntSize, OPM_SetSize, OPM_RealSize, OPM_LRealSize, OPM_PointerSize, OPM_ProcSize, OPM_RecSize, OPM_CharAlign, OPM_BoolAlign, OPM_SIntAlign, OPM_IntAlign, OPM_LIntAlign, OPM_SetAlign, OPM_RealAlign, OPM_LRealAlign, OPM_PointerAlign, OPM_ProcAlign, OPM_RecAlign, OPM_MaxSet; import INTEGER OPM_Alignment, OPM_ByteSize, OPM_CharSize, OPM_BoolSize, OPM_SIntSize, OPM_IntSize, OPM_LIntSize, OPM_SetSize, OPM_RealSize, OPM_LRealSize, OPM_PointerSize, OPM_ProcSize, OPM_RecSize, OPM_MaxSet;
import LONGINT OPM_MinSInt, OPM_MinInt, OPM_MinLInt, OPM_MaxSInt, OPM_MaxInt, OPM_MaxLInt, OPM_MaxIndex; import LONGINT OPM_MaxIndex;
import LONGREAL OPM_MinReal, OPM_MaxReal, OPM_MinLReal, OPM_MaxLReal; import LONGREAL OPM_MinReal, OPM_MaxReal, OPM_MinLReal, OPM_MaxLReal;
import BOOLEAN OPM_noerr; import BOOLEAN OPM_noerr;
import LONGINT OPM_curpos, OPM_errpos, OPM_breakpc; import LONGINT OPM_curpos, OPM_errpos, OPM_breakpc;
@ -18,7 +18,6 @@ import SET OPM_opt, OPM_glbopt;
import BOOLEAN OPM_dontAsm, OPM_dontLink, OPM_mainProg, OPM_mainLinkStat, OPM_notColorOutput, OPM_forceNewSym, OPM_Verbose; import BOOLEAN OPM_dontAsm, OPM_dontLink, OPM_mainProg, OPM_mainLinkStat, OPM_notColorOutput, OPM_forceNewSym, OPM_Verbose;
import INTEGER OPM_AlignSize (LONGINT size);
import void OPM_CloseFiles (void); import void OPM_CloseFiles (void);
import void OPM_CloseOldSym (void); import void OPM_CloseOldSym (void);
import void OPM_DeleteNewSym (void); import void OPM_DeleteNewSym (void);
@ -39,6 +38,8 @@ import void OPM_OldSym (CHAR *modName, LONGINT modName__len, BOOLEAN *done);
import void OPM_OpenFiles (CHAR *moduleName, LONGINT moduleName__len); import void OPM_OpenFiles (CHAR *moduleName, LONGINT moduleName__len);
import BOOLEAN OPM_OpenPar (void); import BOOLEAN OPM_OpenPar (void);
import void OPM_RegisterNewSym (void); import void OPM_RegisterNewSym (void);
import LONGINT OPM_SignedMaximum (LONGINT bytecount);
import LONGINT OPM_SignedMinimum (LONGINT bytecount);
import void OPM_SymRCh (CHAR *ch); import void OPM_SymRCh (CHAR *ch);
import LONGINT OPM_SymRInt (void); import LONGINT OPM_SymRInt (void);
import void OPM_SymRLReal (LONGREAL *lr); import void OPM_SymRLReal (LONGREAL *lr);

View file

@ -82,7 +82,7 @@ void OPV_TypSize (OPT_Struct typ)
btyp = typ->BaseTyp; btyp = typ->BaseTyp;
if (btyp == NIL) { if (btyp == NIL) {
offset = 0; offset = 0;
base = OPM_RecAlign; base = OPC_SizeAlignment(OPM_RecSize);
} else { } else {
OPV_TypSize(btyp); OPV_TypSize(btyp);
offset = btyp->size - (LONGINT)__ASHR(btyp->sysflag, 8); offset = btyp->size - (LONGINT)__ASHR(btyp->sysflag, 8);
@ -93,7 +93,7 @@ void OPV_TypSize (OPT_Struct typ)
btyp = fld->typ; btyp = fld->typ;
OPV_TypSize(btyp); OPV_TypSize(btyp);
size = btyp->size; size = btyp->size;
fbase = OPC_Base(btyp); fbase = OPC_BaseAlignment(btyp);
OPC_Align(&offset, fbase); OPC_Align(&offset, fbase);
fld->adr = offset; fld->adr = offset;
offset += size; offset += size;
@ -107,7 +107,7 @@ void OPV_TypSize (OPT_Struct typ)
offset = 1; offset = 1;
} }
if (OPM_RecSize == 0) { if (OPM_RecSize == 0) {
base = OPV_NaturalAlignment(offset, OPM_RecAlign); base = OPV_NaturalAlignment(offset, OPC_SizeAlignment(OPM_RecSize));
} }
OPC_Align(&offset, base); OPC_Align(&offset, base);
if ((typ->strobj == NIL && __MASK(typ->align, -65536) == 0)) { if ((typ->strobj == NIL && __MASK(typ->align, -65536) == 0)) {
@ -491,7 +491,7 @@ static void OPV_Convert (OPT_Node n, INTEGER form, INTEGER prec)
OPM_Write('('); OPM_Write('(');
OPV_Entier(n, -1); OPV_Entier(n, -1);
OPM_WriteString((CHAR*)", ", (LONGINT)3); OPM_WriteString((CHAR*)", ", (LONGINT)3);
OPM_WriteInt(OPM_MaxInt + 1); OPM_WriteInt(OPM_SignedMaximum(OPM_IntSize) + 1);
OPM_Write(')'); OPM_Write(')');
} else { } else {
OPM_WriteString((CHAR*)"(int)", (LONGINT)6); OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
@ -507,7 +507,7 @@ static void OPV_Convert (OPT_Node n, INTEGER form, INTEGER prec)
OPM_Write('('); OPM_Write('(');
OPV_Entier(n, -1); OPV_Entier(n, -1);
OPM_WriteString((CHAR*)", ", (LONGINT)3); OPM_WriteString((CHAR*)", ", (LONGINT)3);
OPM_WriteInt(OPM_MaxSInt + 1); OPM_WriteInt(OPM_SignedMaximum(OPM_SIntSize) + 1);
OPM_Write(')'); OPM_Write(')');
} else { } else {
OPM_WriteString((CHAR*)"(int)", (LONGINT)6); OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
@ -795,7 +795,7 @@ static void OPV_ActualPar (OPT_Node n, OPT_Object fp)
} }
if ((((mode == 2 && n->class == 11)) && n->subcl == 29)) { if ((((mode == 2 && n->class == 11)) && n->subcl == 29)) {
OPV_expr(n->left, prec); OPV_expr(n->left, prec);
} else if ((((((form == 6 && n->class == 7)) && n->conval->intval <= OPM_MaxInt)) && n->conval->intval >= OPM_MinInt)) { } else if ((((((form == 6 && n->class == 7)) && n->conval->intval <= OPM_SignedMaximum(OPM_IntSize))) && n->conval->intval >= OPM_SignedMinimum(OPM_IntSize))) {
OPM_WriteString((CHAR*)"((LONGINT)(", (LONGINT)12); OPM_WriteString((CHAR*)"((LONGINT)(", (LONGINT)12);
OPV_expr(n, prec); OPV_expr(n, prec);
OPM_WriteString((CHAR*)"))", (LONGINT)3); OPM_WriteString((CHAR*)"))", (LONGINT)3);
@ -1322,7 +1322,7 @@ static void OPV_NewArr (OPT_Node d, OPT_Node x)
OPM_WriteInt(base->size); OPM_WriteInt(base->size);
OPM_WriteString((CHAR*)"))", (LONGINT)3); OPM_WriteString((CHAR*)"))", (LONGINT)3);
OPM_WriteString((CHAR*)", ", (LONGINT)3); OPM_WriteString((CHAR*)", ", (LONGINT)3);
OPM_WriteInt(OPC_Base(base)); OPM_WriteInt(OPC_BaseAlignment(base));
OPM_WriteString((CHAR*)", ", (LONGINT)3); OPM_WriteString((CHAR*)", ", (LONGINT)3);
OPM_WriteInt(nofdim); OPM_WriteInt(nofdim);
OPM_WriteString((CHAR*)", ", (LONGINT)3); OPM_WriteString((CHAR*)", ", (LONGINT)3);

View file

@ -56,8 +56,6 @@ static void OPB_SetIntType (OPT_Node node);
export void OPB_SetRange (OPT_Node *x, OPT_Node y); export void OPB_SetRange (OPT_Node *x, OPT_Node y);
static LONGINT OPB_ShorterSize (LONGINT i); static LONGINT OPB_ShorterSize (LONGINT i);
static INTEGER OPB_SignedByteSize (LONGINT n); static INTEGER OPB_SignedByteSize (LONGINT n);
static LONGINT OPB_SignedMaximum (LONGINT bytecount);
static LONGINT OPB_SignedMinimum (LONGINT bytecount);
export void OPB_StFct (OPT_Node *par0, SHORTINT fctno, INTEGER parno); export void OPB_StFct (OPT_Node *par0, SHORTINT fctno, INTEGER parno);
export void OPB_StPar0 (OPT_Node *par0, INTEGER fctno); export void OPB_StPar0 (OPT_Node *par0, INTEGER fctno);
export void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno); export void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno);
@ -227,23 +225,6 @@ OPT_Node OPB_EmptySet (void)
return _o_result; return _o_result;
} }
static LONGINT OPB_SignedMaximum (LONGINT bytecount)
{
LONGINT _o_result;
LONGINT result;
result = 1;
result = __LSH(result, __ASHL(bytecount, 3) - 1, LONGINT);
_o_result = result - 1;
return _o_result;
}
static LONGINT OPB_SignedMinimum (LONGINT bytecount)
{
LONGINT _o_result;
_o_result = -OPB_SignedMaximum(bytecount) - 1;
return _o_result;
}
static INTEGER OPB_SignedByteSize (LONGINT n) static INTEGER OPB_SignedByteSize (LONGINT n)
{ {
INTEGER _o_result; INTEGER _o_result;
@ -449,16 +430,16 @@ void OPB_Field (OPT_Node *x, OPT_Object y)
} }
} }
static struct TypTest__63 { static struct TypTest__61 {
OPT_Node *x; OPT_Node *x;
OPT_Object *obj; OPT_Object *obj;
BOOLEAN *guard; BOOLEAN *guard;
struct TypTest__63 *lnk; struct TypTest__61 *lnk;
} *TypTest__63_s; } *TypTest__61_s;
static void GTT__64 (OPT_Struct t0, OPT_Struct t1); static void GTT__62 (OPT_Struct t0, OPT_Struct t1);
static void GTT__64 (OPT_Struct t0, OPT_Struct t1) static void GTT__62 (OPT_Struct t0, OPT_Struct t1)
{ {
OPT_Node node = NIL; OPT_Node node = NIL;
OPT_Struct t = NIL; OPT_Struct t = NIL;
@ -471,54 +452,54 @@ static void GTT__64 (OPT_Struct t0, OPT_Struct t1)
t1 = t1->BaseTyp; t1 = t1->BaseTyp;
} }
if (t1 == t0 || t0->form == 0) { if (t1 == t0 || t0->form == 0) {
if (*TypTest__63_s->guard) { if (*TypTest__61_s->guard) {
OPB_BindNodes(5, NIL, &*TypTest__63_s->x, NIL); OPB_BindNodes(5, NIL, &*TypTest__61_s->x, NIL);
(*TypTest__63_s->x)->readonly = (*TypTest__63_s->x)->left->readonly; (*TypTest__61_s->x)->readonly = (*TypTest__61_s->x)->left->readonly;
} else { } else {
node = OPT_NewNode(11); node = OPT_NewNode(11);
node->subcl = 16; node->subcl = 16;
node->left = *TypTest__63_s->x; node->left = *TypTest__61_s->x;
node->obj = *TypTest__63_s->obj; node->obj = *TypTest__61_s->obj;
*TypTest__63_s->x = node; *TypTest__61_s->x = node;
} }
} else { } else {
OPB_err(85); OPB_err(85);
} }
} else if (t0 != t1) { } else if (t0 != t1) {
OPB_err(85); OPB_err(85);
} else if (!*TypTest__63_s->guard) { } else if (!*TypTest__61_s->guard) {
if ((*TypTest__63_s->x)->class == 5) { if ((*TypTest__61_s->x)->class == 5) {
node = OPT_NewNode(11); node = OPT_NewNode(11);
node->subcl = 16; node->subcl = 16;
node->left = *TypTest__63_s->x; node->left = *TypTest__61_s->x;
node->obj = *TypTest__63_s->obj; node->obj = *TypTest__61_s->obj;
*TypTest__63_s->x = node; *TypTest__61_s->x = node;
} else { } else {
*TypTest__63_s->x = OPB_NewBoolConst(1); *TypTest__61_s->x = OPB_NewBoolConst(1);
} }
} }
} }
void OPB_TypTest (OPT_Node *x, OPT_Object obj, BOOLEAN guard) void OPB_TypTest (OPT_Node *x, OPT_Object obj, BOOLEAN guard)
{ {
struct TypTest__63 _s; struct TypTest__61 _s;
_s.x = x; _s.x = x;
_s.obj = &obj; _s.obj = &obj;
_s.guard = &guard; _s.guard = &guard;
_s.lnk = TypTest__63_s; _s.lnk = TypTest__61_s;
TypTest__63_s = &_s; TypTest__61_s = &_s;
if (OPB_NotVar(*x)) { if (OPB_NotVar(*x)) {
OPB_err(112); OPB_err(112);
} else if ((*x)->typ->form == 13) { } else if ((*x)->typ->form == 13) {
if (((*x)->typ->BaseTyp->comp != 4 && (*x)->typ != OPT_sysptrtyp)) { if (((*x)->typ->BaseTyp->comp != 4 && (*x)->typ != OPT_sysptrtyp)) {
OPB_err(85); OPB_err(85);
} else if (obj->typ->form == 13) { } else if (obj->typ->form == 13) {
GTT__64((*x)->typ->BaseTyp, obj->typ->BaseTyp); GTT__62((*x)->typ->BaseTyp, obj->typ->BaseTyp);
} else { } else {
OPB_err(86); OPB_err(86);
} }
} else if (((((*x)->typ->comp == 4 && (*x)->class == 1)) && obj->typ->comp == 4)) { } else if (((((*x)->typ->comp == 4 && (*x)->class == 1)) && obj->typ->comp == 4)) {
GTT__64((*x)->typ, obj->typ); GTT__62((*x)->typ, obj->typ);
} else { } else {
OPB_err(87); OPB_err(87);
} }
@ -527,7 +508,7 @@ void OPB_TypTest (OPT_Node *x, OPT_Object obj, BOOLEAN guard)
} else { } else {
(*x)->typ = OPT_booltyp; (*x)->typ = OPT_booltyp;
} }
TypTest__63_s = _s.lnk; TypTest__61_s = _s.lnk;
} }
void OPB_In (OPT_Node *x, OPT_Node y) void OPB_In (OPT_Node *x, OPT_Node y)
@ -1850,7 +1831,7 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno)
x->typ = OPT_chartyp; x->typ = OPT_chartyp;
break; break;
case 4: case 5: case 6: case 4: case 5: case 6:
x = OPB_NewIntConst(OPB_SignedMinimum(x->typ->size)); x = OPB_NewIntConst(OPM_SignedMinimum(x->typ->size));
break; break;
case 9: case 9:
x = OPB_NewIntConst(((LONGINT)(0))); x = OPB_NewIntConst(((LONGINT)(0)));
@ -1881,7 +1862,7 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno)
x->typ = OPT_chartyp; x->typ = OPT_chartyp;
break; break;
case 4: case 5: case 6: case 4: case 5: case 6:
x = OPB_NewIntConst(OPB_SignedMaximum(x->typ->size)); x = OPB_NewIntConst(OPM_SignedMaximum(x->typ->size));
break; break;
case 9: case 9:
x = OPB_NewIntConst(OPM_MaxSet); x = OPB_NewIntConst(OPM_MaxSet);
@ -2063,13 +2044,13 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno)
*par0 = x; *par0 = x;
} }
static struct StPar1__58 { static struct StPar1__56 {
struct StPar1__58 *lnk; struct StPar1__56 *lnk;
} *StPar1__58_s; } *StPar1__56_s;
static OPT_Node NewOp__59 (SHORTINT class, SHORTINT subcl, OPT_Node left, OPT_Node right); static OPT_Node NewOp__57 (SHORTINT class, SHORTINT subcl, OPT_Node left, OPT_Node right);
static OPT_Node NewOp__59 (SHORTINT class, SHORTINT subcl, OPT_Node left, OPT_Node right) static OPT_Node NewOp__57 (SHORTINT class, SHORTINT subcl, OPT_Node left, OPT_Node right)
{ {
OPT_Node _o_result; OPT_Node _o_result;
OPT_Node node = NIL; OPT_Node node = NIL;
@ -2086,9 +2067,9 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
INTEGER f, L; INTEGER f, L;
OPT_Struct typ = NIL; OPT_Struct typ = NIL;
OPT_Node p = NIL, t = NIL; OPT_Node p = NIL, t = NIL;
struct StPar1__58 _s; struct StPar1__56 _s;
_s.lnk = StPar1__58_s; _s.lnk = StPar1__56_s;
StPar1__58_s = &_s; StPar1__56_s = &_s;
p = *par0; p = *par0;
f = x->typ->form; f = x->typ->form;
switch (fctno) { switch (fctno) {
@ -2104,7 +2085,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
OPB_err(111); OPB_err(111);
} }
} }
p = NewOp__59(19, fctno, p, x); p = NewOp__57(19, fctno, p, x);
p->typ = OPT_notyp; p->typ = OPT_notyp;
} }
break; break;
@ -2115,7 +2096,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
if ((x->class == 7 && (0 > x->conval->intval || x->conval->intval > (LONGINT)OPM_MaxSet))) { if ((x->class == 7 && (0 > x->conval->intval || x->conval->intval > (LONGINT)OPM_MaxSet))) {
OPB_err(202); OPB_err(202);
} }
p = NewOp__59(19, fctno, p, x); p = NewOp__57(19, fctno, p, x);
} else { } else {
OPB_err(111); OPB_err(111);
} }
@ -2140,7 +2121,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
p = p->left; p = p->left;
x->conval->intval += 1; x->conval->intval += 1;
} }
p = NewOp__59(12, 19, p, x); p = NewOp__57(12, 19, p, x);
p->typ = OPT_linttyp; p->typ = OPT_linttyp;
} else { } else {
p = x; p = x;
@ -2162,7 +2143,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
t = x; t = x;
x = p; x = p;
p = t; p = t;
p = NewOp__59(19, 18, p, x); p = NewOp__57(19, 18, p, x);
} else { } else {
OPB_err(111); OPB_err(111);
} }
@ -2188,7 +2169,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
} }
p->obj = NIL; p->obj = NIL;
} else { } else {
p = NewOp__59(12, 17, p, x); p = NewOp__57(12, 17, p, x);
p->typ = OPT_linttyp; p->typ = OPT_linttyp;
} }
} else { } else {
@ -2219,9 +2200,9 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
OPB_err(111); OPB_err(111);
} else { } else {
if (fctno == 22) { if (fctno == 22) {
p = NewOp__59(12, 27, p, x); p = NewOp__57(12, 27, p, x);
} else { } else {
p = NewOp__59(12, 28, p, x); p = NewOp__57(12, 28, p, x);
} }
p->typ = p->left->typ; p->typ = p->left->typ;
} }
@ -2238,7 +2219,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
x = p; x = p;
p = t; p = t;
} }
p = NewOp__59(19, fctno, p, x); p = NewOp__57(19, fctno, p, x);
} else { } else {
OPB_err(111); OPB_err(111);
} }
@ -2248,7 +2229,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
if (x->class == 8 || x->class == 9) { if (x->class == 8 || x->class == 9) {
OPB_err(126); OPB_err(126);
} else if (__IN(f, 0x70)) { } else if (__IN(f, 0x70)) {
p = NewOp__59(12, 26, p, x); p = NewOp__57(12, 26, p, x);
} else { } else {
OPB_err(111); OPB_err(111);
} }
@ -2272,7 +2253,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
if (x->class == 8 || x->class == 9) { if (x->class == 8 || x->class == 9) {
OPB_err(126); OPB_err(126);
} else if (__IN(f, 0x70)) { } else if (__IN(f, 0x70)) {
p = NewOp__59(19, 30, p, x); p = NewOp__57(19, 30, p, x);
} else { } else {
OPB_err(111); OPB_err(111);
} }
@ -2318,7 +2299,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
break; break;
} }
*par0 = p; *par0 = p;
StPar1__58_s = _s.lnk; StPar1__56_s = _s.lnk;
} }
void OPB_StParN (OPT_Node *par0, OPT_Node x, INTEGER fctno, INTEGER n) void OPB_StParN (OPT_Node *par0, OPT_Node x, INTEGER fctno, INTEGER n)

View file

@ -17,7 +17,7 @@ static CHAR OPC_BodyNameExt[13];
export void OPC_Align (LONGINT *adr, LONGINT base); export void OPC_Align (LONGINT *adr, LONGINT base);
export void OPC_Andent (OPT_Struct typ); export void OPC_Andent (OPT_Struct typ);
static void OPC_AnsiParamList (OPT_Object obj, BOOLEAN showParamNames); static void OPC_AnsiParamList (OPT_Object obj, BOOLEAN showParamNames);
export LONGINT OPC_Base (OPT_Struct typ); export LONGINT OPC_BaseAlignment (OPT_Struct typ);
export OPT_Object OPC_BaseTProc (OPT_Object obj); export OPT_Object OPC_BaseTProc (OPT_Object obj);
export void OPC_BegBlk (void); export void OPC_BegBlk (void);
export void OPC_BegStat (void); export void OPC_BegStat (void);
@ -75,6 +75,7 @@ static void OPC_PutBase (OPT_Struct typ);
static void OPC_PutPtrOffsets (OPT_Struct typ, LONGINT adr, LONGINT *cnt); static void OPC_PutPtrOffsets (OPT_Struct typ, LONGINT adr, LONGINT *cnt);
static void OPC_RegCmds (OPT_Object obj); static void OPC_RegCmds (OPT_Object obj);
export void OPC_SetInclude (BOOLEAN exclude); export void OPC_SetInclude (BOOLEAN exclude);
export LONGINT OPC_SizeAlignment (LONGINT size);
static void OPC_Stars (OPT_Struct typ, BOOLEAN *openClause); static void OPC_Stars (OPT_Struct typ, BOOLEAN *openClause);
static void OPC_Str1 (CHAR *s, LONGINT s__len, LONGINT x); static void OPC_Str1 (CHAR *s, LONGINT s__len, LONGINT x);
static void OPC_StringLiteral (CHAR *s, LONGINT s__len, LONGINT l); static void OPC_StringLiteral (CHAR *s, LONGINT s__len, LONGINT l);
@ -868,70 +869,37 @@ void OPC_Align (LONGINT *adr, LONGINT base)
} }
} }
LONGINT OPC_Base (OPT_Struct typ) LONGINT OPC_SizeAlignment (LONGINT size)
{ {
LONGINT _o_result; LONGINT _o_result;
switch (typ->form) { LONGINT alignment;
case 1: if (size < (LONGINT)OPM_Alignment) {
_o_result = 1; alignment = 1;
return _o_result; while (alignment < size) {
break; alignment = __ASHL(alignment, 1);
case 3: }
_o_result = OPM_CharAlign; } else {
return _o_result; alignment = OPM_Alignment;
break;
case 2:
_o_result = OPM_BoolAlign;
return _o_result;
break;
case 4:
_o_result = OPM_SIntAlign;
return _o_result;
break;
case 5:
_o_result = OPM_IntAlign;
return _o_result;
break;
case 6:
_o_result = OPM_LIntAlign;
return _o_result;
break;
case 7:
_o_result = OPM_RealAlign;
return _o_result;
break;
case 8:
_o_result = OPM_LRealAlign;
return _o_result;
break;
case 9:
_o_result = OPM_SetAlign;
return _o_result;
break;
case 13:
_o_result = OPM_PointerAlign;
return _o_result;
break;
case 14:
_o_result = OPM_ProcAlign;
return _o_result;
break;
case 15:
if (typ->comp == 4) {
_o_result = __MASK(typ->align, -65536);
return _o_result;
} else {
_o_result = OPC_Base(typ->BaseTyp);
return _o_result;
}
break;
default:
OPM_LogWStr((CHAR*)"unhandled case in OPC.Base, typ^form = ", (LONGINT)40);
OPM_LogWNum(typ->form, ((LONGINT)(0)));
OPM_LogWLn();
break;
} }
__RETCHK; _o_result = alignment;
return _o_result;
}
LONGINT OPC_BaseAlignment (OPT_Struct typ)
{
LONGINT _o_result;
LONGINT alignment;
if (typ->form == 15) {
if (typ->comp == 4) {
alignment = __MASK(typ->align, -65536);
} else {
alignment = OPC_BaseAlignment(typ->BaseTyp);
}
} else {
alignment = OPC_SizeAlignment(typ->size);
}
_o_result = alignment;
return _o_result;
} }
static void OPC_FillGap (LONGINT gap, LONGINT off, LONGINT align, LONGINT *n, LONGINT *curAlign) static void OPC_FillGap (LONGINT gap, LONGINT off, LONGINT align, LONGINT *n, LONGINT *curAlign)
@ -985,7 +953,7 @@ static void OPC_FieldList (OPT_Struct typ, BOOLEAN last, LONGINT *off, LONGINT *
} }
} else { } else {
adr = *off; adr = *off;
fldAlign = OPC_Base(fld->typ); fldAlign = OPC_BaseAlignment(fld->typ);
OPC_Align(&adr, fldAlign); OPC_Align(&adr, fldAlign);
gap = fld->adr - adr; gap = fld->adr - adr;
if (fldAlign > *curAlign) { if (fldAlign > *curAlign) {

View file

@ -12,7 +12,7 @@
import void OPC_Align (LONGINT *adr, LONGINT base); import void OPC_Align (LONGINT *adr, LONGINT base);
import void OPC_Andent (OPT_Struct typ); import void OPC_Andent (OPT_Struct typ);
import LONGINT OPC_Base (OPT_Struct typ); import LONGINT OPC_BaseAlignment (OPT_Struct typ);
import OPT_Object OPC_BaseTProc (OPT_Object obj); import OPT_Object OPC_BaseTProc (OPT_Object obj);
import void OPC_BegBlk (void); import void OPC_BegBlk (void);
import void OPC_BegStat (void); import void OPC_BegStat (void);
@ -41,6 +41,7 @@ import void OPC_InitTDesc (OPT_Struct typ);
import void OPC_Len (OPT_Object obj, OPT_Struct array, LONGINT dim); import void OPC_Len (OPT_Object obj, OPT_Struct array, LONGINT dim);
import LONGINT OPC_NofPtrs (OPT_Struct typ); import LONGINT OPC_NofPtrs (OPT_Struct typ);
import void OPC_SetInclude (BOOLEAN exclude); import void OPC_SetInclude (BOOLEAN exclude);
import LONGINT OPC_SizeAlignment (LONGINT size);
import void OPC_TDescDecl (OPT_Struct typ); import void OPC_TDescDecl (OPT_Struct typ);
import void OPC_TypeDefs (OPT_Object obj, INTEGER vis); import void OPC_TypeDefs (OPT_Object obj, INTEGER vis);
import void OPC_TypeOf (OPT_Object ap); import void OPC_TypeOf (OPT_Object ap);

View file

@ -15,8 +15,8 @@ typedef
static CHAR OPM_SourceFileName[256]; static CHAR OPM_SourceFileName[256];
export INTEGER OPM_Alignment, OPM_ByteSize, OPM_CharSize, OPM_BoolSize, OPM_SIntSize, OPM_IntSize, OPM_LIntSize, OPM_SetSize, OPM_RealSize, OPM_LRealSize, OPM_PointerSize, OPM_ProcSize, OPM_RecSize, OPM_CharAlign, OPM_BoolAlign, OPM_SIntAlign, OPM_IntAlign, OPM_LIntAlign, OPM_SetAlign, OPM_RealAlign, OPM_LRealAlign, OPM_PointerAlign, OPM_ProcAlign, OPM_RecAlign, OPM_MaxSet; export INTEGER OPM_Alignment, OPM_ByteSize, OPM_CharSize, OPM_BoolSize, OPM_SIntSize, OPM_IntSize, OPM_LIntSize, OPM_SetSize, OPM_RealSize, OPM_LRealSize, OPM_PointerSize, OPM_ProcSize, OPM_RecSize, OPM_MaxSet;
export LONGINT OPM_MinSInt, OPM_MinInt, OPM_MinLInt, OPM_MaxSInt, OPM_MaxInt, OPM_MaxLInt, OPM_MaxIndex; export LONGINT OPM_MaxIndex;
export LONGREAL OPM_MinReal, OPM_MaxReal, OPM_MinLReal, OPM_MaxLReal; export LONGREAL OPM_MinReal, OPM_MaxReal, OPM_MinLReal, OPM_MaxLReal;
export BOOLEAN OPM_noerr; export BOOLEAN OPM_noerr;
export LONGINT OPM_curpos, OPM_errpos, OPM_breakpc; export LONGINT OPM_curpos, OPM_errpos, OPM_breakpc;
@ -37,7 +37,6 @@ static CHAR OPM_OBERON[1024];
static CHAR OPM_MODULES[1024]; static CHAR OPM_MODULES[1024];
export INTEGER OPM_AlignSize (LONGINT size);
static void OPM_Append (Files_Rider *R, LONGINT *R__typ, Files_File F); static void OPM_Append (Files_Rider *R, LONGINT *R__typ, Files_File F);
export void OPM_CloseFiles (void); export void OPM_CloseFiles (void);
export void OPM_CloseOldSym (void); export void OPM_CloseOldSym (void);
@ -66,6 +65,8 @@ export BOOLEAN OPM_OpenPar (void);
export void OPM_RegisterNewSym (void); export void OPM_RegisterNewSym (void);
static void OPM_ScanOptions (CHAR *s, LONGINT s__len, SET *opt); static void OPM_ScanOptions (CHAR *s, LONGINT s__len, SET *opt);
static void OPM_ShowLine (LONGINT pos); static void OPM_ShowLine (LONGINT pos);
export LONGINT OPM_SignedMaximum (LONGINT bytecount);
export LONGINT OPM_SignedMinimum (LONGINT bytecount);
export void OPM_SymRCh (CHAR *ch); export void OPM_SymRCh (CHAR *ch);
export LONGINT OPM_SymRInt (void); export LONGINT OPM_SymRInt (void);
export void OPM_SymRLReal (LONGREAL *lr); export void OPM_SymRLReal (LONGREAL *lr);
@ -606,111 +607,62 @@ static void OPM_VerboseListSizes (void)
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"CHAR ", (LONGINT)14); OPM_LogWStr((CHAR*)"CHAR ", (LONGINT)14);
OPM_LogWNum(OPM_CharSize, ((LONGINT)(4))); OPM_LogWNum(OPM_CharSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_CharAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"BOOLEAN ", (LONGINT)14); OPM_LogWStr((CHAR*)"BOOLEAN ", (LONGINT)14);
OPM_LogWNum(OPM_BoolSize, ((LONGINT)(4))); OPM_LogWNum(OPM_BoolSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_BoolAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"SHORTINT ", (LONGINT)14); OPM_LogWStr((CHAR*)"SHORTINT ", (LONGINT)14);
OPM_LogWNum(OPM_SIntSize, ((LONGINT)(4))); OPM_LogWNum(OPM_SIntSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_SIntAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"INTEGER ", (LONGINT)14); OPM_LogWStr((CHAR*)"INTEGER ", (LONGINT)14);
OPM_LogWNum(OPM_IntSize, ((LONGINT)(4))); OPM_LogWNum(OPM_IntSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_IntAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"LONGINT ", (LONGINT)14); OPM_LogWStr((CHAR*)"LONGINT ", (LONGINT)14);
OPM_LogWNum(OPM_LIntSize, ((LONGINT)(4))); OPM_LogWNum(OPM_LIntSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_LIntAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"SET ", (LONGINT)14); OPM_LogWStr((CHAR*)"SET ", (LONGINT)14);
OPM_LogWNum(OPM_SetSize, ((LONGINT)(4))); OPM_LogWNum(OPM_SetSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_SetAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"REAL ", (LONGINT)14); OPM_LogWStr((CHAR*)"REAL ", (LONGINT)14);
OPM_LogWNum(OPM_RealSize, ((LONGINT)(4))); OPM_LogWNum(OPM_RealSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_RealAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"LONGREAL ", (LONGINT)14); OPM_LogWStr((CHAR*)"LONGREAL ", (LONGINT)14);
OPM_LogWNum(OPM_LRealSize, ((LONGINT)(4))); OPM_LogWNum(OPM_LRealSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_LRealAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"PTR ", (LONGINT)14); OPM_LogWStr((CHAR*)"PTR ", (LONGINT)14);
OPM_LogWNum(OPM_PointerSize, ((LONGINT)(4))); OPM_LogWNum(OPM_PointerSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_PointerAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"PROC ", (LONGINT)14); OPM_LogWStr((CHAR*)"PROC ", (LONGINT)14);
OPM_LogWNum(OPM_ProcSize, ((LONGINT)(4))); OPM_LogWNum(OPM_ProcSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_ProcAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"RECORD ", (LONGINT)14); OPM_LogWStr((CHAR*)"RECORD ", (LONGINT)14);
OPM_LogWNum(OPM_RecSize, ((LONGINT)(4))); OPM_LogWNum(OPM_RecSize, ((LONGINT)(4)));
OPM_LogWNum(OPM_RecAlign, ((LONGINT)(5)));
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWLn(); OPM_LogWLn();
OPM_LogWStr((CHAR*)"Min shortint ", (LONGINT)14);
OPM_LogWNum(OPM_MinSInt, ((LONGINT)(4)));
OPM_LogWLn();
OPM_LogWStr((CHAR*)"Max shortint ", (LONGINT)14);
OPM_LogWNum(OPM_MaxSInt, ((LONGINT)(4)));
OPM_LogWLn();
OPM_LogWStr((CHAR*)"Min integer ", (LONGINT)14);
OPM_LogWNum(OPM_MinInt, ((LONGINT)(4)));
OPM_LogWLn();
OPM_LogWStr((CHAR*)"Max integer ", (LONGINT)14);
OPM_LogWNum(OPM_MaxInt, ((LONGINT)(4)));
OPM_LogWLn();
OPM_LogWStr((CHAR*)"Min longint ", (LONGINT)14);
OPM_LogWNum(OPM_MinLInt, ((LONGINT)(4)));
OPM_LogWLn();
} }
INTEGER OPM_AlignSize (LONGINT size) LONGINT OPM_SignedMaximum (LONGINT bytecount)
{ {
INTEGER _o_result; LONGINT _o_result;
INTEGER align; LONGINT result;
if (size < (LONGINT)OPM_Alignment) { result = 1;
if (size > 8) { result = __LSH(result, __ASHL(bytecount, 3) - 1, LONGINT);
align = 16; _o_result = result - 1;
} else if (size > 4) { return _o_result;
align = 8; }
} else if (size > 2) {
align = 4; LONGINT OPM_SignedMinimum (LONGINT bytecount)
} else { {
align = (int)size; LONGINT _o_result;
} _o_result = -OPM_SignedMaximum(bytecount) - 1;
} else {
align = OPM_Alignment;
}
_o_result = align;
return _o_result; return _o_result;
} }
static void OPM_GetProperties (void) static void OPM_GetProperties (void)
{ {
LONGINT base;
OPM_ProcSize = OPM_PointerSize; OPM_ProcSize = OPM_PointerSize;
OPM_LIntSize = __ASHL(OPM_IntSize, 1); OPM_LIntSize = __ASHL(OPM_IntSize, 1);
OPM_SetSize = OPM_LIntSize; OPM_SetSize = OPM_LIntSize;
OPM_CharAlign = OPM_AlignSize(OPM_CharSize);
OPM_BoolAlign = OPM_AlignSize(OPM_BoolSize);
OPM_SIntAlign = OPM_AlignSize(OPM_SIntSize);
OPM_RecAlign = OPM_AlignSize(OPM_RecSize);
OPM_RealAlign = OPM_AlignSize(OPM_RealSize);
OPM_LRealAlign = OPM_AlignSize(OPM_LRealSize);
OPM_PointerAlign = OPM_AlignSize(OPM_PointerSize);
OPM_ProcAlign = OPM_AlignSize(OPM_ProcSize);
OPM_IntAlign = OPM_AlignSize(OPM_IntSize);
OPM_LIntAlign = OPM_AlignSize(OPM_LIntSize);
OPM_SetAlign = OPM_AlignSize(OPM_SetSize);
base = -2;
OPM_MinSInt = __ASH(base, __ASHL(OPM_SIntSize, 3) - 2);
OPM_MaxSInt = OPM_minusop(OPM_MinSInt + 1);
OPM_MinInt = __ASH(base, __ASHL(OPM_IntSize, 3) - 2);
OPM_MaxInt = OPM_minusop(OPM_MinInt + 1);
OPM_MinLInt = __ASH(base, __ASHL(OPM_LIntSize, 3) - 2);
OPM_MaxLInt = OPM_minusop(OPM_MinLInt + 1);
if (OPM_RealSize == 4) { if (OPM_RealSize == 4) {
OPM_MaxReal = 3.40282346000000e+038; OPM_MaxReal = 3.40282346000000e+038;
} else if (OPM_RealSize == 8) { } else if (OPM_RealSize == 8) {
@ -724,7 +676,7 @@ static void OPM_GetProperties (void)
OPM_MinReal = -OPM_MaxReal; OPM_MinReal = -OPM_MaxReal;
OPM_MinLReal = -OPM_MaxLReal; OPM_MinLReal = -OPM_MaxLReal;
OPM_MaxSet = __ASHL(OPM_SetSize, 3) - 1; OPM_MaxSet = __ASHL(OPM_SetSize, 3) - 1;
OPM_MaxIndex = OPM_MaxLInt; OPM_MaxIndex = OPM_SignedMaximum(OPM_PointerSize);
if (OPM_Verbose) { if (OPM_Verbose) {
OPM_VerboseListSizes(); OPM_VerboseListSizes();
} }
@ -886,7 +838,7 @@ void OPM_WriteInt (LONGINT i)
{ {
CHAR s[20]; CHAR s[20];
LONGINT i1, k; LONGINT i1, k;
if (i == OPM_MinInt || i == OPM_MinLInt) { if (i == OPM_SignedMinimum(OPM_IntSize) || i == OPM_SignedMinimum(OPM_LIntSize)) {
OPM_Write('('); OPM_Write('(');
OPM_WriteInt(i + 1); OPM_WriteInt(i + 1);
OPM_WriteString((CHAR*)"-1)", (LONGINT)4); OPM_WriteString((CHAR*)"-1)", (LONGINT)4);
@ -919,7 +871,7 @@ void OPM_WriteReal (LONGREAL r, CHAR suffx)
CHAR s[32]; CHAR s[32];
CHAR ch; CHAR ch;
INTEGER i; INTEGER i;
if ((((r < OPM_MaxLInt && r > OPM_MinLInt)) && r == (__ENTIER(r)))) { if ((((r < OPM_SignedMaximum(OPM_LIntSize) && r > OPM_SignedMinimum(OPM_LIntSize))) && r == (__ENTIER(r)))) {
if (suffx == 'f') { if (suffx == 'f') {
OPM_WriteString((CHAR*)"(REAL)", (LONGINT)7); OPM_WriteString((CHAR*)"(REAL)", (LONGINT)7);
} else { } else {

View file

@ -7,8 +7,8 @@
#include "SYSTEM.h" #include "SYSTEM.h"
import INTEGER OPM_Alignment, OPM_ByteSize, OPM_CharSize, OPM_BoolSize, OPM_SIntSize, OPM_IntSize, OPM_LIntSize, OPM_SetSize, OPM_RealSize, OPM_LRealSize, OPM_PointerSize, OPM_ProcSize, OPM_RecSize, OPM_CharAlign, OPM_BoolAlign, OPM_SIntAlign, OPM_IntAlign, OPM_LIntAlign, OPM_SetAlign, OPM_RealAlign, OPM_LRealAlign, OPM_PointerAlign, OPM_ProcAlign, OPM_RecAlign, OPM_MaxSet; import INTEGER OPM_Alignment, OPM_ByteSize, OPM_CharSize, OPM_BoolSize, OPM_SIntSize, OPM_IntSize, OPM_LIntSize, OPM_SetSize, OPM_RealSize, OPM_LRealSize, OPM_PointerSize, OPM_ProcSize, OPM_RecSize, OPM_MaxSet;
import LONGINT OPM_MinSInt, OPM_MinInt, OPM_MinLInt, OPM_MaxSInt, OPM_MaxInt, OPM_MaxLInt, OPM_MaxIndex; import LONGINT OPM_MaxIndex;
import LONGREAL OPM_MinReal, OPM_MaxReal, OPM_MinLReal, OPM_MaxLReal; import LONGREAL OPM_MinReal, OPM_MaxReal, OPM_MinLReal, OPM_MaxLReal;
import BOOLEAN OPM_noerr; import BOOLEAN OPM_noerr;
import LONGINT OPM_curpos, OPM_errpos, OPM_breakpc; import LONGINT OPM_curpos, OPM_errpos, OPM_breakpc;
@ -19,7 +19,6 @@ import SET OPM_opt, OPM_glbopt;
import BOOLEAN OPM_dontAsm, OPM_dontLink, OPM_mainProg, OPM_mainLinkStat, OPM_notColorOutput, OPM_forceNewSym, OPM_Verbose; import BOOLEAN OPM_dontAsm, OPM_dontLink, OPM_mainProg, OPM_mainLinkStat, OPM_notColorOutput, OPM_forceNewSym, OPM_Verbose;
import INTEGER OPM_AlignSize (LONGINT size);
import void OPM_CloseFiles (void); import void OPM_CloseFiles (void);
import void OPM_CloseOldSym (void); import void OPM_CloseOldSym (void);
import void OPM_DeleteNewSym (void); import void OPM_DeleteNewSym (void);
@ -40,6 +39,8 @@ import void OPM_OldSym (CHAR *modName, LONGINT modName__len, BOOLEAN *done);
import void OPM_OpenFiles (CHAR *moduleName, LONGINT moduleName__len); import void OPM_OpenFiles (CHAR *moduleName, LONGINT moduleName__len);
import BOOLEAN OPM_OpenPar (void); import BOOLEAN OPM_OpenPar (void);
import void OPM_RegisterNewSym (void); import void OPM_RegisterNewSym (void);
import LONGINT OPM_SignedMaximum (LONGINT bytecount);
import LONGINT OPM_SignedMinimum (LONGINT bytecount);
import void OPM_SymRCh (CHAR *ch); import void OPM_SymRCh (CHAR *ch);
import LONGINT OPM_SymRInt (void); import LONGINT OPM_SymRInt (void);
import void OPM_SymRLReal (LONGREAL *lr); import void OPM_SymRLReal (LONGREAL *lr);

View file

@ -83,7 +83,7 @@ void OPV_TypSize (OPT_Struct typ)
btyp = typ->BaseTyp; btyp = typ->BaseTyp;
if (btyp == NIL) { if (btyp == NIL) {
offset = 0; offset = 0;
base = OPM_RecAlign; base = OPC_SizeAlignment(OPM_RecSize);
} else { } else {
OPV_TypSize(btyp); OPV_TypSize(btyp);
offset = btyp->size - (LONGINT)__ASHR(btyp->sysflag, 8); offset = btyp->size - (LONGINT)__ASHR(btyp->sysflag, 8);
@ -94,7 +94,7 @@ void OPV_TypSize (OPT_Struct typ)
btyp = fld->typ; btyp = fld->typ;
OPV_TypSize(btyp); OPV_TypSize(btyp);
size = btyp->size; size = btyp->size;
fbase = OPC_Base(btyp); fbase = OPC_BaseAlignment(btyp);
OPC_Align(&offset, fbase); OPC_Align(&offset, fbase);
fld->adr = offset; fld->adr = offset;
offset += size; offset += size;
@ -108,7 +108,7 @@ void OPV_TypSize (OPT_Struct typ)
offset = 1; offset = 1;
} }
if (OPM_RecSize == 0) { if (OPM_RecSize == 0) {
base = OPV_NaturalAlignment(offset, OPM_RecAlign); base = OPV_NaturalAlignment(offset, OPC_SizeAlignment(OPM_RecSize));
} }
OPC_Align(&offset, base); OPC_Align(&offset, base);
if ((typ->strobj == NIL && __MASK(typ->align, -65536) == 0)) { if ((typ->strobj == NIL && __MASK(typ->align, -65536) == 0)) {
@ -492,7 +492,7 @@ static void OPV_Convert (OPT_Node n, INTEGER form, INTEGER prec)
OPM_Write('('); OPM_Write('(');
OPV_Entier(n, -1); OPV_Entier(n, -1);
OPM_WriteString((CHAR*)", ", (LONGINT)3); OPM_WriteString((CHAR*)", ", (LONGINT)3);
OPM_WriteInt(OPM_MaxInt + 1); OPM_WriteInt(OPM_SignedMaximum(OPM_IntSize) + 1);
OPM_Write(')'); OPM_Write(')');
} else { } else {
OPM_WriteString((CHAR*)"(int)", (LONGINT)6); OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
@ -508,7 +508,7 @@ static void OPV_Convert (OPT_Node n, INTEGER form, INTEGER prec)
OPM_Write('('); OPM_Write('(');
OPV_Entier(n, -1); OPV_Entier(n, -1);
OPM_WriteString((CHAR*)", ", (LONGINT)3); OPM_WriteString((CHAR*)", ", (LONGINT)3);
OPM_WriteInt(OPM_MaxSInt + 1); OPM_WriteInt(OPM_SignedMaximum(OPM_SIntSize) + 1);
OPM_Write(')'); OPM_Write(')');
} else { } else {
OPM_WriteString((CHAR*)"(int)", (LONGINT)6); OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
@ -796,7 +796,7 @@ static void OPV_ActualPar (OPT_Node n, OPT_Object fp)
} }
if ((((mode == 2 && n->class == 11)) && n->subcl == 29)) { if ((((mode == 2 && n->class == 11)) && n->subcl == 29)) {
OPV_expr(n->left, prec); OPV_expr(n->left, prec);
} else if ((((((form == 6 && n->class == 7)) && n->conval->intval <= OPM_MaxInt)) && n->conval->intval >= OPM_MinInt)) { } else if ((((((form == 6 && n->class == 7)) && n->conval->intval <= OPM_SignedMaximum(OPM_IntSize))) && n->conval->intval >= OPM_SignedMinimum(OPM_IntSize))) {
OPM_WriteString((CHAR*)"((LONGINT)(", (LONGINT)12); OPM_WriteString((CHAR*)"((LONGINT)(", (LONGINT)12);
OPV_expr(n, prec); OPV_expr(n, prec);
OPM_WriteString((CHAR*)"))", (LONGINT)3); OPM_WriteString((CHAR*)"))", (LONGINT)3);
@ -1323,7 +1323,7 @@ static void OPV_NewArr (OPT_Node d, OPT_Node x)
OPM_WriteInt(base->size); OPM_WriteInt(base->size);
OPM_WriteString((CHAR*)"))", (LONGINT)3); OPM_WriteString((CHAR*)"))", (LONGINT)3);
OPM_WriteString((CHAR*)", ", (LONGINT)3); OPM_WriteString((CHAR*)", ", (LONGINT)3);
OPM_WriteInt(OPC_Base(base)); OPM_WriteInt(OPC_BaseAlignment(base));
OPM_WriteString((CHAR*)", ", (LONGINT)3); OPM_WriteString((CHAR*)", ", (LONGINT)3);
OPM_WriteInt(nofdim); OPM_WriteInt(nofdim);
OPM_WriteString((CHAR*)", ", (LONGINT)3); OPM_WriteString((CHAR*)", ", (LONGINT)3);

View file

@ -108,18 +108,6 @@ MODULE OPB; (* RC 6.3.89 / 21.2.94 *) (* object model 17.1.93 *)
(* Integer size support *) (* Integer size support *)
PROCEDURE SignedMaximum(bytecount: LONGINT): LONGINT;
VAR result: LONGINT;
BEGIN
result := 1;
result := SYSTEM.LSH(result, bytecount*8-1);
RETURN result - 1;
END SignedMaximum;
PROCEDURE SignedMinimum(bytecount: LONGINT): LONGINT;
BEGIN RETURN -SignedMaximum(bytecount) - 1
END SignedMinimum;
PROCEDURE SignedByteSize(n: LONGINT): INTEGER; PROCEDURE SignedByteSize(n: LONGINT): INTEGER;
(* Returns number of bytes required to represent signed value n *) (* Returns number of bytes required to represent signed value n *)
VAR b: INTEGER; VAR b: INTEGER;
@ -1016,7 +1004,7 @@ MODULE OPB; (* RC 6.3.89 / 21.2.94 *) (* object model 17.1.93 *)
| OPM.Char: x := NewIntConst(0); x^.typ := OPT.chartyp | OPM.Char: x := NewIntConst(0); x^.typ := OPT.chartyp
| OPM.SInt, | OPM.SInt,
OPM.Int, OPM.Int,
OPM.LInt: x := NewIntConst(SignedMinimum(x.typ.size)) OPM.LInt: x := NewIntConst(OPM.SignedMinimum(x.typ.size))
| OPM.Set: x := NewIntConst(0); x^.typ := OPT.inttyp | OPM.Set: x := NewIntConst(0); x^.typ := OPT.inttyp
| OPM.Real: x := NewRealConst(OPM.MinReal, OPT.realtyp) | OPM.Real: x := NewRealConst(OPM.MinReal, OPT.realtyp)
| OPM.LReal: x := NewRealConst(OPM.MinLReal, OPT.lrltyp) | OPM.LReal: x := NewRealConst(OPM.MinLReal, OPT.lrltyp)
@ -1031,7 +1019,7 @@ MODULE OPB; (* RC 6.3.89 / 21.2.94 *) (* object model 17.1.93 *)
| OPM.Char: x := NewIntConst(0FFH); x^.typ := OPT.chartyp | OPM.Char: x := NewIntConst(0FFH); x^.typ := OPT.chartyp
| OPM.SInt, | OPM.SInt,
OPM.Int, OPM.Int,
OPM.LInt: x := NewIntConst(SignedMaximum(x.typ.size)) OPM.LInt: x := NewIntConst(OPM.SignedMaximum(x.typ.size))
| OPM.Set: x := NewIntConst(OPM.MaxSet); x^.typ := OPT.inttyp | OPM.Set: x := NewIntConst(OPM.MaxSet); x^.typ := OPT.inttyp
| OPM.Real: x := NewRealConst(OPM.MaxReal, OPT.realtyp) | OPM.Real: x := NewRealConst(OPM.MaxReal, OPT.realtyp)
| OPM.LReal: x := NewRealConst(OPM.MaxLReal, OPT.lrltyp) | OPM.LReal: x := NewRealConst(OPM.MaxLReal, OPT.lrltyp)

View file

@ -574,6 +574,7 @@ MODULE OPC; (* copyright (c) J. Templ 12.7.95 / 3.7.96 *)
END END
END Align; END Align;
(*
PROCEDURE Base0(typ: OPT.Struct): LONGINT; PROCEDURE Base0(typ: OPT.Struct): LONGINT;
BEGIN BEGIN
CASE typ^.form OF CASE typ^.form OF
@ -594,39 +595,42 @@ MODULE OPC; (* copyright (c) J. Templ 12.7.95 / 3.7.96 *)
ELSE OPM.LogWStr("unhandled case in OPC.BaseAlignment, typ^form = "); OPM.LogWNum(typ^.form, 0); OPM.LogWLn; ELSE OPM.LogWStr("unhandled case in OPC.BaseAlignment, typ^form = "); OPM.LogWNum(typ^.form, 0); OPM.LogWLn;
END END
END Base0; END Base0;
*)
PROCEDURE SizeAlignment*(size: LONGINT): LONGINT;
VAR alignment: LONGINT;
BEGIN
IF size < OPM.Alignment THEN
(* Round up to next power of 2 *)
alignment := 1; WHILE alignment < size DO alignment := alignment * 2 END;
ELSE
alignment := OPM.Alignment
END;
RETURN alignment
END SizeAlignment;
PROCEDURE BaseAlignment*(typ: OPT.Struct): LONGINT; PROCEDURE BaseAlignment*(typ: OPT.Struct): LONGINT;
VAR align, result: LONGINT; VAR alignment: LONGINT;
BEGIN BEGIN
IF typ.form = OPM.Comp THEN IF typ.form = OPM.Comp THEN
IF typ.comp = OPM.Record THEN IF typ.comp = OPM.Record THEN
result := typ.align MOD 10000H alignment := typ.align MOD 10000H
ELSE ELSE
result := BaseAlignment(typ.BaseTyp) alignment := BaseAlignment(typ.BaseTyp)
END END
ELSE ELSE
(* Not a compound type *) (* Not a compound type, determine alignment from size *)
result := Base0(typ); alignment := SizeAlignment(typ.size)
(*
(* Now determine alignment from size *) IF alignment # Base0(typ) THEN
IF typ.size < OPM.Alignment THEN
(* Round up to next power of 2 *)
align := 1; WHILE align < typ.size DO align := align * 2 END;
ELSE
align := OPM.Alignment
END;
IF align # result THEN
OPM.LogWStr("BaseAlignment. typ.form "); OPM.LogWNum(typ.form,1); OPM.LogWStr("BaseAlignment. typ.form "); OPM.LogWNum(typ.form,1);
OPM.LogWStr(", typ.size "); OPM.LogWNum(typ.size,1); OPM.LogWStr(", typ.size "); OPM.LogWNum(typ.size,1);
OPM.LogWStr(", old alignment "); OPM.LogWNum(result,1); OPM.LogWStr(", old alignment "); OPM.LogWNum(alignment,1);
OPM.LogWStr(", alignment based on size "); OPM.LogWNum(align,1); OPM.LogWLn OPM.LogWStr(", alignment based on size "); OPM.LogWNum(align,1); OPM.LogWLn
END; END;
ASSERT(align = result) *)
END; END;
RETURN alignment
RETURN result
END BaseAlignment; END BaseAlignment;

View file

@ -210,11 +210,16 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
ByteSize*, CharSize*, BoolSize*, SIntSize*, IntSize*, ByteSize*, CharSize*, BoolSize*, SIntSize*, IntSize*,
LIntSize*, SetSize*, RealSize*, LRealSize*, PointerSize*, ProcSize*, RecSize*, LIntSize*, SetSize*, RealSize*, LRealSize*, PointerSize*, ProcSize*, RecSize*,
(*
CharAlign*, BoolAlign*, SIntAlign*, IntAlign*, CharAlign*, BoolAlign*, SIntAlign*, IntAlign*,
LIntAlign*, SetAlign*, RealAlign*, LRealAlign*, PointerAlign*, ProcAlign*, RecAlign*, LIntAlign*, SetAlign*, RealAlign*, LRealAlign*, PointerAlign*, ProcAlign*, RecAlign*,
*)
MaxSet*: INTEGER; MaxSet*: INTEGER;
MinSInt*, MinInt*, MinLInt*, MaxSInt*, MaxInt*, MaxLInt*, MaxIndex*: LONGINT; (*
MinSInt*, MinInt*, MinLInt*, MaxSInt*, MaxInt*, MaxLInt*,
*)
MaxIndex*: LONGINT;
MinReal*, MaxReal*, MinLReal*, MaxLReal*: LONGREAL; MinReal*, MaxReal*, MinLReal*, MaxLReal*: LONGREAL;
@ -645,27 +650,30 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
BEGIN BEGIN
LogWLn; LogWLn;
LogWStr("Type Size Alignement"); LogWLn; LogWStr("Type Size Alignement"); LogWLn;
LogWStr("CHAR "); LogWNum(CharSize, 4); LogWNum(CharAlign, 5); LogWLn; LogWStr("CHAR "); LogWNum(CharSize, 4); (* LogWNum(CharAlign, 5); *) LogWLn;
LogWStr("BOOLEAN "); LogWNum(BoolSize, 4); LogWNum(BoolAlign, 5); LogWLn; LogWStr("BOOLEAN "); LogWNum(BoolSize, 4); (* LogWNum(BoolAlign, 5); *) LogWLn;
LogWStr("SHORTINT "); LogWNum(SIntSize, 4); LogWNum(SIntAlign, 5); LogWLn; LogWStr("SHORTINT "); LogWNum(SIntSize, 4); (* LogWNum(SIntAlign, 5); *) LogWLn;
LogWStr("INTEGER "); LogWNum(IntSize, 4); LogWNum(IntAlign, 5); LogWLn; LogWStr("INTEGER "); LogWNum(IntSize, 4); (* LogWNum(IntAlign, 5); *) LogWLn;
LogWStr("LONGINT "); LogWNum(LIntSize, 4); LogWNum(LIntAlign, 5); LogWLn; LogWStr("LONGINT "); LogWNum(LIntSize, 4); (* LogWNum(LIntAlign, 5); *) LogWLn;
LogWStr("SET "); LogWNum(SetSize, 4); LogWNum(SetAlign, 5); LogWLn; LogWStr("SET "); LogWNum(SetSize, 4); (* LogWNum(SetAlign, 5); *) LogWLn;
LogWStr("REAL "); LogWNum(RealSize, 4); LogWNum(RealAlign, 5); LogWLn; LogWStr("REAL "); LogWNum(RealSize, 4); (* LogWNum(RealAlign, 5); *) LogWLn;
LogWStr("LONGREAL "); LogWNum(LRealSize, 4); LogWNum(LRealAlign, 5); LogWLn; LogWStr("LONGREAL "); LogWNum(LRealSize, 4); (* LogWNum(LRealAlign, 5); *) LogWLn;
LogWStr("PTR "); LogWNum(PointerSize, 4); LogWNum(PointerAlign, 5); LogWLn; LogWStr("PTR "); LogWNum(PointerSize, 4); (* LogWNum(PointerAlign, 5); *) LogWLn;
LogWStr("PROC "); LogWNum(ProcSize, 4); LogWNum(ProcAlign, 5); LogWLn; LogWStr("PROC "); LogWNum(ProcSize, 4); (* LogWNum(ProcAlign, 5); *) LogWLn;
LogWStr("RECORD "); LogWNum(RecSize, 4); LogWNum(RecAlign, 5); LogWLn; LogWStr("RECORD "); LogWNum(RecSize, 4); (* LogWNum(RecAlign, 5); *) LogWLn;
(*LogWStr("ENDIAN "); LogWNum(ByteOrder, 4); LogWNum(BitOrder, 5); LogWLn;*) (*LogWStr("ENDIAN "); LogWNum(ByteOrder, 4); LogWNum(BitOrder, 5); LogWLn;*)
LogWLn; LogWLn;
(*
LogWStr("Min shortint "); LogWNum(MinSInt, 4); LogWLn; LogWStr("Min shortint "); LogWNum(MinSInt, 4); LogWLn;
LogWStr("Max shortint "); LogWNum(MaxSInt, 4); LogWLn; LogWStr("Max shortint "); LogWNum(MaxSInt, 4); LogWLn;
LogWStr("Min integer "); LogWNum(MinInt, 4); LogWLn; LogWStr("Min integer "); LogWNum(MinInt, 4); LogWLn;
LogWStr("Max integer "); LogWNum(MaxInt, 4); LogWLn; LogWStr("Max integer "); LogWNum(MaxInt, 4); LogWLn;
LogWStr("Min longint "); LogWNum(MinLInt, 4); LogWLn; LogWStr("Min longint "); LogWNum(MinLInt, 4); LogWLn;
*)
END VerboseListSizes; END VerboseListSizes;
(*
PROCEDURE AlignSize*(size: LONGINT): INTEGER; PROCEDURE AlignSize*(size: LONGINT): INTEGER;
VAR align: INTEGER; VAR align: INTEGER;
BEGIN BEGIN
@ -680,10 +688,25 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
END; END;
RETURN align RETURN align
END AlignSize; END AlignSize;
*)
PROCEDURE SignedMaximum*(bytecount: LONGINT): LONGINT;
VAR result: LONGINT;
BEGIN
result := 1;
result := SYSTEM.LSH(result, bytecount*8-1);
RETURN result - 1;
END SignedMaximum;
PROCEDURE SignedMinimum*(bytecount: LONGINT): LONGINT;
BEGIN RETURN -SignedMaximum(bytecount) - 1
END SignedMinimum;
PROCEDURE GetProperties(); PROCEDURE GetProperties();
VAR (* VAR base: LONGINT; *)
base: LONGINT;
BEGIN BEGIN
(* Fixed and Configuration.Mod based sizes have been initialised in (* Fixed and Configuration.Mod based sizes have been initialised in
the module startup code, and maybe overridden by the -Bnnn bootstrap the module startup code, and maybe overridden by the -Bnnn bootstrap
@ -695,6 +718,7 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
SetSize := LIntSize; SetSize := LIntSize;
(* Calculate all type alignments *) (* Calculate all type alignments *)
(*
CharAlign := AlignSize(CharSize); CharAlign := AlignSize(CharSize);
BoolAlign := AlignSize(BoolSize); BoolAlign := AlignSize(BoolSize);
SIntAlign := AlignSize(SIntSize); SIntAlign := AlignSize(SIntSize);
@ -706,8 +730,9 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
IntAlign := AlignSize(IntSize); IntAlign := AlignSize(IntSize);
LIntAlign := AlignSize(LIntSize); LIntAlign := AlignSize(LIntSize);
SetAlign := AlignSize(SetSize); SetAlign := AlignSize(SetSize);
*)
(* and I'd like to calculate it, not hardcode constants *) (*
base := -2; base := -2;
MinSInt := ASH(base, SIntSize*8-2); MinSInt := ASH(base, SIntSize*8-2);
MaxSInt := minusop(MinSInt + 1); MaxSInt := minusop(MinSInt + 1);
@ -717,6 +742,7 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
MinLInt := ASH(base, LIntSize*8-2); MinLInt := ASH(base, LIntSize*8-2);
MaxLInt := minusop(MinLInt +1); MaxLInt := minusop(MinLInt +1);
*)
IF RealSize = 4 THEN MaxReal := 3.40282346D38 IF RealSize = 4 THEN MaxReal := 3.40282346D38
ELSIF RealSize = 8 THEN MaxReal := 1.7976931348623157D307 * 9.999999 ELSIF RealSize = 8 THEN MaxReal := 1.7976931348623157D307 * 9.999999
@ -732,16 +758,17 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
MinLReal := -MaxLReal; MinLReal := -MaxLReal;
MaxSet := SetSize * 8 - 1; MaxSet := SetSize * 8 - 1;
(*
MaxIndex := MaxLInt; (* shouldn't it be like max(int)? so that for loop will be safe, noch *) MaxIndex := MaxLInt; (* shouldn't it be like max(int)? so that for loop will be safe, noch *)
*)
MaxIndex := SignedMaximum(PointerSize);
IF Verbose THEN VerboseListSizes END; IF Verbose THEN VerboseListSizes END;
END GetProperties; END GetProperties;
(* ------------------------- Read Symbol File ------------------------- *) (* ------------------------- Read Symbol File ------------------------- *)
PROCEDURE SymRCh*(VAR ch: CHAR); PROCEDURE SymRCh*(VAR ch: CHAR);
BEGIN Files.Read(oldSF, ch) BEGIN Files.Read(oldSF, ch)
END SymRCh; END SymRCh;
@ -863,7 +890,7 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
PROCEDURE WriteInt* (i: LONGINT); PROCEDURE WriteInt* (i: LONGINT);
VAR s: ARRAY 20 OF CHAR; i1, k: LONGINT; VAR s: ARRAY 20 OF CHAR; i1, k: LONGINT;
BEGIN BEGIN
IF (i = MinInt) OR (i = MinLInt) THEN IF (i = SignedMinimum(IntSize)) OR (i = SignedMinimum(LIntSize)) THEN
(* abs(minint) is one more than maxint, causing problems representing the value as a minus sign (* abs(minint) is one more than maxint, causing problems representing the value as a minus sign
followed by absoute value. Therefore represent as -maxint - 1. For INTEGER this avoids a followed by absoute value. Therefore represent as -maxint - 1. For INTEGER this avoids a
compiler warning 'this decimal constant is unsigned only in ISO C90', for LONGINT it is the compiler warning 'this decimal constant is unsigned only in ISO C90', for LONGINT it is the
@ -881,7 +908,7 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
VAR W: Texts.Writer; T: Texts.Text; R: Texts.Reader; s: ARRAY 32 OF CHAR; ch: CHAR; i: INTEGER; VAR W: Texts.Writer; T: Texts.Text; R: Texts.Reader; s: ARRAY 32 OF CHAR; ch: CHAR; i: INTEGER;
BEGIN BEGIN
(*should be improved *) (*should be improved *)
IF (r < MaxLInt) & (r > MinLInt) & (r = ENTIER(r)) THEN IF (r < SignedMaximum(LIntSize)) & (r > SignedMinimum(LIntSize)) & (r = ENTIER(r)) THEN
IF suffx = "f" THEN WriteString("(REAL)") ELSE WriteString("(LONGREAL)") END ; IF suffx = "f" THEN WriteString("(REAL)") ELSE WriteString("(LONGREAL)") END ;
WriteInt(ENTIER(r)) WriteInt(ENTIER(r))
ELSE ELSE

View file

@ -76,7 +76,7 @@ MODULE OPV; (* J. Templ 16.2.95 / 3.7.96
ELSIF typ^.size = -1 THEN ELSIF typ^.size = -1 THEN
f := typ^.form; c := typ^.comp; f := typ^.form; c := typ^.comp;
IF c = OPM.Record THEN btyp := typ^.BaseTyp; IF c = OPM.Record THEN btyp := typ^.BaseTyp;
IF btyp = NIL THEN offset := 0; base := OPM.RecAlign; IF btyp = NIL THEN offset := 0; base := (*OPM.RecAlign*)OPC.SizeAlignment(OPM.RecSize);
ELSE TypSize(btyp); offset := btyp^.size - btyp^.sysflag DIV 100H; base := btyp^.align; ELSE TypSize(btyp); offset := btyp^.size - btyp^.sysflag DIV 100H; base := btyp^.align;
END; END;
fld := typ^.link; fld := typ^.link;
@ -90,7 +90,7 @@ MODULE OPV; (* J. Templ 16.2.95 / 3.7.96
END ; END ;
off0 := offset; off0 := offset;
IF offset = 0 THEN offset := 1 END ; (* 1 byte filler to avoid empty struct *) IF offset = 0 THEN offset := 1 END ; (* 1 byte filler to avoid empty struct *)
IF OPM.RecSize = 0 THEN base := NaturalAlignment(offset, OPM.RecAlign) END ; IF OPM.RecSize = 0 THEN base := NaturalAlignment(offset, (*OPM.RecAlign*)OPC.SizeAlignment(OPM.RecSize)) END ;
OPC.Align(offset, base); OPC.Align(offset, base);
IF (typ^.strobj = NIL) & (typ^.align MOD 10000H = 0) THEN INC(recno); INC(base, recno * 10000H) END ; IF (typ^.strobj = NIL) & (typ^.align MOD 10000H = 0) THEN INC(recno); INC(base, recno * 10000H) END ;
typ^.size := offset; typ^.align := base; typ^.size := offset; typ^.align := base;
@ -303,7 +303,7 @@ MODULE OPV; (* J. Templ 16.2.95 / 3.7.96
IF OPM.ranchk IN OPM.opt THEN OPM.WriteString("__SHORT"); IF OPM.ranchk IN OPM.opt THEN OPM.WriteString("__SHORT");
IF SideEffects(n) THEN OPM.Write("F") END ; IF SideEffects(n) THEN OPM.Write("F") END ;
OPM.Write(OpenParen); Entier(n, MinPrec); OPM.Write(OpenParen); Entier(n, MinPrec);
OPM.WriteString(Comma); OPM.WriteInt(OPM.MaxInt + 1); OPM.Write(CloseParen) OPM.WriteString(Comma); OPM.WriteInt(OPM.SignedMaximum(OPM.IntSize) + 1); OPM.Write(CloseParen)
ELSE OPM.WriteString("(int)"); Entier(n, 9) ELSE OPM.WriteString("(int)"); Entier(n, 9)
END END
END END
@ -311,7 +311,7 @@ MODULE OPV; (* J. Templ 16.2.95 / 3.7.96
IF OPM.ranchk IN OPM.opt THEN OPM.WriteString("__SHORT"); IF OPM.ranchk IN OPM.opt THEN OPM.WriteString("__SHORT");
IF SideEffects(n) THEN OPM.Write("F") END ; IF SideEffects(n) THEN OPM.Write("F") END ;
OPM.Write(OpenParen); Entier(n, MinPrec); OPM.Write(OpenParen); Entier(n, MinPrec);
OPM.WriteString(Comma); OPM.WriteInt(OPM.MaxSInt + 1); OPM.Write(CloseParen) OPM.WriteString(Comma); OPM.WriteInt(OPM.SignedMaximum(OPM.SIntSize) + 1); OPM.Write(CloseParen)
ELSE OPM.WriteString("(int)"); Entier(n, 9) ELSE OPM.WriteString("(int)"); Entier(n, 9)
END END
ELSIF form = OPM.Char THEN ELSIF form = OPM.Char THEN
@ -475,7 +475,7 @@ MODULE OPV; (* J. Templ 16.2.95 / 3.7.96
IF (mode = OPM.VarPar) & (n^.class = OPM.Nmop) & (n^.subcl = OPM.val) THEN IF (mode = OPM.VarPar) & (n^.class = OPM.Nmop) & (n^.subcl = OPM.val) THEN
expr(n^.left, prec) (* avoid cast in lvalue *) expr(n^.left, prec) (* avoid cast in lvalue *)
ELSIF (form = OPM.LInt) & (n^.class = OPM.Nconst) ELSIF (form = OPM.LInt) & (n^.class = OPM.Nconst)
& (n^.conval^.intval <= OPM.MaxInt) & (n^.conval^.intval >= OPM.MinInt) THEN & (n^.conval^.intval <= OPM.SignedMaximum(OPM.IntSize)) & (n^.conval^.intval >= OPM.SignedMinimum(OPM.IntSize)) THEN
OPM.WriteString("((LONGINT)("); expr(n, prec); OPM.WriteString("))"); OPM.WriteString("((LONGINT)("); expr(n, prec); OPM.WriteString("))");
ELSE ELSE
expr(n, prec) expr(n, prec)