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);
static LONGINT OPB_ShorterSize (LONGINT i);
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_StPar0 (OPT_Node *par0, INTEGER 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;
}
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)
{
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_Object *obj;
BOOLEAN *guard;
struct TypTest__63 *lnk;
} *TypTest__63_s;
struct TypTest__61 *lnk;
} *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_Struct t = NIL;
@ -470,54 +451,54 @@ static void GTT__64 (OPT_Struct t0, OPT_Struct t1)
t1 = t1->BaseTyp;
}
if (t1 == t0 || t0->form == 0) {
if (*TypTest__63_s->guard) {
OPB_BindNodes(5, NIL, &*TypTest__63_s->x, NIL);
(*TypTest__63_s->x)->readonly = (*TypTest__63_s->x)->left->readonly;
if (*TypTest__61_s->guard) {
OPB_BindNodes(5, NIL, &*TypTest__61_s->x, NIL);
(*TypTest__61_s->x)->readonly = (*TypTest__61_s->x)->left->readonly;
} else {
node = OPT_NewNode(11);
node->subcl = 16;
node->left = *TypTest__63_s->x;
node->obj = *TypTest__63_s->obj;
*TypTest__63_s->x = node;
node->left = *TypTest__61_s->x;
node->obj = *TypTest__61_s->obj;
*TypTest__61_s->x = node;
}
} else {
OPB_err(85);
}
} else if (t0 != t1) {
OPB_err(85);
} else if (!*TypTest__63_s->guard) {
if ((*TypTest__63_s->x)->class == 5) {
} else if (!*TypTest__61_s->guard) {
if ((*TypTest__61_s->x)->class == 5) {
node = OPT_NewNode(11);
node->subcl = 16;
node->left = *TypTest__63_s->x;
node->obj = *TypTest__63_s->obj;
*TypTest__63_s->x = node;
node->left = *TypTest__61_s->x;
node->obj = *TypTest__61_s->obj;
*TypTest__61_s->x = node;
} 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)
{
struct TypTest__63 _s;
struct TypTest__61 _s;
_s.x = x;
_s.obj = &obj;
_s.guard = &guard;
_s.lnk = TypTest__63_s;
TypTest__63_s = &_s;
_s.lnk = TypTest__61_s;
TypTest__61_s = &_s;
if (OPB_NotVar(*x)) {
OPB_err(112);
} else if ((*x)->typ->form == 13) {
if (((*x)->typ->BaseTyp->comp != 4 && (*x)->typ != OPT_sysptrtyp)) {
OPB_err(85);
} else if (obj->typ->form == 13) {
GTT__64((*x)->typ->BaseTyp, obj->typ->BaseTyp);
GTT__62((*x)->typ->BaseTyp, obj->typ->BaseTyp);
} else {
OPB_err(86);
}
} 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 {
OPB_err(87);
}
@ -526,7 +507,7 @@ void OPB_TypTest (OPT_Node *x, OPT_Object obj, BOOLEAN guard)
} else {
(*x)->typ = OPT_booltyp;
}
TypTest__63_s = _s.lnk;
TypTest__61_s = _s.lnk;
}
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;
break;
case 4: case 5: case 6:
x = OPB_NewIntConst(OPB_SignedMinimum(x->typ->size));
x = OPB_NewIntConst(OPM_SignedMinimum(x->typ->size));
break;
case 9:
x = OPB_NewIntConst(((LONGINT)(0)));
@ -1880,7 +1861,7 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno)
x->typ = OPT_chartyp;
break;
case 4: case 5: case 6:
x = OPB_NewIntConst(OPB_SignedMaximum(x->typ->size));
x = OPB_NewIntConst(OPM_SignedMaximum(x->typ->size));
break;
case 9:
x = OPB_NewIntConst(OPM_MaxSet);
@ -2062,13 +2043,13 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno)
*par0 = x;
}
static struct StPar1__58 {
struct StPar1__58 *lnk;
} *StPar1__58_s;
static struct StPar1__56 {
struct StPar1__56 *lnk;
} *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 node = NIL;
@ -2085,9 +2066,9 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
INTEGER f, L;
OPT_Struct typ = NIL;
OPT_Node p = NIL, t = NIL;
struct StPar1__58 _s;
_s.lnk = StPar1__58_s;
StPar1__58_s = &_s;
struct StPar1__56 _s;
_s.lnk = StPar1__56_s;
StPar1__56_s = &_s;
p = *par0;
f = x->typ->form;
switch (fctno) {
@ -2103,7 +2084,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
OPB_err(111);
}
}
p = NewOp__59(19, fctno, p, x);
p = NewOp__57(19, fctno, p, x);
p->typ = OPT_notyp;
}
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))) {
OPB_err(202);
}
p = NewOp__59(19, fctno, p, x);
p = NewOp__57(19, fctno, p, x);
} else {
OPB_err(111);
}
@ -2139,7 +2120,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
p = p->left;
x->conval->intval += 1;
}
p = NewOp__59(12, 19, p, x);
p = NewOp__57(12, 19, p, x);
p->typ = OPT_linttyp;
} else {
p = x;
@ -2161,7 +2142,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
t = x;
x = p;
p = t;
p = NewOp__59(19, 18, p, x);
p = NewOp__57(19, 18, p, x);
} else {
OPB_err(111);
}
@ -2187,7 +2168,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
}
p->obj = NIL;
} else {
p = NewOp__59(12, 17, p, x);
p = NewOp__57(12, 17, p, x);
p->typ = OPT_linttyp;
}
} else {
@ -2218,9 +2199,9 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
OPB_err(111);
} else {
if (fctno == 22) {
p = NewOp__59(12, 27, p, x);
p = NewOp__57(12, 27, p, x);
} else {
p = NewOp__59(12, 28, p, x);
p = NewOp__57(12, 28, p, x);
}
p->typ = p->left->typ;
}
@ -2237,7 +2218,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
x = p;
p = t;
}
p = NewOp__59(19, fctno, p, x);
p = NewOp__57(19, fctno, p, x);
} else {
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) {
OPB_err(126);
} else if (__IN(f, 0x70)) {
p = NewOp__59(12, 26, p, x);
p = NewOp__57(12, 26, p, x);
} else {
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) {
OPB_err(126);
} else if (__IN(f, 0x70)) {
p = NewOp__59(19, 30, p, x);
p = NewOp__57(19, 30, p, x);
} else {
OPB_err(111);
}
@ -2317,7 +2298,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
break;
}
*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)

View file

