* Deduplicate common constants into OPM and do some source format tidying.

* Fix postpush buildall script to force checkout of updated buildall.

* Show enlistment branch in makefiles

* Support non-printables in string literals and tidy case alignment and constant literals.

* Common code for MIN and MAX of integer types.

* Common code for SInt/Int/LInt in ConstOp parameter preparation.

* Common code for SInt/Int/LInt in Op parameter preparation.

* Refactor SetIntType to work with byte size directly. Prepare to revert my incorrect VAL changes.

* Original meaning of VAL restored. Many library files disabled until use of VAL in 64 bits fixed.

* Make Reals.Mod independent of INTEGER size and add reals tests.

* Implement fraction, IsInfinity and IsNaN in oocLowReal.Mod.

* OPB little simplifications and ShorterSize/LongerSize functions.

* Add test for alignment computability

* Replace alignment constants with calculated alignment.

* typ.size aware OPV.Convert

* Add SYSTEM_INT64 and make tests name independent.

* Remove SYSTEM.H includes (string.h and stdint.h).

* Replace uses of uintptr_t and size_t with SYSTEM_ADDRESS.

* Sad hack to make FreeBSD and OpenBSD happy with memcpy declaration.

* Detect 64 bit on FreeBSD, and size_t defined on OpenBSD.

* %zd not supportd by mingw, cast strnlen return to int.

* Add debug for intermittent failure only on OpenBSD.

* Add textTexts as a confidence test and tidy up a couple of other tests.

* Update binary test process.
This commit is contained in:
David C W Brown 2016-08-25 14:41:00 +01:00 committed by GitHub
parent 1f41d80b1e
commit da88496c5f
224 changed files with 7494 additions and 8065 deletions

View file

