diff --git a/bootstrap/SYSTEM.h b/bootstrap/SYSTEM.h index d9778393..43baa836 100644 --- a/bootstrap/SYSTEM.h +++ b/bootstrap/SYSTEM.h @@ -103,11 +103,11 @@ extern void Platform_OSFree (ADDRESS addr); // Assertions and Halts -extern void Platform_Halt(INT32 x); -extern void Platform_AssertFail(INT32 x); +extern void Modules_Halt(INT32 x); +extern void Modules_AssertFail(INT32 x); -#define __HALT(x) Platform_Halt(x) -#define __ASSERT(cond, x) if (!(cond)) Platform_AssertFail((INT32)(x)) +#define __HALT(x) Modules_Halt((INT32)(x)) +#define __ASSERT(cond, x) if (!(cond)) Modules_AssertFail((INT32)(x)) // Index checking diff --git a/bootstrap/unix-44/Compiler.c b/bootstrap/unix-44/Compiler.c index 87b0392c..a6d5a403 100644 --- a/bootstrap/unix-44/Compiler.c +++ b/bootstrap/unix-44/Compiler.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspamSf */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspamSf */ #define SHORTINT INT8 #define INTEGER INT16 @@ -153,7 +153,7 @@ static void Compiler_Trap (INT32 sig) if (sig == 3) { Platform_Exit(0); } else { - if ((sig == 4 && Platform_HaltCode == -15)) { + if (sig == 4) { OPM_LogWStr((CHAR*)" --- Oberon compiler internal error", 36); OPM_LogWLn(); } diff --git a/bootstrap/unix-44/Configuration.c b/bootstrap/unix-44/Configuration.c index c15b87f9..d84a7f24 100644 --- a/bootstrap/unix-44/Configuration.c +++ b/bootstrap/unix-44/Configuration.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -19,6 +19,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); + __MOVE("1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); __ENDMOD; } diff --git a/bootstrap/unix-44/Configuration.h b/bootstrap/unix-44/Configuration.h index f169a3b6..09543f0b 100644 --- a/bootstrap/unix-44/Configuration.h +++ b/bootstrap/unix-44/Configuration.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Configuration__h #define Configuration__h diff --git a/bootstrap/unix-44/Files.c b/bootstrap/unix-44/Files.c index 5aedd8ec..3ce83372 100644 --- a/bootstrap/unix-44/Files.c +++ b/bootstrap/unix-44/Files.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/Files.h b/bootstrap/unix-44/Files.h index 88034b00..c04d545c 100644 --- a/bootstrap/unix-44/Files.h +++ b/bootstrap/unix-44/Files.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/unix-44/Heap.c b/bootstrap/unix-44/Heap.c index 45b45394..2a5c9464 100644 --- a/bootstrap/unix-44/Heap.c +++ b/bootstrap/unix-44/Heap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -108,8 +108,8 @@ extern void *Heap__init(); extern ADDRESS Platform_MainStackFrame; extern ADDRESS Platform_OSAllocate(ADDRESS size); #define Heap_HeapModuleInit() Heap__init() +#define Heap_ModulesHalt(code) Modules_Halt(code) #define Heap_OSAllocate(size) Platform_OSAllocate(size) -#define Heap_PlatformHalt(code) Platform_Halt(code) #define Heap_PlatformMainStackFrame() Platform_MainStackFrame void Heap_Lock (void) @@ -121,7 +121,7 @@ void Heap_Unlock (void) { Heap_lockdepth -= 1; if ((Heap_interrupted && Heap_lockdepth == 0)) { - Heap_PlatformHalt(-9); + Heap_ModulesHalt(-9); } } diff --git a/bootstrap/unix-44/Heap.h b/bootstrap/unix-44/Heap.h index 8626628d..5f888271 100644 --- a/bootstrap/unix-44/Heap.h +++ b/bootstrap/unix-44/Heap.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ #ifndef Heap__h #define Heap__h diff --git a/bootstrap/unix-44/Modules.c b/bootstrap/unix-44/Modules.c index 5eddf9be..23c71a96 100644 --- a/bootstrap/unix-44/Modules.c +++ b/bootstrap/unix-44/Modules.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -7,6 +7,7 @@ #include "SYSTEM.h" #include "Heap.h" +#include "Platform.h" typedef struct Modules_CmdDesc *Modules_Cmd; @@ -47,9 +48,16 @@ export ADDRESS *Modules_ModuleDesc__typ; export ADDRESS *Modules_CmdDesc__typ; static void Modules_Append (CHAR *a, LONGINT a__len, CHAR *b, LONGINT b__len); +export void Modules_AssertFail (INT32 code); +static void Modules_DisplayHaltCode (INT32 code); export void Modules_Free (CHAR *name, LONGINT name__len, BOOLEAN all); +export void Modules_Halt (INT32 code); export Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, LONGINT name__len); export Modules_Module Modules_ThisMod (CHAR *name, LONGINT name__len); +static void Modules_errch (CHAR c); +export void Modules_errint (INT32 l); +static void Modules_errposint (INT32 l); +export void Modules_errstring (CHAR *s, LONGINT s__len); #define Modules_modules() (Modules_Module)Heap_modules #define Modules_setmodules(m) Heap_modules = m @@ -155,6 +163,121 @@ void Modules_Free (CHAR *name, LONGINT name__len, BOOLEAN all) __DEL(name); } +static void Modules_errch (CHAR c) +{ + INT16 e; + e = Platform_Write(1, (ADDRESS)&c, 1); +} + +void Modules_errstring (CHAR *s, LONGINT s__len) +{ + INT32 i; + __DUP(s, s__len, CHAR); + i = 0; + while ((i < s__len && s[__X(i, s__len)] != 0x00)) { + Modules_errch(s[__X(i, s__len)]); + i += 1; + } + __DEL(s); +} + +static void Modules_errposint (INT32 l) +{ + if (l > 10) { + Modules_errposint(__DIV(l, 10)); + } + Modules_errch((CHAR)(48 + (int)__MOD(l, 10))); +} + +void Modules_errint (INT32 l) +{ + if (l < 0) { + Modules_errch('-'); + l = -l; + } + Modules_errposint(l); +} + +static void Modules_DisplayHaltCode (INT32 code) +{ + switch (code) { + case -1: + Modules_errstring((CHAR*)"Assertion failure.", 19); + break; + case -2: + Modules_errstring((CHAR*)"Index out of range.", 20); + break; + case -3: + Modules_errstring((CHAR*)"Reached end of function without reaching RETURN.", 49); + break; + case -4: + Modules_errstring((CHAR*)"CASE statement: no matching label and no ELSE.", 47); + break; + case -5: + Modules_errstring((CHAR*)"Type guard failed.", 19); + break; + case -6: + Modules_errstring((CHAR*)"Implicit type guard in record assignment failed.", 49); + break; + case -7: + Modules_errstring((CHAR*)"Invalid case in WITH statement.", 32); + break; + case -8: + Modules_errstring((CHAR*)"Value out of range.", 20); + break; + case -9: + Modules_errstring((CHAR*)"Heap interrupted while locked, but lockdepth = 0 at unlock.", 60); + break; + case -10: + Modules_errstring((CHAR*)"NIL access.", 12); + break; + case -11: + Modules_errstring((CHAR*)"Alignment error.", 17); + break; + case -12: + Modules_errstring((CHAR*)"Divide by zero.", 16); + break; + case -13: + Modules_errstring((CHAR*)"Arithmetic overflow/underflow.", 31); + break; + case -14: + Modules_errstring((CHAR*)"Invalid function argument.", 27); + break; + case -15: + Modules_errstring((CHAR*)"Internal error, e.g. Type descriptor size mismatch.", 52); + break; + case -20: + Modules_errstring((CHAR*)"Too many, or negative number of, elements in dynamic array.", 60); + break; + default: + break; + } +} + +void Modules_Halt (INT32 code) +{ + Modules_errstring((CHAR*)"Terminated by Halt(", 20); + Modules_errint(code); + Modules_errstring((CHAR*)"). ", 4); + if (code < 0) { + Modules_DisplayHaltCode(code); + } + Modules_errstring(Platform_NL, 3); + Platform_Exit(code); +} + +void Modules_AssertFail (INT32 code) +{ + Modules_errstring((CHAR*)"Assertion failure.", 19); + if (code != 0) { + Modules_errstring((CHAR*)" ASSERT code ", 14); + Modules_errint(code); + Modules_errstring((CHAR*)".", 2); + } + Modules_errstring(Platform_NL, 3); + Platform_Exit(code); +} + __TDESC(Modules_ModuleDesc, 1, 2) = {__TDFLDS("ModuleDesc", 48), {0, 28, -12}}; __TDESC(Modules_CmdDesc, 1, 1) = {__TDFLDS("CmdDesc", 32), {0, -8}}; @@ -162,6 +285,7 @@ export void *Modules__init(void) { __DEFMOD; __MODULE_IMPORT(Heap); + __MODULE_IMPORT(Platform); __REGMOD("Modules", 0); __INITYP(Modules_ModuleDesc, Modules_ModuleDesc, 0); __INITYP(Modules_CmdDesc, Modules_CmdDesc, 0); diff --git a/bootstrap/unix-44/Modules.h b/bootstrap/unix-44/Modules.h index 2da3fa50..6809ec05 100644 --- a/bootstrap/unix-44/Modules.h +++ b/bootstrap/unix-44/Modules.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Modules__h #define Modules__h @@ -43,9 +43,13 @@ import Modules_ModuleName Modules_imported, Modules_importing; import ADDRESS *Modules_ModuleDesc__typ; import ADDRESS *Modules_CmdDesc__typ; +import void Modules_AssertFail (INT32 code); import void Modules_Free (CHAR *name, LONGINT name__len, BOOLEAN all); +import void Modules_Halt (INT32 code); import Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, LONGINT name__len); import Modules_Module Modules_ThisMod (CHAR *name, LONGINT name__len); +import void Modules_errint (INT32 l); +import void Modules_errstring (CHAR *s, LONGINT s__len); import void *Modules__init(void); #define Modules_modules() (Modules_Module)Heap_modules diff --git a/bootstrap/unix-44/OPB.c b/bootstrap/unix-44/OPB.c index dcac4eb9..8a1b80fe 100644 --- a/bootstrap/unix-44/OPB.c +++ b/bootstrap/unix-44/OPB.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/OPB.h b/bootstrap/unix-44/OPB.h index cb6399f9..0caeb234 100644 --- a/bootstrap/unix-44/OPB.h +++ b/bootstrap/unix-44/OPB.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPB__h #define OPB__h diff --git a/bootstrap/unix-44/OPC.c b/bootstrap/unix-44/OPC.c index 9b3d80c3..c4b9a965 100644 --- a/bootstrap/unix-44/OPC.c +++ b/bootstrap/unix-44/OPC.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/OPC.h b/bootstrap/unix-44/OPC.h index 6cc996c8..a1917812 100644 --- a/bootstrap/unix-44/OPC.h +++ b/bootstrap/unix-44/OPC.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPC__h #define OPC__h diff --git a/bootstrap/unix-44/OPM.c b/bootstrap/unix-44/OPM.c index 0ac4141a..9610f289 100644 --- a/bootstrap/unix-44/OPM.c +++ b/bootstrap/unix-44/OPM.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/OPM.h b/bootstrap/unix-44/OPM.h index 91212642..fce0614a 100644 --- a/bootstrap/unix-44/OPM.h +++ b/bootstrap/unix-44/OPM.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPM__h #define OPM__h diff --git a/bootstrap/unix-44/OPP.c b/bootstrap/unix-44/OPP.c index 6a24e3cd..124bccb1 100644 --- a/bootstrap/unix-44/OPP.c +++ b/bootstrap/unix-44/OPP.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/OPP.h b/bootstrap/unix-44/OPP.h index 3cadf5a4..978ccdff 100644 --- a/bootstrap/unix-44/OPP.h +++ b/bootstrap/unix-44/OPP.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/unix-44/OPS.c b/bootstrap/unix-44/OPS.c index 898b14b6..845787eb 100644 --- a/bootstrap/unix-44/OPS.c +++ b/bootstrap/unix-44/OPS.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/OPS.h b/bootstrap/unix-44/OPS.h index 34906046..d8134366 100644 --- a/bootstrap/unix-44/OPS.h +++ b/bootstrap/unix-44/OPS.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/unix-44/OPT.c b/bootstrap/unix-44/OPT.c index fc148d64..43d368dd 100644 --- a/bootstrap/unix-44/OPT.c +++ b/bootstrap/unix-44/OPT.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/OPT.h b/bootstrap/unix-44/OPT.h index 3a248e3c..e3170fc0 100644 --- a/bootstrap/unix-44/OPT.h +++ b/bootstrap/unix-44/OPT.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPT__h #define OPT__h diff --git a/bootstrap/unix-44/OPV.c b/bootstrap/unix-44/OPV.c index 77b842f8..bc68a5c6 100644 --- a/bootstrap/unix-44/OPV.c +++ b/bootstrap/unix-44/OPV.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/OPV.h b/bootstrap/unix-44/OPV.h index 34e34ae6..9d02e218 100644 --- a/bootstrap/unix-44/OPV.h +++ b/bootstrap/unix-44/OPV.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPV__h #define OPV__h diff --git a/bootstrap/unix-44/Out.c b/bootstrap/unix-44/Out.c index 09fecc76..ad7ed82c 100644 --- a/bootstrap/unix-44/Out.c +++ b/bootstrap/unix-44/Out.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/Out.h b/bootstrap/unix-44/Out.h index 63fefd3c..247b98de 100644 --- a/bootstrap/unix-44/Out.h +++ b/bootstrap/unix-44/Out.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Out__h #define Out__h diff --git a/bootstrap/unix-44/Platform.c b/bootstrap/unix-44/Platform.c index bc020535..0a70d4aa 100644 --- a/bootstrap/unix-44/Platform.c +++ b/bootstrap/unix-44/Platform.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -33,7 +33,6 @@ typedef export BOOLEAN Platform_LittleEndian; export INT32 Platform_MainStackFrame; -export INT32 Platform_HaltCode; export INT16 Platform_PID; export CHAR Platform_CWD[256]; export INT16 Platform_ArgCount; @@ -47,21 +46,18 @@ export ADDRESS *Platform_FileIdentity__typ; export BOOLEAN Platform_Absent (INT16 e); export INT16 Platform_ArgPos (CHAR *s, LONGINT s__len); -export void Platform_AssertFail (INT32 code); export INT16 Platform_Chdir (CHAR *n, LONGINT n__len); export INT16 Platform_Close (INT32 h); export BOOLEAN Platform_ConnectionFailed (INT16 e); export void Platform_Delay (INT32 ms); export BOOLEAN Platform_DifferentFilesystems (INT16 e); -static void Platform_DisplayHaltCode (INT32 code); export INT16 Platform_Error (void); -export void Platform_Exit (INT16 code); +export void Platform_Exit (INT32 code); export void Platform_GetArg (INT16 n, CHAR *val, LONGINT val__len); export void Platform_GetClock (INT32 *t, INT32 *d); export void Platform_GetEnv (CHAR *var, LONGINT var__len, CHAR *val, LONGINT val__len); export void Platform_GetIntArg (INT16 n, INT32 *val); export void Platform_GetTimeOfDay (INT32 *sec, INT32 *usec); -export void Platform_Halt (INT32 code); export INT16 Platform_Identify (INT32 h, Platform_FileIdentity *identity, ADDRESS *identity__typ); export INT16 Platform_IdentifyByName (CHAR *n, LONGINT n__len, Platform_FileIdentity *identity, ADDRESS *identity__typ); export BOOLEAN Platform_Inaccessible (INT16 e); @@ -81,7 +77,6 @@ export BOOLEAN Platform_SameFile (Platform_FileIdentity i1, Platform_FileIdentit export BOOLEAN Platform_SameFileTime (Platform_FileIdentity i1, Platform_FileIdentity i2); export INT16 Platform_Seek (INT32 h, INT32 offset, INT16 whence); export void Platform_SetBadInstructionHandler (Platform_SignalHandler handler); -export void Platform_SetHalt (Platform_HaltProcedure p); export void Platform_SetInterruptHandler (Platform_SignalHandler handler); export void Platform_SetMTime (Platform_FileIdentity *target, ADDRESS *target__typ, Platform_FileIdentity source); export void Platform_SetQuitHandler (Platform_SignalHandler handler); @@ -96,10 +91,6 @@ export INT16 Platform_Truncate (INT32 h, INT32 l); export INT16 Platform_Unlink (CHAR *n, LONGINT n__len); export INT16 Platform_Write (INT32 h, INT32 p, INT32 l); static void Platform_YMDHMStoClock (INT32 ye, INT32 mo, INT32 da, INT32 ho, INT32 mi, INT32 se, INT32 *t, INT32 *d); -static void Platform_errch (CHAR c); -static void Platform_errint (INT32 l); -static void Platform_errln (void); -static void Platform_errposint (INT32 l); export BOOLEAN Platform_getEnv (CHAR *var, LONGINT var__len, CHAR *val, LONGINT val__len); #include @@ -131,9 +122,7 @@ extern void Heap_InitHeap(); #define Platform_chdir(n, n__len) chdir((char*)n) #define Platform_closefile(fd) close(fd) #define Platform_err() errno -#define Platform_errc(c) write(1, &c, 1) -#define Platform_errstring(s, s__len) write(1, s, s__len-1) -#define Platform_exit(code) exit(code) +#define Platform_exit(code) exit((int)code) #define Platform_free(address) free((void*)address) #define Platform_fstat(fd) fstat(fd, &s) #define Platform_fsync(fd) fsync(fd) @@ -229,7 +218,6 @@ void Platform_Init (INT32 argc, INT32 argvadr) Platform_ArgCount = __VAL(INT16, argc); av = (Platform_ArgVecPtr)(ADDRESS)argvadr; Platform_ArgVector = (*av)[0]; - Platform_HaltCode = -128; Platform_HeapInitHeap(); } @@ -571,127 +559,11 @@ INT16 Platform_Rename (CHAR *o, LONGINT o__len, CHAR *n, LONGINT n__len) __RETCHK; } -void Platform_Exit (INT16 code) +void Platform_Exit (INT32 code) { Platform_exit(code); } -static void Platform_errch (CHAR c) -{ - Platform_errc(c); -} - -static void Platform_errln (void) -{ - Platform_errch(0x0a); -} - -static void Platform_errposint (INT32 l) -{ - if (l > 10) { - Platform_errposint(__DIV(l, 10)); - } - Platform_errch((CHAR)(48 + (int)__MOD(l, 10))); -} - -static void Platform_errint (INT32 l) -{ - if (l < 0) { - Platform_errch('-'); - l = -l; - } - Platform_errposint(l); -} - -static void Platform_DisplayHaltCode (INT32 code) -{ - switch (code) { - case -1: - Platform_errstring((CHAR*)"Assertion failure.", 19); - break; - case -2: - Platform_errstring((CHAR*)"Index out of range.", 20); - break; - case -3: - Platform_errstring((CHAR*)"Reached end of function without reaching RETURN.", 49); - break; - case -4: - Platform_errstring((CHAR*)"CASE statement: no matching label and no ELSE.", 47); - break; - case -5: - Platform_errstring((CHAR*)"Type guard failed.", 19); - break; - case -6: - Platform_errstring((CHAR*)"Implicit type guard in record assignment failed.", 49); - break; - case -7: - Platform_errstring((CHAR*)"Invalid case in WITH statement.", 32); - break; - case -8: - Platform_errstring((CHAR*)"Value out of range.", 20); - break; - case -9: - Platform_errstring((CHAR*)"Heap interrupted while locked, but lockdepth = 0 at unlock.", 60); - break; - case -10: - Platform_errstring((CHAR*)"NIL access.", 12); - break; - case -11: - Platform_errstring((CHAR*)"Alignment error.", 17); - break; - case -12: - Platform_errstring((CHAR*)"Divide by zero.", 16); - break; - case -13: - Platform_errstring((CHAR*)"Arithmetic overflow/underflow.", 31); - break; - case -14: - Platform_errstring((CHAR*)"Invalid function argument.", 27); - break; - case -15: - Platform_errstring((CHAR*)"Internal error, e.g. Type descriptor size mismatch.", 52); - break; - case -20: - Platform_errstring((CHAR*)"Too many, or negative number of, elements in dynamic array.", 60); - break; - default: - break; - } -} - -void Platform_Halt (INT32 code) -{ - Platform_HaltCode = code; - if (Platform_HaltHandler != NIL) { - (*Platform_HaltHandler)(code); - } - Platform_errstring((CHAR*)"Terminated by Halt(", 20); - Platform_errint(code); - Platform_errstring((CHAR*)"). ", 4); - if (code < 0) { - Platform_DisplayHaltCode(code); - } - Platform_errln(); - Platform_exit(__VAL(INT16, code)); -} - -void Platform_AssertFail (INT32 code) -{ - Platform_errstring((CHAR*)"Assertion failure.", 19); - if (code != 0) { - Platform_errstring((CHAR*)" ASSERT code ", 14); - Platform_errint(code); - Platform_errstring((CHAR*)".", 2); - } - Platform_errln(); - Platform_exit(__VAL(INT16, code)); -} - -void Platform_SetHalt (Platform_HaltProcedure p) -{ - Platform_HaltHandler = p; -} - static void Platform_TestLittleEndian (void) { INT16 i; @@ -708,7 +580,6 @@ export void *Platform__init(void) __INITYP(Platform_FileIdentity, Platform_FileIdentity, 0); /* BEGIN */ Platform_TestLittleEndian(); - Platform_HaltCode = -128; Platform_HaltHandler = NIL; Platform_TimeStart = 0; Platform_TimeStart = Platform_Time(); diff --git a/bootstrap/unix-44/Platform.h b/bootstrap/unix-44/Platform.h index 2bbafb50..7f48cd11 100644 --- a/bootstrap/unix-44/Platform.h +++ b/bootstrap/unix-44/Platform.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Platform__h #define Platform__h @@ -11,16 +11,12 @@ typedef char _prvt1[8]; } Platform_FileIdentity; -typedef - void (*Platform_HaltProcedure)(INT32); - typedef void (*Platform_SignalHandler)(INT32); import BOOLEAN Platform_LittleEndian; import INT32 Platform_MainStackFrame; -import INT32 Platform_HaltCode; import INT16 Platform_PID; import CHAR Platform_CWD[256]; import INT16 Platform_ArgCount; @@ -32,20 +28,18 @@ import ADDRESS *Platform_FileIdentity__typ; import BOOLEAN Platform_Absent (INT16 e); import INT16 Platform_ArgPos (CHAR *s, LONGINT s__len); -import void Platform_AssertFail (INT32 code); import INT16 Platform_Chdir (CHAR *n, LONGINT n__len); import INT16 Platform_Close (INT32 h); import BOOLEAN Platform_ConnectionFailed (INT16 e); import void Platform_Delay (INT32 ms); import BOOLEAN Platform_DifferentFilesystems (INT16 e); import INT16 Platform_Error (void); -import void Platform_Exit (INT16 code); +import void Platform_Exit (INT32 code); import void Platform_GetArg (INT16 n, CHAR *val, LONGINT val__len); import void Platform_GetClock (INT32 *t, INT32 *d); import void Platform_GetEnv (CHAR *var, LONGINT var__len, CHAR *val, LONGINT val__len); import void Platform_GetIntArg (INT16 n, INT32 *val); import void Platform_GetTimeOfDay (INT32 *sec, INT32 *usec); -import void Platform_Halt (INT32 code); import INT16 Platform_Identify (INT32 h, Platform_FileIdentity *identity, ADDRESS *identity__typ); import INT16 Platform_IdentifyByName (CHAR *n, LONGINT n__len, Platform_FileIdentity *identity, ADDRESS *identity__typ); import BOOLEAN Platform_Inaccessible (INT16 e); @@ -65,7 +59,6 @@ import BOOLEAN Platform_SameFile (Platform_FileIdentity i1, Platform_FileIdentit import BOOLEAN Platform_SameFileTime (Platform_FileIdentity i1, Platform_FileIdentity i2); import INT16 Platform_Seek (INT32 h, INT32 offset, INT16 whence); import void Platform_SetBadInstructionHandler (Platform_SignalHandler handler); -import void Platform_SetHalt (Platform_HaltProcedure p); import void Platform_SetInterruptHandler (Platform_SignalHandler handler); import void Platform_SetMTime (Platform_FileIdentity *target, ADDRESS *target__typ, Platform_FileIdentity source); import void Platform_SetQuitHandler (Platform_SignalHandler handler); diff --git a/bootstrap/unix-44/Reals.c b/bootstrap/unix-44/Reals.c index f7860591..955cd8dc 100644 --- a/bootstrap/unix-44/Reals.c +++ b/bootstrap/unix-44/Reals.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/Reals.h b/bootstrap/unix-44/Reals.h index 5ed2ec95..fbae270c 100644 --- a/bootstrap/unix-44/Reals.h +++ b/bootstrap/unix-44/Reals.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/unix-44/Strings.c b/bootstrap/unix-44/Strings.c index 5ae2e44e..07e3b700 100644 --- a/bootstrap/unix-44/Strings.c +++ b/bootstrap/unix-44/Strings.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/Strings.h b/bootstrap/unix-44/Strings.h index a9d577f6..e3525cd0 100644 --- a/bootstrap/unix-44/Strings.h +++ b/bootstrap/unix-44/Strings.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/unix-44/Texts.c b/bootstrap/unix-44/Texts.c index db16a845..90bf9113 100644 --- a/bootstrap/unix-44/Texts.c +++ b/bootstrap/unix-44/Texts.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/Texts.h b/bootstrap/unix-44/Texts.h index f7454dae..8e1a2514 100644 --- a/bootstrap/unix-44/Texts.h +++ b/bootstrap/unix-44/Texts.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/unix-44/VT100.c b/bootstrap/unix-44/VT100.c index 01b8a481..97a7d318 100644 --- a/bootstrap/unix-44/VT100.c +++ b/bootstrap/unix-44/VT100.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/VT100.h b/bootstrap/unix-44/VT100.h index 5ee411dd..577a2d44 100644 --- a/bootstrap/unix-44/VT100.h +++ b/bootstrap/unix-44/VT100.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef VT100__h #define VT100__h diff --git a/bootstrap/unix-44/errors.c b/bootstrap/unix-44/errors.c index b7d411bb..aac72a79 100644 --- a/bootstrap/unix-44/errors.c +++ b/bootstrap/unix-44/errors.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/errors.h b/bootstrap/unix-44/errors.h index fa08de1c..4f03779e 100644 --- a/bootstrap/unix-44/errors.h +++ b/bootstrap/unix-44/errors.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef errors__h #define errors__h diff --git a/bootstrap/unix-44/extTools.c b/bootstrap/unix-44/extTools.c index 74271e5d..3493ea47 100644 --- a/bootstrap/unix-44/extTools.c +++ b/bootstrap/unix-44/extTools.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -7,6 +7,7 @@ #include "SYSTEM.h" #include "Configuration.h" +#include "Modules.h" #include "OPM.h" #include "Out.h" #include "Platform.h" @@ -53,9 +54,9 @@ static void extTools_execute (CHAR *title, LONGINT title__len, CHAR *cmd, LONGIN Out_Ln(); } if (status != 0) { - Platform_Halt(status); + Modules_Halt(status); } else { - Platform_Halt(exitcode); + Modules_Halt(exitcode); } } __DEL(title); @@ -114,6 +115,7 @@ export void *extTools__init(void) { __DEFMOD; __MODULE_IMPORT(Configuration); + __MODULE_IMPORT(Modules); __MODULE_IMPORT(OPM); __MODULE_IMPORT(Out); __MODULE_IMPORT(Platform); diff --git a/bootstrap/unix-44/extTools.h b/bootstrap/unix-44/extTools.h index 9b7b3c17..691b2968 100644 --- a/bootstrap/unix-44/extTools.h +++ b/bootstrap/unix-44/extTools.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef extTools__h #define extTools__h diff --git a/bootstrap/unix-48/Compiler.c b/bootstrap/unix-48/Compiler.c index 87b0392c..a6d5a403 100644 --- a/bootstrap/unix-48/Compiler.c +++ b/bootstrap/unix-48/Compiler.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspamSf */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspamSf */ #define SHORTINT INT8 #define INTEGER INT16 @@ -153,7 +153,7 @@ static void Compiler_Trap (INT32 sig) if (sig == 3) { Platform_Exit(0); } else { - if ((sig == 4 && Platform_HaltCode == -15)) { + if (sig == 4) { OPM_LogWStr((CHAR*)" --- Oberon compiler internal error", 36); OPM_LogWLn(); } diff --git a/bootstrap/unix-48/Configuration.c b/bootstrap/unix-48/Configuration.c index c15b87f9..d84a7f24 100644 --- a/bootstrap/unix-48/Configuration.c +++ b/bootstrap/unix-48/Configuration.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -19,6 +19,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); + __MOVE("1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); __ENDMOD; } diff --git a/bootstrap/unix-48/Configuration.h b/bootstrap/unix-48/Configuration.h index f169a3b6..09543f0b 100644 --- a/bootstrap/unix-48/Configuration.h +++ b/bootstrap/unix-48/Configuration.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Configuration__h #define Configuration__h diff --git a/bootstrap/unix-48/Files.c b/bootstrap/unix-48/Files.c index 5aedd8ec..3ce83372 100644 --- a/bootstrap/unix-48/Files.c +++ b/bootstrap/unix-48/Files.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/Files.h b/bootstrap/unix-48/Files.h index 88034b00..c04d545c 100644 --- a/bootstrap/unix-48/Files.h +++ b/bootstrap/unix-48/Files.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/unix-48/Heap.c b/bootstrap/unix-48/Heap.c index 45b45394..2a5c9464 100644 --- a/bootstrap/unix-48/Heap.c +++ b/bootstrap/unix-48/Heap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -108,8 +108,8 @@ extern void *Heap__init(); extern ADDRESS Platform_MainStackFrame; extern ADDRESS Platform_OSAllocate(ADDRESS size); #define Heap_HeapModuleInit() Heap__init() +#define Heap_ModulesHalt(code) Modules_Halt(code) #define Heap_OSAllocate(size) Platform_OSAllocate(size) -#define Heap_PlatformHalt(code) Platform_Halt(code) #define Heap_PlatformMainStackFrame() Platform_MainStackFrame void Heap_Lock (void) @@ -121,7 +121,7 @@ void Heap_Unlock (void) { Heap_lockdepth -= 1; if ((Heap_interrupted && Heap_lockdepth == 0)) { - Heap_PlatformHalt(-9); + Heap_ModulesHalt(-9); } } diff --git a/bootstrap/unix-48/Heap.h b/bootstrap/unix-48/Heap.h index 8626628d..5f888271 100644 --- a/bootstrap/unix-48/Heap.h +++ b/bootstrap/unix-48/Heap.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ #ifndef Heap__h #define Heap__h diff --git a/bootstrap/unix-48/Modules.c b/bootstrap/unix-48/Modules.c index 5eddf9be..23c71a96 100644 --- a/bootstrap/unix-48/Modules.c +++ b/bootstrap/unix-48/Modules.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -7,6 +7,7 @@ #include "SYSTEM.h" #include "Heap.h" +#include "Platform.h" typedef struct Modules_CmdDesc *Modules_Cmd; @@ -47,9 +48,16 @@ export ADDRESS *Modules_ModuleDesc__typ; export ADDRESS *Modules_CmdDesc__typ; static void Modules_Append (CHAR *a, LONGINT a__len, CHAR *b, LONGINT b__len); +export void Modules_AssertFail (INT32 code); +static void Modules_DisplayHaltCode (INT32 code); export void Modules_Free (CHAR *name, LONGINT name__len, BOOLEAN all); +export void Modules_Halt (INT32 code); export Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, LONGINT name__len); export Modules_Module Modules_ThisMod (CHAR *name, LONGINT name__len); +static void Modules_errch (CHAR c); +export void Modules_errint (INT32 l); +static void Modules_errposint (INT32 l); +export void Modules_errstring (CHAR *s, LONGINT s__len); #define Modules_modules() (Modules_Module)Heap_modules #define Modules_setmodules(m) Heap_modules = m @@ -155,6 +163,121 @@ void Modules_Free (CHAR *name, LONGINT name__len, BOOLEAN all) __DEL(name); } +static void Modules_errch (CHAR c) +{ + INT16 e; + e = Platform_Write(1, (ADDRESS)&c, 1); +} + +void Modules_errstring (CHAR *s, LONGINT s__len) +{ + INT32 i; + __DUP(s, s__len, CHAR); + i = 0; + while ((i < s__len && s[__X(i, s__len)] != 0x00)) { + Modules_errch(s[__X(i, s__len)]); + i += 1; + } + __DEL(s); +} + +static void Modules_errposint (INT32 l) +{ + if (l > 10) { + Modules_errposint(__DIV(l, 10)); + } + Modules_errch((CHAR)(48 + (int)__MOD(l, 10))); +} + +void Modules_errint (INT32 l) +{ + if (l < 0) { + Modules_errch('-'); + l = -l; + } + Modules_errposint(l); +} + +static void Modules_DisplayHaltCode (INT32 code) +{ + switch (code) { + case -1: + Modules_errstring((CHAR*)"Assertion failure.", 19); + break; + case -2: + Modules_errstring((CHAR*)"Index out of range.", 20); + break; + case -3: + Modules_errstring((CHAR*)"Reached end of function without reaching RETURN.", 49); + break; + case -4: + Modules_errstring((CHAR*)"CASE statement: no matching label and no ELSE.", 47); + break; + case -5: + Modules_errstring((CHAR*)"Type guard failed.", 19); + break; + case -6: + Modules_errstring((CHAR*)"Implicit type guard in record assignment failed.", 49); + break; + case -7: + Modules_errstring((CHAR*)"Invalid case in WITH statement.", 32); + break; + case -8: + Modules_errstring((CHAR*)"Value out of range.", 20); + break; + case -9: + Modules_errstring((CHAR*)"Heap interrupted while locked, but lockdepth = 0 at unlock.", 60); + break; + case -10: + Modules_errstring((CHAR*)"NIL access.", 12); + break; + case -11: + Modules_errstring((CHAR*)"Alignment error.", 17); + break; + case -12: + Modules_errstring((CHAR*)"Divide by zero.", 16); + break; + case -13: + Modules_errstring((CHAR*)"Arithmetic overflow/underflow.", 31); + break; + case -14: + Modules_errstring((CHAR*)"Invalid function argument.", 27); + break; + case -15: + Modules_errstring((CHAR*)"Internal error, e.g. Type descriptor size mismatch.", 52); + break; + case -20: + Modules_errstring((CHAR*)"Too many, or negative number of, elements in dynamic array.", 60); + break; + default: + break; + } +} + +void Modules_Halt (INT32 code) +{ + Modules_errstring((CHAR*)"Terminated by Halt(", 20); + Modules_errint(code); + Modules_errstring((CHAR*)"). ", 4); + if (code < 0) { + Modules_DisplayHaltCode(code); + } + Modules_errstring(Platform_NL, 3); + Platform_Exit(code); +} + +void Modules_AssertFail (INT32 code) +{ + Modules_errstring((CHAR*)"Assertion failure.", 19); + if (code != 0) { + Modules_errstring((CHAR*)" ASSERT code ", 14); + Modules_errint(code); + Modules_errstring((CHAR*)".", 2); + } + Modules_errstring(Platform_NL, 3); + Platform_Exit(code); +} + __TDESC(Modules_ModuleDesc, 1, 2) = {__TDFLDS("ModuleDesc", 48), {0, 28, -12}}; __TDESC(Modules_CmdDesc, 1, 1) = {__TDFLDS("CmdDesc", 32), {0, -8}}; @@ -162,6 +285,7 @@ export void *Modules__init(void) { __DEFMOD; __MODULE_IMPORT(Heap); + __MODULE_IMPORT(Platform); __REGMOD("Modules", 0); __INITYP(Modules_ModuleDesc, Modules_ModuleDesc, 0); __INITYP(Modules_CmdDesc, Modules_CmdDesc, 0); diff --git a/bootstrap/unix-48/Modules.h b/bootstrap/unix-48/Modules.h index 2da3fa50..6809ec05 100644 --- a/bootstrap/unix-48/Modules.h +++ b/bootstrap/unix-48/Modules.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Modules__h #define Modules__h @@ -43,9 +43,13 @@ import Modules_ModuleName Modules_imported, Modules_importing; import ADDRESS *Modules_ModuleDesc__typ; import ADDRESS *Modules_CmdDesc__typ; +import void Modules_AssertFail (INT32 code); import void Modules_Free (CHAR *name, LONGINT name__len, BOOLEAN all); +import void Modules_Halt (INT32 code); import Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, LONGINT name__len); import Modules_Module Modules_ThisMod (CHAR *name, LONGINT name__len); +import void Modules_errint (INT32 l); +import void Modules_errstring (CHAR *s, LONGINT s__len); import void *Modules__init(void); #define Modules_modules() (Modules_Module)Heap_modules diff --git a/bootstrap/unix-48/OPB.c b/bootstrap/unix-48/OPB.c index dcac4eb9..8a1b80fe 100644 --- a/bootstrap/unix-48/OPB.c +++ b/bootstrap/unix-48/OPB.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/OPB.h b/bootstrap/unix-48/OPB.h index cb6399f9..0caeb234 100644 --- a/bootstrap/unix-48/OPB.h +++ b/bootstrap/unix-48/OPB.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPB__h #define OPB__h diff --git a/bootstrap/unix-48/OPC.c b/bootstrap/unix-48/OPC.c index 9b3d80c3..c4b9a965 100644 --- a/bootstrap/unix-48/OPC.c +++ b/bootstrap/unix-48/OPC.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/OPC.h b/bootstrap/unix-48/OPC.h index 6cc996c8..a1917812 100644 --- a/bootstrap/unix-48/OPC.h +++ b/bootstrap/unix-48/OPC.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPC__h #define OPC__h diff --git a/bootstrap/unix-48/OPM.c b/bootstrap/unix-48/OPM.c index 0ac4141a..9610f289 100644 --- a/bootstrap/unix-48/OPM.c +++ b/bootstrap/unix-48/OPM.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/OPM.h b/bootstrap/unix-48/OPM.h index 91212642..fce0614a 100644 --- a/bootstrap/unix-48/OPM.h +++ b/bootstrap/unix-48/OPM.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPM__h #define OPM__h diff --git a/bootstrap/unix-48/OPP.c b/bootstrap/unix-48/OPP.c index 6a24e3cd..124bccb1 100644 --- a/bootstrap/unix-48/OPP.c +++ b/bootstrap/unix-48/OPP.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/OPP.h b/bootstrap/unix-48/OPP.h index 3cadf5a4..978ccdff 100644 --- a/bootstrap/unix-48/OPP.h +++ b/bootstrap/unix-48/OPP.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/unix-48/OPS.c b/bootstrap/unix-48/OPS.c index 898b14b6..845787eb 100644 --- a/bootstrap/unix-48/OPS.c +++ b/bootstrap/unix-48/OPS.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/OPS.h b/bootstrap/unix-48/OPS.h index 34906046..d8134366 100644 --- a/bootstrap/unix-48/OPS.h +++ b/bootstrap/unix-48/OPS.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/unix-48/OPT.c b/bootstrap/unix-48/OPT.c index a8951123..46e05141 100644 --- a/bootstrap/unix-48/OPT.c +++ b/bootstrap/unix-48/OPT.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/OPT.h b/bootstrap/unix-48/OPT.h index 3a248e3c..e3170fc0 100644 --- a/bootstrap/unix-48/OPT.h +++ b/bootstrap/unix-48/OPT.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPT__h #define OPT__h diff --git a/bootstrap/unix-48/OPV.c b/bootstrap/unix-48/OPV.c index 77b842f8..bc68a5c6 100644 --- a/bootstrap/unix-48/OPV.c +++ b/bootstrap/unix-48/OPV.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/OPV.h b/bootstrap/unix-48/OPV.h index 34e34ae6..9d02e218 100644 --- a/bootstrap/unix-48/OPV.h +++ b/bootstrap/unix-48/OPV.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPV__h #define OPV__h diff --git a/bootstrap/unix-48/Out.c b/bootstrap/unix-48/Out.c index 09fecc76..ad7ed82c 100644 --- a/bootstrap/unix-48/Out.c +++ b/bootstrap/unix-48/Out.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/Out.h b/bootstrap/unix-48/Out.h index 63fefd3c..247b98de 100644 --- a/bootstrap/unix-48/Out.h +++ b/bootstrap/unix-48/Out.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Out__h #define Out__h diff --git a/bootstrap/unix-48/Platform.c b/bootstrap/unix-48/Platform.c index bc020535..0a70d4aa 100644 --- a/bootstrap/unix-48/Platform.c +++ b/bootstrap/unix-48/Platform.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -33,7 +33,6 @@ typedef export BOOLEAN Platform_LittleEndian; export INT32 Platform_MainStackFrame; -export INT32 Platform_HaltCode; export INT16 Platform_PID; export CHAR Platform_CWD[256]; export INT16 Platform_ArgCount; @@ -47,21 +46,18 @@ export ADDRESS *Platform_FileIdentity__typ; export BOOLEAN Platform_Absent (INT16 e); export INT16 Platform_ArgPos (CHAR *s, LONGINT s__len); -export void Platform_AssertFail (INT32 code); export INT16 Platform_Chdir (CHAR *n, LONGINT n__len); export INT16 Platform_Close (INT32 h); export BOOLEAN Platform_ConnectionFailed (INT16 e); export void Platform_Delay (INT32 ms); export BOOLEAN Platform_DifferentFilesystems (INT16 e); -static void Platform_DisplayHaltCode (INT32 code); export INT16 Platform_Error (void); -export void Platform_Exit (INT16 code); +export void Platform_Exit (INT32 code); export void Platform_GetArg (INT16 n, CHAR *val, LONGINT val__len); export void Platform_GetClock (INT32 *t, INT32 *d); export void Platform_GetEnv (CHAR *var, LONGINT var__len, CHAR *val, LONGINT val__len); export void Platform_GetIntArg (INT16 n, INT32 *val); export void Platform_GetTimeOfDay (INT32 *sec, INT32 *usec); -export void Platform_Halt (INT32 code); export INT16 Platform_Identify (INT32 h, Platform_FileIdentity *identity, ADDRESS *identity__typ); export INT16 Platform_IdentifyByName (CHAR *n, LONGINT n__len, Platform_FileIdentity *identity, ADDRESS *identity__typ); export BOOLEAN Platform_Inaccessible (INT16 e); @@ -81,7 +77,6 @@ export BOOLEAN Platform_SameFile (Platform_FileIdentity i1, Platform_FileIdentit export BOOLEAN Platform_SameFileTime (Platform_FileIdentity i1, Platform_FileIdentity i2); export INT16 Platform_Seek (INT32 h, INT32 offset, INT16 whence); export void Platform_SetBadInstructionHandler (Platform_SignalHandler handler); -export void Platform_SetHalt (Platform_HaltProcedure p); export void Platform_SetInterruptHandler (Platform_SignalHandler handler); export void Platform_SetMTime (Platform_FileIdentity *target, ADDRESS *target__typ, Platform_FileIdentity source); export void Platform_SetQuitHandler (Platform_SignalHandler handler); @@ -96,10 +91,6 @@ export INT16 Platform_Truncate (INT32 h, INT32 l); export INT16 Platform_Unlink (CHAR *n, LONGINT n__len); export INT16 Platform_Write (INT32 h, INT32 p, INT32 l); static void Platform_YMDHMStoClock (INT32 ye, INT32 mo, INT32 da, INT32 ho, INT32 mi, INT32 se, INT32 *t, INT32 *d); -static void Platform_errch (CHAR c); -static void Platform_errint (INT32 l); -static void Platform_errln (void); -static void Platform_errposint (INT32 l); export BOOLEAN Platform_getEnv (CHAR *var, LONGINT var__len, CHAR *val, LONGINT val__len); #include @@ -131,9 +122,7 @@ extern void Heap_InitHeap(); #define Platform_chdir(n, n__len) chdir((char*)n) #define Platform_closefile(fd) close(fd) #define Platform_err() errno -#define Platform_errc(c) write(1, &c, 1) -#define Platform_errstring(s, s__len) write(1, s, s__len-1) -#define Platform_exit(code) exit(code) +#define Platform_exit(code) exit((int)code) #define Platform_free(address) free((void*)address) #define Platform_fstat(fd) fstat(fd, &s) #define Platform_fsync(fd) fsync(fd) @@ -229,7 +218,6 @@ void Platform_Init (INT32 argc, INT32 argvadr) Platform_ArgCount = __VAL(INT16, argc); av = (Platform_ArgVecPtr)(ADDRESS)argvadr; Platform_ArgVector = (*av)[0]; - Platform_HaltCode = -128; Platform_HeapInitHeap(); } @@ -571,127 +559,11 @@ INT16 Platform_Rename (CHAR *o, LONGINT o__len, CHAR *n, LONGINT n__len) __RETCHK; } -void Platform_Exit (INT16 code) +void Platform_Exit (INT32 code) { Platform_exit(code); } -static void Platform_errch (CHAR c) -{ - Platform_errc(c); -} - -static void Platform_errln (void) -{ - Platform_errch(0x0a); -} - -static void Platform_errposint (INT32 l) -{ - if (l > 10) { - Platform_errposint(__DIV(l, 10)); - } - Platform_errch((CHAR)(48 + (int)__MOD(l, 10))); -} - -static void Platform_errint (INT32 l) -{ - if (l < 0) { - Platform_errch('-'); - l = -l; - } - Platform_errposint(l); -} - -static void Platform_DisplayHaltCode (INT32 code) -{ - switch (code) { - case -1: - Platform_errstring((CHAR*)"Assertion failure.", 19); - break; - case -2: - Platform_errstring((CHAR*)"Index out of range.", 20); - break; - case -3: - Platform_errstring((CHAR*)"Reached end of function without reaching RETURN.", 49); - break; - case -4: - Platform_errstring((CHAR*)"CASE statement: no matching label and no ELSE.", 47); - break; - case -5: - Platform_errstring((CHAR*)"Type guard failed.", 19); - break; - case -6: - Platform_errstring((CHAR*)"Implicit type guard in record assignment failed.", 49); - break; - case -7: - Platform_errstring((CHAR*)"Invalid case in WITH statement.", 32); - break; - case -8: - Platform_errstring((CHAR*)"Value out of range.", 20); - break; - case -9: - Platform_errstring((CHAR*)"Heap interrupted while locked, but lockdepth = 0 at unlock.", 60); - break; - case -10: - Platform_errstring((CHAR*)"NIL access.", 12); - break; - case -11: - Platform_errstring((CHAR*)"Alignment error.", 17); - break; - case -12: - Platform_errstring((CHAR*)"Divide by zero.", 16); - break; - case -13: - Platform_errstring((CHAR*)"Arithmetic overflow/underflow.", 31); - break; - case -14: - Platform_errstring((CHAR*)"Invalid function argument.", 27); - break; - case -15: - Platform_errstring((CHAR*)"Internal error, e.g. Type descriptor size mismatch.", 52); - break; - case -20: - Platform_errstring((CHAR*)"Too many, or negative number of, elements in dynamic array.", 60); - break; - default: - break; - } -} - -void Platform_Halt (INT32 code) -{ - Platform_HaltCode = code; - if (Platform_HaltHandler != NIL) { - (*Platform_HaltHandler)(code); - } - Platform_errstring((CHAR*)"Terminated by Halt(", 20); - Platform_errint(code); - Platform_errstring((CHAR*)"). ", 4); - if (code < 0) { - Platform_DisplayHaltCode(code); - } - Platform_errln(); - Platform_exit(__VAL(INT16, code)); -} - -void Platform_AssertFail (INT32 code) -{ - Platform_errstring((CHAR*)"Assertion failure.", 19); - if (code != 0) { - Platform_errstring((CHAR*)" ASSERT code ", 14); - Platform_errint(code); - Platform_errstring((CHAR*)".", 2); - } - Platform_errln(); - Platform_exit(__VAL(INT16, code)); -} - -void Platform_SetHalt (Platform_HaltProcedure p) -{ - Platform_HaltHandler = p; -} - static void Platform_TestLittleEndian (void) { INT16 i; @@ -708,7 +580,6 @@ export void *Platform__init(void) __INITYP(Platform_FileIdentity, Platform_FileIdentity, 0); /* BEGIN */ Platform_TestLittleEndian(); - Platform_HaltCode = -128; Platform_HaltHandler = NIL; Platform_TimeStart = 0; Platform_TimeStart = Platform_Time(); diff --git a/bootstrap/unix-48/Platform.h b/bootstrap/unix-48/Platform.h index 2bbafb50..7f48cd11 100644 --- a/bootstrap/unix-48/Platform.h +++ b/bootstrap/unix-48/Platform.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Platform__h #define Platform__h @@ -11,16 +11,12 @@ typedef char _prvt1[8]; } Platform_FileIdentity; -typedef - void (*Platform_HaltProcedure)(INT32); - typedef void (*Platform_SignalHandler)(INT32); import BOOLEAN Platform_LittleEndian; import INT32 Platform_MainStackFrame; -import INT32 Platform_HaltCode; import INT16 Platform_PID; import CHAR Platform_CWD[256]; import INT16 Platform_ArgCount; @@ -32,20 +28,18 @@ import ADDRESS *Platform_FileIdentity__typ; import BOOLEAN Platform_Absent (INT16 e); import INT16 Platform_ArgPos (CHAR *s, LONGINT s__len); -import void Platform_AssertFail (INT32 code); import INT16 Platform_Chdir (CHAR *n, LONGINT n__len); import INT16 Platform_Close (INT32 h); import BOOLEAN Platform_ConnectionFailed (INT16 e); import void Platform_Delay (INT32 ms); import BOOLEAN Platform_DifferentFilesystems (INT16 e); import INT16 Platform_Error (void); -import void Platform_Exit (INT16 code); +import void Platform_Exit (INT32 code); import void Platform_GetArg (INT16 n, CHAR *val, LONGINT val__len); import void Platform_GetClock (INT32 *t, INT32 *d); import void Platform_GetEnv (CHAR *var, LONGINT var__len, CHAR *val, LONGINT val__len); import void Platform_GetIntArg (INT16 n, INT32 *val); import void Platform_GetTimeOfDay (INT32 *sec, INT32 *usec); -import void Platform_Halt (INT32 code); import INT16 Platform_Identify (INT32 h, Platform_FileIdentity *identity, ADDRESS *identity__typ); import INT16 Platform_IdentifyByName (CHAR *n, LONGINT n__len, Platform_FileIdentity *identity, ADDRESS *identity__typ); import BOOLEAN Platform_Inaccessible (INT16 e); @@ -65,7 +59,6 @@ import BOOLEAN Platform_SameFile (Platform_FileIdentity i1, Platform_FileIdentit import BOOLEAN Platform_SameFileTime (Platform_FileIdentity i1, Platform_FileIdentity i2); import INT16 Platform_Seek (INT32 h, INT32 offset, INT16 whence); import void Platform_SetBadInstructionHandler (Platform_SignalHandler handler); -import void Platform_SetHalt (Platform_HaltProcedure p); import void Platform_SetInterruptHandler (Platform_SignalHandler handler); import void Platform_SetMTime (Platform_FileIdentity *target, ADDRESS *target__typ, Platform_FileIdentity source); import void Platform_SetQuitHandler (Platform_SignalHandler handler); diff --git a/bootstrap/unix-48/Reals.c b/bootstrap/unix-48/Reals.c index f7860591..955cd8dc 100644 --- a/bootstrap/unix-48/Reals.c +++ b/bootstrap/unix-48/Reals.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/Reals.h b/bootstrap/unix-48/Reals.h index 5ed2ec95..fbae270c 100644 --- a/bootstrap/unix-48/Reals.h +++ b/bootstrap/unix-48/Reals.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/unix-48/Strings.c b/bootstrap/unix-48/Strings.c index 5ae2e44e..07e3b700 100644 --- a/bootstrap/unix-48/Strings.c +++ b/bootstrap/unix-48/Strings.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/Strings.h b/bootstrap/unix-48/Strings.h index a9d577f6..e3525cd0 100644 --- a/bootstrap/unix-48/Strings.h +++ b/bootstrap/unix-48/Strings.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/unix-48/Texts.c b/bootstrap/unix-48/Texts.c index 987b9952..36cd76fb 100644 --- a/bootstrap/unix-48/Texts.c +++ b/bootstrap/unix-48/Texts.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/Texts.h b/bootstrap/unix-48/Texts.h index e902469a..4bae7210 100644 --- a/bootstrap/unix-48/Texts.h +++ b/bootstrap/unix-48/Texts.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/unix-48/VT100.c b/bootstrap/unix-48/VT100.c index 01b8a481..97a7d318 100644 --- a/bootstrap/unix-48/VT100.c +++ b/bootstrap/unix-48/VT100.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/VT100.h b/bootstrap/unix-48/VT100.h index 5ee411dd..577a2d44 100644 --- a/bootstrap/unix-48/VT100.h +++ b/bootstrap/unix-48/VT100.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef VT100__h #define VT100__h diff --git a/bootstrap/unix-48/errors.c b/bootstrap/unix-48/errors.c index b7d411bb..aac72a79 100644 --- a/bootstrap/unix-48/errors.c +++ b/bootstrap/unix-48/errors.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/errors.h b/bootstrap/unix-48/errors.h index fa08de1c..4f03779e 100644 --- a/bootstrap/unix-48/errors.h +++ b/bootstrap/unix-48/errors.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef errors__h #define errors__h diff --git a/bootstrap/unix-48/extTools.c b/bootstrap/unix-48/extTools.c index 74271e5d..3493ea47 100644 --- a/bootstrap/unix-48/extTools.c +++ b/bootstrap/unix-48/extTools.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -7,6 +7,7 @@ #include "SYSTEM.h" #include "Configuration.h" +#include "Modules.h" #include "OPM.h" #include "Out.h" #include "Platform.h" @@ -53,9 +54,9 @@ static void extTools_execute (CHAR *title, LONGINT title__len, CHAR *cmd, LONGIN Out_Ln(); } if (status != 0) { - Platform_Halt(status); + Modules_Halt(status); } else { - Platform_Halt(exitcode); + Modules_Halt(exitcode); } } __DEL(title); @@ -114,6 +115,7 @@ export void *extTools__init(void) { __DEFMOD; __MODULE_IMPORT(Configuration); + __MODULE_IMPORT(Modules); __MODULE_IMPORT(OPM); __MODULE_IMPORT(Out); __MODULE_IMPORT(Platform); diff --git a/bootstrap/unix-48/extTools.h b/bootstrap/unix-48/extTools.h index 9b7b3c17..691b2968 100644 --- a/bootstrap/unix-48/extTools.h +++ b/bootstrap/unix-48/extTools.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef extTools__h #define extTools__h diff --git a/bootstrap/unix-88/Compiler.c b/bootstrap/unix-88/Compiler.c index 87b0392c..a6d5a403 100644 --- a/bootstrap/unix-88/Compiler.c +++ b/bootstrap/unix-88/Compiler.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspamSf */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspamSf */ #define SHORTINT INT8 #define INTEGER INT16 @@ -153,7 +153,7 @@ static void Compiler_Trap (INT32 sig) if (sig == 3) { Platform_Exit(0); } else { - if ((sig == 4 && Platform_HaltCode == -15)) { + if (sig == 4) { OPM_LogWStr((CHAR*)" --- Oberon compiler internal error", 36); OPM_LogWLn(); } diff --git a/bootstrap/unix-88/Configuration.c b/bootstrap/unix-88/Configuration.c index c15b87f9..d84a7f24 100644 --- a/bootstrap/unix-88/Configuration.c +++ b/bootstrap/unix-88/Configuration.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -19,6 +19,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); + __MOVE("1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); __ENDMOD; } diff --git a/bootstrap/unix-88/Configuration.h b/bootstrap/unix-88/Configuration.h index f169a3b6..09543f0b 100644 --- a/bootstrap/unix-88/Configuration.h +++ b/bootstrap/unix-88/Configuration.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Configuration__h #define Configuration__h diff --git a/bootstrap/unix-88/Files.c b/bootstrap/unix-88/Files.c index 53ac0902..ba54d44e 100644 --- a/bootstrap/unix-88/Files.c +++ b/bootstrap/unix-88/Files.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/Files.h b/bootstrap/unix-88/Files.h index 3bfefe80..ef304bed 100644 --- a/bootstrap/unix-88/Files.h +++ b/bootstrap/unix-88/Files.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/unix-88/Heap.c b/bootstrap/unix-88/Heap.c index 806a01db..46f70cc1 100644 --- a/bootstrap/unix-88/Heap.c +++ b/bootstrap/unix-88/Heap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -108,8 +108,8 @@ extern void *Heap__init(); extern ADDRESS Platform_MainStackFrame; extern ADDRESS Platform_OSAllocate(ADDRESS size); #define Heap_HeapModuleInit() Heap__init() +#define Heap_ModulesHalt(code) Modules_Halt(code) #define Heap_OSAllocate(size) Platform_OSAllocate(size) -#define Heap_PlatformHalt(code) Platform_Halt(code) #define Heap_PlatformMainStackFrame() Platform_MainStackFrame void Heap_Lock (void) @@ -121,7 +121,7 @@ void Heap_Unlock (void) { Heap_lockdepth -= 1; if ((Heap_interrupted && Heap_lockdepth == 0)) { - Heap_PlatformHalt(-9); + Heap_ModulesHalt(-9); } } diff --git a/bootstrap/unix-88/Heap.h b/bootstrap/unix-88/Heap.h index 2603a3eb..06cbd0ec 100644 --- a/bootstrap/unix-88/Heap.h +++ b/bootstrap/unix-88/Heap.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ #ifndef Heap__h #define Heap__h diff --git a/bootstrap/unix-88/Modules.c b/bootstrap/unix-88/Modules.c index f463ec4e..494f9fdc 100644 --- a/bootstrap/unix-88/Modules.c +++ b/bootstrap/unix-88/Modules.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -7,6 +7,7 @@ #include "SYSTEM.h" #include "Heap.h" +#include "Platform.h" typedef struct Modules_CmdDesc *Modules_Cmd; @@ -47,9 +48,16 @@ export ADDRESS *Modules_ModuleDesc__typ; export ADDRESS *Modules_CmdDesc__typ; static void Modules_Append (CHAR *a, LONGINT a__len, CHAR *b, LONGINT b__len); +export void Modules_AssertFail (INT32 code); +static void Modules_DisplayHaltCode (INT32 code); export void Modules_Free (CHAR *name, LONGINT name__len, BOOLEAN all); +export void Modules_Halt (INT32 code); export Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, LONGINT name__len); export Modules_Module Modules_ThisMod (CHAR *name, LONGINT name__len); +static void Modules_errch (CHAR c); +export void Modules_errint (INT32 l); +static void Modules_errposint (INT32 l); +export void Modules_errstring (CHAR *s, LONGINT s__len); #define Modules_modules() (Modules_Module)Heap_modules #define Modules_setmodules(m) Heap_modules = m @@ -155,6 +163,121 @@ void Modules_Free (CHAR *name, LONGINT name__len, BOOLEAN all) __DEL(name); } +static void Modules_errch (CHAR c) +{ + INT16 e; + e = Platform_Write(1, (ADDRESS)&c, 1); +} + +void Modules_errstring (CHAR *s, LONGINT s__len) +{ + INT32 i; + __DUP(s, s__len, CHAR); + i = 0; + while ((i < s__len && s[__X(i, s__len)] != 0x00)) { + Modules_errch(s[__X(i, s__len)]); + i += 1; + } + __DEL(s); +} + +static void Modules_errposint (INT32 l) +{ + if (l > 10) { + Modules_errposint(__DIV(l, 10)); + } + Modules_errch((CHAR)(48 + (int)__MOD(l, 10))); +} + +void Modules_errint (INT32 l) +{ + if (l < 0) { + Modules_errch('-'); + l = -l; + } + Modules_errposint(l); +} + +static void Modules_DisplayHaltCode (INT32 code) +{ + switch (code) { + case -1: + Modules_errstring((CHAR*)"Assertion failure.", 19); + break; + case -2: + Modules_errstring((CHAR*)"Index out of range.", 20); + break; + case -3: + Modules_errstring((CHAR*)"Reached end of function without reaching RETURN.", 49); + break; + case -4: + Modules_errstring((CHAR*)"CASE statement: no matching label and no ELSE.", 47); + break; + case -5: + Modules_errstring((CHAR*)"Type guard failed.", 19); + break; + case -6: + Modules_errstring((CHAR*)"Implicit type guard in record assignment failed.", 49); + break; + case -7: + Modules_errstring((CHAR*)"Invalid case in WITH statement.", 32); + break; + case -8: + Modules_errstring((CHAR*)"Value out of range.", 20); + break; + case -9: + Modules_errstring((CHAR*)"Heap interrupted while locked, but lockdepth = 0 at unlock.", 60); + break; + case -10: + Modules_errstring((CHAR*)"NIL access.", 12); + break; + case -11: + Modules_errstring((CHAR*)"Alignment error.", 17); + break; + case -12: + Modules_errstring((CHAR*)"Divide by zero.", 16); + break; + case -13: + Modules_errstring((CHAR*)"Arithmetic overflow/underflow.", 31); + break; + case -14: + Modules_errstring((CHAR*)"Invalid function argument.", 27); + break; + case -15: + Modules_errstring((CHAR*)"Internal error, e.g. Type descriptor size mismatch.", 52); + break; + case -20: + Modules_errstring((CHAR*)"Too many, or negative number of, elements in dynamic array.", 60); + break; + default: + break; + } +} + +void Modules_Halt (INT32 code) +{ + Modules_errstring((CHAR*)"Terminated by Halt(", 20); + Modules_errint(code); + Modules_errstring((CHAR*)"). ", 4); + if (code < 0) { + Modules_DisplayHaltCode(code); + } + Modules_errstring(Platform_NL, 3); + Platform_Exit(code); +} + +void Modules_AssertFail (INT32 code) +{ + Modules_errstring((CHAR*)"Assertion failure.", 19); + if (code != 0) { + Modules_errstring((CHAR*)" ASSERT code ", 14); + Modules_errint(code); + Modules_errstring((CHAR*)".", 2); + } + Modules_errstring(Platform_NL, 3); + Platform_Exit(code); +} + __TDESC(Modules_ModuleDesc, 1, 2) = {__TDFLDS("ModuleDesc", 64), {0, 32, -24}}; __TDESC(Modules_CmdDesc, 1, 1) = {__TDFLDS("CmdDesc", 40), {0, -16}}; @@ -162,6 +285,7 @@ export void *Modules__init(void) { __DEFMOD; __MODULE_IMPORT(Heap); + __MODULE_IMPORT(Platform); __REGMOD("Modules", 0); __INITYP(Modules_ModuleDesc, Modules_ModuleDesc, 0); __INITYP(Modules_CmdDesc, Modules_CmdDesc, 0); diff --git a/bootstrap/unix-88/Modules.h b/bootstrap/unix-88/Modules.h index 2da3fa50..6809ec05 100644 --- a/bootstrap/unix-88/Modules.h +++ b/bootstrap/unix-88/Modules.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Modules__h #define Modules__h @@ -43,9 +43,13 @@ import Modules_ModuleName Modules_imported, Modules_importing; import ADDRESS *Modules_ModuleDesc__typ; import ADDRESS *Modules_CmdDesc__typ; +import void Modules_AssertFail (INT32 code); import void Modules_Free (CHAR *name, LONGINT name__len, BOOLEAN all); +import void Modules_Halt (INT32 code); import Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, LONGINT name__len); import Modules_Module Modules_ThisMod (CHAR *name, LONGINT name__len); +import void Modules_errint (INT32 l); +import void Modules_errstring (CHAR *s, LONGINT s__len); import void *Modules__init(void); #define Modules_modules() (Modules_Module)Heap_modules diff --git a/bootstrap/unix-88/OPB.c b/bootstrap/unix-88/OPB.c index dcac4eb9..8a1b80fe 100644 --- a/bootstrap/unix-88/OPB.c +++ b/bootstrap/unix-88/OPB.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/OPB.h b/bootstrap/unix-88/OPB.h index cb6399f9..0caeb234 100644 --- a/bootstrap/unix-88/OPB.h +++ b/bootstrap/unix-88/OPB.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPB__h #define OPB__h diff --git a/bootstrap/unix-88/OPC.c b/bootstrap/unix-88/OPC.c index 9b3d80c3..c4b9a965 100644 --- a/bootstrap/unix-88/OPC.c +++ b/bootstrap/unix-88/OPC.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/OPC.h b/bootstrap/unix-88/OPC.h index 6cc996c8..a1917812 100644 --- a/bootstrap/unix-88/OPC.h +++ b/bootstrap/unix-88/OPC.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPC__h #define OPC__h diff --git a/bootstrap/unix-88/OPM.c b/bootstrap/unix-88/OPM.c index 97726a71..c2258e5b 100644 --- a/bootstrap/unix-88/OPM.c +++ b/bootstrap/unix-88/OPM.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/OPM.h b/bootstrap/unix-88/OPM.h index 91212642..fce0614a 100644 --- a/bootstrap/unix-88/OPM.h +++ b/bootstrap/unix-88/OPM.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPM__h #define OPM__h diff --git a/bootstrap/unix-88/OPP.c b/bootstrap/unix-88/OPP.c index e3840599..bcedf318 100644 --- a/bootstrap/unix-88/OPP.c +++ b/bootstrap/unix-88/OPP.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/OPP.h b/bootstrap/unix-88/OPP.h index 3cadf5a4..978ccdff 100644 --- a/bootstrap/unix-88/OPP.h +++ b/bootstrap/unix-88/OPP.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/unix-88/OPS.c b/bootstrap/unix-88/OPS.c index 898b14b6..845787eb 100644 --- a/bootstrap/unix-88/OPS.c +++ b/bootstrap/unix-88/OPS.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/OPS.h b/bootstrap/unix-88/OPS.h index 34906046..d8134366 100644 --- a/bootstrap/unix-88/OPS.h +++ b/bootstrap/unix-88/OPS.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/unix-88/OPT.c b/bootstrap/unix-88/OPT.c index 0a7b463e..896d5ead 100644 --- a/bootstrap/unix-88/OPT.c +++ b/bootstrap/unix-88/OPT.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/OPT.h b/bootstrap/unix-88/OPT.h index 3a248e3c..e3170fc0 100644 --- a/bootstrap/unix-88/OPT.h +++ b/bootstrap/unix-88/OPT.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPT__h #define OPT__h diff --git a/bootstrap/unix-88/OPV.c b/bootstrap/unix-88/OPV.c index 7c411904..3602bbf6 100644 --- a/bootstrap/unix-88/OPV.c +++ b/bootstrap/unix-88/OPV.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/OPV.h b/bootstrap/unix-88/OPV.h index 34e34ae6..9d02e218 100644 --- a/bootstrap/unix-88/OPV.h +++ b/bootstrap/unix-88/OPV.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPV__h #define OPV__h diff --git a/bootstrap/unix-88/Out.c b/bootstrap/unix-88/Out.c index 09fecc76..ad7ed82c 100644 --- a/bootstrap/unix-88/Out.c +++ b/bootstrap/unix-88/Out.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/Out.h b/bootstrap/unix-88/Out.h index 63fefd3c..247b98de 100644 --- a/bootstrap/unix-88/Out.h +++ b/bootstrap/unix-88/Out.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Out__h #define Out__h diff --git a/bootstrap/unix-88/Platform.c b/bootstrap/unix-88/Platform.c index 46853757..76346d8f 100644 --- a/bootstrap/unix-88/Platform.c +++ b/bootstrap/unix-88/Platform.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -33,7 +33,6 @@ typedef export BOOLEAN Platform_LittleEndian; export INT64 Platform_MainStackFrame; -export INT32 Platform_HaltCode; export INT16 Platform_PID; export CHAR Platform_CWD[256]; export INT16 Platform_ArgCount; @@ -47,21 +46,18 @@ export ADDRESS *Platform_FileIdentity__typ; export BOOLEAN Platform_Absent (INT16 e); export INT16 Platform_ArgPos (CHAR *s, LONGINT s__len); -export void Platform_AssertFail (INT32 code); export INT16 Platform_Chdir (CHAR *n, LONGINT n__len); export INT16 Platform_Close (INT32 h); export BOOLEAN Platform_ConnectionFailed (INT16 e); export void Platform_Delay (INT32 ms); export BOOLEAN Platform_DifferentFilesystems (INT16 e); -static void Platform_DisplayHaltCode (INT32 code); export INT16 Platform_Error (void); -export void Platform_Exit (INT16 code); +export void Platform_Exit (INT32 code); export void Platform_GetArg (INT16 n, CHAR *val, LONGINT val__len); export void Platform_GetClock (INT32 *t, INT32 *d); export void Platform_GetEnv (CHAR *var, LONGINT var__len, CHAR *val, LONGINT val__len); export void Platform_GetIntArg (INT16 n, INT32 *val); export void Platform_GetTimeOfDay (INT32 *sec, INT32 *usec); -export void Platform_Halt (INT32 code); export INT16 Platform_Identify (INT32 h, Platform_FileIdentity *identity, ADDRESS *identity__typ); export INT16 Platform_IdentifyByName (CHAR *n, LONGINT n__len, Platform_FileIdentity *identity, ADDRESS *identity__typ); export BOOLEAN Platform_Inaccessible (INT16 e); @@ -81,7 +77,6 @@ export BOOLEAN Platform_SameFile (Platform_FileIdentity i1, Platform_FileIdentit export BOOLEAN Platform_SameFileTime (Platform_FileIdentity i1, Platform_FileIdentity i2); export INT16 Platform_Seek (INT32 h, INT32 offset, INT16 whence); export void Platform_SetBadInstructionHandler (Platform_SignalHandler handler); -export void Platform_SetHalt (Platform_HaltProcedure p); export void Platform_SetInterruptHandler (Platform_SignalHandler handler); export void Platform_SetMTime (Platform_FileIdentity *target, ADDRESS *target__typ, Platform_FileIdentity source); export void Platform_SetQuitHandler (Platform_SignalHandler handler); @@ -96,10 +91,6 @@ export INT16 Platform_Truncate (INT32 h, INT32 l); export INT16 Platform_Unlink (CHAR *n, LONGINT n__len); export INT16 Platform_Write (INT32 h, INT64 p, INT32 l); static void Platform_YMDHMStoClock (INT32 ye, INT32 mo, INT32 da, INT32 ho, INT32 mi, INT32 se, INT32 *t, INT32 *d); -static void Platform_errch (CHAR c); -static void Platform_errint (INT32 l); -static void Platform_errln (void); -static void Platform_errposint (INT32 l); export BOOLEAN Platform_getEnv (CHAR *var, LONGINT var__len, CHAR *val, LONGINT val__len); #include @@ -131,9 +122,7 @@ extern void Heap_InitHeap(); #define Platform_chdir(n, n__len) chdir((char*)n) #define Platform_closefile(fd) close(fd) #define Platform_err() errno -#define Platform_errc(c) write(1, &c, 1) -#define Platform_errstring(s, s__len) write(1, s, s__len-1) -#define Platform_exit(code) exit(code) +#define Platform_exit(code) exit((int)code) #define Platform_free(address) free((void*)address) #define Platform_fstat(fd) fstat(fd, &s) #define Platform_fsync(fd) fsync(fd) @@ -229,7 +218,6 @@ void Platform_Init (INT32 argc, INT64 argvadr) Platform_ArgCount = __VAL(INT16, argc); av = (Platform_ArgVecPtr)(ADDRESS)argvadr; Platform_ArgVector = (*av)[0]; - Platform_HaltCode = -128; Platform_HeapInitHeap(); } @@ -571,127 +559,11 @@ INT16 Platform_Rename (CHAR *o, LONGINT o__len, CHAR *n, LONGINT n__len) __RETCHK; } -void Platform_Exit (INT16 code) +void Platform_Exit (INT32 code) { Platform_exit(code); } -static void Platform_errch (CHAR c) -{ - Platform_errc(c); -} - -static void Platform_errln (void) -{ - Platform_errch(0x0a); -} - -static void Platform_errposint (INT32 l) -{ - if (l > 10) { - Platform_errposint(__DIV(l, 10)); - } - Platform_errch((CHAR)(48 + (int)__MOD(l, 10))); -} - -static void Platform_errint (INT32 l) -{ - if (l < 0) { - Platform_errch('-'); - l = -l; - } - Platform_errposint(l); -} - -static void Platform_DisplayHaltCode (INT32 code) -{ - switch (code) { - case -1: - Platform_errstring((CHAR*)"Assertion failure.", 19); - break; - case -2: - Platform_errstring((CHAR*)"Index out of range.", 20); - break; - case -3: - Platform_errstring((CHAR*)"Reached end of function without reaching RETURN.", 49); - break; - case -4: - Platform_errstring((CHAR*)"CASE statement: no matching label and no ELSE.", 47); - break; - case -5: - Platform_errstring((CHAR*)"Type guard failed.", 19); - break; - case -6: - Platform_errstring((CHAR*)"Implicit type guard in record assignment failed.", 49); - break; - case -7: - Platform_errstring((CHAR*)"Invalid case in WITH statement.", 32); - break; - case -8: - Platform_errstring((CHAR*)"Value out of range.", 20); - break; - case -9: - Platform_errstring((CHAR*)"Heap interrupted while locked, but lockdepth = 0 at unlock.", 60); - break; - case -10: - Platform_errstring((CHAR*)"NIL access.", 12); - break; - case -11: - Platform_errstring((CHAR*)"Alignment error.", 17); - break; - case -12: - Platform_errstring((CHAR*)"Divide by zero.", 16); - break; - case -13: - Platform_errstring((CHAR*)"Arithmetic overflow/underflow.", 31); - break; - case -14: - Platform_errstring((CHAR*)"Invalid function argument.", 27); - break; - case -15: - Platform_errstring((CHAR*)"Internal error, e.g. Type descriptor size mismatch.", 52); - break; - case -20: - Platform_errstring((CHAR*)"Too many, or negative number of, elements in dynamic array.", 60); - break; - default: - break; - } -} - -void Platform_Halt (INT32 code) -{ - Platform_HaltCode = code; - if (Platform_HaltHandler != NIL) { - (*Platform_HaltHandler)(code); - } - Platform_errstring((CHAR*)"Terminated by Halt(", 20); - Platform_errint(code); - Platform_errstring((CHAR*)"). ", 4); - if (code < 0) { - Platform_DisplayHaltCode(code); - } - Platform_errln(); - Platform_exit(__VAL(INT16, code)); -} - -void Platform_AssertFail (INT32 code) -{ - Platform_errstring((CHAR*)"Assertion failure.", 19); - if (code != 0) { - Platform_errstring((CHAR*)" ASSERT code ", 14); - Platform_errint(code); - Platform_errstring((CHAR*)".", 2); - } - Platform_errln(); - Platform_exit(__VAL(INT16, code)); -} - -void Platform_SetHalt (Platform_HaltProcedure p) -{ - Platform_HaltHandler = p; -} - static void Platform_TestLittleEndian (void) { INT16 i; @@ -708,7 +580,6 @@ export void *Platform__init(void) __INITYP(Platform_FileIdentity, Platform_FileIdentity, 0); /* BEGIN */ Platform_TestLittleEndian(); - Platform_HaltCode = -128; Platform_HaltHandler = NIL; Platform_TimeStart = 0; Platform_TimeStart = Platform_Time(); diff --git a/bootstrap/unix-88/Platform.h b/bootstrap/unix-88/Platform.h index ca01598a..c890c863 100644 --- a/bootstrap/unix-88/Platform.h +++ b/bootstrap/unix-88/Platform.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Platform__h #define Platform__h @@ -11,16 +11,12 @@ typedef char _prvt1[8]; } Platform_FileIdentity; -typedef - void (*Platform_HaltProcedure)(INT32); - typedef void (*Platform_SignalHandler)(INT32); import BOOLEAN Platform_LittleEndian; import INT64 Platform_MainStackFrame; -import INT32 Platform_HaltCode; import INT16 Platform_PID; import CHAR Platform_CWD[256]; import INT16 Platform_ArgCount; @@ -32,20 +28,18 @@ import ADDRESS *Platform_FileIdentity__typ; import BOOLEAN Platform_Absent (INT16 e); import INT16 Platform_ArgPos (CHAR *s, LONGINT s__len); -import void Platform_AssertFail (INT32 code); import INT16 Platform_Chdir (CHAR *n, LONGINT n__len); import INT16 Platform_Close (INT32 h); import BOOLEAN Platform_ConnectionFailed (INT16 e); import void Platform_Delay (INT32 ms); import BOOLEAN Platform_DifferentFilesystems (INT16 e); import INT16 Platform_Error (void); -import void Platform_Exit (INT16 code); +import void Platform_Exit (INT32 code); import void Platform_GetArg (INT16 n, CHAR *val, LONGINT val__len); import void Platform_GetClock (INT32 *t, INT32 *d); import void Platform_GetEnv (CHAR *var, LONGINT var__len, CHAR *val, LONGINT val__len); import void Platform_GetIntArg (INT16 n, INT32 *val); import void Platform_GetTimeOfDay (INT32 *sec, INT32 *usec); -import void Platform_Halt (INT32 code); import INT16 Platform_Identify (INT32 h, Platform_FileIdentity *identity, ADDRESS *identity__typ); import INT16 Platform_IdentifyByName (CHAR *n, LONGINT n__len, Platform_FileIdentity *identity, ADDRESS *identity__typ); import BOOLEAN Platform_Inaccessible (INT16 e); @@ -65,7 +59,6 @@ import BOOLEAN Platform_SameFile (Platform_FileIdentity i1, Platform_FileIdentit import BOOLEAN Platform_SameFileTime (Platform_FileIdentity i1, Platform_FileIdentity i2); import INT16 Platform_Seek (INT32 h, INT32 offset, INT16 whence); import void Platform_SetBadInstructionHandler (Platform_SignalHandler handler); -import void Platform_SetHalt (Platform_HaltProcedure p); import void Platform_SetInterruptHandler (Platform_SignalHandler handler); import void Platform_SetMTime (Platform_FileIdentity *target, ADDRESS *target__typ, Platform_FileIdentity source); import void Platform_SetQuitHandler (Platform_SignalHandler handler); diff --git a/bootstrap/unix-88/Reals.c b/bootstrap/unix-88/Reals.c index f7860591..955cd8dc 100644 --- a/bootstrap/unix-88/Reals.c +++ b/bootstrap/unix-88/Reals.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/Reals.h b/bootstrap/unix-88/Reals.h index 5ed2ec95..fbae270c 100644 --- a/bootstrap/unix-88/Reals.h +++ b/bootstrap/unix-88/Reals.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/unix-88/Strings.c b/bootstrap/unix-88/Strings.c index 5ae2e44e..07e3b700 100644 --- a/bootstrap/unix-88/Strings.c +++ b/bootstrap/unix-88/Strings.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/Strings.h b/bootstrap/unix-88/Strings.h index a9d577f6..e3525cd0 100644 --- a/bootstrap/unix-88/Strings.h +++ b/bootstrap/unix-88/Strings.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/unix-88/Texts.c b/bootstrap/unix-88/Texts.c index 3a949175..deefc817 100644 --- a/bootstrap/unix-88/Texts.c +++ b/bootstrap/unix-88/Texts.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/Texts.h b/bootstrap/unix-88/Texts.h index 216e64dc..6fe829e0 100644 --- a/bootstrap/unix-88/Texts.h +++ b/bootstrap/unix-88/Texts.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/unix-88/VT100.c b/bootstrap/unix-88/VT100.c index 01b8a481..97a7d318 100644 --- a/bootstrap/unix-88/VT100.c +++ b/bootstrap/unix-88/VT100.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/VT100.h b/bootstrap/unix-88/VT100.h index 5ee411dd..577a2d44 100644 --- a/bootstrap/unix-88/VT100.h +++ b/bootstrap/unix-88/VT100.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef VT100__h #define VT100__h diff --git a/bootstrap/unix-88/errors.c b/bootstrap/unix-88/errors.c index b7d411bb..aac72a79 100644 --- a/bootstrap/unix-88/errors.c +++ b/bootstrap/unix-88/errors.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/errors.h b/bootstrap/unix-88/errors.h index fa08de1c..4f03779e 100644 --- a/bootstrap/unix-88/errors.h +++ b/bootstrap/unix-88/errors.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef errors__h #define errors__h diff --git a/bootstrap/unix-88/extTools.c b/bootstrap/unix-88/extTools.c index 74271e5d..3493ea47 100644 --- a/bootstrap/unix-88/extTools.c +++ b/bootstrap/unix-88/extTools.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -7,6 +7,7 @@ #include "SYSTEM.h" #include "Configuration.h" +#include "Modules.h" #include "OPM.h" #include "Out.h" #include "Platform.h" @@ -53,9 +54,9 @@ static void extTools_execute (CHAR *title, LONGINT title__len, CHAR *cmd, LONGIN Out_Ln(); } if (status != 0) { - Platform_Halt(status); + Modules_Halt(status); } else { - Platform_Halt(exitcode); + Modules_Halt(exitcode); } } __DEL(title); @@ -114,6 +115,7 @@ export void *extTools__init(void) { __DEFMOD; __MODULE_IMPORT(Configuration); + __MODULE_IMPORT(Modules); __MODULE_IMPORT(OPM); __MODULE_IMPORT(Out); __MODULE_IMPORT(Platform); diff --git a/bootstrap/unix-88/extTools.h b/bootstrap/unix-88/extTools.h index 9b7b3c17..691b2968 100644 --- a/bootstrap/unix-88/extTools.h +++ b/bootstrap/unix-88/extTools.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef extTools__h #define extTools__h diff --git a/bootstrap/windows-48/Compiler.c b/bootstrap/windows-48/Compiler.c index 87b0392c..a6d5a403 100644 --- a/bootstrap/windows-48/Compiler.c +++ b/bootstrap/windows-48/Compiler.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspamSf */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspamSf */ #define SHORTINT INT8 #define INTEGER INT16 @@ -153,7 +153,7 @@ static void Compiler_Trap (INT32 sig) if (sig == 3) { Platform_Exit(0); } else { - if ((sig == 4 && Platform_HaltCode == -15)) { + if (sig == 4) { OPM_LogWStr((CHAR*)" --- Oberon compiler internal error", 36); OPM_LogWLn(); } diff --git a/bootstrap/windows-48/Configuration.c b/bootstrap/windows-48/Configuration.c index c15b87f9..d84a7f24 100644 --- a/bootstrap/windows-48/Configuration.c +++ b/bootstrap/windows-48/Configuration.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -19,6 +19,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); + __MOVE("1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); __ENDMOD; } diff --git a/bootstrap/windows-48/Configuration.h b/bootstrap/windows-48/Configuration.h index f169a3b6..09543f0b 100644 --- a/bootstrap/windows-48/Configuration.h +++ b/bootstrap/windows-48/Configuration.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Configuration__h #define Configuration__h diff --git a/bootstrap/windows-48/Files.c b/bootstrap/windows-48/Files.c index 1d23fdc4..1b2bcbfc 100644 --- a/bootstrap/windows-48/Files.c +++ b/bootstrap/windows-48/Files.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/Files.h b/bootstrap/windows-48/Files.h index 38b52f44..89ff4f9d 100644 --- a/bootstrap/windows-48/Files.h +++ b/bootstrap/windows-48/Files.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/windows-48/Heap.c b/bootstrap/windows-48/Heap.c index 45b45394..2a5c9464 100644 --- a/bootstrap/windows-48/Heap.c +++ b/bootstrap/windows-48/Heap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -108,8 +108,8 @@ extern void *Heap__init(); extern ADDRESS Platform_MainStackFrame; extern ADDRESS Platform_OSAllocate(ADDRESS size); #define Heap_HeapModuleInit() Heap__init() +#define Heap_ModulesHalt(code) Modules_Halt(code) #define Heap_OSAllocate(size) Platform_OSAllocate(size) -#define Heap_PlatformHalt(code) Platform_Halt(code) #define Heap_PlatformMainStackFrame() Platform_MainStackFrame void Heap_Lock (void) @@ -121,7 +121,7 @@ void Heap_Unlock (void) { Heap_lockdepth -= 1; if ((Heap_interrupted && Heap_lockdepth == 0)) { - Heap_PlatformHalt(-9); + Heap_ModulesHalt(-9); } } diff --git a/bootstrap/windows-48/Heap.h b/bootstrap/windows-48/Heap.h index 8626628d..5f888271 100644 --- a/bootstrap/windows-48/Heap.h +++ b/bootstrap/windows-48/Heap.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ #ifndef Heap__h #define Heap__h diff --git a/bootstrap/windows-48/Modules.c b/bootstrap/windows-48/Modules.c index 5eddf9be..23c71a96 100644 --- a/bootstrap/windows-48/Modules.c +++ b/bootstrap/windows-48/Modules.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -7,6 +7,7 @@ #include "SYSTEM.h" #include "Heap.h" +#include "Platform.h" typedef struct Modules_CmdDesc *Modules_Cmd; @@ -47,9 +48,16 @@ export ADDRESS *Modules_ModuleDesc__typ; export ADDRESS *Modules_CmdDesc__typ; static void Modules_Append (CHAR *a, LONGINT a__len, CHAR *b, LONGINT b__len); +export void Modules_AssertFail (INT32 code); +static void Modules_DisplayHaltCode (INT32 code); export void Modules_Free (CHAR *name, LONGINT name__len, BOOLEAN all); +export void Modules_Halt (INT32 code); export Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, LONGINT name__len); export Modules_Module Modules_ThisMod (CHAR *name, LONGINT name__len); +static void Modules_errch (CHAR c); +export void Modules_errint (INT32 l); +static void Modules_errposint (INT32 l); +export void Modules_errstring (CHAR *s, LONGINT s__len); #define Modules_modules() (Modules_Module)Heap_modules #define Modules_setmodules(m) Heap_modules = m @@ -155,6 +163,121 @@ void Modules_Free (CHAR *name, LONGINT name__len, BOOLEAN all) __DEL(name); } +static void Modules_errch (CHAR c) +{ + INT16 e; + e = Platform_Write(1, (ADDRESS)&c, 1); +} + +void Modules_errstring (CHAR *s, LONGINT s__len) +{ + INT32 i; + __DUP(s, s__len, CHAR); + i = 0; + while ((i < s__len && s[__X(i, s__len)] != 0x00)) { + Modules_errch(s[__X(i, s__len)]); + i += 1; + } + __DEL(s); +} + +static void Modules_errposint (INT32 l) +{ + if (l > 10) { + Modules_errposint(__DIV(l, 10)); + } + Modules_errch((CHAR)(48 + (int)__MOD(l, 10))); +} + +void Modules_errint (INT32 l) +{ + if (l < 0) { + Modules_errch('-'); + l = -l; + } + Modules_errposint(l); +} + +static void Modules_DisplayHaltCode (INT32 code) +{ + switch (code) { + case -1: + Modules_errstring((CHAR*)"Assertion failure.", 19); + break; + case -2: + Modules_errstring((CHAR*)"Index out of range.", 20); + break; + case -3: + Modules_errstring((CHAR*)"Reached end of function without reaching RETURN.", 49); + break; + case -4: + Modules_errstring((CHAR*)"CASE statement: no matching label and no ELSE.", 47); + break; + case -5: + Modules_errstring((CHAR*)"Type guard failed.", 19); + break; + case -6: + Modules_errstring((CHAR*)"Implicit type guard in record assignment failed.", 49); + break; + case -7: + Modules_errstring((CHAR*)"Invalid case in WITH statement.", 32); + break; + case -8: + Modules_errstring((CHAR*)"Value out of range.", 20); + break; + case -9: + Modules_errstring((CHAR*)"Heap interrupted while locked, but lockdepth = 0 at unlock.", 60); + break; + case -10: + Modules_errstring((CHAR*)"NIL access.", 12); + break; + case -11: + Modules_errstring((CHAR*)"Alignment error.", 17); + break; + case -12: + Modules_errstring((CHAR*)"Divide by zero.", 16); + break; + case -13: + Modules_errstring((CHAR*)"Arithmetic overflow/underflow.", 31); + break; + case -14: + Modules_errstring((CHAR*)"Invalid function argument.", 27); + break; + case -15: + Modules_errstring((CHAR*)"Internal error, e.g. Type descriptor size mismatch.", 52); + break; + case -20: + Modules_errstring((CHAR*)"Too many, or negative number of, elements in dynamic array.", 60); + break; + default: + break; + } +} + +void Modules_Halt (INT32 code) +{ + Modules_errstring((CHAR*)"Terminated by Halt(", 20); + Modules_errint(code); + Modules_errstring((CHAR*)"). ", 4); + if (code < 0) { + Modules_DisplayHaltCode(code); + } + Modules_errstring(Platform_NL, 3); + Platform_Exit(code); +} + +void Modules_AssertFail (INT32 code) +{ + Modules_errstring((CHAR*)"Assertion failure.", 19); + if (code != 0) { + Modules_errstring((CHAR*)" ASSERT code ", 14); + Modules_errint(code); + Modules_errstring((CHAR*)".", 2); + } + Modules_errstring(Platform_NL, 3); + Platform_Exit(code); +} + __TDESC(Modules_ModuleDesc, 1, 2) = {__TDFLDS("ModuleDesc", 48), {0, 28, -12}}; __TDESC(Modules_CmdDesc, 1, 1) = {__TDFLDS("CmdDesc", 32), {0, -8}}; @@ -162,6 +285,7 @@ export void *Modules__init(void) { __DEFMOD; __MODULE_IMPORT(Heap); + __MODULE_IMPORT(Platform); __REGMOD("Modules", 0); __INITYP(Modules_ModuleDesc, Modules_ModuleDesc, 0); __INITYP(Modules_CmdDesc, Modules_CmdDesc, 0); diff --git a/bootstrap/windows-48/Modules.h b/bootstrap/windows-48/Modules.h index 2da3fa50..6809ec05 100644 --- a/bootstrap/windows-48/Modules.h +++ b/bootstrap/windows-48/Modules.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Modules__h #define Modules__h @@ -43,9 +43,13 @@ import Modules_ModuleName Modules_imported, Modules_importing; import ADDRESS *Modules_ModuleDesc__typ; import ADDRESS *Modules_CmdDesc__typ; +import void Modules_AssertFail (INT32 code); import void Modules_Free (CHAR *name, LONGINT name__len, BOOLEAN all); +import void Modules_Halt (INT32 code); import Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, LONGINT name__len); import Modules_Module Modules_ThisMod (CHAR *name, LONGINT name__len); +import void Modules_errint (INT32 l); +import void Modules_errstring (CHAR *s, LONGINT s__len); import void *Modules__init(void); #define Modules_modules() (Modules_Module)Heap_modules diff --git a/bootstrap/windows-48/OPB.c b/bootstrap/windows-48/OPB.c index dcac4eb9..8a1b80fe 100644 --- a/bootstrap/windows-48/OPB.c +++ b/bootstrap/windows-48/OPB.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/OPB.h b/bootstrap/windows-48/OPB.h index cb6399f9..0caeb234 100644 --- a/bootstrap/windows-48/OPB.h +++ b/bootstrap/windows-48/OPB.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPB__h #define OPB__h diff --git a/bootstrap/windows-48/OPC.c b/bootstrap/windows-48/OPC.c index 9b3d80c3..c4b9a965 100644 --- a/bootstrap/windows-48/OPC.c +++ b/bootstrap/windows-48/OPC.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/OPC.h b/bootstrap/windows-48/OPC.h index 6cc996c8..a1917812 100644 --- a/bootstrap/windows-48/OPC.h +++ b/bootstrap/windows-48/OPC.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPC__h #define OPC__h diff --git a/bootstrap/windows-48/OPM.c b/bootstrap/windows-48/OPM.c index 0ac4141a..9610f289 100644 --- a/bootstrap/windows-48/OPM.c +++ b/bootstrap/windows-48/OPM.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/OPM.h b/bootstrap/windows-48/OPM.h index 91212642..fce0614a 100644 --- a/bootstrap/windows-48/OPM.h +++ b/bootstrap/windows-48/OPM.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPM__h #define OPM__h diff --git a/bootstrap/windows-48/OPP.c b/bootstrap/windows-48/OPP.c index 6a24e3cd..124bccb1 100644 --- a/bootstrap/windows-48/OPP.c +++ b/bootstrap/windows-48/OPP.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/OPP.h b/bootstrap/windows-48/OPP.h index 3cadf5a4..978ccdff 100644 --- a/bootstrap/windows-48/OPP.h +++ b/bootstrap/windows-48/OPP.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/windows-48/OPS.c b/bootstrap/windows-48/OPS.c index 898b14b6..845787eb 100644 --- a/bootstrap/windows-48/OPS.c +++ b/bootstrap/windows-48/OPS.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/OPS.h b/bootstrap/windows-48/OPS.h index 34906046..d8134366 100644 --- a/bootstrap/windows-48/OPS.h +++ b/bootstrap/windows-48/OPS.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/windows-48/OPT.c b/bootstrap/windows-48/OPT.c index a8951123..46e05141 100644 --- a/bootstrap/windows-48/OPT.c +++ b/bootstrap/windows-48/OPT.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/OPT.h b/bootstrap/windows-48/OPT.h index 3a248e3c..e3170fc0 100644 --- a/bootstrap/windows-48/OPT.h +++ b/bootstrap/windows-48/OPT.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPT__h #define OPT__h diff --git a/bootstrap/windows-48/OPV.c b/bootstrap/windows-48/OPV.c index 77b842f8..bc68a5c6 100644 --- a/bootstrap/windows-48/OPV.c +++ b/bootstrap/windows-48/OPV.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/OPV.h b/bootstrap/windows-48/OPV.h index 34e34ae6..9d02e218 100644 --- a/bootstrap/windows-48/OPV.h +++ b/bootstrap/windows-48/OPV.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPV__h #define OPV__h diff --git a/bootstrap/windows-48/Out.c b/bootstrap/windows-48/Out.c index de6a9e16..dc4c9541 100644 --- a/bootstrap/windows-48/Out.c +++ b/bootstrap/windows-48/Out.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/Out.h b/bootstrap/windows-48/Out.h index 63fefd3c..247b98de 100644 --- a/bootstrap/windows-48/Out.h +++ b/bootstrap/windows-48/Out.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Out__h #define Out__h diff --git a/bootstrap/windows-48/Platform.c b/bootstrap/windows-48/Platform.c index 29801da0..dcf47b13 100644 --- a/bootstrap/windows-48/Platform.c +++ b/bootstrap/windows-48/Platform.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -49,22 +49,19 @@ export ADDRESS *Platform_FileIdentity__typ; export BOOLEAN Platform_Absent (INT16 e); export INT16 Platform_ArgPos (CHAR *s, LONGINT s__len); -export void Platform_AssertFail (INT32 code); export INT16 Platform_Chdir (CHAR *n, LONGINT n__len); export INT16 Platform_Close (INT32 h); export BOOLEAN Platform_ConnectionFailed (INT16 e); export void Platform_Delay (INT32 ms); export BOOLEAN Platform_DifferentFilesystems (INT16 e); -static void Platform_DisplayHaltCode (INT32 code); static void Platform_EnableVT100 (void); export INT16 Platform_Error (void); -export void Platform_Exit (INT16 code); +export void Platform_Exit (INT32 code); export void Platform_GetArg (INT16 n, CHAR *val, LONGINT val__len); export void Platform_GetClock (INT32 *t, INT32 *d); export void Platform_GetEnv (CHAR *var, LONGINT var__len, CHAR *val, LONGINT val__len); export void Platform_GetIntArg (INT16 n, INT32 *val); export void Platform_GetTimeOfDay (INT32 *sec, INT32 *usec); -export void Platform_Halt (INT32 code); export INT16 Platform_Identify (INT32 h, Platform_FileIdentity *identity, ADDRESS *identity__typ); export INT16 Platform_IdentifyByName (CHAR *n, LONGINT n__len, Platform_FileIdentity *identity, ADDRESS *identity__typ); export BOOLEAN Platform_Inaccessible (INT16 e); @@ -84,7 +81,6 @@ export BOOLEAN Platform_SameFile (Platform_FileIdentity i1, Platform_FileIdentit export BOOLEAN Platform_SameFileTime (Platform_FileIdentity i1, Platform_FileIdentity i2); export INT16 Platform_Seek (INT32 h, INT32 o, INT16 r); export void Platform_SetBadInstructionHandler (Platform_SignalHandler handler); -export void Platform_SetHalt (Platform_HaltProcedure p); export void Platform_SetMTime (Platform_FileIdentity *target, ADDRESS *target__typ, Platform_FileIdentity source); export INT16 Platform_Size (INT32 h, INT32 *l); export INT16 Platform_Sync (INT32 h); @@ -97,10 +93,6 @@ export INT16 Platform_Truncate (INT32 h, INT32 limit); export INT16 Platform_Unlink (CHAR *n, LONGINT n__len); export INT16 Platform_Write (INT32 h, INT32 p, INT32 l); static void Platform_YMDHMStoClock (INT16 ye, INT16 mo, INT16 da, INT16 ho, INT16 mi, INT16 se, INT32 *t, INT32 *d); -static void Platform_errch (CHAR c); -static void Platform_errint (INT32 l); -static void Platform_errln (void); -static void Platform_errposint (INT32 l); export BOOLEAN Platform_getEnv (CHAR *var, LONGINT var__len, CHAR *val, LONGINT val__len); #include "WindowsWrapper.h" @@ -137,8 +129,6 @@ extern void Heap_InitHeap(); #define Platform_createProcess(str, str__len) (INTEGER)CreateProcess(0, (char*)str, 0,0,0,0,0,0,&si,&pi) #define Platform_deleteFile(n, n__len) (INTEGER)DeleteFile((char*)n) #define Platform_err() (INTEGER)GetLastError() -#define Platform_errc(c) WriteFile((HANDLE)Platform_StdOut, &c, 1, 0,0) -#define Platform_errstring(s, s__len) WriteFile((HANDLE)Platform_StdOut, s, s__len-1, 0,0) #define Platform_exit(code) ExitProcess((UINT)code) #define Platform_fileTimeToSysTime() SYSTEMTIME st; FileTimeToSystemTime(&ft, &st) #define Platform_flushFileBuffers(h) (INTEGER)FlushFileBuffers((HANDLE)h) @@ -619,128 +609,11 @@ INT16 Platform_Rename (CHAR *o, LONGINT o__len, CHAR *n, LONGINT n__len) __RETCHK; } -void Platform_Exit (INT16 code) +void Platform_Exit (INT32 code) { Platform_exit(code); } -static void Platform_errch (CHAR c) -{ - Platform_errc(c); -} - -static void Platform_errln (void) -{ - Platform_errch(0x0d); - Platform_errch(0x0a); -} - -static void Platform_errposint (INT32 l) -{ - if (l > 10) { - Platform_errposint(__DIV(l, 10)); - } - Platform_errch((CHAR)(48 + (int)__MOD(l, 10))); -} - -static void Platform_errint (INT32 l) -{ - if (l < 0) { - Platform_errch('-'); - l = -l; - } - Platform_errposint(l); -} - -static void Platform_DisplayHaltCode (INT32 code) -{ - switch (code) { - case -1: - Platform_errstring((CHAR*)"Assertion failure.", 19); - break; - case -2: - Platform_errstring((CHAR*)"Index out of range.", 20); - break; - case -3: - Platform_errstring((CHAR*)"Reached end of function without reaching RETURN.", 49); - break; - case -4: - Platform_errstring((CHAR*)"CASE statement: no matching label and no ELSE.", 47); - break; - case -5: - Platform_errstring((CHAR*)"Type guard failed.", 19); - break; - case -6: - Platform_errstring((CHAR*)"Type equality failed.", 22); - break; - case -7: - Platform_errstring((CHAR*)"WITH statement type guard failed.", 34); - break; - case -8: - Platform_errstring((CHAR*)"SHORT: Value too large for shorter type.", 41); - break; - case -9: - Platform_errstring((CHAR*)"Heap interrupted while locked, but lockdepth = 0 at unlock.", 60); - break; - case -10: - Platform_errstring((CHAR*)"NIL access.", 12); - break; - case -11: - Platform_errstring((CHAR*)"Alignment error.", 17); - break; - case -12: - Platform_errstring((CHAR*)"Divide by zero.", 16); - break; - case -13: - Platform_errstring((CHAR*)"Arithmetic overflow/underflow.", 31); - break; - case -14: - Platform_errstring((CHAR*)"Invalid function argument.", 27); - break; - case -15: - Platform_errstring((CHAR*)"Internal error, e.g. Type descriptor size mismatch.", 52); - break; - case -20: - Platform_errstring((CHAR*)"Too many, or negative number of, elements in dynamic array.", 60); - break; - default: - break; - } -} - -void Platform_Halt (INT32 code) -{ - Platform_HaltCode = code; - if (Platform_HaltHandler != NIL) { - (*Platform_HaltHandler)(code); - } - Platform_errstring((CHAR*)"Terminated by Halt(", 20); - Platform_errint(code); - Platform_errstring((CHAR*)"). ", 4); - if (code < 0) { - Platform_DisplayHaltCode(code); - } - Platform_errln(); - Platform_exit(__VAL(INT16, code)); -} - -void Platform_AssertFail (INT32 code) -{ - Platform_errstring((CHAR*)"Assertion failure.", 19); - if (code != 0) { - Platform_errstring((CHAR*)" ASSERT code ", 14); - Platform_errint(code); - Platform_errstring((CHAR*)".", 2); - } - Platform_errln(); - Platform_exit(__VAL(INT16, code)); -} - -void Platform_SetHalt (Platform_HaltProcedure p) -{ - Platform_HaltHandler = p; -} - static void Platform_EnableVT100 (void) { INT32 mode; diff --git a/bootstrap/windows-48/Platform.h b/bootstrap/windows-48/Platform.h index e96a1eec..714c8e3c 100644 --- a/bootstrap/windows-48/Platform.h +++ b/bootstrap/windows-48/Platform.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Platform__h #define Platform__h @@ -11,9 +11,6 @@ typedef char _prvt1[16]; } Platform_FileIdentity; -typedef - void (*Platform_HaltProcedure)(INT32); - typedef void (*Platform_SignalHandler)(INT32); @@ -33,20 +30,18 @@ import ADDRESS *Platform_FileIdentity__typ; import BOOLEAN Platform_Absent (INT16 e); import INT16 Platform_ArgPos (CHAR *s, LONGINT s__len); -import void Platform_AssertFail (INT32 code); import INT16 Platform_Chdir (CHAR *n, LONGINT n__len); import INT16 Platform_Close (INT32 h); import BOOLEAN Platform_ConnectionFailed (INT16 e); import void Platform_Delay (INT32 ms); import BOOLEAN Platform_DifferentFilesystems (INT16 e); import INT16 Platform_Error (void); -import void Platform_Exit (INT16 code); +import void Platform_Exit (INT32 code); import void Platform_GetArg (INT16 n, CHAR *val, LONGINT val__len); import void Platform_GetClock (INT32 *t, INT32 *d); import void Platform_GetEnv (CHAR *var, LONGINT var__len, CHAR *val, LONGINT val__len); import void Platform_GetIntArg (INT16 n, INT32 *val); import void Platform_GetTimeOfDay (INT32 *sec, INT32 *usec); -import void Platform_Halt (INT32 code); import INT16 Platform_Identify (INT32 h, Platform_FileIdentity *identity, ADDRESS *identity__typ); import INT16 Platform_IdentifyByName (CHAR *n, LONGINT n__len, Platform_FileIdentity *identity, ADDRESS *identity__typ); import BOOLEAN Platform_Inaccessible (INT16 e); @@ -66,7 +61,6 @@ import BOOLEAN Platform_SameFile (Platform_FileIdentity i1, Platform_FileIdentit import BOOLEAN Platform_SameFileTime (Platform_FileIdentity i1, Platform_FileIdentity i2); import INT16 Platform_Seek (INT32 h, INT32 o, INT16 r); import void Platform_SetBadInstructionHandler (Platform_SignalHandler handler); -import void Platform_SetHalt (Platform_HaltProcedure p); import void Platform_SetMTime (Platform_FileIdentity *target, ADDRESS *target__typ, Platform_FileIdentity source); import INT16 Platform_Size (INT32 h, INT32 *l); import INT16 Platform_Sync (INT32 h); diff --git a/bootstrap/windows-48/Reals.c b/bootstrap/windows-48/Reals.c index f7860591..955cd8dc 100644 --- a/bootstrap/windows-48/Reals.c +++ b/bootstrap/windows-48/Reals.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/Reals.h b/bootstrap/windows-48/Reals.h index 5ed2ec95..fbae270c 100644 --- a/bootstrap/windows-48/Reals.h +++ b/bootstrap/windows-48/Reals.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/windows-48/Strings.c b/bootstrap/windows-48/Strings.c index 5ae2e44e..07e3b700 100644 --- a/bootstrap/windows-48/Strings.c +++ b/bootstrap/windows-48/Strings.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/Strings.h b/bootstrap/windows-48/Strings.h index a9d577f6..e3525cd0 100644 --- a/bootstrap/windows-48/Strings.h +++ b/bootstrap/windows-48/Strings.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/windows-48/Texts.c b/bootstrap/windows-48/Texts.c index 987b9952..36cd76fb 100644 --- a/bootstrap/windows-48/Texts.c +++ b/bootstrap/windows-48/Texts.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/Texts.h b/bootstrap/windows-48/Texts.h index e902469a..4bae7210 100644 --- a/bootstrap/windows-48/Texts.h +++ b/bootstrap/windows-48/Texts.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/windows-48/VT100.c b/bootstrap/windows-48/VT100.c index 01b8a481..97a7d318 100644 --- a/bootstrap/windows-48/VT100.c +++ b/bootstrap/windows-48/VT100.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/VT100.h b/bootstrap/windows-48/VT100.h index 5ee411dd..577a2d44 100644 --- a/bootstrap/windows-48/VT100.h +++ b/bootstrap/windows-48/VT100.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef VT100__h #define VT100__h diff --git a/bootstrap/windows-48/errors.c b/bootstrap/windows-48/errors.c index b7d411bb..aac72a79 100644 --- a/bootstrap/windows-48/errors.c +++ b/bootstrap/windows-48/errors.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/errors.h b/bootstrap/windows-48/errors.h index fa08de1c..4f03779e 100644 --- a/bootstrap/windows-48/errors.h +++ b/bootstrap/windows-48/errors.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef errors__h #define errors__h diff --git a/bootstrap/windows-48/extTools.c b/bootstrap/windows-48/extTools.c index 74271e5d..3493ea47 100644 --- a/bootstrap/windows-48/extTools.c +++ b/bootstrap/windows-48/extTools.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -7,6 +7,7 @@ #include "SYSTEM.h" #include "Configuration.h" +#include "Modules.h" #include "OPM.h" #include "Out.h" #include "Platform.h" @@ -53,9 +54,9 @@ static void extTools_execute (CHAR *title, LONGINT title__len, CHAR *cmd, LONGIN Out_Ln(); } if (status != 0) { - Platform_Halt(status); + Modules_Halt(status); } else { - Platform_Halt(exitcode); + Modules_Halt(exitcode); } } __DEL(title); @@ -114,6 +115,7 @@ export void *extTools__init(void) { __DEFMOD; __MODULE_IMPORT(Configuration); + __MODULE_IMPORT(Modules); __MODULE_IMPORT(OPM); __MODULE_IMPORT(Out); __MODULE_IMPORT(Platform); diff --git a/bootstrap/windows-48/extTools.h b/bootstrap/windows-48/extTools.h index 9b7b3c17..691b2968 100644 --- a/bootstrap/windows-48/extTools.h +++ b/bootstrap/windows-48/extTools.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef extTools__h #define extTools__h diff --git a/bootstrap/windows-88/Compiler.c b/bootstrap/windows-88/Compiler.c index 87b0392c..a6d5a403 100644 --- a/bootstrap/windows-88/Compiler.c +++ b/bootstrap/windows-88/Compiler.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspamSf */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspamSf */ #define SHORTINT INT8 #define INTEGER INT16 @@ -153,7 +153,7 @@ static void Compiler_Trap (INT32 sig) if (sig == 3) { Platform_Exit(0); } else { - if ((sig == 4 && Platform_HaltCode == -15)) { + if (sig == 4) { OPM_LogWStr((CHAR*)" --- Oberon compiler internal error", 36); OPM_LogWLn(); } diff --git a/bootstrap/windows-88/Configuration.c b/bootstrap/windows-88/Configuration.c index c15b87f9..d84a7f24 100644 --- a/bootstrap/windows-88/Configuration.c +++ b/bootstrap/windows-88/Configuration.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -19,6 +19,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); + __MOVE("1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); __ENDMOD; } diff --git a/bootstrap/windows-88/Configuration.h b/bootstrap/windows-88/Configuration.h index f169a3b6..09543f0b 100644 --- a/bootstrap/windows-88/Configuration.h +++ b/bootstrap/windows-88/Configuration.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Configuration__h #define Configuration__h diff --git a/bootstrap/windows-88/Files.c b/bootstrap/windows-88/Files.c index c519f8d5..fe9b24c9 100644 --- a/bootstrap/windows-88/Files.c +++ b/bootstrap/windows-88/Files.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/Files.h b/bootstrap/windows-88/Files.h index 376ef83e..5b66b18a 100644 --- a/bootstrap/windows-88/Files.h +++ b/bootstrap/windows-88/Files.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/windows-88/Heap.c b/bootstrap/windows-88/Heap.c index 806a01db..46f70cc1 100644 --- a/bootstrap/windows-88/Heap.c +++ b/bootstrap/windows-88/Heap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -108,8 +108,8 @@ extern void *Heap__init(); extern ADDRESS Platform_MainStackFrame; extern ADDRESS Platform_OSAllocate(ADDRESS size); #define Heap_HeapModuleInit() Heap__init() +#define Heap_ModulesHalt(code) Modules_Halt(code) #define Heap_OSAllocate(size) Platform_OSAllocate(size) -#define Heap_PlatformHalt(code) Platform_Halt(code) #define Heap_PlatformMainStackFrame() Platform_MainStackFrame void Heap_Lock (void) @@ -121,7 +121,7 @@ void Heap_Unlock (void) { Heap_lockdepth -= 1; if ((Heap_interrupted && Heap_lockdepth == 0)) { - Heap_PlatformHalt(-9); + Heap_ModulesHalt(-9); } } diff --git a/bootstrap/windows-88/Heap.h b/bootstrap/windows-88/Heap.h index 2603a3eb..06cbd0ec 100644 --- a/bootstrap/windows-88/Heap.h +++ b/bootstrap/windows-88/Heap.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ #ifndef Heap__h #define Heap__h diff --git a/bootstrap/windows-88/Modules.c b/bootstrap/windows-88/Modules.c index f463ec4e..494f9fdc 100644 --- a/bootstrap/windows-88/Modules.c +++ b/bootstrap/windows-88/Modules.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -7,6 +7,7 @@ #include "SYSTEM.h" #include "Heap.h" +#include "Platform.h" typedef struct Modules_CmdDesc *Modules_Cmd; @@ -47,9 +48,16 @@ export ADDRESS *Modules_ModuleDesc__typ; export ADDRESS *Modules_CmdDesc__typ; static void Modules_Append (CHAR *a, LONGINT a__len, CHAR *b, LONGINT b__len); +export void Modules_AssertFail (INT32 code); +static void Modules_DisplayHaltCode (INT32 code); export void Modules_Free (CHAR *name, LONGINT name__len, BOOLEAN all); +export void Modules_Halt (INT32 code); export Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, LONGINT name__len); export Modules_Module Modules_ThisMod (CHAR *name, LONGINT name__len); +static void Modules_errch (CHAR c); +export void Modules_errint (INT32 l); +static void Modules_errposint (INT32 l); +export void Modules_errstring (CHAR *s, LONGINT s__len); #define Modules_modules() (Modules_Module)Heap_modules #define Modules_setmodules(m) Heap_modules = m @@ -155,6 +163,121 @@ void Modules_Free (CHAR *name, LONGINT name__len, BOOLEAN all) __DEL(name); } +static void Modules_errch (CHAR c) +{ + INT16 e; + e = Platform_Write(1, (ADDRESS)&c, 1); +} + +void Modules_errstring (CHAR *s, LONGINT s__len) +{ + INT32 i; + __DUP(s, s__len, CHAR); + i = 0; + while ((i < s__len && s[__X(i, s__len)] != 0x00)) { + Modules_errch(s[__X(i, s__len)]); + i += 1; + } + __DEL(s); +} + +static void Modules_errposint (INT32 l) +{ + if (l > 10) { + Modules_errposint(__DIV(l, 10)); + } + Modules_errch((CHAR)(48 + (int)__MOD(l, 10))); +} + +void Modules_errint (INT32 l) +{ + if (l < 0) { + Modules_errch('-'); + l = -l; + } + Modules_errposint(l); +} + +static void Modules_DisplayHaltCode (INT32 code) +{ + switch (code) { + case -1: + Modules_errstring((CHAR*)"Assertion failure.", 19); + break; + case -2: + Modules_errstring((CHAR*)"Index out of range.", 20); + break; + case -3: + Modules_errstring((CHAR*)"Reached end of function without reaching RETURN.", 49); + break; + case -4: + Modules_errstring((CHAR*)"CASE statement: no matching label and no ELSE.", 47); + break; + case -5: + Modules_errstring((CHAR*)"Type guard failed.", 19); + break; + case -6: + Modules_errstring((CHAR*)"Implicit type guard in record assignment failed.", 49); + break; + case -7: + Modules_errstring((CHAR*)"Invalid case in WITH statement.", 32); + break; + case -8: + Modules_errstring((CHAR*)"Value out of range.", 20); + break; + case -9: + Modules_errstring((CHAR*)"Heap interrupted while locked, but lockdepth = 0 at unlock.", 60); + break; + case -10: + Modules_errstring((CHAR*)"NIL access.", 12); + break; + case -11: + Modules_errstring((CHAR*)"Alignment error.", 17); + break; + case -12: + Modules_errstring((CHAR*)"Divide by zero.", 16); + break; + case -13: + Modules_errstring((CHAR*)"Arithmetic overflow/underflow.", 31); + break; + case -14: + Modules_errstring((CHAR*)"Invalid function argument.", 27); + break; + case -15: + Modules_errstring((CHAR*)"Internal error, e.g. Type descriptor size mismatch.", 52); + break; + case -20: + Modules_errstring((CHAR*)"Too many, or negative number of, elements in dynamic array.", 60); + break; + default: + break; + } +} + +void Modules_Halt (INT32 code) +{ + Modules_errstring((CHAR*)"Terminated by Halt(", 20); + Modules_errint(code); + Modules_errstring((CHAR*)"). ", 4); + if (code < 0) { + Modules_DisplayHaltCode(code); + } + Modules_errstring(Platform_NL, 3); + Platform_Exit(code); +} + +void Modules_AssertFail (INT32 code) +{ + Modules_errstring((CHAR*)"Assertion failure.", 19); + if (code != 0) { + Modules_errstring((CHAR*)" ASSERT code ", 14); + Modules_errint(code); + Modules_errstring((CHAR*)".", 2); + } + Modules_errstring(Platform_NL, 3); + Platform_Exit(code); +} + __TDESC(Modules_ModuleDesc, 1, 2) = {__TDFLDS("ModuleDesc", 64), {0, 32, -24}}; __TDESC(Modules_CmdDesc, 1, 1) = {__TDFLDS("CmdDesc", 40), {0, -16}}; @@ -162,6 +285,7 @@ export void *Modules__init(void) { __DEFMOD; __MODULE_IMPORT(Heap); + __MODULE_IMPORT(Platform); __REGMOD("Modules", 0); __INITYP(Modules_ModuleDesc, Modules_ModuleDesc, 0); __INITYP(Modules_CmdDesc, Modules_CmdDesc, 0); diff --git a/bootstrap/windows-88/Modules.h b/bootstrap/windows-88/Modules.h index 2da3fa50..6809ec05 100644 --- a/bootstrap/windows-88/Modules.h +++ b/bootstrap/windows-88/Modules.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Modules__h #define Modules__h @@ -43,9 +43,13 @@ import Modules_ModuleName Modules_imported, Modules_importing; import ADDRESS *Modules_ModuleDesc__typ; import ADDRESS *Modules_CmdDesc__typ; +import void Modules_AssertFail (INT32 code); import void Modules_Free (CHAR *name, LONGINT name__len, BOOLEAN all); +import void Modules_Halt (INT32 code); import Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, LONGINT name__len); import Modules_Module Modules_ThisMod (CHAR *name, LONGINT name__len); +import void Modules_errint (INT32 l); +import void Modules_errstring (CHAR *s, LONGINT s__len); import void *Modules__init(void); #define Modules_modules() (Modules_Module)Heap_modules diff --git a/bootstrap/windows-88/OPB.c b/bootstrap/windows-88/OPB.c index dcac4eb9..8a1b80fe 100644 --- a/bootstrap/windows-88/OPB.c +++ b/bootstrap/windows-88/OPB.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/OPB.h b/bootstrap/windows-88/OPB.h index cb6399f9..0caeb234 100644 --- a/bootstrap/windows-88/OPB.h +++ b/bootstrap/windows-88/OPB.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPB__h #define OPB__h diff --git a/bootstrap/windows-88/OPC.c b/bootstrap/windows-88/OPC.c index 9b3d80c3..c4b9a965 100644 --- a/bootstrap/windows-88/OPC.c +++ b/bootstrap/windows-88/OPC.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/OPC.h b/bootstrap/windows-88/OPC.h index 6cc996c8..a1917812 100644 --- a/bootstrap/windows-88/OPC.h +++ b/bootstrap/windows-88/OPC.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPC__h #define OPC__h diff --git a/bootstrap/windows-88/OPM.c b/bootstrap/windows-88/OPM.c index 97726a71..c2258e5b 100644 --- a/bootstrap/windows-88/OPM.c +++ b/bootstrap/windows-88/OPM.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/OPM.h b/bootstrap/windows-88/OPM.h index 91212642..fce0614a 100644 --- a/bootstrap/windows-88/OPM.h +++ b/bootstrap/windows-88/OPM.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPM__h #define OPM__h diff --git a/bootstrap/windows-88/OPP.c b/bootstrap/windows-88/OPP.c index e3840599..bcedf318 100644 --- a/bootstrap/windows-88/OPP.c +++ b/bootstrap/windows-88/OPP.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/OPP.h b/bootstrap/windows-88/OPP.h index 3cadf5a4..978ccdff 100644 --- a/bootstrap/windows-88/OPP.h +++ b/bootstrap/windows-88/OPP.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/windows-88/OPS.c b/bootstrap/windows-88/OPS.c index 898b14b6..845787eb 100644 --- a/bootstrap/windows-88/OPS.c +++ b/bootstrap/windows-88/OPS.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/OPS.h b/bootstrap/windows-88/OPS.h index 34906046..d8134366 100644 --- a/bootstrap/windows-88/OPS.h +++ b/bootstrap/windows-88/OPS.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/windows-88/OPT.c b/bootstrap/windows-88/OPT.c index 0a7b463e..896d5ead 100644 --- a/bootstrap/windows-88/OPT.c +++ b/bootstrap/windows-88/OPT.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/OPT.h b/bootstrap/windows-88/OPT.h index 3a248e3c..e3170fc0 100644 --- a/bootstrap/windows-88/OPT.h +++ b/bootstrap/windows-88/OPT.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPT__h #define OPT__h diff --git a/bootstrap/windows-88/OPV.c b/bootstrap/windows-88/OPV.c index 7c411904..3602bbf6 100644 --- a/bootstrap/windows-88/OPV.c +++ b/bootstrap/windows-88/OPV.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/OPV.h b/bootstrap/windows-88/OPV.h index 34e34ae6..9d02e218 100644 --- a/bootstrap/windows-88/OPV.h +++ b/bootstrap/windows-88/OPV.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPV__h #define OPV__h diff --git a/bootstrap/windows-88/Out.c b/bootstrap/windows-88/Out.c index de6a9e16..dc4c9541 100644 --- a/bootstrap/windows-88/Out.c +++ b/bootstrap/windows-88/Out.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/Out.h b/bootstrap/windows-88/Out.h index 63fefd3c..247b98de 100644 --- a/bootstrap/windows-88/Out.h +++ b/bootstrap/windows-88/Out.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Out__h #define Out__h diff --git a/bootstrap/windows-88/Platform.c b/bootstrap/windows-88/Platform.c index 151ed04c..91508fdf 100644 --- a/bootstrap/windows-88/Platform.c +++ b/bootstrap/windows-88/Platform.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -49,22 +49,19 @@ export ADDRESS *Platform_FileIdentity__typ; export BOOLEAN Platform_Absent (INT16 e); export INT16 Platform_ArgPos (CHAR *s, LONGINT s__len); -export void Platform_AssertFail (INT32 code); export INT16 Platform_Chdir (CHAR *n, LONGINT n__len); export INT16 Platform_Close (INT64 h); export BOOLEAN Platform_ConnectionFailed (INT16 e); export void Platform_Delay (INT32 ms); export BOOLEAN Platform_DifferentFilesystems (INT16 e); -static void Platform_DisplayHaltCode (INT32 code); static void Platform_EnableVT100 (void); export INT16 Platform_Error (void); -export void Platform_Exit (INT16 code); +export void Platform_Exit (INT32 code); export void Platform_GetArg (INT16 n, CHAR *val, LONGINT val__len); export void Platform_GetClock (INT32 *t, INT32 *d); export void Platform_GetEnv (CHAR *var, LONGINT var__len, CHAR *val, LONGINT val__len); export void Platform_GetIntArg (INT16 n, INT32 *val); export void Platform_GetTimeOfDay (INT32 *sec, INT32 *usec); -export void Platform_Halt (INT32 code); export INT16 Platform_Identify (INT64 h, Platform_FileIdentity *identity, ADDRESS *identity__typ); export INT16 Platform_IdentifyByName (CHAR *n, LONGINT n__len, Platform_FileIdentity *identity, ADDRESS *identity__typ); export BOOLEAN Platform_Inaccessible (INT16 e); @@ -84,7 +81,6 @@ export BOOLEAN Platform_SameFile (Platform_FileIdentity i1, Platform_FileIdentit export BOOLEAN Platform_SameFileTime (Platform_FileIdentity i1, Platform_FileIdentity i2); export INT16 Platform_Seek (INT64 h, INT32 o, INT16 r); export void Platform_SetBadInstructionHandler (Platform_SignalHandler handler); -export void Platform_SetHalt (Platform_HaltProcedure p); export void Platform_SetMTime (Platform_FileIdentity *target, ADDRESS *target__typ, Platform_FileIdentity source); export INT16 Platform_Size (INT64 h, INT32 *l); export INT16 Platform_Sync (INT64 h); @@ -97,10 +93,6 @@ export INT16 Platform_Truncate (INT64 h, INT32 limit); export INT16 Platform_Unlink (CHAR *n, LONGINT n__len); export INT16 Platform_Write (INT64 h, INT64 p, INT32 l); static void Platform_YMDHMStoClock (INT16 ye, INT16 mo, INT16 da, INT16 ho, INT16 mi, INT16 se, INT32 *t, INT32 *d); -static void Platform_errch (CHAR c); -static void Platform_errint (INT32 l); -static void Platform_errln (void); -static void Platform_errposint (INT32 l); export BOOLEAN Platform_getEnv (CHAR *var, LONGINT var__len, CHAR *val, LONGINT val__len); #include "WindowsWrapper.h" @@ -137,8 +129,6 @@ extern void Heap_InitHeap(); #define Platform_createProcess(str, str__len) (INTEGER)CreateProcess(0, (char*)str, 0,0,0,0,0,0,&si,&pi) #define Platform_deleteFile(n, n__len) (INTEGER)DeleteFile((char*)n) #define Platform_err() (INTEGER)GetLastError() -#define Platform_errc(c) WriteFile((HANDLE)Platform_StdOut, &c, 1, 0,0) -#define Platform_errstring(s, s__len) WriteFile((HANDLE)Platform_StdOut, s, s__len-1, 0,0) #define Platform_exit(code) ExitProcess((UINT)code) #define Platform_fileTimeToSysTime() SYSTEMTIME st; FileTimeToSystemTime(&ft, &st) #define Platform_flushFileBuffers(h) (INTEGER)FlushFileBuffers((HANDLE)h) @@ -619,128 +609,11 @@ INT16 Platform_Rename (CHAR *o, LONGINT o__len, CHAR *n, LONGINT n__len) __RETCHK; } -void Platform_Exit (INT16 code) +void Platform_Exit (INT32 code) { Platform_exit(code); } -static void Platform_errch (CHAR c) -{ - Platform_errc(c); -} - -static void Platform_errln (void) -{ - Platform_errch(0x0d); - Platform_errch(0x0a); -} - -static void Platform_errposint (INT32 l) -{ - if (l > 10) { - Platform_errposint(__DIV(l, 10)); - } - Platform_errch((CHAR)(48 + (int)__MOD(l, 10))); -} - -static void Platform_errint (INT32 l) -{ - if (l < 0) { - Platform_errch('-'); - l = -l; - } - Platform_errposint(l); -} - -static void Platform_DisplayHaltCode (INT32 code) -{ - switch (code) { - case -1: - Platform_errstring((CHAR*)"Assertion failure.", 19); - break; - case -2: - Platform_errstring((CHAR*)"Index out of range.", 20); - break; - case -3: - Platform_errstring((CHAR*)"Reached end of function without reaching RETURN.", 49); - break; - case -4: - Platform_errstring((CHAR*)"CASE statement: no matching label and no ELSE.", 47); - break; - case -5: - Platform_errstring((CHAR*)"Type guard failed.", 19); - break; - case -6: - Platform_errstring((CHAR*)"Type equality failed.", 22); - break; - case -7: - Platform_errstring((CHAR*)"WITH statement type guard failed.", 34); - break; - case -8: - Platform_errstring((CHAR*)"SHORT: Value too large for shorter type.", 41); - break; - case -9: - Platform_errstring((CHAR*)"Heap interrupted while locked, but lockdepth = 0 at unlock.", 60); - break; - case -10: - Platform_errstring((CHAR*)"NIL access.", 12); - break; - case -11: - Platform_errstring((CHAR*)"Alignment error.", 17); - break; - case -12: - Platform_errstring((CHAR*)"Divide by zero.", 16); - break; - case -13: - Platform_errstring((CHAR*)"Arithmetic overflow/underflow.", 31); - break; - case -14: - Platform_errstring((CHAR*)"Invalid function argument.", 27); - break; - case -15: - Platform_errstring((CHAR*)"Internal error, e.g. Type descriptor size mismatch.", 52); - break; - case -20: - Platform_errstring((CHAR*)"Too many, or negative number of, elements in dynamic array.", 60); - break; - default: - break; - } -} - -void Platform_Halt (INT32 code) -{ - Platform_HaltCode = code; - if (Platform_HaltHandler != NIL) { - (*Platform_HaltHandler)(code); - } - Platform_errstring((CHAR*)"Terminated by Halt(", 20); - Platform_errint(code); - Platform_errstring((CHAR*)"). ", 4); - if (code < 0) { - Platform_DisplayHaltCode(code); - } - Platform_errln(); - Platform_exit(__VAL(INT16, code)); -} - -void Platform_AssertFail (INT32 code) -{ - Platform_errstring((CHAR*)"Assertion failure.", 19); - if (code != 0) { - Platform_errstring((CHAR*)" ASSERT code ", 14); - Platform_errint(code); - Platform_errstring((CHAR*)".", 2); - } - Platform_errln(); - Platform_exit(__VAL(INT16, code)); -} - -void Platform_SetHalt (Platform_HaltProcedure p) -{ - Platform_HaltHandler = p; -} - static void Platform_EnableVT100 (void) { INT32 mode; diff --git a/bootstrap/windows-88/Platform.h b/bootstrap/windows-88/Platform.h index e3841844..c6c57d6a 100644 --- a/bootstrap/windows-88/Platform.h +++ b/bootstrap/windows-88/Platform.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Platform__h #define Platform__h @@ -11,9 +11,6 @@ typedef char _prvt1[16]; } Platform_FileIdentity; -typedef - void (*Platform_HaltProcedure)(INT32); - typedef void (*Platform_SignalHandler)(INT32); @@ -33,20 +30,18 @@ import ADDRESS *Platform_FileIdentity__typ; import BOOLEAN Platform_Absent (INT16 e); import INT16 Platform_ArgPos (CHAR *s, LONGINT s__len); -import void Platform_AssertFail (INT32 code); import INT16 Platform_Chdir (CHAR *n, LONGINT n__len); import INT16 Platform_Close (INT64 h); import BOOLEAN Platform_ConnectionFailed (INT16 e); import void Platform_Delay (INT32 ms); import BOOLEAN Platform_DifferentFilesystems (INT16 e); import INT16 Platform_Error (void); -import void Platform_Exit (INT16 code); +import void Platform_Exit (INT32 code); import void Platform_GetArg (INT16 n, CHAR *val, LONGINT val__len); import void Platform_GetClock (INT32 *t, INT32 *d); import void Platform_GetEnv (CHAR *var, LONGINT var__len, CHAR *val, LONGINT val__len); import void Platform_GetIntArg (INT16 n, INT32 *val); import void Platform_GetTimeOfDay (INT32 *sec, INT32 *usec); -import void Platform_Halt (INT32 code); import INT16 Platform_Identify (INT64 h, Platform_FileIdentity *identity, ADDRESS *identity__typ); import INT16 Platform_IdentifyByName (CHAR *n, LONGINT n__len, Platform_FileIdentity *identity, ADDRESS *identity__typ); import BOOLEAN Platform_Inaccessible (INT16 e); @@ -66,7 +61,6 @@ import BOOLEAN Platform_SameFile (Platform_FileIdentity i1, Platform_FileIdentit import BOOLEAN Platform_SameFileTime (Platform_FileIdentity i1, Platform_FileIdentity i2); import INT16 Platform_Seek (INT64 h, INT32 o, INT16 r); import void Platform_SetBadInstructionHandler (Platform_SignalHandler handler); -import void Platform_SetHalt (Platform_HaltProcedure p); import void Platform_SetMTime (Platform_FileIdentity *target, ADDRESS *target__typ, Platform_FileIdentity source); import INT16 Platform_Size (INT64 h, INT32 *l); import INT16 Platform_Sync (INT64 h); diff --git a/bootstrap/windows-88/Reals.c b/bootstrap/windows-88/Reals.c index f7860591..955cd8dc 100644 --- a/bootstrap/windows-88/Reals.c +++ b/bootstrap/windows-88/Reals.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/Reals.h b/bootstrap/windows-88/Reals.h index 5ed2ec95..fbae270c 100644 --- a/bootstrap/windows-88/Reals.h +++ b/bootstrap/windows-88/Reals.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/windows-88/Strings.c b/bootstrap/windows-88/Strings.c index 5ae2e44e..07e3b700 100644 --- a/bootstrap/windows-88/Strings.c +++ b/bootstrap/windows-88/Strings.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/Strings.h b/bootstrap/windows-88/Strings.h index a9d577f6..e3525cd0 100644 --- a/bootstrap/windows-88/Strings.h +++ b/bootstrap/windows-88/Strings.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/windows-88/Texts.c b/bootstrap/windows-88/Texts.c index 3a949175..deefc817 100644 --- a/bootstrap/windows-88/Texts.c +++ b/bootstrap/windows-88/Texts.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/Texts.h b/bootstrap/windows-88/Texts.h index 216e64dc..6fe829e0 100644 --- a/bootstrap/windows-88/Texts.h +++ b/bootstrap/windows-88/Texts.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/windows-88/VT100.c b/bootstrap/windows-88/VT100.c index 01b8a481..97a7d318 100644 --- a/bootstrap/windows-88/VT100.c +++ b/bootstrap/windows-88/VT100.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/VT100.h b/bootstrap/windows-88/VT100.h index 5ee411dd..577a2d44 100644 --- a/bootstrap/windows-88/VT100.h +++ b/bootstrap/windows-88/VT100.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef VT100__h #define VT100__h diff --git a/bootstrap/windows-88/errors.c b/bootstrap/windows-88/errors.c index b7d411bb..aac72a79 100644 --- a/bootstrap/windows-88/errors.c +++ b/bootstrap/windows-88/errors.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/errors.h b/bootstrap/windows-88/errors.h index fa08de1c..4f03779e 100644 --- a/bootstrap/windows-88/errors.h +++ b/bootstrap/windows-88/errors.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef errors__h #define errors__h diff --git a/bootstrap/windows-88/extTools.c b/bootstrap/windows-88/extTools.c index 74271e5d..3493ea47 100644 --- a/bootstrap/windows-88/extTools.c +++ b/bootstrap/windows-88/extTools.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -7,6 +7,7 @@ #include "SYSTEM.h" #include "Configuration.h" +#include "Modules.h" #include "OPM.h" #include "Out.h" #include "Platform.h" @@ -53,9 +54,9 @@ static void extTools_execute (CHAR *title, LONGINT title__len, CHAR *cmd, LONGIN Out_Ln(); } if (status != 0) { - Platform_Halt(status); + Modules_Halt(status); } else { - Platform_Halt(exitcode); + Modules_Halt(exitcode); } } __DEL(title); @@ -114,6 +115,7 @@ export void *extTools__init(void) { __DEFMOD; __MODULE_IMPORT(Configuration); + __MODULE_IMPORT(Modules); __MODULE_IMPORT(OPM); __MODULE_IMPORT(Out); __MODULE_IMPORT(Platform); diff --git a/bootstrap/windows-88/extTools.h b/bootstrap/windows-88/extTools.h index 9b7b3c17..691b2968 100644 --- a/bootstrap/windows-88/extTools.h +++ b/bootstrap/windows-88/extTools.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/11/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/11/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef extTools__h #define extTools__h diff --git a/src/compiler/Compiler.Mod b/src/compiler/Compiler.Mod index c8e3c40f..6c6381e6 100644 --- a/src/compiler/Compiler.Mod +++ b/src/compiler/Compiler.Mod @@ -135,9 +135,8 @@ MODULE Compiler; (* J. Templ 3.2.95 *) IF sig = 3 THEN Platform.Exit(0) ELSE - IF (sig = 4) & (Platform.HaltCode = -15) THEN - OPM.LogWStr(" --- Oberon compiler internal error"); - OPM.LogWLn + IF sig = 4 THEN + OPM.LogWStr(" --- Oberon compiler internal error"); OPM.LogWLn END ; Platform.Exit(2) END diff --git a/src/compiler/extTools.Mod b/src/compiler/extTools.Mod index 8c84ecae..2847768e 100644 --- a/src/compiler/extTools.Mod +++ b/src/compiler/extTools.Mod @@ -1,6 +1,6 @@ MODULE extTools; -IMPORT Strings, Out, Configuration, Platform, OPM; +IMPORT Strings, Out, Configuration, Platform, Modules, OPM; VAR CFLAGS: ARRAY 1023 OF CHAR; @@ -24,7 +24,7 @@ BEGIN IF (status = 0) & (exitcode = 127) THEN Out.String("Is the C compiler in the current command path?"); Out.Ln END; - IF status # 0 THEN Platform.Halt(status) ELSE Platform.Halt(exitcode) END + IF status # 0 THEN Modules.Halt(status) ELSE Modules.Halt(exitcode) END END; END execute; diff --git a/src/library/s3/ethReals.Mod b/src/library/s3/ethReals.Mod index ea2d9d9f..484b186c 100644 --- a/src/library/s3/ethReals.Mod +++ b/src/library/s3/ethReals.Mod @@ -10,7 +10,7 @@ Implemented by Bernd Moesli, Seminar for Applied Mathematics, Swiss Federal Institute of Technology Z…rich. *) -IMPORT SYSTEM, Platform; +IMPORT SYSTEM, Modules; (* Bernd Moesli Seminar for Applied Mathematics @@ -50,7 +50,7 @@ BEGIN RETURN SHORT(ASH(SYSTEM.VAL(INTEGER, x), -23)) MOD 256 ELSIF SIZE(LONGINT) = 4 THEN RETURN SHORT(ASH(SYSTEM.VAL(LONGINT, x), -23)) MOD 256 - ELSE Platform.Halt(-15); + ELSE Modules.Halt(-15); END END Expo; @@ -77,7 +77,7 @@ BEGIN SYSTEM.GET(SYSTEM.ADR(x), i); i := SHORT(ASH(ASH(ASH(i, -31), 8) + e MOD 256, 23) + i MOD ASH(1, 23)); SYSTEM.PUT(SYSTEM.ADR(x), i) - ELSE Platform.Halt(-15) + ELSE Modules.Halt(-15) END END SetExpo; @@ -93,7 +93,7 @@ BEGIN SYSTEM.GET(SYSTEM.ADR(x) + H, i); i := SHORT(ASH(ASH(ASH(i, -31), 11) + e MOD 2048, 20) + i MOD ASH(1, 20)); SYSTEM.PUT(SYSTEM.ADR(x) + H, i) - ELSE Platform.Halt(-15) + ELSE Modules.Halt(-15) END END SetExpoL; @@ -105,7 +105,7 @@ BEGIN SYSTEM.PUT(SYSTEM.ADR(x), h) ELSIF SIZE(INTEGER) = 4 THEN SYSTEM.PUT(SYSTEM.ADR(x), SYSTEM.VAL(INTEGER, h)) - ELSE Platform.Halt(-15) + ELSE Modules.Halt(-15) END; RETURN x END Real; @@ -120,7 +120,7 @@ BEGIN ELSIF SIZE(INTEGER) = 4 THEN SYSTEM.PUT(SYSTEM.ADR(x) + H, SYSTEM.VAL(INTEGER, h)); SYSTEM.PUT(SYSTEM.ADR(x) + L, SYSTEM.VAL(INTEGER, l)) - ELSE Platform.Halt(-15) + ELSE Modules.Halt(-15) END; RETURN x END RealL; @@ -133,7 +133,7 @@ BEGIN SYSTEM.PUT(SYSTEM.ADR(l), x); RETURN l ELSIF SIZE(INTEGER) = 4 THEN SYSTEM.PUT(SYSTEM.ADR(i), x); RETURN i - ELSE Platform.Halt(-15) + ELSE Modules.Halt(-15) END END Int; @@ -147,7 +147,7 @@ BEGIN ELSIF SIZE(INTEGER) = 4 THEN SYSTEM.GET(SYSTEM.ADR(x) + H, i); h := i; SYSTEM.GET(SYSTEM.ADR(x) + L, i); l := i - ELSE Platform.Halt(-15) + ELSE Modules.Halt(-15) END END IntL; diff --git a/src/runtime/Heap.Mod b/src/runtime/Heap.Mod index a74b4684..550867f7 100644 --- a/src/runtime/Heap.Mod +++ b/src/runtime/Heap.Mod @@ -99,13 +99,13 @@ MODULE Heap; INC(lockdepth); END Lock; - PROCEDURE -PlatformHalt(code: LONGINT) "Platform_Halt(code)"; + PROCEDURE -ModulesHalt(code: LONGINT) "Modules_Halt(code)"; PROCEDURE Unlock*; BEGIN DEC(lockdepth); IF interrupted & (lockdepth = 0) THEN - PlatformHalt(-9); + ModulesHalt(-9); END END Unlock; diff --git a/src/runtime/Modules.Mod b/src/runtime/Modules.Mod index 26268749..33d210d6 100644 --- a/src/runtime/Modules.Mod +++ b/src/runtime/Modules.Mod @@ -3,7 +3,7 @@ MODULE Modules; (* jt 6.1.96 *) (* access to list of modules and commands, based on ETH Oberon *) - IMPORT SYSTEM, Heap; + IMPORT SYSTEM, Heap, Platform; CONST ModNameLen* = 20; @@ -93,4 +93,69 @@ MODULE Modules; (* jt 6.1.96 *) END END Free; + + (* Run time error reporting. *) + + PROCEDURE errch(c: CHAR); (* Here we favour simplicity over efficiency, so no buffering. *) + VAR e: Platform.ErrorCode; + BEGIN e := Platform.Write(1, SYSTEM.ADR(c), 1) + END errch; + + PROCEDURE errstring*(s: ARRAY OF CHAR); + VAR i: LONGINT; + BEGIN i := 0; + WHILE (i10 THEN errposint(l DIV 10) END; errch(CHR(ORD('0') + (l MOD 10))) END errposint; + + PROCEDURE errint*(l: SYSTEM.INT32); + BEGIN IF l<0 THEN errch('-'); l := -l END; errposint(l) END errint; + + PROCEDURE DisplayHaltCode(code: SYSTEM.INT32); + BEGIN + CASE code OF + | -1: errstring("Assertion failure.") + | -2: errstring("Index out of range.") + | -3: errstring("Reached end of function without reaching RETURN.") + | -4: errstring("CASE statement: no matching label and no ELSE.") + | -5: errstring("Type guard failed.") + | -6: errstring("Implicit type guard in record assignment failed.") + | -7: errstring("Invalid case in WITH statement.") + | -8: errstring("Value out of range.") + | -9: errstring("Heap interrupted while locked, but lockdepth = 0 at unlock.") + |-10: errstring("NIL access."); + |-11: errstring("Alignment error."); + |-12: errstring("Divide by zero."); + |-13: errstring("Arithmetic overflow/underflow."); + |-14: errstring("Invalid function argument."); + |-15: errstring("Internal error, e.g. Type descriptor size mismatch.") + |-20: errstring("Too many, or negative number of, elements in dynamic array.") + ELSE + END + END DisplayHaltCode; + + PROCEDURE Halt*(code: SYSTEM.INT32); + BEGIN + (*IF HaltHandler # NIL THEN HaltHandler(code) END;*) + errstring("Terminated by Halt("); errint(code); errstring("). "); + IF code < 0 THEN DisplayHaltCode(code) END; + errstring(Platform.NL); + Platform.Exit(code); + END Halt; + + PROCEDURE AssertFail*(code: SYSTEM.INT32); + BEGIN + errstring("Assertion failure."); + IF code # 0 THEN errstring(" ASSERT code "); errint(code); errstring("."); END; + errstring(Platform.NL); + Platform.Exit(code); + END AssertFail; + + (* + PROCEDURE SetHalt*(p: HaltProcedure); + BEGIN HaltHandler := p; END SetHalt; + *) + END Modules. diff --git a/src/runtime/Platformunix.Mod b/src/runtime/Platformunix.Mod index 6f7dc4a0..27ce9539 100644 --- a/src/runtime/Platformunix.Mod +++ b/src/runtime/Platformunix.Mod @@ -28,7 +28,6 @@ TYPE VAR LittleEndian-: BOOLEAN; MainStackFrame-: SYSTEM.ADDRESS; - HaltCode-: LONGINT; PID-: INTEGER; (* Note: Must be updated by Fork implementation *) CWD-: ARRAY 256 OF CHAR; ArgCount-: INTEGER; @@ -131,7 +130,6 @@ BEGIN ArgCount := SYSTEM.VAL(INTEGER, argc); av := SYSTEM.VAL(ArgVecPtr, argvadr); ArgVector := av[0]; - HaltCode := -128; (* This function (Platform.Init) is called at program startup BEFORE any modules have been initalised. In turn we must initialise the heap @@ -464,66 +462,8 @@ END Rename; (* Process termination *) -PROCEDURE -exit(code: INTEGER) "exit(code)"; -PROCEDURE Exit*(code: INTEGER); -BEGIN exit(code) END Exit; - -PROCEDURE -errstring(s: ARRAY OF CHAR) 'write(1, s, s__len-1)'; -PROCEDURE -errc (c: CHAR) 'write(1, &c, 1)'; -PROCEDURE errch(c: CHAR); BEGIN errc(c) END errch; -PROCEDURE errln; BEGIN errch(0AX) END errln; - -PROCEDURE errposint(l: LONGINT); -BEGIN IF l>10 THEN errposint(l DIV 10) END; errch(CHR(ORD('0') + (l MOD 10))) END errposint; - -PROCEDURE errint(l: LONGINT); -BEGIN IF l<0 THEN errch('-'); l := -l END; errposint(l) END errint; - -PROCEDURE DisplayHaltCode(code: LONGINT); -BEGIN - CASE code OF - | -1: errstring("Assertion failure.") - | -2: errstring("Index out of range.") - | -3: errstring("Reached end of function without reaching RETURN.") - | -4: errstring("CASE statement: no matching label and no ELSE.") - | -5: errstring("Type guard failed.") - | -6: errstring("Implicit type guard in record assignment failed.") - | -7: errstring("Invalid case in WITH statement.") - | -8: errstring("Value out of range.") - | -9: errstring("Heap interrupted while locked, but lockdepth = 0 at unlock.") - |-10: errstring("NIL access."); - |-11: errstring("Alignment error."); - |-12: errstring("Divide by zero."); - |-13: errstring("Arithmetic overflow/underflow."); - |-14: errstring("Invalid function argument."); - |-15: errstring("Internal error, e.g. Type descriptor size mismatch.") - |-20: errstring("Too many, or negative number of, elements in dynamic array.") - ELSE - END -END DisplayHaltCode; - -PROCEDURE Halt*(code: SYSTEM.INT32); -BEGIN - HaltCode := code; - IF HaltHandler # NIL THEN HaltHandler(code) END; - errstring("Terminated by Halt("); errint(code); errstring("). "); - IF code < 0 THEN DisplayHaltCode(code) END; - errln; - exit(SYSTEM.VAL(INTEGER,code)); -END Halt; - -PROCEDURE AssertFail*(code: SYSTEM.INT32); -BEGIN - errstring("Assertion failure."); - IF code # 0 THEN errstring(" ASSERT code "); errint(code); errstring("."); END; - errln; - exit(SYSTEM.VAL(INTEGER,code)); -END AssertFail; - -PROCEDURE SetHalt*(p: HaltProcedure); -BEGIN HaltHandler := p; END SetHalt; - - +PROCEDURE -exit(code: LONGINT) "exit((int)code)"; +PROCEDURE Exit*(code: LONGINT); BEGIN exit(code) END Exit; @@ -537,7 +477,6 @@ PROCEDURE -getpid(): INTEGER "(INTEGER)getpid()"; BEGIN TestLittleEndian; - HaltCode := -128; HaltHandler := NIL; TimeStart := 0; TimeStart := Time(); PID := getpid(); diff --git a/src/runtime/Platformwindows.Mod b/src/runtime/Platformwindows.Mod index a52ae92c..937c1da0 100644 --- a/src/runtime/Platformwindows.Mod +++ b/src/runtime/Platformwindows.Mod @@ -526,65 +526,8 @@ END Rename; (* Process termination *) -PROCEDURE -exit(code: INTEGER) "ExitProcess((UINT)code)"; -PROCEDURE Exit*(code: INTEGER); -BEGIN exit(code) END Exit; - - -PROCEDURE -errstring(s: ARRAY OF CHAR) 'WriteFile((HANDLE)Platform_StdOut, s, s__len-1, 0,0)'; -PROCEDURE -errc (c: CHAR) 'WriteFile((HANDLE)Platform_StdOut, &c, 1, 0,0)'; -PROCEDURE errch(c: CHAR); BEGIN errc(c) END errch; -PROCEDURE errln; BEGIN errch(0DX); errch(0AX) END errln; - -PROCEDURE errposint(l: LONGINT); -BEGIN IF l>10 THEN errposint(l DIV 10) END; errch(CHR(ORD('0') + (l MOD 10))) END errposint; - -PROCEDURE errint(l: LONGINT); -BEGIN IF l<0 THEN errch('-'); l := -l END; errposint(l) END errint; - -PROCEDURE DisplayHaltCode(code: LONGINT); -BEGIN - CASE code OF - | -1: errstring("Assertion failure.") - | -2: errstring("Index out of range.") - | -3: errstring("Reached end of function without reaching RETURN.") - | -4: errstring("CASE statement: no matching label and no ELSE.") - | -5: errstring("Type guard failed.") - | -6: errstring("Type equality failed.") - | -7: errstring("WITH statement type guard failed.") - | -8: errstring("SHORT: Value too large for shorter type.") - | -9: errstring("Heap interrupted while locked, but lockdepth = 0 at unlock.") - |-10: errstring("NIL access."); - |-11: errstring("Alignment error."); - |-12: errstring("Divide by zero."); - |-13: errstring("Arithmetic overflow/underflow."); - |-14: errstring("Invalid function argument."); - |-15: errstring("Internal error, e.g. Type descriptor size mismatch.") - |-20: errstring("Too many, or negative number of, elements in dynamic array.") - ELSE - END -END DisplayHaltCode; - -PROCEDURE Halt*(code: SYSTEM.INT32); -BEGIN - HaltCode := code; - IF HaltHandler # NIL THEN HaltHandler(code) END; - errstring("Terminated by Halt("); errint(code); errstring("). "); - IF code < 0 THEN DisplayHaltCode(code) END; - errln; - exit(SYSTEM.VAL(INTEGER,code)); -END Halt; - -PROCEDURE AssertFail*(code: SYSTEM.INT32); -BEGIN - errstring("Assertion failure."); - IF code # 0 THEN errstring(" ASSERT code "); errint(code); errstring("."); END; - errln; - exit(SYSTEM.VAL(INTEGER,code)); -END AssertFail; - -PROCEDURE SetHalt*(p: HaltProcedure); -BEGIN HaltHandler := p; END SetHalt; +PROCEDURE -exit(code: LONGINT) "ExitProcess((UINT)code)"; +PROCEDURE Exit*(code: LONGINT); BEGIN exit(code) END Exit; PROCEDURE -GetConsoleMode(h: FileHandle; VAR m: SYSTEM.INT32): BOOLEAN "GetConsoleMode((HANDLE)h, (DWORD*)m)"; diff --git a/src/runtime/SYSTEM.h b/src/runtime/SYSTEM.h index d9778393..43baa836 100644 --- a/src/runtime/SYSTEM.h +++ b/src/runtime/SYSTEM.h @@ -103,11 +103,11 @@ extern void Platform_OSFree (ADDRESS addr); // Assertions and Halts -extern void Platform_Halt(INT32 x); -extern void Platform_AssertFail(INT32 x); +extern void Modules_Halt(INT32 x); +extern void Modules_AssertFail(INT32 x); -#define __HALT(x) Platform_Halt(x) -#define __ASSERT(cond, x) if (!(cond)) Platform_AssertFail((INT32)(x)) +#define __HALT(x) Modules_Halt((INT32)(x)) +#define __ASSERT(cond, x) if (!(cond)) Modules_AssertFail((INT32)(x)) // Index checking diff --git a/src/tools/make/oberon.mk b/src/tools/make/oberon.mk index e5fde295..bb8b0f60 100644 --- a/src/tools/make/oberon.mk +++ b/src/tools/make/oberon.mk @@ -122,6 +122,7 @@ translate: cd $(BUILDDIR); $(ROOTDIR)/$(OBECOMP) -SsfF -A$(ADRSIZE)$(ALIGNMENT) -O$(MODEL) ../../src/compiler/OPP.Mod cd $(BUILDDIR); $(ROOTDIR)/$(OBECOMP) -Ssfm -A$(ADRSIZE)$(ALIGNMENT) -O$(MODEL) ../../src/compiler/Compiler.Mod + cp src/runtime/*.[ch] $(BUILDDIR) @printf "$(BUILDDIR) filled with compiler C source.\n"