@ -16,7 +16,7 @@ static CHAR OPC_BodyNameExt[13];
export void OPC_Align (LONGINT *adr, LONGINT base);
export void OPC_Andent (OPT_Struct typ);
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 void OPC_BegBlk (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_RegCmds (OPT_Object obj);
export void OPC_SetInclude (BOOLEAN exclude);
export LONGINT OPC_SizeAlignment (LONGINT size);
static void OPC_Stars (OPT_Struct typ, BOOLEAN *openClause);
static void OPC_Str1 (CHAR *s, LONGINT s__len, LONGINT x);
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;
switch (typ->form) {
case 1:
_o_result = 1;
return _o_result;
break;
case 3:
_o_result = OPM_CharAlign;
return _o_result;
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;
LONGINT alignment;
if (size < (LONGINT)OPM_Alignment) {
alignment = 1;
while (alignment < size) {
alignment = __ASHL(alignment, 1);
}
} else {
alignment = OPM_Alignment;
}
__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)
@ -984,7 +952,7 @@ static void OPC_FieldList (OPT_Struct typ, BOOLEAN last, LONGINT *off, LONGINT *
}
} else {
adr = *off;
fldAlign = OPC_Base(fld->typ);
fldAlign = OPC_BaseAlignment(fld->typ);
OPC_Align(&adr, fldAlign);
gap = fld->adr - adr;
if (fldAlign > *curAlign) {

View file

@ -11,7 +11,7 @@
import void OPC_Align (LONGINT *adr, LONGINT base);
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 void OPC_BegBlk (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 LONGINT OPC_NofPtrs (OPT_Struct typ);
import void OPC_SetInclude (BOOLEAN exclude);
import LONGINT OPC_SizeAlignment (LONGINT size);
import void OPC_TDescDecl (OPT_Struct typ);
import void OPC_TypeDefs (OPT_Object obj, INTEGER vis);
import void OPC_TypeOf (OPT_Object ap);

View file

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

View file

@ -6,8 +6,8 @@
#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 LONGINT OPM_MinSInt, OPM_MinInt, OPM_MinLInt, OPM_MaxSInt, OPM_MaxInt, OPM_MaxLInt, OPM_MaxIndex;
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_MaxIndex;
import LONGREAL OPM_MinReal, OPM_MaxReal, OPM_MinLReal, OPM_MaxLReal;
import BOOLEAN OPM_noerr;
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 INTEGER OPM_AlignSize (LONGINT size);
import void OPM_CloseFiles (void);
import void OPM_CloseOldSym (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 BOOLEAN OPM_OpenPar (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 LONGINT OPM_SymRInt (void);
import void OPM_SymRLReal (LONGREAL *lr);

View file

@ -82,7 +82,7 @@ void OPV_TypSize (OPT_Struct typ)
btyp = typ->BaseTyp;
if (btyp == NIL) {
offset = 0;
base = OPM_RecAlign;
base = OPC_SizeAlignment(OPM_RecSize);
} else {
OPV_TypSize(btyp);
offset = btyp->size - (LONGINT)__ASHR(btyp->sysflag, 8);
@ -93,7 +93,7 @@ void OPV_TypSize (OPT_Struct typ)
btyp = fld->typ;
OPV_TypSize(btyp);
size = btyp->size;
fbase = OPC_Base(btyp);
fbase = OPC_BaseAlignment(btyp);
OPC_Align(&offset, fbase);
fld->adr = offset;
offset += size;
@ -107,7 +107,7 @@ void OPV_TypSize (OPT_Struct typ)
offset = 1;
}
if (OPM_RecSize == 0) {
base = OPV_NaturalAlignment(offset, OPM_RecAlign);
base = OPV_NaturalAlignment(offset, OPC_SizeAlignment(OPM_RecSize));
}
OPC_Align(&offset, base);
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('(');
OPV_Entier(n, -1);
OPM_WriteString((CHAR*)", ", (LONGINT)3);
OPM_WriteInt(OPM_MaxInt + 1);
OPM_WriteInt(OPM_SignedMaximum(OPM_IntSize) + 1);
OPM_Write(')');
} else {
OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
@ -507,7 +507,7 @@ static void OPV_Convert (OPT_Node n, INTEGER form, INTEGER prec)
OPM_Write('(');
OPV_Entier(n, -1);
OPM_WriteString((CHAR*)", ", (LONGINT)3);
OPM_WriteInt(OPM_MaxSInt + 1);
OPM_WriteInt(OPM_SignedMaximum(OPM_SIntSize) + 1);
OPM_Write(')');
} else {
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)) {
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);
OPV_expr(n, prec);
OPM_WriteString((CHAR*)"))", (LONGINT)3);
@ -1322,7 +1322,7 @@ static void OPV_NewArr (OPT_Node d, OPT_Node x)
OPM_WriteInt(base->size);
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_WriteInt(nofdim);
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);
static LONGINT OPB_ShorterSize (LONGINT i);
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_StPar0 (OPT_Node *par0, INTEGER 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;
}
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)
{
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_Object *obj;
BOOLEAN *guard;
struct TypTest__63 *lnk;
} *TypTest__63_s;
struct TypTest__61 *lnk;
} *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_Struct t = NIL;
@ -470,54 +451,54 @@ static void GTT__64 (OPT_Struct t0, OPT_Struct t1)
t1 = t1->BaseTyp;
}
if (t1 == t0 || t0->form == 0) {
if (*TypTest__63_s->guard) {
OPB_BindNodes(5, NIL, &*TypTest__63_s->x, NIL);
(*TypTest__63_s->x)->readonly = (*TypTest__63_s->x)->left->readonly;
if (*TypTest__61_s->guard) {
OPB_BindNodes(5, NIL, &*TypTest__61_s->x, NIL);
(*TypTest__61_s->x)->readonly = (*TypTest__61_s->x)->left->readonly;
} else {
node = OPT_NewNode(11);
node->subcl = 16;
node->left = *TypTest__63_s->x;
node->obj = *TypTest__63_s->obj;
*TypTest__63_s->x = node;
node->left = *TypTest__61_s->x;
node->obj = *TypTest__61_s->obj;
*TypTest__61_s->x = node;
}
} else {
OPB_err(85);
}
} else if (t0 != t1) {
OPB_err(85);
} else if (!*TypTest__63_s->guard) {
if ((*TypTest__63_s->x)->class == 5) {
} else if (!*TypTest__61_s->guard) {
if ((*TypTest__61_s->x)->class == 5) {
node = OPT_NewNode(11);
node->subcl = 16;
node->left = *TypTest__63_s->x;
node->obj = *TypTest__63_s->obj;
*TypTest__63_s->x = node;
node->left = *TypTest__61_s->x;
node->obj = *TypTest__61_s->obj;
*TypTest__61_s->x = node;
} 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)
{
struct TypTest__63 _s;
struct TypTest__61 _s;
_s.x = x;
_s.obj = &obj;
_s.guard = &guard;
_s.lnk = TypTest__63_s;
TypTest__63_s = &_s;
_s.lnk = TypTest__61_s;
TypTest__61_s = &_s;
if (OPB_NotVar(*x)) {
OPB_err(112);
} else if ((*x)->typ->form == 13) {
if (((*x)->typ->BaseTyp->comp != 4 && (*x)->typ != OPT_sysptrtyp)) {
OPB_err(85);
} else if (obj->typ->form == 13) {
GTT__64((*x)->typ->BaseTyp, obj->typ->BaseTyp);
GTT__62((*x)->typ->BaseTyp, obj->typ->BaseTyp);
} else {
OPB_err(86);
}
} 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 {
OPB_err(87);
}
@ -526,7 +507,7 @@ void OPB_TypTest (OPT_Node *x, OPT_Object obj, BOOLEAN guard)
} else {
(*x)->typ = OPT_booltyp;
}
TypTest__63_s = _s.lnk;
TypTest__61_s = _s.lnk;
}
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;
break;
case 4: case 5: case 6:
x = OPB_NewIntConst(OPB_SignedMinimum(x->typ->size));
x = OPB_NewIntConst(OPM_SignedMinimum(x->typ->size));
break;
case 9:
x = OPB_NewIntConst(((LONGINT)(0)));
@ -1880,7 +1861,7 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno)
x->typ = OPT_chartyp;
break;
case 4: case 5: case 6:
x = OPB_NewIntConst(OPB_SignedMaximum(x->typ->size));
x = OPB_NewIntConst(OPM_SignedMaximum(x->typ->size));
break;
case 9:
x = OPB_NewIntConst(OPM_MaxSet);
@ -2062,13 +2043,13 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno)
*par0 = x;
}
static struct StPar1__58 {
struct StPar1__58 *lnk;
} *StPar1__58_s;
static struct StPar1__56 {
struct StPar1__56 *lnk;
} *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 node = NIL;
@ -2085,9 +2066,9 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
INTEGER f, L;
OPT_Struct typ = NIL;
OPT_Node p = NIL, t = NIL;
struct StPar1__58 _s;
_s.lnk = StPar1__58_s;
StPar1__58_s = &_s;
struct StPar1__56 _s;
_s.lnk = StPar1__56_s;
StPar1__56_s = &_s;
p = *par0;
f = x->typ->form;
switch (fctno) {
@ -2103,7 +2084,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
OPB_err(111);
}
}
p = NewOp__59(19, fctno, p, x);
p = NewOp__57(19, fctno, p, x);
p->typ = OPT_notyp;
}
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))) {
OPB_err(202);
}
p = NewOp__59(19, fctno, p, x);
p = NewOp__57(19, fctno, p, x);
} else {
OPB_err(111);
}
@ -2139,7 +2120,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
p = p->left;
x->conval->intval += 1;
}
p = NewOp__59(12, 19, p, x);
p = NewOp__57(12, 19, p, x);
p->typ = OPT_linttyp;
} else {
p = x;
@ -2161,7 +2142,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
t = x;
x = p;
p = t;
p = NewOp__59(19, 18, p, x);
p = NewOp__57(19, 18, p, x);
} else {
OPB_err(111);
}
@ -2187,7 +2168,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
}
p->obj = NIL;
} else {
p = NewOp__59(12, 17, p, x);
p = NewOp__57(12, 17, p, x);
p->typ = OPT_linttyp;
}
} else {
@ -2218,9 +2199,9 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
OPB_err(111);
} else {
if (fctno == 22) {
p = NewOp__59(12, 27, p, x);
p = NewOp__57(12, 27, p, x);
} else {
p = NewOp__59(12, 28, p, x);
p = NewOp__57(12, 28, p, x);
}
p->typ = p->left->typ;
}
@ -2237,7 +2218,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
x = p;
p = t;
}
p = NewOp__59(19, fctno, p, x);
p = NewOp__57(19, fctno, p, x);
} else {
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) {
OPB_err(126);
} else if (__IN(f, 0x70)) {
p = NewOp__59(12, 26, p, x);
p = NewOp__57(12, 26, p, x);
} else {
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) {
OPB_err(126);
} else if (__IN(f, 0x70)) {
p = NewOp__59(19, 30, p, x);
p = NewOp__57(19, 30, p, x);
} else {
OPB_err(111);
}
@ -2317,7 +2298,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
break;
}
*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)