@ -1,4 +1,4 @@
/* voc 1.95 [2016/08/24] for gcc LP64 on cygwin xtspkaSfF */
/* voc 1.95 [2016/08/23] for gcc LP64 on cygwin xtspkaSfF */
#include "SYSTEM.h"
#include "Configuration.h"
#include "OPM.h"
@ -16,12 +16,13 @@ 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);
static void OPC_CProcDefs (OPT_Object obj, INTEGER vis);
export void OPC_Case (LONGINT caseVal, INTEGER form);
static void OPC_CharacterLiteral (LONGINT c);
export void OPC_Cmp (INTEGER rel);
export void OPC_CompleteIdent (OPT_Object obj);
export void OPC_Constant (OPT_Const con, INTEGER form);
@ -73,8 +74,10 @@ 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);
export void OPC_TDescDecl (OPT_Struct typ);
export void OPC_TypeDefs (OPT_Object obj, INTEGER vis);
export void OPC_TypeOf (OPT_Object ap);
@ -315,7 +318,7 @@ void OPC_Andent (OPT_Struct typ)
static BOOLEAN OPC_Undefined (OPT_Object obj)
{
BOOLEAN _o_result;
_o_result = (((obj->mnolev >= 0 && obj->linkadr != (LONGINT)(3 + OPM_currFile))) && obj->linkadr != 2) || obj->name[0] == 0x00;
_o_result = obj->name[0] == 0x00 || (((obj->mnolev >= 0 && obj->linkadr != (int)(3 + OPM_currFile))) && obj->linkadr != 2);
return _o_result;
}
@ -815,14 +818,15 @@ void OPC_TDescDecl (OPT_Struct typ)
OPC_Andent(typ);
OPC_Str1((CHAR*)", #", (LONGINT)4, typ->n + 1);
OPC_Str1((CHAR*)", #) = {__TDFLDS(", (LONGINT)18, OPC_NofPtrs(typ));
OPM_Write('\"');
OPM_Write('"');
if (typ->strobj != NIL) {
OPM_WriteStringVar((void*)typ->strobj->name, ((LONGINT)(256)));
}
OPC_Str1((CHAR*)"\", #), {", (LONGINT)9, typ->size);
OPM_Write('"');
OPC_Str1((CHAR*)", #), {", (LONGINT)8, typ->size);
nofptrs = 0;
OPC_PutPtrOffsets(typ, ((LONGINT)(0)), &nofptrs);
OPC_Str1((CHAR*)"#}}", (LONGINT)4, -((nofptrs + 1) * (LONGINT)OPM_LIntSize));
OPC_Str1((CHAR*)"#}}", (LONGINT)4, -((nofptrs + 1) * (int)OPM_LIntSize));
OPC_EndStat();
}
@ -864,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 < (int)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)
@ -938,11 +909,11 @@ static void OPC_FillGap (LONGINT gap, LONGINT off, LONGINT align, LONGINT *n, LO
if ((*curAlign < align && gap - (adr - off) >= align)) {
gap -= (adr - off) + align;
OPC_BegStat();
if (align == (LONGINT)OPM_IntSize) {
if (align == (int)OPM_IntSize) {
OPM_WriteString((CHAR*)"INTEGER", (LONGINT)8);
} else if (align == (LONGINT)OPM_LIntSize) {
} else if (align == (int)OPM_LIntSize) {
OPM_WriteString((CHAR*)"LONGINT", (LONGINT)8);
} else if (align == (LONGINT)OPM_LRealSize) {
} else if (align == (int)OPM_LRealSize) {
OPM_WriteString((CHAR*)"LONGREAL", (LONGINT)9);
}
OPC_Str1((CHAR*)" _prvt#", (LONGINT)8, *n);
@ -981,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) {
@ -1007,7 +978,7 @@ static void OPC_FieldList (OPT_Struct typ, BOOLEAN last, LONGINT *off, LONGINT *
}
}
if (last) {
adr = typ->size - (LONGINT)__ASHR(typ->sysflag, 8);
adr = typ->size - (int)__ASHR(typ->sysflag, 8);
if (adr == 0) {
gap = 1;
} else {
@ -1170,10 +1141,10 @@ static void OPC_Include (CHAR *name, LONGINT name__len)
{
__DUP(name, name__len, CHAR);
OPM_WriteString((CHAR*)"#include ", (LONGINT)10);
OPM_Write('\"');
OPM_Write('"');
OPM_WriteStringVar((void*)name, name__len);
OPM_WriteString((CHAR*)".h", (LONGINT)3);
OPM_Write('\"');
OPM_Write('"');
OPM_WriteLn();
__DEL(name);
}
@ -1238,8 +1209,8 @@ void OPC_GenHdr (OPT_Node n)
static void OPC_GenHeaderMsg (void)
{
INTEGER i;
OPM_WriteString((CHAR*)"/*", (LONGINT)3);
OPM_WriteString((CHAR*)" voc ", (LONGINT)6);
OPM_WriteString((CHAR*)"/* ", (LONGINT)4);
OPM_WriteString((CHAR*)"voc", (LONGINT)4);
OPM_Write(' ');
OPM_WriteString(Configuration_versionLong, ((LONGINT)(41)));
OPM_Write(' ');
@ -1855,26 +1826,56 @@ void OPC_Cmp (INTEGER rel)
}
}
static void OPC_CharacterLiteral (LONGINT c)
{
if (c < 32 || c > 126) {
OPM_WriteString((CHAR*)"0x", (LONGINT)3);
OPM_WriteHex(c);
} else {
OPM_Write('\'');
if ((c == 92 || c == 39) || c == 63) {
OPM_Write('\\');
}
OPM_Write((CHAR)c);
OPM_Write('\'');
}
}
static void OPC_StringLiteral (CHAR *s, LONGINT s__len, LONGINT l)
{
LONGINT i;
INTEGER c;
__DUP(s, s__len, CHAR);
OPM_Write('"');
i = 0;
while (i < l) {
c = (int)s[__X(i, s__len)];
if (c < 32 || c > 126) {
OPM_Write('\\');
OPM_Write((CHAR)(48 + __ASHR(c, 6)));
c = __MASK(c, -64);
OPM_Write((CHAR)(48 + __ASHR(c, 3)));
c = __MASK(c, -8);
OPM_Write((CHAR)(48 + c));
} else {
if ((c == 92 || c == 34) || c == 63) {
OPM_Write('\\');
}
OPM_Write((CHAR)c);
}
i += 1;
}
OPM_Write('"');
__DEL(s);
}
void OPC_Case (LONGINT caseVal, INTEGER form)
{
CHAR ch;
OPM_WriteString((CHAR*)"case ", (LONGINT)6);
switch (form) {
case 3:
ch = (CHAR)caseVal;
if ((ch >= ' ' && ch <= '~')) {
OPM_Write('\'');
if (((ch == '\\' || ch == '\?') || ch == '\'') || ch == '\"') {
OPM_Write('\\');
OPM_Write(ch);
} else {
OPM_Write(ch);
}
OPM_Write('\'');
} else {
OPM_WriteString((CHAR*)"0x", (LONGINT)3);
OPM_WriteHex(caseVal);
}
OPC_CharacterLiteral(caseVal);
break;
case 4: case 5: case 6:
OPM_WriteInt(caseVal);
@ -1932,8 +1933,7 @@ void OPC_Len (OPT_Object obj, OPT_Struct array, LONGINT dim)
void OPC_Constant (OPT_Const con, INTEGER form)
{
INTEGER i, len;
CHAR ch;
INTEGER i;
SET s;
LONGINT hex;
BOOLEAN skipLeading;
@ -1945,18 +1945,7 @@ void OPC_Constant (OPT_Const con, INTEGER form)
OPM_WriteInt(con->intval);
break;
case 3:
ch = (CHAR)con->intval;
if ((ch >= ' ' && ch <= '~')) {
OPM_Write('\'');
if (((ch == '\\' || ch == '\?') || ch == '\'') || ch == '\"') {
OPM_Write('\\');
}
OPM_Write(ch);
OPM_Write('\'');
} else {
OPM_WriteString((CHAR*)"0x", (LONGINT)3);
OPM_WriteHex(con->intval);
}
OPC_CharacterLiteral(con->intval);
break;
case 4: case 5: case 6:
OPM_WriteInt(con->intval);
@ -1991,18 +1980,7 @@ void OPC_Constant (OPT_Const con, INTEGER form)
}
break;
case 10:
OPM_Write('\"');
len = (int)con->intval2 - 1;
i = 0;
while (i < len) {
ch = (*con->ext)[__X(i, ((LONGINT)(256)))];
if (((ch == '\\' || ch == '\?') || ch == '\'') || ch == '\"') {
OPM_Write('\\');
}
OPM_Write(ch);
i += 1;
}
OPM_Write('\"');
OPC_StringLiteral(*con->ext, ((LONGINT)(256)), con->intval2 - 1);
break;
case 11:
OPM_WriteString((CHAR*)"NIL", (LONGINT)4);
@ -2015,74 +1993,74 @@ void OPC_Constant (OPT_Const con, INTEGER form)
}
}
static struct InitKeywords__47 {
static struct InitKeywords__48 {
SHORTINT *n;
struct InitKeywords__47 *lnk;
} *InitKeywords__47_s;
struct InitKeywords__48 *lnk;
} *InitKeywords__48_s;
static void Enter__48 (CHAR *s, LONGINT s__len);
static void Enter__49 (CHAR *s, LONGINT s__len);
static void Enter__48 (CHAR *s, LONGINT s__len)
static void Enter__49 (CHAR *s, LONGINT s__len)
{
INTEGER h;
__DUP(s, s__len, CHAR);
h = OPC_PerfectHash((void*)s, s__len);
OPC_hashtab[__X(h, ((LONGINT)(105)))] = *InitKeywords__47_s->n;
__COPY(s, OPC_keytab[__X(*InitKeywords__47_s->n, ((LONGINT)(36)))], ((LONGINT)(9)));
*InitKeywords__47_s->n += 1;
OPC_hashtab[__X(h, ((LONGINT)(105)))] = *InitKeywords__48_s->n;
__COPY(s, OPC_keytab[__X(*InitKeywords__48_s->n, ((LONGINT)(36)))], ((LONGINT)(9)));
*InitKeywords__48_s->n += 1;
__DEL(s);
}
static void OPC_InitKeywords (void)
{
SHORTINT n, i;
struct InitKeywords__47 _s;
struct InitKeywords__48 _s;
_s.n = &n;
_s.lnk = InitKeywords__47_s;
InitKeywords__47_s = &_s;
_s.lnk = InitKeywords__48_s;
InitKeywords__48_s = &_s;
n = 0;
i = 0;
while (i <= 104) {
OPC_hashtab[__X(i, ((LONGINT)(105)))] = -1;
i += 1;
}
Enter__48((CHAR*)"asm", (LONGINT)4);
Enter__48((CHAR*)"auto", (LONGINT)5);
Enter__48((CHAR*)"break", (LONGINT)6);
Enter__48((CHAR*)"case", (LONGINT)5);
Enter__48((CHAR*)"char", (LONGINT)5);
Enter__48((CHAR*)"const", (LONGINT)6);
Enter__48((CHAR*)"continue", (LONGINT)9);
Enter__48((CHAR*)"default", (LONGINT)8);
Enter__48((CHAR*)"do", (LONGINT)3);
Enter__48((CHAR*)"double", (LONGINT)7);
Enter__48((CHAR*)"else", (LONGINT)5);
Enter__48((CHAR*)"enum", (LONGINT)5);
Enter__48((CHAR*)"extern", (LONGINT)7);
Enter__48((CHAR*)"export", (LONGINT)7);
Enter__48((CHAR*)"float", (LONGINT)6);
Enter__48((CHAR*)"for", (LONGINT)4);
Enter__48((CHAR*)"fortran", (LONGINT)8);
Enter__48((CHAR*)"goto", (LONGINT)5);
Enter__48((CHAR*)"if", (LONGINT)3);
Enter__48((CHAR*)"import", (LONGINT)7);
Enter__48((CHAR*)"int", (LONGINT)4);
Enter__48((CHAR*)"long", (LONGINT)5);
Enter__48((CHAR*)"register", (LONGINT)9);
Enter__48((CHAR*)"return", (LONGINT)7);
Enter__48((CHAR*)"short", (LONGINT)6);
Enter__48((CHAR*)"signed", (LONGINT)7);
Enter__48((CHAR*)"sizeof", (LONGINT)7);
Enter__48((CHAR*)"static", (LONGINT)7);
Enter__48((CHAR*)"struct", (LONGINT)7);
Enter__48((CHAR*)"switch", (LONGINT)7);
Enter__48((CHAR*)"typedef", (LONGINT)8);
Enter__48((CHAR*)"union", (LONGINT)6);
Enter__48((CHAR*)"unsigned", (LONGINT)9);
Enter__48((CHAR*)"void", (LONGINT)5);
Enter__48((CHAR*)"volatile", (LONGINT)9);
Enter__48((CHAR*)"while", (LONGINT)6);
InitKeywords__47_s = _s.lnk;
Enter__49((CHAR*)"asm", (LONGINT)4);
Enter__49((CHAR*)"auto", (LONGINT)5);
Enter__49((CHAR*)"break", (LONGINT)6);
Enter__49((CHAR*)"case", (LONGINT)5);
Enter__49((CHAR*)"char", (LONGINT)5);
Enter__49((CHAR*)"const", (LONGINT)6);
Enter__49((CHAR*)"continue", (LONGINT)9);
Enter__49((CHAR*)"default", (LONGINT)8);
Enter__49((CHAR*)"do", (LONGINT)3);
Enter__49((CHAR*)"double", (LONGINT)7);
Enter__49((CHAR*)"else", (LONGINT)5);
Enter__49((CHAR*)"enum", (LONGINT)5);
Enter__49((CHAR*)"extern", (LONGINT)7);
Enter__49((CHAR*)"export", (LONGINT)7);
Enter__49((CHAR*)"float", (LONGINT)6);
Enter__49((CHAR*)"for", (LONGINT)4);
Enter__49((CHAR*)"fortran", (LONGINT)8);
Enter__49((CHAR*)"goto", (LONGINT)5);
Enter__49((CHAR*)"if", (LONGINT)3);
Enter__49((CHAR*)"import", (LONGINT)7);
Enter__49((CHAR*)"int", (LONGINT)4);
Enter__49((CHAR*)"long", (LONGINT)5);
Enter__49((CHAR*)"register", (LONGINT)9);
Enter__49((CHAR*)"return", (LONGINT)7);
Enter__49((CHAR*)"short", (LONGINT)6);
Enter__49((CHAR*)"signed", (LONGINT)7);
Enter__49((CHAR*)"sizeof", (LONGINT)7);
Enter__49((CHAR*)"static", (LONGINT)7);
Enter__49((CHAR*)"struct", (LONGINT)7);
Enter__49((CHAR*)"switch", (LONGINT)7);
Enter__49((CHAR*)"typedef", (LONGINT)8);
Enter__49((CHAR*)"union", (LONGINT)6);
Enter__49((CHAR*)"unsigned", (LONGINT)9);
Enter__49((CHAR*)"void", (LONGINT)5);
Enter__49((CHAR*)"volatile", (LONGINT)9);
Enter__49((CHAR*)"while", (LONGINT)6);
InitKeywords__48_s = _s.lnk;
}