From a9465ccfc6510de08b3daeadd4d5f38ed9d32aae Mon Sep 17 00:00:00 2001 From: Norayr Chilingarian Date: Tue, 24 Jun 2025 18:27:35 +0400 Subject: [PATCH] bootstrap sources. --- bootstrap/SYSTEM.h | 8 +- bootstrap/unix-44/Compiler.c | 2 +- bootstrap/unix-44/Configuration.c | 4 +- bootstrap/unix-44/Configuration.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 | 2 +- bootstrap/unix-44/OPB.h | 2 +- bootstrap/unix-44/OPC.c | 59 ++++++++------- bootstrap/unix-44/OPC.h | 2 +- bootstrap/unix-44/OPM.c | 42 ++++++++++- bootstrap/unix-44/OPM.h | 4 +- bootstrap/unix-44/OPP.c | 2 +- bootstrap/unix-44/OPP.h | 2 +- bootstrap/unix-44/OPS.c | 80 +++++++++++++++----- bootstrap/unix-44/OPS.h | 2 +- bootstrap/unix-44/OPT.c | 107 ++++++++++++++++++++++++++- bootstrap/unix-44/OPT.h | 3 +- bootstrap/unix-44/OPV.c | 2 +- bootstrap/unix-44/OPV.h | 2 +- bootstrap/unix-44/Out.c | 2 +- bootstrap/unix-44/Out.h | 2 +- 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/VT100.c | 2 +- bootstrap/unix-44/VT100.h | 2 +- bootstrap/unix-44/extTools.c | 4 +- bootstrap/unix-44/extTools.h | 2 +- bootstrap/unix-48/Compiler.c | 2 +- bootstrap/unix-48/Configuration.c | 4 +- bootstrap/unix-48/Configuration.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 | 2 +- bootstrap/unix-48/OPB.h | 2 +- bootstrap/unix-48/OPC.c | 59 ++++++++------- bootstrap/unix-48/OPC.h | 2 +- bootstrap/unix-48/OPM.c | 42 ++++++++++- bootstrap/unix-48/OPM.h | 4 +- bootstrap/unix-48/OPP.c | 2 +- bootstrap/unix-48/OPP.h | 2 +- bootstrap/unix-48/OPS.c | 80 +++++++++++++++----- bootstrap/unix-48/OPS.h | 2 +- bootstrap/unix-48/OPT.c | 107 ++++++++++++++++++++++++++- bootstrap/unix-48/OPT.h | 3 +- bootstrap/unix-48/OPV.c | 2 +- bootstrap/unix-48/OPV.h | 2 +- bootstrap/unix-48/Out.c | 2 +- bootstrap/unix-48/Out.h | 2 +- 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/VT100.c | 2 +- bootstrap/unix-48/VT100.h | 2 +- bootstrap/unix-48/extTools.c | 4 +- bootstrap/unix-48/extTools.h | 2 +- bootstrap/unix-88/Compiler.c | 2 +- bootstrap/unix-88/Configuration.c | 4 +- bootstrap/unix-88/Configuration.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 | 2 +- bootstrap/unix-88/OPB.h | 2 +- bootstrap/unix-88/OPC.c | 59 ++++++++------- bootstrap/unix-88/OPC.h | 2 +- bootstrap/unix-88/OPM.c | 42 ++++++++++- bootstrap/unix-88/OPM.h | 4 +- bootstrap/unix-88/OPP.c | 2 +- bootstrap/unix-88/OPP.h | 2 +- bootstrap/unix-88/OPS.c | 80 +++++++++++++++----- bootstrap/unix-88/OPS.h | 2 +- bootstrap/unix-88/OPT.c | 107 ++++++++++++++++++++++++++- bootstrap/unix-88/OPT.h | 3 +- bootstrap/unix-88/OPV.c | 2 +- bootstrap/unix-88/OPV.h | 2 +- bootstrap/unix-88/Out.c | 2 +- bootstrap/unix-88/Out.h | 2 +- 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/VT100.c | 2 +- bootstrap/unix-88/VT100.h | 2 +- bootstrap/unix-88/extTools.c | 4 +- bootstrap/unix-88/extTools.h | 2 +- bootstrap/windows-48/Compiler.c | 2 +- bootstrap/windows-48/Configuration.c | 4 +- bootstrap/windows-48/Configuration.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 | 2 +- bootstrap/windows-48/OPB.h | 2 +- bootstrap/windows-48/OPC.c | 59 ++++++++------- bootstrap/windows-48/OPC.h | 2 +- bootstrap/windows-48/OPM.c | 42 ++++++++++- bootstrap/windows-48/OPM.h | 4 +- bootstrap/windows-48/OPP.c | 2 +- bootstrap/windows-48/OPP.h | 2 +- bootstrap/windows-48/OPS.c | 80 +++++++++++++++----- bootstrap/windows-48/OPS.h | 2 +- bootstrap/windows-48/OPT.c | 107 ++++++++++++++++++++++++++- bootstrap/windows-48/OPT.h | 3 +- bootstrap/windows-48/OPV.c | 2 +- bootstrap/windows-48/OPV.h | 2 +- bootstrap/windows-48/Out.c | 2 +- bootstrap/windows-48/Out.h | 2 +- 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/VT100.c | 2 +- bootstrap/windows-48/VT100.h | 2 +- bootstrap/windows-48/extTools.c | 4 +- bootstrap/windows-48/extTools.h | 2 +- bootstrap/windows-88/Compiler.c | 2 +- bootstrap/windows-88/Configuration.c | 4 +- bootstrap/windows-88/Configuration.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 | 2 +- bootstrap/windows-88/OPB.h | 2 +- bootstrap/windows-88/OPC.c | 59 ++++++++------- bootstrap/windows-88/OPC.h | 2 +- bootstrap/windows-88/OPM.c | 42 ++++++++++- bootstrap/windows-88/OPM.h | 4 +- bootstrap/windows-88/OPP.c | 2 +- bootstrap/windows-88/OPP.h | 2 +- bootstrap/windows-88/OPS.c | 80 +++++++++++++++----- bootstrap/windows-88/OPS.h | 2 +- bootstrap/windows-88/OPT.c | 107 ++++++++++++++++++++++++++- bootstrap/windows-88/OPT.h | 3 +- bootstrap/windows-88/OPV.c | 2 +- bootstrap/windows-88/OPV.h | 2 +- bootstrap/windows-88/Out.c | 2 +- bootstrap/windows-88/Out.h | 2 +- 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/VT100.c | 2 +- bootstrap/windows-88/VT100.h | 2 +- bootstrap/windows-88/extTools.c | 4 +- bootstrap/windows-88/extTools.h | 2 +- src/library/ooc/oocIntStr.Mod | 20 ++--- 187 files changed, 1390 insertions(+), 443 deletions(-) diff --git a/bootstrap/SYSTEM.h b/bootstrap/SYSTEM.h index 2ecdc7f9..39d594ed 100644 --- a/bootstrap/SYSTEM.h +++ b/bootstrap/SYSTEM.h @@ -116,9 +116,11 @@ extern void Modules_AssertFail(INT32 x); // Index checking -static inline INT64 __XF(UINT64 i, UINT64 ub) {if (i >= ub) {__HALT(-2);} return i;} -#define __X(i, ub) (((i)<(ub))?i:(__HALT(-2),0)) - +static inline INT64 __XF(INT64 i, UINT64 ub) { + if (i < 0 || (UINT64)i >= ub) __HALT(-2); + return i; +} +#define __X(i, ub) (((i) >= 0 && (i) < (ub)) ? (i) : (__HALT(-2),0)) // Range checking, and checked SHORT and CHR functions diff --git a/bootstrap/unix-44/Compiler.c b/bootstrap/unix-44/Compiler.c index 1807e545..4460479d 100644 --- a/bootstrap/unix-44/Compiler.c +++ b/bootstrap/unix-44/Compiler.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspamS */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspamS */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/Configuration.c b/bootstrap/unix-44/Configuration.c index fb7a8f35..fa87c9de 100644 --- a/bootstrap/unix-44/Configuration.c +++ b/bootstrap/unix-44/Configuration.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -19,6 +19,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 76); + __MOVE("2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 76); __ENDMOD; } diff --git a/bootstrap/unix-44/Configuration.h b/bootstrap/unix-44/Configuration.h index c8bae246..c3c54eed 100644 --- a/bootstrap/unix-44/Configuration.h +++ b/bootstrap/unix-44/Configuration.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Configuration__h #define Configuration__h diff --git a/bootstrap/unix-44/Files.c b/bootstrap/unix-44/Files.c index 7ce57bc2..54341368 100644 --- a/bootstrap/unix-44/Files.c +++ b/bootstrap/unix-44/Files.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/Files.h b/bootstrap/unix-44/Files.h index 3622bbe7..ccdabcc2 100644 --- a/bootstrap/unix-44/Files.h +++ b/bootstrap/unix-44/Files.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/unix-44/Heap.c b/bootstrap/unix-44/Heap.c index df721094..42552415 100644 --- a/bootstrap/unix-44/Heap.c +++ b/bootstrap/unix-44/Heap.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/Heap.h b/bootstrap/unix-44/Heap.h index dbc11b6f..3cde1c3b 100644 --- a/bootstrap/unix-44/Heap.h +++ b/bootstrap/unix-44/Heap.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ #ifndef Heap__h #define Heap__h diff --git a/bootstrap/unix-44/Modules.c b/bootstrap/unix-44/Modules.c index 00137463..535721e8 100644 --- a/bootstrap/unix-44/Modules.c +++ b/bootstrap/unix-44/Modules.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/Modules.h b/bootstrap/unix-44/Modules.h index 22468d7d..26d86b38 100644 --- a/bootstrap/unix-44/Modules.h +++ b/bootstrap/unix-44/Modules.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Modules__h #define Modules__h diff --git a/bootstrap/unix-44/OPB.c b/bootstrap/unix-44/OPB.c index 4d4925c6..913fbf2d 100644 --- a/bootstrap/unix-44/OPB.c +++ b/bootstrap/unix-44/OPB.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/OPB.h b/bootstrap/unix-44/OPB.h index cb41ad3d..f66fcd66 100644 --- a/bootstrap/unix-44/OPB.h +++ b/bootstrap/unix-44/OPB.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPB__h #define OPB__h diff --git a/bootstrap/unix-44/OPC.c b/bootstrap/unix-44/OPC.c index dc9da7db..7b92ccc1 100644 --- a/bootstrap/unix-44/OPC.c +++ b/bootstrap/unix-44/OPC.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -618,31 +618,33 @@ static void OPC_DefineTProcMacros (OPT_Object obj, BOOLEAN *empty) { if (obj != NIL) { OPC_DefineTProcMacros(obj->left, &*empty); - if ((((obj->mode == 13 && obj == OPC_BaseTProc(obj))) && (OPM_currFile != 0 || obj->vis == 1))) { - OPM_WriteString((CHAR*)"#define __", 11); - OPC_Ident(obj); - OPC_DeclareParams(obj->link, 1); - OPM_WriteString((CHAR*)" __SEND(", 9); - if (obj->link->typ->form == 11) { - OPM_WriteString((CHAR*)"__TYPEOF(", 10); - OPC_Ident(obj->link); + if ((obj->mode == 13 && obj == OPC_BaseTProc(obj))) { + if (OPM_currFile == 1 || (OPM_currFile == 0 && obj->vis == 1)) { + OPM_WriteString((CHAR*)"#define __", 11); + OPC_Ident(obj); + OPC_DeclareParams(obj->link, 1); + OPM_WriteString((CHAR*)" __SEND(", 9); + if (obj->link->typ->form == 11) { + OPM_WriteString((CHAR*)"__TYPEOF(", 10); + OPC_Ident(obj->link); + OPM_Write(')'); + } else { + OPC_Ident(obj->link); + OPM_WriteString((CHAR*)"__typ", 6); + } + OPC_Str1((CHAR*)", #, ", 6, __ASHR(obj->adr, 16)); + if (obj->typ == OPT_notyp) { + OPM_WriteString((CHAR*)"void", 5); + } else { + OPC_Ident(obj->typ->strobj); + } + OPM_WriteString((CHAR*)"(*)", 4); + OPC_AnsiParamList(obj->link, 0); + OPM_WriteString((CHAR*)", ", 3); + OPC_DeclareParams(obj->link, 1); OPM_Write(')'); - } else { - OPC_Ident(obj->link); - OPM_WriteString((CHAR*)"__typ", 6); + OPM_WriteLn(); } - OPC_Str1((CHAR*)", #, ", 6, __ASHR(obj->adr, 16)); - if (obj->typ == OPT_notyp) { - OPM_WriteString((CHAR*)"void", 5); - } else { - OPC_Ident(obj->typ->strobj); - } - OPM_WriteString((CHAR*)"(*)", 4); - OPC_AnsiParamList(obj->link, 0); - OPM_WriteString((CHAR*)", ", 3); - OPC_DeclareParams(obj->link, 1); - OPM_Write(')'); - OPM_WriteLn(); } OPC_DefineTProcMacros(obj->right, &*empty); } @@ -652,7 +654,7 @@ static void OPC_DefineType (OPT_Struct str) { OPT_Object obj = NIL, field = NIL, par = NIL; BOOLEAN empty; - if (OPM_currFile == 1 || str->ref < 255) { + if ((OPM_currFile == 1 || str->ref < 255) || (((OPM_currFile == 0 && str->strobj != NIL)) && str->strobj->vis == 1)) { obj = str->strobj; if (obj == NIL || OPC_Undefined(obj)) { if (obj != NIL) { @@ -719,6 +721,13 @@ static void OPC_DefineType (OPT_Struct str) if (!empty) { OPM_WriteLn(); } + } else if ((obj->typ->form == 11 && obj->typ->BaseTyp->comp == 4)) { + empty = 1; + OPC_DeclareTProcs(obj->typ->BaseTyp->link, &empty); + OPC_DefineTProcMacros(obj->typ->BaseTyp->link, &empty); + if (!empty) { + OPM_WriteLn(); + } } } } diff --git a/bootstrap/unix-44/OPC.h b/bootstrap/unix-44/OPC.h index fd7ddb5e..3bfd88b8 100644 --- a/bootstrap/unix-44/OPC.h +++ b/bootstrap/unix-44/OPC.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPC__h #define OPC__h diff --git a/bootstrap/unix-44/OPM.c b/bootstrap/unix-44/OPM.c index d2462ff6..bcb39247 100644 --- a/bootstrap/unix-44/OPM.c +++ b/bootstrap/unix-44/OPM.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -19,6 +19,8 @@ typedef CHAR OPM_FileName[32]; +static CHAR OPM_currentComment[256]; +static BOOLEAN OPM_hasComment; static CHAR OPM_SourceFileName[256]; static CHAR OPM_GlobalModel[10]; export CHAR OPM_Model[10]; @@ -59,6 +61,7 @@ static void OPM_FindInstallDir (void); static void OPM_FindLine (Files_File f, Files_Rider *r, ADDRESS *r__typ, INT64 pos); static void OPM_FingerprintBytes (INT32 *fp, SYSTEM_BYTE *bytes, ADDRESS bytes__len); export void OPM_Get (CHAR *ch); +export void OPM_GetComment (CHAR *text, ADDRESS text__len); export void OPM_Init (BOOLEAN *done); export void OPM_InitOptions (void); export INT16 OPM_Integer (INT64 n); @@ -82,6 +85,7 @@ static void OPM_ScanOptions (CHAR *s, ADDRESS s__len); static void OPM_ShowLine (INT64 pos); export INT64 OPM_SignedMaximum (INT32 bytecount); export INT64 OPM_SignedMinimum (INT32 bytecount); +export void OPM_StoreComment (CHAR *text, ADDRESS text__len); export void OPM_SymRCh (CHAR *ch); export INT32 OPM_SymRInt (void); export INT64 OPM_SymRInt64 (void); @@ -157,6 +161,36 @@ void OPM_LogCompiling (CHAR *modname, ADDRESS modname__len) __DEL(modname); } +void OPM_StoreComment (CHAR *text, ADDRESS text__len) +{ + INT16 i; + __DUP(text, text__len, CHAR); + i = 0; + while ((i < 255 && text[__X(i, text__len)] != 0x00)) { + OPM_currentComment[__X(i, 256)] = text[__X(i, text__len)]; + i += 1; + } + OPM_currentComment[__X(i, 256)] = 0x00; + OPM_hasComment = 1; + __DEL(text); +} + +void OPM_GetComment (CHAR *text, ADDRESS text__len) +{ + INT16 i; + if (OPM_hasComment) { + i = 0; + while ((((i < text__len && i < 256)) && OPM_currentComment[__X(i, 256)] != 0x00)) { + text[__X(i, text__len)] = OPM_currentComment[__X(i, 256)]; + i += 1; + } + text[__X(i, text__len)] = 0x00; + OPM_hasComment = 0; + } else { + text[0] = 0x00; + } +} + INT64 OPM_SignedMaximum (INT32 bytecount) { INT64 result; @@ -763,7 +797,7 @@ void OPM_OldSym (CHAR *modName, ADDRESS modName__len, BOOLEAN *done) Files_Set(&OPM_oldSF, Files_Rider__typ, OPM_oldSFile, 0); Files_Read(&OPM_oldSF, Files_Rider__typ, (void*)&tag); Files_Read(&OPM_oldSF, Files_Rider__typ, (void*)&ver); - if (tag != 0xf7 || ver != 0x83) { + if (tag != 0xf7 || ver != 0x84) { if (!__IN(4, OPM_Options, 32)) { OPM_err(-306); } @@ -834,7 +868,7 @@ void OPM_NewSym (CHAR *modName, ADDRESS modName__len) if (OPM_newSFile != NIL) { Files_Set(&OPM_newSF, Files_Rider__typ, OPM_newSFile, 0); Files_Write(&OPM_newSF, Files_Rider__typ, 0xf7); - Files_Write(&OPM_newSF, Files_Rider__typ, 0x83); + Files_Write(&OPM_newSF, Files_Rider__typ, 0x84); } else { OPM_err(153); } @@ -1143,5 +1177,7 @@ export void *OPM__init(void) OPM_MinReal = -OPM_MaxReal; OPM_MinLReal = -OPM_MaxLReal; OPM_FindInstallDir(); + OPM_hasComment = 0; + OPM_currentComment[0] = 0x00; __ENDMOD; } diff --git a/bootstrap/unix-44/OPM.h b/bootstrap/unix-44/OPM.h index 14ef9200..64c15a28 100644 --- a/bootstrap/unix-44/OPM.h +++ b/bootstrap/unix-44/OPM.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPM__h #define OPM__h @@ -30,6 +30,7 @@ import void OPM_FPrintLReal (INT32 *fp, LONGREAL val); import void OPM_FPrintReal (INT32 *fp, REAL val); import void OPM_FPrintSet (INT32 *fp, UINT64 val); import void OPM_Get (CHAR *ch); +import void OPM_GetComment (CHAR *text, ADDRESS text__len); import void OPM_Init (BOOLEAN *done); import void OPM_InitOptions (void); import INT16 OPM_Integer (INT64 n); @@ -48,6 +49,7 @@ import BOOLEAN OPM_OpenPar (void); import void OPM_RegisterNewSym (void); import INT64 OPM_SignedMaximum (INT32 bytecount); import INT64 OPM_SignedMinimum (INT32 bytecount); +import void OPM_StoreComment (CHAR *text, ADDRESS text__len); import void OPM_SymRCh (CHAR *ch); import INT32 OPM_SymRInt (void); import INT64 OPM_SymRInt64 (void); diff --git a/bootstrap/unix-44/OPP.c b/bootstrap/unix-44/OPP.c index 2bbed37b..ad4a370a 100644 --- a/bootstrap/unix-44/OPP.c +++ b/bootstrap/unix-44/OPP.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/OPP.h b/bootstrap/unix-44/OPP.h index 5980afc3..3d8cefe8 100644 --- a/bootstrap/unix-44/OPP.h +++ b/bootstrap/unix-44/OPP.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/unix-44/OPS.c b/bootstrap/unix-44/OPS.c index 95456407..a25a2c12 100644 --- a/bootstrap/unix-44/OPS.c +++ b/bootstrap/unix-44/OPS.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -279,32 +279,74 @@ static void Comment__2 (void); static void Comment__2 (void) { + BOOLEAN isExported; + CHAR commentText[256]; + INT16 i, nestLevel; + CHAR prevCh, nextCh; + i = 0; + while (i <= 255) { + commentText[__X(i, 256)] = 0x00; + i += 1; + } + isExported = 0; + i = 0; + nestLevel = 1; + prevCh = 0x00; OPM_Get(&OPS_ch); - for (;;) { - for (;;) { - while (OPS_ch == '(') { + if (OPS_ch == '*') { + isExported = 1; + OPM_Get(&OPS_ch); + if (OPS_ch == ')') { + commentText[0] = 0x00; + OPM_StoreComment(commentText, 256); + OPM_Get(&OPS_ch); + return; + } + } + while ((nestLevel > 0 && OPS_ch != 0x00)) { + if ((prevCh == '(' && OPS_ch == '*')) { + nestLevel += 1; + prevCh = 0x00; + } else if ((prevCh == '*' && OPS_ch == ')')) { + nestLevel -= 1; + if (nestLevel == 0) { OPM_Get(&OPS_ch); - if (OPS_ch == '*') { - Comment__2(); + } else { + prevCh = 0x00; + } + } else { + if ((((isExported && nestLevel == 1)) && prevCh != 0x00)) { + if (i < 255) { + commentText[__X(i, 256)] = prevCh; + i += 1; } } - if (OPS_ch == '*') { - OPM_Get(&OPS_ch); - break; - } - if (OPS_ch == 0x00) { - break; - } + prevCh = OPS_ch; + } + if (nestLevel > 0) { OPM_Get(&OPS_ch); } - if (OPS_ch == ')') { - OPM_Get(&OPS_ch); - break; + } + if (OPS_ch == 0x00) { + OPS_err(5); + } + if ((((((isExported && nestLevel == 0)) && prevCh != 0x00)) && prevCh != '*')) { + if (i < 255) { + commentText[__X(i, 256)] = prevCh; + i += 1; + } else { + OPM_LogWStr((CHAR*)"Truncating final comment character", 35); + OPM_LogWLn(); } - if (OPS_ch == 0x00) { - OPS_err(5); - break; + } + if (isExported) { + if (i >= 256) { + OPM_LogWStr((CHAR*)"Warning: commentText overflow", 30); + OPM_LogWLn(); + i = 255; } + commentText[__X(i, 256)] = 0x00; + OPM_StoreComment(commentText, 256); } } diff --git a/bootstrap/unix-44/OPS.h b/bootstrap/unix-44/OPS.h index f4851b8a..19e222ac 100644 --- a/bootstrap/unix-44/OPS.h +++ b/bootstrap/unix-44/OPS.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/unix-44/OPT.c b/bootstrap/unix-44/OPT.c index 9e34302b..72261b24 100644 --- a/bootstrap/unix-44/OPT.c +++ b/bootstrap/unix-44/OPT.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -83,6 +83,7 @@ typedef OPT_Const conval; INT32 adr, linkadr; INT16 x; + OPT_ConstExt comment; } OPT_ObjDesc; typedef @@ -173,6 +174,7 @@ static void OPT_OutObj (OPT_Object obj); 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); +static void OPT_OutTruncatedName (CHAR *text, ADDRESS text__len); export OPT_Struct OPT_SetType (INT32 size); export OPT_Struct OPT_ShorterOrLongerType (OPT_Struct x, INT16 dir); export INT32 OPT_SizeAlignment (INT32 size); @@ -388,6 +390,10 @@ OPT_Object OPT_NewObj (void) { OPT_Object obj = NIL; __NEW(obj, OPT_ObjDesc); + obj->typ = NIL; + obj->conval = NIL; + obj->comment = NIL; + obj->name[0] = 0x00; return obj; } @@ -554,6 +560,8 @@ void OPT_Insert (OPS_Name name, OPT_Object *obj) OPT_Object ob0 = NIL, ob1 = NIL; BOOLEAN left; INT8 mnolev; + CHAR commentText[256]; + INT16 j; ob0 = OPT_topScope; ob1 = ob0->right; left = 0; @@ -585,6 +593,16 @@ void OPT_Insert (OPS_Name name, OPT_Object *obj) __COPY(name, ob1->name, 256); mnolev = OPT_topScope->mnolev; ob1->mnolev = mnolev; + OPM_GetComment((void*)commentText, 256); + if (commentText[0] != 0x00) { + ob1->comment = __NEWARR(NIL, 1, 1, 1, 0, 256); + j = 0; + while ((j < 255 && commentText[__X(j, 256)] != 0x00)) { + (*ob1->comment)[__X(j, 256)] = commentText[__X(j, 256)]; + j += 1; + } + (*ob1->comment)[__X(j, 256)] = 0x00; + } break; } } @@ -1103,6 +1121,13 @@ static void OPT_InSign (INT8 mno, OPT_Struct *res, OPT_Object *par) tag = OPM_SymRInt(); last = NIL; while (tag != 18) { + if (tag < 0 || tag > 100) { + OPM_LogWStr((CHAR*)"ERROR: Invalid tag value in InSign: ", 37); + OPM_LogWNum(tag, 0); + OPM_LogWLn(); + OPM_err(155); + return; + } new = OPT_NewObj(); new->mnolev = -mno; if (last == NIL) { @@ -1381,7 +1406,37 @@ static OPT_Object OPT_InObj (INT8 mno) OPT_Struct typ = NIL; INT32 tag; OPT_ConstExt ext = NIL; + OPS_Name commentText; + BOOLEAN hasComment; + INT16 j; + INT32 len; tag = OPT_impCtxt.nextTag; + hasComment = 0; + while (tag == 41) { + len = OPM_SymRInt(); + if (len < 0) { + len = 0; + } + if (len > 255) { + len = 255; + } + i = 0; + while (i < len) { + OPM_SymRCh(&commentText[__X(i, 256)]); + i += 1; + } + commentText[__X(i, 256)] = 0x00; + hasComment = 1; + tag = OPM_SymRInt(); + } + OPT_impCtxt.nextTag = tag; + if (tag < 0 || tag > 50) { + OPM_LogWStr((CHAR*)"ERROR: Invalid tag in InObj: ", 30); + OPM_LogWNum(tag, 0); + OPM_LogWLn(); + OPM_err(155); + return NIL; + } if (tag == 19) { OPT_InStruct(&typ); obj = typ->strobj; @@ -1397,7 +1452,7 @@ static OPT_Object OPT_InObj (INT8 mno) obj->conval = OPT_NewConst(); OPT_InConstant(tag, obj->conval); obj->typ = OPT_InTyp(tag); - } else if (tag >= 31) { + } else if ((tag >= 31 && tag <= 33)) { obj->conval = OPT_NewConst(); obj->conval->intval = -1; OPT_InSign(mno, &obj->typ, &obj->link); @@ -1424,20 +1479,37 @@ static OPT_Object OPT_InObj (INT8 mno) OPM_LogWStr((CHAR*)"unhandled case at InObj, tag = ", 32); OPM_LogWNum(tag, 0); OPM_LogWLn(); + OPM_err(155); + return NIL; break; } } else if (tag == 20) { obj->mode = 5; OPT_InStruct(&obj->typ); - } else { + } else if (tag == 21 || tag == 22) { obj->mode = 1; if (tag == 22) { obj->vis = 2; } OPT_InStruct(&obj->typ); + } else { + OPM_LogWStr((CHAR*)"ERROR: Unexpected tag in InObj: ", 33); + OPM_LogWNum(tag, 0); + OPM_LogWLn(); + OPM_err(155); + return NIL; } OPT_InName((void*)obj->name, 256); } + if ((hasComment && obj != NIL)) { + obj->comment = __NEWARR(NIL, 1, 1, 1, 0, 256); + j = 0; + while ((((j < 255 && j < len)) && commentText[__X(j, 256)] != 0x00)) { + (*obj->comment)[__X(j, 256)] = commentText[__X(j, 256)]; + j += 1; + } + (*obj->comment)[__X(j, 256)] = 0x00; + } OPT_FPrintObj(obj); if ((obj->mode == 1 && (obj->typ->strobj == NIL || obj->typ->strobj->name[0] == 0x00))) { OPM_FPrint(&OPT_impCtxt.reffp, obj->typ->ref - 255); @@ -1780,13 +1852,40 @@ static void OPT_OutConstant (OPT_Object obj) } } +static void OPT_OutTruncatedName (CHAR *text, ADDRESS text__len) +{ + INT16 i; + __DUP(text, text__len, CHAR); + i = 0; + while ((i < 255 && text[__X(i, text__len)] != 0x00)) { + OPM_SymWCh(text[__X(i, text__len)]); + i += 1; + } + OPM_SymWCh(0x00); + __DEL(text); +} + static void OPT_OutObj (OPT_Object obj) { INT16 i, j; OPT_ConstExt ext = NIL; + INT16 k, l; if (obj != NIL) { OPT_OutObj(obj->left); if (__IN(obj->mode, 0x06ea, 32)) { + if (obj->comment != NIL) { + OPM_SymWInt(41); + k = 0; + while ((k < 255 && (*obj->comment)[__X(k, 256)] != 0x00)) { + k += 1; + } + OPM_SymWInt(k); + l = 0; + while (l < k) { + OPM_SymWCh((*obj->comment)[__X(l, 256)]); + l += 1; + } + } if (obj->history == 4) { OPT_FPrintErr(obj, 250); } else if (obj->vis != 0) { @@ -2026,7 +2125,7 @@ static void EnumPtrs(void (*P)(void*)) } __TDESC(OPT_ConstDesc, 1, 1) = {__TDFLDS("ConstDesc", 32), {0, -8}}; -__TDESC(OPT_ObjDesc, 1, 6) = {__TDFLDS("ObjDesc", 304), {0, 4, 8, 12, 284, 288, -28}}; +__TDESC(OPT_ObjDesc, 1, 7) = {__TDFLDS("ObjDesc", 308), {0, 4, 8, 12, 284, 288, 304, -32}}; __TDESC(OPT_StrDesc, 1, 3) = {__TDFLDS("StrDesc", 56), {44, 48, 52, -16}}; __TDESC(OPT_NodeDesc, 1, 6) = {__TDFLDS("NodeDesc", 28), {0, 4, 8, 16, 20, 24, -28}}; __TDESC(OPT_ImpCtxt, 1, 510) = {__TDFLDS("ImpCtxt", 3140), {16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, diff --git a/bootstrap/unix-44/OPT.h b/bootstrap/unix-44/OPT.h index d2f8d9fe..cf456af5 100644 --- a/bootstrap/unix-44/OPT.h +++ b/bootstrap/unix-44/OPT.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPT__h #define OPT__h @@ -61,6 +61,7 @@ typedef OPT_Const conval; INT32 adr, linkadr; INT16 x; + OPT_ConstExt comment; } OPT_ObjDesc; typedef diff --git a/bootstrap/unix-44/OPV.c b/bootstrap/unix-44/OPV.c index ecef063d..0425b2e0 100644 --- a/bootstrap/unix-44/OPV.c +++ b/bootstrap/unix-44/OPV.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/OPV.h b/bootstrap/unix-44/OPV.h index 44652222..fbabd8f4 100644 --- a/bootstrap/unix-44/OPV.h +++ b/bootstrap/unix-44/OPV.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPV__h #define OPV__h diff --git a/bootstrap/unix-44/Out.c b/bootstrap/unix-44/Out.c index d5a45e43..ce936589 100644 --- a/bootstrap/unix-44/Out.c +++ b/bootstrap/unix-44/Out.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/Out.h b/bootstrap/unix-44/Out.h index a008c089..a72547f4 100644 --- a/bootstrap/unix-44/Out.h +++ b/bootstrap/unix-44/Out.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Out__h #define Out__h diff --git a/bootstrap/unix-44/Platform.c b/bootstrap/unix-44/Platform.c index 61463b51..befa6033 100644 --- a/bootstrap/unix-44/Platform.c +++ b/bootstrap/unix-44/Platform.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/Platform.h b/bootstrap/unix-44/Platform.h index 89ce40d3..fbeef8c7 100644 --- a/bootstrap/unix-44/Platform.h +++ b/bootstrap/unix-44/Platform.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/unix-44/Reals.c b/bootstrap/unix-44/Reals.c index f4cc31eb..512ec2c4 100644 --- a/bootstrap/unix-44/Reals.c +++ b/bootstrap/unix-44/Reals.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/Reals.h b/bootstrap/unix-44/Reals.h index 04ff0d7c..93e7fa75 100644 --- a/bootstrap/unix-44/Reals.h +++ b/bootstrap/unix-44/Reals.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/unix-44/Strings.c b/bootstrap/unix-44/Strings.c index 629009fa..4b18812f 100644 --- a/bootstrap/unix-44/Strings.c +++ b/bootstrap/unix-44/Strings.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/Strings.h b/bootstrap/unix-44/Strings.h index 6acdef43..f0e3ae34 100644 --- a/bootstrap/unix-44/Strings.h +++ b/bootstrap/unix-44/Strings.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/unix-44/Texts.c b/bootstrap/unix-44/Texts.c index 369d0244..7e7522c2 100644 --- a/bootstrap/unix-44/Texts.c +++ b/bootstrap/unix-44/Texts.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/Texts.h b/bootstrap/unix-44/Texts.h index 3c805fbe..dc569fa9 100644 --- a/bootstrap/unix-44/Texts.h +++ b/bootstrap/unix-44/Texts.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/unix-44/VT100.c b/bootstrap/unix-44/VT100.c index c5e8a3ba..346fb37b 100644 --- a/bootstrap/unix-44/VT100.c +++ b/bootstrap/unix-44/VT100.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/VT100.h b/bootstrap/unix-44/VT100.h index 94b7b846..4e708647 100644 --- a/bootstrap/unix-44/VT100.h +++ b/bootstrap/unix-44/VT100.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef VT100__h #define VT100__h diff --git a/bootstrap/unix-44/extTools.c b/bootstrap/unix-44/extTools.c index cf90fa2a..ce2fc413 100644 --- a/bootstrap/unix-44/extTools.c +++ b/bootstrap/unix-44/extTools.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -73,7 +73,7 @@ static void extTools_execute (CHAR *title, ADDRESS title__len, CHAR *cmd, ADDRES static void extTools_InitialiseCompilerCommand (CHAR *s, ADDRESS s__len, CHAR *additionalopts, ADDRESS additionalopts__len) { __DUP(additionalopts, additionalopts__len, CHAR); - __COPY("gcc -fPIC -g", s, s__len); + __COPY("gcc -fPIC -g -Wno-stringop-overflow", s, s__len); Strings_Append((CHAR*)" -I \"", 6, (void*)s, s__len); Strings_Append(OPM_ResourceDir, 1024, (void*)s, s__len); Strings_Append((CHAR*)"/include\" ", 11, (void*)s, s__len); diff --git a/bootstrap/unix-44/extTools.h b/bootstrap/unix-44/extTools.h index 6b1b37eb..686f0b4e 100644 --- a/bootstrap/unix-44/extTools.h +++ b/bootstrap/unix-44/extTools.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef extTools__h #define extTools__h diff --git a/bootstrap/unix-48/Compiler.c b/bootstrap/unix-48/Compiler.c index 1807e545..4460479d 100644 --- a/bootstrap/unix-48/Compiler.c +++ b/bootstrap/unix-48/Compiler.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspamS */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspamS */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/Configuration.c b/bootstrap/unix-48/Configuration.c index fb7a8f35..fa87c9de 100644 --- a/bootstrap/unix-48/Configuration.c +++ b/bootstrap/unix-48/Configuration.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -19,6 +19,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 76); + __MOVE("2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 76); __ENDMOD; } diff --git a/bootstrap/unix-48/Configuration.h b/bootstrap/unix-48/Configuration.h index c8bae246..c3c54eed 100644 --- a/bootstrap/unix-48/Configuration.h +++ b/bootstrap/unix-48/Configuration.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Configuration__h #define Configuration__h diff --git a/bootstrap/unix-48/Files.c b/bootstrap/unix-48/Files.c index 7ce57bc2..54341368 100644 --- a/bootstrap/unix-48/Files.c +++ b/bootstrap/unix-48/Files.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/Files.h b/bootstrap/unix-48/Files.h index 3622bbe7..ccdabcc2 100644 --- a/bootstrap/unix-48/Files.h +++ b/bootstrap/unix-48/Files.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/unix-48/Heap.c b/bootstrap/unix-48/Heap.c index df721094..42552415 100644 --- a/bootstrap/unix-48/Heap.c +++ b/bootstrap/unix-48/Heap.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/Heap.h b/bootstrap/unix-48/Heap.h index dbc11b6f..3cde1c3b 100644 --- a/bootstrap/unix-48/Heap.h +++ b/bootstrap/unix-48/Heap.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ #ifndef Heap__h #define Heap__h diff --git a/bootstrap/unix-48/Modules.c b/bootstrap/unix-48/Modules.c index 00137463..535721e8 100644 --- a/bootstrap/unix-48/Modules.c +++ b/bootstrap/unix-48/Modules.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/Modules.h b/bootstrap/unix-48/Modules.h index 22468d7d..26d86b38 100644 --- a/bootstrap/unix-48/Modules.h +++ b/bootstrap/unix-48/Modules.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Modules__h #define Modules__h diff --git a/bootstrap/unix-48/OPB.c b/bootstrap/unix-48/OPB.c index 4d4925c6..913fbf2d 100644 --- a/bootstrap/unix-48/OPB.c +++ b/bootstrap/unix-48/OPB.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/OPB.h b/bootstrap/unix-48/OPB.h index cb41ad3d..f66fcd66 100644 --- a/bootstrap/unix-48/OPB.h +++ b/bootstrap/unix-48/OPB.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPB__h #define OPB__h diff --git a/bootstrap/unix-48/OPC.c b/bootstrap/unix-48/OPC.c index dc9da7db..7b92ccc1 100644 --- a/bootstrap/unix-48/OPC.c +++ b/bootstrap/unix-48/OPC.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -618,31 +618,33 @@ static void OPC_DefineTProcMacros (OPT_Object obj, BOOLEAN *empty) { if (obj != NIL) { OPC_DefineTProcMacros(obj->left, &*empty); - if ((((obj->mode == 13 && obj == OPC_BaseTProc(obj))) && (OPM_currFile != 0 || obj->vis == 1))) { - OPM_WriteString((CHAR*)"#define __", 11); - OPC_Ident(obj); - OPC_DeclareParams(obj->link, 1); - OPM_WriteString((CHAR*)" __SEND(", 9); - if (obj->link->typ->form == 11) { - OPM_WriteString((CHAR*)"__TYPEOF(", 10); - OPC_Ident(obj->link); + if ((obj->mode == 13 && obj == OPC_BaseTProc(obj))) { + if (OPM_currFile == 1 || (OPM_currFile == 0 && obj->vis == 1)) { + OPM_WriteString((CHAR*)"#define __", 11); + OPC_Ident(obj); + OPC_DeclareParams(obj->link, 1); + OPM_WriteString((CHAR*)" __SEND(", 9); + if (obj->link->typ->form == 11) { + OPM_WriteString((CHAR*)"__TYPEOF(", 10); + OPC_Ident(obj->link); + OPM_Write(')'); + } else { + OPC_Ident(obj->link); + OPM_WriteString((CHAR*)"__typ", 6); + } + OPC_Str1((CHAR*)", #, ", 6, __ASHR(obj->adr, 16)); + if (obj->typ == OPT_notyp) { + OPM_WriteString((CHAR*)"void", 5); + } else { + OPC_Ident(obj->typ->strobj); + } + OPM_WriteString((CHAR*)"(*)", 4); + OPC_AnsiParamList(obj->link, 0); + OPM_WriteString((CHAR*)", ", 3); + OPC_DeclareParams(obj->link, 1); OPM_Write(')'); - } else { - OPC_Ident(obj->link); - OPM_WriteString((CHAR*)"__typ", 6); + OPM_WriteLn(); } - OPC_Str1((CHAR*)", #, ", 6, __ASHR(obj->adr, 16)); - if (obj->typ == OPT_notyp) { - OPM_WriteString((CHAR*)"void", 5); - } else { - OPC_Ident(obj->typ->strobj); - } - OPM_WriteString((CHAR*)"(*)", 4); - OPC_AnsiParamList(obj->link, 0); - OPM_WriteString((CHAR*)", ", 3); - OPC_DeclareParams(obj->link, 1); - OPM_Write(')'); - OPM_WriteLn(); } OPC_DefineTProcMacros(obj->right, &*empty); } @@ -652,7 +654,7 @@ static void OPC_DefineType (OPT_Struct str) { OPT_Object obj = NIL, field = NIL, par = NIL; BOOLEAN empty; - if (OPM_currFile == 1 || str->ref < 255) { + if ((OPM_currFile == 1 || str->ref < 255) || (((OPM_currFile == 0 && str->strobj != NIL)) && str->strobj->vis == 1)) { obj = str->strobj; if (obj == NIL || OPC_Undefined(obj)) { if (obj != NIL) { @@ -719,6 +721,13 @@ static void OPC_DefineType (OPT_Struct str) if (!empty) { OPM_WriteLn(); } + } else if ((obj->typ->form == 11 && obj->typ->BaseTyp->comp == 4)) { + empty = 1; + OPC_DeclareTProcs(obj->typ->BaseTyp->link, &empty); + OPC_DefineTProcMacros(obj->typ->BaseTyp->link, &empty); + if (!empty) { + OPM_WriteLn(); + } } } } diff --git a/bootstrap/unix-48/OPC.h b/bootstrap/unix-48/OPC.h index fd7ddb5e..3bfd88b8 100644 --- a/bootstrap/unix-48/OPC.h +++ b/bootstrap/unix-48/OPC.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPC__h #define OPC__h diff --git a/bootstrap/unix-48/OPM.c b/bootstrap/unix-48/OPM.c index d2462ff6..bcb39247 100644 --- a/bootstrap/unix-48/OPM.c +++ b/bootstrap/unix-48/OPM.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -19,6 +19,8 @@ typedef CHAR OPM_FileName[32]; +static CHAR OPM_currentComment[256]; +static BOOLEAN OPM_hasComment; static CHAR OPM_SourceFileName[256]; static CHAR OPM_GlobalModel[10]; export CHAR OPM_Model[10]; @@ -59,6 +61,7 @@ static void OPM_FindInstallDir (void); static void OPM_FindLine (Files_File f, Files_Rider *r, ADDRESS *r__typ, INT64 pos); static void OPM_FingerprintBytes (INT32 *fp, SYSTEM_BYTE *bytes, ADDRESS bytes__len); export void OPM_Get (CHAR *ch); +export void OPM_GetComment (CHAR *text, ADDRESS text__len); export void OPM_Init (BOOLEAN *done); export void OPM_InitOptions (void); export INT16 OPM_Integer (INT64 n); @@ -82,6 +85,7 @@ static void OPM_ScanOptions (CHAR *s, ADDRESS s__len); static void OPM_ShowLine (INT64 pos); export INT64 OPM_SignedMaximum (INT32 bytecount); export INT64 OPM_SignedMinimum (INT32 bytecount); +export void OPM_StoreComment (CHAR *text, ADDRESS text__len); export void OPM_SymRCh (CHAR *ch); export INT32 OPM_SymRInt (void); export INT64 OPM_SymRInt64 (void); @@ -157,6 +161,36 @@ void OPM_LogCompiling (CHAR *modname, ADDRESS modname__len) __DEL(modname); } +void OPM_StoreComment (CHAR *text, ADDRESS text__len) +{ + INT16 i; + __DUP(text, text__len, CHAR); + i = 0; + while ((i < 255 && text[__X(i, text__len)] != 0x00)) { + OPM_currentComment[__X(i, 256)] = text[__X(i, text__len)]; + i += 1; + } + OPM_currentComment[__X(i, 256)] = 0x00; + OPM_hasComment = 1; + __DEL(text); +} + +void OPM_GetComment (CHAR *text, ADDRESS text__len) +{ + INT16 i; + if (OPM_hasComment) { + i = 0; + while ((((i < text__len && i < 256)) && OPM_currentComment[__X(i, 256)] != 0x00)) { + text[__X(i, text__len)] = OPM_currentComment[__X(i, 256)]; + i += 1; + } + text[__X(i, text__len)] = 0x00; + OPM_hasComment = 0; + } else { + text[0] = 0x00; + } +} + INT64 OPM_SignedMaximum (INT32 bytecount) { INT64 result; @@ -763,7 +797,7 @@ void OPM_OldSym (CHAR *modName, ADDRESS modName__len, BOOLEAN *done) Files_Set(&OPM_oldSF, Files_Rider__typ, OPM_oldSFile, 0); Files_Read(&OPM_oldSF, Files_Rider__typ, (void*)&tag); Files_Read(&OPM_oldSF, Files_Rider__typ, (void*)&ver); - if (tag != 0xf7 || ver != 0x83) { + if (tag != 0xf7 || ver != 0x84) { if (!__IN(4, OPM_Options, 32)) { OPM_err(-306); } @@ -834,7 +868,7 @@ void OPM_NewSym (CHAR *modName, ADDRESS modName__len) if (OPM_newSFile != NIL) { Files_Set(&OPM_newSF, Files_Rider__typ, OPM_newSFile, 0); Files_Write(&OPM_newSF, Files_Rider__typ, 0xf7); - Files_Write(&OPM_newSF, Files_Rider__typ, 0x83); + Files_Write(&OPM_newSF, Files_Rider__typ, 0x84); } else { OPM_err(153); } @@ -1143,5 +1177,7 @@ export void *OPM__init(void) OPM_MinReal = -OPM_MaxReal; OPM_MinLReal = -OPM_MaxLReal; OPM_FindInstallDir(); + OPM_hasComment = 0; + OPM_currentComment[0] = 0x00; __ENDMOD; } diff --git a/bootstrap/unix-48/OPM.h b/bootstrap/unix-48/OPM.h index 14ef9200..64c15a28 100644 --- a/bootstrap/unix-48/OPM.h +++ b/bootstrap/unix-48/OPM.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPM__h #define OPM__h @@ -30,6 +30,7 @@ import void OPM_FPrintLReal (INT32 *fp, LONGREAL val); import void OPM_FPrintReal (INT32 *fp, REAL val); import void OPM_FPrintSet (INT32 *fp, UINT64 val); import void OPM_Get (CHAR *ch); +import void OPM_GetComment (CHAR *text, ADDRESS text__len); import void OPM_Init (BOOLEAN *done); import void OPM_InitOptions (void); import INT16 OPM_Integer (INT64 n); @@ -48,6 +49,7 @@ import BOOLEAN OPM_OpenPar (void); import void OPM_RegisterNewSym (void); import INT64 OPM_SignedMaximum (INT32 bytecount); import INT64 OPM_SignedMinimum (INT32 bytecount); +import void OPM_StoreComment (CHAR *text, ADDRESS text__len); import void OPM_SymRCh (CHAR *ch); import INT32 OPM_SymRInt (void); import INT64 OPM_SymRInt64 (void); diff --git a/bootstrap/unix-48/OPP.c b/bootstrap/unix-48/OPP.c index 2bbed37b..ad4a370a 100644 --- a/bootstrap/unix-48/OPP.c +++ b/bootstrap/unix-48/OPP.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/OPP.h b/bootstrap/unix-48/OPP.h index 5980afc3..3d8cefe8 100644 --- a/bootstrap/unix-48/OPP.h +++ b/bootstrap/unix-48/OPP.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/unix-48/OPS.c b/bootstrap/unix-48/OPS.c index 95456407..a25a2c12 100644 --- a/bootstrap/unix-48/OPS.c +++ b/bootstrap/unix-48/OPS.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -279,32 +279,74 @@ static void Comment__2 (void); static void Comment__2 (void) { + BOOLEAN isExported; + CHAR commentText[256]; + INT16 i, nestLevel; + CHAR prevCh, nextCh; + i = 0; + while (i <= 255) { + commentText[__X(i, 256)] = 0x00; + i += 1; + } + isExported = 0; + i = 0; + nestLevel = 1; + prevCh = 0x00; OPM_Get(&OPS_ch); - for (;;) { - for (;;) { - while (OPS_ch == '(') { + if (OPS_ch == '*') { + isExported = 1; + OPM_Get(&OPS_ch); + if (OPS_ch == ')') { + commentText[0] = 0x00; + OPM_StoreComment(commentText, 256); + OPM_Get(&OPS_ch); + return; + } + } + while ((nestLevel > 0 && OPS_ch != 0x00)) { + if ((prevCh == '(' && OPS_ch == '*')) { + nestLevel += 1; + prevCh = 0x00; + } else if ((prevCh == '*' && OPS_ch == ')')) { + nestLevel -= 1; + if (nestLevel == 0) { OPM_Get(&OPS_ch); - if (OPS_ch == '*') { - Comment__2(); + } else { + prevCh = 0x00; + } + } else { + if ((((isExported && nestLevel == 1)) && prevCh != 0x00)) { + if (i < 255) { + commentText[__X(i, 256)] = prevCh; + i += 1; } } - if (OPS_ch == '*') { - OPM_Get(&OPS_ch); - break; - } - if (OPS_ch == 0x00) { - break; - } + prevCh = OPS_ch; + } + if (nestLevel > 0) { OPM_Get(&OPS_ch); } - if (OPS_ch == ')') { - OPM_Get(&OPS_ch); - break; + } + if (OPS_ch == 0x00) { + OPS_err(5); + } + if ((((((isExported && nestLevel == 0)) && prevCh != 0x00)) && prevCh != '*')) { + if (i < 255) { + commentText[__X(i, 256)] = prevCh; + i += 1; + } else { + OPM_LogWStr((CHAR*)"Truncating final comment character", 35); + OPM_LogWLn(); } - if (OPS_ch == 0x00) { - OPS_err(5); - break; + } + if (isExported) { + if (i >= 256) { + OPM_LogWStr((CHAR*)"Warning: commentText overflow", 30); + OPM_LogWLn(); + i = 255; } + commentText[__X(i, 256)] = 0x00; + OPM_StoreComment(commentText, 256); } } diff --git a/bootstrap/unix-48/OPS.h b/bootstrap/unix-48/OPS.h index f4851b8a..19e222ac 100644 --- a/bootstrap/unix-48/OPS.h +++ b/bootstrap/unix-48/OPS.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/unix-48/OPT.c b/bootstrap/unix-48/OPT.c index 85b0ef1c..ebb47dd8 100644 --- a/bootstrap/unix-48/OPT.c +++ b/bootstrap/unix-48/OPT.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -83,6 +83,7 @@ typedef OPT_Const conval; INT32 adr, linkadr; INT16 x; + OPT_ConstExt comment; } OPT_ObjDesc; typedef @@ -173,6 +174,7 @@ static void OPT_OutObj (OPT_Object obj); 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); +static void OPT_OutTruncatedName (CHAR *text, ADDRESS text__len); export OPT_Struct OPT_SetType (INT32 size); export OPT_Struct OPT_ShorterOrLongerType (OPT_Struct x, INT16 dir); export INT32 OPT_SizeAlignment (INT32 size); @@ -388,6 +390,10 @@ OPT_Object OPT_NewObj (void) { OPT_Object obj = NIL; __NEW(obj, OPT_ObjDesc); + obj->typ = NIL; + obj->conval = NIL; + obj->comment = NIL; + obj->name[0] = 0x00; return obj; } @@ -554,6 +560,8 @@ void OPT_Insert (OPS_Name name, OPT_Object *obj) OPT_Object ob0 = NIL, ob1 = NIL; BOOLEAN left; INT8 mnolev; + CHAR commentText[256]; + INT16 j; ob0 = OPT_topScope; ob1 = ob0->right; left = 0; @@ -585,6 +593,16 @@ void OPT_Insert (OPS_Name name, OPT_Object *obj) __COPY(name, ob1->name, 256); mnolev = OPT_topScope->mnolev; ob1->mnolev = mnolev; + OPM_GetComment((void*)commentText, 256); + if (commentText[0] != 0x00) { + ob1->comment = __NEWARR(NIL, 1, 1, 1, 0, 256); + j = 0; + while ((j < 255 && commentText[__X(j, 256)] != 0x00)) { + (*ob1->comment)[__X(j, 256)] = commentText[__X(j, 256)]; + j += 1; + } + (*ob1->comment)[__X(j, 256)] = 0x00; + } break; } } @@ -1103,6 +1121,13 @@ static void OPT_InSign (INT8 mno, OPT_Struct *res, OPT_Object *par) tag = OPM_SymRInt(); last = NIL; while (tag != 18) { + if (tag < 0 || tag > 100) { + OPM_LogWStr((CHAR*)"ERROR: Invalid tag value in InSign: ", 37); + OPM_LogWNum(tag, 0); + OPM_LogWLn(); + OPM_err(155); + return; + } new = OPT_NewObj(); new->mnolev = -mno; if (last == NIL) { @@ -1381,7 +1406,37 @@ static OPT_Object OPT_InObj (INT8 mno) OPT_Struct typ = NIL; INT32 tag; OPT_ConstExt ext = NIL; + OPS_Name commentText; + BOOLEAN hasComment; + INT16 j; + INT32 len; tag = OPT_impCtxt.nextTag; + hasComment = 0; + while (tag == 41) { + len = OPM_SymRInt(); + if (len < 0) { + len = 0; + } + if (len > 255) { + len = 255; + } + i = 0; + while (i < len) { + OPM_SymRCh(&commentText[__X(i, 256)]); + i += 1; + } + commentText[__X(i, 256)] = 0x00; + hasComment = 1; + tag = OPM_SymRInt(); + } + OPT_impCtxt.nextTag = tag; + if (tag < 0 || tag > 50) { + OPM_LogWStr((CHAR*)"ERROR: Invalid tag in InObj: ", 30); + OPM_LogWNum(tag, 0); + OPM_LogWLn(); + OPM_err(155); + return NIL; + } if (tag == 19) { OPT_InStruct(&typ); obj = typ->strobj; @@ -1397,7 +1452,7 @@ static OPT_Object OPT_InObj (INT8 mno) obj->conval = OPT_NewConst(); OPT_InConstant(tag, obj->conval); obj->typ = OPT_InTyp(tag); - } else if (tag >= 31) { + } else if ((tag >= 31 && tag <= 33)) { obj->conval = OPT_NewConst(); obj->conval->intval = -1; OPT_InSign(mno, &obj->typ, &obj->link); @@ -1424,20 +1479,37 @@ static OPT_Object OPT_InObj (INT8 mno) OPM_LogWStr((CHAR*)"unhandled case at InObj, tag = ", 32); OPM_LogWNum(tag, 0); OPM_LogWLn(); + OPM_err(155); + return NIL; break; } } else if (tag == 20) { obj->mode = 5; OPT_InStruct(&obj->typ); - } else { + } else if (tag == 21 || tag == 22) { obj->mode = 1; if (tag == 22) { obj->vis = 2; } OPT_InStruct(&obj->typ); + } else { + OPM_LogWStr((CHAR*)"ERROR: Unexpected tag in InObj: ", 33); + OPM_LogWNum(tag, 0); + OPM_LogWLn(); + OPM_err(155); + return NIL; } OPT_InName((void*)obj->name, 256); } + if ((hasComment && obj != NIL)) { + obj->comment = __NEWARR(NIL, 1, 1, 1, 0, 256); + j = 0; + while ((((j < 255 && j < len)) && commentText[__X(j, 256)] != 0x00)) { + (*obj->comment)[__X(j, 256)] = commentText[__X(j, 256)]; + j += 1; + } + (*obj->comment)[__X(j, 256)] = 0x00; + } OPT_FPrintObj(obj); if ((obj->mode == 1 && (obj->typ->strobj == NIL || obj->typ->strobj->name[0] == 0x00))) { OPM_FPrint(&OPT_impCtxt.reffp, obj->typ->ref - 255); @@ -1780,13 +1852,40 @@ static void OPT_OutConstant (OPT_Object obj) } } +static void OPT_OutTruncatedName (CHAR *text, ADDRESS text__len) +{ + INT16 i; + __DUP(text, text__len, CHAR); + i = 0; + while ((i < 255 && text[__X(i, text__len)] != 0x00)) { + OPM_SymWCh(text[__X(i, text__len)]); + i += 1; + } + OPM_SymWCh(0x00); + __DEL(text); +} + static void OPT_OutObj (OPT_Object obj) { INT16 i, j; OPT_ConstExt ext = NIL; + INT16 k, l; if (obj != NIL) { OPT_OutObj(obj->left); if (__IN(obj->mode, 0x06ea, 32)) { + if (obj->comment != NIL) { + OPM_SymWInt(41); + k = 0; + while ((k < 255 && (*obj->comment)[__X(k, 256)] != 0x00)) { + k += 1; + } + OPM_SymWInt(k); + l = 0; + while (l < k) { + OPM_SymWCh((*obj->comment)[__X(l, 256)]); + l += 1; + } + } if (obj->history == 4) { OPT_FPrintErr(obj, 250); } else if (obj->vis != 0) { @@ -2026,7 +2125,7 @@ static void EnumPtrs(void (*P)(void*)) } __TDESC(OPT_ConstDesc, 1, 1) = {__TDFLDS("ConstDesc", 40), {0, -8}}; -__TDESC(OPT_ObjDesc, 1, 6) = {__TDFLDS("ObjDesc", 304), {0, 4, 8, 12, 284, 288, -28}}; +__TDESC(OPT_ObjDesc, 1, 7) = {__TDFLDS("ObjDesc", 308), {0, 4, 8, 12, 284, 288, 304, -32}}; __TDESC(OPT_StrDesc, 1, 3) = {__TDFLDS("StrDesc", 56), {44, 48, 52, -16}}; __TDESC(OPT_NodeDesc, 1, 6) = {__TDFLDS("NodeDesc", 28), {0, 4, 8, 16, 20, 24, -28}}; __TDESC(OPT_ImpCtxt, 1, 510) = {__TDFLDS("ImpCtxt", 3140), {16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, diff --git a/bootstrap/unix-48/OPT.h b/bootstrap/unix-48/OPT.h index d2f8d9fe..cf456af5 100644 --- a/bootstrap/unix-48/OPT.h +++ b/bootstrap/unix-48/OPT.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPT__h #define OPT__h @@ -61,6 +61,7 @@ typedef OPT_Const conval; INT32 adr, linkadr; INT16 x; + OPT_ConstExt comment; } OPT_ObjDesc; typedef diff --git a/bootstrap/unix-48/OPV.c b/bootstrap/unix-48/OPV.c index ecef063d..0425b2e0 100644 --- a/bootstrap/unix-48/OPV.c +++ b/bootstrap/unix-48/OPV.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/OPV.h b/bootstrap/unix-48/OPV.h index 44652222..fbabd8f4 100644 --- a/bootstrap/unix-48/OPV.h +++ b/bootstrap/unix-48/OPV.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPV__h #define OPV__h diff --git a/bootstrap/unix-48/Out.c b/bootstrap/unix-48/Out.c index d5a45e43..ce936589 100644 --- a/bootstrap/unix-48/Out.c +++ b/bootstrap/unix-48/Out.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/Out.h b/bootstrap/unix-48/Out.h index a008c089..a72547f4 100644 --- a/bootstrap/unix-48/Out.h +++ b/bootstrap/unix-48/Out.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Out__h #define Out__h diff --git a/bootstrap/unix-48/Platform.c b/bootstrap/unix-48/Platform.c index 61463b51..befa6033 100644 --- a/bootstrap/unix-48/Platform.c +++ b/bootstrap/unix-48/Platform.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/Platform.h b/bootstrap/unix-48/Platform.h index 89ce40d3..fbeef8c7 100644 --- a/bootstrap/unix-48/Platform.h +++ b/bootstrap/unix-48/Platform.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/unix-48/Reals.c b/bootstrap/unix-48/Reals.c index f4cc31eb..512ec2c4 100644 --- a/bootstrap/unix-48/Reals.c +++ b/bootstrap/unix-48/Reals.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/Reals.h b/bootstrap/unix-48/Reals.h index 04ff0d7c..93e7fa75 100644 --- a/bootstrap/unix-48/Reals.h +++ b/bootstrap/unix-48/Reals.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/unix-48/Strings.c b/bootstrap/unix-48/Strings.c index 629009fa..4b18812f 100644 --- a/bootstrap/unix-48/Strings.c +++ b/bootstrap/unix-48/Strings.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/Strings.h b/bootstrap/unix-48/Strings.h index 6acdef43..f0e3ae34 100644 --- a/bootstrap/unix-48/Strings.h +++ b/bootstrap/unix-48/Strings.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/unix-48/Texts.c b/bootstrap/unix-48/Texts.c index 2b57b307..43c3858f 100644 --- a/bootstrap/unix-48/Texts.c +++ b/bootstrap/unix-48/Texts.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/Texts.h b/bootstrap/unix-48/Texts.h index 75712cc1..fd0c0fa5 100644 --- a/bootstrap/unix-48/Texts.h +++ b/bootstrap/unix-48/Texts.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/unix-48/VT100.c b/bootstrap/unix-48/VT100.c index c5e8a3ba..346fb37b 100644 --- a/bootstrap/unix-48/VT100.c +++ b/bootstrap/unix-48/VT100.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/VT100.h b/bootstrap/unix-48/VT100.h index 94b7b846..4e708647 100644 --- a/bootstrap/unix-48/VT100.h +++ b/bootstrap/unix-48/VT100.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef VT100__h #define VT100__h diff --git a/bootstrap/unix-48/extTools.c b/bootstrap/unix-48/extTools.c index cf90fa2a..ce2fc413 100644 --- a/bootstrap/unix-48/extTools.c +++ b/bootstrap/unix-48/extTools.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -73,7 +73,7 @@ static void extTools_execute (CHAR *title, ADDRESS title__len, CHAR *cmd, ADDRES static void extTools_InitialiseCompilerCommand (CHAR *s, ADDRESS s__len, CHAR *additionalopts, ADDRESS additionalopts__len) { __DUP(additionalopts, additionalopts__len, CHAR); - __COPY("gcc -fPIC -g", s, s__len); + __COPY("gcc -fPIC -g -Wno-stringop-overflow", s, s__len); Strings_Append((CHAR*)" -I \"", 6, (void*)s, s__len); Strings_Append(OPM_ResourceDir, 1024, (void*)s, s__len); Strings_Append((CHAR*)"/include\" ", 11, (void*)s, s__len); diff --git a/bootstrap/unix-48/extTools.h b/bootstrap/unix-48/extTools.h index 6b1b37eb..686f0b4e 100644 --- a/bootstrap/unix-48/extTools.h +++ b/bootstrap/unix-48/extTools.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef extTools__h #define extTools__h diff --git a/bootstrap/unix-88/Compiler.c b/bootstrap/unix-88/Compiler.c index 1807e545..4460479d 100644 --- a/bootstrap/unix-88/Compiler.c +++ b/bootstrap/unix-88/Compiler.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspamS */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspamS */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/Configuration.c b/bootstrap/unix-88/Configuration.c index fb7a8f35..fa87c9de 100644 --- a/bootstrap/unix-88/Configuration.c +++ b/bootstrap/unix-88/Configuration.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -19,6 +19,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 76); + __MOVE("2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 76); __ENDMOD; } diff --git a/bootstrap/unix-88/Configuration.h b/bootstrap/unix-88/Configuration.h index c8bae246..c3c54eed 100644 --- a/bootstrap/unix-88/Configuration.h +++ b/bootstrap/unix-88/Configuration.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Configuration__h #define Configuration__h diff --git a/bootstrap/unix-88/Files.c b/bootstrap/unix-88/Files.c index 940170c8..57e78310 100644 --- a/bootstrap/unix-88/Files.c +++ b/bootstrap/unix-88/Files.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/Files.h b/bootstrap/unix-88/Files.h index 375065c6..676f434c 100644 --- a/bootstrap/unix-88/Files.h +++ b/bootstrap/unix-88/Files.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/unix-88/Heap.c b/bootstrap/unix-88/Heap.c index 980fab89..7b004b60 100644 --- a/bootstrap/unix-88/Heap.c +++ b/bootstrap/unix-88/Heap.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/Heap.h b/bootstrap/unix-88/Heap.h index e188739a..45a9c6d2 100644 --- a/bootstrap/unix-88/Heap.h +++ b/bootstrap/unix-88/Heap.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ #ifndef Heap__h #define Heap__h diff --git a/bootstrap/unix-88/Modules.c b/bootstrap/unix-88/Modules.c index 011ac733..a5b989e5 100644 --- a/bootstrap/unix-88/Modules.c +++ b/bootstrap/unix-88/Modules.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/Modules.h b/bootstrap/unix-88/Modules.h index 34d0e538..ee65a938 100644 --- a/bootstrap/unix-88/Modules.h +++ b/bootstrap/unix-88/Modules.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Modules__h #define Modules__h diff --git a/bootstrap/unix-88/OPB.c b/bootstrap/unix-88/OPB.c index 4d4925c6..913fbf2d 100644 --- a/bootstrap/unix-88/OPB.c +++ b/bootstrap/unix-88/OPB.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/OPB.h b/bootstrap/unix-88/OPB.h index cb41ad3d..f66fcd66 100644 --- a/bootstrap/unix-88/OPB.h +++ b/bootstrap/unix-88/OPB.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPB__h #define OPB__h diff --git a/bootstrap/unix-88/OPC.c b/bootstrap/unix-88/OPC.c index dc9da7db..7b92ccc1 100644 --- a/bootstrap/unix-88/OPC.c +++ b/bootstrap/unix-88/OPC.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -618,31 +618,33 @@ static void OPC_DefineTProcMacros (OPT_Object obj, BOOLEAN *empty) { if (obj != NIL) { OPC_DefineTProcMacros(obj->left, &*empty); - if ((((obj->mode == 13 && obj == OPC_BaseTProc(obj))) && (OPM_currFile != 0 || obj->vis == 1))) { - OPM_WriteString((CHAR*)"#define __", 11); - OPC_Ident(obj); - OPC_DeclareParams(obj->link, 1); - OPM_WriteString((CHAR*)" __SEND(", 9); - if (obj->link->typ->form == 11) { - OPM_WriteString((CHAR*)"__TYPEOF(", 10); - OPC_Ident(obj->link); + if ((obj->mode == 13 && obj == OPC_BaseTProc(obj))) { + if (OPM_currFile == 1 || (OPM_currFile == 0 && obj->vis == 1)) { + OPM_WriteString((CHAR*)"#define __", 11); + OPC_Ident(obj); + OPC_DeclareParams(obj->link, 1); + OPM_WriteString((CHAR*)" __SEND(", 9); + if (obj->link->typ->form == 11) { + OPM_WriteString((CHAR*)"__TYPEOF(", 10); + OPC_Ident(obj->link); + OPM_Write(')'); + } else { + OPC_Ident(obj->link); + OPM_WriteString((CHAR*)"__typ", 6); + } + OPC_Str1((CHAR*)", #, ", 6, __ASHR(obj->adr, 16)); + if (obj->typ == OPT_notyp) { + OPM_WriteString((CHAR*)"void", 5); + } else { + OPC_Ident(obj->typ->strobj); + } + OPM_WriteString((CHAR*)"(*)", 4); + OPC_AnsiParamList(obj->link, 0); + OPM_WriteString((CHAR*)", ", 3); + OPC_DeclareParams(obj->link, 1); OPM_Write(')'); - } else { - OPC_Ident(obj->link); - OPM_WriteString((CHAR*)"__typ", 6); + OPM_WriteLn(); } - OPC_Str1((CHAR*)", #, ", 6, __ASHR(obj->adr, 16)); - if (obj->typ == OPT_notyp) { - OPM_WriteString((CHAR*)"void", 5); - } else { - OPC_Ident(obj->typ->strobj); - } - OPM_WriteString((CHAR*)"(*)", 4); - OPC_AnsiParamList(obj->link, 0); - OPM_WriteString((CHAR*)", ", 3); - OPC_DeclareParams(obj->link, 1); - OPM_Write(')'); - OPM_WriteLn(); } OPC_DefineTProcMacros(obj->right, &*empty); } @@ -652,7 +654,7 @@ static void OPC_DefineType (OPT_Struct str) { OPT_Object obj = NIL, field = NIL, par = NIL; BOOLEAN empty; - if (OPM_currFile == 1 || str->ref < 255) { + if ((OPM_currFile == 1 || str->ref < 255) || (((OPM_currFile == 0 && str->strobj != NIL)) && str->strobj->vis == 1)) { obj = str->strobj; if (obj == NIL || OPC_Undefined(obj)) { if (obj != NIL) { @@ -719,6 +721,13 @@ static void OPC_DefineType (OPT_Struct str) if (!empty) { OPM_WriteLn(); } + } else if ((obj->typ->form == 11 && obj->typ->BaseTyp->comp == 4)) { + empty = 1; + OPC_DeclareTProcs(obj->typ->BaseTyp->link, &empty); + OPC_DefineTProcMacros(obj->typ->BaseTyp->link, &empty); + if (!empty) { + OPM_WriteLn(); + } } } } diff --git a/bootstrap/unix-88/OPC.h b/bootstrap/unix-88/OPC.h index fd7ddb5e..3bfd88b8 100644 --- a/bootstrap/unix-88/OPC.h +++ b/bootstrap/unix-88/OPC.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPC__h #define OPC__h diff --git a/bootstrap/unix-88/OPM.c b/bootstrap/unix-88/OPM.c index f298d2d5..b486b3b9 100644 --- a/bootstrap/unix-88/OPM.c +++ b/bootstrap/unix-88/OPM.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -19,6 +19,8 @@ typedef CHAR OPM_FileName[32]; +static CHAR OPM_currentComment[256]; +static BOOLEAN OPM_hasComment; static CHAR OPM_SourceFileName[256]; static CHAR OPM_GlobalModel[10]; export CHAR OPM_Model[10]; @@ -59,6 +61,7 @@ static void OPM_FindInstallDir (void); static void OPM_FindLine (Files_File f, Files_Rider *r, ADDRESS *r__typ, INT64 pos); static void OPM_FingerprintBytes (INT32 *fp, SYSTEM_BYTE *bytes, ADDRESS bytes__len); export void OPM_Get (CHAR *ch); +export void OPM_GetComment (CHAR *text, ADDRESS text__len); export void OPM_Init (BOOLEAN *done); export void OPM_InitOptions (void); export INT16 OPM_Integer (INT64 n); @@ -82,6 +85,7 @@ static void OPM_ScanOptions (CHAR *s, ADDRESS s__len); static void OPM_ShowLine (INT64 pos); export INT64 OPM_SignedMaximum (INT32 bytecount); export INT64 OPM_SignedMinimum (INT32 bytecount); +export void OPM_StoreComment (CHAR *text, ADDRESS text__len); export void OPM_SymRCh (CHAR *ch); export INT32 OPM_SymRInt (void); export INT64 OPM_SymRInt64 (void); @@ -157,6 +161,36 @@ void OPM_LogCompiling (CHAR *modname, ADDRESS modname__len) __DEL(modname); } +void OPM_StoreComment (CHAR *text, ADDRESS text__len) +{ + INT16 i; + __DUP(text, text__len, CHAR); + i = 0; + while ((i < 255 && text[__X(i, text__len)] != 0x00)) { + OPM_currentComment[__X(i, 256)] = text[__X(i, text__len)]; + i += 1; + } + OPM_currentComment[__X(i, 256)] = 0x00; + OPM_hasComment = 1; + __DEL(text); +} + +void OPM_GetComment (CHAR *text, ADDRESS text__len) +{ + INT16 i; + if (OPM_hasComment) { + i = 0; + while ((((i < text__len && i < 256)) && OPM_currentComment[__X(i, 256)] != 0x00)) { + text[__X(i, text__len)] = OPM_currentComment[__X(i, 256)]; + i += 1; + } + text[__X(i, text__len)] = 0x00; + OPM_hasComment = 0; + } else { + text[0] = 0x00; + } +} + INT64 OPM_SignedMaximum (INT32 bytecount) { INT64 result; @@ -763,7 +797,7 @@ void OPM_OldSym (CHAR *modName, ADDRESS modName__len, BOOLEAN *done) Files_Set(&OPM_oldSF, Files_Rider__typ, OPM_oldSFile, 0); Files_Read(&OPM_oldSF, Files_Rider__typ, (void*)&tag); Files_Read(&OPM_oldSF, Files_Rider__typ, (void*)&ver); - if (tag != 0xf7 || ver != 0x83) { + if (tag != 0xf7 || ver != 0x84) { if (!__IN(4, OPM_Options, 32)) { OPM_err(-306); } @@ -834,7 +868,7 @@ void OPM_NewSym (CHAR *modName, ADDRESS modName__len) if (OPM_newSFile != NIL) { Files_Set(&OPM_newSF, Files_Rider__typ, OPM_newSFile, 0); Files_Write(&OPM_newSF, Files_Rider__typ, 0xf7); - Files_Write(&OPM_newSF, Files_Rider__typ, 0x83); + Files_Write(&OPM_newSF, Files_Rider__typ, 0x84); } else { OPM_err(153); } @@ -1143,5 +1177,7 @@ export void *OPM__init(void) OPM_MinReal = -OPM_MaxReal; OPM_MinLReal = -OPM_MaxLReal; OPM_FindInstallDir(); + OPM_hasComment = 0; + OPM_currentComment[0] = 0x00; __ENDMOD; } diff --git a/bootstrap/unix-88/OPM.h b/bootstrap/unix-88/OPM.h index 14ef9200..64c15a28 100644 --- a/bootstrap/unix-88/OPM.h +++ b/bootstrap/unix-88/OPM.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPM__h #define OPM__h @@ -30,6 +30,7 @@ import void OPM_FPrintLReal (INT32 *fp, LONGREAL val); import void OPM_FPrintReal (INT32 *fp, REAL val); import void OPM_FPrintSet (INT32 *fp, UINT64 val); import void OPM_Get (CHAR *ch); +import void OPM_GetComment (CHAR *text, ADDRESS text__len); import void OPM_Init (BOOLEAN *done); import void OPM_InitOptions (void); import INT16 OPM_Integer (INT64 n); @@ -48,6 +49,7 @@ import BOOLEAN OPM_OpenPar (void); import void OPM_RegisterNewSym (void); import INT64 OPM_SignedMaximum (INT32 bytecount); import INT64 OPM_SignedMinimum (INT32 bytecount); +import void OPM_StoreComment (CHAR *text, ADDRESS text__len); import void OPM_SymRCh (CHAR *ch); import INT32 OPM_SymRInt (void); import INT64 OPM_SymRInt64 (void); diff --git a/bootstrap/unix-88/OPP.c b/bootstrap/unix-88/OPP.c index f98062ab..3fed2e31 100644 --- a/bootstrap/unix-88/OPP.c +++ b/bootstrap/unix-88/OPP.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/OPP.h b/bootstrap/unix-88/OPP.h index 5980afc3..3d8cefe8 100644 --- a/bootstrap/unix-88/OPP.h +++ b/bootstrap/unix-88/OPP.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/unix-88/OPS.c b/bootstrap/unix-88/OPS.c index 95456407..a25a2c12 100644 --- a/bootstrap/unix-88/OPS.c +++ b/bootstrap/unix-88/OPS.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -279,32 +279,74 @@ static void Comment__2 (void); static void Comment__2 (void) { + BOOLEAN isExported; + CHAR commentText[256]; + INT16 i, nestLevel; + CHAR prevCh, nextCh; + i = 0; + while (i <= 255) { + commentText[__X(i, 256)] = 0x00; + i += 1; + } + isExported = 0; + i = 0; + nestLevel = 1; + prevCh = 0x00; OPM_Get(&OPS_ch); - for (;;) { - for (;;) { - while (OPS_ch == '(') { + if (OPS_ch == '*') { + isExported = 1; + OPM_Get(&OPS_ch); + if (OPS_ch == ')') { + commentText[0] = 0x00; + OPM_StoreComment(commentText, 256); + OPM_Get(&OPS_ch); + return; + } + } + while ((nestLevel > 0 && OPS_ch != 0x00)) { + if ((prevCh == '(' && OPS_ch == '*')) { + nestLevel += 1; + prevCh = 0x00; + } else if ((prevCh == '*' && OPS_ch == ')')) { + nestLevel -= 1; + if (nestLevel == 0) { OPM_Get(&OPS_ch); - if (OPS_ch == '*') { - Comment__2(); + } else { + prevCh = 0x00; + } + } else { + if ((((isExported && nestLevel == 1)) && prevCh != 0x00)) { + if (i < 255) { + commentText[__X(i, 256)] = prevCh; + i += 1; } } - if (OPS_ch == '*') { - OPM_Get(&OPS_ch); - break; - } - if (OPS_ch == 0x00) { - break; - } + prevCh = OPS_ch; + } + if (nestLevel > 0) { OPM_Get(&OPS_ch); } - if (OPS_ch == ')') { - OPM_Get(&OPS_ch); - break; + } + if (OPS_ch == 0x00) { + OPS_err(5); + } + if ((((((isExported && nestLevel == 0)) && prevCh != 0x00)) && prevCh != '*')) { + if (i < 255) { + commentText[__X(i, 256)] = prevCh; + i += 1; + } else { + OPM_LogWStr((CHAR*)"Truncating final comment character", 35); + OPM_LogWLn(); } - if (OPS_ch == 0x00) { - OPS_err(5); - break; + } + if (isExported) { + if (i >= 256) { + OPM_LogWStr((CHAR*)"Warning: commentText overflow", 30); + OPM_LogWLn(); + i = 255; } + commentText[__X(i, 256)] = 0x00; + OPM_StoreComment(commentText, 256); } } diff --git a/bootstrap/unix-88/OPS.h b/bootstrap/unix-88/OPS.h index f4851b8a..19e222ac 100644 --- a/bootstrap/unix-88/OPS.h +++ b/bootstrap/unix-88/OPS.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/unix-88/OPT.c b/bootstrap/unix-88/OPT.c index 3b837866..c3999981 100644 --- a/bootstrap/unix-88/OPT.c +++ b/bootstrap/unix-88/OPT.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -83,6 +83,7 @@ typedef OPT_Const conval; INT32 adr, linkadr; INT16 x; + OPT_ConstExt comment; } OPT_ObjDesc; typedef @@ -173,6 +174,7 @@ static void OPT_OutObj (OPT_Object obj); 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); +static void OPT_OutTruncatedName (CHAR *text, ADDRESS text__len); export OPT_Struct OPT_SetType (INT32 size); export OPT_Struct OPT_ShorterOrLongerType (OPT_Struct x, INT16 dir); export INT32 OPT_SizeAlignment (INT32 size); @@ -388,6 +390,10 @@ OPT_Object OPT_NewObj (void) { OPT_Object obj = NIL; __NEW(obj, OPT_ObjDesc); + obj->typ = NIL; + obj->conval = NIL; + obj->comment = NIL; + obj->name[0] = 0x00; return obj; } @@ -554,6 +560,8 @@ void OPT_Insert (OPS_Name name, OPT_Object *obj) OPT_Object ob0 = NIL, ob1 = NIL; BOOLEAN left; INT8 mnolev; + CHAR commentText[256]; + INT16 j; ob0 = OPT_topScope; ob1 = ob0->right; left = 0; @@ -585,6 +593,16 @@ void OPT_Insert (OPS_Name name, OPT_Object *obj) __COPY(name, ob1->name, 256); mnolev = OPT_topScope->mnolev; ob1->mnolev = mnolev; + OPM_GetComment((void*)commentText, 256); + if (commentText[0] != 0x00) { + ob1->comment = __NEWARR(NIL, 1, 1, 1, 0, ((INT64)(256))); + j = 0; + while ((j < 255 && commentText[__X(j, 256)] != 0x00)) { + (*ob1->comment)[__X(j, 256)] = commentText[__X(j, 256)]; + j += 1; + } + (*ob1->comment)[__X(j, 256)] = 0x00; + } break; } } @@ -1103,6 +1121,13 @@ static void OPT_InSign (INT8 mno, OPT_Struct *res, OPT_Object *par) tag = OPM_SymRInt(); last = NIL; while (tag != 18) { + if (tag < 0 || tag > 100) { + OPM_LogWStr((CHAR*)"ERROR: Invalid tag value in InSign: ", 37); + OPM_LogWNum(tag, 0); + OPM_LogWLn(); + OPM_err(155); + return; + } new = OPT_NewObj(); new->mnolev = -mno; if (last == NIL) { @@ -1381,7 +1406,37 @@ static OPT_Object OPT_InObj (INT8 mno) OPT_Struct typ = NIL; INT32 tag; OPT_ConstExt ext = NIL; + OPS_Name commentText; + BOOLEAN hasComment; + INT16 j; + INT32 len; tag = OPT_impCtxt.nextTag; + hasComment = 0; + while (tag == 41) { + len = OPM_SymRInt(); + if (len < 0) { + len = 0; + } + if (len > 255) { + len = 255; + } + i = 0; + while (i < len) { + OPM_SymRCh(&commentText[__X(i, 256)]); + i += 1; + } + commentText[__X(i, 256)] = 0x00; + hasComment = 1; + tag = OPM_SymRInt(); + } + OPT_impCtxt.nextTag = tag; + if (tag < 0 || tag > 50) { + OPM_LogWStr((CHAR*)"ERROR: Invalid tag in InObj: ", 30); + OPM_LogWNum(tag, 0); + OPM_LogWLn(); + OPM_err(155); + return NIL; + } if (tag == 19) { OPT_InStruct(&typ); obj = typ->strobj; @@ -1397,7 +1452,7 @@ static OPT_Object OPT_InObj (INT8 mno) obj->conval = OPT_NewConst(); OPT_InConstant(tag, obj->conval); obj->typ = OPT_InTyp(tag); - } else if (tag >= 31) { + } else if ((tag >= 31 && tag <= 33)) { obj->conval = OPT_NewConst(); obj->conval->intval = -1; OPT_InSign(mno, &obj->typ, &obj->link); @@ -1424,20 +1479,37 @@ static OPT_Object OPT_InObj (INT8 mno) OPM_LogWStr((CHAR*)"unhandled case at InObj, tag = ", 32); OPM_LogWNum(tag, 0); OPM_LogWLn(); + OPM_err(155); + return NIL; break; } } else if (tag == 20) { obj->mode = 5; OPT_InStruct(&obj->typ); - } else { + } else if (tag == 21 || tag == 22) { obj->mode = 1; if (tag == 22) { obj->vis = 2; } OPT_InStruct(&obj->typ); + } else { + OPM_LogWStr((CHAR*)"ERROR: Unexpected tag in InObj: ", 33); + OPM_LogWNum(tag, 0); + OPM_LogWLn(); + OPM_err(155); + return NIL; } OPT_InName((void*)obj->name, 256); } + if ((hasComment && obj != NIL)) { + obj->comment = __NEWARR(NIL, 1, 1, 1, 0, ((INT64)(256))); + j = 0; + while ((((j < 255 && j < len)) && commentText[__X(j, 256)] != 0x00)) { + (*obj->comment)[__X(j, 256)] = commentText[__X(j, 256)]; + j += 1; + } + (*obj->comment)[__X(j, 256)] = 0x00; + } OPT_FPrintObj(obj); if ((obj->mode == 1 && (obj->typ->strobj == NIL || obj->typ->strobj->name[0] == 0x00))) { OPM_FPrint(&OPT_impCtxt.reffp, obj->typ->ref - 255); @@ -1780,13 +1852,40 @@ static void OPT_OutConstant (OPT_Object obj) } } +static void OPT_OutTruncatedName (CHAR *text, ADDRESS text__len) +{ + INT16 i; + __DUP(text, text__len, CHAR); + i = 0; + while ((i < 255 && text[__X(i, text__len)] != 0x00)) { + OPM_SymWCh(text[__X(i, text__len)]); + i += 1; + } + OPM_SymWCh(0x00); + __DEL(text); +} + static void OPT_OutObj (OPT_Object obj) { INT16 i, j; OPT_ConstExt ext = NIL; + INT16 k, l; if (obj != NIL) { OPT_OutObj(obj->left); if (__IN(obj->mode, 0x06ea, 32)) { + if (obj->comment != NIL) { + OPM_SymWInt(41); + k = 0; + while ((k < 255 && (*obj->comment)[__X(k, 256)] != 0x00)) { + k += 1; + } + OPM_SymWInt(k); + l = 0; + while (l < k) { + OPM_SymWCh((*obj->comment)[__X(l, 256)]); + l += 1; + } + } if (obj->history == 4) { OPT_FPrintErr(obj, 250); } else if (obj->vis != 0) { @@ -2026,7 +2125,7 @@ static void EnumPtrs(void (*P)(void*)) } __TDESC(OPT_ConstDesc, 1, 1) = {__TDFLDS("ConstDesc", 40), {0, -16}}; -__TDESC(OPT_ObjDesc, 1, 6) = {__TDFLDS("ObjDesc", 336), {0, 8, 16, 24, 304, 312, -56}}; +__TDESC(OPT_ObjDesc, 1, 7) = {__TDFLDS("ObjDesc", 344), {0, 8, 16, 24, 304, 312, 336, -64}}; __TDESC(OPT_StrDesc, 1, 3) = {__TDFLDS("StrDesc", 72), {48, 56, 64, -32}}; __TDESC(OPT_NodeDesc, 1, 6) = {__TDFLDS("NodeDesc", 56), {0, 8, 16, 32, 40, 48, -56}}; __TDESC(OPT_ImpCtxt, 1, 510) = {__TDFLDS("ImpCtxt", 5184), {16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, diff --git a/bootstrap/unix-88/OPT.h b/bootstrap/unix-88/OPT.h index d2f8d9fe..cf456af5 100644 --- a/bootstrap/unix-88/OPT.h +++ b/bootstrap/unix-88/OPT.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPT__h #define OPT__h @@ -61,6 +61,7 @@ typedef OPT_Const conval; INT32 adr, linkadr; INT16 x; + OPT_ConstExt comment; } OPT_ObjDesc; typedef diff --git a/bootstrap/unix-88/OPV.c b/bootstrap/unix-88/OPV.c index 2535e861..26c1c715 100644 --- a/bootstrap/unix-88/OPV.c +++ b/bootstrap/unix-88/OPV.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/OPV.h b/bootstrap/unix-88/OPV.h index 44652222..fbabd8f4 100644 --- a/bootstrap/unix-88/OPV.h +++ b/bootstrap/unix-88/OPV.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPV__h #define OPV__h diff --git a/bootstrap/unix-88/Out.c b/bootstrap/unix-88/Out.c index d5a45e43..ce936589 100644 --- a/bootstrap/unix-88/Out.c +++ b/bootstrap/unix-88/Out.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/Out.h b/bootstrap/unix-88/Out.h index a008c089..a72547f4 100644 --- a/bootstrap/unix-88/Out.h +++ b/bootstrap/unix-88/Out.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Out__h #define Out__h diff --git a/bootstrap/unix-88/Platform.c b/bootstrap/unix-88/Platform.c index c545b975..139181a0 100644 --- a/bootstrap/unix-88/Platform.c +++ b/bootstrap/unix-88/Platform.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/Platform.h b/bootstrap/unix-88/Platform.h index c6cd7505..e827b641 100644 --- a/bootstrap/unix-88/Platform.h +++ b/bootstrap/unix-88/Platform.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/unix-88/Reals.c b/bootstrap/unix-88/Reals.c index f4cc31eb..512ec2c4 100644 --- a/bootstrap/unix-88/Reals.c +++ b/bootstrap/unix-88/Reals.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/Reals.h b/bootstrap/unix-88/Reals.h index 04ff0d7c..93e7fa75 100644 --- a/bootstrap/unix-88/Reals.h +++ b/bootstrap/unix-88/Reals.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/unix-88/Strings.c b/bootstrap/unix-88/Strings.c index 629009fa..4b18812f 100644 --- a/bootstrap/unix-88/Strings.c +++ b/bootstrap/unix-88/Strings.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/Strings.h b/bootstrap/unix-88/Strings.h index 6acdef43..f0e3ae34 100644 --- a/bootstrap/unix-88/Strings.h +++ b/bootstrap/unix-88/Strings.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/unix-88/Texts.c b/bootstrap/unix-88/Texts.c index 291ccf2b..77dc1bac 100644 --- a/bootstrap/unix-88/Texts.c +++ b/bootstrap/unix-88/Texts.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/Texts.h b/bootstrap/unix-88/Texts.h index 56bb9359..081eec2c 100644 --- a/bootstrap/unix-88/Texts.h +++ b/bootstrap/unix-88/Texts.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/unix-88/VT100.c b/bootstrap/unix-88/VT100.c index c5e8a3ba..346fb37b 100644 --- a/bootstrap/unix-88/VT100.c +++ b/bootstrap/unix-88/VT100.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/VT100.h b/bootstrap/unix-88/VT100.h index 94b7b846..4e708647 100644 --- a/bootstrap/unix-88/VT100.h +++ b/bootstrap/unix-88/VT100.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef VT100__h #define VT100__h diff --git a/bootstrap/unix-88/extTools.c b/bootstrap/unix-88/extTools.c index cf90fa2a..ce2fc413 100644 --- a/bootstrap/unix-88/extTools.c +++ b/bootstrap/unix-88/extTools.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -73,7 +73,7 @@ static void extTools_execute (CHAR *title, ADDRESS title__len, CHAR *cmd, ADDRES static void extTools_InitialiseCompilerCommand (CHAR *s, ADDRESS s__len, CHAR *additionalopts, ADDRESS additionalopts__len) { __DUP(additionalopts, additionalopts__len, CHAR); - __COPY("gcc -fPIC -g", s, s__len); + __COPY("gcc -fPIC -g -Wno-stringop-overflow", s, s__len); Strings_Append((CHAR*)" -I \"", 6, (void*)s, s__len); Strings_Append(OPM_ResourceDir, 1024, (void*)s, s__len); Strings_Append((CHAR*)"/include\" ", 11, (void*)s, s__len); diff --git a/bootstrap/unix-88/extTools.h b/bootstrap/unix-88/extTools.h index 6b1b37eb..686f0b4e 100644 --- a/bootstrap/unix-88/extTools.h +++ b/bootstrap/unix-88/extTools.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef extTools__h #define extTools__h diff --git a/bootstrap/windows-48/Compiler.c b/bootstrap/windows-48/Compiler.c index 1807e545..4460479d 100644 --- a/bootstrap/windows-48/Compiler.c +++ b/bootstrap/windows-48/Compiler.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspamS */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspamS */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/Configuration.c b/bootstrap/windows-48/Configuration.c index fb7a8f35..fa87c9de 100644 --- a/bootstrap/windows-48/Configuration.c +++ b/bootstrap/windows-48/Configuration.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -19,6 +19,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 76); + __MOVE("2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 76); __ENDMOD; } diff --git a/bootstrap/windows-48/Configuration.h b/bootstrap/windows-48/Configuration.h index c8bae246..c3c54eed 100644 --- a/bootstrap/windows-48/Configuration.h +++ b/bootstrap/windows-48/Configuration.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Configuration__h #define Configuration__h diff --git a/bootstrap/windows-48/Files.c b/bootstrap/windows-48/Files.c index 15dcd35d..553bb49a 100644 --- a/bootstrap/windows-48/Files.c +++ b/bootstrap/windows-48/Files.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/Files.h b/bootstrap/windows-48/Files.h index 6d39b035..dadf1ace 100644 --- a/bootstrap/windows-48/Files.h +++ b/bootstrap/windows-48/Files.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/windows-48/Heap.c b/bootstrap/windows-48/Heap.c index df721094..42552415 100644 --- a/bootstrap/windows-48/Heap.c +++ b/bootstrap/windows-48/Heap.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/Heap.h b/bootstrap/windows-48/Heap.h index dbc11b6f..3cde1c3b 100644 --- a/bootstrap/windows-48/Heap.h +++ b/bootstrap/windows-48/Heap.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ #ifndef Heap__h #define Heap__h diff --git a/bootstrap/windows-48/Modules.c b/bootstrap/windows-48/Modules.c index 35b801dc..bdad4713 100644 --- a/bootstrap/windows-48/Modules.c +++ b/bootstrap/windows-48/Modules.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/Modules.h b/bootstrap/windows-48/Modules.h index 22468d7d..26d86b38 100644 --- a/bootstrap/windows-48/Modules.h +++ b/bootstrap/windows-48/Modules.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Modules__h #define Modules__h diff --git a/bootstrap/windows-48/OPB.c b/bootstrap/windows-48/OPB.c index 4d4925c6..913fbf2d 100644 --- a/bootstrap/windows-48/OPB.c +++ b/bootstrap/windows-48/OPB.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/OPB.h b/bootstrap/windows-48/OPB.h index cb41ad3d..f66fcd66 100644 --- a/bootstrap/windows-48/OPB.h +++ b/bootstrap/windows-48/OPB.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPB__h #define OPB__h diff --git a/bootstrap/windows-48/OPC.c b/bootstrap/windows-48/OPC.c index dc9da7db..7b92ccc1 100644 --- a/bootstrap/windows-48/OPC.c +++ b/bootstrap/windows-48/OPC.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -618,31 +618,33 @@ static void OPC_DefineTProcMacros (OPT_Object obj, BOOLEAN *empty) { if (obj != NIL) { OPC_DefineTProcMacros(obj->left, &*empty); - if ((((obj->mode == 13 && obj == OPC_BaseTProc(obj))) && (OPM_currFile != 0 || obj->vis == 1))) { - OPM_WriteString((CHAR*)"#define __", 11); - OPC_Ident(obj); - OPC_DeclareParams(obj->link, 1); - OPM_WriteString((CHAR*)" __SEND(", 9); - if (obj->link->typ->form == 11) { - OPM_WriteString((CHAR*)"__TYPEOF(", 10); - OPC_Ident(obj->link); + if ((obj->mode == 13 && obj == OPC_BaseTProc(obj))) { + if (OPM_currFile == 1 || (OPM_currFile == 0 && obj->vis == 1)) { + OPM_WriteString((CHAR*)"#define __", 11); + OPC_Ident(obj); + OPC_DeclareParams(obj->link, 1); + OPM_WriteString((CHAR*)" __SEND(", 9); + if (obj->link->typ->form == 11) { + OPM_WriteString((CHAR*)"__TYPEOF(", 10); + OPC_Ident(obj->link); + OPM_Write(')'); + } else { + OPC_Ident(obj->link); + OPM_WriteString((CHAR*)"__typ", 6); + } + OPC_Str1((CHAR*)", #, ", 6, __ASHR(obj->adr, 16)); + if (obj->typ == OPT_notyp) { + OPM_WriteString((CHAR*)"void", 5); + } else { + OPC_Ident(obj->typ->strobj); + } + OPM_WriteString((CHAR*)"(*)", 4); + OPC_AnsiParamList(obj->link, 0); + OPM_WriteString((CHAR*)", ", 3); + OPC_DeclareParams(obj->link, 1); OPM_Write(')'); - } else { - OPC_Ident(obj->link); - OPM_WriteString((CHAR*)"__typ", 6); + OPM_WriteLn(); } - OPC_Str1((CHAR*)", #, ", 6, __ASHR(obj->adr, 16)); - if (obj->typ == OPT_notyp) { - OPM_WriteString((CHAR*)"void", 5); - } else { - OPC_Ident(obj->typ->strobj); - } - OPM_WriteString((CHAR*)"(*)", 4); - OPC_AnsiParamList(obj->link, 0); - OPM_WriteString((CHAR*)", ", 3); - OPC_DeclareParams(obj->link, 1); - OPM_Write(')'); - OPM_WriteLn(); } OPC_DefineTProcMacros(obj->right, &*empty); } @@ -652,7 +654,7 @@ static void OPC_DefineType (OPT_Struct str) { OPT_Object obj = NIL, field = NIL, par = NIL; BOOLEAN empty; - if (OPM_currFile == 1 || str->ref < 255) { + if ((OPM_currFile == 1 || str->ref < 255) || (((OPM_currFile == 0 && str->strobj != NIL)) && str->strobj->vis == 1)) { obj = str->strobj; if (obj == NIL || OPC_Undefined(obj)) { if (obj != NIL) { @@ -719,6 +721,13 @@ static void OPC_DefineType (OPT_Struct str) if (!empty) { OPM_WriteLn(); } + } else if ((obj->typ->form == 11 && obj->typ->BaseTyp->comp == 4)) { + empty = 1; + OPC_DeclareTProcs(obj->typ->BaseTyp->link, &empty); + OPC_DefineTProcMacros(obj->typ->BaseTyp->link, &empty); + if (!empty) { + OPM_WriteLn(); + } } } } diff --git a/bootstrap/windows-48/OPC.h b/bootstrap/windows-48/OPC.h index fd7ddb5e..3bfd88b8 100644 --- a/bootstrap/windows-48/OPC.h +++ b/bootstrap/windows-48/OPC.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPC__h #define OPC__h diff --git a/bootstrap/windows-48/OPM.c b/bootstrap/windows-48/OPM.c index d2462ff6..bcb39247 100644 --- a/bootstrap/windows-48/OPM.c +++ b/bootstrap/windows-48/OPM.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -19,6 +19,8 @@ typedef CHAR OPM_FileName[32]; +static CHAR OPM_currentComment[256]; +static BOOLEAN OPM_hasComment; static CHAR OPM_SourceFileName[256]; static CHAR OPM_GlobalModel[10]; export CHAR OPM_Model[10]; @@ -59,6 +61,7 @@ static void OPM_FindInstallDir (void); static void OPM_FindLine (Files_File f, Files_Rider *r, ADDRESS *r__typ, INT64 pos); static void OPM_FingerprintBytes (INT32 *fp, SYSTEM_BYTE *bytes, ADDRESS bytes__len); export void OPM_Get (CHAR *ch); +export void OPM_GetComment (CHAR *text, ADDRESS text__len); export void OPM_Init (BOOLEAN *done); export void OPM_InitOptions (void); export INT16 OPM_Integer (INT64 n); @@ -82,6 +85,7 @@ static void OPM_ScanOptions (CHAR *s, ADDRESS s__len); static void OPM_ShowLine (INT64 pos); export INT64 OPM_SignedMaximum (INT32 bytecount); export INT64 OPM_SignedMinimum (INT32 bytecount); +export void OPM_StoreComment (CHAR *text, ADDRESS text__len); export void OPM_SymRCh (CHAR *ch); export INT32 OPM_SymRInt (void); export INT64 OPM_SymRInt64 (void); @@ -157,6 +161,36 @@ void OPM_LogCompiling (CHAR *modname, ADDRESS modname__len) __DEL(modname); } +void OPM_StoreComment (CHAR *text, ADDRESS text__len) +{ + INT16 i; + __DUP(text, text__len, CHAR); + i = 0; + while ((i < 255 && text[__X(i, text__len)] != 0x00)) { + OPM_currentComment[__X(i, 256)] = text[__X(i, text__len)]; + i += 1; + } + OPM_currentComment[__X(i, 256)] = 0x00; + OPM_hasComment = 1; + __DEL(text); +} + +void OPM_GetComment (CHAR *text, ADDRESS text__len) +{ + INT16 i; + if (OPM_hasComment) { + i = 0; + while ((((i < text__len && i < 256)) && OPM_currentComment[__X(i, 256)] != 0x00)) { + text[__X(i, text__len)] = OPM_currentComment[__X(i, 256)]; + i += 1; + } + text[__X(i, text__len)] = 0x00; + OPM_hasComment = 0; + } else { + text[0] = 0x00; + } +} + INT64 OPM_SignedMaximum (INT32 bytecount) { INT64 result; @@ -763,7 +797,7 @@ void OPM_OldSym (CHAR *modName, ADDRESS modName__len, BOOLEAN *done) Files_Set(&OPM_oldSF, Files_Rider__typ, OPM_oldSFile, 0); Files_Read(&OPM_oldSF, Files_Rider__typ, (void*)&tag); Files_Read(&OPM_oldSF, Files_Rider__typ, (void*)&ver); - if (tag != 0xf7 || ver != 0x83) { + if (tag != 0xf7 || ver != 0x84) { if (!__IN(4, OPM_Options, 32)) { OPM_err(-306); } @@ -834,7 +868,7 @@ void OPM_NewSym (CHAR *modName, ADDRESS modName__len) if (OPM_newSFile != NIL) { Files_Set(&OPM_newSF, Files_Rider__typ, OPM_newSFile, 0); Files_Write(&OPM_newSF, Files_Rider__typ, 0xf7); - Files_Write(&OPM_newSF, Files_Rider__typ, 0x83); + Files_Write(&OPM_newSF, Files_Rider__typ, 0x84); } else { OPM_err(153); } @@ -1143,5 +1177,7 @@ export void *OPM__init(void) OPM_MinReal = -OPM_MaxReal; OPM_MinLReal = -OPM_MaxLReal; OPM_FindInstallDir(); + OPM_hasComment = 0; + OPM_currentComment[0] = 0x00; __ENDMOD; } diff --git a/bootstrap/windows-48/OPM.h b/bootstrap/windows-48/OPM.h index 14ef9200..64c15a28 100644 --- a/bootstrap/windows-48/OPM.h +++ b/bootstrap/windows-48/OPM.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPM__h #define OPM__h @@ -30,6 +30,7 @@ import void OPM_FPrintLReal (INT32 *fp, LONGREAL val); import void OPM_FPrintReal (INT32 *fp, REAL val); import void OPM_FPrintSet (INT32 *fp, UINT64 val); import void OPM_Get (CHAR *ch); +import void OPM_GetComment (CHAR *text, ADDRESS text__len); import void OPM_Init (BOOLEAN *done); import void OPM_InitOptions (void); import INT16 OPM_Integer (INT64 n); @@ -48,6 +49,7 @@ import BOOLEAN OPM_OpenPar (void); import void OPM_RegisterNewSym (void); import INT64 OPM_SignedMaximum (INT32 bytecount); import INT64 OPM_SignedMinimum (INT32 bytecount); +import void OPM_StoreComment (CHAR *text, ADDRESS text__len); import void OPM_SymRCh (CHAR *ch); import INT32 OPM_SymRInt (void); import INT64 OPM_SymRInt64 (void); diff --git a/bootstrap/windows-48/OPP.c b/bootstrap/windows-48/OPP.c index 2bbed37b..ad4a370a 100644 --- a/bootstrap/windows-48/OPP.c +++ b/bootstrap/windows-48/OPP.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/OPP.h b/bootstrap/windows-48/OPP.h index 5980afc3..3d8cefe8 100644 --- a/bootstrap/windows-48/OPP.h +++ b/bootstrap/windows-48/OPP.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/windows-48/OPS.c b/bootstrap/windows-48/OPS.c index 95456407..a25a2c12 100644 --- a/bootstrap/windows-48/OPS.c +++ b/bootstrap/windows-48/OPS.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -279,32 +279,74 @@ static void Comment__2 (void); static void Comment__2 (void) { + BOOLEAN isExported; + CHAR commentText[256]; + INT16 i, nestLevel; + CHAR prevCh, nextCh; + i = 0; + while (i <= 255) { + commentText[__X(i, 256)] = 0x00; + i += 1; + } + isExported = 0; + i = 0; + nestLevel = 1; + prevCh = 0x00; OPM_Get(&OPS_ch); - for (;;) { - for (;;) { - while (OPS_ch == '(') { + if (OPS_ch == '*') { + isExported = 1; + OPM_Get(&OPS_ch); + if (OPS_ch == ')') { + commentText[0] = 0x00; + OPM_StoreComment(commentText, 256); + OPM_Get(&OPS_ch); + return; + } + } + while ((nestLevel > 0 && OPS_ch != 0x00)) { + if ((prevCh == '(' && OPS_ch == '*')) { + nestLevel += 1; + prevCh = 0x00; + } else if ((prevCh == '*' && OPS_ch == ')')) { + nestLevel -= 1; + if (nestLevel == 0) { OPM_Get(&OPS_ch); - if (OPS_ch == '*') { - Comment__2(); + } else { + prevCh = 0x00; + } + } else { + if ((((isExported && nestLevel == 1)) && prevCh != 0x00)) { + if (i < 255) { + commentText[__X(i, 256)] = prevCh; + i += 1; } } - if (OPS_ch == '*') { - OPM_Get(&OPS_ch); - break; - } - if (OPS_ch == 0x00) { - break; - } + prevCh = OPS_ch; + } + if (nestLevel > 0) { OPM_Get(&OPS_ch); } - if (OPS_ch == ')') { - OPM_Get(&OPS_ch); - break; + } + if (OPS_ch == 0x00) { + OPS_err(5); + } + if ((((((isExported && nestLevel == 0)) && prevCh != 0x00)) && prevCh != '*')) { + if (i < 255) { + commentText[__X(i, 256)] = prevCh; + i += 1; + } else { + OPM_LogWStr((CHAR*)"Truncating final comment character", 35); + OPM_LogWLn(); } - if (OPS_ch == 0x00) { - OPS_err(5); - break; + } + if (isExported) { + if (i >= 256) { + OPM_LogWStr((CHAR*)"Warning: commentText overflow", 30); + OPM_LogWLn(); + i = 255; } + commentText[__X(i, 256)] = 0x00; + OPM_StoreComment(commentText, 256); } } diff --git a/bootstrap/windows-48/OPS.h b/bootstrap/windows-48/OPS.h index f4851b8a..19e222ac 100644 --- a/bootstrap/windows-48/OPS.h +++ b/bootstrap/windows-48/OPS.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/windows-48/OPT.c b/bootstrap/windows-48/OPT.c index 85b0ef1c..ebb47dd8 100644 --- a/bootstrap/windows-48/OPT.c +++ b/bootstrap/windows-48/OPT.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -83,6 +83,7 @@ typedef OPT_Const conval; INT32 adr, linkadr; INT16 x; + OPT_ConstExt comment; } OPT_ObjDesc; typedef @@ -173,6 +174,7 @@ static void OPT_OutObj (OPT_Object obj); 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); +static void OPT_OutTruncatedName (CHAR *text, ADDRESS text__len); export OPT_Struct OPT_SetType (INT32 size); export OPT_Struct OPT_ShorterOrLongerType (OPT_Struct x, INT16 dir); export INT32 OPT_SizeAlignment (INT32 size); @@ -388,6 +390,10 @@ OPT_Object OPT_NewObj (void) { OPT_Object obj = NIL; __NEW(obj, OPT_ObjDesc); + obj->typ = NIL; + obj->conval = NIL; + obj->comment = NIL; + obj->name[0] = 0x00; return obj; } @@ -554,6 +560,8 @@ void OPT_Insert (OPS_Name name, OPT_Object *obj) OPT_Object ob0 = NIL, ob1 = NIL; BOOLEAN left; INT8 mnolev; + CHAR commentText[256]; + INT16 j; ob0 = OPT_topScope; ob1 = ob0->right; left = 0; @@ -585,6 +593,16 @@ void OPT_Insert (OPS_Name name, OPT_Object *obj) __COPY(name, ob1->name, 256); mnolev = OPT_topScope->mnolev; ob1->mnolev = mnolev; + OPM_GetComment((void*)commentText, 256); + if (commentText[0] != 0x00) { + ob1->comment = __NEWARR(NIL, 1, 1, 1, 0, 256); + j = 0; + while ((j < 255 && commentText[__X(j, 256)] != 0x00)) { + (*ob1->comment)[__X(j, 256)] = commentText[__X(j, 256)]; + j += 1; + } + (*ob1->comment)[__X(j, 256)] = 0x00; + } break; } } @@ -1103,6 +1121,13 @@ static void OPT_InSign (INT8 mno, OPT_Struct *res, OPT_Object *par) tag = OPM_SymRInt(); last = NIL; while (tag != 18) { + if (tag < 0 || tag > 100) { + OPM_LogWStr((CHAR*)"ERROR: Invalid tag value in InSign: ", 37); + OPM_LogWNum(tag, 0); + OPM_LogWLn(); + OPM_err(155); + return; + } new = OPT_NewObj(); new->mnolev = -mno; if (last == NIL) { @@ -1381,7 +1406,37 @@ static OPT_Object OPT_InObj (INT8 mno) OPT_Struct typ = NIL; INT32 tag; OPT_ConstExt ext = NIL; + OPS_Name commentText; + BOOLEAN hasComment; + INT16 j; + INT32 len; tag = OPT_impCtxt.nextTag; + hasComment = 0; + while (tag == 41) { + len = OPM_SymRInt(); + if (len < 0) { + len = 0; + } + if (len > 255) { + len = 255; + } + i = 0; + while (i < len) { + OPM_SymRCh(&commentText[__X(i, 256)]); + i += 1; + } + commentText[__X(i, 256)] = 0x00; + hasComment = 1; + tag = OPM_SymRInt(); + } + OPT_impCtxt.nextTag = tag; + if (tag < 0 || tag > 50) { + OPM_LogWStr((CHAR*)"ERROR: Invalid tag in InObj: ", 30); + OPM_LogWNum(tag, 0); + OPM_LogWLn(); + OPM_err(155); + return NIL; + } if (tag == 19) { OPT_InStruct(&typ); obj = typ->strobj; @@ -1397,7 +1452,7 @@ static OPT_Object OPT_InObj (INT8 mno) obj->conval = OPT_NewConst(); OPT_InConstant(tag, obj->conval); obj->typ = OPT_InTyp(tag); - } else if (tag >= 31) { + } else if ((tag >= 31 && tag <= 33)) { obj->conval = OPT_NewConst(); obj->conval->intval = -1; OPT_InSign(mno, &obj->typ, &obj->link); @@ -1424,20 +1479,37 @@ static OPT_Object OPT_InObj (INT8 mno) OPM_LogWStr((CHAR*)"unhandled case at InObj, tag = ", 32); OPM_LogWNum(tag, 0); OPM_LogWLn(); + OPM_err(155); + return NIL; break; } } else if (tag == 20) { obj->mode = 5; OPT_InStruct(&obj->typ); - } else { + } else if (tag == 21 || tag == 22) { obj->mode = 1; if (tag == 22) { obj->vis = 2; } OPT_InStruct(&obj->typ); + } else { + OPM_LogWStr((CHAR*)"ERROR: Unexpected tag in InObj: ", 33); + OPM_LogWNum(tag, 0); + OPM_LogWLn(); + OPM_err(155); + return NIL; } OPT_InName((void*)obj->name, 256); } + if ((hasComment && obj != NIL)) { + obj->comment = __NEWARR(NIL, 1, 1, 1, 0, 256); + j = 0; + while ((((j < 255 && j < len)) && commentText[__X(j, 256)] != 0x00)) { + (*obj->comment)[__X(j, 256)] = commentText[__X(j, 256)]; + j += 1; + } + (*obj->comment)[__X(j, 256)] = 0x00; + } OPT_FPrintObj(obj); if ((obj->mode == 1 && (obj->typ->strobj == NIL || obj->typ->strobj->name[0] == 0x00))) { OPM_FPrint(&OPT_impCtxt.reffp, obj->typ->ref - 255); @@ -1780,13 +1852,40 @@ static void OPT_OutConstant (OPT_Object obj) } } +static void OPT_OutTruncatedName (CHAR *text, ADDRESS text__len) +{ + INT16 i; + __DUP(text, text__len, CHAR); + i = 0; + while ((i < 255 && text[__X(i, text__len)] != 0x00)) { + OPM_SymWCh(text[__X(i, text__len)]); + i += 1; + } + OPM_SymWCh(0x00); + __DEL(text); +} + static void OPT_OutObj (OPT_Object obj) { INT16 i, j; OPT_ConstExt ext = NIL; + INT16 k, l; if (obj != NIL) { OPT_OutObj(obj->left); if (__IN(obj->mode, 0x06ea, 32)) { + if (obj->comment != NIL) { + OPM_SymWInt(41); + k = 0; + while ((k < 255 && (*obj->comment)[__X(k, 256)] != 0x00)) { + k += 1; + } + OPM_SymWInt(k); + l = 0; + while (l < k) { + OPM_SymWCh((*obj->comment)[__X(l, 256)]); + l += 1; + } + } if (obj->history == 4) { OPT_FPrintErr(obj, 250); } else if (obj->vis != 0) { @@ -2026,7 +2125,7 @@ static void EnumPtrs(void (*P)(void*)) } __TDESC(OPT_ConstDesc, 1, 1) = {__TDFLDS("ConstDesc", 40), {0, -8}}; -__TDESC(OPT_ObjDesc, 1, 6) = {__TDFLDS("ObjDesc", 304), {0, 4, 8, 12, 284, 288, -28}}; +__TDESC(OPT_ObjDesc, 1, 7) = {__TDFLDS("ObjDesc", 308), {0, 4, 8, 12, 284, 288, 304, -32}}; __TDESC(OPT_StrDesc, 1, 3) = {__TDFLDS("StrDesc", 56), {44, 48, 52, -16}}; __TDESC(OPT_NodeDesc, 1, 6) = {__TDFLDS("NodeDesc", 28), {0, 4, 8, 16, 20, 24, -28}}; __TDESC(OPT_ImpCtxt, 1, 510) = {__TDFLDS("ImpCtxt", 3140), {16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, diff --git a/bootstrap/windows-48/OPT.h b/bootstrap/windows-48/OPT.h index d2f8d9fe..cf456af5 100644 --- a/bootstrap/windows-48/OPT.h +++ b/bootstrap/windows-48/OPT.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPT__h #define OPT__h @@ -61,6 +61,7 @@ typedef OPT_Const conval; INT32 adr, linkadr; INT16 x; + OPT_ConstExt comment; } OPT_ObjDesc; typedef diff --git a/bootstrap/windows-48/OPV.c b/bootstrap/windows-48/OPV.c index ecef063d..0425b2e0 100644 --- a/bootstrap/windows-48/OPV.c +++ b/bootstrap/windows-48/OPV.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/OPV.h b/bootstrap/windows-48/OPV.h index 44652222..fbabd8f4 100644 --- a/bootstrap/windows-48/OPV.h +++ b/bootstrap/windows-48/OPV.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPV__h #define OPV__h diff --git a/bootstrap/windows-48/Out.c b/bootstrap/windows-48/Out.c index d8b08478..b43e55f1 100644 --- a/bootstrap/windows-48/Out.c +++ b/bootstrap/windows-48/Out.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/Out.h b/bootstrap/windows-48/Out.h index a008c089..a72547f4 100644 --- a/bootstrap/windows-48/Out.h +++ b/bootstrap/windows-48/Out.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Out__h #define Out__h diff --git a/bootstrap/windows-48/Platform.c b/bootstrap/windows-48/Platform.c index e57cfbc4..9b1f0e4f 100644 --- a/bootstrap/windows-48/Platform.c +++ b/bootstrap/windows-48/Platform.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/Platform.h b/bootstrap/windows-48/Platform.h index 543943d3..b1ed4c6f 100644 --- a/bootstrap/windows-48/Platform.h +++ b/bootstrap/windows-48/Platform.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/windows-48/Reals.c b/bootstrap/windows-48/Reals.c index f4cc31eb..512ec2c4 100644 --- a/bootstrap/windows-48/Reals.c +++ b/bootstrap/windows-48/Reals.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/Reals.h b/bootstrap/windows-48/Reals.h index 04ff0d7c..93e7fa75 100644 --- a/bootstrap/windows-48/Reals.h +++ b/bootstrap/windows-48/Reals.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/windows-48/Strings.c b/bootstrap/windows-48/Strings.c index 629009fa..4b18812f 100644 --- a/bootstrap/windows-48/Strings.c +++ b/bootstrap/windows-48/Strings.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/Strings.h b/bootstrap/windows-48/Strings.h index 6acdef43..f0e3ae34 100644 --- a/bootstrap/windows-48/Strings.h +++ b/bootstrap/windows-48/Strings.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/windows-48/Texts.c b/bootstrap/windows-48/Texts.c index 2b57b307..43c3858f 100644 --- a/bootstrap/windows-48/Texts.c +++ b/bootstrap/windows-48/Texts.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/Texts.h b/bootstrap/windows-48/Texts.h index 75712cc1..fd0c0fa5 100644 --- a/bootstrap/windows-48/Texts.h +++ b/bootstrap/windows-48/Texts.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/windows-48/VT100.c b/bootstrap/windows-48/VT100.c index c5e8a3ba..346fb37b 100644 --- a/bootstrap/windows-48/VT100.c +++ b/bootstrap/windows-48/VT100.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/VT100.h b/bootstrap/windows-48/VT100.h index 94b7b846..4e708647 100644 --- a/bootstrap/windows-48/VT100.h +++ b/bootstrap/windows-48/VT100.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef VT100__h #define VT100__h diff --git a/bootstrap/windows-48/extTools.c b/bootstrap/windows-48/extTools.c index cf90fa2a..ce2fc413 100644 --- a/bootstrap/windows-48/extTools.c +++ b/bootstrap/windows-48/extTools.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -73,7 +73,7 @@ static void extTools_execute (CHAR *title, ADDRESS title__len, CHAR *cmd, ADDRES static void extTools_InitialiseCompilerCommand (CHAR *s, ADDRESS s__len, CHAR *additionalopts, ADDRESS additionalopts__len) { __DUP(additionalopts, additionalopts__len, CHAR); - __COPY("gcc -fPIC -g", s, s__len); + __COPY("gcc -fPIC -g -Wno-stringop-overflow", s, s__len); Strings_Append((CHAR*)" -I \"", 6, (void*)s, s__len); Strings_Append(OPM_ResourceDir, 1024, (void*)s, s__len); Strings_Append((CHAR*)"/include\" ", 11, (void*)s, s__len); diff --git a/bootstrap/windows-48/extTools.h b/bootstrap/windows-48/extTools.h index 6b1b37eb..686f0b4e 100644 --- a/bootstrap/windows-48/extTools.h +++ b/bootstrap/windows-48/extTools.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef extTools__h #define extTools__h diff --git a/bootstrap/windows-88/Compiler.c b/bootstrap/windows-88/Compiler.c index 1807e545..4460479d 100644 --- a/bootstrap/windows-88/Compiler.c +++ b/bootstrap/windows-88/Compiler.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspamS */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspamS */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/Configuration.c b/bootstrap/windows-88/Configuration.c index fb7a8f35..fa87c9de 100644 --- a/bootstrap/windows-88/Configuration.c +++ b/bootstrap/windows-88/Configuration.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -19,6 +19,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 76); + __MOVE("2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 76); __ENDMOD; } diff --git a/bootstrap/windows-88/Configuration.h b/bootstrap/windows-88/Configuration.h index c8bae246..c3c54eed 100644 --- a/bootstrap/windows-88/Configuration.h +++ b/bootstrap/windows-88/Configuration.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Configuration__h #define Configuration__h diff --git a/bootstrap/windows-88/Files.c b/bootstrap/windows-88/Files.c index 5412cd99..07655515 100644 --- a/bootstrap/windows-88/Files.c +++ b/bootstrap/windows-88/Files.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/Files.h b/bootstrap/windows-88/Files.h index 2bbdcf3c..8a7e59f8 100644 --- a/bootstrap/windows-88/Files.h +++ b/bootstrap/windows-88/Files.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/windows-88/Heap.c b/bootstrap/windows-88/Heap.c index 980fab89..7b004b60 100644 --- a/bootstrap/windows-88/Heap.c +++ b/bootstrap/windows-88/Heap.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/Heap.h b/bootstrap/windows-88/Heap.h index e188739a..45a9c6d2 100644 --- a/bootstrap/windows-88/Heap.h +++ b/bootstrap/windows-88/Heap.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ #ifndef Heap__h #define Heap__h diff --git a/bootstrap/windows-88/Modules.c b/bootstrap/windows-88/Modules.c index 8617e065..7a49b8ff 100644 --- a/bootstrap/windows-88/Modules.c +++ b/bootstrap/windows-88/Modules.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/Modules.h b/bootstrap/windows-88/Modules.h index 34d0e538..ee65a938 100644 --- a/bootstrap/windows-88/Modules.h +++ b/bootstrap/windows-88/Modules.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Modules__h #define Modules__h diff --git a/bootstrap/windows-88/OPB.c b/bootstrap/windows-88/OPB.c index 4d4925c6..913fbf2d 100644 --- a/bootstrap/windows-88/OPB.c +++ b/bootstrap/windows-88/OPB.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/OPB.h b/bootstrap/windows-88/OPB.h index cb41ad3d..f66fcd66 100644 --- a/bootstrap/windows-88/OPB.h +++ b/bootstrap/windows-88/OPB.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPB__h #define OPB__h diff --git a/bootstrap/windows-88/OPC.c b/bootstrap/windows-88/OPC.c index dc9da7db..7b92ccc1 100644 --- a/bootstrap/windows-88/OPC.c +++ b/bootstrap/windows-88/OPC.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -618,31 +618,33 @@ static void OPC_DefineTProcMacros (OPT_Object obj, BOOLEAN *empty) { if (obj != NIL) { OPC_DefineTProcMacros(obj->left, &*empty); - if ((((obj->mode == 13 && obj == OPC_BaseTProc(obj))) && (OPM_currFile != 0 || obj->vis == 1))) { - OPM_WriteString((CHAR*)"#define __", 11); - OPC_Ident(obj); - OPC_DeclareParams(obj->link, 1); - OPM_WriteString((CHAR*)" __SEND(", 9); - if (obj->link->typ->form == 11) { - OPM_WriteString((CHAR*)"__TYPEOF(", 10); - OPC_Ident(obj->link); + if ((obj->mode == 13 && obj == OPC_BaseTProc(obj))) { + if (OPM_currFile == 1 || (OPM_currFile == 0 && obj->vis == 1)) { + OPM_WriteString((CHAR*)"#define __", 11); + OPC_Ident(obj); + OPC_DeclareParams(obj->link, 1); + OPM_WriteString((CHAR*)" __SEND(", 9); + if (obj->link->typ->form == 11) { + OPM_WriteString((CHAR*)"__TYPEOF(", 10); + OPC_Ident(obj->link); + OPM_Write(')'); + } else { + OPC_Ident(obj->link); + OPM_WriteString((CHAR*)"__typ", 6); + } + OPC_Str1((CHAR*)", #, ", 6, __ASHR(obj->adr, 16)); + if (obj->typ == OPT_notyp) { + OPM_WriteString((CHAR*)"void", 5); + } else { + OPC_Ident(obj->typ->strobj); + } + OPM_WriteString((CHAR*)"(*)", 4); + OPC_AnsiParamList(obj->link, 0); + OPM_WriteString((CHAR*)", ", 3); + OPC_DeclareParams(obj->link, 1); OPM_Write(')'); - } else { - OPC_Ident(obj->link); - OPM_WriteString((CHAR*)"__typ", 6); + OPM_WriteLn(); } - OPC_Str1((CHAR*)", #, ", 6, __ASHR(obj->adr, 16)); - if (obj->typ == OPT_notyp) { - OPM_WriteString((CHAR*)"void", 5); - } else { - OPC_Ident(obj->typ->strobj); - } - OPM_WriteString((CHAR*)"(*)", 4); - OPC_AnsiParamList(obj->link, 0); - OPM_WriteString((CHAR*)", ", 3); - OPC_DeclareParams(obj->link, 1); - OPM_Write(')'); - OPM_WriteLn(); } OPC_DefineTProcMacros(obj->right, &*empty); } @@ -652,7 +654,7 @@ static void OPC_DefineType (OPT_Struct str) { OPT_Object obj = NIL, field = NIL, par = NIL; BOOLEAN empty; - if (OPM_currFile == 1 || str->ref < 255) { + if ((OPM_currFile == 1 || str->ref < 255) || (((OPM_currFile == 0 && str->strobj != NIL)) && str->strobj->vis == 1)) { obj = str->strobj; if (obj == NIL || OPC_Undefined(obj)) { if (obj != NIL) { @@ -719,6 +721,13 @@ static void OPC_DefineType (OPT_Struct str) if (!empty) { OPM_WriteLn(); } + } else if ((obj->typ->form == 11 && obj->typ->BaseTyp->comp == 4)) { + empty = 1; + OPC_DeclareTProcs(obj->typ->BaseTyp->link, &empty); + OPC_DefineTProcMacros(obj->typ->BaseTyp->link, &empty); + if (!empty) { + OPM_WriteLn(); + } } } } diff --git a/bootstrap/windows-88/OPC.h b/bootstrap/windows-88/OPC.h index fd7ddb5e..3bfd88b8 100644 --- a/bootstrap/windows-88/OPC.h +++ b/bootstrap/windows-88/OPC.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPC__h #define OPC__h diff --git a/bootstrap/windows-88/OPM.c b/bootstrap/windows-88/OPM.c index f298d2d5..b486b3b9 100644 --- a/bootstrap/windows-88/OPM.c +++ b/bootstrap/windows-88/OPM.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -19,6 +19,8 @@ typedef CHAR OPM_FileName[32]; +static CHAR OPM_currentComment[256]; +static BOOLEAN OPM_hasComment; static CHAR OPM_SourceFileName[256]; static CHAR OPM_GlobalModel[10]; export CHAR OPM_Model[10]; @@ -59,6 +61,7 @@ static void OPM_FindInstallDir (void); static void OPM_FindLine (Files_File f, Files_Rider *r, ADDRESS *r__typ, INT64 pos); static void OPM_FingerprintBytes (INT32 *fp, SYSTEM_BYTE *bytes, ADDRESS bytes__len); export void OPM_Get (CHAR *ch); +export void OPM_GetComment (CHAR *text, ADDRESS text__len); export void OPM_Init (BOOLEAN *done); export void OPM_InitOptions (void); export INT16 OPM_Integer (INT64 n); @@ -82,6 +85,7 @@ static void OPM_ScanOptions (CHAR *s, ADDRESS s__len); static void OPM_ShowLine (INT64 pos); export INT64 OPM_SignedMaximum (INT32 bytecount); export INT64 OPM_SignedMinimum (INT32 bytecount); +export void OPM_StoreComment (CHAR *text, ADDRESS text__len); export void OPM_SymRCh (CHAR *ch); export INT32 OPM_SymRInt (void); export INT64 OPM_SymRInt64 (void); @@ -157,6 +161,36 @@ void OPM_LogCompiling (CHAR *modname, ADDRESS modname__len) __DEL(modname); } +void OPM_StoreComment (CHAR *text, ADDRESS text__len) +{ + INT16 i; + __DUP(text, text__len, CHAR); + i = 0; + while ((i < 255 && text[__X(i, text__len)] != 0x00)) { + OPM_currentComment[__X(i, 256)] = text[__X(i, text__len)]; + i += 1; + } + OPM_currentComment[__X(i, 256)] = 0x00; + OPM_hasComment = 1; + __DEL(text); +} + +void OPM_GetComment (CHAR *text, ADDRESS text__len) +{ + INT16 i; + if (OPM_hasComment) { + i = 0; + while ((((i < text__len && i < 256)) && OPM_currentComment[__X(i, 256)] != 0x00)) { + text[__X(i, text__len)] = OPM_currentComment[__X(i, 256)]; + i += 1; + } + text[__X(i, text__len)] = 0x00; + OPM_hasComment = 0; + } else { + text[0] = 0x00; + } +} + INT64 OPM_SignedMaximum (INT32 bytecount) { INT64 result; @@ -763,7 +797,7 @@ void OPM_OldSym (CHAR *modName, ADDRESS modName__len, BOOLEAN *done) Files_Set(&OPM_oldSF, Files_Rider__typ, OPM_oldSFile, 0); Files_Read(&OPM_oldSF, Files_Rider__typ, (void*)&tag); Files_Read(&OPM_oldSF, Files_Rider__typ, (void*)&ver); - if (tag != 0xf7 || ver != 0x83) { + if (tag != 0xf7 || ver != 0x84) { if (!__IN(4, OPM_Options, 32)) { OPM_err(-306); } @@ -834,7 +868,7 @@ void OPM_NewSym (CHAR *modName, ADDRESS modName__len) if (OPM_newSFile != NIL) { Files_Set(&OPM_newSF, Files_Rider__typ, OPM_newSFile, 0); Files_Write(&OPM_newSF, Files_Rider__typ, 0xf7); - Files_Write(&OPM_newSF, Files_Rider__typ, 0x83); + Files_Write(&OPM_newSF, Files_Rider__typ, 0x84); } else { OPM_err(153); } @@ -1143,5 +1177,7 @@ export void *OPM__init(void) OPM_MinReal = -OPM_MaxReal; OPM_MinLReal = -OPM_MaxLReal; OPM_FindInstallDir(); + OPM_hasComment = 0; + OPM_currentComment[0] = 0x00; __ENDMOD; } diff --git a/bootstrap/windows-88/OPM.h b/bootstrap/windows-88/OPM.h index 14ef9200..64c15a28 100644 --- a/bootstrap/windows-88/OPM.h +++ b/bootstrap/windows-88/OPM.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPM__h #define OPM__h @@ -30,6 +30,7 @@ import void OPM_FPrintLReal (INT32 *fp, LONGREAL val); import void OPM_FPrintReal (INT32 *fp, REAL val); import void OPM_FPrintSet (INT32 *fp, UINT64 val); import void OPM_Get (CHAR *ch); +import void OPM_GetComment (CHAR *text, ADDRESS text__len); import void OPM_Init (BOOLEAN *done); import void OPM_InitOptions (void); import INT16 OPM_Integer (INT64 n); @@ -48,6 +49,7 @@ import BOOLEAN OPM_OpenPar (void); import void OPM_RegisterNewSym (void); import INT64 OPM_SignedMaximum (INT32 bytecount); import INT64 OPM_SignedMinimum (INT32 bytecount); +import void OPM_StoreComment (CHAR *text, ADDRESS text__len); import void OPM_SymRCh (CHAR *ch); import INT32 OPM_SymRInt (void); import INT64 OPM_SymRInt64 (void); diff --git a/bootstrap/windows-88/OPP.c b/bootstrap/windows-88/OPP.c index f98062ab..3fed2e31 100644 --- a/bootstrap/windows-88/OPP.c +++ b/bootstrap/windows-88/OPP.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/OPP.h b/bootstrap/windows-88/OPP.h index 5980afc3..3d8cefe8 100644 --- a/bootstrap/windows-88/OPP.h +++ b/bootstrap/windows-88/OPP.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/windows-88/OPS.c b/bootstrap/windows-88/OPS.c index 95456407..a25a2c12 100644 --- a/bootstrap/windows-88/OPS.c +++ b/bootstrap/windows-88/OPS.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -279,32 +279,74 @@ static void Comment__2 (void); static void Comment__2 (void) { + BOOLEAN isExported; + CHAR commentText[256]; + INT16 i, nestLevel; + CHAR prevCh, nextCh; + i = 0; + while (i <= 255) { + commentText[__X(i, 256)] = 0x00; + i += 1; + } + isExported = 0; + i = 0; + nestLevel = 1; + prevCh = 0x00; OPM_Get(&OPS_ch); - for (;;) { - for (;;) { - while (OPS_ch == '(') { + if (OPS_ch == '*') { + isExported = 1; + OPM_Get(&OPS_ch); + if (OPS_ch == ')') { + commentText[0] = 0x00; + OPM_StoreComment(commentText, 256); + OPM_Get(&OPS_ch); + return; + } + } + while ((nestLevel > 0 && OPS_ch != 0x00)) { + if ((prevCh == '(' && OPS_ch == '*')) { + nestLevel += 1; + prevCh = 0x00; + } else if ((prevCh == '*' && OPS_ch == ')')) { + nestLevel -= 1; + if (nestLevel == 0) { OPM_Get(&OPS_ch); - if (OPS_ch == '*') { - Comment__2(); + } else { + prevCh = 0x00; + } + } else { + if ((((isExported && nestLevel == 1)) && prevCh != 0x00)) { + if (i < 255) { + commentText[__X(i, 256)] = prevCh; + i += 1; } } - if (OPS_ch == '*') { - OPM_Get(&OPS_ch); - break; - } - if (OPS_ch == 0x00) { - break; - } + prevCh = OPS_ch; + } + if (nestLevel > 0) { OPM_Get(&OPS_ch); } - if (OPS_ch == ')') { - OPM_Get(&OPS_ch); - break; + } + if (OPS_ch == 0x00) { + OPS_err(5); + } + if ((((((isExported && nestLevel == 0)) && prevCh != 0x00)) && prevCh != '*')) { + if (i < 255) { + commentText[__X(i, 256)] = prevCh; + i += 1; + } else { + OPM_LogWStr((CHAR*)"Truncating final comment character", 35); + OPM_LogWLn(); } - if (OPS_ch == 0x00) { - OPS_err(5); - break; + } + if (isExported) { + if (i >= 256) { + OPM_LogWStr((CHAR*)"Warning: commentText overflow", 30); + OPM_LogWLn(); + i = 255; } + commentText[__X(i, 256)] = 0x00; + OPM_StoreComment(commentText, 256); } } diff --git a/bootstrap/windows-88/OPS.h b/bootstrap/windows-88/OPS.h index f4851b8a..19e222ac 100644 --- a/bootstrap/windows-88/OPS.h +++ b/bootstrap/windows-88/OPS.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/windows-88/OPT.c b/bootstrap/windows-88/OPT.c index 3b837866..c3999981 100644 --- a/bootstrap/windows-88/OPT.c +++ b/bootstrap/windows-88/OPT.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -83,6 +83,7 @@ typedef OPT_Const conval; INT32 adr, linkadr; INT16 x; + OPT_ConstExt comment; } OPT_ObjDesc; typedef @@ -173,6 +174,7 @@ static void OPT_OutObj (OPT_Object obj); 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); +static void OPT_OutTruncatedName (CHAR *text, ADDRESS text__len); export OPT_Struct OPT_SetType (INT32 size); export OPT_Struct OPT_ShorterOrLongerType (OPT_Struct x, INT16 dir); export INT32 OPT_SizeAlignment (INT32 size); @@ -388,6 +390,10 @@ OPT_Object OPT_NewObj (void) { OPT_Object obj = NIL; __NEW(obj, OPT_ObjDesc); + obj->typ = NIL; + obj->conval = NIL; + obj->comment = NIL; + obj->name[0] = 0x00; return obj; } @@ -554,6 +560,8 @@ void OPT_Insert (OPS_Name name, OPT_Object *obj) OPT_Object ob0 = NIL, ob1 = NIL; BOOLEAN left; INT8 mnolev; + CHAR commentText[256]; + INT16 j; ob0 = OPT_topScope; ob1 = ob0->right; left = 0; @@ -585,6 +593,16 @@ void OPT_Insert (OPS_Name name, OPT_Object *obj) __COPY(name, ob1->name, 256); mnolev = OPT_topScope->mnolev; ob1->mnolev = mnolev; + OPM_GetComment((void*)commentText, 256); + if (commentText[0] != 0x00) { + ob1->comment = __NEWARR(NIL, 1, 1, 1, 0, ((INT64)(256))); + j = 0; + while ((j < 255 && commentText[__X(j, 256)] != 0x00)) { + (*ob1->comment)[__X(j, 256)] = commentText[__X(j, 256)]; + j += 1; + } + (*ob1->comment)[__X(j, 256)] = 0x00; + } break; } } @@ -1103,6 +1121,13 @@ static void OPT_InSign (INT8 mno, OPT_Struct *res, OPT_Object *par) tag = OPM_SymRInt(); last = NIL; while (tag != 18) { + if (tag < 0 || tag > 100) { + OPM_LogWStr((CHAR*)"ERROR: Invalid tag value in InSign: ", 37); + OPM_LogWNum(tag, 0); + OPM_LogWLn(); + OPM_err(155); + return; + } new = OPT_NewObj(); new->mnolev = -mno; if (last == NIL) { @@ -1381,7 +1406,37 @@ static OPT_Object OPT_InObj (INT8 mno) OPT_Struct typ = NIL; INT32 tag; OPT_ConstExt ext = NIL; + OPS_Name commentText; + BOOLEAN hasComment; + INT16 j; + INT32 len; tag = OPT_impCtxt.nextTag; + hasComment = 0; + while (tag == 41) { + len = OPM_SymRInt(); + if (len < 0) { + len = 0; + } + if (len > 255) { + len = 255; + } + i = 0; + while (i < len) { + OPM_SymRCh(&commentText[__X(i, 256)]); + i += 1; + } + commentText[__X(i, 256)] = 0x00; + hasComment = 1; + tag = OPM_SymRInt(); + } + OPT_impCtxt.nextTag = tag; + if (tag < 0 || tag > 50) { + OPM_LogWStr((CHAR*)"ERROR: Invalid tag in InObj: ", 30); + OPM_LogWNum(tag, 0); + OPM_LogWLn(); + OPM_err(155); + return NIL; + } if (tag == 19) { OPT_InStruct(&typ); obj = typ->strobj; @@ -1397,7 +1452,7 @@ static OPT_Object OPT_InObj (INT8 mno) obj->conval = OPT_NewConst(); OPT_InConstant(tag, obj->conval); obj->typ = OPT_InTyp(tag); - } else if (tag >= 31) { + } else if ((tag >= 31 && tag <= 33)) { obj->conval = OPT_NewConst(); obj->conval->intval = -1; OPT_InSign(mno, &obj->typ, &obj->link); @@ -1424,20 +1479,37 @@ static OPT_Object OPT_InObj (INT8 mno) OPM_LogWStr((CHAR*)"unhandled case at InObj, tag = ", 32); OPM_LogWNum(tag, 0); OPM_LogWLn(); + OPM_err(155); + return NIL; break; } } else if (tag == 20) { obj->mode = 5; OPT_InStruct(&obj->typ); - } else { + } else if (tag == 21 || tag == 22) { obj->mode = 1; if (tag == 22) { obj->vis = 2; } OPT_InStruct(&obj->typ); + } else { + OPM_LogWStr((CHAR*)"ERROR: Unexpected tag in InObj: ", 33); + OPM_LogWNum(tag, 0); + OPM_LogWLn(); + OPM_err(155); + return NIL; } OPT_InName((void*)obj->name, 256); } + if ((hasComment && obj != NIL)) { + obj->comment = __NEWARR(NIL, 1, 1, 1, 0, ((INT64)(256))); + j = 0; + while ((((j < 255 && j < len)) && commentText[__X(j, 256)] != 0x00)) { + (*obj->comment)[__X(j, 256)] = commentText[__X(j, 256)]; + j += 1; + } + (*obj->comment)[__X(j, 256)] = 0x00; + } OPT_FPrintObj(obj); if ((obj->mode == 1 && (obj->typ->strobj == NIL || obj->typ->strobj->name[0] == 0x00))) { OPM_FPrint(&OPT_impCtxt.reffp, obj->typ->ref - 255); @@ -1780,13 +1852,40 @@ static void OPT_OutConstant (OPT_Object obj) } } +static void OPT_OutTruncatedName (CHAR *text, ADDRESS text__len) +{ + INT16 i; + __DUP(text, text__len, CHAR); + i = 0; + while ((i < 255 && text[__X(i, text__len)] != 0x00)) { + OPM_SymWCh(text[__X(i, text__len)]); + i += 1; + } + OPM_SymWCh(0x00); + __DEL(text); +} + static void OPT_OutObj (OPT_Object obj) { INT16 i, j; OPT_ConstExt ext = NIL; + INT16 k, l; if (obj != NIL) { OPT_OutObj(obj->left); if (__IN(obj->mode, 0x06ea, 32)) { + if (obj->comment != NIL) { + OPM_SymWInt(41); + k = 0; + while ((k < 255 && (*obj->comment)[__X(k, 256)] != 0x00)) { + k += 1; + } + OPM_SymWInt(k); + l = 0; + while (l < k) { + OPM_SymWCh((*obj->comment)[__X(l, 256)]); + l += 1; + } + } if (obj->history == 4) { OPT_FPrintErr(obj, 250); } else if (obj->vis != 0) { @@ -2026,7 +2125,7 @@ static void EnumPtrs(void (*P)(void*)) } __TDESC(OPT_ConstDesc, 1, 1) = {__TDFLDS("ConstDesc", 40), {0, -16}}; -__TDESC(OPT_ObjDesc, 1, 6) = {__TDFLDS("ObjDesc", 336), {0, 8, 16, 24, 304, 312, -56}}; +__TDESC(OPT_ObjDesc, 1, 7) = {__TDFLDS("ObjDesc", 344), {0, 8, 16, 24, 304, 312, 336, -64}}; __TDESC(OPT_StrDesc, 1, 3) = {__TDFLDS("StrDesc", 72), {48, 56, 64, -32}}; __TDESC(OPT_NodeDesc, 1, 6) = {__TDFLDS("NodeDesc", 56), {0, 8, 16, 32, 40, 48, -56}}; __TDESC(OPT_ImpCtxt, 1, 510) = {__TDFLDS("ImpCtxt", 5184), {16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, diff --git a/bootstrap/windows-88/OPT.h b/bootstrap/windows-88/OPT.h index d2f8d9fe..cf456af5 100644 --- a/bootstrap/windows-88/OPT.h +++ b/bootstrap/windows-88/OPT.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPT__h #define OPT__h @@ -61,6 +61,7 @@ typedef OPT_Const conval; INT32 adr, linkadr; INT16 x; + OPT_ConstExt comment; } OPT_ObjDesc; typedef diff --git a/bootstrap/windows-88/OPV.c b/bootstrap/windows-88/OPV.c index 2535e861..26c1c715 100644 --- a/bootstrap/windows-88/OPV.c +++ b/bootstrap/windows-88/OPV.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/OPV.h b/bootstrap/windows-88/OPV.h index 44652222..fbabd8f4 100644 --- a/bootstrap/windows-88/OPV.h +++ b/bootstrap/windows-88/OPV.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPV__h #define OPV__h diff --git a/bootstrap/windows-88/Out.c b/bootstrap/windows-88/Out.c index d8b08478..b43e55f1 100644 --- a/bootstrap/windows-88/Out.c +++ b/bootstrap/windows-88/Out.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/Out.h b/bootstrap/windows-88/Out.h index a008c089..a72547f4 100644 --- a/bootstrap/windows-88/Out.h +++ b/bootstrap/windows-88/Out.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Out__h #define Out__h diff --git a/bootstrap/windows-88/Platform.c b/bootstrap/windows-88/Platform.c index 358785ee..563f6417 100644 --- a/bootstrap/windows-88/Platform.c +++ b/bootstrap/windows-88/Platform.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/Platform.h b/bootstrap/windows-88/Platform.h index 7bd26e48..1259a228 100644 --- a/bootstrap/windows-88/Platform.h +++ b/bootstrap/windows-88/Platform.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/windows-88/Reals.c b/bootstrap/windows-88/Reals.c index f4cc31eb..512ec2c4 100644 --- a/bootstrap/windows-88/Reals.c +++ b/bootstrap/windows-88/Reals.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/Reals.h b/bootstrap/windows-88/Reals.h index 04ff0d7c..93e7fa75 100644 --- a/bootstrap/windows-88/Reals.h +++ b/bootstrap/windows-88/Reals.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/windows-88/Strings.c b/bootstrap/windows-88/Strings.c index 629009fa..4b18812f 100644 --- a/bootstrap/windows-88/Strings.c +++ b/bootstrap/windows-88/Strings.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/Strings.h b/bootstrap/windows-88/Strings.h index 6acdef43..f0e3ae34 100644 --- a/bootstrap/windows-88/Strings.h +++ b/bootstrap/windows-88/Strings.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/windows-88/Texts.c b/bootstrap/windows-88/Texts.c index 291ccf2b..77dc1bac 100644 --- a/bootstrap/windows-88/Texts.c +++ b/bootstrap/windows-88/Texts.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/Texts.h b/bootstrap/windows-88/Texts.h index 56bb9359..081eec2c 100644 --- a/bootstrap/windows-88/Texts.h +++ b/bootstrap/windows-88/Texts.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/windows-88/VT100.c b/bootstrap/windows-88/VT100.c index c5e8a3ba..346fb37b 100644 --- a/bootstrap/windows-88/VT100.c +++ b/bootstrap/windows-88/VT100.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/VT100.h b/bootstrap/windows-88/VT100.h index 94b7b846..4e708647 100644 --- a/bootstrap/windows-88/VT100.h +++ b/bootstrap/windows-88/VT100.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef VT100__h #define VT100__h diff --git a/bootstrap/windows-88/extTools.c b/bootstrap/windows-88/extTools.c index cf90fa2a..ce2fc413 100644 --- a/bootstrap/windows-88/extTools.c +++ b/bootstrap/windows-88/extTools.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -73,7 +73,7 @@ static void extTools_execute (CHAR *title, ADDRESS title__len, CHAR *cmd, ADDRES static void extTools_InitialiseCompilerCommand (CHAR *s, ADDRESS s__len, CHAR *additionalopts, ADDRESS additionalopts__len) { __DUP(additionalopts, additionalopts__len, CHAR); - __COPY("gcc -fPIC -g", s, s__len); + __COPY("gcc -fPIC -g -Wno-stringop-overflow", s, s__len); Strings_Append((CHAR*)" -I \"", 6, (void*)s, s__len); Strings_Append(OPM_ResourceDir, 1024, (void*)s, s__len); Strings_Append((CHAR*)"/include\" ", 11, (void*)s, s__len); diff --git a/bootstrap/windows-88/extTools.h b/bootstrap/windows-88/extTools.h index 6b1b37eb..686f0b4e 100644 --- a/bootstrap/windows-88/extTools.h +++ b/bootstrap/windows-88/extTools.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2024/08/23]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef extTools__h #define extTools__h diff --git a/src/library/ooc/oocIntStr.Mod b/src/library/ooc/oocIntStr.Mod index b5f9d928..2b8213ca 100644 --- a/src/library/ooc/oocIntStr.Mod +++ b/src/library/ooc/oocIntStr.Mod @@ -22,28 +22,28 @@ IMPORT Conv := oocConvTypes, IntConv := oocIntConv; TYPE - ConvResults*= Conv.ConvResults; (** possible values: strAllRight, strOutOfRange, strWrongFormat, strEmpty *) + ConvResults*= Conv.ConvResults; CONST - strAllRight*=Conv.strAllRight; (** the string format is correct for the corresponding conversion *) - strOutOfRange*=Conv.strOutOfRange; + strAllRight*=Conv.strAllRight; (** the string is well-formed but the value cannot be represented *) - strWrongFormat*=Conv.strWrongFormat; + strOutOfRange*=Conv.strOutOfRange; (** the string is in the wrong format for the conversion *) - strEmpty*=Conv.strEmpty; + strWrongFormat*=Conv.strWrongFormat; (** the given string is empty *) + strEmpty*=Conv.strEmpty; (** the string form of a signed whole number is ["+" | "-"] decimal_digit {decimal_digit} *) - -PROCEDURE StrToInt*(str: ARRAY OF CHAR; VAR int: LONGINT; VAR res: ConvResults); (** Ignores any leading spaces in `str'. If the subsequent characters in `str' are in the format of a signed whole number, assigns a corresponding value to `int'. Assigns a value indicating the format of `str' to `res'. *) + +PROCEDURE StrToInt*(str: ARRAY OF CHAR; VAR int: LONGINT; VAR res: ConvResults); BEGIN res:=IntConv.FormatInt(str); IF (res = strAllRight) THEN @@ -53,7 +53,7 @@ END StrToInt; PROCEDURE Reverse (VAR str : ARRAY OF CHAR; start, end : INTEGER); -(** Reverses order of characters in the interval [start..end]. *) +(* Reverses order of characters in the interval [start..end]. *) VAR h : CHAR; BEGIN @@ -63,10 +63,10 @@ BEGIN END END Reverse; - -PROCEDURE IntToStr*(int: LONGINT; VAR str: ARRAY OF CHAR); (** Converts the value of `int' to string form and copies the possibly truncated result to `str'. *) + +PROCEDURE IntToStr*(int: LONGINT; VAR str: ARRAY OF CHAR); CONST maxLength = 11; (* maximum number of digits representing a LONGINT value *) VAR