View file

@ -16,7 +16,7 @@ static CHAR OPC_BodyNameExt[13];
export void OPC_Align (LONGINT *adr, LONGINT base);
export void OPC_Andent (OPT_Struct typ);
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 void OPC_BegBlk (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_RegCmds (OPT_Object obj);
export void OPC_SetInclude (BOOLEAN exclude);
export LONGINT OPC_SizeAlignment (LONGINT size);
static void OPC_Stars (OPT_Struct typ, BOOLEAN *openClause);
static void OPC_Str1 (CHAR *s, LONGINT s__len, LONGINT x);
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;
switch (typ->form) {
case 1:
_o_result = 1;
return _o_result;
break;
case 3:
_o_result = OPM_CharAlign;
return _o_result;
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;
LONGINT alignment;
if (size < (LONGINT)OPM_Alignment) {
alignment = 1;
while (alignment < size) {
alignment = __ASHL(alignment, 1);
}
} else {
alignment = OPM_Alignment;
}
__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)
@ -984,7 +952,7 @@ static void OPC_FieldList (OPT_Struct typ, BOOLEAN last, LONGINT *off, LONGINT *
}
} else {
adr = *off;
fldAlign = OPC_Base(fld->typ);
fldAlign = OPC_BaseAlignment(fld->typ);
OPC_Align(&adr, fldAlign);
gap = fld->adr - adr;
if (fldAlign > *curAlign) {

View file

@ -11,7 +11,7 @@
import void OPC_Align (LONGINT *adr, LONGINT base);
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 void OPC_BegBlk (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 LONGINT OPC_NofPtrs (OPT_Struct typ);
import void OPC_SetInclude (BOOLEAN exclude);
import LONGINT OPC_SizeAlignment (LONGINT size);
import void OPC_TDescDecl (OPT_Struct typ);
import void OPC_TypeDefs (OPT_Object obj, INTEGER vis);
import void OPC_TypeOf (OPT_Object ap);

View file

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

View file

@ -6,8 +6,8 @@
#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 LONGINT OPM_MinSInt, OPM_MinInt, OPM_MinLInt, OPM_MaxSInt, OPM_MaxInt, OPM_MaxLInt, OPM_MaxIndex;
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_MaxIndex;
import LONGREAL OPM_MinReal, OPM_MaxReal, OPM_MinLReal, OPM_MaxLReal;
import BOOLEAN OPM_noerr;
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 INTEGER OPM_AlignSize (LONGINT size);
import void OPM_CloseFiles (void);
import void OPM_CloseOldSym (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 BOOLEAN OPM_OpenPar (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 LONGINT OPM_SymRInt (void);
import void OPM_SymRLReal (LONGREAL *lr);

View file

@ -82,7 +82,7 @@ void OPV_TypSize (OPT_Struct typ)
btyp = typ->BaseTyp;
if (btyp == NIL) {
offset = 0;
base = OPM_RecAlign;
base = OPC_SizeAlignment(OPM_RecSize);
} else {
OPV_TypSize(btyp);
offset = btyp->size - (LONGINT)__ASHR(btyp->sysflag, 8);
@ -93,7 +93,7 @@ void OPV_TypSize (OPT_Struct typ)
btyp = fld->typ;
OPV_TypSize(btyp);
size = btyp->size;
fbase = OPC_Base(btyp);
fbase = OPC_BaseAlignment(btyp);
OPC_Align(&offset, fbase);
fld->adr = offset;
offset += size;
@ -107,7 +107,7 @@ void OPV_TypSize (OPT_Struct typ)
offset = 1;
}
if (OPM_RecSize == 0) {
base = OPV_NaturalAlignment(offset, OPM_RecAlign);
base = OPV_NaturalAlignment(offset, OPC_SizeAlignment(OPM_RecSize));
}
OPC_Align(&offset, base);
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('(');
OPV_Entier(n, -1);
OPM_WriteString((CHAR*)", ", (LONGINT)3);
OPM_WriteInt(OPM_MaxInt + 1);
OPM_WriteInt(OPM_SignedMaximum(OPM_IntSize) + 1);
OPM_Write(')');
} else {
OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
@ -507,7 +507,7 @@ static void OPV_Convert (OPT_Node n, INTEGER form, INTEGER prec)
OPM_Write('(');
OPV_Entier(n, -1);
OPM_WriteString((CHAR*)", ", (LONGINT)3);
OPM_WriteInt(OPM_MaxSInt + 1);
OPM_WriteInt(OPM_SignedMaximum(OPM_SIntSize) + 1);
OPM_Write(')');
} else {
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)) {
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);
OPV_expr(n, prec);
OPM_WriteString((CHAR*)"))", (LONGINT)3);
@ -1322,7 +1322,7 @@ static void OPV_NewArr (OPT_Node d, OPT_Node x)
OPM_WriteInt(base->size);
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_WriteInt(nofdim);
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);
static LONGINT OPB_ShorterSize (LONGINT i);
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_StPar0 (OPT_Node *par0, INTEGER 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;
}
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)
{
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_Object *obj;
BOOLEAN *guard;
struct TypTest__63 *lnk;
} *TypTest__63_s;
struct TypTest__61 *lnk;
} *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_Struct t = NIL;
@ -471,54 +452,54 @@ static void GTT__64 (OPT_Struct t0, OPT_Struct t1)
t1 = t1->BaseTyp;
}
if (t1 == t0 || t0->form == 0) {
if (*TypTest__63_s->guard) {
OPB_BindNodes(5, NIL, &*TypTest__63_s->x, NIL);
(*TypTest__63_s->x)->readonly = (*TypTest__63_s->x)->left->readonly;
if (*TypTest__61_s->guard) {
OPB_BindNodes(5, NIL, &*TypTest__61_s->x, NIL);
(*TypTest__61_s->x)->readonly = (*TypTest__61_s->x)->left->readonly;
} else {
node = OPT_NewNode(11);
node->subcl = 16;
node->left = *TypTest__63_s->x;
node->obj = *TypTest__63_s->obj;
*TypTest__63_s->x = node;
node->left = *TypTest__61_s->x;
node->obj = *TypTest__61_s->obj;
*TypTest__61_s->x = node;
}
} else {
OPB_err(85);
}
} else if (t0 != t1) {
OPB_err(85);
} else if (!*TypTest__63_s->guard) {
if ((*TypTest__63_s->x)->class == 5) {
} else if (!*TypTest__61_s->guard) {
if ((*TypTest__61_s->x)->class == 5) {
node = OPT_NewNode(11);
node->subcl = 16;
node->left = *TypTest__63_s->x;
node->obj = *TypTest__63_s->obj;
*TypTest__63_s->x = node;
node->left = *TypTest__61_s->x;
node->obj = *TypTest__61_s->obj;
*TypTest__61_s->x = node;
} 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)
{
struct TypTest__63 _s;
struct TypTest__61 _s;
_s.x = x;
_s.obj = &obj;
_s.guard = &guard;
_s.lnk = TypTest__63_s;
TypTest__63_s = &_s;
_s.lnk = TypTest__61_s;
TypTest__61_s = &_s;
if (OPB_NotVar(*x)) {
OPB_err(112);
} else if ((*x)->typ->form == 13) {
if (((*x)->typ->BaseTyp->comp != 4 && (*x)->typ != OPT_sysptrtyp)) {
OPB_err(85);
} else if (obj->typ->form == 13) {
GTT__64((*x)->typ->BaseTyp, obj->typ->BaseTyp);
GTT__62((*x)->typ->BaseTyp, obj->typ->BaseTyp);
} else {
OPB_err(86);
}
} 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 {
OPB_err(87);
}
@ -527,7 +508,7 @@ void OPB_TypTest (OPT_Node *x, OPT_Object obj, BOOLEAN guard)
} else {
(*x)->typ = OPT_booltyp;
}
TypTest__63_s = _s.lnk;
TypTest__61_s = _s.lnk;
}
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;
break;
case 4: case 5: case 6:
x = OPB_NewIntConst(OPB_SignedMinimum(x->typ->size));
x = OPB_NewIntConst(OPM_SignedMinimum(x->typ->size));
break;
case 9:
x = OPB_NewIntConst(((LONGINT)(0)));
@ -1881,7 +1862,7 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno)
x->typ = OPT_chartyp;
break;
case 4: case 5: case 6:
x = OPB_NewIntConst(OPB_SignedMaximum(x->typ->size));
x = OPB_NewIntConst(OPM_SignedMaximum(x->typ->size));
break;
case 9:
x = OPB_NewIntConst(OPM_MaxSet);
@ -2063,13 +2044,13 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno)
*par0 = x;
}
static struct StPar1__58 {
struct StPar1__58 *lnk;
} *StPar1__58_s;
static struct StPar1__56 {
struct StPar1__56 *lnk;
} *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 node = NIL;
@ -2086,9 +2067,9 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
INTEGER f, L;
OPT_Struct typ = NIL;
OPT_Node p = NIL, t = NIL;
struct StPar1__58 _s;
_s.lnk = StPar1__58_s;
StPar1__58_s = &_s;
struct StPar1__56 _s;
_s.lnk = StPar1__56_s;
StPar1__56_s = &_s;
p = *par0;
f = x->typ->form;
switch (fctno) {
@ -2104,7 +2085,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
OPB_err(111);
}
}
p = NewOp__59(19, fctno, p, x);
p = NewOp__57(19, fctno, p, x);
p->typ = OPT_notyp;
}
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))) {
OPB_err(202);
}
p = NewOp__59(19, fctno, p, x);
p = NewOp__57(19, fctno, p, x);
} else {
OPB_err(111);
}
@ -2140,7 +2121,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
p = p->left;
x->conval->intval += 1;
}
p = NewOp__59(12, 19, p, x);
p = NewOp__57(12, 19, p, x);
p->typ = OPT_linttyp;
} else {
p = x;
@ -2162,7 +2143,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
t = x;
x = p;
p = t;
p = NewOp__59(19, 18, p, x);
p = NewOp__57(19, 18, p, x);
} else {
OPB_err(111);
}
@ -2188,7 +2169,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
}
p->obj = NIL;
} else {
p = NewOp__59(12, 17, p, x);
p = NewOp__57(12, 17, p, x);
p->typ = OPT_linttyp;
}
} else {
@ -2219,9 +2200,9 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
OPB_err(111);
} else {
if (fctno == 22) {
p = NewOp__59(12, 27, p, x);
p = NewOp__57(12, 27, p, x);
} else {
p = NewOp__59(12, 28, p, x);
p = NewOp__57(12, 28, p, x);
}
p->typ = p->left->typ;
}
@ -2238,7 +2219,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
x = p;
p = t;
}
p = NewOp__59(19, fctno, p, x);
p = NewOp__57(19, fctno, p, x);
} else {
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) {
OPB_err(126);
} else if (__IN(f, 0x70)) {
p = NewOp__59(12, 26, p, x);
p = NewOp__57(12, 26, p, x);
} else {
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) {
OPB_err(126);
} else if (__IN(f, 0x70)) {
p = NewOp__59(19, 30, p, x);
p = NewOp__57(19, 30, p, x);
} else {
OPB_err(111);
}
@ -2318,7 +2299,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
break;
}
*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)

