mirror of
https://github.com/vishapoberon/compiler.git
synced 2026-04-06 13:22:26 +00:00
Simplify runtime error reporting and move to platform common source.
This commit is contained in:
parent
ed7043324d
commit
716240bdd6
205 changed files with 986 additions and 1063 deletions
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 <errno.h>
|
||||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue