From fb002de0dd35fd69a44d13670b21e40efaadad3c Mon Sep 17 00:00:00 2001 From: David Brown Date: Fri, 23 Sep 2016 19:04:26 +0100 Subject: [PATCH] Move alignment and type size code from OPC to OPT. Remove search path in bootstrap compiler. --- bootstrap/unix-44/Configuration.c | 6 +- bootstrap/unix-44/Configuration.h | 4 +- bootstrap/unix-44/Console.c | 2 +- bootstrap/unix-44/Console.h | 2 +- bootstrap/unix-44/Files.c | 2 +- bootstrap/unix-44/Files.h | 2 +- bootstrap/unix-44/Heap.c | 2 +- bootstrap/unix-44/Heap.h | 2 +- bootstrap/unix-44/Modules.c | 2 +- bootstrap/unix-44/Modules.h | 2 +- bootstrap/unix-44/OPB.c | 5 +- bootstrap/unix-44/OPB.h | 3 +- bootstrap/unix-44/OPC.c | 188 +++++++++--------------- bootstrap/unix-44/OPC.h | 5 +- bootstrap/unix-44/OPM.c | 7 +- bootstrap/unix-44/OPM.h | 2 +- bootstrap/unix-44/OPP.c | 2 +- bootstrap/unix-44/OPP.h | 2 +- bootstrap/unix-44/OPS.c | 2 +- bootstrap/unix-44/OPS.h | 2 +- bootstrap/unix-44/OPT.c | 207 ++++++++++++++++++++++----- bootstrap/unix-44/OPT.h | 8 +- bootstrap/unix-44/OPV.c | 88 +----------- bootstrap/unix-44/OPV.h | 3 +- bootstrap/unix-44/Platform.c | 2 +- bootstrap/unix-44/Platform.h | 2 +- bootstrap/unix-44/Reals.c | 2 +- bootstrap/unix-44/Reals.h | 2 +- bootstrap/unix-44/Strings.c | 2 +- bootstrap/unix-44/Strings.h | 2 +- bootstrap/unix-44/Texts.c | 2 +- bootstrap/unix-44/Texts.h | 2 +- bootstrap/unix-44/Vishap.c | 5 +- bootstrap/unix-44/errors.c | 2 +- bootstrap/unix-44/errors.h | 2 +- bootstrap/unix-44/extTools.c | 6 +- bootstrap/unix-44/extTools.h | 2 +- bootstrap/unix-44/vt100.c | 2 +- bootstrap/unix-44/vt100.h | 2 +- bootstrap/unix-48/Configuration.c | 6 +- bootstrap/unix-48/Configuration.h | 4 +- bootstrap/unix-48/Console.c | 2 +- bootstrap/unix-48/Console.h | 2 +- bootstrap/unix-48/Files.c | 2 +- bootstrap/unix-48/Files.h | 2 +- bootstrap/unix-48/Heap.c | 2 +- bootstrap/unix-48/Heap.h | 2 +- bootstrap/unix-48/Modules.c | 2 +- bootstrap/unix-48/Modules.h | 2 +- bootstrap/unix-48/OPB.c | 5 +- bootstrap/unix-48/OPB.h | 3 +- bootstrap/unix-48/OPC.c | 188 +++++++++--------------- bootstrap/unix-48/OPC.h | 5 +- bootstrap/unix-48/OPM.c | 7 +- bootstrap/unix-48/OPM.h | 2 +- bootstrap/unix-48/OPP.c | 2 +- bootstrap/unix-48/OPP.h | 2 +- bootstrap/unix-48/OPS.c | 2 +- bootstrap/unix-48/OPS.h | 2 +- bootstrap/unix-48/OPT.c | 207 ++++++++++++++++++++++----- bootstrap/unix-48/OPT.h | 8 +- bootstrap/unix-48/OPV.c | 88 +----------- bootstrap/unix-48/OPV.h | 3 +- bootstrap/unix-48/Platform.c | 2 +- bootstrap/unix-48/Platform.h | 2 +- bootstrap/unix-48/Reals.c | 2 +- bootstrap/unix-48/Reals.h | 2 +- bootstrap/unix-48/Strings.c | 2 +- bootstrap/unix-48/Strings.h | 2 +- bootstrap/unix-48/Texts.c | 2 +- bootstrap/unix-48/Texts.h | 2 +- bootstrap/unix-48/Vishap.c | 5 +- bootstrap/unix-48/errors.c | 2 +- bootstrap/unix-48/errors.h | 2 +- bootstrap/unix-48/extTools.c | 6 +- bootstrap/unix-48/extTools.h | 2 +- bootstrap/unix-48/vt100.c | 2 +- bootstrap/unix-48/vt100.h | 2 +- bootstrap/unix-88/Configuration.c | 6 +- bootstrap/unix-88/Configuration.h | 4 +- bootstrap/unix-88/Console.c | 2 +- bootstrap/unix-88/Console.h | 2 +- bootstrap/unix-88/Files.c | 2 +- bootstrap/unix-88/Files.h | 2 +- bootstrap/unix-88/Heap.c | 2 +- bootstrap/unix-88/Heap.h | 2 +- bootstrap/unix-88/Modules.c | 2 +- bootstrap/unix-88/Modules.h | 2 +- bootstrap/unix-88/OPB.c | 5 +- bootstrap/unix-88/OPB.h | 3 +- bootstrap/unix-88/OPC.c | 188 +++++++++--------------- bootstrap/unix-88/OPC.h | 5 +- bootstrap/unix-88/OPM.c | 7 +- bootstrap/unix-88/OPM.h | 2 +- bootstrap/unix-88/OPP.c | 2 +- bootstrap/unix-88/OPP.h | 2 +- bootstrap/unix-88/OPS.c | 2 +- bootstrap/unix-88/OPS.h | 2 +- bootstrap/unix-88/OPT.c | 207 ++++++++++++++++++++++----- bootstrap/unix-88/OPT.h | 8 +- bootstrap/unix-88/OPV.c | 88 +----------- bootstrap/unix-88/OPV.h | 3 +- bootstrap/unix-88/Platform.c | 2 +- bootstrap/unix-88/Platform.h | 2 +- bootstrap/unix-88/Reals.c | 2 +- bootstrap/unix-88/Reals.h | 2 +- bootstrap/unix-88/Strings.c | 2 +- bootstrap/unix-88/Strings.h | 2 +- bootstrap/unix-88/Texts.c | 2 +- bootstrap/unix-88/Texts.h | 2 +- bootstrap/unix-88/Vishap.c | 5 +- bootstrap/unix-88/errors.c | 2 +- bootstrap/unix-88/errors.h | 2 +- bootstrap/unix-88/extTools.c | 6 +- bootstrap/unix-88/extTools.h | 2 +- bootstrap/unix-88/vt100.c | 2 +- bootstrap/unix-88/vt100.h | 2 +- bootstrap/windows-48/Configuration.c | 6 +- bootstrap/windows-48/Configuration.h | 4 +- bootstrap/windows-48/Console.c | 2 +- bootstrap/windows-48/Console.h | 2 +- bootstrap/windows-48/Files.c | 2 +- bootstrap/windows-48/Files.h | 2 +- bootstrap/windows-48/Heap.c | 2 +- bootstrap/windows-48/Heap.h | 2 +- bootstrap/windows-48/Modules.c | 2 +- bootstrap/windows-48/Modules.h | 2 +- bootstrap/windows-48/OPB.c | 5 +- bootstrap/windows-48/OPB.h | 3 +- bootstrap/windows-48/OPC.c | 188 +++++++++--------------- bootstrap/windows-48/OPC.h | 5 +- bootstrap/windows-48/OPM.c | 7 +- bootstrap/windows-48/OPM.h | 2 +- bootstrap/windows-48/OPP.c | 2 +- bootstrap/windows-48/OPP.h | 2 +- bootstrap/windows-48/OPS.c | 2 +- bootstrap/windows-48/OPS.h | 2 +- bootstrap/windows-48/OPT.c | 207 ++++++++++++++++++++++----- bootstrap/windows-48/OPT.h | 8 +- bootstrap/windows-48/OPV.c | 88 +----------- bootstrap/windows-48/OPV.h | 3 +- bootstrap/windows-48/Platform.c | 2 +- bootstrap/windows-48/Platform.h | 2 +- bootstrap/windows-48/Reals.c | 2 +- bootstrap/windows-48/Reals.h | 2 +- bootstrap/windows-48/Strings.c | 2 +- bootstrap/windows-48/Strings.h | 2 +- bootstrap/windows-48/Texts.c | 2 +- bootstrap/windows-48/Texts.h | 2 +- bootstrap/windows-48/Vishap.c | 5 +- bootstrap/windows-48/errors.c | 2 +- bootstrap/windows-48/errors.h | 2 +- bootstrap/windows-48/extTools.c | 6 +- bootstrap/windows-48/extTools.h | 2 +- bootstrap/windows-48/vt100.c | 2 +- bootstrap/windows-48/vt100.h | 2 +- bootstrap/windows-88/Configuration.c | 6 +- bootstrap/windows-88/Configuration.h | 4 +- bootstrap/windows-88/Console.c | 2 +- bootstrap/windows-88/Console.h | 2 +- bootstrap/windows-88/Files.c | 2 +- bootstrap/windows-88/Files.h | 2 +- bootstrap/windows-88/Heap.c | 2 +- bootstrap/windows-88/Heap.h | 2 +- bootstrap/windows-88/Modules.c | 2 +- bootstrap/windows-88/Modules.h | 2 +- bootstrap/windows-88/OPB.c | 5 +- bootstrap/windows-88/OPB.h | 3 +- bootstrap/windows-88/OPC.c | 188 +++++++++--------------- bootstrap/windows-88/OPC.h | 5 +- bootstrap/windows-88/OPM.c | 7 +- bootstrap/windows-88/OPM.h | 2 +- bootstrap/windows-88/OPP.c | 2 +- bootstrap/windows-88/OPP.h | 2 +- bootstrap/windows-88/OPS.c | 2 +- bootstrap/windows-88/OPS.h | 2 +- bootstrap/windows-88/OPT.c | 207 ++++++++++++++++++++++----- bootstrap/windows-88/OPT.h | 8 +- bootstrap/windows-88/OPV.c | 88 +----------- bootstrap/windows-88/OPV.h | 3 +- bootstrap/windows-88/Platform.c | 2 +- bootstrap/windows-88/Platform.h | 2 +- bootstrap/windows-88/Reals.c | 2 +- bootstrap/windows-88/Reals.h | 2 +- bootstrap/windows-88/Strings.c | 2 +- bootstrap/windows-88/Strings.h | 2 +- bootstrap/windows-88/Texts.c | 2 +- bootstrap/windows-88/Texts.h | 2 +- bootstrap/windows-88/Vishap.c | 5 +- bootstrap/windows-88/errors.c | 2 +- bootstrap/windows-88/errors.h | 2 +- bootstrap/windows-88/extTools.c | 6 +- bootstrap/windows-88/extTools.h | 2 +- bootstrap/windows-88/vt100.c | 2 +- bootstrap/windows-88/vt100.h | 2 +- makefile | 12 +- src/compiler/OPB.Mod | 3 +- src/compiler/OPC.Mod | 46 +----- src/compiler/OPT.Mod | 98 ++++++++++++- src/compiler/OPV.Mod | 56 +------- src/compiler/Vishap.Mod | 3 +- src/tools/make/configure.c | 65 +++++---- 202 files changed, 1628 insertions(+), 1590 deletions(-) diff --git a/bootstrap/unix-44/Configuration.c b/bootstrap/unix-44/Configuration.c index abdf151b..7f7f4b26 100644 --- a/bootstrap/unix-44/Configuration.c +++ b/bootstrap/unix-44/Configuration.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -7,7 +7,7 @@ #include "SYSTEM.h" -export CHAR Configuration_versionLong[41]; +export CHAR Configuration_versionLong[75]; @@ -18,6 +18,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("1.95 [2016/09/23] for gcc LP64 on cygwin", Configuration_versionLong, 41); + __MOVE("1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); __ENDMOD; } diff --git a/bootstrap/unix-44/Configuration.h b/bootstrap/unix-44/Configuration.h index f51f63f2..618bc77f 100644 --- a/bootstrap/unix-44/Configuration.h +++ b/bootstrap/unix-44/Configuration.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Configuration__h #define Configuration__h @@ -6,7 +6,7 @@ #include "SYSTEM.h" -import CHAR Configuration_versionLong[41]; +import CHAR Configuration_versionLong[75]; import void *Configuration__init(void); diff --git a/bootstrap/unix-44/Console.c b/bootstrap/unix-44/Console.c index 115e60f5..f9e5e585 100644 --- a/bootstrap/unix-44/Console.c +++ b/bootstrap/unix-44/Console.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-44/Console.h b/bootstrap/unix-44/Console.h index b08c93ea..d645f05c 100644 --- a/bootstrap/unix-44/Console.h +++ b/bootstrap/unix-44/Console.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Console__h #define Console__h diff --git a/bootstrap/unix-44/Files.c b/bootstrap/unix-44/Files.c index 0a7ac692..ad002606 100644 --- a/bootstrap/unix-44/Files.c +++ b/bootstrap/unix-44/Files.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin tspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-44/Files.h b/bootstrap/unix-44/Files.h index e2b7a3bb..0518133f 100644 --- a/bootstrap/unix-44/Files.h +++ b/bootstrap/unix-44/Files.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin tspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/unix-44/Heap.c b/bootstrap/unix-44/Heap.c index b7c8c827..905fcb24 100644 --- a/bootstrap/unix-44/Heap.c +++ b/bootstrap/unix-44/Heap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin tsSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-44/Heap.h b/bootstrap/unix-44/Heap.h index 6ad4813e..3ea975a7 100644 --- a/bootstrap/unix-44/Heap.h +++ b/bootstrap/unix-44/Heap.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin tsSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ #ifndef Heap__h #define Heap__h diff --git a/bootstrap/unix-44/Modules.c b/bootstrap/unix-44/Modules.c index 7704f005..21d62e05 100644 --- a/bootstrap/unix-44/Modules.c +++ b/bootstrap/unix-44/Modules.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-44/Modules.h b/bootstrap/unix-44/Modules.h index 060208c6..d2d0a476 100644 --- a/bootstrap/unix-44/Modules.h +++ b/bootstrap/unix-44/Modules.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Modules__h #define Modules__h diff --git a/bootstrap/unix-44/OPB.c b/bootstrap/unix-44/OPB.c index e09bf1b4..6c15aa17 100644 --- a/bootstrap/unix-44/OPB.c +++ b/bootstrap/unix-44/OPB.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -10,7 +10,6 @@ #include "OPT.h" -export void (*OPB_typSize)(OPT_Struct); static int16 OPB_exp; static int64 OPB_maxExp; @@ -1917,7 +1916,7 @@ void OPB_StPar0 (OPT_Node *par0, int16 fctno) OPB_err(110); x = OPB_NewIntConst(1); } else if (__IN(f, 0x18fe, 32) || __IN(x->typ->comp, 0x14, 32)) { - (*OPB_typSize)(x->typ); + OPT_TypSize(x->typ); x->typ->pvused = 1; x = OPB_NewIntConst(x->typ->size); } else { diff --git a/bootstrap/unix-44/OPB.h b/bootstrap/unix-44/OPB.h index dc0085af..8395741b 100644 --- a/bootstrap/unix-44/OPB.h +++ b/bootstrap/unix-44/OPB.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPB__h #define OPB__h @@ -8,7 +8,6 @@ #include "OPT.h" -import void (*OPB_typSize)(OPT_Struct); import void OPB_Assign (OPT_Node *x, OPT_Node y); diff --git a/bootstrap/unix-44/OPC.c b/bootstrap/unix-44/OPC.c index 99353400..9104c5c4 100644 --- a/bootstrap/unix-44/OPC.c +++ b/bootstrap/unix-44/OPC.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -17,10 +17,8 @@ static BOOLEAN OPC_GlbPtrs; static CHAR OPC_BodyNameExt[13]; -export void OPC_Align (int32 *adr, int32 base); export void OPC_Andent (OPT_Struct typ); static void OPC_AnsiParamList (OPT_Object obj, BOOLEAN showParamNames); -export int32 OPC_BaseAlignment (OPT_Struct typ); export OPT_Object OPC_BaseTProc (OPT_Object obj); export void OPC_BegBlk (void); export void OPC_BegStat (void); @@ -79,7 +77,6 @@ static void OPC_PutBase (OPT_Struct typ); static void OPC_PutPtrOffsets (OPT_Struct typ, int32 adr, int32 *cnt); static void OPC_RegCmds (OPT_Object obj); export void OPC_SetInclude (BOOLEAN exclude); -export int32 OPC_SizeAlignment (int32 size); static void OPC_Stars (OPT_Struct typ, BOOLEAN *openClause); static void OPC_Str1 (CHAR *s, LONGINT s__len, int32 x); static void OPC_StringLiteral (CHAR *s, LONGINT s__len, int32 l); @@ -750,7 +747,7 @@ static void OPC_CProcDefs (OPT_Object obj, int16 vis) { int16 i; OPT_ConstExt ext = NIL; - int16 _for__9; + int16 _for__7; if (obj != NIL) { OPC_CProcDefs(obj->left, vis); if ((((obj->mode == 9 && (int16)obj->vis >= vis)) && obj->adr == 1)) { @@ -762,9 +759,9 @@ static void OPC_CProcDefs (OPT_Object obj, int16 vis) OPC_DeclareParams(obj->link, 1); OPM_Write(0x09); } - _for__9 = (int16)(*obj->conval->ext)[0]; + _for__7 = (int16)(*obj->conval->ext)[0]; i = i; - while (i <= _for__9) { + while (i <= _for__7) { OPM_Write((*obj->conval->ext)[__X(i, 256)]); i += 1; } @@ -843,64 +840,11 @@ void OPC_InitTDesc (OPT_Struct typ) } } -void OPC_Align (int32 *adr, int32 base) -{ - switch (base) { - case 2: - *adr += __MASK(*adr, -2); - break; - case 4: - *adr += __MASK(-*adr, -4); - break; - case 8: - *adr += __MASK(-*adr, -8); - break; - case 16: - *adr += __MASK(-*adr, -16); - break; - default: - break; - } -} - -int32 OPC_SizeAlignment (int32 size) -{ - int32 _o_result; - int32 alignment; - if (size < OPM_Alignment) { - alignment = 1; - while (alignment < size) { - alignment = __ASHL(alignment, 1); - } - } else { - alignment = OPM_Alignment; - } - _o_result = alignment; - return _o_result; -} - -int32 OPC_BaseAlignment (OPT_Struct typ) -{ - int32 _o_result; - int32 alignment; - if (typ->form == 13) { - 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 (int32 gap, int32 off, int32 align, int32 *n, int32 *curAlign) { int32 adr; adr = off; - OPC_Align(&adr, align); + OPT_Align(&adr, align); if ((*curAlign < align && gap - (adr - off) >= align)) { gap -= (adr - off) + align; OPC_BegStat(); @@ -955,8 +899,8 @@ static void OPC_FieldList (OPT_Struct typ, BOOLEAN last, int32 *off, int32 *n, i } } else { adr = *off; - fldAlign = OPC_BaseAlignment(fld->typ); - OPC_Align(&adr, fldAlign); + fldAlign = OPT_BaseAlignment(fld->typ); + OPT_Align(&adr, fldAlign); gap = fld->adr - adr; if (fldAlign > *curAlign) { *curAlign = fldAlign; @@ -1205,7 +1149,7 @@ static void OPC_GenHeaderMsg (void) OPM_WriteString((CHAR*)"/* ", 4); OPM_WriteString((CHAR*)"voc", 4); OPM_Write(' '); - OPM_WriteString(Configuration_versionLong, 41); + OPM_WriteString(Configuration_versionLong, 75); OPM_Write(' '); i = 0; while (i <= 31) { @@ -1966,84 +1910,84 @@ void OPC_Constant (OPT_Const con, int16 form) } } -static struct InitKeywords__48 { +static struct InitKeywords__46 { int8 *n; - struct InitKeywords__48 *lnk; -} *InitKeywords__48_s; + struct InitKeywords__46 *lnk; +} *InitKeywords__46_s; -static void Enter__49 (CHAR *s, LONGINT s__len); +static void Enter__47 (CHAR *s, LONGINT s__len); -static void Enter__49 (CHAR *s, LONGINT s__len) +static void Enter__47 (CHAR *s, LONGINT s__len) { int16 h; __DUP(s, s__len, CHAR); h = OPC_PerfectHash((void*)s, s__len); - OPC_hashtab[__X(h, 105)] = *InitKeywords__48_s->n; - __COPY(s, OPC_keytab[__X(*InitKeywords__48_s->n, 50)], 9); - *InitKeywords__48_s->n += 1; + OPC_hashtab[__X(h, 105)] = *InitKeywords__46_s->n; + __COPY(s, OPC_keytab[__X(*InitKeywords__46_s->n, 50)], 9); + *InitKeywords__46_s->n += 1; __DEL(s); } static void OPC_InitKeywords (void) { int8 n, i; - struct InitKeywords__48 _s; + struct InitKeywords__46 _s; _s.n = &n; - _s.lnk = InitKeywords__48_s; - InitKeywords__48_s = &_s; + _s.lnk = InitKeywords__46_s; + InitKeywords__46_s = &_s; n = 0; i = 0; while (i <= 104) { OPC_hashtab[__X(i, 105)] = -1; i += 1; } - Enter__49((CHAR*)"address", 8); - Enter__49((CHAR*)"asm", 4); - Enter__49((CHAR*)"auto", 5); - Enter__49((CHAR*)"break", 6); - Enter__49((CHAR*)"case", 5); - Enter__49((CHAR*)"char", 5); - Enter__49((CHAR*)"const", 6); - Enter__49((CHAR*)"continue", 9); - Enter__49((CHAR*)"default", 8); - Enter__49((CHAR*)"do", 3); - Enter__49((CHAR*)"double", 7); - Enter__49((CHAR*)"else", 5); - Enter__49((CHAR*)"enum", 5); - Enter__49((CHAR*)"extern", 7); - Enter__49((CHAR*)"export", 7); - Enter__49((CHAR*)"float", 6); - Enter__49((CHAR*)"for", 4); - Enter__49((CHAR*)"fortran", 8); - Enter__49((CHAR*)"goto", 5); - Enter__49((CHAR*)"if", 3); - Enter__49((CHAR*)"import", 7); - Enter__49((CHAR*)"int", 4); - Enter__49((CHAR*)"int16", 6); - Enter__49((CHAR*)"int32", 6); - Enter__49((CHAR*)"int64", 6); - Enter__49((CHAR*)"int8", 5); - Enter__49((CHAR*)"long", 5); - Enter__49((CHAR*)"register", 9); - Enter__49((CHAR*)"return", 7); - Enter__49((CHAR*)"short", 6); - Enter__49((CHAR*)"signed", 7); - Enter__49((CHAR*)"sizeof", 7); - Enter__49((CHAR*)"size_t", 7); - Enter__49((CHAR*)"static", 7); - Enter__49((CHAR*)"struct", 7); - Enter__49((CHAR*)"switch", 7); - Enter__49((CHAR*)"typedef", 8); - Enter__49((CHAR*)"uint16", 7); - Enter__49((CHAR*)"uint32", 7); - Enter__49((CHAR*)"uint64", 7); - Enter__49((CHAR*)"uint8", 6); - Enter__49((CHAR*)"union", 6); - Enter__49((CHAR*)"unsigned", 9); - Enter__49((CHAR*)"void", 5); - Enter__49((CHAR*)"volatile", 9); - Enter__49((CHAR*)"while", 6); - InitKeywords__48_s = _s.lnk; + Enter__47((CHAR*)"address", 8); + Enter__47((CHAR*)"asm", 4); + Enter__47((CHAR*)"auto", 5); + Enter__47((CHAR*)"break", 6); + Enter__47((CHAR*)"case", 5); + Enter__47((CHAR*)"char", 5); + Enter__47((CHAR*)"const", 6); + Enter__47((CHAR*)"continue", 9); + Enter__47((CHAR*)"default", 8); + Enter__47((CHAR*)"do", 3); + Enter__47((CHAR*)"double", 7); + Enter__47((CHAR*)"else", 5); + Enter__47((CHAR*)"enum", 5); + Enter__47((CHAR*)"extern", 7); + Enter__47((CHAR*)"export", 7); + Enter__47((CHAR*)"float", 6); + Enter__47((CHAR*)"for", 4); + Enter__47((CHAR*)"fortran", 8); + Enter__47((CHAR*)"goto", 5); + Enter__47((CHAR*)"if", 3); + Enter__47((CHAR*)"import", 7); + Enter__47((CHAR*)"int", 4); + Enter__47((CHAR*)"int16", 6); + Enter__47((CHAR*)"int32", 6); + Enter__47((CHAR*)"int64", 6); + Enter__47((CHAR*)"int8", 5); + Enter__47((CHAR*)"long", 5); + Enter__47((CHAR*)"register", 9); + Enter__47((CHAR*)"return", 7); + Enter__47((CHAR*)"short", 6); + Enter__47((CHAR*)"signed", 7); + Enter__47((CHAR*)"sizeof", 7); + Enter__47((CHAR*)"size_t", 7); + Enter__47((CHAR*)"static", 7); + Enter__47((CHAR*)"struct", 7); + Enter__47((CHAR*)"switch", 7); + Enter__47((CHAR*)"typedef", 8); + Enter__47((CHAR*)"uint16", 7); + Enter__47((CHAR*)"uint32", 7); + Enter__47((CHAR*)"uint64", 7); + Enter__47((CHAR*)"uint8", 6); + Enter__47((CHAR*)"union", 6); + Enter__47((CHAR*)"unsigned", 9); + Enter__47((CHAR*)"void", 5); + Enter__47((CHAR*)"volatile", 9); + Enter__47((CHAR*)"while", 6); + InitKeywords__46_s = _s.lnk; } diff --git a/bootstrap/unix-44/OPC.h b/bootstrap/unix-44/OPC.h index 4215947f..6236cd73 100644 --- a/bootstrap/unix-44/OPC.h +++ b/bootstrap/unix-44/OPC.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPC__h #define OPC__h @@ -9,9 +9,7 @@ -import void OPC_Align (int32 *adr, int32 base); import void OPC_Andent (OPT_Struct typ); -import int32 OPC_BaseAlignment (OPT_Struct typ); import OPT_Object OPC_BaseTProc (OPT_Object obj); import void OPC_BegBlk (void); import void OPC_BegStat (void); @@ -41,7 +39,6 @@ import void OPC_IntLiteral (int64 n, int32 size); import void OPC_Len (OPT_Object obj, OPT_Struct array, int64 dim); import int32 OPC_NofPtrs (OPT_Struct typ); import void OPC_SetInclude (BOOLEAN exclude); -import int32 OPC_SizeAlignment (int32 size); import void OPC_TDescDecl (OPT_Struct typ); import void OPC_TypeDefs (OPT_Object obj, int16 vis); import void OPC_TypeOf (OPT_Object ap); diff --git a/bootstrap/unix-44/OPM.c b/bootstrap/unix-44/OPM.c index 8b1f6805..9297c0a3 100644 --- a/bootstrap/unix-44/OPM.c +++ b/bootstrap/unix-44/OPM.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -223,6 +223,7 @@ static void OPM_ScanOptions (CHAR *s, LONGINT s__len, SET *opt) OPM_AddressSize = (int16)s[__X(i + 1, s__len)] - 48; OPM_Alignment = (int16)s[__X(i + 2, s__len)] - 48; i += 2; + Files_SetSearchPath((CHAR*)"", 1); } break; case 'B': @@ -270,7 +271,7 @@ BOOLEAN OPM_OpenPar (void) if (Platform_ArgCount == 1) { OPM_LogWLn(); OPM_LogWStr((CHAR*)"Oberon-2 compiler v", 20); - OPM_LogWStr(Configuration_versionLong, 41); + OPM_LogWStr(Configuration_versionLong, 75); OPM_LogW('.'); OPM_LogWLn(); OPM_LogWStr((CHAR*)"Based on Ofront by Software Templ OEG.", 39); @@ -1118,7 +1119,7 @@ export void *OPM__init(void) Strings_Append((CHAR*)";.;", 4, (void*)OPM_OBERON, 1024); Strings_Append(OPM_MODULES, 1024, (void*)OPM_OBERON, 1024); Strings_Append((CHAR*)";", 2, (void*)OPM_OBERON, 1024); - Strings_Append((CHAR*)"/opt/voc", 9, (void*)OPM_OBERON, 1024); + Strings_Append((CHAR*)"", 1, (void*)OPM_OBERON, 1024); Strings_Append((CHAR*)"/sym;", 6, (void*)OPM_OBERON, 1024); Files_SetSearchPath(OPM_OBERON, 1024); OPM_AddressSize = 4; diff --git a/bootstrap/unix-44/OPM.h b/bootstrap/unix-44/OPM.h index 96af4022..b62666db 100644 --- a/bootstrap/unix-44/OPM.h +++ b/bootstrap/unix-44/OPM.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPM__h #define OPM__h diff --git a/bootstrap/unix-44/OPP.c b/bootstrap/unix-44/OPP.c index a3ab1dd3..66b821d2 100644 --- a/bootstrap/unix-44/OPP.c +++ b/bootstrap/unix-44/OPP.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-44/OPP.h b/bootstrap/unix-44/OPP.h index e5a59f6c..ea6663ba 100644 --- a/bootstrap/unix-44/OPP.h +++ b/bootstrap/unix-44/OPP.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/unix-44/OPS.c b/bootstrap/unix-44/OPS.c index 0cac83bd..2b449cae 100644 --- a/bootstrap/unix-44/OPS.c +++ b/bootstrap/unix-44/OPS.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin tspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-44/OPS.h b/bootstrap/unix-44/OPS.h index caef45f4..8d90d974 100644 --- a/bootstrap/unix-44/OPS.h +++ b/bootstrap/unix-44/OPS.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin tspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/unix-44/OPT.c b/bootstrap/unix-44/OPT.c index 8e7d9b8d..7405b27f 100644 --- a/bootstrap/unix-44/OPT.c +++ b/bootstrap/unix-44/OPT.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -87,7 +87,6 @@ typedef } OPT_StrDesc; -export void (*OPT_typSize)(OPT_Struct); export OPT_Object OPT_topScope; export OPT_Struct OPT_undftyp, OPT_bytetyp, OPT_booltyp, OPT_chartyp, OPT_sinttyp, OPT_inttyp, OPT_linttyp, OPT_hinttyp, OPT_adrtyp, OPT_int8typ, OPT_int16typ, OPT_int32typ, OPT_int64typ, OPT_realtyp, OPT_lrltyp, OPT_settyp, OPT_stringtyp, OPT_niltyp, OPT_notyp, OPT_sysptrtyp; export OPT_Object OPT_sintobj, OPT_intobj, OPT_lintobj; @@ -100,6 +99,7 @@ static OPT_ImpCtxt OPT_impCtxt; static OPT_ExpCtxt OPT_expCtxt; static int32 OPT_nofhdfld; static BOOLEAN OPT_newsf, OPT_findpc, OPT_extsf, OPT_sfpresent, OPT_symExtended, OPT_symNew; +static int32 OPT_recno; export address *OPT_ConstDesc__typ; export address *OPT_ObjDesc__typ; @@ -108,6 +108,8 @@ export address *OPT_NodeDesc__typ; export address *OPT_ImpCtxt__typ; export address *OPT_ExpCtxt__typ; +export void OPT_Align (int32 *adr, int32 base); +export int32 OPT_BaseAlignment (OPT_Struct typ); export void OPT_Close (void); export void OPT_CloseScope (void); static void OPT_DebugStruct (OPT_Struct btyp); @@ -136,6 +138,7 @@ static void OPT_InStruct (OPT_Struct *typ); static OPT_Object OPT_InTProc (int8 mno); static OPT_Struct OPT_InTyp (int32 tag); export void OPT_Init (OPS_Name name, SET opt); +export void OPT_InitRecno (void); static void OPT_InitStruct (OPT_Struct *typ, int8 form); export void OPT_Insert (OPS_Name name, OPT_Object *obj); export void OPT_InsertImport (OPT_Object obj, OPT_Object *root, OPT_Object *old); @@ -157,9 +160,16 @@ static void OPT_OutSign (OPT_Struct result, OPT_Object par); static void OPT_OutStr (OPT_Struct typ); static void OPT_OutTProcs (OPT_Struct typ, OPT_Object obj); export OPT_Struct OPT_ShorterOrLongerType (OPT_Struct x, int16 dir); +export int32 OPT_SizeAlignment (int32 size); +export void OPT_TypSize (OPT_Struct typ); static void OPT_err (int16 n); +void OPT_InitRecno (void) +{ + OPT_recno = 0; +} + static void OPT_err (int16 n) { OPM_err(n); @@ -240,6 +250,130 @@ OPT_Struct OPT_ShorterOrLongerType (OPT_Struct x, int16 dir) __RETCHK; } +void OPT_Align (int32 *adr, int32 base) +{ + switch (base) { + case 2: + *adr += __MASK(*adr, -2); + break; + case 4: + *adr += __MASK(-*adr, -4); + break; + case 8: + *adr += __MASK(-*adr, -8); + break; + case 16: + *adr += __MASK(-*adr, -16); + break; + default: + break; + } +} + +int32 OPT_SizeAlignment (int32 size) +{ + int32 _o_result; + int32 alignment; + if (size < OPM_Alignment) { + alignment = 1; + while (alignment < size) { + alignment = __ASHL(alignment, 1); + } + } else { + alignment = OPM_Alignment; + } + _o_result = alignment; + return _o_result; +} + +int32 OPT_BaseAlignment (OPT_Struct typ) +{ + int32 _o_result; + int32 alignment; + if (typ->form == 13) { + if (typ->comp == 4) { + alignment = __MASK(typ->align, -65536); + } else { + alignment = OPT_BaseAlignment(typ->BaseTyp); + } + } else { + alignment = OPT_SizeAlignment(typ->size); + } + _o_result = alignment; + return _o_result; +} + +void OPT_TypSize (OPT_Struct typ) +{ + int16 f, c; + int32 offset, size, base, fbase, off0; + OPT_Object fld = NIL; + OPT_Struct btyp = NIL; + if (typ == OPT_undftyp) { + OPM_err(58); + } else if (typ->size == -1) { + f = typ->form; + c = typ->comp; + if (c == 4) { + btyp = typ->BaseTyp; + if (btyp == NIL) { + offset = 0; + base = 1; + } else { + OPT_TypSize(btyp); + offset = btyp->size - __ASHR(btyp->sysflag, 8); + base = btyp->align; + } + fld = typ->link; + while ((fld != NIL && fld->mode == 4)) { + btyp = fld->typ; + OPT_TypSize(btyp); + size = btyp->size; + fbase = OPT_BaseAlignment(btyp); + OPT_Align(&offset, fbase); + fld->adr = offset; + offset += size; + if (fbase > base) { + base = fbase; + } + fld = fld->link; + } + off0 = offset; + if (offset == 0) { + offset = 1; + } + OPT_Align(&offset, base); + if ((typ->strobj == NIL && __MASK(typ->align, -65536) == 0)) { + OPT_recno += 1; + base += __ASHL(OPT_recno, 16); + } + typ->size = offset; + typ->align = base; + typ->sysflag = __MASK(typ->sysflag, -256) + (int16)__ASHL(offset - off0, 8); + } else if (c == 2) { + OPT_TypSize(typ->BaseTyp); + typ->size = typ->n * typ->BaseTyp->size; + } else if (f == 11) { + typ->size = OPM_AddressSize; + if (typ->BaseTyp == OPT_undftyp) { + OPM_Mark(128, typ->n); + } else { + OPT_TypSize(typ->BaseTyp); + } + } else if (f == 12) { + typ->size = OPM_AddressSize; + } else if (c == 3) { + btyp = typ->BaseTyp; + OPT_TypSize(btyp); + if (btyp->comp == 3) { + typ->size = btyp->size + 4; + } else { + typ->size = 8; + } + } + } +} + OPT_Const OPT_NewConst (void) { OPT_Const _o_result; @@ -552,21 +686,21 @@ void OPT_IdFPrint (OPT_Struct typ) } } -static struct FPrintStr__13 { +static struct FPrintStr__15 { int32 *pbfp, *pvfp; - struct FPrintStr__13 *lnk; -} *FPrintStr__13_s; + struct FPrintStr__15 *lnk; +} *FPrintStr__15_s; -static void FPrintFlds__14 (OPT_Object fld, int32 adr, BOOLEAN visible); -static void FPrintHdFld__16 (OPT_Struct typ, OPT_Object fld, int32 adr); -static void FPrintTProcs__18 (OPT_Object obj); +static void FPrintFlds__16 (OPT_Object fld, int32 adr, BOOLEAN visible); +static void FPrintHdFld__18 (OPT_Struct typ, OPT_Object fld, int32 adr); +static void FPrintTProcs__20 (OPT_Object obj); -static void FPrintHdFld__16 (OPT_Struct typ, OPT_Object fld, int32 adr) +static void FPrintHdFld__18 (OPT_Struct typ, OPT_Object fld, int32 adr) { int32 i, j, n; OPT_Struct btyp = NIL; if (typ->comp == 4) { - FPrintFlds__14(typ->link, adr, 0); + FPrintFlds__16(typ->link, adr, 0); } else if (typ->comp == 2) { btyp = typ->BaseTyp; n = typ->n; @@ -576,53 +710,53 @@ static void FPrintHdFld__16 (OPT_Struct typ, OPT_Object fld, int32 adr) } if (btyp->form == 11 || btyp->comp == 4) { j = OPT_nofhdfld; - FPrintHdFld__16(btyp, fld, adr); + FPrintHdFld__18(btyp, fld, adr); if (j != OPT_nofhdfld) { i = 1; while ((i < n && OPT_nofhdfld <= 2048)) { adr += btyp->size; - FPrintHdFld__16(btyp, fld, adr); + FPrintHdFld__18(btyp, fld, adr); i += 1; } } } } else if (typ->form == 11 || __STRCMP(fld->name, "@ptr") == 0) { - OPM_FPrint(&*FPrintStr__13_s->pvfp, 11); - OPM_FPrint(&*FPrintStr__13_s->pvfp, adr); + OPM_FPrint(&*FPrintStr__15_s->pvfp, 11); + OPM_FPrint(&*FPrintStr__15_s->pvfp, adr); OPT_nofhdfld += 1; } } -static void FPrintFlds__14 (OPT_Object fld, int32 adr, BOOLEAN visible) +static void FPrintFlds__16 (OPT_Object fld, int32 adr, BOOLEAN visible) { while ((fld != NIL && fld->mode == 4)) { if ((fld->vis != 0 && visible)) { - OPM_FPrint(&*FPrintStr__13_s->pbfp, fld->vis); - OPT_FPrintName(&*FPrintStr__13_s->pbfp, (void*)fld->name, 256); - OPM_FPrint(&*FPrintStr__13_s->pbfp, fld->adr); + OPM_FPrint(&*FPrintStr__15_s->pbfp, fld->vis); + OPT_FPrintName(&*FPrintStr__15_s->pbfp, (void*)fld->name, 256); + OPM_FPrint(&*FPrintStr__15_s->pbfp, fld->adr); OPT_FPrintStr(fld->typ); - OPM_FPrint(&*FPrintStr__13_s->pbfp, fld->typ->pbfp); - OPM_FPrint(&*FPrintStr__13_s->pvfp, fld->typ->pvfp); + OPM_FPrint(&*FPrintStr__15_s->pbfp, fld->typ->pbfp); + OPM_FPrint(&*FPrintStr__15_s->pvfp, fld->typ->pvfp); } else { - FPrintHdFld__16(fld->typ, fld, fld->adr + adr); + FPrintHdFld__18(fld->typ, fld, fld->adr + adr); } fld = fld->link; } } -static void FPrintTProcs__18 (OPT_Object obj) +static void FPrintTProcs__20 (OPT_Object obj) { if (obj != NIL) { - FPrintTProcs__18(obj->left); + FPrintTProcs__20(obj->left); if (obj->mode == 13) { if (obj->vis != 0) { - OPM_FPrint(&*FPrintStr__13_s->pbfp, 13); - OPM_FPrint(&*FPrintStr__13_s->pbfp, __ASHR(obj->adr, 16)); - OPT_FPrintSign(&*FPrintStr__13_s->pbfp, obj->typ, obj->link); - OPT_FPrintName(&*FPrintStr__13_s->pbfp, (void*)obj->name, 256); + OPM_FPrint(&*FPrintStr__15_s->pbfp, 13); + OPM_FPrint(&*FPrintStr__15_s->pbfp, __ASHR(obj->adr, 16)); + OPT_FPrintSign(&*FPrintStr__15_s->pbfp, obj->typ, obj->link); + OPT_FPrintName(&*FPrintStr__15_s->pbfp, (void*)obj->name, 256); } } - FPrintTProcs__18(obj->right); + FPrintTProcs__20(obj->right); } } @@ -632,11 +766,11 @@ void OPT_FPrintStr (OPT_Struct typ) OPT_Struct btyp = NIL; OPT_Object strobj = NIL, bstrobj = NIL; int32 pbfp, pvfp; - struct FPrintStr__13 _s; + struct FPrintStr__15 _s; _s.pbfp = &pbfp; _s.pvfp = &pvfp; - _s.lnk = FPrintStr__13_s; - FPrintStr__13_s = &_s; + _s.lnk = FPrintStr__15_s; + FPrintStr__15_s = &_s; if (!typ->fpdone) { OPT_IdFPrint(typ); pbfp = typ->idfp; @@ -673,11 +807,11 @@ void OPT_FPrintStr (OPT_Struct typ) OPM_FPrint(&pvfp, typ->align); OPM_FPrint(&pvfp, typ->n); OPT_nofhdfld = 0; - FPrintFlds__14(typ->link, 0, 1); + FPrintFlds__16(typ->link, 0, 1); if (OPT_nofhdfld > 2048) { OPM_Mark(225, typ->txtpos); } - FPrintTProcs__18(typ->link); + FPrintTProcs__20(typ->link); OPM_FPrint(&pvfp, pbfp); strobj = typ->strobj; if (strobj == NIL || strobj->name[0] == 0x00) { @@ -687,7 +821,7 @@ void OPT_FPrintStr (OPT_Struct typ) typ->pbfp = pbfp; typ->pvfp = pvfp; } - FPrintStr__13_s = _s.lnk; + FPrintStr__15_s = _s.lnk; } void OPT_FPrintObj (OPT_Object obj) @@ -1119,7 +1253,7 @@ static void OPT_InStruct (OPT_Struct *typ) (*typ)->comp = 2; OPT_InStruct(&(*typ)->BaseTyp); (*typ)->n = OPM_SymRInt(); - (*OPT_typSize)(*typ); + OPT_TypSize(*typ); break; case 38: (*typ)->form = 13; @@ -1130,7 +1264,7 @@ static void OPT_InStruct (OPT_Struct *typ) } else { (*typ)->n = 0; } - (*OPT_typSize)(*typ); + OPT_TypSize(*typ); break; case 39: (*typ)->form = 13; @@ -1899,6 +2033,7 @@ export void *OPT__init(void) __REGMOD("OPT", EnumPtrs); __REGCMD("Close", OPT_Close); __REGCMD("CloseScope", OPT_CloseScope); + __REGCMD("InitRecno", OPT_InitRecno); __INITYP(OPT_ConstDesc, OPT_ConstDesc, 0); __INITYP(OPT_ObjDesc, OPT_ObjDesc, 0); __INITYP(OPT_StrDesc, OPT_StrDesc, 0); diff --git a/bootstrap/unix-44/OPT.h b/bootstrap/unix-44/OPT.h index 0bd1f189..1a525fcb 100644 --- a/bootstrap/unix-44/OPT.h +++ b/bootstrap/unix-44/OPT.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPT__h #define OPT__h @@ -66,7 +66,6 @@ typedef } OPT_StrDesc; -import void (*OPT_typSize)(OPT_Struct); import OPT_Object OPT_topScope; import OPT_Struct OPT_undftyp, OPT_bytetyp, OPT_booltyp, OPT_chartyp, OPT_sinttyp, OPT_inttyp, OPT_linttyp, OPT_hinttyp, OPT_adrtyp, OPT_int8typ, OPT_int16typ, OPT_int32typ, OPT_int64typ, OPT_realtyp, OPT_lrltyp, OPT_settyp, OPT_stringtyp, OPT_niltyp, OPT_notyp, OPT_sysptrtyp; import OPT_Object OPT_sintobj, OPT_intobj, OPT_lintobj; @@ -80,6 +79,8 @@ import address *OPT_ObjDesc__typ; import address *OPT_StrDesc__typ; import address *OPT_NodeDesc__typ; +import void OPT_Align (int32 *adr, int32 base); +import int32 OPT_BaseAlignment (OPT_Struct typ); import void OPT_Close (void); import void OPT_CloseScope (void); import void OPT_Export (BOOLEAN *ext, BOOLEAN *new); @@ -92,6 +93,7 @@ import void OPT_FindImport (OPT_Object mod, OPT_Object *res); import void OPT_IdFPrint (OPT_Struct typ); import void OPT_Import (OPS_Name aliasName, OPS_Name name, BOOLEAN *done); import void OPT_Init (OPS_Name name, SET opt); +import void OPT_InitRecno (void); import void OPT_Insert (OPS_Name name, OPT_Object *obj); import void OPT_InsertImport (OPT_Object obj, OPT_Object *root, OPT_Object *old); import int16 OPT_IntSize (int64 n); @@ -103,6 +105,8 @@ import OPT_Object OPT_NewObj (void); import OPT_Struct OPT_NewStr (int8 form, int8 comp); import void OPT_OpenScope (int8 level, OPT_Object owner); import OPT_Struct OPT_ShorterOrLongerType (OPT_Struct x, int16 dir); +import int32 OPT_SizeAlignment (int32 size); +import void OPT_TypSize (OPT_Struct typ); import void *OPT__init(void); diff --git a/bootstrap/unix-44/OPV.c b/bootstrap/unix-44/OPV.c index 8bb5ec32..cdb2ab50 100644 --- a/bootstrap/unix-44/OPV.c +++ b/bootstrap/unix-44/OPV.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -17,7 +17,6 @@ typedef static int16 OPV_stamp; -static int32 OPV_recno; static OPV_ExitInfo OPV_exit; static int16 OPV_nofExitLabels; @@ -46,88 +45,15 @@ static void OPV_Stamp (OPS_Name s); static OPT_Object OPV_SuperProc (OPT_Node n); static void OPV_Traverse (OPT_Object obj, OPT_Object outerScope, BOOLEAN exported); static void OPV_TraverseRecord (OPT_Struct typ); -export void OPV_TypSize (OPT_Struct typ); static void OPV_TypeOf (OPT_Node n); static void OPV_design (OPT_Node n, int16 prec); static void OPV_expr (OPT_Node n, int16 prec); static void OPV_stat (OPT_Node n, OPT_Object outerProc); -void OPV_TypSize (OPT_Struct typ) -{ - int16 f, c; - int32 offset, size, base, fbase, off0; - OPT_Object fld = NIL; - OPT_Struct btyp = NIL; - if (typ == OPT_undftyp) { - OPM_err(58); - } else if (typ->size == -1) { - f = typ->form; - c = typ->comp; - if (c == 4) { - btyp = typ->BaseTyp; - if (btyp == NIL) { - offset = 0; - base = 1; - } else { - OPV_TypSize(btyp); - offset = btyp->size - __ASHR(btyp->sysflag, 8); - base = btyp->align; - } - fld = typ->link; - while ((fld != NIL && fld->mode == 4)) { - btyp = fld->typ; - OPV_TypSize(btyp); - size = btyp->size; - fbase = OPC_BaseAlignment(btyp); - OPC_Align(&offset, fbase); - fld->adr = offset; - offset += size; - if (fbase > base) { - base = fbase; - } - fld = fld->link; - } - off0 = offset; - if (offset == 0) { - offset = 1; - } - OPC_Align(&offset, base); - if ((typ->strobj == NIL && __MASK(typ->align, -65536) == 0)) { - OPV_recno += 1; - base += __ASHL(OPV_recno, 16); - } - typ->size = offset; - typ->align = base; - typ->sysflag = __MASK(typ->sysflag, -256) + (int16)__ASHL(offset - off0, 8); - } else if (c == 2) { - OPV_TypSize(typ->BaseTyp); - typ->size = typ->n * typ->BaseTyp->size; - } else if (f == 11) { - typ->size = OPM_AddressSize; - if (typ->BaseTyp == OPT_undftyp) { - OPM_Mark(128, typ->n); - } else { - OPV_TypSize(typ->BaseTyp); - } - } else if (f == 12) { - typ->size = OPM_AddressSize; - } else if (c == 3) { - btyp = typ->BaseTyp; - OPV_TypSize(btyp); - if (btyp->comp == 3) { - typ->size = btyp->size + 4; - } else { - typ->size = 8; - } - } - } -} - void OPV_Init (void) { OPV_stamp = 0; - OPV_recno = 0; OPV_nofExitLabels = 0; } @@ -212,7 +138,7 @@ static void OPV_Traverse (OPT_Object obj, OPT_Object outerScope, BOOLEAN exporte mode = obj->mode; if ((mode == 5 && (obj->vis != 0) == exported)) { typ = obj->typ; - OPV_TypSize(obj->typ); + OPT_TypSize(obj->typ); if (typ->form == 11) { typ = typ->BaseTyp; } @@ -222,7 +148,7 @@ static void OPV_Traverse (OPT_Object obj, OPT_Object outerScope, BOOLEAN exporte } else if (mode == 13) { OPV_GetTProcNum(obj); } else if (mode == 1) { - OPV_TypSize(obj->typ); + OPT_TypSize(obj->typ); } if (!exported) { if ((__IN(mode, 0x60, 32) && obj->mnolev > 0)) { @@ -548,7 +474,7 @@ static void OPV_design (OPT_Node n, int16 prec) OPT_Struct typ = NIL; int16 class, designPrec, comp; OPT_Node d = NIL, x = NIL; - int16 dims, i, _for__27; + int16 dims, i, _for__26; comp = n->typ->comp; obj = n->obj; class = n->class; @@ -624,9 +550,9 @@ static void OPV_design (OPT_Node n, int16 prec) } x = x->left; } - _for__27 = dims; + _for__26 = dims; i = 1; - while (i <= _for__27) { + while (i <= _for__26) { OPM_Write(')'); i += 1; } @@ -1290,7 +1216,7 @@ static void OPV_NewArr (OPT_Node d, OPT_Node x) OPM_WriteString((CHAR*)", ", 3); OPM_WriteInt(base->size); OPM_WriteString((CHAR*)", ", 3); - OPM_WriteInt(OPC_BaseAlignment(base)); + OPM_WriteInt(OPT_BaseAlignment(base)); OPM_WriteString((CHAR*)", ", 3); OPM_WriteInt(nofdim); OPM_WriteString((CHAR*)", ", 3); diff --git a/bootstrap/unix-44/OPV.h b/bootstrap/unix-44/OPV.h index c309d63c..09931dda 100644 --- a/bootstrap/unix-44/OPV.h +++ b/bootstrap/unix-44/OPV.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPV__h #define OPV__h @@ -12,7 +12,6 @@ import void OPV_AdrAndSize (OPT_Object topScope); import void OPV_Init (void); import void OPV_Module (OPT_Node prog); -import void OPV_TypSize (OPT_Struct typ); import void *OPV__init(void); diff --git a/bootstrap/unix-44/Platform.c b/bootstrap/unix-44/Platform.c index 2dacc4b8..e95203ed 100644 --- a/bootstrap/unix-44/Platform.c +++ b/bootstrap/unix-44/Platform.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-44/Platform.h b/bootstrap/unix-44/Platform.h index 32d37057..d76d7ed5 100644 --- a/bootstrap/unix-44/Platform.h +++ b/bootstrap/unix-44/Platform.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/unix-44/Reals.c b/bootstrap/unix-44/Reals.c index fe93e8be..4b72fbe3 100644 --- a/bootstrap/unix-44/Reals.c +++ b/bootstrap/unix-44/Reals.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-44/Reals.h b/bootstrap/unix-44/Reals.h index e7cba0d8..4a4c73b0 100644 --- a/bootstrap/unix-44/Reals.h +++ b/bootstrap/unix-44/Reals.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/unix-44/Strings.c b/bootstrap/unix-44/Strings.c index 427a0cc4..f765b98f 100644 --- a/bootstrap/unix-44/Strings.c +++ b/bootstrap/unix-44/Strings.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-44/Strings.h b/bootstrap/unix-44/Strings.h index 44c51b2a..be1e7d7f 100644 --- a/bootstrap/unix-44/Strings.h +++ b/bootstrap/unix-44/Strings.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/unix-44/Texts.c b/bootstrap/unix-44/Texts.c index f63a7cb6..28dd23c6 100644 --- a/bootstrap/unix-44/Texts.c +++ b/bootstrap/unix-44/Texts.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-44/Texts.h b/bootstrap/unix-44/Texts.h index 1a87761b..56d3fd40 100644 --- a/bootstrap/unix-44/Texts.h +++ b/bootstrap/unix-44/Texts.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/unix-44/Vishap.c b/bootstrap/unix-44/Vishap.c index 1ec89e33..30b81ac7 100644 --- a/bootstrap/unix-44/Vishap.c +++ b/bootstrap/unix-44/Vishap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspamSf */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspamSf */ #define INTEGER int16 #define LONGINT int32 @@ -35,6 +35,7 @@ void Vishap_Module (BOOLEAN *done) OPP_Module(&p, OPM_opt); if (OPM_noerr) { OPV_Init(); + OPT_InitRecno(); OPV_AdrAndSize(OPT_topScope); OPT_Export(&ext, &new); if (OPM_noerr) { @@ -165,8 +166,6 @@ export int main(int argc, char **argv) Platform_SetInterruptHandler(Vishap_Trap); Platform_SetQuitHandler(Vishap_Trap); Platform_SetBadInstructionHandler(Vishap_Trap); - OPB_typSize = OPV_TypSize; - OPT_typSize = OPV_TypSize; Vishap_Translate(); __FINI; } diff --git a/bootstrap/unix-44/errors.c b/bootstrap/unix-44/errors.c index 0a40d5e9..d465624d 100644 --- a/bootstrap/unix-44/errors.c +++ b/bootstrap/unix-44/errors.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-44/errors.h b/bootstrap/unix-44/errors.h index 759b613e..cf093ab3 100644 --- a/bootstrap/unix-44/errors.h +++ b/bootstrap/unix-44/errors.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef errors__h #define errors__h diff --git a/bootstrap/unix-44/extTools.c b/bootstrap/unix-44/extTools.c index 8be0b63d..46f8ac7e 100644 --- a/bootstrap/unix-44/extTools.c +++ b/bootstrap/unix-44/extTools.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -89,7 +89,7 @@ void extTools_LinkMain (CHAR *moduleName, LONGINT moduleName__len, BOOLEAN stati Strings_Append((CHAR*)" -o ", 5, (void*)cmd, 1023); Strings_Append(moduleName, moduleName__len, (void*)cmd, 1023); Strings_Append((CHAR*)" -L\"", 5, (void*)cmd, 1023); - Strings_Append((CHAR*)"/opt/voc", 9, (void*)cmd, 1023); + Strings_Append((CHAR*)"", 1, (void*)cmd, 1023); Strings_Append((CHAR*)"/lib\"", 6, (void*)cmd, 1023); Strings_Append((CHAR*)" -l voc", 8, (void*)cmd, 1023); extTools_execute((CHAR*)"Assemble and link: ", 20, cmd, 1023); @@ -108,7 +108,7 @@ export void *extTools__init(void) __REGMOD("extTools", 0); /* BEGIN */ Strings_Append((CHAR*)" -I \"", 6, (void*)extTools_compilationOptions, 1023); - Strings_Append((CHAR*)"/opt/voc", 9, (void*)extTools_compilationOptions, 1023); + Strings_Append((CHAR*)"", 1, (void*)extTools_compilationOptions, 1023); Strings_Append((CHAR*)"/include\" ", 11, (void*)extTools_compilationOptions, 1023); Platform_GetEnv((CHAR*)"CFLAGS", 7, (void*)extTools_CFLAGS, 1023); Strings_Append(extTools_CFLAGS, 1023, (void*)extTools_compilationOptions, 1023); diff --git a/bootstrap/unix-44/extTools.h b/bootstrap/unix-44/extTools.h index bff1c62c..700e6b39 100644 --- a/bootstrap/unix-44/extTools.h +++ b/bootstrap/unix-44/extTools.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef extTools__h #define extTools__h diff --git a/bootstrap/unix-44/vt100.c b/bootstrap/unix-44/vt100.c index 4f6a6c9d..8d4cbdfc 100644 --- a/bootstrap/unix-44/vt100.c +++ b/bootstrap/unix-44/vt100.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-44/vt100.h b/bootstrap/unix-44/vt100.h index 94f8add4..da86e98b 100644 --- a/bootstrap/unix-44/vt100.h +++ b/bootstrap/unix-44/vt100.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef vt100__h #define vt100__h diff --git a/bootstrap/unix-48/Configuration.c b/bootstrap/unix-48/Configuration.c index abdf151b..7f7f4b26 100644 --- a/bootstrap/unix-48/Configuration.c +++ b/bootstrap/unix-48/Configuration.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -7,7 +7,7 @@ #include "SYSTEM.h" -export CHAR Configuration_versionLong[41]; +export CHAR Configuration_versionLong[75]; @@ -18,6 +18,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("1.95 [2016/09/23] for gcc LP64 on cygwin", Configuration_versionLong, 41); + __MOVE("1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); __ENDMOD; } diff --git a/bootstrap/unix-48/Configuration.h b/bootstrap/unix-48/Configuration.h index f51f63f2..618bc77f 100644 --- a/bootstrap/unix-48/Configuration.h +++ b/bootstrap/unix-48/Configuration.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Configuration__h #define Configuration__h @@ -6,7 +6,7 @@ #include "SYSTEM.h" -import CHAR Configuration_versionLong[41]; +import CHAR Configuration_versionLong[75]; import void *Configuration__init(void); diff --git a/bootstrap/unix-48/Console.c b/bootstrap/unix-48/Console.c index 115e60f5..f9e5e585 100644 --- a/bootstrap/unix-48/Console.c +++ b/bootstrap/unix-48/Console.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-48/Console.h b/bootstrap/unix-48/Console.h index b08c93ea..d645f05c 100644 --- a/bootstrap/unix-48/Console.h +++ b/bootstrap/unix-48/Console.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Console__h #define Console__h diff --git a/bootstrap/unix-48/Files.c b/bootstrap/unix-48/Files.c index 0a7ac692..ad002606 100644 --- a/bootstrap/unix-48/Files.c +++ b/bootstrap/unix-48/Files.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin tspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-48/Files.h b/bootstrap/unix-48/Files.h index e2b7a3bb..0518133f 100644 --- a/bootstrap/unix-48/Files.h +++ b/bootstrap/unix-48/Files.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin tspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/unix-48/Heap.c b/bootstrap/unix-48/Heap.c index b7c8c827..905fcb24 100644 --- a/bootstrap/unix-48/Heap.c +++ b/bootstrap/unix-48/Heap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin tsSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-48/Heap.h b/bootstrap/unix-48/Heap.h index 6ad4813e..3ea975a7 100644 --- a/bootstrap/unix-48/Heap.h +++ b/bootstrap/unix-48/Heap.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin tsSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ #ifndef Heap__h #define Heap__h diff --git a/bootstrap/unix-48/Modules.c b/bootstrap/unix-48/Modules.c index 7704f005..21d62e05 100644 --- a/bootstrap/unix-48/Modules.c +++ b/bootstrap/unix-48/Modules.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-48/Modules.h b/bootstrap/unix-48/Modules.h index 060208c6..d2d0a476 100644 --- a/bootstrap/unix-48/Modules.h +++ b/bootstrap/unix-48/Modules.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Modules__h #define Modules__h diff --git a/bootstrap/unix-48/OPB.c b/bootstrap/unix-48/OPB.c index e09bf1b4..6c15aa17 100644 --- a/bootstrap/unix-48/OPB.c +++ b/bootstrap/unix-48/OPB.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -10,7 +10,6 @@ #include "OPT.h" -export void (*OPB_typSize)(OPT_Struct); static int16 OPB_exp; static int64 OPB_maxExp; @@ -1917,7 +1916,7 @@ void OPB_StPar0 (OPT_Node *par0, int16 fctno) OPB_err(110); x = OPB_NewIntConst(1); } else if (__IN(f, 0x18fe, 32) || __IN(x->typ->comp, 0x14, 32)) { - (*OPB_typSize)(x->typ); + OPT_TypSize(x->typ); x->typ->pvused = 1; x = OPB_NewIntConst(x->typ->size); } else { diff --git a/bootstrap/unix-48/OPB.h b/bootstrap/unix-48/OPB.h index dc0085af..8395741b 100644 --- a/bootstrap/unix-48/OPB.h +++ b/bootstrap/unix-48/OPB.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPB__h #define OPB__h @@ -8,7 +8,6 @@ #include "OPT.h" -import void (*OPB_typSize)(OPT_Struct); import void OPB_Assign (OPT_Node *x, OPT_Node y); diff --git a/bootstrap/unix-48/OPC.c b/bootstrap/unix-48/OPC.c index 99353400..9104c5c4 100644 --- a/bootstrap/unix-48/OPC.c +++ b/bootstrap/unix-48/OPC.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -17,10 +17,8 @@ static BOOLEAN OPC_GlbPtrs; static CHAR OPC_BodyNameExt[13]; -export void OPC_Align (int32 *adr, int32 base); export void OPC_Andent (OPT_Struct typ); static void OPC_AnsiParamList (OPT_Object obj, BOOLEAN showParamNames); -export int32 OPC_BaseAlignment (OPT_Struct typ); export OPT_Object OPC_BaseTProc (OPT_Object obj); export void OPC_BegBlk (void); export void OPC_BegStat (void); @@ -79,7 +77,6 @@ static void OPC_PutBase (OPT_Struct typ); static void OPC_PutPtrOffsets (OPT_Struct typ, int32 adr, int32 *cnt); static void OPC_RegCmds (OPT_Object obj); export void OPC_SetInclude (BOOLEAN exclude); -export int32 OPC_SizeAlignment (int32 size); static void OPC_Stars (OPT_Struct typ, BOOLEAN *openClause); static void OPC_Str1 (CHAR *s, LONGINT s__len, int32 x); static void OPC_StringLiteral (CHAR *s, LONGINT s__len, int32 l); @@ -750,7 +747,7 @@ static void OPC_CProcDefs (OPT_Object obj, int16 vis) { int16 i; OPT_ConstExt ext = NIL; - int16 _for__9; + int16 _for__7; if (obj != NIL) { OPC_CProcDefs(obj->left, vis); if ((((obj->mode == 9 && (int16)obj->vis >= vis)) && obj->adr == 1)) { @@ -762,9 +759,9 @@ static void OPC_CProcDefs (OPT_Object obj, int16 vis) OPC_DeclareParams(obj->link, 1); OPM_Write(0x09); } - _for__9 = (int16)(*obj->conval->ext)[0]; + _for__7 = (int16)(*obj->conval->ext)[0]; i = i; - while (i <= _for__9) { + while (i <= _for__7) { OPM_Write((*obj->conval->ext)[__X(i, 256)]); i += 1; } @@ -843,64 +840,11 @@ void OPC_InitTDesc (OPT_Struct typ) } } -void OPC_Align (int32 *adr, int32 base) -{ - switch (base) { - case 2: - *adr += __MASK(*adr, -2); - break; - case 4: - *adr += __MASK(-*adr, -4); - break; - case 8: - *adr += __MASK(-*adr, -8); - break; - case 16: - *adr += __MASK(-*adr, -16); - break; - default: - break; - } -} - -int32 OPC_SizeAlignment (int32 size) -{ - int32 _o_result; - int32 alignment; - if (size < OPM_Alignment) { - alignment = 1; - while (alignment < size) { - alignment = __ASHL(alignment, 1); - } - } else { - alignment = OPM_Alignment; - } - _o_result = alignment; - return _o_result; -} - -int32 OPC_BaseAlignment (OPT_Struct typ) -{ - int32 _o_result; - int32 alignment; - if (typ->form == 13) { - 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 (int32 gap, int32 off, int32 align, int32 *n, int32 *curAlign) { int32 adr; adr = off; - OPC_Align(&adr, align); + OPT_Align(&adr, align); if ((*curAlign < align && gap - (adr - off) >= align)) { gap -= (adr - off) + align; OPC_BegStat(); @@ -955,8 +899,8 @@ static void OPC_FieldList (OPT_Struct typ, BOOLEAN last, int32 *off, int32 *n, i } } else { adr = *off; - fldAlign = OPC_BaseAlignment(fld->typ); - OPC_Align(&adr, fldAlign); + fldAlign = OPT_BaseAlignment(fld->typ); + OPT_Align(&adr, fldAlign); gap = fld->adr - adr; if (fldAlign > *curAlign) { *curAlign = fldAlign; @@ -1205,7 +1149,7 @@ static void OPC_GenHeaderMsg (void) OPM_WriteString((CHAR*)"/* ", 4); OPM_WriteString((CHAR*)"voc", 4); OPM_Write(' '); - OPM_WriteString(Configuration_versionLong, 41); + OPM_WriteString(Configuration_versionLong, 75); OPM_Write(' '); i = 0; while (i <= 31) { @@ -1966,84 +1910,84 @@ void OPC_Constant (OPT_Const con, int16 form) } } -static struct InitKeywords__48 { +static struct InitKeywords__46 { int8 *n; - struct InitKeywords__48 *lnk; -} *InitKeywords__48_s; + struct InitKeywords__46 *lnk; +} *InitKeywords__46_s; -static void Enter__49 (CHAR *s, LONGINT s__len); +static void Enter__47 (CHAR *s, LONGINT s__len); -static void Enter__49 (CHAR *s, LONGINT s__len) +static void Enter__47 (CHAR *s, LONGINT s__len) { int16 h; __DUP(s, s__len, CHAR); h = OPC_PerfectHash((void*)s, s__len); - OPC_hashtab[__X(h, 105)] = *InitKeywords__48_s->n; - __COPY(s, OPC_keytab[__X(*InitKeywords__48_s->n, 50)], 9); - *InitKeywords__48_s->n += 1; + OPC_hashtab[__X(h, 105)] = *InitKeywords__46_s->n; + __COPY(s, OPC_keytab[__X(*InitKeywords__46_s->n, 50)], 9); + *InitKeywords__46_s->n += 1; __DEL(s); } static void OPC_InitKeywords (void) { int8 n, i; - struct InitKeywords__48 _s; + struct InitKeywords__46 _s; _s.n = &n; - _s.lnk = InitKeywords__48_s; - InitKeywords__48_s = &_s; + _s.lnk = InitKeywords__46_s; + InitKeywords__46_s = &_s; n = 0; i = 0; while (i <= 104) { OPC_hashtab[__X(i, 105)] = -1; i += 1; } - Enter__49((CHAR*)"address", 8); - Enter__49((CHAR*)"asm", 4); - Enter__49((CHAR*)"auto", 5); - Enter__49((CHAR*)"break", 6); - Enter__49((CHAR*)"case", 5); - Enter__49((CHAR*)"char", 5); - Enter__49((CHAR*)"const", 6); - Enter__49((CHAR*)"continue", 9); - Enter__49((CHAR*)"default", 8); - Enter__49((CHAR*)"do", 3); - Enter__49((CHAR*)"double", 7); - Enter__49((CHAR*)"else", 5); - Enter__49((CHAR*)"enum", 5); - Enter__49((CHAR*)"extern", 7); - Enter__49((CHAR*)"export", 7); - Enter__49((CHAR*)"float", 6); - Enter__49((CHAR*)"for", 4); - Enter__49((CHAR*)"fortran", 8); - Enter__49((CHAR*)"goto", 5); - Enter__49((CHAR*)"if", 3); - Enter__49((CHAR*)"import", 7); - Enter__49((CHAR*)"int", 4); - Enter__49((CHAR*)"int16", 6); - Enter__49((CHAR*)"int32", 6); - Enter__49((CHAR*)"int64", 6); - Enter__49((CHAR*)"int8", 5); - Enter__49((CHAR*)"long", 5); - Enter__49((CHAR*)"register", 9); - Enter__49((CHAR*)"return", 7); - Enter__49((CHAR*)"short", 6); - Enter__49((CHAR*)"signed", 7); - Enter__49((CHAR*)"sizeof", 7); - Enter__49((CHAR*)"size_t", 7); - Enter__49((CHAR*)"static", 7); - Enter__49((CHAR*)"struct", 7); - Enter__49((CHAR*)"switch", 7); - Enter__49((CHAR*)"typedef", 8); - Enter__49((CHAR*)"uint16", 7); - Enter__49((CHAR*)"uint32", 7); - Enter__49((CHAR*)"uint64", 7); - Enter__49((CHAR*)"uint8", 6); - Enter__49((CHAR*)"union", 6); - Enter__49((CHAR*)"unsigned", 9); - Enter__49((CHAR*)"void", 5); - Enter__49((CHAR*)"volatile", 9); - Enter__49((CHAR*)"while", 6); - InitKeywords__48_s = _s.lnk; + Enter__47((CHAR*)"address", 8); + Enter__47((CHAR*)"asm", 4); + Enter__47((CHAR*)"auto", 5); + Enter__47((CHAR*)"break", 6); + Enter__47((CHAR*)"case", 5); + Enter__47((CHAR*)"char", 5); + Enter__47((CHAR*)"const", 6); + Enter__47((CHAR*)"continue", 9); + Enter__47((CHAR*)"default", 8); + Enter__47((CHAR*)"do", 3); + Enter__47((CHAR*)"double", 7); + Enter__47((CHAR*)"else", 5); + Enter__47((CHAR*)"enum", 5); + Enter__47((CHAR*)"extern", 7); + Enter__47((CHAR*)"export", 7); + Enter__47((CHAR*)"float", 6); + Enter__47((CHAR*)"for", 4); + Enter__47((CHAR*)"fortran", 8); + Enter__47((CHAR*)"goto", 5); + Enter__47((CHAR*)"if", 3); + Enter__47((CHAR*)"import", 7); + Enter__47((CHAR*)"int", 4); + Enter__47((CHAR*)"int16", 6); + Enter__47((CHAR*)"int32", 6); + Enter__47((CHAR*)"int64", 6); + Enter__47((CHAR*)"int8", 5); + Enter__47((CHAR*)"long", 5); + Enter__47((CHAR*)"register", 9); + Enter__47((CHAR*)"return", 7); + Enter__47((CHAR*)"short", 6); + Enter__47((CHAR*)"signed", 7); + Enter__47((CHAR*)"sizeof", 7); + Enter__47((CHAR*)"size_t", 7); + Enter__47((CHAR*)"static", 7); + Enter__47((CHAR*)"struct", 7); + Enter__47((CHAR*)"switch", 7); + Enter__47((CHAR*)"typedef", 8); + Enter__47((CHAR*)"uint16", 7); + Enter__47((CHAR*)"uint32", 7); + Enter__47((CHAR*)"uint64", 7); + Enter__47((CHAR*)"uint8", 6); + Enter__47((CHAR*)"union", 6); + Enter__47((CHAR*)"unsigned", 9); + Enter__47((CHAR*)"void", 5); + Enter__47((CHAR*)"volatile", 9); + Enter__47((CHAR*)"while", 6); + InitKeywords__46_s = _s.lnk; } diff --git a/bootstrap/unix-48/OPC.h b/bootstrap/unix-48/OPC.h index 4215947f..6236cd73 100644 --- a/bootstrap/unix-48/OPC.h +++ b/bootstrap/unix-48/OPC.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPC__h #define OPC__h @@ -9,9 +9,7 @@ -import void OPC_Align (int32 *adr, int32 base); import void OPC_Andent (OPT_Struct typ); -import int32 OPC_BaseAlignment (OPT_Struct typ); import OPT_Object OPC_BaseTProc (OPT_Object obj); import void OPC_BegBlk (void); import void OPC_BegStat (void); @@ -41,7 +39,6 @@ import void OPC_IntLiteral (int64 n, int32 size); import void OPC_Len (OPT_Object obj, OPT_Struct array, int64 dim); import int32 OPC_NofPtrs (OPT_Struct typ); import void OPC_SetInclude (BOOLEAN exclude); -import int32 OPC_SizeAlignment (int32 size); import void OPC_TDescDecl (OPT_Struct typ); import void OPC_TypeDefs (OPT_Object obj, int16 vis); import void OPC_TypeOf (OPT_Object ap); diff --git a/bootstrap/unix-48/OPM.c b/bootstrap/unix-48/OPM.c index 8b1f6805..9297c0a3 100644 --- a/bootstrap/unix-48/OPM.c +++ b/bootstrap/unix-48/OPM.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -223,6 +223,7 @@ static void OPM_ScanOptions (CHAR *s, LONGINT s__len, SET *opt) OPM_AddressSize = (int16)s[__X(i + 1, s__len)] - 48; OPM_Alignment = (int16)s[__X(i + 2, s__len)] - 48; i += 2; + Files_SetSearchPath((CHAR*)"", 1); } break; case 'B': @@ -270,7 +271,7 @@ BOOLEAN OPM_OpenPar (void) if (Platform_ArgCount == 1) { OPM_LogWLn(); OPM_LogWStr((CHAR*)"Oberon-2 compiler v", 20); - OPM_LogWStr(Configuration_versionLong, 41); + OPM_LogWStr(Configuration_versionLong, 75); OPM_LogW('.'); OPM_LogWLn(); OPM_LogWStr((CHAR*)"Based on Ofront by Software Templ OEG.", 39); @@ -1118,7 +1119,7 @@ export void *OPM__init(void) Strings_Append((CHAR*)";.;", 4, (void*)OPM_OBERON, 1024); Strings_Append(OPM_MODULES, 1024, (void*)OPM_OBERON, 1024); Strings_Append((CHAR*)";", 2, (void*)OPM_OBERON, 1024); - Strings_Append((CHAR*)"/opt/voc", 9, (void*)OPM_OBERON, 1024); + Strings_Append((CHAR*)"", 1, (void*)OPM_OBERON, 1024); Strings_Append((CHAR*)"/sym;", 6, (void*)OPM_OBERON, 1024); Files_SetSearchPath(OPM_OBERON, 1024); OPM_AddressSize = 4; diff --git a/bootstrap/unix-48/OPM.h b/bootstrap/unix-48/OPM.h index 96af4022..b62666db 100644 --- a/bootstrap/unix-48/OPM.h +++ b/bootstrap/unix-48/OPM.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPM__h #define OPM__h diff --git a/bootstrap/unix-48/OPP.c b/bootstrap/unix-48/OPP.c index a3ab1dd3..66b821d2 100644 --- a/bootstrap/unix-48/OPP.c +++ b/bootstrap/unix-48/OPP.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-48/OPP.h b/bootstrap/unix-48/OPP.h index e5a59f6c..ea6663ba 100644 --- a/bootstrap/unix-48/OPP.h +++ b/bootstrap/unix-48/OPP.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/unix-48/OPS.c b/bootstrap/unix-48/OPS.c index 0cac83bd..2b449cae 100644 --- a/bootstrap/unix-48/OPS.c +++ b/bootstrap/unix-48/OPS.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin tspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-48/OPS.h b/bootstrap/unix-48/OPS.h index caef45f4..8d90d974 100644 --- a/bootstrap/unix-48/OPS.h +++ b/bootstrap/unix-48/OPS.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin tspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/unix-48/OPT.c b/bootstrap/unix-48/OPT.c index c52efac6..1b69128c 100644 --- a/bootstrap/unix-48/OPT.c +++ b/bootstrap/unix-48/OPT.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -87,7 +87,6 @@ typedef } OPT_StrDesc; -export void (*OPT_typSize)(OPT_Struct); export OPT_Object OPT_topScope; export OPT_Struct OPT_undftyp, OPT_bytetyp, OPT_booltyp, OPT_chartyp, OPT_sinttyp, OPT_inttyp, OPT_linttyp, OPT_hinttyp, OPT_adrtyp, OPT_int8typ, OPT_int16typ, OPT_int32typ, OPT_int64typ, OPT_realtyp, OPT_lrltyp, OPT_settyp, OPT_stringtyp, OPT_niltyp, OPT_notyp, OPT_sysptrtyp; export OPT_Object OPT_sintobj, OPT_intobj, OPT_lintobj; @@ -100,6 +99,7 @@ static OPT_ImpCtxt OPT_impCtxt; static OPT_ExpCtxt OPT_expCtxt; static int32 OPT_nofhdfld; static BOOLEAN OPT_newsf, OPT_findpc, OPT_extsf, OPT_sfpresent, OPT_symExtended, OPT_symNew; +static int32 OPT_recno; export address *OPT_ConstDesc__typ; export address *OPT_ObjDesc__typ; @@ -108,6 +108,8 @@ export address *OPT_NodeDesc__typ; export address *OPT_ImpCtxt__typ; export address *OPT_ExpCtxt__typ; +export void OPT_Align (int32 *adr, int32 base); +export int32 OPT_BaseAlignment (OPT_Struct typ); export void OPT_Close (void); export void OPT_CloseScope (void); static void OPT_DebugStruct (OPT_Struct btyp); @@ -136,6 +138,7 @@ static void OPT_InStruct (OPT_Struct *typ); static OPT_Object OPT_InTProc (int8 mno); static OPT_Struct OPT_InTyp (int32 tag); export void OPT_Init (OPS_Name name, SET opt); +export void OPT_InitRecno (void); static void OPT_InitStruct (OPT_Struct *typ, int8 form); export void OPT_Insert (OPS_Name name, OPT_Object *obj); export void OPT_InsertImport (OPT_Object obj, OPT_Object *root, OPT_Object *old); @@ -157,9 +160,16 @@ static void OPT_OutSign (OPT_Struct result, OPT_Object par); static void OPT_OutStr (OPT_Struct typ); static void OPT_OutTProcs (OPT_Struct typ, OPT_Object obj); export OPT_Struct OPT_ShorterOrLongerType (OPT_Struct x, int16 dir); +export int32 OPT_SizeAlignment (int32 size); +export void OPT_TypSize (OPT_Struct typ); static void OPT_err (int16 n); +void OPT_InitRecno (void) +{ + OPT_recno = 0; +} + static void OPT_err (int16 n) { OPM_err(n); @@ -240,6 +250,130 @@ OPT_Struct OPT_ShorterOrLongerType (OPT_Struct x, int16 dir) __RETCHK; } +void OPT_Align (int32 *adr, int32 base) +{ + switch (base) { + case 2: + *adr += __MASK(*adr, -2); + break; + case 4: + *adr += __MASK(-*adr, -4); + break; + case 8: + *adr += __MASK(-*adr, -8); + break; + case 16: + *adr += __MASK(-*adr, -16); + break; + default: + break; + } +} + +int32 OPT_SizeAlignment (int32 size) +{ + int32 _o_result; + int32 alignment; + if (size < OPM_Alignment) { + alignment = 1; + while (alignment < size) { + alignment = __ASHL(alignment, 1); + } + } else { + alignment = OPM_Alignment; + } + _o_result = alignment; + return _o_result; +} + +int32 OPT_BaseAlignment (OPT_Struct typ) +{ + int32 _o_result; + int32 alignment; + if (typ->form == 13) { + if (typ->comp == 4) { + alignment = __MASK(typ->align, -65536); + } else { + alignment = OPT_BaseAlignment(typ->BaseTyp); + } + } else { + alignment = OPT_SizeAlignment(typ->size); + } + _o_result = alignment; + return _o_result; +} + +void OPT_TypSize (OPT_Struct typ) +{ + int16 f, c; + int32 offset, size, base, fbase, off0; + OPT_Object fld = NIL; + OPT_Struct btyp = NIL; + if (typ == OPT_undftyp) { + OPM_err(58); + } else if (typ->size == -1) { + f = typ->form; + c = typ->comp; + if (c == 4) { + btyp = typ->BaseTyp; + if (btyp == NIL) { + offset = 0; + base = 1; + } else { + OPT_TypSize(btyp); + offset = btyp->size - __ASHR(btyp->sysflag, 8); + base = btyp->align; + } + fld = typ->link; + while ((fld != NIL && fld->mode == 4)) { + btyp = fld->typ; + OPT_TypSize(btyp); + size = btyp->size; + fbase = OPT_BaseAlignment(btyp); + OPT_Align(&offset, fbase); + fld->adr = offset; + offset += size; + if (fbase > base) { + base = fbase; + } + fld = fld->link; + } + off0 = offset; + if (offset == 0) { + offset = 1; + } + OPT_Align(&offset, base); + if ((typ->strobj == NIL && __MASK(typ->align, -65536) == 0)) { + OPT_recno += 1; + base += __ASHL(OPT_recno, 16); + } + typ->size = offset; + typ->align = base; + typ->sysflag = __MASK(typ->sysflag, -256) + (int16)__ASHL(offset - off0, 8); + } else if (c == 2) { + OPT_TypSize(typ->BaseTyp); + typ->size = typ->n * typ->BaseTyp->size; + } else if (f == 11) { + typ->size = OPM_AddressSize; + if (typ->BaseTyp == OPT_undftyp) { + OPM_Mark(128, typ->n); + } else { + OPT_TypSize(typ->BaseTyp); + } + } else if (f == 12) { + typ->size = OPM_AddressSize; + } else if (c == 3) { + btyp = typ->BaseTyp; + OPT_TypSize(btyp); + if (btyp->comp == 3) { + typ->size = btyp->size + 4; + } else { + typ->size = 8; + } + } + } +} + OPT_Const OPT_NewConst (void) { OPT_Const _o_result; @@ -552,21 +686,21 @@ void OPT_IdFPrint (OPT_Struct typ) } } -static struct FPrintStr__13 { +static struct FPrintStr__15 { int32 *pbfp, *pvfp; - struct FPrintStr__13 *lnk; -} *FPrintStr__13_s; + struct FPrintStr__15 *lnk; +} *FPrintStr__15_s; -static void FPrintFlds__14 (OPT_Object fld, int32 adr, BOOLEAN visible); -static void FPrintHdFld__16 (OPT_Struct typ, OPT_Object fld, int32 adr); -static void FPrintTProcs__18 (OPT_Object obj); +static void FPrintFlds__16 (OPT_Object fld, int32 adr, BOOLEAN visible); +static void FPrintHdFld__18 (OPT_Struct typ, OPT_Object fld, int32 adr); +static void FPrintTProcs__20 (OPT_Object obj); -static void FPrintHdFld__16 (OPT_Struct typ, OPT_Object fld, int32 adr) +static void FPrintHdFld__18 (OPT_Struct typ, OPT_Object fld, int32 adr) { int32 i, j, n; OPT_Struct btyp = NIL; if (typ->comp == 4) { - FPrintFlds__14(typ->link, adr, 0); + FPrintFlds__16(typ->link, adr, 0); } else if (typ->comp == 2) { btyp = typ->BaseTyp; n = typ->n; @@ -576,53 +710,53 @@ static void FPrintHdFld__16 (OPT_Struct typ, OPT_Object fld, int32 adr) } if (btyp->form == 11 || btyp->comp == 4) { j = OPT_nofhdfld; - FPrintHdFld__16(btyp, fld, adr); + FPrintHdFld__18(btyp, fld, adr); if (j != OPT_nofhdfld) { i = 1; while ((i < n && OPT_nofhdfld <= 2048)) { adr += btyp->size; - FPrintHdFld__16(btyp, fld, adr); + FPrintHdFld__18(btyp, fld, adr); i += 1; } } } } else if (typ->form == 11 || __STRCMP(fld->name, "@ptr") == 0) { - OPM_FPrint(&*FPrintStr__13_s->pvfp, 11); - OPM_FPrint(&*FPrintStr__13_s->pvfp, adr); + OPM_FPrint(&*FPrintStr__15_s->pvfp, 11); + OPM_FPrint(&*FPrintStr__15_s->pvfp, adr); OPT_nofhdfld += 1; } } -static void FPrintFlds__14 (OPT_Object fld, int32 adr, BOOLEAN visible) +static void FPrintFlds__16 (OPT_Object fld, int32 adr, BOOLEAN visible) { while ((fld != NIL && fld->mode == 4)) { if ((fld->vis != 0 && visible)) { - OPM_FPrint(&*FPrintStr__13_s->pbfp, fld->vis); - OPT_FPrintName(&*FPrintStr__13_s->pbfp, (void*)fld->name, 256); - OPM_FPrint(&*FPrintStr__13_s->pbfp, fld->adr); + OPM_FPrint(&*FPrintStr__15_s->pbfp, fld->vis); + OPT_FPrintName(&*FPrintStr__15_s->pbfp, (void*)fld->name, 256); + OPM_FPrint(&*FPrintStr__15_s->pbfp, fld->adr); OPT_FPrintStr(fld->typ); - OPM_FPrint(&*FPrintStr__13_s->pbfp, fld->typ->pbfp); - OPM_FPrint(&*FPrintStr__13_s->pvfp, fld->typ->pvfp); + OPM_FPrint(&*FPrintStr__15_s->pbfp, fld->typ->pbfp); + OPM_FPrint(&*FPrintStr__15_s->pvfp, fld->typ->pvfp); } else { - FPrintHdFld__16(fld->typ, fld, fld->adr + adr); + FPrintHdFld__18(fld->typ, fld, fld->adr + adr); } fld = fld->link; } } -static void FPrintTProcs__18 (OPT_Object obj) +static void FPrintTProcs__20 (OPT_Object obj) { if (obj != NIL) { - FPrintTProcs__18(obj->left); + FPrintTProcs__20(obj->left); if (obj->mode == 13) { if (obj->vis != 0) { - OPM_FPrint(&*FPrintStr__13_s->pbfp, 13); - OPM_FPrint(&*FPrintStr__13_s->pbfp, __ASHR(obj->adr, 16)); - OPT_FPrintSign(&*FPrintStr__13_s->pbfp, obj->typ, obj->link); - OPT_FPrintName(&*FPrintStr__13_s->pbfp, (void*)obj->name, 256); + OPM_FPrint(&*FPrintStr__15_s->pbfp, 13); + OPM_FPrint(&*FPrintStr__15_s->pbfp, __ASHR(obj->adr, 16)); + OPT_FPrintSign(&*FPrintStr__15_s->pbfp, obj->typ, obj->link); + OPT_FPrintName(&*FPrintStr__15_s->pbfp, (void*)obj->name, 256); } } - FPrintTProcs__18(obj->right); + FPrintTProcs__20(obj->right); } } @@ -632,11 +766,11 @@ void OPT_FPrintStr (OPT_Struct typ) OPT_Struct btyp = NIL; OPT_Object strobj = NIL, bstrobj = NIL; int32 pbfp, pvfp; - struct FPrintStr__13 _s; + struct FPrintStr__15 _s; _s.pbfp = &pbfp; _s.pvfp = &pvfp; - _s.lnk = FPrintStr__13_s; - FPrintStr__13_s = &_s; + _s.lnk = FPrintStr__15_s; + FPrintStr__15_s = &_s; if (!typ->fpdone) { OPT_IdFPrint(typ); pbfp = typ->idfp; @@ -673,11 +807,11 @@ void OPT_FPrintStr (OPT_Struct typ) OPM_FPrint(&pvfp, typ->align); OPM_FPrint(&pvfp, typ->n); OPT_nofhdfld = 0; - FPrintFlds__14(typ->link, 0, 1); + FPrintFlds__16(typ->link, 0, 1); if (OPT_nofhdfld > 2048) { OPM_Mark(225, typ->txtpos); } - FPrintTProcs__18(typ->link); + FPrintTProcs__20(typ->link); OPM_FPrint(&pvfp, pbfp); strobj = typ->strobj; if (strobj == NIL || strobj->name[0] == 0x00) { @@ -687,7 +821,7 @@ void OPT_FPrintStr (OPT_Struct typ) typ->pbfp = pbfp; typ->pvfp = pvfp; } - FPrintStr__13_s = _s.lnk; + FPrintStr__15_s = _s.lnk; } void OPT_FPrintObj (OPT_Object obj) @@ -1119,7 +1253,7 @@ static void OPT_InStruct (OPT_Struct *typ) (*typ)->comp = 2; OPT_InStruct(&(*typ)->BaseTyp); (*typ)->n = OPM_SymRInt(); - (*OPT_typSize)(*typ); + OPT_TypSize(*typ); break; case 38: (*typ)->form = 13; @@ -1130,7 +1264,7 @@ static void OPT_InStruct (OPT_Struct *typ) } else { (*typ)->n = 0; } - (*OPT_typSize)(*typ); + OPT_TypSize(*typ); break; case 39: (*typ)->form = 13; @@ -1899,6 +2033,7 @@ export void *OPT__init(void) __REGMOD("OPT", EnumPtrs); __REGCMD("Close", OPT_Close); __REGCMD("CloseScope", OPT_CloseScope); + __REGCMD("InitRecno", OPT_InitRecno); __INITYP(OPT_ConstDesc, OPT_ConstDesc, 0); __INITYP(OPT_ObjDesc, OPT_ObjDesc, 0); __INITYP(OPT_StrDesc, OPT_StrDesc, 0); diff --git a/bootstrap/unix-48/OPT.h b/bootstrap/unix-48/OPT.h index 0bd1f189..1a525fcb 100644 --- a/bootstrap/unix-48/OPT.h +++ b/bootstrap/unix-48/OPT.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPT__h #define OPT__h @@ -66,7 +66,6 @@ typedef } OPT_StrDesc; -import void (*OPT_typSize)(OPT_Struct); import OPT_Object OPT_topScope; import OPT_Struct OPT_undftyp, OPT_bytetyp, OPT_booltyp, OPT_chartyp, OPT_sinttyp, OPT_inttyp, OPT_linttyp, OPT_hinttyp, OPT_adrtyp, OPT_int8typ, OPT_int16typ, OPT_int32typ, OPT_int64typ, OPT_realtyp, OPT_lrltyp, OPT_settyp, OPT_stringtyp, OPT_niltyp, OPT_notyp, OPT_sysptrtyp; import OPT_Object OPT_sintobj, OPT_intobj, OPT_lintobj; @@ -80,6 +79,8 @@ import address *OPT_ObjDesc__typ; import address *OPT_StrDesc__typ; import address *OPT_NodeDesc__typ; +import void OPT_Align (int32 *adr, int32 base); +import int32 OPT_BaseAlignment (OPT_Struct typ); import void OPT_Close (void); import void OPT_CloseScope (void); import void OPT_Export (BOOLEAN *ext, BOOLEAN *new); @@ -92,6 +93,7 @@ import void OPT_FindImport (OPT_Object mod, OPT_Object *res); import void OPT_IdFPrint (OPT_Struct typ); import void OPT_Import (OPS_Name aliasName, OPS_Name name, BOOLEAN *done); import void OPT_Init (OPS_Name name, SET opt); +import void OPT_InitRecno (void); import void OPT_Insert (OPS_Name name, OPT_Object *obj); import void OPT_InsertImport (OPT_Object obj, OPT_Object *root, OPT_Object *old); import int16 OPT_IntSize (int64 n); @@ -103,6 +105,8 @@ import OPT_Object OPT_NewObj (void); import OPT_Struct OPT_NewStr (int8 form, int8 comp); import void OPT_OpenScope (int8 level, OPT_Object owner); import OPT_Struct OPT_ShorterOrLongerType (OPT_Struct x, int16 dir); +import int32 OPT_SizeAlignment (int32 size); +import void OPT_TypSize (OPT_Struct typ); import void *OPT__init(void); diff --git a/bootstrap/unix-48/OPV.c b/bootstrap/unix-48/OPV.c index 8bb5ec32..cdb2ab50 100644 --- a/bootstrap/unix-48/OPV.c +++ b/bootstrap/unix-48/OPV.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -17,7 +17,6 @@ typedef static int16 OPV_stamp; -static int32 OPV_recno; static OPV_ExitInfo OPV_exit; static int16 OPV_nofExitLabels; @@ -46,88 +45,15 @@ static void OPV_Stamp (OPS_Name s); static OPT_Object OPV_SuperProc (OPT_Node n); static void OPV_Traverse (OPT_Object obj, OPT_Object outerScope, BOOLEAN exported); static void OPV_TraverseRecord (OPT_Struct typ); -export void OPV_TypSize (OPT_Struct typ); static void OPV_TypeOf (OPT_Node n); static void OPV_design (OPT_Node n, int16 prec); static void OPV_expr (OPT_Node n, int16 prec); static void OPV_stat (OPT_Node n, OPT_Object outerProc); -void OPV_TypSize (OPT_Struct typ) -{ - int16 f, c; - int32 offset, size, base, fbase, off0; - OPT_Object fld = NIL; - OPT_Struct btyp = NIL; - if (typ == OPT_undftyp) { - OPM_err(58); - } else if (typ->size == -1) { - f = typ->form; - c = typ->comp; - if (c == 4) { - btyp = typ->BaseTyp; - if (btyp == NIL) { - offset = 0; - base = 1; - } else { - OPV_TypSize(btyp); - offset = btyp->size - __ASHR(btyp->sysflag, 8); - base = btyp->align; - } - fld = typ->link; - while ((fld != NIL && fld->mode == 4)) { - btyp = fld->typ; - OPV_TypSize(btyp); - size = btyp->size; - fbase = OPC_BaseAlignment(btyp); - OPC_Align(&offset, fbase); - fld->adr = offset; - offset += size; - if (fbase > base) { - base = fbase; - } - fld = fld->link; - } - off0 = offset; - if (offset == 0) { - offset = 1; - } - OPC_Align(&offset, base); - if ((typ->strobj == NIL && __MASK(typ->align, -65536) == 0)) { - OPV_recno += 1; - base += __ASHL(OPV_recno, 16); - } - typ->size = offset; - typ->align = base; - typ->sysflag = __MASK(typ->sysflag, -256) + (int16)__ASHL(offset - off0, 8); - } else if (c == 2) { - OPV_TypSize(typ->BaseTyp); - typ->size = typ->n * typ->BaseTyp->size; - } else if (f == 11) { - typ->size = OPM_AddressSize; - if (typ->BaseTyp == OPT_undftyp) { - OPM_Mark(128, typ->n); - } else { - OPV_TypSize(typ->BaseTyp); - } - } else if (f == 12) { - typ->size = OPM_AddressSize; - } else if (c == 3) { - btyp = typ->BaseTyp; - OPV_TypSize(btyp); - if (btyp->comp == 3) { - typ->size = btyp->size + 4; - } else { - typ->size = 8; - } - } - } -} - void OPV_Init (void) { OPV_stamp = 0; - OPV_recno = 0; OPV_nofExitLabels = 0; } @@ -212,7 +138,7 @@ static void OPV_Traverse (OPT_Object obj, OPT_Object outerScope, BOOLEAN exporte mode = obj->mode; if ((mode == 5 && (obj->vis != 0) == exported)) { typ = obj->typ; - OPV_TypSize(obj->typ); + OPT_TypSize(obj->typ); if (typ->form == 11) { typ = typ->BaseTyp; } @@ -222,7 +148,7 @@ static void OPV_Traverse (OPT_Object obj, OPT_Object outerScope, BOOLEAN exporte } else if (mode == 13) { OPV_GetTProcNum(obj); } else if (mode == 1) { - OPV_TypSize(obj->typ); + OPT_TypSize(obj->typ); } if (!exported) { if ((__IN(mode, 0x60, 32) && obj->mnolev > 0)) { @@ -548,7 +474,7 @@ static void OPV_design (OPT_Node n, int16 prec) OPT_Struct typ = NIL; int16 class, designPrec, comp; OPT_Node d = NIL, x = NIL; - int16 dims, i, _for__27; + int16 dims, i, _for__26; comp = n->typ->comp; obj = n->obj; class = n->class; @@ -624,9 +550,9 @@ static void OPV_design (OPT_Node n, int16 prec) } x = x->left; } - _for__27 = dims; + _for__26 = dims; i = 1; - while (i <= _for__27) { + while (i <= _for__26) { OPM_Write(')'); i += 1; } @@ -1290,7 +1216,7 @@ static void OPV_NewArr (OPT_Node d, OPT_Node x) OPM_WriteString((CHAR*)", ", 3); OPM_WriteInt(base->size); OPM_WriteString((CHAR*)", ", 3); - OPM_WriteInt(OPC_BaseAlignment(base)); + OPM_WriteInt(OPT_BaseAlignment(base)); OPM_WriteString((CHAR*)", ", 3); OPM_WriteInt(nofdim); OPM_WriteString((CHAR*)", ", 3); diff --git a/bootstrap/unix-48/OPV.h b/bootstrap/unix-48/OPV.h index c309d63c..09931dda 100644 --- a/bootstrap/unix-48/OPV.h +++ b/bootstrap/unix-48/OPV.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPV__h #define OPV__h @@ -12,7 +12,6 @@ import void OPV_AdrAndSize (OPT_Object topScope); import void OPV_Init (void); import void OPV_Module (OPT_Node prog); -import void OPV_TypSize (OPT_Struct typ); import void *OPV__init(void); diff --git a/bootstrap/unix-48/Platform.c b/bootstrap/unix-48/Platform.c index 2dacc4b8..e95203ed 100644 --- a/bootstrap/unix-48/Platform.c +++ b/bootstrap/unix-48/Platform.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-48/Platform.h b/bootstrap/unix-48/Platform.h index 32d37057..d76d7ed5 100644 --- a/bootstrap/unix-48/Platform.h +++ b/bootstrap/unix-48/Platform.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/unix-48/Reals.c b/bootstrap/unix-48/Reals.c index fe93e8be..4b72fbe3 100644 --- a/bootstrap/unix-48/Reals.c +++ b/bootstrap/unix-48/Reals.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-48/Reals.h b/bootstrap/unix-48/Reals.h index e7cba0d8..4a4c73b0 100644 --- a/bootstrap/unix-48/Reals.h +++ b/bootstrap/unix-48/Reals.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/unix-48/Strings.c b/bootstrap/unix-48/Strings.c index 427a0cc4..f765b98f 100644 --- a/bootstrap/unix-48/Strings.c +++ b/bootstrap/unix-48/Strings.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-48/Strings.h b/bootstrap/unix-48/Strings.h index 44c51b2a..be1e7d7f 100644 --- a/bootstrap/unix-48/Strings.h +++ b/bootstrap/unix-48/Strings.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/unix-48/Texts.c b/bootstrap/unix-48/Texts.c index 60a7ea7a..779daa7a 100644 --- a/bootstrap/unix-48/Texts.c +++ b/bootstrap/unix-48/Texts.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-48/Texts.h b/bootstrap/unix-48/Texts.h index df86e814..07f53445 100644 --- a/bootstrap/unix-48/Texts.h +++ b/bootstrap/unix-48/Texts.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/unix-48/Vishap.c b/bootstrap/unix-48/Vishap.c index 1ec89e33..30b81ac7 100644 --- a/bootstrap/unix-48/Vishap.c +++ b/bootstrap/unix-48/Vishap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspamSf */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspamSf */ #define INTEGER int16 #define LONGINT int32 @@ -35,6 +35,7 @@ void Vishap_Module (BOOLEAN *done) OPP_Module(&p, OPM_opt); if (OPM_noerr) { OPV_Init(); + OPT_InitRecno(); OPV_AdrAndSize(OPT_topScope); OPT_Export(&ext, &new); if (OPM_noerr) { @@ -165,8 +166,6 @@ export int main(int argc, char **argv) Platform_SetInterruptHandler(Vishap_Trap); Platform_SetQuitHandler(Vishap_Trap); Platform_SetBadInstructionHandler(Vishap_Trap); - OPB_typSize = OPV_TypSize; - OPT_typSize = OPV_TypSize; Vishap_Translate(); __FINI; } diff --git a/bootstrap/unix-48/errors.c b/bootstrap/unix-48/errors.c index 0a40d5e9..d465624d 100644 --- a/bootstrap/unix-48/errors.c +++ b/bootstrap/unix-48/errors.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-48/errors.h b/bootstrap/unix-48/errors.h index 759b613e..cf093ab3 100644 --- a/bootstrap/unix-48/errors.h +++ b/bootstrap/unix-48/errors.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef errors__h #define errors__h diff --git a/bootstrap/unix-48/extTools.c b/bootstrap/unix-48/extTools.c index 8be0b63d..46f8ac7e 100644 --- a/bootstrap/unix-48/extTools.c +++ b/bootstrap/unix-48/extTools.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -89,7 +89,7 @@ void extTools_LinkMain (CHAR *moduleName, LONGINT moduleName__len, BOOLEAN stati Strings_Append((CHAR*)" -o ", 5, (void*)cmd, 1023); Strings_Append(moduleName, moduleName__len, (void*)cmd, 1023); Strings_Append((CHAR*)" -L\"", 5, (void*)cmd, 1023); - Strings_Append((CHAR*)"/opt/voc", 9, (void*)cmd, 1023); + Strings_Append((CHAR*)"", 1, (void*)cmd, 1023); Strings_Append((CHAR*)"/lib\"", 6, (void*)cmd, 1023); Strings_Append((CHAR*)" -l voc", 8, (void*)cmd, 1023); extTools_execute((CHAR*)"Assemble and link: ", 20, cmd, 1023); @@ -108,7 +108,7 @@ export void *extTools__init(void) __REGMOD("extTools", 0); /* BEGIN */ Strings_Append((CHAR*)" -I \"", 6, (void*)extTools_compilationOptions, 1023); - Strings_Append((CHAR*)"/opt/voc", 9, (void*)extTools_compilationOptions, 1023); + Strings_Append((CHAR*)"", 1, (void*)extTools_compilationOptions, 1023); Strings_Append((CHAR*)"/include\" ", 11, (void*)extTools_compilationOptions, 1023); Platform_GetEnv((CHAR*)"CFLAGS", 7, (void*)extTools_CFLAGS, 1023); Strings_Append(extTools_CFLAGS, 1023, (void*)extTools_compilationOptions, 1023); diff --git a/bootstrap/unix-48/extTools.h b/bootstrap/unix-48/extTools.h index bff1c62c..700e6b39 100644 --- a/bootstrap/unix-48/extTools.h +++ b/bootstrap/unix-48/extTools.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef extTools__h #define extTools__h diff --git a/bootstrap/unix-48/vt100.c b/bootstrap/unix-48/vt100.c index 4f6a6c9d..8d4cbdfc 100644 --- a/bootstrap/unix-48/vt100.c +++ b/bootstrap/unix-48/vt100.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-48/vt100.h b/bootstrap/unix-48/vt100.h index 94f8add4..da86e98b 100644 --- a/bootstrap/unix-48/vt100.h +++ b/bootstrap/unix-48/vt100.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef vt100__h #define vt100__h diff --git a/bootstrap/unix-88/Configuration.c b/bootstrap/unix-88/Configuration.c index abdf151b..7f7f4b26 100644 --- a/bootstrap/unix-88/Configuration.c +++ b/bootstrap/unix-88/Configuration.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -7,7 +7,7 @@ #include "SYSTEM.h" -export CHAR Configuration_versionLong[41]; +export CHAR Configuration_versionLong[75]; @@ -18,6 +18,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("1.95 [2016/09/23] for gcc LP64 on cygwin", Configuration_versionLong, 41); + __MOVE("1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); __ENDMOD; } diff --git a/bootstrap/unix-88/Configuration.h b/bootstrap/unix-88/Configuration.h index f51f63f2..618bc77f 100644 --- a/bootstrap/unix-88/Configuration.h +++ b/bootstrap/unix-88/Configuration.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Configuration__h #define Configuration__h @@ -6,7 +6,7 @@ #include "SYSTEM.h" -import CHAR Configuration_versionLong[41]; +import CHAR Configuration_versionLong[75]; import void *Configuration__init(void); diff --git a/bootstrap/unix-88/Console.c b/bootstrap/unix-88/Console.c index 115e60f5..f9e5e585 100644 --- a/bootstrap/unix-88/Console.c +++ b/bootstrap/unix-88/Console.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-88/Console.h b/bootstrap/unix-88/Console.h index b08c93ea..d645f05c 100644 --- a/bootstrap/unix-88/Console.h +++ b/bootstrap/unix-88/Console.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Console__h #define Console__h diff --git a/bootstrap/unix-88/Files.c b/bootstrap/unix-88/Files.c index e7eb30f3..d7e16dab 100644 --- a/bootstrap/unix-88/Files.c +++ b/bootstrap/unix-88/Files.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin tspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-88/Files.h b/bootstrap/unix-88/Files.h index a371a423..64d47c3f 100644 --- a/bootstrap/unix-88/Files.h +++ b/bootstrap/unix-88/Files.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin tspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/unix-88/Heap.c b/bootstrap/unix-88/Heap.c index 16ae9ffd..785efa1a 100644 --- a/bootstrap/unix-88/Heap.c +++ b/bootstrap/unix-88/Heap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin tsSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-88/Heap.h b/bootstrap/unix-88/Heap.h index 151a2d59..cfa2ab6f 100644 --- a/bootstrap/unix-88/Heap.h +++ b/bootstrap/unix-88/Heap.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin tsSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ #ifndef Heap__h #define Heap__h diff --git a/bootstrap/unix-88/Modules.c b/bootstrap/unix-88/Modules.c index f844dfa9..b6890cfe 100644 --- a/bootstrap/unix-88/Modules.c +++ b/bootstrap/unix-88/Modules.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-88/Modules.h b/bootstrap/unix-88/Modules.h index 060208c6..d2d0a476 100644 --- a/bootstrap/unix-88/Modules.h +++ b/bootstrap/unix-88/Modules.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Modules__h #define Modules__h diff --git a/bootstrap/unix-88/OPB.c b/bootstrap/unix-88/OPB.c index e09bf1b4..6c15aa17 100644 --- a/bootstrap/unix-88/OPB.c +++ b/bootstrap/unix-88/OPB.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -10,7 +10,6 @@ #include "OPT.h" -export void (*OPB_typSize)(OPT_Struct); static int16 OPB_exp; static int64 OPB_maxExp; @@ -1917,7 +1916,7 @@ void OPB_StPar0 (OPT_Node *par0, int16 fctno) OPB_err(110); x = OPB_NewIntConst(1); } else if (__IN(f, 0x18fe, 32) || __IN(x->typ->comp, 0x14, 32)) { - (*OPB_typSize)(x->typ); + OPT_TypSize(x->typ); x->typ->pvused = 1; x = OPB_NewIntConst(x->typ->size); } else { diff --git a/bootstrap/unix-88/OPB.h b/bootstrap/unix-88/OPB.h index dc0085af..8395741b 100644 --- a/bootstrap/unix-88/OPB.h +++ b/bootstrap/unix-88/OPB.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPB__h #define OPB__h @@ -8,7 +8,6 @@ #include "OPT.h" -import void (*OPB_typSize)(OPT_Struct); import void OPB_Assign (OPT_Node *x, OPT_Node y); diff --git a/bootstrap/unix-88/OPC.c b/bootstrap/unix-88/OPC.c index 99353400..9104c5c4 100644 --- a/bootstrap/unix-88/OPC.c +++ b/bootstrap/unix-88/OPC.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -17,10 +17,8 @@ static BOOLEAN OPC_GlbPtrs; static CHAR OPC_BodyNameExt[13]; -export void OPC_Align (int32 *adr, int32 base); export void OPC_Andent (OPT_Struct typ); static void OPC_AnsiParamList (OPT_Object obj, BOOLEAN showParamNames); -export int32 OPC_BaseAlignment (OPT_Struct typ); export OPT_Object OPC_BaseTProc (OPT_Object obj); export void OPC_BegBlk (void); export void OPC_BegStat (void); @@ -79,7 +77,6 @@ static void OPC_PutBase (OPT_Struct typ); static void OPC_PutPtrOffsets (OPT_Struct typ, int32 adr, int32 *cnt); static void OPC_RegCmds (OPT_Object obj); export void OPC_SetInclude (BOOLEAN exclude); -export int32 OPC_SizeAlignment (int32 size); static void OPC_Stars (OPT_Struct typ, BOOLEAN *openClause); static void OPC_Str1 (CHAR *s, LONGINT s__len, int32 x); static void OPC_StringLiteral (CHAR *s, LONGINT s__len, int32 l); @@ -750,7 +747,7 @@ static void OPC_CProcDefs (OPT_Object obj, int16 vis) { int16 i; OPT_ConstExt ext = NIL; - int16 _for__9; + int16 _for__7; if (obj != NIL) { OPC_CProcDefs(obj->left, vis); if ((((obj->mode == 9 && (int16)obj->vis >= vis)) && obj->adr == 1)) { @@ -762,9 +759,9 @@ static void OPC_CProcDefs (OPT_Object obj, int16 vis) OPC_DeclareParams(obj->link, 1); OPM_Write(0x09); } - _for__9 = (int16)(*obj->conval->ext)[0]; + _for__7 = (int16)(*obj->conval->ext)[0]; i = i; - while (i <= _for__9) { + while (i <= _for__7) { OPM_Write((*obj->conval->ext)[__X(i, 256)]); i += 1; } @@ -843,64 +840,11 @@ void OPC_InitTDesc (OPT_Struct typ) } } -void OPC_Align (int32 *adr, int32 base) -{ - switch (base) { - case 2: - *adr += __MASK(*adr, -2); - break; - case 4: - *adr += __MASK(-*adr, -4); - break; - case 8: - *adr += __MASK(-*adr, -8); - break; - case 16: - *adr += __MASK(-*adr, -16); - break; - default: - break; - } -} - -int32 OPC_SizeAlignment (int32 size) -{ - int32 _o_result; - int32 alignment; - if (size < OPM_Alignment) { - alignment = 1; - while (alignment < size) { - alignment = __ASHL(alignment, 1); - } - } else { - alignment = OPM_Alignment; - } - _o_result = alignment; - return _o_result; -} - -int32 OPC_BaseAlignment (OPT_Struct typ) -{ - int32 _o_result; - int32 alignment; - if (typ->form == 13) { - 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 (int32 gap, int32 off, int32 align, int32 *n, int32 *curAlign) { int32 adr; adr = off; - OPC_Align(&adr, align); + OPT_Align(&adr, align); if ((*curAlign < align && gap - (adr - off) >= align)) { gap -= (adr - off) + align; OPC_BegStat(); @@ -955,8 +899,8 @@ static void OPC_FieldList (OPT_Struct typ, BOOLEAN last, int32 *off, int32 *n, i } } else { adr = *off; - fldAlign = OPC_BaseAlignment(fld->typ); - OPC_Align(&adr, fldAlign); + fldAlign = OPT_BaseAlignment(fld->typ); + OPT_Align(&adr, fldAlign); gap = fld->adr - adr; if (fldAlign > *curAlign) { *curAlign = fldAlign; @@ -1205,7 +1149,7 @@ static void OPC_GenHeaderMsg (void) OPM_WriteString((CHAR*)"/* ", 4); OPM_WriteString((CHAR*)"voc", 4); OPM_Write(' '); - OPM_WriteString(Configuration_versionLong, 41); + OPM_WriteString(Configuration_versionLong, 75); OPM_Write(' '); i = 0; while (i <= 31) { @@ -1966,84 +1910,84 @@ void OPC_Constant (OPT_Const con, int16 form) } } -static struct InitKeywords__48 { +static struct InitKeywords__46 { int8 *n; - struct InitKeywords__48 *lnk; -} *InitKeywords__48_s; + struct InitKeywords__46 *lnk; +} *InitKeywords__46_s; -static void Enter__49 (CHAR *s, LONGINT s__len); +static void Enter__47 (CHAR *s, LONGINT s__len); -static void Enter__49 (CHAR *s, LONGINT s__len) +static void Enter__47 (CHAR *s, LONGINT s__len) { int16 h; __DUP(s, s__len, CHAR); h = OPC_PerfectHash((void*)s, s__len); - OPC_hashtab[__X(h, 105)] = *InitKeywords__48_s->n; - __COPY(s, OPC_keytab[__X(*InitKeywords__48_s->n, 50)], 9); - *InitKeywords__48_s->n += 1; + OPC_hashtab[__X(h, 105)] = *InitKeywords__46_s->n; + __COPY(s, OPC_keytab[__X(*InitKeywords__46_s->n, 50)], 9); + *InitKeywords__46_s->n += 1; __DEL(s); } static void OPC_InitKeywords (void) { int8 n, i; - struct InitKeywords__48 _s; + struct InitKeywords__46 _s; _s.n = &n; - _s.lnk = InitKeywords__48_s; - InitKeywords__48_s = &_s; + _s.lnk = InitKeywords__46_s; + InitKeywords__46_s = &_s; n = 0; i = 0; while (i <= 104) { OPC_hashtab[__X(i, 105)] = -1; i += 1; } - Enter__49((CHAR*)"address", 8); - Enter__49((CHAR*)"asm", 4); - Enter__49((CHAR*)"auto", 5); - Enter__49((CHAR*)"break", 6); - Enter__49((CHAR*)"case", 5); - Enter__49((CHAR*)"char", 5); - Enter__49((CHAR*)"const", 6); - Enter__49((CHAR*)"continue", 9); - Enter__49((CHAR*)"default", 8); - Enter__49((CHAR*)"do", 3); - Enter__49((CHAR*)"double", 7); - Enter__49((CHAR*)"else", 5); - Enter__49((CHAR*)"enum", 5); - Enter__49((CHAR*)"extern", 7); - Enter__49((CHAR*)"export", 7); - Enter__49((CHAR*)"float", 6); - Enter__49((CHAR*)"for", 4); - Enter__49((CHAR*)"fortran", 8); - Enter__49((CHAR*)"goto", 5); - Enter__49((CHAR*)"if", 3); - Enter__49((CHAR*)"import", 7); - Enter__49((CHAR*)"int", 4); - Enter__49((CHAR*)"int16", 6); - Enter__49((CHAR*)"int32", 6); - Enter__49((CHAR*)"int64", 6); - Enter__49((CHAR*)"int8", 5); - Enter__49((CHAR*)"long", 5); - Enter__49((CHAR*)"register", 9); - Enter__49((CHAR*)"return", 7); - Enter__49((CHAR*)"short", 6); - Enter__49((CHAR*)"signed", 7); - Enter__49((CHAR*)"sizeof", 7); - Enter__49((CHAR*)"size_t", 7); - Enter__49((CHAR*)"static", 7); - Enter__49((CHAR*)"struct", 7); - Enter__49((CHAR*)"switch", 7); - Enter__49((CHAR*)"typedef", 8); - Enter__49((CHAR*)"uint16", 7); - Enter__49((CHAR*)"uint32", 7); - Enter__49((CHAR*)"uint64", 7); - Enter__49((CHAR*)"uint8", 6); - Enter__49((CHAR*)"union", 6); - Enter__49((CHAR*)"unsigned", 9); - Enter__49((CHAR*)"void", 5); - Enter__49((CHAR*)"volatile", 9); - Enter__49((CHAR*)"while", 6); - InitKeywords__48_s = _s.lnk; + Enter__47((CHAR*)"address", 8); + Enter__47((CHAR*)"asm", 4); + Enter__47((CHAR*)"auto", 5); + Enter__47((CHAR*)"break", 6); + Enter__47((CHAR*)"case", 5); + Enter__47((CHAR*)"char", 5); + Enter__47((CHAR*)"const", 6); + Enter__47((CHAR*)"continue", 9); + Enter__47((CHAR*)"default", 8); + Enter__47((CHAR*)"do", 3); + Enter__47((CHAR*)"double", 7); + Enter__47((CHAR*)"else", 5); + Enter__47((CHAR*)"enum", 5); + Enter__47((CHAR*)"extern", 7); + Enter__47((CHAR*)"export", 7); + Enter__47((CHAR*)"float", 6); + Enter__47((CHAR*)"for", 4); + Enter__47((CHAR*)"fortran", 8); + Enter__47((CHAR*)"goto", 5); + Enter__47((CHAR*)"if", 3); + Enter__47((CHAR*)"import", 7); + Enter__47((CHAR*)"int", 4); + Enter__47((CHAR*)"int16", 6); + Enter__47((CHAR*)"int32", 6); + Enter__47((CHAR*)"int64", 6); + Enter__47((CHAR*)"int8", 5); + Enter__47((CHAR*)"long", 5); + Enter__47((CHAR*)"register", 9); + Enter__47((CHAR*)"return", 7); + Enter__47((CHAR*)"short", 6); + Enter__47((CHAR*)"signed", 7); + Enter__47((CHAR*)"sizeof", 7); + Enter__47((CHAR*)"size_t", 7); + Enter__47((CHAR*)"static", 7); + Enter__47((CHAR*)"struct", 7); + Enter__47((CHAR*)"switch", 7); + Enter__47((CHAR*)"typedef", 8); + Enter__47((CHAR*)"uint16", 7); + Enter__47((CHAR*)"uint32", 7); + Enter__47((CHAR*)"uint64", 7); + Enter__47((CHAR*)"uint8", 6); + Enter__47((CHAR*)"union", 6); + Enter__47((CHAR*)"unsigned", 9); + Enter__47((CHAR*)"void", 5); + Enter__47((CHAR*)"volatile", 9); + Enter__47((CHAR*)"while", 6); + InitKeywords__46_s = _s.lnk; } diff --git a/bootstrap/unix-88/OPC.h b/bootstrap/unix-88/OPC.h index 4215947f..6236cd73 100644 --- a/bootstrap/unix-88/OPC.h +++ b/bootstrap/unix-88/OPC.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPC__h #define OPC__h @@ -9,9 +9,7 @@ -import void OPC_Align (int32 *adr, int32 base); import void OPC_Andent (OPT_Struct typ); -import int32 OPC_BaseAlignment (OPT_Struct typ); import OPT_Object OPC_BaseTProc (OPT_Object obj); import void OPC_BegBlk (void); import void OPC_BegStat (void); @@ -41,7 +39,6 @@ import void OPC_IntLiteral (int64 n, int32 size); import void OPC_Len (OPT_Object obj, OPT_Struct array, int64 dim); import int32 OPC_NofPtrs (OPT_Struct typ); import void OPC_SetInclude (BOOLEAN exclude); -import int32 OPC_SizeAlignment (int32 size); import void OPC_TDescDecl (OPT_Struct typ); import void OPC_TypeDefs (OPT_Object obj, int16 vis); import void OPC_TypeOf (OPT_Object ap); diff --git a/bootstrap/unix-88/OPM.c b/bootstrap/unix-88/OPM.c index 931ecb18..7b566324 100644 --- a/bootstrap/unix-88/OPM.c +++ b/bootstrap/unix-88/OPM.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -223,6 +223,7 @@ static void OPM_ScanOptions (CHAR *s, LONGINT s__len, SET *opt) OPM_AddressSize = (int16)s[__X(i + 1, s__len)] - 48; OPM_Alignment = (int16)s[__X(i + 2, s__len)] - 48; i += 2; + Files_SetSearchPath((CHAR*)"", 1); } break; case 'B': @@ -270,7 +271,7 @@ BOOLEAN OPM_OpenPar (void) if (Platform_ArgCount == 1) { OPM_LogWLn(); OPM_LogWStr((CHAR*)"Oberon-2 compiler v", 20); - OPM_LogWStr(Configuration_versionLong, 41); + OPM_LogWStr(Configuration_versionLong, 75); OPM_LogW('.'); OPM_LogWLn(); OPM_LogWStr((CHAR*)"Based on Ofront by Software Templ OEG.", 39); @@ -1118,7 +1119,7 @@ export void *OPM__init(void) Strings_Append((CHAR*)";.;", 4, (void*)OPM_OBERON, 1024); Strings_Append(OPM_MODULES, 1024, (void*)OPM_OBERON, 1024); Strings_Append((CHAR*)";", 2, (void*)OPM_OBERON, 1024); - Strings_Append((CHAR*)"/opt/voc", 9, (void*)OPM_OBERON, 1024); + Strings_Append((CHAR*)"", 1, (void*)OPM_OBERON, 1024); Strings_Append((CHAR*)"/sym;", 6, (void*)OPM_OBERON, 1024); Files_SetSearchPath(OPM_OBERON, 1024); OPM_AddressSize = 8; diff --git a/bootstrap/unix-88/OPM.h b/bootstrap/unix-88/OPM.h index 96af4022..b62666db 100644 --- a/bootstrap/unix-88/OPM.h +++ b/bootstrap/unix-88/OPM.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPM__h #define OPM__h diff --git a/bootstrap/unix-88/OPP.c b/bootstrap/unix-88/OPP.c index 74f93e77..03366726 100644 --- a/bootstrap/unix-88/OPP.c +++ b/bootstrap/unix-88/OPP.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-88/OPP.h b/bootstrap/unix-88/OPP.h index e5a59f6c..ea6663ba 100644 --- a/bootstrap/unix-88/OPP.h +++ b/bootstrap/unix-88/OPP.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/unix-88/OPS.c b/bootstrap/unix-88/OPS.c index 0cac83bd..2b449cae 100644 --- a/bootstrap/unix-88/OPS.c +++ b/bootstrap/unix-88/OPS.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin tspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-88/OPS.h b/bootstrap/unix-88/OPS.h index caef45f4..8d90d974 100644 --- a/bootstrap/unix-88/OPS.h +++ b/bootstrap/unix-88/OPS.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin tspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/unix-88/OPT.c b/bootstrap/unix-88/OPT.c index d40808d2..c9ff5430 100644 --- a/bootstrap/unix-88/OPT.c +++ b/bootstrap/unix-88/OPT.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -87,7 +87,6 @@ typedef } OPT_StrDesc; -export void (*OPT_typSize)(OPT_Struct); export OPT_Object OPT_topScope; export OPT_Struct OPT_undftyp, OPT_bytetyp, OPT_booltyp, OPT_chartyp, OPT_sinttyp, OPT_inttyp, OPT_linttyp, OPT_hinttyp, OPT_adrtyp, OPT_int8typ, OPT_int16typ, OPT_int32typ, OPT_int64typ, OPT_realtyp, OPT_lrltyp, OPT_settyp, OPT_stringtyp, OPT_niltyp, OPT_notyp, OPT_sysptrtyp; export OPT_Object OPT_sintobj, OPT_intobj, OPT_lintobj; @@ -100,6 +99,7 @@ static OPT_ImpCtxt OPT_impCtxt; static OPT_ExpCtxt OPT_expCtxt; static int32 OPT_nofhdfld; static BOOLEAN OPT_newsf, OPT_findpc, OPT_extsf, OPT_sfpresent, OPT_symExtended, OPT_symNew; +static int32 OPT_recno; export address *OPT_ConstDesc__typ; export address *OPT_ObjDesc__typ; @@ -108,6 +108,8 @@ export address *OPT_NodeDesc__typ; export address *OPT_ImpCtxt__typ; export address *OPT_ExpCtxt__typ; +export void OPT_Align (int32 *adr, int32 base); +export int32 OPT_BaseAlignment (OPT_Struct typ); export void OPT_Close (void); export void OPT_CloseScope (void); static void OPT_DebugStruct (OPT_Struct btyp); @@ -136,6 +138,7 @@ static void OPT_InStruct (OPT_Struct *typ); static OPT_Object OPT_InTProc (int8 mno); static OPT_Struct OPT_InTyp (int32 tag); export void OPT_Init (OPS_Name name, SET opt); +export void OPT_InitRecno (void); static void OPT_InitStruct (OPT_Struct *typ, int8 form); export void OPT_Insert (OPS_Name name, OPT_Object *obj); export void OPT_InsertImport (OPT_Object obj, OPT_Object *root, OPT_Object *old); @@ -157,9 +160,16 @@ static void OPT_OutSign (OPT_Struct result, OPT_Object par); static void OPT_OutStr (OPT_Struct typ); static void OPT_OutTProcs (OPT_Struct typ, OPT_Object obj); export OPT_Struct OPT_ShorterOrLongerType (OPT_Struct x, int16 dir); +export int32 OPT_SizeAlignment (int32 size); +export void OPT_TypSize (OPT_Struct typ); static void OPT_err (int16 n); +void OPT_InitRecno (void) +{ + OPT_recno = 0; +} + static void OPT_err (int16 n) { OPM_err(n); @@ -240,6 +250,130 @@ OPT_Struct OPT_ShorterOrLongerType (OPT_Struct x, int16 dir) __RETCHK; } +void OPT_Align (int32 *adr, int32 base) +{ + switch (base) { + case 2: + *adr += __MASK(*adr, -2); + break; + case 4: + *adr += __MASK(-*adr, -4); + break; + case 8: + *adr += __MASK(-*adr, -8); + break; + case 16: + *adr += __MASK(-*adr, -16); + break; + default: + break; + } +} + +int32 OPT_SizeAlignment (int32 size) +{ + int32 _o_result; + int32 alignment; + if (size < OPM_Alignment) { + alignment = 1; + while (alignment < size) { + alignment = __ASHL(alignment, 1); + } + } else { + alignment = OPM_Alignment; + } + _o_result = alignment; + return _o_result; +} + +int32 OPT_BaseAlignment (OPT_Struct typ) +{ + int32 _o_result; + int32 alignment; + if (typ->form == 13) { + if (typ->comp == 4) { + alignment = __MASK(typ->align, -65536); + } else { + alignment = OPT_BaseAlignment(typ->BaseTyp); + } + } else { + alignment = OPT_SizeAlignment(typ->size); + } + _o_result = alignment; + return _o_result; +} + +void OPT_TypSize (OPT_Struct typ) +{ + int16 f, c; + int32 offset, size, base, fbase, off0; + OPT_Object fld = NIL; + OPT_Struct btyp = NIL; + if (typ == OPT_undftyp) { + OPM_err(58); + } else if (typ->size == -1) { + f = typ->form; + c = typ->comp; + if (c == 4) { + btyp = typ->BaseTyp; + if (btyp == NIL) { + offset = 0; + base = 1; + } else { + OPT_TypSize(btyp); + offset = btyp->size - __ASHR(btyp->sysflag, 8); + base = btyp->align; + } + fld = typ->link; + while ((fld != NIL && fld->mode == 4)) { + btyp = fld->typ; + OPT_TypSize(btyp); + size = btyp->size; + fbase = OPT_BaseAlignment(btyp); + OPT_Align(&offset, fbase); + fld->adr = offset; + offset += size; + if (fbase > base) { + base = fbase; + } + fld = fld->link; + } + off0 = offset; + if (offset == 0) { + offset = 1; + } + OPT_Align(&offset, base); + if ((typ->strobj == NIL && __MASK(typ->align, -65536) == 0)) { + OPT_recno += 1; + base += __ASHL(OPT_recno, 16); + } + typ->size = offset; + typ->align = base; + typ->sysflag = __MASK(typ->sysflag, -256) + (int16)__ASHL(offset - off0, 8); + } else if (c == 2) { + OPT_TypSize(typ->BaseTyp); + typ->size = typ->n * typ->BaseTyp->size; + } else if (f == 11) { + typ->size = OPM_AddressSize; + if (typ->BaseTyp == OPT_undftyp) { + OPM_Mark(128, typ->n); + } else { + OPT_TypSize(typ->BaseTyp); + } + } else if (f == 12) { + typ->size = OPM_AddressSize; + } else if (c == 3) { + btyp = typ->BaseTyp; + OPT_TypSize(btyp); + if (btyp->comp == 3) { + typ->size = btyp->size + 4; + } else { + typ->size = 8; + } + } + } +} + OPT_Const OPT_NewConst (void) { OPT_Const _o_result; @@ -552,21 +686,21 @@ void OPT_IdFPrint (OPT_Struct typ) } } -static struct FPrintStr__13 { +static struct FPrintStr__15 { int32 *pbfp, *pvfp; - struct FPrintStr__13 *lnk; -} *FPrintStr__13_s; + struct FPrintStr__15 *lnk; +} *FPrintStr__15_s; -static void FPrintFlds__14 (OPT_Object fld, int32 adr, BOOLEAN visible); -static void FPrintHdFld__16 (OPT_Struct typ, OPT_Object fld, int32 adr); -static void FPrintTProcs__18 (OPT_Object obj); +static void FPrintFlds__16 (OPT_Object fld, int32 adr, BOOLEAN visible); +static void FPrintHdFld__18 (OPT_Struct typ, OPT_Object fld, int32 adr); +static void FPrintTProcs__20 (OPT_Object obj); -static void FPrintHdFld__16 (OPT_Struct typ, OPT_Object fld, int32 adr) +static void FPrintHdFld__18 (OPT_Struct typ, OPT_Object fld, int32 adr) { int32 i, j, n; OPT_Struct btyp = NIL; if (typ->comp == 4) { - FPrintFlds__14(typ->link, adr, 0); + FPrintFlds__16(typ->link, adr, 0); } else if (typ->comp == 2) { btyp = typ->BaseTyp; n = typ->n; @@ -576,53 +710,53 @@ static void FPrintHdFld__16 (OPT_Struct typ, OPT_Object fld, int32 adr) } if (btyp->form == 11 || btyp->comp == 4) { j = OPT_nofhdfld; - FPrintHdFld__16(btyp, fld, adr); + FPrintHdFld__18(btyp, fld, adr); if (j != OPT_nofhdfld) { i = 1; while ((i < n && OPT_nofhdfld <= 2048)) { adr += btyp->size; - FPrintHdFld__16(btyp, fld, adr); + FPrintHdFld__18(btyp, fld, adr); i += 1; } } } } else if (typ->form == 11 || __STRCMP(fld->name, "@ptr") == 0) { - OPM_FPrint(&*FPrintStr__13_s->pvfp, 11); - OPM_FPrint(&*FPrintStr__13_s->pvfp, adr); + OPM_FPrint(&*FPrintStr__15_s->pvfp, 11); + OPM_FPrint(&*FPrintStr__15_s->pvfp, adr); OPT_nofhdfld += 1; } } -static void FPrintFlds__14 (OPT_Object fld, int32 adr, BOOLEAN visible) +static void FPrintFlds__16 (OPT_Object fld, int32 adr, BOOLEAN visible) { while ((fld != NIL && fld->mode == 4)) { if ((fld->vis != 0 && visible)) { - OPM_FPrint(&*FPrintStr__13_s->pbfp, fld->vis); - OPT_FPrintName(&*FPrintStr__13_s->pbfp, (void*)fld->name, 256); - OPM_FPrint(&*FPrintStr__13_s->pbfp, fld->adr); + OPM_FPrint(&*FPrintStr__15_s->pbfp, fld->vis); + OPT_FPrintName(&*FPrintStr__15_s->pbfp, (void*)fld->name, 256); + OPM_FPrint(&*FPrintStr__15_s->pbfp, fld->adr); OPT_FPrintStr(fld->typ); - OPM_FPrint(&*FPrintStr__13_s->pbfp, fld->typ->pbfp); - OPM_FPrint(&*FPrintStr__13_s->pvfp, fld->typ->pvfp); + OPM_FPrint(&*FPrintStr__15_s->pbfp, fld->typ->pbfp); + OPM_FPrint(&*FPrintStr__15_s->pvfp, fld->typ->pvfp); } else { - FPrintHdFld__16(fld->typ, fld, fld->adr + adr); + FPrintHdFld__18(fld->typ, fld, fld->adr + adr); } fld = fld->link; } } -static void FPrintTProcs__18 (OPT_Object obj) +static void FPrintTProcs__20 (OPT_Object obj) { if (obj != NIL) { - FPrintTProcs__18(obj->left); + FPrintTProcs__20(obj->left); if (obj->mode == 13) { if (obj->vis != 0) { - OPM_FPrint(&*FPrintStr__13_s->pbfp, 13); - OPM_FPrint(&*FPrintStr__13_s->pbfp, __ASHR(obj->adr, 16)); - OPT_FPrintSign(&*FPrintStr__13_s->pbfp, obj->typ, obj->link); - OPT_FPrintName(&*FPrintStr__13_s->pbfp, (void*)obj->name, 256); + OPM_FPrint(&*FPrintStr__15_s->pbfp, 13); + OPM_FPrint(&*FPrintStr__15_s->pbfp, __ASHR(obj->adr, 16)); + OPT_FPrintSign(&*FPrintStr__15_s->pbfp, obj->typ, obj->link); + OPT_FPrintName(&*FPrintStr__15_s->pbfp, (void*)obj->name, 256); } } - FPrintTProcs__18(obj->right); + FPrintTProcs__20(obj->right); } } @@ -632,11 +766,11 @@ void OPT_FPrintStr (OPT_Struct typ) OPT_Struct btyp = NIL; OPT_Object strobj = NIL, bstrobj = NIL; int32 pbfp, pvfp; - struct FPrintStr__13 _s; + struct FPrintStr__15 _s; _s.pbfp = &pbfp; _s.pvfp = &pvfp; - _s.lnk = FPrintStr__13_s; - FPrintStr__13_s = &_s; + _s.lnk = FPrintStr__15_s; + FPrintStr__15_s = &_s; if (!typ->fpdone) { OPT_IdFPrint(typ); pbfp = typ->idfp; @@ -673,11 +807,11 @@ void OPT_FPrintStr (OPT_Struct typ) OPM_FPrint(&pvfp, typ->align); OPM_FPrint(&pvfp, typ->n); OPT_nofhdfld = 0; - FPrintFlds__14(typ->link, 0, 1); + FPrintFlds__16(typ->link, 0, 1); if (OPT_nofhdfld > 2048) { OPM_Mark(225, typ->txtpos); } - FPrintTProcs__18(typ->link); + FPrintTProcs__20(typ->link); OPM_FPrint(&pvfp, pbfp); strobj = typ->strobj; if (strobj == NIL || strobj->name[0] == 0x00) { @@ -687,7 +821,7 @@ void OPT_FPrintStr (OPT_Struct typ) typ->pbfp = pbfp; typ->pvfp = pvfp; } - FPrintStr__13_s = _s.lnk; + FPrintStr__15_s = _s.lnk; } void OPT_FPrintObj (OPT_Object obj) @@ -1119,7 +1253,7 @@ static void OPT_InStruct (OPT_Struct *typ) (*typ)->comp = 2; OPT_InStruct(&(*typ)->BaseTyp); (*typ)->n = OPM_SymRInt(); - (*OPT_typSize)(*typ); + OPT_TypSize(*typ); break; case 38: (*typ)->form = 13; @@ -1130,7 +1264,7 @@ static void OPT_InStruct (OPT_Struct *typ) } else { (*typ)->n = 0; } - (*OPT_typSize)(*typ); + OPT_TypSize(*typ); break; case 39: (*typ)->form = 13; @@ -1899,6 +2033,7 @@ export void *OPT__init(void) __REGMOD("OPT", EnumPtrs); __REGCMD("Close", OPT_Close); __REGCMD("CloseScope", OPT_CloseScope); + __REGCMD("InitRecno", OPT_InitRecno); __INITYP(OPT_ConstDesc, OPT_ConstDesc, 0); __INITYP(OPT_ObjDesc, OPT_ObjDesc, 0); __INITYP(OPT_StrDesc, OPT_StrDesc, 0); diff --git a/bootstrap/unix-88/OPT.h b/bootstrap/unix-88/OPT.h index 0bd1f189..1a525fcb 100644 --- a/bootstrap/unix-88/OPT.h +++ b/bootstrap/unix-88/OPT.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPT__h #define OPT__h @@ -66,7 +66,6 @@ typedef } OPT_StrDesc; -import void (*OPT_typSize)(OPT_Struct); import OPT_Object OPT_topScope; import OPT_Struct OPT_undftyp, OPT_bytetyp, OPT_booltyp, OPT_chartyp, OPT_sinttyp, OPT_inttyp, OPT_linttyp, OPT_hinttyp, OPT_adrtyp, OPT_int8typ, OPT_int16typ, OPT_int32typ, OPT_int64typ, OPT_realtyp, OPT_lrltyp, OPT_settyp, OPT_stringtyp, OPT_niltyp, OPT_notyp, OPT_sysptrtyp; import OPT_Object OPT_sintobj, OPT_intobj, OPT_lintobj; @@ -80,6 +79,8 @@ import address *OPT_ObjDesc__typ; import address *OPT_StrDesc__typ; import address *OPT_NodeDesc__typ; +import void OPT_Align (int32 *adr, int32 base); +import int32 OPT_BaseAlignment (OPT_Struct typ); import void OPT_Close (void); import void OPT_CloseScope (void); import void OPT_Export (BOOLEAN *ext, BOOLEAN *new); @@ -92,6 +93,7 @@ import void OPT_FindImport (OPT_Object mod, OPT_Object *res); import void OPT_IdFPrint (OPT_Struct typ); import void OPT_Import (OPS_Name aliasName, OPS_Name name, BOOLEAN *done); import void OPT_Init (OPS_Name name, SET opt); +import void OPT_InitRecno (void); import void OPT_Insert (OPS_Name name, OPT_Object *obj); import void OPT_InsertImport (OPT_Object obj, OPT_Object *root, OPT_Object *old); import int16 OPT_IntSize (int64 n); @@ -103,6 +105,8 @@ import OPT_Object OPT_NewObj (void); import OPT_Struct OPT_NewStr (int8 form, int8 comp); import void OPT_OpenScope (int8 level, OPT_Object owner); import OPT_Struct OPT_ShorterOrLongerType (OPT_Struct x, int16 dir); +import int32 OPT_SizeAlignment (int32 size); +import void OPT_TypSize (OPT_Struct typ); import void *OPT__init(void); diff --git a/bootstrap/unix-88/OPV.c b/bootstrap/unix-88/OPV.c index 8ef2c450..f9e7c27c 100644 --- a/bootstrap/unix-88/OPV.c +++ b/bootstrap/unix-88/OPV.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -17,7 +17,6 @@ typedef static int16 OPV_stamp; -static int32 OPV_recno; static OPV_ExitInfo OPV_exit; static int16 OPV_nofExitLabels; @@ -46,88 +45,15 @@ static void OPV_Stamp (OPS_Name s); static OPT_Object OPV_SuperProc (OPT_Node n); static void OPV_Traverse (OPT_Object obj, OPT_Object outerScope, BOOLEAN exported); static void OPV_TraverseRecord (OPT_Struct typ); -export void OPV_TypSize (OPT_Struct typ); static void OPV_TypeOf (OPT_Node n); static void OPV_design (OPT_Node n, int16 prec); static void OPV_expr (OPT_Node n, int16 prec); static void OPV_stat (OPT_Node n, OPT_Object outerProc); -void OPV_TypSize (OPT_Struct typ) -{ - int16 f, c; - int32 offset, size, base, fbase, off0; - OPT_Object fld = NIL; - OPT_Struct btyp = NIL; - if (typ == OPT_undftyp) { - OPM_err(58); - } else if (typ->size == -1) { - f = typ->form; - c = typ->comp; - if (c == 4) { - btyp = typ->BaseTyp; - if (btyp == NIL) { - offset = 0; - base = 1; - } else { - OPV_TypSize(btyp); - offset = btyp->size - __ASHR(btyp->sysflag, 8); - base = btyp->align; - } - fld = typ->link; - while ((fld != NIL && fld->mode == 4)) { - btyp = fld->typ; - OPV_TypSize(btyp); - size = btyp->size; - fbase = OPC_BaseAlignment(btyp); - OPC_Align(&offset, fbase); - fld->adr = offset; - offset += size; - if (fbase > base) { - base = fbase; - } - fld = fld->link; - } - off0 = offset; - if (offset == 0) { - offset = 1; - } - OPC_Align(&offset, base); - if ((typ->strobj == NIL && __MASK(typ->align, -65536) == 0)) { - OPV_recno += 1; - base += __ASHL(OPV_recno, 16); - } - typ->size = offset; - typ->align = base; - typ->sysflag = __MASK(typ->sysflag, -256) + (int16)__ASHL(offset - off0, 8); - } else if (c == 2) { - OPV_TypSize(typ->BaseTyp); - typ->size = typ->n * typ->BaseTyp->size; - } else if (f == 11) { - typ->size = OPM_AddressSize; - if (typ->BaseTyp == OPT_undftyp) { - OPM_Mark(128, typ->n); - } else { - OPV_TypSize(typ->BaseTyp); - } - } else if (f == 12) { - typ->size = OPM_AddressSize; - } else if (c == 3) { - btyp = typ->BaseTyp; - OPV_TypSize(btyp); - if (btyp->comp == 3) { - typ->size = btyp->size + 4; - } else { - typ->size = 8; - } - } - } -} - void OPV_Init (void) { OPV_stamp = 0; - OPV_recno = 0; OPV_nofExitLabels = 0; } @@ -212,7 +138,7 @@ static void OPV_Traverse (OPT_Object obj, OPT_Object outerScope, BOOLEAN exporte mode = obj->mode; if ((mode == 5 && (obj->vis != 0) == exported)) { typ = obj->typ; - OPV_TypSize(obj->typ); + OPT_TypSize(obj->typ); if (typ->form == 11) { typ = typ->BaseTyp; } @@ -222,7 +148,7 @@ static void OPV_Traverse (OPT_Object obj, OPT_Object outerScope, BOOLEAN exporte } else if (mode == 13) { OPV_GetTProcNum(obj); } else if (mode == 1) { - OPV_TypSize(obj->typ); + OPT_TypSize(obj->typ); } if (!exported) { if ((__IN(mode, 0x60, 32) && obj->mnolev > 0)) { @@ -548,7 +474,7 @@ static void OPV_design (OPT_Node n, int16 prec) OPT_Struct typ = NIL; int16 class, designPrec, comp; OPT_Node d = NIL, x = NIL; - int16 dims, i, _for__27; + int16 dims, i, _for__26; comp = n->typ->comp; obj = n->obj; class = n->class; @@ -624,9 +550,9 @@ static void OPV_design (OPT_Node n, int16 prec) } x = x->left; } - _for__27 = dims; + _for__26 = dims; i = 1; - while (i <= _for__27) { + while (i <= _for__26) { OPM_Write(')'); i += 1; } @@ -1290,7 +1216,7 @@ static void OPV_NewArr (OPT_Node d, OPT_Node x) OPM_WriteString((CHAR*)", ", 3); OPM_WriteInt(base->size); OPM_WriteString((CHAR*)", ", 3); - OPM_WriteInt(OPC_BaseAlignment(base)); + OPM_WriteInt(OPT_BaseAlignment(base)); OPM_WriteString((CHAR*)", ", 3); OPM_WriteInt(nofdim); OPM_WriteString((CHAR*)", ", 3); diff --git a/bootstrap/unix-88/OPV.h b/bootstrap/unix-88/OPV.h index c309d63c..09931dda 100644 --- a/bootstrap/unix-88/OPV.h +++ b/bootstrap/unix-88/OPV.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPV__h #define OPV__h @@ -12,7 +12,6 @@ import void OPV_AdrAndSize (OPT_Object topScope); import void OPV_Init (void); import void OPV_Module (OPT_Node prog); -import void OPV_TypSize (OPT_Struct typ); import void *OPV__init(void); diff --git a/bootstrap/unix-88/Platform.c b/bootstrap/unix-88/Platform.c index 016d1d64..8df906c3 100644 --- a/bootstrap/unix-88/Platform.c +++ b/bootstrap/unix-88/Platform.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-88/Platform.h b/bootstrap/unix-88/Platform.h index 32d37057..d76d7ed5 100644 --- a/bootstrap/unix-88/Platform.h +++ b/bootstrap/unix-88/Platform.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/unix-88/Reals.c b/bootstrap/unix-88/Reals.c index fe93e8be..4b72fbe3 100644 --- a/bootstrap/unix-88/Reals.c +++ b/bootstrap/unix-88/Reals.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-88/Reals.h b/bootstrap/unix-88/Reals.h index e7cba0d8..4a4c73b0 100644 --- a/bootstrap/unix-88/Reals.h +++ b/bootstrap/unix-88/Reals.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/unix-88/Strings.c b/bootstrap/unix-88/Strings.c index 427a0cc4..f765b98f 100644 --- a/bootstrap/unix-88/Strings.c +++ b/bootstrap/unix-88/Strings.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-88/Strings.h b/bootstrap/unix-88/Strings.h index 44c51b2a..be1e7d7f 100644 --- a/bootstrap/unix-88/Strings.h +++ b/bootstrap/unix-88/Strings.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/unix-88/Texts.c b/bootstrap/unix-88/Texts.c index 8c41a062..6cb415b9 100644 --- a/bootstrap/unix-88/Texts.c +++ b/bootstrap/unix-88/Texts.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-88/Texts.h b/bootstrap/unix-88/Texts.h index fa080b7f..dc456f77 100644 --- a/bootstrap/unix-88/Texts.h +++ b/bootstrap/unix-88/Texts.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/unix-88/Vishap.c b/bootstrap/unix-88/Vishap.c index 1ec89e33..30b81ac7 100644 --- a/bootstrap/unix-88/Vishap.c +++ b/bootstrap/unix-88/Vishap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspamSf */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspamSf */ #define INTEGER int16 #define LONGINT int32 @@ -35,6 +35,7 @@ void Vishap_Module (BOOLEAN *done) OPP_Module(&p, OPM_opt); if (OPM_noerr) { OPV_Init(); + OPT_InitRecno(); OPV_AdrAndSize(OPT_topScope); OPT_Export(&ext, &new); if (OPM_noerr) { @@ -165,8 +166,6 @@ export int main(int argc, char **argv) Platform_SetInterruptHandler(Vishap_Trap); Platform_SetQuitHandler(Vishap_Trap); Platform_SetBadInstructionHandler(Vishap_Trap); - OPB_typSize = OPV_TypSize; - OPT_typSize = OPV_TypSize; Vishap_Translate(); __FINI; } diff --git a/bootstrap/unix-88/errors.c b/bootstrap/unix-88/errors.c index 0a40d5e9..d465624d 100644 --- a/bootstrap/unix-88/errors.c +++ b/bootstrap/unix-88/errors.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-88/errors.h b/bootstrap/unix-88/errors.h index 759b613e..cf093ab3 100644 --- a/bootstrap/unix-88/errors.h +++ b/bootstrap/unix-88/errors.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef errors__h #define errors__h diff --git a/bootstrap/unix-88/extTools.c b/bootstrap/unix-88/extTools.c index 8be0b63d..46f8ac7e 100644 --- a/bootstrap/unix-88/extTools.c +++ b/bootstrap/unix-88/extTools.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -89,7 +89,7 @@ void extTools_LinkMain (CHAR *moduleName, LONGINT moduleName__len, BOOLEAN stati Strings_Append((CHAR*)" -o ", 5, (void*)cmd, 1023); Strings_Append(moduleName, moduleName__len, (void*)cmd, 1023); Strings_Append((CHAR*)" -L\"", 5, (void*)cmd, 1023); - Strings_Append((CHAR*)"/opt/voc", 9, (void*)cmd, 1023); + Strings_Append((CHAR*)"", 1, (void*)cmd, 1023); Strings_Append((CHAR*)"/lib\"", 6, (void*)cmd, 1023); Strings_Append((CHAR*)" -l voc", 8, (void*)cmd, 1023); extTools_execute((CHAR*)"Assemble and link: ", 20, cmd, 1023); @@ -108,7 +108,7 @@ export void *extTools__init(void) __REGMOD("extTools", 0); /* BEGIN */ Strings_Append((CHAR*)" -I \"", 6, (void*)extTools_compilationOptions, 1023); - Strings_Append((CHAR*)"/opt/voc", 9, (void*)extTools_compilationOptions, 1023); + Strings_Append((CHAR*)"", 1, (void*)extTools_compilationOptions, 1023); Strings_Append((CHAR*)"/include\" ", 11, (void*)extTools_compilationOptions, 1023); Platform_GetEnv((CHAR*)"CFLAGS", 7, (void*)extTools_CFLAGS, 1023); Strings_Append(extTools_CFLAGS, 1023, (void*)extTools_compilationOptions, 1023); diff --git a/bootstrap/unix-88/extTools.h b/bootstrap/unix-88/extTools.h index bff1c62c..700e6b39 100644 --- a/bootstrap/unix-88/extTools.h +++ b/bootstrap/unix-88/extTools.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef extTools__h #define extTools__h diff --git a/bootstrap/unix-88/vt100.c b/bootstrap/unix-88/vt100.c index 4f6a6c9d..8d4cbdfc 100644 --- a/bootstrap/unix-88/vt100.c +++ b/bootstrap/unix-88/vt100.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-88/vt100.h b/bootstrap/unix-88/vt100.h index 94f8add4..da86e98b 100644 --- a/bootstrap/unix-88/vt100.h +++ b/bootstrap/unix-88/vt100.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef vt100__h #define vt100__h diff --git a/bootstrap/windows-48/Configuration.c b/bootstrap/windows-48/Configuration.c index abdf151b..7f7f4b26 100644 --- a/bootstrap/windows-48/Configuration.c +++ b/bootstrap/windows-48/Configuration.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -7,7 +7,7 @@ #include "SYSTEM.h" -export CHAR Configuration_versionLong[41]; +export CHAR Configuration_versionLong[75]; @@ -18,6 +18,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("1.95 [2016/09/23] for gcc LP64 on cygwin", Configuration_versionLong, 41); + __MOVE("1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); __ENDMOD; } diff --git a/bootstrap/windows-48/Configuration.h b/bootstrap/windows-48/Configuration.h index f51f63f2..618bc77f 100644 --- a/bootstrap/windows-48/Configuration.h +++ b/bootstrap/windows-48/Configuration.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Configuration__h #define Configuration__h @@ -6,7 +6,7 @@ #include "SYSTEM.h" -import CHAR Configuration_versionLong[41]; +import CHAR Configuration_versionLong[75]; import void *Configuration__init(void); diff --git a/bootstrap/windows-48/Console.c b/bootstrap/windows-48/Console.c index 7b492ced..8b55dc14 100644 --- a/bootstrap/windows-48/Console.c +++ b/bootstrap/windows-48/Console.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-48/Console.h b/bootstrap/windows-48/Console.h index b08c93ea..d645f05c 100644 --- a/bootstrap/windows-48/Console.h +++ b/bootstrap/windows-48/Console.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Console__h #define Console__h diff --git a/bootstrap/windows-48/Files.c b/bootstrap/windows-48/Files.c index 98974743..9a5d7c98 100644 --- a/bootstrap/windows-48/Files.c +++ b/bootstrap/windows-48/Files.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin tspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-48/Files.h b/bootstrap/windows-48/Files.h index 80684752..3e6db0f2 100644 --- a/bootstrap/windows-48/Files.h +++ b/bootstrap/windows-48/Files.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin tspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/windows-48/Heap.c b/bootstrap/windows-48/Heap.c index b7c8c827..905fcb24 100644 --- a/bootstrap/windows-48/Heap.c +++ b/bootstrap/windows-48/Heap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin tsSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-48/Heap.h b/bootstrap/windows-48/Heap.h index 6ad4813e..3ea975a7 100644 --- a/bootstrap/windows-48/Heap.h +++ b/bootstrap/windows-48/Heap.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin tsSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ #ifndef Heap__h #define Heap__h diff --git a/bootstrap/windows-48/Modules.c b/bootstrap/windows-48/Modules.c index 7704f005..21d62e05 100644 --- a/bootstrap/windows-48/Modules.c +++ b/bootstrap/windows-48/Modules.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-48/Modules.h b/bootstrap/windows-48/Modules.h index 060208c6..d2d0a476 100644 --- a/bootstrap/windows-48/Modules.h +++ b/bootstrap/windows-48/Modules.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Modules__h #define Modules__h diff --git a/bootstrap/windows-48/OPB.c b/bootstrap/windows-48/OPB.c index e09bf1b4..6c15aa17 100644 --- a/bootstrap/windows-48/OPB.c +++ b/bootstrap/windows-48/OPB.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -10,7 +10,6 @@ #include "OPT.h" -export void (*OPB_typSize)(OPT_Struct); static int16 OPB_exp; static int64 OPB_maxExp; @@ -1917,7 +1916,7 @@ void OPB_StPar0 (OPT_Node *par0, int16 fctno) OPB_err(110); x = OPB_NewIntConst(1); } else if (__IN(f, 0x18fe, 32) || __IN(x->typ->comp, 0x14, 32)) { - (*OPB_typSize)(x->typ); + OPT_TypSize(x->typ); x->typ->pvused = 1; x = OPB_NewIntConst(x->typ->size); } else { diff --git a/bootstrap/windows-48/OPB.h b/bootstrap/windows-48/OPB.h index dc0085af..8395741b 100644 --- a/bootstrap/windows-48/OPB.h +++ b/bootstrap/windows-48/OPB.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPB__h #define OPB__h @@ -8,7 +8,6 @@ #include "OPT.h" -import void (*OPB_typSize)(OPT_Struct); import void OPB_Assign (OPT_Node *x, OPT_Node y); diff --git a/bootstrap/windows-48/OPC.c b/bootstrap/windows-48/OPC.c index 99353400..9104c5c4 100644 --- a/bootstrap/windows-48/OPC.c +++ b/bootstrap/windows-48/OPC.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -17,10 +17,8 @@ static BOOLEAN OPC_GlbPtrs; static CHAR OPC_BodyNameExt[13]; -export void OPC_Align (int32 *adr, int32 base); export void OPC_Andent (OPT_Struct typ); static void OPC_AnsiParamList (OPT_Object obj, BOOLEAN showParamNames); -export int32 OPC_BaseAlignment (OPT_Struct typ); export OPT_Object OPC_BaseTProc (OPT_Object obj); export void OPC_BegBlk (void); export void OPC_BegStat (void); @@ -79,7 +77,6 @@ static void OPC_PutBase (OPT_Struct typ); static void OPC_PutPtrOffsets (OPT_Struct typ, int32 adr, int32 *cnt); static void OPC_RegCmds (OPT_Object obj); export void OPC_SetInclude (BOOLEAN exclude); -export int32 OPC_SizeAlignment (int32 size); static void OPC_Stars (OPT_Struct typ, BOOLEAN *openClause); static void OPC_Str1 (CHAR *s, LONGINT s__len, int32 x); static void OPC_StringLiteral (CHAR *s, LONGINT s__len, int32 l); @@ -750,7 +747,7 @@ static void OPC_CProcDefs (OPT_Object obj, int16 vis) { int16 i; OPT_ConstExt ext = NIL; - int16 _for__9; + int16 _for__7; if (obj != NIL) { OPC_CProcDefs(obj->left, vis); if ((((obj->mode == 9 && (int16)obj->vis >= vis)) && obj->adr == 1)) { @@ -762,9 +759,9 @@ static void OPC_CProcDefs (OPT_Object obj, int16 vis) OPC_DeclareParams(obj->link, 1); OPM_Write(0x09); } - _for__9 = (int16)(*obj->conval->ext)[0]; + _for__7 = (int16)(*obj->conval->ext)[0]; i = i; - while (i <= _for__9) { + while (i <= _for__7) { OPM_Write((*obj->conval->ext)[__X(i, 256)]); i += 1; } @@ -843,64 +840,11 @@ void OPC_InitTDesc (OPT_Struct typ) } } -void OPC_Align (int32 *adr, int32 base) -{ - switch (base) { - case 2: - *adr += __MASK(*adr, -2); - break; - case 4: - *adr += __MASK(-*adr, -4); - break; - case 8: - *adr += __MASK(-*adr, -8); - break; - case 16: - *adr += __MASK(-*adr, -16); - break; - default: - break; - } -} - -int32 OPC_SizeAlignment (int32 size) -{ - int32 _o_result; - int32 alignment; - if (size < OPM_Alignment) { - alignment = 1; - while (alignment < size) { - alignment = __ASHL(alignment, 1); - } - } else { - alignment = OPM_Alignment; - } - _o_result = alignment; - return _o_result; -} - -int32 OPC_BaseAlignment (OPT_Struct typ) -{ - int32 _o_result; - int32 alignment; - if (typ->form == 13) { - 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 (int32 gap, int32 off, int32 align, int32 *n, int32 *curAlign) { int32 adr; adr = off; - OPC_Align(&adr, align); + OPT_Align(&adr, align); if ((*curAlign < align && gap - (adr - off) >= align)) { gap -= (adr - off) + align; OPC_BegStat(); @@ -955,8 +899,8 @@ static void OPC_FieldList (OPT_Struct typ, BOOLEAN last, int32 *off, int32 *n, i } } else { adr = *off; - fldAlign = OPC_BaseAlignment(fld->typ); - OPC_Align(&adr, fldAlign); + fldAlign = OPT_BaseAlignment(fld->typ); + OPT_Align(&adr, fldAlign); gap = fld->adr - adr; if (fldAlign > *curAlign) { *curAlign = fldAlign; @@ -1205,7 +1149,7 @@ static void OPC_GenHeaderMsg (void) OPM_WriteString((CHAR*)"/* ", 4); OPM_WriteString((CHAR*)"voc", 4); OPM_Write(' '); - OPM_WriteString(Configuration_versionLong, 41); + OPM_WriteString(Configuration_versionLong, 75); OPM_Write(' '); i = 0; while (i <= 31) { @@ -1966,84 +1910,84 @@ void OPC_Constant (OPT_Const con, int16 form) } } -static struct InitKeywords__48 { +static struct InitKeywords__46 { int8 *n; - struct InitKeywords__48 *lnk; -} *InitKeywords__48_s; + struct InitKeywords__46 *lnk; +} *InitKeywords__46_s; -static void Enter__49 (CHAR *s, LONGINT s__len); +static void Enter__47 (CHAR *s, LONGINT s__len); -static void Enter__49 (CHAR *s, LONGINT s__len) +static void Enter__47 (CHAR *s, LONGINT s__len) { int16 h; __DUP(s, s__len, CHAR); h = OPC_PerfectHash((void*)s, s__len); - OPC_hashtab[__X(h, 105)] = *InitKeywords__48_s->n; - __COPY(s, OPC_keytab[__X(*InitKeywords__48_s->n, 50)], 9); - *InitKeywords__48_s->n += 1; + OPC_hashtab[__X(h, 105)] = *InitKeywords__46_s->n; + __COPY(s, OPC_keytab[__X(*InitKeywords__46_s->n, 50)], 9); + *InitKeywords__46_s->n += 1; __DEL(s); } static void OPC_InitKeywords (void) { int8 n, i; - struct InitKeywords__48 _s; + struct InitKeywords__46 _s; _s.n = &n; - _s.lnk = InitKeywords__48_s; - InitKeywords__48_s = &_s; + _s.lnk = InitKeywords__46_s; + InitKeywords__46_s = &_s; n = 0; i = 0; while (i <= 104) { OPC_hashtab[__X(i, 105)] = -1; i += 1; } - Enter__49((CHAR*)"address", 8); - Enter__49((CHAR*)"asm", 4); - Enter__49((CHAR*)"auto", 5); - Enter__49((CHAR*)"break", 6); - Enter__49((CHAR*)"case", 5); - Enter__49((CHAR*)"char", 5); - Enter__49((CHAR*)"const", 6); - Enter__49((CHAR*)"continue", 9); - Enter__49((CHAR*)"default", 8); - Enter__49((CHAR*)"do", 3); - Enter__49((CHAR*)"double", 7); - Enter__49((CHAR*)"else", 5); - Enter__49((CHAR*)"enum", 5); - Enter__49((CHAR*)"extern", 7); - Enter__49((CHAR*)"export", 7); - Enter__49((CHAR*)"float", 6); - Enter__49((CHAR*)"for", 4); - Enter__49((CHAR*)"fortran", 8); - Enter__49((CHAR*)"goto", 5); - Enter__49((CHAR*)"if", 3); - Enter__49((CHAR*)"import", 7); - Enter__49((CHAR*)"int", 4); - Enter__49((CHAR*)"int16", 6); - Enter__49((CHAR*)"int32", 6); - Enter__49((CHAR*)"int64", 6); - Enter__49((CHAR*)"int8", 5); - Enter__49((CHAR*)"long", 5); - Enter__49((CHAR*)"register", 9); - Enter__49((CHAR*)"return", 7); - Enter__49((CHAR*)"short", 6); - Enter__49((CHAR*)"signed", 7); - Enter__49((CHAR*)"sizeof", 7); - Enter__49((CHAR*)"size_t", 7); - Enter__49((CHAR*)"static", 7); - Enter__49((CHAR*)"struct", 7); - Enter__49((CHAR*)"switch", 7); - Enter__49((CHAR*)"typedef", 8); - Enter__49((CHAR*)"uint16", 7); - Enter__49((CHAR*)"uint32", 7); - Enter__49((CHAR*)"uint64", 7); - Enter__49((CHAR*)"uint8", 6); - Enter__49((CHAR*)"union", 6); - Enter__49((CHAR*)"unsigned", 9); - Enter__49((CHAR*)"void", 5); - Enter__49((CHAR*)"volatile", 9); - Enter__49((CHAR*)"while", 6); - InitKeywords__48_s = _s.lnk; + Enter__47((CHAR*)"address", 8); + Enter__47((CHAR*)"asm", 4); + Enter__47((CHAR*)"auto", 5); + Enter__47((CHAR*)"break", 6); + Enter__47((CHAR*)"case", 5); + Enter__47((CHAR*)"char", 5); + Enter__47((CHAR*)"const", 6); + Enter__47((CHAR*)"continue", 9); + Enter__47((CHAR*)"default", 8); + Enter__47((CHAR*)"do", 3); + Enter__47((CHAR*)"double", 7); + Enter__47((CHAR*)"else", 5); + Enter__47((CHAR*)"enum", 5); + Enter__47((CHAR*)"extern", 7); + Enter__47((CHAR*)"export", 7); + Enter__47((CHAR*)"float", 6); + Enter__47((CHAR*)"for", 4); + Enter__47((CHAR*)"fortran", 8); + Enter__47((CHAR*)"goto", 5); + Enter__47((CHAR*)"if", 3); + Enter__47((CHAR*)"import", 7); + Enter__47((CHAR*)"int", 4); + Enter__47((CHAR*)"int16", 6); + Enter__47((CHAR*)"int32", 6); + Enter__47((CHAR*)"int64", 6); + Enter__47((CHAR*)"int8", 5); + Enter__47((CHAR*)"long", 5); + Enter__47((CHAR*)"register", 9); + Enter__47((CHAR*)"return", 7); + Enter__47((CHAR*)"short", 6); + Enter__47((CHAR*)"signed", 7); + Enter__47((CHAR*)"sizeof", 7); + Enter__47((CHAR*)"size_t", 7); + Enter__47((CHAR*)"static", 7); + Enter__47((CHAR*)"struct", 7); + Enter__47((CHAR*)"switch", 7); + Enter__47((CHAR*)"typedef", 8); + Enter__47((CHAR*)"uint16", 7); + Enter__47((CHAR*)"uint32", 7); + Enter__47((CHAR*)"uint64", 7); + Enter__47((CHAR*)"uint8", 6); + Enter__47((CHAR*)"union", 6); + Enter__47((CHAR*)"unsigned", 9); + Enter__47((CHAR*)"void", 5); + Enter__47((CHAR*)"volatile", 9); + Enter__47((CHAR*)"while", 6); + InitKeywords__46_s = _s.lnk; } diff --git a/bootstrap/windows-48/OPC.h b/bootstrap/windows-48/OPC.h index 4215947f..6236cd73 100644 --- a/bootstrap/windows-48/OPC.h +++ b/bootstrap/windows-48/OPC.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPC__h #define OPC__h @@ -9,9 +9,7 @@ -import void OPC_Align (int32 *adr, int32 base); import void OPC_Andent (OPT_Struct typ); -import int32 OPC_BaseAlignment (OPT_Struct typ); import OPT_Object OPC_BaseTProc (OPT_Object obj); import void OPC_BegBlk (void); import void OPC_BegStat (void); @@ -41,7 +39,6 @@ import void OPC_IntLiteral (int64 n, int32 size); import void OPC_Len (OPT_Object obj, OPT_Struct array, int64 dim); import int32 OPC_NofPtrs (OPT_Struct typ); import void OPC_SetInclude (BOOLEAN exclude); -import int32 OPC_SizeAlignment (int32 size); import void OPC_TDescDecl (OPT_Struct typ); import void OPC_TypeDefs (OPT_Object obj, int16 vis); import void OPC_TypeOf (OPT_Object ap); diff --git a/bootstrap/windows-48/OPM.c b/bootstrap/windows-48/OPM.c index 8b1f6805..9297c0a3 100644 --- a/bootstrap/windows-48/OPM.c +++ b/bootstrap/windows-48/OPM.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -223,6 +223,7 @@ static void OPM_ScanOptions (CHAR *s, LONGINT s__len, SET *opt) OPM_AddressSize = (int16)s[__X(i + 1, s__len)] - 48; OPM_Alignment = (int16)s[__X(i + 2, s__len)] - 48; i += 2; + Files_SetSearchPath((CHAR*)"", 1); } break; case 'B': @@ -270,7 +271,7 @@ BOOLEAN OPM_OpenPar (void) if (Platform_ArgCount == 1) { OPM_LogWLn(); OPM_LogWStr((CHAR*)"Oberon-2 compiler v", 20); - OPM_LogWStr(Configuration_versionLong, 41); + OPM_LogWStr(Configuration_versionLong, 75); OPM_LogW('.'); OPM_LogWLn(); OPM_LogWStr((CHAR*)"Based on Ofront by Software Templ OEG.", 39); @@ -1118,7 +1119,7 @@ export void *OPM__init(void) Strings_Append((CHAR*)";.;", 4, (void*)OPM_OBERON, 1024); Strings_Append(OPM_MODULES, 1024, (void*)OPM_OBERON, 1024); Strings_Append((CHAR*)";", 2, (void*)OPM_OBERON, 1024); - Strings_Append((CHAR*)"/opt/voc", 9, (void*)OPM_OBERON, 1024); + Strings_Append((CHAR*)"", 1, (void*)OPM_OBERON, 1024); Strings_Append((CHAR*)"/sym;", 6, (void*)OPM_OBERON, 1024); Files_SetSearchPath(OPM_OBERON, 1024); OPM_AddressSize = 4; diff --git a/bootstrap/windows-48/OPM.h b/bootstrap/windows-48/OPM.h index 96af4022..b62666db 100644 --- a/bootstrap/windows-48/OPM.h +++ b/bootstrap/windows-48/OPM.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPM__h #define OPM__h diff --git a/bootstrap/windows-48/OPP.c b/bootstrap/windows-48/OPP.c index a3ab1dd3..66b821d2 100644 --- a/bootstrap/windows-48/OPP.c +++ b/bootstrap/windows-48/OPP.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-48/OPP.h b/bootstrap/windows-48/OPP.h index e5a59f6c..ea6663ba 100644 --- a/bootstrap/windows-48/OPP.h +++ b/bootstrap/windows-48/OPP.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/windows-48/OPS.c b/bootstrap/windows-48/OPS.c index 0cac83bd..2b449cae 100644 --- a/bootstrap/windows-48/OPS.c +++ b/bootstrap/windows-48/OPS.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin tspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-48/OPS.h b/bootstrap/windows-48/OPS.h index caef45f4..8d90d974 100644 --- a/bootstrap/windows-48/OPS.h +++ b/bootstrap/windows-48/OPS.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin tspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/windows-48/OPT.c b/bootstrap/windows-48/OPT.c index c52efac6..1b69128c 100644 --- a/bootstrap/windows-48/OPT.c +++ b/bootstrap/windows-48/OPT.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -87,7 +87,6 @@ typedef } OPT_StrDesc; -export void (*OPT_typSize)(OPT_Struct); export OPT_Object OPT_topScope; export OPT_Struct OPT_undftyp, OPT_bytetyp, OPT_booltyp, OPT_chartyp, OPT_sinttyp, OPT_inttyp, OPT_linttyp, OPT_hinttyp, OPT_adrtyp, OPT_int8typ, OPT_int16typ, OPT_int32typ, OPT_int64typ, OPT_realtyp, OPT_lrltyp, OPT_settyp, OPT_stringtyp, OPT_niltyp, OPT_notyp, OPT_sysptrtyp; export OPT_Object OPT_sintobj, OPT_intobj, OPT_lintobj; @@ -100,6 +99,7 @@ static OPT_ImpCtxt OPT_impCtxt; static OPT_ExpCtxt OPT_expCtxt; static int32 OPT_nofhdfld; static BOOLEAN OPT_newsf, OPT_findpc, OPT_extsf, OPT_sfpresent, OPT_symExtended, OPT_symNew; +static int32 OPT_recno; export address *OPT_ConstDesc__typ; export address *OPT_ObjDesc__typ; @@ -108,6 +108,8 @@ export address *OPT_NodeDesc__typ; export address *OPT_ImpCtxt__typ; export address *OPT_ExpCtxt__typ; +export void OPT_Align (int32 *adr, int32 base); +export int32 OPT_BaseAlignment (OPT_Struct typ); export void OPT_Close (void); export void OPT_CloseScope (void); static void OPT_DebugStruct (OPT_Struct btyp); @@ -136,6 +138,7 @@ static void OPT_InStruct (OPT_Struct *typ); static OPT_Object OPT_InTProc (int8 mno); static OPT_Struct OPT_InTyp (int32 tag); export void OPT_Init (OPS_Name name, SET opt); +export void OPT_InitRecno (void); static void OPT_InitStruct (OPT_Struct *typ, int8 form); export void OPT_Insert (OPS_Name name, OPT_Object *obj); export void OPT_InsertImport (OPT_Object obj, OPT_Object *root, OPT_Object *old); @@ -157,9 +160,16 @@ static void OPT_OutSign (OPT_Struct result, OPT_Object par); static void OPT_OutStr (OPT_Struct typ); static void OPT_OutTProcs (OPT_Struct typ, OPT_Object obj); export OPT_Struct OPT_ShorterOrLongerType (OPT_Struct x, int16 dir); +export int32 OPT_SizeAlignment (int32 size); +export void OPT_TypSize (OPT_Struct typ); static void OPT_err (int16 n); +void OPT_InitRecno (void) +{ + OPT_recno = 0; +} + static void OPT_err (int16 n) { OPM_err(n); @@ -240,6 +250,130 @@ OPT_Struct OPT_ShorterOrLongerType (OPT_Struct x, int16 dir) __RETCHK; } +void OPT_Align (int32 *adr, int32 base) +{ + switch (base) { + case 2: + *adr += __MASK(*adr, -2); + break; + case 4: + *adr += __MASK(-*adr, -4); + break; + case 8: + *adr += __MASK(-*adr, -8); + break; + case 16: + *adr += __MASK(-*adr, -16); + break; + default: + break; + } +} + +int32 OPT_SizeAlignment (int32 size) +{ + int32 _o_result; + int32 alignment; + if (size < OPM_Alignment) { + alignment = 1; + while (alignment < size) { + alignment = __ASHL(alignment, 1); + } + } else { + alignment = OPM_Alignment; + } + _o_result = alignment; + return _o_result; +} + +int32 OPT_BaseAlignment (OPT_Struct typ) +{ + int32 _o_result; + int32 alignment; + if (typ->form == 13) { + if (typ->comp == 4) { + alignment = __MASK(typ->align, -65536); + } else { + alignment = OPT_BaseAlignment(typ->BaseTyp); + } + } else { + alignment = OPT_SizeAlignment(typ->size); + } + _o_result = alignment; + return _o_result; +} + +void OPT_TypSize (OPT_Struct typ) +{ + int16 f, c; + int32 offset, size, base, fbase, off0; + OPT_Object fld = NIL; + OPT_Struct btyp = NIL; + if (typ == OPT_undftyp) { + OPM_err(58); + } else if (typ->size == -1) { + f = typ->form; + c = typ->comp; + if (c == 4) { + btyp = typ->BaseTyp; + if (btyp == NIL) { + offset = 0; + base = 1; + } else { + OPT_TypSize(btyp); + offset = btyp->size - __ASHR(btyp->sysflag, 8); + base = btyp->align; + } + fld = typ->link; + while ((fld != NIL && fld->mode == 4)) { + btyp = fld->typ; + OPT_TypSize(btyp); + size = btyp->size; + fbase = OPT_BaseAlignment(btyp); + OPT_Align(&offset, fbase); + fld->adr = offset; + offset += size; + if (fbase > base) { + base = fbase; + } + fld = fld->link; + } + off0 = offset; + if (offset == 0) { + offset = 1; + } + OPT_Align(&offset, base); + if ((typ->strobj == NIL && __MASK(typ->align, -65536) == 0)) { + OPT_recno += 1; + base += __ASHL(OPT_recno, 16); + } + typ->size = offset; + typ->align = base; + typ->sysflag = __MASK(typ->sysflag, -256) + (int16)__ASHL(offset - off0, 8); + } else if (c == 2) { + OPT_TypSize(typ->BaseTyp); + typ->size = typ->n * typ->BaseTyp->size; + } else if (f == 11) { + typ->size = OPM_AddressSize; + if (typ->BaseTyp == OPT_undftyp) { + OPM_Mark(128, typ->n); + } else { + OPT_TypSize(typ->BaseTyp); + } + } else if (f == 12) { + typ->size = OPM_AddressSize; + } else if (c == 3) { + btyp = typ->BaseTyp; + OPT_TypSize(btyp); + if (btyp->comp == 3) { + typ->size = btyp->size + 4; + } else { + typ->size = 8; + } + } + } +} + OPT_Const OPT_NewConst (void) { OPT_Const _o_result; @@ -552,21 +686,21 @@ void OPT_IdFPrint (OPT_Struct typ) } } -static struct FPrintStr__13 { +static struct FPrintStr__15 { int32 *pbfp, *pvfp; - struct FPrintStr__13 *lnk; -} *FPrintStr__13_s; + struct FPrintStr__15 *lnk; +} *FPrintStr__15_s; -static void FPrintFlds__14 (OPT_Object fld, int32 adr, BOOLEAN visible); -static void FPrintHdFld__16 (OPT_Struct typ, OPT_Object fld, int32 adr); -static void FPrintTProcs__18 (OPT_Object obj); +static void FPrintFlds__16 (OPT_Object fld, int32 adr, BOOLEAN visible); +static void FPrintHdFld__18 (OPT_Struct typ, OPT_Object fld, int32 adr); +static void FPrintTProcs__20 (OPT_Object obj); -static void FPrintHdFld__16 (OPT_Struct typ, OPT_Object fld, int32 adr) +static void FPrintHdFld__18 (OPT_Struct typ, OPT_Object fld, int32 adr) { int32 i, j, n; OPT_Struct btyp = NIL; if (typ->comp == 4) { - FPrintFlds__14(typ->link, adr, 0); + FPrintFlds__16(typ->link, adr, 0); } else if (typ->comp == 2) { btyp = typ->BaseTyp; n = typ->n; @@ -576,53 +710,53 @@ static void FPrintHdFld__16 (OPT_Struct typ, OPT_Object fld, int32 adr) } if (btyp->form == 11 || btyp->comp == 4) { j = OPT_nofhdfld; - FPrintHdFld__16(btyp, fld, adr); + FPrintHdFld__18(btyp, fld, adr); if (j != OPT_nofhdfld) { i = 1; while ((i < n && OPT_nofhdfld <= 2048)) { adr += btyp->size; - FPrintHdFld__16(btyp, fld, adr); + FPrintHdFld__18(btyp, fld, adr); i += 1; } } } } else if (typ->form == 11 || __STRCMP(fld->name, "@ptr") == 0) { - OPM_FPrint(&*FPrintStr__13_s->pvfp, 11); - OPM_FPrint(&*FPrintStr__13_s->pvfp, adr); + OPM_FPrint(&*FPrintStr__15_s->pvfp, 11); + OPM_FPrint(&*FPrintStr__15_s->pvfp, adr); OPT_nofhdfld += 1; } } -static void FPrintFlds__14 (OPT_Object fld, int32 adr, BOOLEAN visible) +static void FPrintFlds__16 (OPT_Object fld, int32 adr, BOOLEAN visible) { while ((fld != NIL && fld->mode == 4)) { if ((fld->vis != 0 && visible)) { - OPM_FPrint(&*FPrintStr__13_s->pbfp, fld->vis); - OPT_FPrintName(&*FPrintStr__13_s->pbfp, (void*)fld->name, 256); - OPM_FPrint(&*FPrintStr__13_s->pbfp, fld->adr); + OPM_FPrint(&*FPrintStr__15_s->pbfp, fld->vis); + OPT_FPrintName(&*FPrintStr__15_s->pbfp, (void*)fld->name, 256); + OPM_FPrint(&*FPrintStr__15_s->pbfp, fld->adr); OPT_FPrintStr(fld->typ); - OPM_FPrint(&*FPrintStr__13_s->pbfp, fld->typ->pbfp); - OPM_FPrint(&*FPrintStr__13_s->pvfp, fld->typ->pvfp); + OPM_FPrint(&*FPrintStr__15_s->pbfp, fld->typ->pbfp); + OPM_FPrint(&*FPrintStr__15_s->pvfp, fld->typ->pvfp); } else { - FPrintHdFld__16(fld->typ, fld, fld->adr + adr); + FPrintHdFld__18(fld->typ, fld, fld->adr + adr); } fld = fld->link; } } -static void FPrintTProcs__18 (OPT_Object obj) +static void FPrintTProcs__20 (OPT_Object obj) { if (obj != NIL) { - FPrintTProcs__18(obj->left); + FPrintTProcs__20(obj->left); if (obj->mode == 13) { if (obj->vis != 0) { - OPM_FPrint(&*FPrintStr__13_s->pbfp, 13); - OPM_FPrint(&*FPrintStr__13_s->pbfp, __ASHR(obj->adr, 16)); - OPT_FPrintSign(&*FPrintStr__13_s->pbfp, obj->typ, obj->link); - OPT_FPrintName(&*FPrintStr__13_s->pbfp, (void*)obj->name, 256); + OPM_FPrint(&*FPrintStr__15_s->pbfp, 13); + OPM_FPrint(&*FPrintStr__15_s->pbfp, __ASHR(obj->adr, 16)); + OPT_FPrintSign(&*FPrintStr__15_s->pbfp, obj->typ, obj->link); + OPT_FPrintName(&*FPrintStr__15_s->pbfp, (void*)obj->name, 256); } } - FPrintTProcs__18(obj->right); + FPrintTProcs__20(obj->right); } } @@ -632,11 +766,11 @@ void OPT_FPrintStr (OPT_Struct typ) OPT_Struct btyp = NIL; OPT_Object strobj = NIL, bstrobj = NIL; int32 pbfp, pvfp; - struct FPrintStr__13 _s; + struct FPrintStr__15 _s; _s.pbfp = &pbfp; _s.pvfp = &pvfp; - _s.lnk = FPrintStr__13_s; - FPrintStr__13_s = &_s; + _s.lnk = FPrintStr__15_s; + FPrintStr__15_s = &_s; if (!typ->fpdone) { OPT_IdFPrint(typ); pbfp = typ->idfp; @@ -673,11 +807,11 @@ void OPT_FPrintStr (OPT_Struct typ) OPM_FPrint(&pvfp, typ->align); OPM_FPrint(&pvfp, typ->n); OPT_nofhdfld = 0; - FPrintFlds__14(typ->link, 0, 1); + FPrintFlds__16(typ->link, 0, 1); if (OPT_nofhdfld > 2048) { OPM_Mark(225, typ->txtpos); } - FPrintTProcs__18(typ->link); + FPrintTProcs__20(typ->link); OPM_FPrint(&pvfp, pbfp); strobj = typ->strobj; if (strobj == NIL || strobj->name[0] == 0x00) { @@ -687,7 +821,7 @@ void OPT_FPrintStr (OPT_Struct typ) typ->pbfp = pbfp; typ->pvfp = pvfp; } - FPrintStr__13_s = _s.lnk; + FPrintStr__15_s = _s.lnk; } void OPT_FPrintObj (OPT_Object obj) @@ -1119,7 +1253,7 @@ static void OPT_InStruct (OPT_Struct *typ) (*typ)->comp = 2; OPT_InStruct(&(*typ)->BaseTyp); (*typ)->n = OPM_SymRInt(); - (*OPT_typSize)(*typ); + OPT_TypSize(*typ); break; case 38: (*typ)->form = 13; @@ -1130,7 +1264,7 @@ static void OPT_InStruct (OPT_Struct *typ) } else { (*typ)->n = 0; } - (*OPT_typSize)(*typ); + OPT_TypSize(*typ); break; case 39: (*typ)->form = 13; @@ -1899,6 +2033,7 @@ export void *OPT__init(void) __REGMOD("OPT", EnumPtrs); __REGCMD("Close", OPT_Close); __REGCMD("CloseScope", OPT_CloseScope); + __REGCMD("InitRecno", OPT_InitRecno); __INITYP(OPT_ConstDesc, OPT_ConstDesc, 0); __INITYP(OPT_ObjDesc, OPT_ObjDesc, 0); __INITYP(OPT_StrDesc, OPT_StrDesc, 0); diff --git a/bootstrap/windows-48/OPT.h b/bootstrap/windows-48/OPT.h index 0bd1f189..1a525fcb 100644 --- a/bootstrap/windows-48/OPT.h +++ b/bootstrap/windows-48/OPT.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPT__h #define OPT__h @@ -66,7 +66,6 @@ typedef } OPT_StrDesc; -import void (*OPT_typSize)(OPT_Struct); import OPT_Object OPT_topScope; import OPT_Struct OPT_undftyp, OPT_bytetyp, OPT_booltyp, OPT_chartyp, OPT_sinttyp, OPT_inttyp, OPT_linttyp, OPT_hinttyp, OPT_adrtyp, OPT_int8typ, OPT_int16typ, OPT_int32typ, OPT_int64typ, OPT_realtyp, OPT_lrltyp, OPT_settyp, OPT_stringtyp, OPT_niltyp, OPT_notyp, OPT_sysptrtyp; import OPT_Object OPT_sintobj, OPT_intobj, OPT_lintobj; @@ -80,6 +79,8 @@ import address *OPT_ObjDesc__typ; import address *OPT_StrDesc__typ; import address *OPT_NodeDesc__typ; +import void OPT_Align (int32 *adr, int32 base); +import int32 OPT_BaseAlignment (OPT_Struct typ); import void OPT_Close (void); import void OPT_CloseScope (void); import void OPT_Export (BOOLEAN *ext, BOOLEAN *new); @@ -92,6 +93,7 @@ import void OPT_FindImport (OPT_Object mod, OPT_Object *res); import void OPT_IdFPrint (OPT_Struct typ); import void OPT_Import (OPS_Name aliasName, OPS_Name name, BOOLEAN *done); import void OPT_Init (OPS_Name name, SET opt); +import void OPT_InitRecno (void); import void OPT_Insert (OPS_Name name, OPT_Object *obj); import void OPT_InsertImport (OPT_Object obj, OPT_Object *root, OPT_Object *old); import int16 OPT_IntSize (int64 n); @@ -103,6 +105,8 @@ import OPT_Object OPT_NewObj (void); import OPT_Struct OPT_NewStr (int8 form, int8 comp); import void OPT_OpenScope (int8 level, OPT_Object owner); import OPT_Struct OPT_ShorterOrLongerType (OPT_Struct x, int16 dir); +import int32 OPT_SizeAlignment (int32 size); +import void OPT_TypSize (OPT_Struct typ); import void *OPT__init(void); diff --git a/bootstrap/windows-48/OPV.c b/bootstrap/windows-48/OPV.c index 8bb5ec32..cdb2ab50 100644 --- a/bootstrap/windows-48/OPV.c +++ b/bootstrap/windows-48/OPV.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -17,7 +17,6 @@ typedef static int16 OPV_stamp; -static int32 OPV_recno; static OPV_ExitInfo OPV_exit; static int16 OPV_nofExitLabels; @@ -46,88 +45,15 @@ static void OPV_Stamp (OPS_Name s); static OPT_Object OPV_SuperProc (OPT_Node n); static void OPV_Traverse (OPT_Object obj, OPT_Object outerScope, BOOLEAN exported); static void OPV_TraverseRecord (OPT_Struct typ); -export void OPV_TypSize (OPT_Struct typ); static void OPV_TypeOf (OPT_Node n); static void OPV_design (OPT_Node n, int16 prec); static void OPV_expr (OPT_Node n, int16 prec); static void OPV_stat (OPT_Node n, OPT_Object outerProc); -void OPV_TypSize (OPT_Struct typ) -{ - int16 f, c; - int32 offset, size, base, fbase, off0; - OPT_Object fld = NIL; - OPT_Struct btyp = NIL; - if (typ == OPT_undftyp) { - OPM_err(58); - } else if (typ->size == -1) { - f = typ->form; - c = typ->comp; - if (c == 4) { - btyp = typ->BaseTyp; - if (btyp == NIL) { - offset = 0; - base = 1; - } else { - OPV_TypSize(btyp); - offset = btyp->size - __ASHR(btyp->sysflag, 8); - base = btyp->align; - } - fld = typ->link; - while ((fld != NIL && fld->mode == 4)) { - btyp = fld->typ; - OPV_TypSize(btyp); - size = btyp->size; - fbase = OPC_BaseAlignment(btyp); - OPC_Align(&offset, fbase); - fld->adr = offset; - offset += size; - if (fbase > base) { - base = fbase; - } - fld = fld->link; - } - off0 = offset; - if (offset == 0) { - offset = 1; - } - OPC_Align(&offset, base); - if ((typ->strobj == NIL && __MASK(typ->align, -65536) == 0)) { - OPV_recno += 1; - base += __ASHL(OPV_recno, 16); - } - typ->size = offset; - typ->align = base; - typ->sysflag = __MASK(typ->sysflag, -256) + (int16)__ASHL(offset - off0, 8); - } else if (c == 2) { - OPV_TypSize(typ->BaseTyp); - typ->size = typ->n * typ->BaseTyp->size; - } else if (f == 11) { - typ->size = OPM_AddressSize; - if (typ->BaseTyp == OPT_undftyp) { - OPM_Mark(128, typ->n); - } else { - OPV_TypSize(typ->BaseTyp); - } - } else if (f == 12) { - typ->size = OPM_AddressSize; - } else if (c == 3) { - btyp = typ->BaseTyp; - OPV_TypSize(btyp); - if (btyp->comp == 3) { - typ->size = btyp->size + 4; - } else { - typ->size = 8; - } - } - } -} - void OPV_Init (void) { OPV_stamp = 0; - OPV_recno = 0; OPV_nofExitLabels = 0; } @@ -212,7 +138,7 @@ static void OPV_Traverse (OPT_Object obj, OPT_Object outerScope, BOOLEAN exporte mode = obj->mode; if ((mode == 5 && (obj->vis != 0) == exported)) { typ = obj->typ; - OPV_TypSize(obj->typ); + OPT_TypSize(obj->typ); if (typ->form == 11) { typ = typ->BaseTyp; } @@ -222,7 +148,7 @@ static void OPV_Traverse (OPT_Object obj, OPT_Object outerScope, BOOLEAN exporte } else if (mode == 13) { OPV_GetTProcNum(obj); } else if (mode == 1) { - OPV_TypSize(obj->typ); + OPT_TypSize(obj->typ); } if (!exported) { if ((__IN(mode, 0x60, 32) && obj->mnolev > 0)) { @@ -548,7 +474,7 @@ static void OPV_design (OPT_Node n, int16 prec) OPT_Struct typ = NIL; int16 class, designPrec, comp; OPT_Node d = NIL, x = NIL; - int16 dims, i, _for__27; + int16 dims, i, _for__26; comp = n->typ->comp; obj = n->obj; class = n->class; @@ -624,9 +550,9 @@ static void OPV_design (OPT_Node n, int16 prec) } x = x->left; } - _for__27 = dims; + _for__26 = dims; i = 1; - while (i <= _for__27) { + while (i <= _for__26) { OPM_Write(')'); i += 1; } @@ -1290,7 +1216,7 @@ static void OPV_NewArr (OPT_Node d, OPT_Node x) OPM_WriteString((CHAR*)", ", 3); OPM_WriteInt(base->size); OPM_WriteString((CHAR*)", ", 3); - OPM_WriteInt(OPC_BaseAlignment(base)); + OPM_WriteInt(OPT_BaseAlignment(base)); OPM_WriteString((CHAR*)", ", 3); OPM_WriteInt(nofdim); OPM_WriteString((CHAR*)", ", 3); diff --git a/bootstrap/windows-48/OPV.h b/bootstrap/windows-48/OPV.h index c309d63c..09931dda 100644 --- a/bootstrap/windows-48/OPV.h +++ b/bootstrap/windows-48/OPV.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPV__h #define OPV__h @@ -12,7 +12,6 @@ import void OPV_AdrAndSize (OPT_Object topScope); import void OPV_Init (void); import void OPV_Module (OPT_Node prog); -import void OPV_TypSize (OPT_Struct typ); import void *OPV__init(void); diff --git a/bootstrap/windows-48/Platform.c b/bootstrap/windows-48/Platform.c index 8aeae1b8..21a73e4d 100644 --- a/bootstrap/windows-48/Platform.c +++ b/bootstrap/windows-48/Platform.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-48/Platform.h b/bootstrap/windows-48/Platform.h index d62dd343..d697acd7 100644 --- a/bootstrap/windows-48/Platform.h +++ b/bootstrap/windows-48/Platform.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/windows-48/Reals.c b/bootstrap/windows-48/Reals.c index fe93e8be..4b72fbe3 100644 --- a/bootstrap/windows-48/Reals.c +++ b/bootstrap/windows-48/Reals.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-48/Reals.h b/bootstrap/windows-48/Reals.h index e7cba0d8..4a4c73b0 100644 --- a/bootstrap/windows-48/Reals.h +++ b/bootstrap/windows-48/Reals.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/windows-48/Strings.c b/bootstrap/windows-48/Strings.c index 427a0cc4..f765b98f 100644 --- a/bootstrap/windows-48/Strings.c +++ b/bootstrap/windows-48/Strings.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-48/Strings.h b/bootstrap/windows-48/Strings.h index 44c51b2a..be1e7d7f 100644 --- a/bootstrap/windows-48/Strings.h +++ b/bootstrap/windows-48/Strings.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/windows-48/Texts.c b/bootstrap/windows-48/Texts.c index 60a7ea7a..779daa7a 100644 --- a/bootstrap/windows-48/Texts.c +++ b/bootstrap/windows-48/Texts.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-48/Texts.h b/bootstrap/windows-48/Texts.h index df86e814..07f53445 100644 --- a/bootstrap/windows-48/Texts.h +++ b/bootstrap/windows-48/Texts.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/windows-48/Vishap.c b/bootstrap/windows-48/Vishap.c index 1ec89e33..30b81ac7 100644 --- a/bootstrap/windows-48/Vishap.c +++ b/bootstrap/windows-48/Vishap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspamSf */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspamSf */ #define INTEGER int16 #define LONGINT int32 @@ -35,6 +35,7 @@ void Vishap_Module (BOOLEAN *done) OPP_Module(&p, OPM_opt); if (OPM_noerr) { OPV_Init(); + OPT_InitRecno(); OPV_AdrAndSize(OPT_topScope); OPT_Export(&ext, &new); if (OPM_noerr) { @@ -165,8 +166,6 @@ export int main(int argc, char **argv) Platform_SetInterruptHandler(Vishap_Trap); Platform_SetQuitHandler(Vishap_Trap); Platform_SetBadInstructionHandler(Vishap_Trap); - OPB_typSize = OPV_TypSize; - OPT_typSize = OPV_TypSize; Vishap_Translate(); __FINI; } diff --git a/bootstrap/windows-48/errors.c b/bootstrap/windows-48/errors.c index 0a40d5e9..d465624d 100644 --- a/bootstrap/windows-48/errors.c +++ b/bootstrap/windows-48/errors.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-48/errors.h b/bootstrap/windows-48/errors.h index 759b613e..cf093ab3 100644 --- a/bootstrap/windows-48/errors.h +++ b/bootstrap/windows-48/errors.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef errors__h #define errors__h diff --git a/bootstrap/windows-48/extTools.c b/bootstrap/windows-48/extTools.c index 8be0b63d..46f8ac7e 100644 --- a/bootstrap/windows-48/extTools.c +++ b/bootstrap/windows-48/extTools.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -89,7 +89,7 @@ void extTools_LinkMain (CHAR *moduleName, LONGINT moduleName__len, BOOLEAN stati Strings_Append((CHAR*)" -o ", 5, (void*)cmd, 1023); Strings_Append(moduleName, moduleName__len, (void*)cmd, 1023); Strings_Append((CHAR*)" -L\"", 5, (void*)cmd, 1023); - Strings_Append((CHAR*)"/opt/voc", 9, (void*)cmd, 1023); + Strings_Append((CHAR*)"", 1, (void*)cmd, 1023); Strings_Append((CHAR*)"/lib\"", 6, (void*)cmd, 1023); Strings_Append((CHAR*)" -l voc", 8, (void*)cmd, 1023); extTools_execute((CHAR*)"Assemble and link: ", 20, cmd, 1023); @@ -108,7 +108,7 @@ export void *extTools__init(void) __REGMOD("extTools", 0); /* BEGIN */ Strings_Append((CHAR*)" -I \"", 6, (void*)extTools_compilationOptions, 1023); - Strings_Append((CHAR*)"/opt/voc", 9, (void*)extTools_compilationOptions, 1023); + Strings_Append((CHAR*)"", 1, (void*)extTools_compilationOptions, 1023); Strings_Append((CHAR*)"/include\" ", 11, (void*)extTools_compilationOptions, 1023); Platform_GetEnv((CHAR*)"CFLAGS", 7, (void*)extTools_CFLAGS, 1023); Strings_Append(extTools_CFLAGS, 1023, (void*)extTools_compilationOptions, 1023); diff --git a/bootstrap/windows-48/extTools.h b/bootstrap/windows-48/extTools.h index bff1c62c..700e6b39 100644 --- a/bootstrap/windows-48/extTools.h +++ b/bootstrap/windows-48/extTools.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef extTools__h #define extTools__h diff --git a/bootstrap/windows-48/vt100.c b/bootstrap/windows-48/vt100.c index 4f6a6c9d..8d4cbdfc 100644 --- a/bootstrap/windows-48/vt100.c +++ b/bootstrap/windows-48/vt100.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-48/vt100.h b/bootstrap/windows-48/vt100.h index 94f8add4..da86e98b 100644 --- a/bootstrap/windows-48/vt100.h +++ b/bootstrap/windows-48/vt100.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef vt100__h #define vt100__h diff --git a/bootstrap/windows-88/Configuration.c b/bootstrap/windows-88/Configuration.c index abdf151b..7f7f4b26 100644 --- a/bootstrap/windows-88/Configuration.c +++ b/bootstrap/windows-88/Configuration.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -7,7 +7,7 @@ #include "SYSTEM.h" -export CHAR Configuration_versionLong[41]; +export CHAR Configuration_versionLong[75]; @@ -18,6 +18,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("1.95 [2016/09/23] for gcc LP64 on cygwin", Configuration_versionLong, 41); + __MOVE("1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); __ENDMOD; } diff --git a/bootstrap/windows-88/Configuration.h b/bootstrap/windows-88/Configuration.h index f51f63f2..618bc77f 100644 --- a/bootstrap/windows-88/Configuration.h +++ b/bootstrap/windows-88/Configuration.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Configuration__h #define Configuration__h @@ -6,7 +6,7 @@ #include "SYSTEM.h" -import CHAR Configuration_versionLong[41]; +import CHAR Configuration_versionLong[75]; import void *Configuration__init(void); diff --git a/bootstrap/windows-88/Console.c b/bootstrap/windows-88/Console.c index 7b492ced..8b55dc14 100644 --- a/bootstrap/windows-88/Console.c +++ b/bootstrap/windows-88/Console.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-88/Console.h b/bootstrap/windows-88/Console.h index b08c93ea..d645f05c 100644 --- a/bootstrap/windows-88/Console.h +++ b/bootstrap/windows-88/Console.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Console__h #define Console__h diff --git a/bootstrap/windows-88/Files.c b/bootstrap/windows-88/Files.c index c30a1491..1071d452 100644 --- a/bootstrap/windows-88/Files.c +++ b/bootstrap/windows-88/Files.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin tspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-88/Files.h b/bootstrap/windows-88/Files.h index 13fccd9a..1a73a6ec 100644 --- a/bootstrap/windows-88/Files.h +++ b/bootstrap/windows-88/Files.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin tspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/windows-88/Heap.c b/bootstrap/windows-88/Heap.c index 16ae9ffd..785efa1a 100644 --- a/bootstrap/windows-88/Heap.c +++ b/bootstrap/windows-88/Heap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin tsSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-88/Heap.h b/bootstrap/windows-88/Heap.h index 151a2d59..cfa2ab6f 100644 --- a/bootstrap/windows-88/Heap.h +++ b/bootstrap/windows-88/Heap.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin tsSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ #ifndef Heap__h #define Heap__h diff --git a/bootstrap/windows-88/Modules.c b/bootstrap/windows-88/Modules.c index f844dfa9..b6890cfe 100644 --- a/bootstrap/windows-88/Modules.c +++ b/bootstrap/windows-88/Modules.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-88/Modules.h b/bootstrap/windows-88/Modules.h index 060208c6..d2d0a476 100644 --- a/bootstrap/windows-88/Modules.h +++ b/bootstrap/windows-88/Modules.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Modules__h #define Modules__h diff --git a/bootstrap/windows-88/OPB.c b/bootstrap/windows-88/OPB.c index e09bf1b4..6c15aa17 100644 --- a/bootstrap/windows-88/OPB.c +++ b/bootstrap/windows-88/OPB.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -10,7 +10,6 @@ #include "OPT.h" -export void (*OPB_typSize)(OPT_Struct); static int16 OPB_exp; static int64 OPB_maxExp; @@ -1917,7 +1916,7 @@ void OPB_StPar0 (OPT_Node *par0, int16 fctno) OPB_err(110); x = OPB_NewIntConst(1); } else if (__IN(f, 0x18fe, 32) || __IN(x->typ->comp, 0x14, 32)) { - (*OPB_typSize)(x->typ); + OPT_TypSize(x->typ); x->typ->pvused = 1; x = OPB_NewIntConst(x->typ->size); } else { diff --git a/bootstrap/windows-88/OPB.h b/bootstrap/windows-88/OPB.h index dc0085af..8395741b 100644 --- a/bootstrap/windows-88/OPB.h +++ b/bootstrap/windows-88/OPB.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPB__h #define OPB__h @@ -8,7 +8,6 @@ #include "OPT.h" -import void (*OPB_typSize)(OPT_Struct); import void OPB_Assign (OPT_Node *x, OPT_Node y); diff --git a/bootstrap/windows-88/OPC.c b/bootstrap/windows-88/OPC.c index 99353400..9104c5c4 100644 --- a/bootstrap/windows-88/OPC.c +++ b/bootstrap/windows-88/OPC.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -17,10 +17,8 @@ static BOOLEAN OPC_GlbPtrs; static CHAR OPC_BodyNameExt[13]; -export void OPC_Align (int32 *adr, int32 base); export void OPC_Andent (OPT_Struct typ); static void OPC_AnsiParamList (OPT_Object obj, BOOLEAN showParamNames); -export int32 OPC_BaseAlignment (OPT_Struct typ); export OPT_Object OPC_BaseTProc (OPT_Object obj); export void OPC_BegBlk (void); export void OPC_BegStat (void); @@ -79,7 +77,6 @@ static void OPC_PutBase (OPT_Struct typ); static void OPC_PutPtrOffsets (OPT_Struct typ, int32 adr, int32 *cnt); static void OPC_RegCmds (OPT_Object obj); export void OPC_SetInclude (BOOLEAN exclude); -export int32 OPC_SizeAlignment (int32 size); static void OPC_Stars (OPT_Struct typ, BOOLEAN *openClause); static void OPC_Str1 (CHAR *s, LONGINT s__len, int32 x); static void OPC_StringLiteral (CHAR *s, LONGINT s__len, int32 l); @@ -750,7 +747,7 @@ static void OPC_CProcDefs (OPT_Object obj, int16 vis) { int16 i; OPT_ConstExt ext = NIL; - int16 _for__9; + int16 _for__7; if (obj != NIL) { OPC_CProcDefs(obj->left, vis); if ((((obj->mode == 9 && (int16)obj->vis >= vis)) && obj->adr == 1)) { @@ -762,9 +759,9 @@ static void OPC_CProcDefs (OPT_Object obj, int16 vis) OPC_DeclareParams(obj->link, 1); OPM_Write(0x09); } - _for__9 = (int16)(*obj->conval->ext)[0]; + _for__7 = (int16)(*obj->conval->ext)[0]; i = i; - while (i <= _for__9) { + while (i <= _for__7) { OPM_Write((*obj->conval->ext)[__X(i, 256)]); i += 1; } @@ -843,64 +840,11 @@ void OPC_InitTDesc (OPT_Struct typ) } } -void OPC_Align (int32 *adr, int32 base) -{ - switch (base) { - case 2: - *adr += __MASK(*adr, -2); - break; - case 4: - *adr += __MASK(-*adr, -4); - break; - case 8: - *adr += __MASK(-*adr, -8); - break; - case 16: - *adr += __MASK(-*adr, -16); - break; - default: - break; - } -} - -int32 OPC_SizeAlignment (int32 size) -{ - int32 _o_result; - int32 alignment; - if (size < OPM_Alignment) { - alignment = 1; - while (alignment < size) { - alignment = __ASHL(alignment, 1); - } - } else { - alignment = OPM_Alignment; - } - _o_result = alignment; - return _o_result; -} - -int32 OPC_BaseAlignment (OPT_Struct typ) -{ - int32 _o_result; - int32 alignment; - if (typ->form == 13) { - 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 (int32 gap, int32 off, int32 align, int32 *n, int32 *curAlign) { int32 adr; adr = off; - OPC_Align(&adr, align); + OPT_Align(&adr, align); if ((*curAlign < align && gap - (adr - off) >= align)) { gap -= (adr - off) + align; OPC_BegStat(); @@ -955,8 +899,8 @@ static void OPC_FieldList (OPT_Struct typ, BOOLEAN last, int32 *off, int32 *n, i } } else { adr = *off; - fldAlign = OPC_BaseAlignment(fld->typ); - OPC_Align(&adr, fldAlign); + fldAlign = OPT_BaseAlignment(fld->typ); + OPT_Align(&adr, fldAlign); gap = fld->adr - adr; if (fldAlign > *curAlign) { *curAlign = fldAlign; @@ -1205,7 +1149,7 @@ static void OPC_GenHeaderMsg (void) OPM_WriteString((CHAR*)"/* ", 4); OPM_WriteString((CHAR*)"voc", 4); OPM_Write(' '); - OPM_WriteString(Configuration_versionLong, 41); + OPM_WriteString(Configuration_versionLong, 75); OPM_Write(' '); i = 0; while (i <= 31) { @@ -1966,84 +1910,84 @@ void OPC_Constant (OPT_Const con, int16 form) } } -static struct InitKeywords__48 { +static struct InitKeywords__46 { int8 *n; - struct InitKeywords__48 *lnk; -} *InitKeywords__48_s; + struct InitKeywords__46 *lnk; +} *InitKeywords__46_s; -static void Enter__49 (CHAR *s, LONGINT s__len); +static void Enter__47 (CHAR *s, LONGINT s__len); -static void Enter__49 (CHAR *s, LONGINT s__len) +static void Enter__47 (CHAR *s, LONGINT s__len) { int16 h; __DUP(s, s__len, CHAR); h = OPC_PerfectHash((void*)s, s__len); - OPC_hashtab[__X(h, 105)] = *InitKeywords__48_s->n; - __COPY(s, OPC_keytab[__X(*InitKeywords__48_s->n, 50)], 9); - *InitKeywords__48_s->n += 1; + OPC_hashtab[__X(h, 105)] = *InitKeywords__46_s->n; + __COPY(s, OPC_keytab[__X(*InitKeywords__46_s->n, 50)], 9); + *InitKeywords__46_s->n += 1; __DEL(s); } static void OPC_InitKeywords (void) { int8 n, i; - struct InitKeywords__48 _s; + struct InitKeywords__46 _s; _s.n = &n; - _s.lnk = InitKeywords__48_s; - InitKeywords__48_s = &_s; + _s.lnk = InitKeywords__46_s; + InitKeywords__46_s = &_s; n = 0; i = 0; while (i <= 104) { OPC_hashtab[__X(i, 105)] = -1; i += 1; } - Enter__49((CHAR*)"address", 8); - Enter__49((CHAR*)"asm", 4); - Enter__49((CHAR*)"auto", 5); - Enter__49((CHAR*)"break", 6); - Enter__49((CHAR*)"case", 5); - Enter__49((CHAR*)"char", 5); - Enter__49((CHAR*)"const", 6); - Enter__49((CHAR*)"continue", 9); - Enter__49((CHAR*)"default", 8); - Enter__49((CHAR*)"do", 3); - Enter__49((CHAR*)"double", 7); - Enter__49((CHAR*)"else", 5); - Enter__49((CHAR*)"enum", 5); - Enter__49((CHAR*)"extern", 7); - Enter__49((CHAR*)"export", 7); - Enter__49((CHAR*)"float", 6); - Enter__49((CHAR*)"for", 4); - Enter__49((CHAR*)"fortran", 8); - Enter__49((CHAR*)"goto", 5); - Enter__49((CHAR*)"if", 3); - Enter__49((CHAR*)"import", 7); - Enter__49((CHAR*)"int", 4); - Enter__49((CHAR*)"int16", 6); - Enter__49((CHAR*)"int32", 6); - Enter__49((CHAR*)"int64", 6); - Enter__49((CHAR*)"int8", 5); - Enter__49((CHAR*)"long", 5); - Enter__49((CHAR*)"register", 9); - Enter__49((CHAR*)"return", 7); - Enter__49((CHAR*)"short", 6); - Enter__49((CHAR*)"signed", 7); - Enter__49((CHAR*)"sizeof", 7); - Enter__49((CHAR*)"size_t", 7); - Enter__49((CHAR*)"static", 7); - Enter__49((CHAR*)"struct", 7); - Enter__49((CHAR*)"switch", 7); - Enter__49((CHAR*)"typedef", 8); - Enter__49((CHAR*)"uint16", 7); - Enter__49((CHAR*)"uint32", 7); - Enter__49((CHAR*)"uint64", 7); - Enter__49((CHAR*)"uint8", 6); - Enter__49((CHAR*)"union", 6); - Enter__49((CHAR*)"unsigned", 9); - Enter__49((CHAR*)"void", 5); - Enter__49((CHAR*)"volatile", 9); - Enter__49((CHAR*)"while", 6); - InitKeywords__48_s = _s.lnk; + Enter__47((CHAR*)"address", 8); + Enter__47((CHAR*)"asm", 4); + Enter__47((CHAR*)"auto", 5); + Enter__47((CHAR*)"break", 6); + Enter__47((CHAR*)"case", 5); + Enter__47((CHAR*)"char", 5); + Enter__47((CHAR*)"const", 6); + Enter__47((CHAR*)"continue", 9); + Enter__47((CHAR*)"default", 8); + Enter__47((CHAR*)"do", 3); + Enter__47((CHAR*)"double", 7); + Enter__47((CHAR*)"else", 5); + Enter__47((CHAR*)"enum", 5); + Enter__47((CHAR*)"extern", 7); + Enter__47((CHAR*)"export", 7); + Enter__47((CHAR*)"float", 6); + Enter__47((CHAR*)"for", 4); + Enter__47((CHAR*)"fortran", 8); + Enter__47((CHAR*)"goto", 5); + Enter__47((CHAR*)"if", 3); + Enter__47((CHAR*)"import", 7); + Enter__47((CHAR*)"int", 4); + Enter__47((CHAR*)"int16", 6); + Enter__47((CHAR*)"int32", 6); + Enter__47((CHAR*)"int64", 6); + Enter__47((CHAR*)"int8", 5); + Enter__47((CHAR*)"long", 5); + Enter__47((CHAR*)"register", 9); + Enter__47((CHAR*)"return", 7); + Enter__47((CHAR*)"short", 6); + Enter__47((CHAR*)"signed", 7); + Enter__47((CHAR*)"sizeof", 7); + Enter__47((CHAR*)"size_t", 7); + Enter__47((CHAR*)"static", 7); + Enter__47((CHAR*)"struct", 7); + Enter__47((CHAR*)"switch", 7); + Enter__47((CHAR*)"typedef", 8); + Enter__47((CHAR*)"uint16", 7); + Enter__47((CHAR*)"uint32", 7); + Enter__47((CHAR*)"uint64", 7); + Enter__47((CHAR*)"uint8", 6); + Enter__47((CHAR*)"union", 6); + Enter__47((CHAR*)"unsigned", 9); + Enter__47((CHAR*)"void", 5); + Enter__47((CHAR*)"volatile", 9); + Enter__47((CHAR*)"while", 6); + InitKeywords__46_s = _s.lnk; } diff --git a/bootstrap/windows-88/OPC.h b/bootstrap/windows-88/OPC.h index 4215947f..6236cd73 100644 --- a/bootstrap/windows-88/OPC.h +++ b/bootstrap/windows-88/OPC.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPC__h #define OPC__h @@ -9,9 +9,7 @@ -import void OPC_Align (int32 *adr, int32 base); import void OPC_Andent (OPT_Struct typ); -import int32 OPC_BaseAlignment (OPT_Struct typ); import OPT_Object OPC_BaseTProc (OPT_Object obj); import void OPC_BegBlk (void); import void OPC_BegStat (void); @@ -41,7 +39,6 @@ import void OPC_IntLiteral (int64 n, int32 size); import void OPC_Len (OPT_Object obj, OPT_Struct array, int64 dim); import int32 OPC_NofPtrs (OPT_Struct typ); import void OPC_SetInclude (BOOLEAN exclude); -import int32 OPC_SizeAlignment (int32 size); import void OPC_TDescDecl (OPT_Struct typ); import void OPC_TypeDefs (OPT_Object obj, int16 vis); import void OPC_TypeOf (OPT_Object ap); diff --git a/bootstrap/windows-88/OPM.c b/bootstrap/windows-88/OPM.c index 931ecb18..7b566324 100644 --- a/bootstrap/windows-88/OPM.c +++ b/bootstrap/windows-88/OPM.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -223,6 +223,7 @@ static void OPM_ScanOptions (CHAR *s, LONGINT s__len, SET *opt) OPM_AddressSize = (int16)s[__X(i + 1, s__len)] - 48; OPM_Alignment = (int16)s[__X(i + 2, s__len)] - 48; i += 2; + Files_SetSearchPath((CHAR*)"", 1); } break; case 'B': @@ -270,7 +271,7 @@ BOOLEAN OPM_OpenPar (void) if (Platform_ArgCount == 1) { OPM_LogWLn(); OPM_LogWStr((CHAR*)"Oberon-2 compiler v", 20); - OPM_LogWStr(Configuration_versionLong, 41); + OPM_LogWStr(Configuration_versionLong, 75); OPM_LogW('.'); OPM_LogWLn(); OPM_LogWStr((CHAR*)"Based on Ofront by Software Templ OEG.", 39); @@ -1118,7 +1119,7 @@ export void *OPM__init(void) Strings_Append((CHAR*)";.;", 4, (void*)OPM_OBERON, 1024); Strings_Append(OPM_MODULES, 1024, (void*)OPM_OBERON, 1024); Strings_Append((CHAR*)";", 2, (void*)OPM_OBERON, 1024); - Strings_Append((CHAR*)"/opt/voc", 9, (void*)OPM_OBERON, 1024); + Strings_Append((CHAR*)"", 1, (void*)OPM_OBERON, 1024); Strings_Append((CHAR*)"/sym;", 6, (void*)OPM_OBERON, 1024); Files_SetSearchPath(OPM_OBERON, 1024); OPM_AddressSize = 8; diff --git a/bootstrap/windows-88/OPM.h b/bootstrap/windows-88/OPM.h index 96af4022..b62666db 100644 --- a/bootstrap/windows-88/OPM.h +++ b/bootstrap/windows-88/OPM.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPM__h #define OPM__h diff --git a/bootstrap/windows-88/OPP.c b/bootstrap/windows-88/OPP.c index 74f93e77..03366726 100644 --- a/bootstrap/windows-88/OPP.c +++ b/bootstrap/windows-88/OPP.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-88/OPP.h b/bootstrap/windows-88/OPP.h index e5a59f6c..ea6663ba 100644 --- a/bootstrap/windows-88/OPP.h +++ b/bootstrap/windows-88/OPP.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/windows-88/OPS.c b/bootstrap/windows-88/OPS.c index 0cac83bd..2b449cae 100644 --- a/bootstrap/windows-88/OPS.c +++ b/bootstrap/windows-88/OPS.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin tspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-88/OPS.h b/bootstrap/windows-88/OPS.h index caef45f4..8d90d974 100644 --- a/bootstrap/windows-88/OPS.h +++ b/bootstrap/windows-88/OPS.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin tspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/windows-88/OPT.c b/bootstrap/windows-88/OPT.c index d40808d2..c9ff5430 100644 --- a/bootstrap/windows-88/OPT.c +++ b/bootstrap/windows-88/OPT.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -87,7 +87,6 @@ typedef } OPT_StrDesc; -export void (*OPT_typSize)(OPT_Struct); export OPT_Object OPT_topScope; export OPT_Struct OPT_undftyp, OPT_bytetyp, OPT_booltyp, OPT_chartyp, OPT_sinttyp, OPT_inttyp, OPT_linttyp, OPT_hinttyp, OPT_adrtyp, OPT_int8typ, OPT_int16typ, OPT_int32typ, OPT_int64typ, OPT_realtyp, OPT_lrltyp, OPT_settyp, OPT_stringtyp, OPT_niltyp, OPT_notyp, OPT_sysptrtyp; export OPT_Object OPT_sintobj, OPT_intobj, OPT_lintobj; @@ -100,6 +99,7 @@ static OPT_ImpCtxt OPT_impCtxt; static OPT_ExpCtxt OPT_expCtxt; static int32 OPT_nofhdfld; static BOOLEAN OPT_newsf, OPT_findpc, OPT_extsf, OPT_sfpresent, OPT_symExtended, OPT_symNew; +static int32 OPT_recno; export address *OPT_ConstDesc__typ; export address *OPT_ObjDesc__typ; @@ -108,6 +108,8 @@ export address *OPT_NodeDesc__typ; export address *OPT_ImpCtxt__typ; export address *OPT_ExpCtxt__typ; +export void OPT_Align (int32 *adr, int32 base); +export int32 OPT_BaseAlignment (OPT_Struct typ); export void OPT_Close (void); export void OPT_CloseScope (void); static void OPT_DebugStruct (OPT_Struct btyp); @@ -136,6 +138,7 @@ static void OPT_InStruct (OPT_Struct *typ); static OPT_Object OPT_InTProc (int8 mno); static OPT_Struct OPT_InTyp (int32 tag); export void OPT_Init (OPS_Name name, SET opt); +export void OPT_InitRecno (void); static void OPT_InitStruct (OPT_Struct *typ, int8 form); export void OPT_Insert (OPS_Name name, OPT_Object *obj); export void OPT_InsertImport (OPT_Object obj, OPT_Object *root, OPT_Object *old); @@ -157,9 +160,16 @@ static void OPT_OutSign (OPT_Struct result, OPT_Object par); static void OPT_OutStr (OPT_Struct typ); static void OPT_OutTProcs (OPT_Struct typ, OPT_Object obj); export OPT_Struct OPT_ShorterOrLongerType (OPT_Struct x, int16 dir); +export int32 OPT_SizeAlignment (int32 size); +export void OPT_TypSize (OPT_Struct typ); static void OPT_err (int16 n); +void OPT_InitRecno (void) +{ + OPT_recno = 0; +} + static void OPT_err (int16 n) { OPM_err(n); @@ -240,6 +250,130 @@ OPT_Struct OPT_ShorterOrLongerType (OPT_Struct x, int16 dir) __RETCHK; } +void OPT_Align (int32 *adr, int32 base) +{ + switch (base) { + case 2: + *adr += __MASK(*adr, -2); + break; + case 4: + *adr += __MASK(-*adr, -4); + break; + case 8: + *adr += __MASK(-*adr, -8); + break; + case 16: + *adr += __MASK(-*adr, -16); + break; + default: + break; + } +} + +int32 OPT_SizeAlignment (int32 size) +{ + int32 _o_result; + int32 alignment; + if (size < OPM_Alignment) { + alignment = 1; + while (alignment < size) { + alignment = __ASHL(alignment, 1); + } + } else { + alignment = OPM_Alignment; + } + _o_result = alignment; + return _o_result; +} + +int32 OPT_BaseAlignment (OPT_Struct typ) +{ + int32 _o_result; + int32 alignment; + if (typ->form == 13) { + if (typ->comp == 4) { + alignment = __MASK(typ->align, -65536); + } else { + alignment = OPT_BaseAlignment(typ->BaseTyp); + } + } else { + alignment = OPT_SizeAlignment(typ->size); + } + _o_result = alignment; + return _o_result; +} + +void OPT_TypSize (OPT_Struct typ) +{ + int16 f, c; + int32 offset, size, base, fbase, off0; + OPT_Object fld = NIL; + OPT_Struct btyp = NIL; + if (typ == OPT_undftyp) { + OPM_err(58); + } else if (typ->size == -1) { + f = typ->form; + c = typ->comp; + if (c == 4) { + btyp = typ->BaseTyp; + if (btyp == NIL) { + offset = 0; + base = 1; + } else { + OPT_TypSize(btyp); + offset = btyp->size - __ASHR(btyp->sysflag, 8); + base = btyp->align; + } + fld = typ->link; + while ((fld != NIL && fld->mode == 4)) { + btyp = fld->typ; + OPT_TypSize(btyp); + size = btyp->size; + fbase = OPT_BaseAlignment(btyp); + OPT_Align(&offset, fbase); + fld->adr = offset; + offset += size; + if (fbase > base) { + base = fbase; + } + fld = fld->link; + } + off0 = offset; + if (offset == 0) { + offset = 1; + } + OPT_Align(&offset, base); + if ((typ->strobj == NIL && __MASK(typ->align, -65536) == 0)) { + OPT_recno += 1; + base += __ASHL(OPT_recno, 16); + } + typ->size = offset; + typ->align = base; + typ->sysflag = __MASK(typ->sysflag, -256) + (int16)__ASHL(offset - off0, 8); + } else if (c == 2) { + OPT_TypSize(typ->BaseTyp); + typ->size = typ->n * typ->BaseTyp->size; + } else if (f == 11) { + typ->size = OPM_AddressSize; + if (typ->BaseTyp == OPT_undftyp) { + OPM_Mark(128, typ->n); + } else { + OPT_TypSize(typ->BaseTyp); + } + } else if (f == 12) { + typ->size = OPM_AddressSize; + } else if (c == 3) { + btyp = typ->BaseTyp; + OPT_TypSize(btyp); + if (btyp->comp == 3) { + typ->size = btyp->size + 4; + } else { + typ->size = 8; + } + } + } +} + OPT_Const OPT_NewConst (void) { OPT_Const _o_result; @@ -552,21 +686,21 @@ void OPT_IdFPrint (OPT_Struct typ) } } -static struct FPrintStr__13 { +static struct FPrintStr__15 { int32 *pbfp, *pvfp; - struct FPrintStr__13 *lnk; -} *FPrintStr__13_s; + struct FPrintStr__15 *lnk; +} *FPrintStr__15_s; -static void FPrintFlds__14 (OPT_Object fld, int32 adr, BOOLEAN visible); -static void FPrintHdFld__16 (OPT_Struct typ, OPT_Object fld, int32 adr); -static void FPrintTProcs__18 (OPT_Object obj); +static void FPrintFlds__16 (OPT_Object fld, int32 adr, BOOLEAN visible); +static void FPrintHdFld__18 (OPT_Struct typ, OPT_Object fld, int32 adr); +static void FPrintTProcs__20 (OPT_Object obj); -static void FPrintHdFld__16 (OPT_Struct typ, OPT_Object fld, int32 adr) +static void FPrintHdFld__18 (OPT_Struct typ, OPT_Object fld, int32 adr) { int32 i, j, n; OPT_Struct btyp = NIL; if (typ->comp == 4) { - FPrintFlds__14(typ->link, adr, 0); + FPrintFlds__16(typ->link, adr, 0); } else if (typ->comp == 2) { btyp = typ->BaseTyp; n = typ->n; @@ -576,53 +710,53 @@ static void FPrintHdFld__16 (OPT_Struct typ, OPT_Object fld, int32 adr) } if (btyp->form == 11 || btyp->comp == 4) { j = OPT_nofhdfld; - FPrintHdFld__16(btyp, fld, adr); + FPrintHdFld__18(btyp, fld, adr); if (j != OPT_nofhdfld) { i = 1; while ((i < n && OPT_nofhdfld <= 2048)) { adr += btyp->size; - FPrintHdFld__16(btyp, fld, adr); + FPrintHdFld__18(btyp, fld, adr); i += 1; } } } } else if (typ->form == 11 || __STRCMP(fld->name, "@ptr") == 0) { - OPM_FPrint(&*FPrintStr__13_s->pvfp, 11); - OPM_FPrint(&*FPrintStr__13_s->pvfp, adr); + OPM_FPrint(&*FPrintStr__15_s->pvfp, 11); + OPM_FPrint(&*FPrintStr__15_s->pvfp, adr); OPT_nofhdfld += 1; } } -static void FPrintFlds__14 (OPT_Object fld, int32 adr, BOOLEAN visible) +static void FPrintFlds__16 (OPT_Object fld, int32 adr, BOOLEAN visible) { while ((fld != NIL && fld->mode == 4)) { if ((fld->vis != 0 && visible)) { - OPM_FPrint(&*FPrintStr__13_s->pbfp, fld->vis); - OPT_FPrintName(&*FPrintStr__13_s->pbfp, (void*)fld->name, 256); - OPM_FPrint(&*FPrintStr__13_s->pbfp, fld->adr); + OPM_FPrint(&*FPrintStr__15_s->pbfp, fld->vis); + OPT_FPrintName(&*FPrintStr__15_s->pbfp, (void*)fld->name, 256); + OPM_FPrint(&*FPrintStr__15_s->pbfp, fld->adr); OPT_FPrintStr(fld->typ); - OPM_FPrint(&*FPrintStr__13_s->pbfp, fld->typ->pbfp); - OPM_FPrint(&*FPrintStr__13_s->pvfp, fld->typ->pvfp); + OPM_FPrint(&*FPrintStr__15_s->pbfp, fld->typ->pbfp); + OPM_FPrint(&*FPrintStr__15_s->pvfp, fld->typ->pvfp); } else { - FPrintHdFld__16(fld->typ, fld, fld->adr + adr); + FPrintHdFld__18(fld->typ, fld, fld->adr + adr); } fld = fld->link; } } -static void FPrintTProcs__18 (OPT_Object obj) +static void FPrintTProcs__20 (OPT_Object obj) { if (obj != NIL) { - FPrintTProcs__18(obj->left); + FPrintTProcs__20(obj->left); if (obj->mode == 13) { if (obj->vis != 0) { - OPM_FPrint(&*FPrintStr__13_s->pbfp, 13); - OPM_FPrint(&*FPrintStr__13_s->pbfp, __ASHR(obj->adr, 16)); - OPT_FPrintSign(&*FPrintStr__13_s->pbfp, obj->typ, obj->link); - OPT_FPrintName(&*FPrintStr__13_s->pbfp, (void*)obj->name, 256); + OPM_FPrint(&*FPrintStr__15_s->pbfp, 13); + OPM_FPrint(&*FPrintStr__15_s->pbfp, __ASHR(obj->adr, 16)); + OPT_FPrintSign(&*FPrintStr__15_s->pbfp, obj->typ, obj->link); + OPT_FPrintName(&*FPrintStr__15_s->pbfp, (void*)obj->name, 256); } } - FPrintTProcs__18(obj->right); + FPrintTProcs__20(obj->right); } } @@ -632,11 +766,11 @@ void OPT_FPrintStr (OPT_Struct typ) OPT_Struct btyp = NIL; OPT_Object strobj = NIL, bstrobj = NIL; int32 pbfp, pvfp; - struct FPrintStr__13 _s; + struct FPrintStr__15 _s; _s.pbfp = &pbfp; _s.pvfp = &pvfp; - _s.lnk = FPrintStr__13_s; - FPrintStr__13_s = &_s; + _s.lnk = FPrintStr__15_s; + FPrintStr__15_s = &_s; if (!typ->fpdone) { OPT_IdFPrint(typ); pbfp = typ->idfp; @@ -673,11 +807,11 @@ void OPT_FPrintStr (OPT_Struct typ) OPM_FPrint(&pvfp, typ->align); OPM_FPrint(&pvfp, typ->n); OPT_nofhdfld = 0; - FPrintFlds__14(typ->link, 0, 1); + FPrintFlds__16(typ->link, 0, 1); if (OPT_nofhdfld > 2048) { OPM_Mark(225, typ->txtpos); } - FPrintTProcs__18(typ->link); + FPrintTProcs__20(typ->link); OPM_FPrint(&pvfp, pbfp); strobj = typ->strobj; if (strobj == NIL || strobj->name[0] == 0x00) { @@ -687,7 +821,7 @@ void OPT_FPrintStr (OPT_Struct typ) typ->pbfp = pbfp; typ->pvfp = pvfp; } - FPrintStr__13_s = _s.lnk; + FPrintStr__15_s = _s.lnk; } void OPT_FPrintObj (OPT_Object obj) @@ -1119,7 +1253,7 @@ static void OPT_InStruct (OPT_Struct *typ) (*typ)->comp = 2; OPT_InStruct(&(*typ)->BaseTyp); (*typ)->n = OPM_SymRInt(); - (*OPT_typSize)(*typ); + OPT_TypSize(*typ); break; case 38: (*typ)->form = 13; @@ -1130,7 +1264,7 @@ static void OPT_InStruct (OPT_Struct *typ) } else { (*typ)->n = 0; } - (*OPT_typSize)(*typ); + OPT_TypSize(*typ); break; case 39: (*typ)->form = 13; @@ -1899,6 +2033,7 @@ export void *OPT__init(void) __REGMOD("OPT", EnumPtrs); __REGCMD("Close", OPT_Close); __REGCMD("CloseScope", OPT_CloseScope); + __REGCMD("InitRecno", OPT_InitRecno); __INITYP(OPT_ConstDesc, OPT_ConstDesc, 0); __INITYP(OPT_ObjDesc, OPT_ObjDesc, 0); __INITYP(OPT_StrDesc, OPT_StrDesc, 0); diff --git a/bootstrap/windows-88/OPT.h b/bootstrap/windows-88/OPT.h index 0bd1f189..1a525fcb 100644 --- a/bootstrap/windows-88/OPT.h +++ b/bootstrap/windows-88/OPT.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPT__h #define OPT__h @@ -66,7 +66,6 @@ typedef } OPT_StrDesc; -import void (*OPT_typSize)(OPT_Struct); import OPT_Object OPT_topScope; import OPT_Struct OPT_undftyp, OPT_bytetyp, OPT_booltyp, OPT_chartyp, OPT_sinttyp, OPT_inttyp, OPT_linttyp, OPT_hinttyp, OPT_adrtyp, OPT_int8typ, OPT_int16typ, OPT_int32typ, OPT_int64typ, OPT_realtyp, OPT_lrltyp, OPT_settyp, OPT_stringtyp, OPT_niltyp, OPT_notyp, OPT_sysptrtyp; import OPT_Object OPT_sintobj, OPT_intobj, OPT_lintobj; @@ -80,6 +79,8 @@ import address *OPT_ObjDesc__typ; import address *OPT_StrDesc__typ; import address *OPT_NodeDesc__typ; +import void OPT_Align (int32 *adr, int32 base); +import int32 OPT_BaseAlignment (OPT_Struct typ); import void OPT_Close (void); import void OPT_CloseScope (void); import void OPT_Export (BOOLEAN *ext, BOOLEAN *new); @@ -92,6 +93,7 @@ import void OPT_FindImport (OPT_Object mod, OPT_Object *res); import void OPT_IdFPrint (OPT_Struct typ); import void OPT_Import (OPS_Name aliasName, OPS_Name name, BOOLEAN *done); import void OPT_Init (OPS_Name name, SET opt); +import void OPT_InitRecno (void); import void OPT_Insert (OPS_Name name, OPT_Object *obj); import void OPT_InsertImport (OPT_Object obj, OPT_Object *root, OPT_Object *old); import int16 OPT_IntSize (int64 n); @@ -103,6 +105,8 @@ import OPT_Object OPT_NewObj (void); import OPT_Struct OPT_NewStr (int8 form, int8 comp); import void OPT_OpenScope (int8 level, OPT_Object owner); import OPT_Struct OPT_ShorterOrLongerType (OPT_Struct x, int16 dir); +import int32 OPT_SizeAlignment (int32 size); +import void OPT_TypSize (OPT_Struct typ); import void *OPT__init(void); diff --git a/bootstrap/windows-88/OPV.c b/bootstrap/windows-88/OPV.c index 8ef2c450..f9e7c27c 100644 --- a/bootstrap/windows-88/OPV.c +++ b/bootstrap/windows-88/OPV.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -17,7 +17,6 @@ typedef static int16 OPV_stamp; -static int32 OPV_recno; static OPV_ExitInfo OPV_exit; static int16 OPV_nofExitLabels; @@ -46,88 +45,15 @@ static void OPV_Stamp (OPS_Name s); static OPT_Object OPV_SuperProc (OPT_Node n); static void OPV_Traverse (OPT_Object obj, OPT_Object outerScope, BOOLEAN exported); static void OPV_TraverseRecord (OPT_Struct typ); -export void OPV_TypSize (OPT_Struct typ); static void OPV_TypeOf (OPT_Node n); static void OPV_design (OPT_Node n, int16 prec); static void OPV_expr (OPT_Node n, int16 prec); static void OPV_stat (OPT_Node n, OPT_Object outerProc); -void OPV_TypSize (OPT_Struct typ) -{ - int16 f, c; - int32 offset, size, base, fbase, off0; - OPT_Object fld = NIL; - OPT_Struct btyp = NIL; - if (typ == OPT_undftyp) { - OPM_err(58); - } else if (typ->size == -1) { - f = typ->form; - c = typ->comp; - if (c == 4) { - btyp = typ->BaseTyp; - if (btyp == NIL) { - offset = 0; - base = 1; - } else { - OPV_TypSize(btyp); - offset = btyp->size - __ASHR(btyp->sysflag, 8); - base = btyp->align; - } - fld = typ->link; - while ((fld != NIL && fld->mode == 4)) { - btyp = fld->typ; - OPV_TypSize(btyp); - size = btyp->size; - fbase = OPC_BaseAlignment(btyp); - OPC_Align(&offset, fbase); - fld->adr = offset; - offset += size; - if (fbase > base) { - base = fbase; - } - fld = fld->link; - } - off0 = offset; - if (offset == 0) { - offset = 1; - } - OPC_Align(&offset, base); - if ((typ->strobj == NIL && __MASK(typ->align, -65536) == 0)) { - OPV_recno += 1; - base += __ASHL(OPV_recno, 16); - } - typ->size = offset; - typ->align = base; - typ->sysflag = __MASK(typ->sysflag, -256) + (int16)__ASHL(offset - off0, 8); - } else if (c == 2) { - OPV_TypSize(typ->BaseTyp); - typ->size = typ->n * typ->BaseTyp->size; - } else if (f == 11) { - typ->size = OPM_AddressSize; - if (typ->BaseTyp == OPT_undftyp) { - OPM_Mark(128, typ->n); - } else { - OPV_TypSize(typ->BaseTyp); - } - } else if (f == 12) { - typ->size = OPM_AddressSize; - } else if (c == 3) { - btyp = typ->BaseTyp; - OPV_TypSize(btyp); - if (btyp->comp == 3) { - typ->size = btyp->size + 4; - } else { - typ->size = 8; - } - } - } -} - void OPV_Init (void) { OPV_stamp = 0; - OPV_recno = 0; OPV_nofExitLabels = 0; } @@ -212,7 +138,7 @@ static void OPV_Traverse (OPT_Object obj, OPT_Object outerScope, BOOLEAN exporte mode = obj->mode; if ((mode == 5 && (obj->vis != 0) == exported)) { typ = obj->typ; - OPV_TypSize(obj->typ); + OPT_TypSize(obj->typ); if (typ->form == 11) { typ = typ->BaseTyp; } @@ -222,7 +148,7 @@ static void OPV_Traverse (OPT_Object obj, OPT_Object outerScope, BOOLEAN exporte } else if (mode == 13) { OPV_GetTProcNum(obj); } else if (mode == 1) { - OPV_TypSize(obj->typ); + OPT_TypSize(obj->typ); } if (!exported) { if ((__IN(mode, 0x60, 32) && obj->mnolev > 0)) { @@ -548,7 +474,7 @@ static void OPV_design (OPT_Node n, int16 prec) OPT_Struct typ = NIL; int16 class, designPrec, comp; OPT_Node d = NIL, x = NIL; - int16 dims, i, _for__27; + int16 dims, i, _for__26; comp = n->typ->comp; obj = n->obj; class = n->class; @@ -624,9 +550,9 @@ static void OPV_design (OPT_Node n, int16 prec) } x = x->left; } - _for__27 = dims; + _for__26 = dims; i = 1; - while (i <= _for__27) { + while (i <= _for__26) { OPM_Write(')'); i += 1; } @@ -1290,7 +1216,7 @@ static void OPV_NewArr (OPT_Node d, OPT_Node x) OPM_WriteString((CHAR*)", ", 3); OPM_WriteInt(base->size); OPM_WriteString((CHAR*)", ", 3); - OPM_WriteInt(OPC_BaseAlignment(base)); + OPM_WriteInt(OPT_BaseAlignment(base)); OPM_WriteString((CHAR*)", ", 3); OPM_WriteInt(nofdim); OPM_WriteString((CHAR*)", ", 3); diff --git a/bootstrap/windows-88/OPV.h b/bootstrap/windows-88/OPV.h index c309d63c..09931dda 100644 --- a/bootstrap/windows-88/OPV.h +++ b/bootstrap/windows-88/OPV.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPV__h #define OPV__h @@ -12,7 +12,6 @@ import void OPV_AdrAndSize (OPT_Object topScope); import void OPV_Init (void); import void OPV_Module (OPT_Node prog); -import void OPV_TypSize (OPT_Struct typ); import void *OPV__init(void); diff --git a/bootstrap/windows-88/Platform.c b/bootstrap/windows-88/Platform.c index 59f9cfeb..8dc2c83e 100644 --- a/bootstrap/windows-88/Platform.c +++ b/bootstrap/windows-88/Platform.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-88/Platform.h b/bootstrap/windows-88/Platform.h index d62dd343..d697acd7 100644 --- a/bootstrap/windows-88/Platform.h +++ b/bootstrap/windows-88/Platform.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/windows-88/Reals.c b/bootstrap/windows-88/Reals.c index fe93e8be..4b72fbe3 100644 --- a/bootstrap/windows-88/Reals.c +++ b/bootstrap/windows-88/Reals.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-88/Reals.h b/bootstrap/windows-88/Reals.h index e7cba0d8..4a4c73b0 100644 --- a/bootstrap/windows-88/Reals.h +++ b/bootstrap/windows-88/Reals.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/windows-88/Strings.c b/bootstrap/windows-88/Strings.c index 427a0cc4..f765b98f 100644 --- a/bootstrap/windows-88/Strings.c +++ b/bootstrap/windows-88/Strings.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-88/Strings.h b/bootstrap/windows-88/Strings.h index 44c51b2a..be1e7d7f 100644 --- a/bootstrap/windows-88/Strings.h +++ b/bootstrap/windows-88/Strings.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/windows-88/Texts.c b/bootstrap/windows-88/Texts.c index 8c41a062..6cb415b9 100644 --- a/bootstrap/windows-88/Texts.c +++ b/bootstrap/windows-88/Texts.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-88/Texts.h b/bootstrap/windows-88/Texts.h index fa080b7f..dc456f77 100644 --- a/bootstrap/windows-88/Texts.h +++ b/bootstrap/windows-88/Texts.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/windows-88/Vishap.c b/bootstrap/windows-88/Vishap.c index 1ec89e33..30b81ac7 100644 --- a/bootstrap/windows-88/Vishap.c +++ b/bootstrap/windows-88/Vishap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspamSf */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspamSf */ #define INTEGER int16 #define LONGINT int32 @@ -35,6 +35,7 @@ void Vishap_Module (BOOLEAN *done) OPP_Module(&p, OPM_opt); if (OPM_noerr) { OPV_Init(); + OPT_InitRecno(); OPV_AdrAndSize(OPT_topScope); OPT_Export(&ext, &new); if (OPM_noerr) { @@ -165,8 +166,6 @@ export int main(int argc, char **argv) Platform_SetInterruptHandler(Vishap_Trap); Platform_SetQuitHandler(Vishap_Trap); Platform_SetBadInstructionHandler(Vishap_Trap); - OPB_typSize = OPV_TypSize; - OPT_typSize = OPV_TypSize; Vishap_Translate(); __FINI; } diff --git a/bootstrap/windows-88/errors.c b/bootstrap/windows-88/errors.c index 0a40d5e9..d465624d 100644 --- a/bootstrap/windows-88/errors.c +++ b/bootstrap/windows-88/errors.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-88/errors.h b/bootstrap/windows-88/errors.h index 759b613e..cf093ab3 100644 --- a/bootstrap/windows-88/errors.h +++ b/bootstrap/windows-88/errors.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef errors__h #define errors__h diff --git a/bootstrap/windows-88/extTools.c b/bootstrap/windows-88/extTools.c index 8be0b63d..46f8ac7e 100644 --- a/bootstrap/windows-88/extTools.c +++ b/bootstrap/windows-88/extTools.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -89,7 +89,7 @@ void extTools_LinkMain (CHAR *moduleName, LONGINT moduleName__len, BOOLEAN stati Strings_Append((CHAR*)" -o ", 5, (void*)cmd, 1023); Strings_Append(moduleName, moduleName__len, (void*)cmd, 1023); Strings_Append((CHAR*)" -L\"", 5, (void*)cmd, 1023); - Strings_Append((CHAR*)"/opt/voc", 9, (void*)cmd, 1023); + Strings_Append((CHAR*)"", 1, (void*)cmd, 1023); Strings_Append((CHAR*)"/lib\"", 6, (void*)cmd, 1023); Strings_Append((CHAR*)" -l voc", 8, (void*)cmd, 1023); extTools_execute((CHAR*)"Assemble and link: ", 20, cmd, 1023); @@ -108,7 +108,7 @@ export void *extTools__init(void) __REGMOD("extTools", 0); /* BEGIN */ Strings_Append((CHAR*)" -I \"", 6, (void*)extTools_compilationOptions, 1023); - Strings_Append((CHAR*)"/opt/voc", 9, (void*)extTools_compilationOptions, 1023); + Strings_Append((CHAR*)"", 1, (void*)extTools_compilationOptions, 1023); Strings_Append((CHAR*)"/include\" ", 11, (void*)extTools_compilationOptions, 1023); Platform_GetEnv((CHAR*)"CFLAGS", 7, (void*)extTools_CFLAGS, 1023); Strings_Append(extTools_CFLAGS, 1023, (void*)extTools_compilationOptions, 1023); diff --git a/bootstrap/windows-88/extTools.h b/bootstrap/windows-88/extTools.h index bff1c62c..700e6b39 100644 --- a/bootstrap/windows-88/extTools.h +++ b/bootstrap/windows-88/extTools.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef extTools__h #define extTools__h diff --git a/bootstrap/windows-88/vt100.c b/bootstrap/windows-88/vt100.c index 4f6a6c9d..8d4cbdfc 100644 --- a/bootstrap/windows-88/vt100.c +++ b/bootstrap/windows-88/vt100.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-88/vt100.h b/bootstrap/windows-88/vt100.h index 94f8add4..da86e98b 100644 --- a/bootstrap/windows-88/vt100.h +++ b/bootstrap/windows-88/vt100.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/23] for gcc LP64 on cygwin xtspaSfF */ +/* voc 1.95 [2016/09/23]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef vt100__h #define vt100__h diff --git a/makefile b/makefile index 491b28f1..c9feb82b 100644 --- a/makefile +++ b/makefile @@ -109,6 +109,14 @@ configuration: FORCE @echo Branch: $$(git rev-parse --abbrev-ref HEAD). +bootstrapconfiguration: FORCE + @$(CC) -I src/system -o a.o src/tools/make/configure.c + @./a.o bootstrap + @rm a.o + @echo BRANCH=$$(git rev-parse --abbrev-ref HEAD)>>Configuration.Make + @echo Branch: $$(git rev-parse --abbrev-ref HEAD). + + reportsizes: FORCE @@ -257,7 +265,7 @@ planned-binary-change: # bootstrap: Rebuild the bootstrap directories # If the bootstrap directories are broken or only partially # built then run 'make revertbootstrap' first. -bootstrap: configuration +bootstrap: bootstrapconfiguration @make -f src/tools/make/vishap.make -s clean @make -f src/tools/make/vishap.make -s translate @make -f src/tools/make/vishap.make -s assemble @@ -270,7 +278,7 @@ bootstrap: configuration cp src/system/*.[ch] bootstrap -bootstrapunclean: +bootstrapunclean: bootstrapconfiguration rm -rf bootstrap/* make -f src/tools/make/vishap.make -s translate MODEL=-O2 INTSIZE=2 ADRSIZE=4 ALIGNMENT=4 PLATFORM=unix BUILDDIR=bootstrap/unix-44 && rm bootstrap/unix-44/*.sym make -f src/tools/make/vishap.make -s translate MODEL=-O2 INTSIZE=2 ADRSIZE=4 ALIGNMENT=8 PLATFORM=unix BUILDDIR=bootstrap/unix-48 && rm bootstrap/unix-48/*.sym diff --git a/src/compiler/OPB.Mod b/src/compiler/OPB.Mod index e1ed3aa0..8382c965 100644 --- a/src/compiler/OPB.Mod +++ b/src/compiler/OPB.Mod @@ -9,7 +9,6 @@ MODULE OPB; (* RC 6.3.89 / 21.2.94 *) (* object model 17.1.93 *) VAR - typSize*: PROCEDURE(typ: OPT.Struct); exp: INTEGER; (* side effect of log*) maxExp: SYSTEM.INT64; (* max n in ASH(1, n) on this machine *) @@ -1037,7 +1036,7 @@ MODULE OPB; (* RC 6.3.89 / 21.2.94 *) (* object model 17.1.93 *) IF x^.class # OPT.Ntype THEN err(110); x := NewIntConst(1) ELSIF (f IN {OPT.Byte..OPT.Set, OPT.Pointer, OPT.ProcTyp}) OR (x^.typ^.comp IN {OPT.Array, OPT.Record}) THEN - typSize(x^.typ); x^.typ^.pvused := TRUE; x := NewIntConst(x^.typ^.size) + OPT.TypSize(x^.typ); x^.typ^.pvused := TRUE; x := NewIntConst(x^.typ^.size) ELSE err(111); x := NewIntConst(1) END |OPT.ccfn: (*SYSTEM.CC*) diff --git a/src/compiler/OPC.Mod b/src/compiler/OPC.Mod index 8059d5fb..456bcf87 100644 --- a/src/compiler/OPC.Mod +++ b/src/compiler/OPC.Mod @@ -553,46 +553,6 @@ MODULE OPC; (* copyright (c) J. Templ 12.7.95 / 3.7.96 *) IF typ^.strobj # NIL THEN InitTProcs(typ^.strobj, typ^.link) END END InitTDesc; - PROCEDURE Align*(VAR adr: LONGINT; base: LONGINT); - BEGIN - CASE base OF - | 2: INC(adr, adr MOD 2) - | 4: INC(adr, (-adr) MOD 4) - | 8: INC(adr, (-adr) MOD 8) - | 16: INC(adr, (-adr) MOD 16) - ELSE (*1*) (*OPM.LogWStr("unhandled case at OPC.Align, base = "); OPM.LogWNum(base, 0); OPM.LogWLn;*) - END - END Align; - - PROCEDURE SizeAlignment*(size: LONGINT): LONGINT; - VAR alignment: LONGINT; - BEGIN - IF size < OPM.Alignment THEN - (* Round up to next power of 2 *) - alignment := 1; WHILE alignment < size DO alignment := alignment * 2 END; - ELSE - alignment := OPM.Alignment - END; - RETURN alignment - END SizeAlignment; - - - PROCEDURE BaseAlignment*(typ: OPT.Struct): LONGINT; - VAR alignment: LONGINT; - BEGIN - IF typ.form = OPT.Comp THEN - IF typ.comp = OPT.Record THEN - alignment := typ.align MOD 10000H - ELSE - alignment := BaseAlignment(typ.BaseTyp) - END - ELSE - alignment := SizeAlignment(typ.size) - END; - RETURN alignment - END BaseAlignment; - - PROCEDURE FillGap(gap, off, align: LONGINT; VAR n, curAlign: LONGINT); (* gap: Required gap - already calculated based on alignment requirements off: Current offset - where gap begins @@ -602,7 +562,7 @@ MODULE OPC; (* copyright (c) J. Templ 12.7.95 / 3.7.96 *) *) VAR adr: LONGINT; BEGIN - adr := off; Align(adr, align); + adr := off; OPT.Align(adr, align); IF (curAlign < align) & (gap - (adr - off) >= align) THEN (* preserve alignment of the enclosing struct! *) DEC(gap, (adr - off) + align); BegStat; @@ -640,8 +600,8 @@ MODULE OPC; (* copyright (c) J. Templ 12.7.95 / 3.7.96 *) ELSE (* mimic OPV.TypSize to detect gaps caused by private fields *) adr := off; - fldAlign := BaseAlignment(fld^.typ); - Align(adr, fldAlign); + fldAlign := OPT.BaseAlignment(fld^.typ); + OPT.Align(adr, fldAlign); gap := fld.adr - adr; IF fldAlign > curAlign THEN curAlign := fldAlign END; IF gap > 0 THEN diff --git a/src/compiler/OPT.Mod b/src/compiler/OPT.Mod index 7648fcec..bd95c80f 100644 --- a/src/compiler/OPT.Mod +++ b/src/compiler/OPT.Mod @@ -149,7 +149,6 @@ CONST FirstRef = Comp + 1; VAR - typSize*: PROCEDURE(typ: Struct); topScope*: Object; undftyp*, @@ -205,10 +204,11 @@ VAR newsf, findpc: BOOLEAN; extsf, sfpresent: BOOLEAN; symExtended, symNew: BOOLEAN; + recno: LONGINT; (* number of anonymous record types *) - +PROCEDURE InitRecno*; BEGIN recno := 0 END InitRecno; PROCEDURE err(n: INTEGER); BEGIN OPM.err(n) END err; @@ -250,6 +250,96 @@ BEGIN END ShorterOrLongerType; +PROCEDURE Align*(VAR adr: LONGINT; base: LONGINT); +BEGIN + CASE base OF + | 2: INC(adr, adr MOD 2) + | 4: INC(adr, (-adr) MOD 4) + | 8: INC(adr, (-adr) MOD 8) + | 16: INC(adr, (-adr) MOD 16) + ELSE (*1*) (*OPM.LogWStr("unhandled case at OPC.Align, base = "); OPM.LogWNum(base, 0); OPM.LogWLn;*) + END +END Align; + +PROCEDURE SizeAlignment*(size: LONGINT): LONGINT; + VAR alignment: LONGINT; +BEGIN + IF size < OPM.Alignment THEN + (* Round up to next power of 2 *) + alignment := 1; WHILE alignment < size DO alignment := alignment * 2 END; + ELSE + alignment := OPM.Alignment + END; + RETURN alignment +END SizeAlignment; + +PROCEDURE BaseAlignment*(typ: Struct): LONGINT; + VAR alignment: LONGINT; +BEGIN + IF typ.form = Comp THEN + IF typ.comp = Record THEN + alignment := typ.align MOD 10000H + ELSE + alignment := BaseAlignment(typ.BaseTyp) + END + ELSE + alignment := SizeAlignment(typ.size) + END; + RETURN alignment +END BaseAlignment; + +PROCEDURE TypSize*(typ: Struct); + VAR + f, c: INTEGER; + offset, size, base, fbase, off0: LONGINT; + fld: Object; btyp: Struct; +BEGIN + IF typ = undftyp THEN OPM.err(58) + ELSIF typ.size = -1 THEN + f := typ.form; + c := typ.comp; + IF c = Record THEN btyp := typ.BaseTyp; + IF btyp = NIL THEN offset := 0; base := 1; + ELSE TypSize(btyp); offset := btyp.size - btyp.sysflag DIV 100H; base := btyp.align; + END; + fld := typ.link; + WHILE (fld # NIL) & (fld.mode = Fld) DO + btyp := fld.typ; TypSize(btyp); + size := btyp.size; + fbase := BaseAlignment(btyp); + Align(offset, fbase); + fld.adr := offset; INC(offset, size); + IF fbase > base THEN base := fbase END; + fld := fld.link + END; + (* base is now the largest alignment of any field *) + off0 := offset; + IF offset = 0 THEN offset := 1 END; (* 1 byte filler to avoid empty struct *) + Align(offset, base); + IF (typ^.strobj = NIL) & (typ^.align MOD 10000H = 0) THEN INC(recno); INC(base, recno * 10000H) END; + typ.size := offset; + typ.align := base; + (* encode the trailing gap into the symbol table to allow dense packing of extended records *) + typ^.sysflag := typ^.sysflag MOD 100H + SHORT((offset - off0)*100H) + ELSIF c = Array THEN + TypSize(typ.BaseTyp); + typ.size := typ.n * typ.BaseTyp.size; + ELSIF f = Pointer THEN + typ.size := OPM.AddressSize; + IF typ.BaseTyp = undftyp THEN OPM.Mark(128, typ.n) + ELSE TypSize(typ.BaseTyp) + END + ELSIF f = ProcTyp THEN + typ.size := OPM.AddressSize; + ELSIF c = DynArr THEN + btyp := typ.BaseTyp; TypSize(btyp); + IF btyp.comp = DynArr THEN typ.size := btyp.size + 4 (* describes dim not size *) + ELSE typ.size := 8 + END + END + END +END TypSize; + PROCEDURE NewConst*(): Const; VAR const: Const; @@ -766,14 +856,14 @@ BEGIN typ^.n := 0; InStruct(typ^.BaseTyp) | Sarr: typ^.form := Comp; typ^.comp := Array; InStruct(typ^.BaseTyp); typ^.n := OPM.SymRInt(); - typSize(typ) (* no bounds address !! *) + TypSize(typ) (* no bounds address !! *) | Sdarr: typ^.form := Comp; typ^.comp := DynArr; InStruct(typ^.BaseTyp); IF typ^.BaseTyp^.comp = DynArr THEN typ^.n := typ^.BaseTyp^.n + 1 ELSE typ^.n := 0 END; - typSize(typ) + TypSize(typ) | Srec: typ^.form := Comp; typ^.comp := Record; InStruct(typ^.BaseTyp); IF typ^.BaseTyp = notyp THEN typ^.BaseTyp := NIL END; diff --git a/src/compiler/OPV.Mod b/src/compiler/OPV.Mod index 04da5f09..dafedf3d 100644 --- a/src/compiler/OPV.Mod +++ b/src/compiler/OPV.Mod @@ -47,62 +47,14 @@ MODULE OPV; (* J. Templ 16.2.95 / 3.7.96 VAR stamp: INTEGER; (* unique number for nested objects *) - recno: LONGINT; (* number of anonymous record types *) exit: ExitInfo; (* to check if EXIT is simply a break *) nofExitLabels: INTEGER; - PROCEDURE TypSize*(typ: OPT.Struct); - VAR f, c: INTEGER; offset, size, base, fbase, off0: LONGINT; - fld: OPT.Object; btyp: OPT.Struct; - BEGIN - IF typ = OPT.undftyp THEN OPM.err(58) - ELSIF typ^.size = -1 THEN - f := typ^.form; c := typ^.comp; - IF c = OPT.Record THEN btyp := typ^.BaseTyp; - IF btyp = NIL THEN offset := 0; base := 1; - ELSE TypSize(btyp); offset := btyp^.size - btyp^.sysflag DIV 100H; base := btyp^.align; - END; - fld := typ^.link; - WHILE (fld # NIL) & (fld^.mode = OPT.Fld) DO - btyp := fld^.typ; TypSize(btyp); - size := btyp^.size; fbase := OPC.BaseAlignment(btyp); - OPC.Align(offset, fbase); - fld^.adr := offset; INC(offset, size); - IF fbase > base THEN base := fbase END ; - fld := fld^.link - END; - (* base is now the largest alignment of any field *) - off0 := offset; - IF offset = 0 THEN offset := 1 END ; (* 1 byte filler to avoid empty struct *) - OPC.Align(offset, base); - IF (typ^.strobj = NIL) & (typ^.align MOD 10000H = 0) THEN INC(recno); INC(base, recno * 10000H) END ; - typ^.size := offset; typ^.align := base; - (* encode the trailing gap into the symbol table to allow dense packing of extended records *) - typ^.sysflag := typ^.sysflag MOD 100H + SHORT((offset - off0)*100H) - ELSIF c = OPT.Array THEN - TypSize(typ^.BaseTyp); - typ^.size := typ^.n * typ^.BaseTyp^.size; - ELSIF f = OPT.Pointer THEN - typ^.size := OPM.AddressSize; - IF typ^.BaseTyp = OPT.undftyp THEN OPM.Mark(128, typ^.n) - ELSE TypSize(typ^.BaseTyp) - END - ELSIF f = OPT.ProcTyp THEN - typ^.size := OPM.AddressSize; - ELSIF c = OPT.DynArr THEN - btyp := typ^.BaseTyp; TypSize(btyp); - IF btyp^.comp = OPT.DynArr THEN typ^.size := btyp^.size + 4 (* describes dim not size *) - ELSE typ^.size := 8 - END - END - END - END TypSize; - PROCEDURE Init*; BEGIN - stamp := 0; recno := 0; nofExitLabels := 0; + stamp := 0; nofExitLabels := 0; END Init; PROCEDURE ^Traverse (obj, outerScope: OPT.Object; exported: BOOLEAN); @@ -150,11 +102,11 @@ MODULE OPV; (* J. Templ 16.2.95 / 3.7.96 obj^.linkadr := UndefinedType; mode := obj^.mode; IF (mode = OPT.Typ) & ((obj^.vis # OPT.internal) = exported) THEN - typ := obj^.typ; TypSize(obj^.typ); + typ := obj^.typ; OPT.TypSize(obj^.typ); IF typ^.form = OPT.Pointer THEN typ := typ^.BaseTyp END ; IF typ^.comp = OPT.Record THEN TraverseRecord(typ) END ELSIF mode = OPT.TProc THEN GetTProcNum(obj) - ELSIF mode = OPT.Var THEN TypSize(obj^.typ) + ELSIF mode = OPT.Var THEN OPT.TypSize(obj^.typ) END ; IF ~exported THEN (* do this only once *) IF (mode IN {OPT.LProc, OPT.Typ}) & (obj^.mnolev > 0) THEN Stamp(obj^.name) END ; @@ -769,7 +721,7 @@ MODULE OPV; (* J. Templ 16.2.95 / 3.7.96 ELSE OPM.WriteString("NIL") END ; OPM.WriteString(", "); OPM.WriteInt(base.size); - OPM.WriteString(", "); OPM.WriteInt(OPC.BaseAlignment(base)); (* element alignment *) + OPM.WriteString(", "); OPM.WriteInt(OPT.BaseAlignment(base)); (* element alignment *) OPM.WriteString(", "); OPM.WriteInt(nofdim); (* total number of dimensions = number of additional parameters *) OPM.WriteString(", "); OPM.WriteInt(nofdyn); (* number of dynamic dimensions *) WHILE typ # base DO diff --git a/src/compiler/Vishap.Mod b/src/compiler/Vishap.Mod index a898c9a4..12dc0a93 100644 --- a/src/compiler/Vishap.Mod +++ b/src/compiler/Vishap.Mod @@ -15,6 +15,7 @@ MODULE Vishap; (* J. Templ 3.2.95 *) OPP.Module(p, OPM.opt); IF OPM.noerr THEN OPV.Init; + OPT.InitRecno; OPV.AdrAndSize(OPT.topScope); OPT.Export(ext, new); IF OPM.noerr THEN @@ -129,7 +130,5 @@ BEGIN Platform.SetInterruptHandler(Trap); Platform.SetQuitHandler(Trap); Platform.SetBadInstructionHandler(Trap); - OPB.typSize := OPV.TypSize; - OPT.typSize := OPV.TypSize; Translate END Vishap. diff --git a/src/tools/make/configure.c b/src/tools/make/configure.c index 936c71bb..3cc542d4 100644 --- a/src/tools/make/configure.c +++ b/src/tools/make/configure.c @@ -69,6 +69,7 @@ int addressSize = 0; int intsize = 0; int bsd = 0; int termux = 0; +int bootstrap = 0; // 1 iff generating a bootstrap compiler. @@ -161,28 +162,32 @@ void determineCCompiler() { void determineInstallDirectory() { - char *env = getenv("INSTALLDIR"); - if (env) { - strncpy(installdir, env, sizeof(installdir)); + if (bootstrap) { + installdir[0] = 0; } else { - #if defined(_MSC_VER) || defined(__MINGW32__) - if (sizeof (void*) == 8) { - snprintf(installdir, sizeof(installdir), "%s\\%s", getenv("ProgramFiles"), oname); - } else { - snprintf(installdir, sizeof(installdir), "%s\\%s", getenv("ProgramFiles(x86)"), oname); - } - #if defined(__MINGW32__) - int i; for(i=0; installdir[i]; i++) if (installdir[i] == '\\') installdir[i] = '/'; + char *env = getenv("INSTALLDIR"); + if (env) { + strncpy(installdir, env, sizeof(installdir)); + } else { + #if defined(_MSC_VER) || defined(__MINGW32__) + if (sizeof (void*) == 8) { + snprintf(installdir, sizeof(installdir), "%s\\%s", getenv("ProgramFiles"), oname); + } else { + snprintf(installdir, sizeof(installdir), "%s\\%s", getenv("ProgramFiles(x86)"), oname); + } + #if defined(__MINGW32__) + int i; for(i=0; installdir[i]; i++) if (installdir[i] == '\\') installdir[i] = '/'; + #endif + #else + if (bsd) { + snprintf(installdir, sizeof(installdir), "/usr/local/share/%s", oname); + } else if (termux) { + snprintf(installdir, sizeof(installdir), "/data/data/com.termux/files/opt/%s", oname); + } else { + snprintf(installdir, sizeof(installdir), "/opt/%s", oname); + } #endif - #else - if (bsd) { - snprintf(installdir, sizeof(installdir), "/usr/local/share/%s", oname); - } else if (termux) { - snprintf(installdir, sizeof(installdir), "/data/data/com.termux/files/opt/%s", oname); - } else { - snprintf(installdir, sizeof(installdir), "/opt/%s", oname); - } - #endif + } } } @@ -431,8 +436,12 @@ int main(int argc, char *argv[]) oname = getenv("ONAME"); if (!oname) oname = macrotostring(O_NAME); if (argc>1) { - ReportSizesAndAlignments(); - exit(0); + if (strncasecmp(argv[1], "rep", 3) == 0) { + ReportSizesAndAlignments(); + exit(0); + } else { + bootstrap = 1; + } } getcwd(cwd, sizeof(cwd)); @@ -447,9 +456,15 @@ int main(int argc, char *argv[]) testSystemDotH(); - snprintf(versionstring, sizeof(versionstring), - "%s [%s] for %s %s on %s", - version, builddate, compiler, dataModel, os); + if (bootstrap) { + snprintf(versionstring, sizeof(versionstring), + "%s [%s]. Bootstrapping compiler for address size %d, alignment %d.", + version, builddate, addressSize, alignment); + } else { + snprintf(versionstring, sizeof(versionstring), + "%s [%s] for %s %s on %s", + version, builddate, compiler, dataModel, os); + } writeConfigurationMod(); writeMakeParameters();