View file

@ -17,7 +17,7 @@ static CHAR OPC_BodyNameExt[13];
export void OPC_Align (LONGINT *adr, LONGINT base);
export void OPC_Andent (OPT_Struct typ);
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 void OPC_BegBlk (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_RegCmds (OPT_Object obj);
export void OPC_SetInclude (BOOLEAN exclude);
export LONGINT OPC_SizeAlignment (LONGINT size);
static void OPC_Stars (OPT_Struct typ, BOOLEAN *openClause);
static void OPC_Str1 (CHAR *s, LONGINT s__len, LONGINT x);
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;
switch (typ->form) {
case 1:
_o_result = 1;
return _o_result;
break;
case 3:
_o_result = OPM_CharAlign;
return _o_result;
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;
LONGINT alignment;
if (size < (LONGINT)OPM_Alignment) {
alignment = 1;
while (alignment < size) {
alignment = __ASHL(alignment, 1);
}
} else {
alignment = OPM_Alignment;
}
__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)
@ -985,7 +953,7 @@ static void OPC_FieldList (OPT_Struct typ, BOOLEAN last, LONGINT *off, LONGINT *
}
} else {
adr = *off;
fldAlign = OPC_Base(fld->typ);
fldAlign = OPC_BaseAlignment(fld->typ);
OPC_Align(&adr, fldAlign);
gap = fld->adr - adr;
if (fldAlign > *curAlign) {

View file

@ -12,7 +12,7 @@
import void OPC_Align (LONGINT *adr, LONGINT base);
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 void OPC_BegBlk (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 LONGINT OPC_NofPtrs (OPT_Struct typ);
import void OPC_SetInclude (BOOLEAN exclude);
import LONGINT OPC_SizeAlignment (LONGINT size);
import void OPC_TDescDecl (OPT_Struct typ);
import void OPC_TypeDefs (OPT_Object obj, INTEGER vis);
import void OPC_TypeOf (OPT_Object ap);

View file

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

View file

@ -7,8 +7,8 @@
#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 LONGINT OPM_MinSInt, OPM_MinInt, OPM_MinLInt, OPM_MaxSInt, OPM_MaxInt, OPM_MaxLInt, OPM_MaxIndex;
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_MaxIndex;
import LONGREAL OPM_MinReal, OPM_MaxReal, OPM_MinLReal, OPM_MaxLReal;
import BOOLEAN OPM_noerr;
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 INTEGER OPM_AlignSize (LONGINT size);
import void OPM_CloseFiles (void);
import void OPM_CloseOldSym (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 BOOLEAN OPM_OpenPar (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 LONGINT OPM_SymRInt (void);
import void OPM_SymRLReal (LONGREAL *lr);

View file

@ -83,7 +83,7 @@ void OPV_TypSize (OPT_Struct typ)
btyp = typ->BaseTyp;
if (btyp == NIL) {
offset = 0;
base = OPM_RecAlign;
base = OPC_SizeAlignment(OPM_RecSize);
} else {
OPV_TypSize(btyp);
offset = btyp->size - (LONGINT)__ASHR(btyp->sysflag, 8);
@ -94,7 +94,7 @@ void OPV_TypSize (OPT_Struct typ)
btyp = fld->typ;
OPV_TypSize(btyp);
size = btyp->size;
fbase = OPC_Base(btyp);
fbase = OPC_BaseAlignment(btyp);
OPC_Align(&offset, fbase);
fld->adr = offset;
offset += size;
@ -108,7 +108,7 @@ void OPV_TypSize (OPT_Struct typ)
offset = 1;
}
if (OPM_RecSize == 0) {
base = OPV_NaturalAlignment(offset, OPM_RecAlign);
base = OPV_NaturalAlignment(offset, OPC_SizeAlignment(OPM_RecSize));
}
OPC_Align(&offset, base);
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('(');
OPV_Entier(n, -1);
OPM_WriteString((CHAR*)", ", (LONGINT)3);
OPM_WriteInt(OPM_MaxInt + 1);
OPM_WriteInt(OPM_SignedMaximum(OPM_IntSize) + 1);
OPM_Write(')');
} else {
OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
@ -508,7 +508,7 @@ static void OPV_Convert (OPT_Node n, INTEGER form, INTEGER prec)
OPM_Write('(');
OPV_Entier(n, -1);
OPM_WriteString((CHAR*)", ", (LONGINT)3);
OPM_WriteInt(OPM_MaxSInt + 1);
OPM_WriteInt(OPM_SignedMaximum(OPM_SIntSize) + 1);
OPM_Write(')');
} else {
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)) {
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);
OPV_expr(n, prec);
OPM_WriteString((CHAR*)"))", (LONGINT)3);
@ -1323,7 +1323,7 @@ static void OPV_NewArr (OPT_Node d, OPT_Node x)
OPM_WriteInt(base->size);
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_WriteInt(nofdim);
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);
static LONGINT OPB_ShorterSize (LONGINT i);
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_StPar0 (OPT_Node *par0, INTEGER 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;
}
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)
{
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_Object *obj;
BOOLEAN *guard;
struct TypTest__63 *lnk;
} *TypTest__63_s;
struct TypTest__61 *lnk;
} *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_Struct t = NIL;
@ -470,54 +451,54 @@ static void GTT__64 (OPT_Struct t0, OPT_Struct t1)
t1 = t1->BaseTyp;
}
if (t1 == t0 || t0->form == 0) {
if (*TypTest__63_s->guard) {
OPB_BindNodes(5, NIL, &*TypTest__63_s->x, NIL);
(*TypTest__63_s->x)->readonly = (*TypTest__63_s->x)->left->readonly;
if (*TypTest__61_s->guard) {
OPB_BindNodes(5, NIL, &*TypTest__61_s->x, NIL);
(*TypTest__61_s->x)->readonly = (*TypTest__61_s->x)->left->readonly;
} else {
node = OPT_NewNode(11);
node->subcl = 16;
node->left = *TypTest__63_s->x;
node->obj = *TypTest__63_s->obj;
*TypTest__63_s->x = node;
node->left = *TypTest__61_s->x;
node->obj = *TypTest__61_s->obj;
*TypTest__61_s->x = node;
}
} else {
OPB_err(85);
}
} else if (t0 != t1) {
OPB_err(85);
} else if (!*TypTest__63_s->guard) {
if ((*TypTest__63_s->x)->class == 5) {
} else if (!*TypTest__61_s->guard) {
if ((*TypTest__61_s->x)->class == 5) {
node = OPT_NewNode(11);
node->subcl = 16;
node->left = *TypTest__63_s->x;
node->obj = *TypTest__63_s->obj;
*TypTest__63_s->x = node;
node->left = *TypTest__61_s->x;
node->obj = *TypTest__61_s->obj;
*TypTest__61_s->x = node;
} 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)
{
struct TypTest__63 _s;
struct TypTest__61 _s;
_s.x = x;
_s.obj = &obj;
_s.guard = &guard;
_s.lnk = TypTest__63_s;
TypTest__63_s = &_s;
_s.lnk = TypTest__61_s;
TypTest__61_s = &_s;
if (OPB_NotVar(*x)) {
OPB_err(112);
} else if ((*x)->typ->form == 13) {
if (((*x)->typ->BaseTyp->comp != 4 && (*x)->typ != OPT_sysptrtyp)) {
OPB_err(85);
} else if (obj->typ->form == 13) {
GTT__64((*x)->typ->BaseTyp, obj->typ->BaseTyp);
GTT__62((*x)->typ->BaseTyp, obj->typ->BaseTyp);
} else {
OPB_err(86);
}
} 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 {
OPB_err(87);
}
@ -526,7 +507,7 @@ void OPB_TypTest (OPT_Node *x, OPT_Object obj, BOOLEAN guard)
} else {
(*x)->typ = OPT_booltyp;
}
TypTest__63_s = _s.lnk;
TypTest__61_s = _s.lnk;
}
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;
break;
case 4: case 5: case 6:
x = OPB_NewIntConst(OPB_SignedMinimum(x->typ->size));
x = OPB_NewIntConst(OPM_SignedMinimum(x->typ->size));
break;
case 9:
x = OPB_NewIntConst(((LONGINT)(0)));
@ -1880,7 +1861,7 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno)
x->typ = OPT_chartyp;
break;
case 4: case 5: case 6:
x = OPB_NewIntConst(OPB_SignedMaximum(x->typ->size));
x = OPB_NewIntConst(OPM_SignedMaximum(x->typ->size));
break;
case 9:
x = OPB_NewIntConst(OPM_MaxSet);
@ -2062,13 +2043,13 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno)
*par0 = x;
}
static struct StPar1__58 {
struct StPar1__58 *lnk;
} *StPar1__58_s;
static struct StPar1__56 {
struct StPar1__56 *lnk;
} *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 node = NIL;
@ -2085,9 +2066,9 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
INTEGER f, L;
OPT_Struct typ = NIL;
OPT_Node p = NIL, t = NIL;
struct StPar1__58 _s;
_s.lnk = StPar1__58_s;
StPar1__58_s = &_s;
struct StPar1__56 _s;
_s.lnk = StPar1__56_s;
StPar1__56_s = &_s;
p = *par0;
f = x->typ->form;
switch (fctno) {
@ -2103,7 +2084,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
OPB_err(111);
}
}
p = NewOp__59(19, fctno, p, x);
p = NewOp__57(19, fctno, p, x);
p->typ = OPT_notyp;
}
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))) {
OPB_err(202);
}
p = NewOp__59(19, fctno, p, x);
p = NewOp__57(19, fctno, p, x);
} else {
OPB_err(111);
}
@ -2139,7 +2120,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
p = p->left;
x->conval->intval += 1;
}
p = NewOp__59(12, 19, p, x);
p = NewOp__57(12, 19, p, x);
p->typ = OPT_linttyp;
} else {
p = x;
@ -2161,7 +2142,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
t = x;
x = p;
p = t;
p = NewOp__59(19, 18, p, x);
p = NewOp__57(19, 18, p, x);
} else {
OPB_err(111);
}
@ -2187,7 +2168,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
}
p->obj = NIL;
} else {
p = NewOp__59(12, 17, p, x);
p = NewOp__57(12, 17, p, x);
p->typ = OPT_linttyp;
}
} else {
@ -2218,9 +2199,9 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
OPB_err(111);
} else {
if (fctno == 22) {
p = NewOp__59(12, 27, p, x);
p = NewOp__57(12, 27, p, x);
} else {
p = NewOp__59(12, 28, p, x);
p = NewOp__57(12, 28, p, x);
}
p->typ = p->left->typ;
}
@ -2237,7 +2218,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
x = p;
p = t;
}
p = NewOp__59(19, fctno, p, x);
p = NewOp__57(19, fctno, p, x);
} else {
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) {
OPB_err(126);
} else if (__IN(f, 0x70)) {
p = NewOp__59(12, 26, p, x);
p = NewOp__57(12, 26, p, x);
} else {
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) {
OPB_err(126);
} else if (__IN(f, 0x70)) {
p = NewOp__59(19, 30, p, x);
p = NewOp__57(19, 30, p, x);
} else {
OPB_err(111);
}
@ -2317,7 +2298,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
break;
}
*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)

View file

@ -16,7 +16,7 @@ static CHAR OPC_BodyNameExt[13];
export void OPC_Align (LONGINT *adr, LONGINT base);
export void OPC_Andent (OPT_Struct typ);
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 void OPC_BegBlk (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_RegCmds (OPT_Object obj);
export void OPC_SetInclude (BOOLEAN exclude);
export LONGINT OPC_SizeAlignment (LONGINT size);
static void OPC_Stars (OPT_Struct typ, BOOLEAN *openClause);
static void OPC_Str1 (CHAR *s, LONGINT s__len, LONGINT x);
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;
switch (typ->form) {
case 1:
_o_result = 1;
return _o_result;
break;
case 3:
_o_result = OPM_CharAlign;
return _o_result;
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;
LONGINT alignment;
if (size < (LONGINT)OPM_Alignment) {
alignment = 1;
while (alignment < size) {
alignment = __ASHL(alignment, 1);
}
} else {
alignment = OPM_Alignment;
}
__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)
@ -984,7 +952,7 @@ static void OPC_FieldList (OPT_Struct typ, BOOLEAN last, LONGINT *off, LONGINT *
}
} else {
adr = *off;
fldAlign = OPC_Base(fld->typ);
fldAlign = OPC_BaseAlignment(fld->typ);
OPC_Align(&adr, fldAlign);
gap = fld->adr - adr;
if (fldAlign > *curAlign) {

View file

@ -11,7 +11,7 @@
import void OPC_Align (LONGINT *adr, LONGINT base);
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 void OPC_BegBlk (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 LONGINT OPC_NofPtrs (OPT_Struct typ);
import void OPC_SetInclude (BOOLEAN exclude);
import LONGINT OPC_SizeAlignment (LONGINT size);
import void OPC_TDescDecl (OPT_Struct typ);
import void OPC_TypeDefs (OPT_Object obj, INTEGER vis);
import void OPC_TypeOf (OPT_Object ap);

View file

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

View file

@ -6,8 +6,8 @@
#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 LONGINT OPM_MinSInt, OPM_MinInt, OPM_MinLInt, OPM_MaxSInt, OPM_MaxInt, OPM_MaxLInt, OPM_MaxIndex;
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_MaxIndex;
import LONGREAL OPM_MinReal, OPM_MaxReal, OPM_MinLReal, OPM_MaxLReal;
import BOOLEAN OPM_noerr;
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 INTEGER OPM_AlignSize (LONGINT size);
import void OPM_CloseFiles (void);
import void OPM_CloseOldSym (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 BOOLEAN OPM_OpenPar (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 LONGINT OPM_SymRInt (void);
import void OPM_SymRLReal (LONGREAL *lr);

View file

@ -82,7 +82,7 @@ void OPV_TypSize (OPT_Struct typ)
btyp = typ->BaseTyp;
if (btyp == NIL) {
offset = 0;
base = OPM_RecAlign;
base = OPC_SizeAlignment(OPM_RecSize);
} else {
OPV_TypSize(btyp);
offset = btyp->size - (LONGINT)__ASHR(btyp->sysflag, 8);
@ -93,7 +93,7 @@ void OPV_TypSize (OPT_Struct typ)
btyp = fld->typ;
OPV_TypSize(btyp);
size = btyp->size;
fbase = OPC_Base(btyp);
fbase = OPC_BaseAlignment(btyp);
OPC_Align(&offset, fbase);
fld->adr = offset;
offset += size;
@ -107,7 +107,7 @@ void OPV_TypSize (OPT_Struct typ)
offset = 1;
}
if (OPM_RecSize == 0) {
base = OPV_NaturalAlignment(offset, OPM_RecAlign);
base = OPV_NaturalAlignment(offset, OPC_SizeAlignment(OPM_RecSize));
}
OPC_Align(&offset, base);
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('(');
OPV_Entier(n, -1);
OPM_WriteString((CHAR*)", ", (LONGINT)3);
OPM_WriteInt(OPM_MaxInt + 1);
OPM_WriteInt(OPM_SignedMaximum(OPM_IntSize) + 1);
OPM_Write(')');
} else {
OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
@ -507,7 +507,7 @@ static void OPV_Convert (OPT_Node n, INTEGER form, INTEGER prec)
OPM_Write('(');
OPV_Entier(n, -1);
OPM_WriteString((CHAR*)", ", (LONGINT)3);
OPM_WriteInt(OPM_MaxSInt + 1);
OPM_WriteInt(OPM_SignedMaximum(OPM_SIntSize) + 1);
OPM_Write(')');
} else {
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)) {
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);
OPV_expr(n, prec);
OPM_WriteString((CHAR*)"))", (LONGINT)3);
@ -1322,7 +1322,7 @@ static void OPV_NewArr (OPT_Node d, OPT_Node x)
OPM_WriteInt(base->size);
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_WriteInt(nofdim);
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);
static LONGINT OPB_ShorterSize (LONGINT i);
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_StPar0 (OPT_Node *par0, INTEGER 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;
}
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)
{
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_Object *obj;
BOOLEAN *guard;
struct TypTest__63 *lnk;
} *TypTest__63_s;
struct TypTest__61 *lnk;
} *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_Struct t = NIL;
@ -471,54 +452,54 @@ static void GTT__64 (OPT_Struct t0, OPT_Struct t1)
t1 = t1->BaseTyp;
}
if (t1 == t0 || t0->form == 0) {
if (*TypTest__63_s->guard) {
OPB_BindNodes(5, NIL, &*TypTest__63_s->x, NIL);
(*TypTest__63_s->x)->readonly = (*TypTest__63_s->x)->left->readonly;
if (*TypTest__61_s->guard) {
OPB_BindNodes(5, NIL, &*TypTest__61_s->x, NIL);
(*TypTest__61_s->x)->readonly = (*TypTest__61_s->x)->left->readonly;
} else {
node = OPT_NewNode(11);
node->subcl = 16;
node->left = *TypTest__63_s->x;
node->obj = *TypTest__63_s->obj;
*TypTest__63_s->x = node;
node->left = *TypTest__61_s->x;
node->obj = *TypTest__61_s->obj;
*TypTest__61_s->x = node;
}
} else {
OPB_err(85);
}
} else if (t0 != t1) {
OPB_err(85);
} else if (!*TypTest__63_s->guard) {
if ((*TypTest__63_s->x)->class == 5) {
} else if (!*TypTest__61_s->guard) {
if ((*TypTest__61_s->x)->class == 5) {
node = OPT_NewNode(11);
node->subcl = 16;
node->left = *TypTest__63_s->x;
node->obj = *TypTest__63_s->obj;
*TypTest__63_s->x = node;
node->left = *TypTest__61_s->x;
node->obj = *TypTest__61_s->obj;
*TypTest__61_s->x = node;
} 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)
{
struct TypTest__63 _s;
struct TypTest__61 _s;
_s.x = x;
_s.obj = &obj;
_s.guard = &guard;
_s.lnk = TypTest__63_s;
TypTest__63_s = &_s;
_s.lnk = TypTest__61_s;
TypTest__61_s = &_s;
if (OPB_NotVar(*x)) {
OPB_err(112);
} else if ((*x)->typ->form == 13) {
if (((*x)->typ->BaseTyp->comp != 4 && (*x)->typ != OPT_sysptrtyp)) {
OPB_err(85);
} else if (obj->typ->form == 13) {
GTT__64((*x)->typ->BaseTyp, obj->typ->BaseTyp);
GTT__62((*x)->typ->BaseTyp, obj->typ->BaseTyp);
} else {
OPB_err(86);
}
} 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 {
OPB_err(87);
}
@ -527,7 +508,7 @@ void OPB_TypTest (OPT_Node *x, OPT_Object obj, BOOLEAN guard)
} else {
(*x)->typ = OPT_booltyp;
}
TypTest__63_s = _s.lnk;
TypTest__61_s = _s.lnk;
}
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;
break;
case 4: case 5: case 6:
x = OPB_NewIntConst(OPB_SignedMinimum(x->typ->size));
x = OPB_NewIntConst(OPM_SignedMinimum(x->typ->size));
break;
case 9:
x = OPB_NewIntConst(((LONGINT)(0)));
@ -1881,7 +1862,7 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno)
x->typ = OPT_chartyp;
break;
case 4: case 5: case 6:
x = OPB_NewIntConst(OPB_SignedMaximum(x->typ->size));
x = OPB_NewIntConst(OPM_SignedMaximum(x->typ->size));
break;
case 9:
x = OPB_NewIntConst(OPM_MaxSet);
@ -2063,13 +2044,13 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno)
*par0 = x;
}
static struct StPar1__58 {
struct StPar1__58 *lnk;
} *StPar1__58_s;
static struct StPar1__56 {
struct StPar1__56 *lnk;
} *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 node = NIL;
@ -2086,9 +2067,9 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
INTEGER f, L;
OPT_Struct typ = NIL;
OPT_Node p = NIL, t = NIL;
struct StPar1__58 _s;
_s.lnk = StPar1__58_s;
StPar1__58_s = &_s;
struct StPar1__56 _s;
_s.lnk = StPar1__56_s;
StPar1__56_s = &_s;
p = *par0;
f = x->typ->form;
switch (fctno) {
@ -2104,7 +2085,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
OPB_err(111);
}
}
p = NewOp__59(19, fctno, p, x);
p = NewOp__57(19, fctno, p, x);
p->typ = OPT_notyp;
}
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))) {
OPB_err(202);
}
p = NewOp__59(19, fctno, p, x);
p = NewOp__57(19, fctno, p, x);
} else {
OPB_err(111);
}
@ -2140,7 +2121,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
p = p->left;
x->conval->intval += 1;
}
p = NewOp__59(12, 19, p, x);
p = NewOp__57(12, 19, p, x);
p->typ = OPT_linttyp;
} else {
p = x;
@ -2162,7 +2143,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
t = x;
x = p;
p = t;
p = NewOp__59(19, 18, p, x);
p = NewOp__57(19, 18, p, x);
} else {
OPB_err(111);
}
@ -2188,7 +2169,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
}
p->obj = NIL;
} else {
p = NewOp__59(12, 17, p, x);
p = NewOp__57(12, 17, p, x);
p->typ = OPT_linttyp;
}
} else {
@ -2219,9 +2200,9 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
OPB_err(111);
} else {
if (fctno == 22) {
p = NewOp__59(12, 27, p, x);
p = NewOp__57(12, 27, p, x);
} else {
p = NewOp__59(12, 28, p, x);
p = NewOp__57(12, 28, p, x);
}
p->typ = p->left->typ;
}
@ -2238,7 +2219,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
x = p;
p = t;
}
p = NewOp__59(19, fctno, p, x);
p = NewOp__57(19, fctno, p, x);
} else {
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) {
OPB_err(126);
} else if (__IN(f, 0x70)) {
p = NewOp__59(12, 26, p, x);
p = NewOp__57(12, 26, p, x);
} else {
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) {
OPB_err(126);
} else if (__IN(f, 0x70)) {
p = NewOp__59(19, 30, p, x);
p = NewOp__57(19, 30, p, x);
} else {
OPB_err(111);
}
@ -2318,7 +2299,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno)
break;
}
*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)

View file

@ -17,7 +17,7 @@ static CHAR OPC_BodyNameExt[13];
export void OPC_Align (LONGINT *adr, LONGINT base);
export void OPC_Andent (OPT_Struct typ);
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 void OPC_BegBlk (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_RegCmds (OPT_Object obj);
export void OPC_SetInclude (BOOLEAN exclude);
export LONGINT OPC_SizeAlignment (LONGINT size);
static void OPC_Stars (OPT_Struct typ, BOOLEAN *openClause);
static void OPC_Str1 (CHAR *s, LONGINT s__len, LONGINT x);
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;
switch (typ->form) {
case 1:
_o_result = 1;
return _o_result;
break;
case 3:
_o_result = OPM_CharAlign;
return _o_result;
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;
LONGINT alignment;
if (size < (LONGINT)OPM_Alignment) {
alignment = 1;
while (alignment < size) {
alignment = __ASHL(alignment, 1);
}
} else {
alignment = OPM_Alignment;
}
__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)
@ -985,7 +953,7 @@ static void OPC_FieldList (OPT_Struct typ, BOOLEAN last, LONGINT *off, LONGINT *
}
} else {
adr = *off;
fldAlign = OPC_Base(fld->typ);
fldAlign = OPC_BaseAlignment(fld->typ);
OPC_Align(&adr, fldAlign);
gap = fld->adr - adr;
if (fldAlign > *curAlign) {

View file

@ -12,7 +12,7 @@
import void OPC_Align (LONGINT *adr, LONGINT base);
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 void OPC_BegBlk (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 LONGINT OPC_NofPtrs (OPT_Struct typ);
import void OPC_SetInclude (BOOLEAN exclude);
import LONGINT OPC_SizeAlignment (LONGINT size);
import void OPC_TDescDecl (OPT_Struct typ);
import void OPC_TypeDefs (OPT_Object obj, INTEGER vis);
import void OPC_TypeOf (OPT_Object ap);

View file

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

View file

@ -7,8 +7,8 @@
#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 LONGINT OPM_MinSInt, OPM_MinInt, OPM_MinLInt, OPM_MaxSInt, OPM_MaxInt, OPM_MaxLInt, OPM_MaxIndex;
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_MaxIndex;
import LONGREAL OPM_MinReal, OPM_MaxReal, OPM_MinLReal, OPM_MaxLReal;
import BOOLEAN OPM_noerr;
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 INTEGER OPM_AlignSize (LONGINT size);
import void OPM_CloseFiles (void);
import void OPM_CloseOldSym (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 BOOLEAN OPM_OpenPar (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 LONGINT OPM_SymRInt (void);
import void OPM_SymRLReal (LONGREAL *lr);

View file

@ -83,7 +83,7 @@ void OPV_TypSize (OPT_Struct typ)
btyp = typ->BaseTyp;
if (btyp == NIL) {
offset = 0;
base = OPM_RecAlign;
base = OPC_SizeAlignment(OPM_RecSize);
} else {
OPV_TypSize(btyp);
offset = btyp->size - (LONGINT)__ASHR(btyp->sysflag, 8);
@ -94,7 +94,7 @@ void OPV_TypSize (OPT_Struct typ)
btyp = fld->typ;
OPV_TypSize(btyp);
size = btyp->size;
fbase = OPC_Base(btyp);
fbase = OPC_BaseAlignment(btyp);
OPC_Align(&offset, fbase);
fld->adr = offset;
offset += size;
@ -108,7 +108,7 @@ void OPV_TypSize (OPT_Struct typ)
offset = 1;
}
if (OPM_RecSize == 0) {
base = OPV_NaturalAlignment(offset, OPM_RecAlign);
base = OPV_NaturalAlignment(offset, OPC_SizeAlignment(OPM_RecSize));
}
OPC_Align(&offset, base);
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('(');
OPV_Entier(n, -1);
OPM_WriteString((CHAR*)", ", (LONGINT)3);
OPM_WriteInt(OPM_MaxInt + 1);
OPM_WriteInt(OPM_SignedMaximum(OPM_IntSize) + 1);
OPM_Write(')');
} else {
OPM_WriteString((CHAR*)"(int)", (LONGINT)6);
@ -508,7 +508,7 @@ static void OPV_Convert (OPT_Node n, INTEGER form, INTEGER prec)
OPM_Write('(');
OPV_Entier(n, -1);
OPM_WriteString((CHAR*)", ", (LONGINT)3);
OPM_WriteInt(OPM_MaxSInt + 1);
OPM_WriteInt(OPM_SignedMaximum(OPM_SIntSize) + 1);
OPM_Write(')');
} else {
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)) {
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);
OPV_expr(n, prec);
OPM_WriteString((CHAR*)"))", (LONGINT)3);
@ -1323,7 +1323,7 @@ static void OPV_NewArr (OPT_Node d, OPT_Node x)
OPM_WriteInt(base->size);
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_WriteInt(nofdim);
OPM_WriteString((CHAR*)", ", (LONGINT)3);