diff --git a/bootstrap/unix-44/Compiler.c b/bootstrap/unix-44/Compiler.c index ffd8b03e..65da2216 100644 --- a/bootstrap/unix-44/Compiler.c +++ b/bootstrap/unix-44/Compiler.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspamS */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspamS */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/Configuration.c b/bootstrap/unix-44/Configuration.c index 6db13d09..77782293 100644 --- a/bootstrap/unix-44/Configuration.c +++ b/bootstrap/unix-44/Configuration.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -19,6 +19,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); + __MOVE("2.00 [2016/12/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 4259cfef..438fec28 100644 --- a/bootstrap/unix-44/Configuration.h +++ b/bootstrap/unix-44/Configuration.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Configuration__h #define Configuration__h diff --git a/bootstrap/unix-44/Files.c b/bootstrap/unix-44/Files.c index 652cb128..02716878 100644 --- a/bootstrap/unix-44/Files.c +++ b/bootstrap/unix-44/Files.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/Files.h b/bootstrap/unix-44/Files.h index c548dae1..2270fec0 100644 --- a/bootstrap/unix-44/Files.h +++ b/bootstrap/unix-44/Files.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/unix-44/Heap.c b/bootstrap/unix-44/Heap.c index 125a2854..c9adb169 100644 --- a/bootstrap/unix-44/Heap.c +++ b/bootstrap/unix-44/Heap.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -84,6 +84,7 @@ static void Heap_CheckFin (void); static void Heap_ExtendHeap (INT32 blksz); export void Heap_FINALL (void); static void Heap_Finalize (void); +export INT32 Heap_FreeModule (CHAR *name, ADDRESS name__len); export void Heap_GC (BOOLEAN markStack); static void Heap_HeapSort (INT32 n, INT32 *a, ADDRESS a__len); export void Heap_INCREF (Heap_Module m); @@ -143,6 +144,35 @@ SYSTEM_PTR Heap_REGMOD (Heap_ModuleName name, Heap_EnumProc enumPtrs) return (void*)m; } +INT32 Heap_FreeModule (CHAR *name, ADDRESS name__len) +{ + Heap_Module m, p; + __DUP(name, name__len, CHAR); + m = (Heap_Module)(ADDRESS)Heap_modules; + while ((m != NIL && __STRCMP(m->name, name) != 0)) { + p = m; + m = m->next; + } + if ((m != NIL && m->refcnt == 0)) { + if (m == (Heap_Module)(ADDRESS)Heap_modules) { + Heap_modules = (SYSTEM_PTR)m->next; + } else { + p->next = m->next; + } + __DEL(name); + return 0; + } else { + if (m == NIL) { + __DEL(name); + return -1; + } else { + __DEL(name); + return m->refcnt; + } + } + __RETCHK; +} + void Heap_REGCMD (Heap_Module m, Heap_CmdName name, Heap_Command cmd) { Heap_Cmd c; diff --git a/bootstrap/unix-44/Heap.h b/bootstrap/unix-44/Heap.h index e794a4a3..0df71d54 100644 --- a/bootstrap/unix-44/Heap.h +++ b/bootstrap/unix-44/Heap.h @@ -1,16 +1,26 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ #ifndef Heap__h #define Heap__h #include "SYSTEM.h" +typedef + struct Heap_CmdDesc *Heap_Cmd; + typedef CHAR Heap_CmdName[24]; typedef void (*Heap_Command)(void); +typedef + struct Heap_CmdDesc { + Heap_Cmd next; + Heap_CmdName name; + Heap_Command cmd; + } Heap_CmdDesc; + typedef void (*Heap_EnumProc)(void(*)(SYSTEM_PTR)); @@ -21,13 +31,18 @@ typedef struct Heap_ModuleDesc *Heap_Module; typedef - struct Heap_ModuleDesc { - INT32 _prvt0; - char _prvt1[44]; - } Heap_ModuleDesc; + CHAR Heap_ModuleName[20]; typedef - CHAR Heap_ModuleName[20]; + struct Heap_ModuleDesc { + Heap_Module next; + Heap_ModuleName name; + INT32 refcnt; + Heap_Cmd cmds; + INT32 types; + Heap_EnumProc enumPtrs; + char _prvt0[8]; + } Heap_ModuleDesc; import SYSTEM_PTR Heap_modules; @@ -35,8 +50,10 @@ import INT32 Heap_allocated, Heap_heapsize; import INT16 Heap_FileCount; import ADDRESS *Heap_ModuleDesc__typ; +import ADDRESS *Heap_CmdDesc__typ; import void Heap_FINALL (void); +import INT32 Heap_FreeModule (CHAR *name, ADDRESS name__len); import void Heap_GC (BOOLEAN markStack); import void Heap_INCREF (Heap_Module m); import void Heap_InitHeap (void); diff --git a/bootstrap/unix-44/Modules.c b/bootstrap/unix-44/Modules.c index b27930e7..03d205e0 100644 --- a/bootstrap/unix-44/Modules.c +++ b/bootstrap/unix-44/Modules.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -9,47 +9,15 @@ #include "Heap.h" #include "Platform.h" -typedef - struct Modules_CmdDesc *Modules_Cmd; - -typedef - void (*Modules_Command)(void); - -typedef - struct Modules_CmdDesc { - Modules_Cmd next; - CHAR name[24]; - Modules_Command cmd; - } Modules_CmdDesc; - -typedef - struct Modules_ModuleDesc *Modules_Module; - -typedef - CHAR Modules_ModuleName[20]; - -typedef - struct Modules_ModuleDesc { - Modules_Module next; - Modules_ModuleName name; - INT32 refcnt; - Modules_Cmd cmds; - INT32 types; - void (*enumPtrs)(void(*)(INT32)); - INT32 reserved1, reserved2; - } Modules_ModuleDesc; - export INT16 Modules_res; export CHAR Modules_resMsg[256]; -export Modules_ModuleName Modules_imported, Modules_importing; +export Heap_ModuleName Modules_imported, Modules_importing; export INT32 Modules_MainStackFrame; export INT16 Modules_ArgCount; export INT32 Modules_ArgVector; export CHAR Modules_BinaryDir[1024]; -export ADDRESS *Modules_ModuleDesc__typ; -export ADDRESS *Modules_CmdDesc__typ; static void Modules_Append (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len); static void Modules_AppendPart (CHAR c, CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len); @@ -68,8 +36,8 @@ export void Modules_Init (INT32 argc, INT32 argvadr); static BOOLEAN Modules_IsAbsolute (CHAR *d, ADDRESS d__len); static BOOLEAN Modules_IsFilePresent (CHAR *s, ADDRESS s__len); static BOOLEAN Modules_IsOneOf (CHAR c, CHAR *s, ADDRESS s__len); -export Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, ADDRESS name__len); -export Modules_Module Modules_ThisMod (CHAR *name, ADDRESS name__len); +export Heap_Command Modules_ThisCommand (Heap_Module mod, CHAR *name, ADDRESS name__len); +export Heap_Module Modules_ThisMod (CHAR *name, ADDRESS name__len); static void Modules_Trim (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len); static void Modules_errch (CHAR c); static void Modules_errint (INT32 l); @@ -79,8 +47,7 @@ extern void Heap_InitHeap(); extern void *Modules__init(void); #define Modules_InitHeap() Heap_InitHeap() #define Modules_ModulesInit() Modules__init() -#define Modules_modules() (Modules_Module)Heap_modules -#define Modules_setmodules(m) Heap_modules = m +#define Modules_modules() (Heap_Module)Heap_modules void Modules_Init (INT32 argc, INT32 argvadr) { @@ -334,11 +301,11 @@ static void Modules_FindBinaryDir (CHAR *binarydir, ADDRESS binarydir__len) } } -Modules_Module Modules_ThisMod (CHAR *name, ADDRESS name__len) +Heap_Module Modules_ThisMod (CHAR *name, ADDRESS name__len) { - Modules_Module m = NIL; + Heap_Module m = NIL; CHAR bodyname[64]; - Modules_Command body; + Heap_Command body; __DUP(name, name__len, CHAR); m = Modules_modules(); while ((m != NIL && __STRCMP(m->name, name) != 0)) { @@ -358,9 +325,9 @@ Modules_Module Modules_ThisMod (CHAR *name, ADDRESS name__len) return m; } -Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, ADDRESS name__len) +Heap_Command Modules_ThisCommand (Heap_Module mod, CHAR *name, ADDRESS name__len) { - Modules_Cmd c = NIL; + Heap_Cmd c = NIL; __DUP(name, name__len, CHAR); c = mod->cmds; while ((c != NIL && __STRCMP(c->name, name) != 0)) { @@ -387,31 +354,24 @@ Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, ADDRESS nam void Modules_Free (CHAR *name, ADDRESS name__len, BOOLEAN all) { - Modules_Module m = NIL, p = NIL; + Heap_Module m = NIL, p = NIL; + INT32 refcount; __DUP(name, name__len, CHAR); m = Modules_modules(); if (all) { Modules_res = 1; __MOVE("unloading \"all\" not yet supported", Modules_resMsg, 34); } else { - while ((m != NIL && __STRCMP(m->name, name) != 0)) { - p = m; - m = m->next; - } - if ((m != NIL && m->refcnt == 0)) { - if (m == Modules_modules()) { - Modules_setmodules(m->next); - } else { - p->next = m->next; - } + refcount = Heap_FreeModule(name, name__len); + if (refcount == 0) { Modules_res = 0; } else { - Modules_res = 1; - if (m == NIL) { + if (refcount < 0) { __MOVE("module not found", Modules_resMsg, 17); } else { __MOVE("clients of this module exist", Modules_resMsg, 29); } + Modules_res = 1; } } __DEL(name); @@ -533,8 +493,6 @@ void Modules_AssertFail (INT32 code) } } -__TDESC(Modules_ModuleDesc, 1, 2) = {__TDFLDS("ModuleDesc", 48), {0, 28, -12}}; -__TDESC(Modules_CmdDesc, 1, 1) = {__TDFLDS("CmdDesc", 32), {0, -8}}; export void *Modules__init(void) { @@ -542,8 +500,6 @@ export void *Modules__init(void) __MODULE_IMPORT(Heap); __MODULE_IMPORT(Platform); __REGMOD("Modules", 0); - __INITYP(Modules_ModuleDesc, Modules_ModuleDesc, 0); - __INITYP(Modules_CmdDesc, Modules_CmdDesc, 0); /* BEGIN */ Modules_FindBinaryDir((void*)Modules_BinaryDir, 1024); __ENDMOD; diff --git a/bootstrap/unix-44/Modules.h b/bootstrap/unix-44/Modules.h index 553f80ed..3c1c580d 100644 --- a/bootstrap/unix-44/Modules.h +++ b/bootstrap/unix-44/Modules.h @@ -1,51 +1,20 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Modules__h #define Modules__h #include "SYSTEM.h" - -typedef - struct Modules_CmdDesc *Modules_Cmd; - -typedef - void (*Modules_Command)(void); - -typedef - struct Modules_CmdDesc { - Modules_Cmd next; - CHAR name[24]; - Modules_Command cmd; - } Modules_CmdDesc; - -typedef - struct Modules_ModuleDesc *Modules_Module; - -typedef - CHAR Modules_ModuleName[20]; - -typedef - struct Modules_ModuleDesc { - Modules_Module next; - Modules_ModuleName name; - INT32 refcnt; - Modules_Cmd cmds; - INT32 types; - void (*enumPtrs)(void(*)(INT32)); - char _prvt0[8]; - } Modules_ModuleDesc; +#include "Heap.h" import INT16 Modules_res; import CHAR Modules_resMsg[256]; -import Modules_ModuleName Modules_imported, Modules_importing; +import Heap_ModuleName Modules_imported, Modules_importing; import INT32 Modules_MainStackFrame; import INT16 Modules_ArgCount; import INT32 Modules_ArgVector; import CHAR Modules_BinaryDir[1024]; -import ADDRESS *Modules_ModuleDesc__typ; -import ADDRESS *Modules_CmdDesc__typ; import INT16 Modules_ArgPos (CHAR *s, ADDRESS s__len); import void Modules_AssertFail (INT32 code); @@ -54,8 +23,8 @@ import void Modules_GetArg (INT16 n, CHAR *val, ADDRESS val__len); import void Modules_GetIntArg (INT16 n, INT32 *val); import void Modules_Halt (INT32 code); import void Modules_Init (INT32 argc, INT32 argvadr); -import Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, ADDRESS name__len); -import Modules_Module Modules_ThisMod (CHAR *name, ADDRESS name__len); +import Heap_Command Modules_ThisCommand (Heap_Module mod, CHAR *name, ADDRESS name__len); +import Heap_Module Modules_ThisMod (CHAR *name, ADDRESS name__len); import void *Modules__init(void); diff --git a/bootstrap/unix-44/OPB.c b/bootstrap/unix-44/OPB.c index d83386eb..7e558357 100644 --- a/bootstrap/unix-44/OPB.c +++ b/bootstrap/unix-44/OPB.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/OPB.h b/bootstrap/unix-44/OPB.h index feb85d73..b6d457bd 100644 --- a/bootstrap/unix-44/OPB.h +++ b/bootstrap/unix-44/OPB.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPB__h #define OPB__h diff --git a/bootstrap/unix-44/OPC.c b/bootstrap/unix-44/OPC.c index ab01642c..c09d2e6a 100644 --- a/bootstrap/unix-44/OPC.c +++ b/bootstrap/unix-44/OPC.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/OPC.h b/bootstrap/unix-44/OPC.h index f742f265..7c47ed18 100644 --- a/bootstrap/unix-44/OPC.h +++ b/bootstrap/unix-44/OPC.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPC__h #define OPC__h diff --git a/bootstrap/unix-44/OPM.c b/bootstrap/unix-44/OPM.c index a6c7a5cd..a3718f79 100644 --- a/bootstrap/unix-44/OPM.c +++ b/bootstrap/unix-44/OPM.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/OPM.h b/bootstrap/unix-44/OPM.h index 621dfb51..6d2755d8 100644 --- a/bootstrap/unix-44/OPM.h +++ b/bootstrap/unix-44/OPM.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPM__h #define OPM__h diff --git a/bootstrap/unix-44/OPP.c b/bootstrap/unix-44/OPP.c index 383b6d65..5924f42f 100644 --- a/bootstrap/unix-44/OPP.c +++ b/bootstrap/unix-44/OPP.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/OPP.h b/bootstrap/unix-44/OPP.h index c1fe21fb..c13a4e91 100644 --- a/bootstrap/unix-44/OPP.h +++ b/bootstrap/unix-44/OPP.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/unix-44/OPS.c b/bootstrap/unix-44/OPS.c index 4569c80d..ed3ea3a1 100644 --- a/bootstrap/unix-44/OPS.c +++ b/bootstrap/unix-44/OPS.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/OPS.h b/bootstrap/unix-44/OPS.h index c0707c34..6dae098c 100644 --- a/bootstrap/unix-44/OPS.h +++ b/bootstrap/unix-44/OPS.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/unix-44/OPT.c b/bootstrap/unix-44/OPT.c index 9bc66090..e929a6e0 100644 --- a/bootstrap/unix-44/OPT.c +++ b/bootstrap/unix-44/OPT.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/OPT.h b/bootstrap/unix-44/OPT.h index 6b2b0929..00094b66 100644 --- a/bootstrap/unix-44/OPT.h +++ b/bootstrap/unix-44/OPT.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPT__h #define OPT__h diff --git a/bootstrap/unix-44/OPV.c b/bootstrap/unix-44/OPV.c index 42081077..7e829aa2 100644 --- a/bootstrap/unix-44/OPV.c +++ b/bootstrap/unix-44/OPV.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/OPV.h b/bootstrap/unix-44/OPV.h index d363f022..f83e65fb 100644 --- a/bootstrap/unix-44/OPV.h +++ b/bootstrap/unix-44/OPV.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPV__h #define OPV__h diff --git a/bootstrap/unix-44/Out.c b/bootstrap/unix-44/Out.c index 65e2e307..39900621 100644 --- a/bootstrap/unix-44/Out.c +++ b/bootstrap/unix-44/Out.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -6,6 +6,7 @@ #define SET UINT32 #include "SYSTEM.h" +#include "Heap.h" #include "Platform.h" @@ -13,8 +14,11 @@ export BOOLEAN Out_IsConsole; static CHAR Out_buf[128]; static INT16 Out_in; +static ADDRESS *typedesc__5__typ; export void Out_Char (CHAR ch); +static void Out_DumpModule (Heap_Module m); +export void Out_DumpType (SYSTEM_BYTE *o, ADDRESS o__len); export void Out_Flush (void); export void Out_Hex (INT64 x, INT64 n); export void Out_HexDump (SYSTEM_BYTE *m, ADDRESS m__len); @@ -203,6 +207,94 @@ void Out_HexDump (SYSTEM_BYTE *m, ADDRESS m__len) Out_HexDumpAdr((ADDRESS)m, 0, m__len); } +static void Out_DumpModule (Heap_Module m) +{ + Out_String((CHAR*)" next: ", 13); + Out_Hex((INT32)(ADDRESS)m->next, 1); + Out_Ln(); + Out_String((CHAR*)" name: ", 13); + Out_String(m->name, 20); + Out_Ln(); + Out_String((CHAR*)" refcnt: ", 13); + Out_Hex(m->refcnt, 1); + Out_Ln(); + Out_String((CHAR*)" cmds: ", 13); + Out_Hex((INT32)(ADDRESS)m->cmds, 1); + Out_Ln(); + Out_String((CHAR*)" types: ", 13); + Out_Hex(m->types, 1); + Out_Ln(); + Out_String((CHAR*)" enumPtrs: ", 13); + Out_Hex((INT32)(ADDRESS)m->enumPtrs, 1); + Out_Ln(); +} + +typedef + struct typedesc__5 *tag__4; + +typedef + struct typedesc__5 { + INT32 tag, next, level, module; + CHAR name[24]; + INT32 bases[16]; + INT32 reserved, blksz, ptr0; + } typedesc__5; + +void Out_DumpType (SYSTEM_BYTE *o, ADDRESS o__len) +{ + INT32 addr; + tag__4 desc = NIL; + INT16 i; + __GET((ADDRESS)o - 4, addr, INT32); + Out_String((CHAR*)"obj tag: ", 11); + Out_Hex(addr, 1); + Out_Ln(); + desc = (tag__4)(ADDRESS)(addr - 108); + Out_String((CHAR*)"desc at: ", 11); + Out_Hex((INT32)(ADDRESS)desc, 1); + Out_Ln(); + Out_String((CHAR*)"desc contains:", 15); + Out_Ln(); + Out_String((CHAR*)"tag: ", 11); + Out_Hex(desc->tag, 1); + Out_Ln(); + Out_String((CHAR*)"next: ", 11); + Out_Hex(desc->next, 1); + Out_Ln(); + Out_String((CHAR*)"level: ", 11); + Out_Hex(desc->level, 1); + Out_Ln(); + Out_String((CHAR*)"module: ", 11); + Out_Hex(desc->module, 1); + Out_Ln(); + Out_DumpModule((Heap_Module)(ADDRESS)desc->module); + Out_String((CHAR*)"name: ", 11); + Out_String(desc->name, 24); + Out_Ln(); + Out_String((CHAR*)"bases: ", 11); + i = 0; + while (i < 16) { + Out_Hex(desc->bases[__X(i, 16)], 8); + if (__MASK(i, -4) == 3) { + Out_Ln(); + Out_String((CHAR*)" ", 11); + } else { + Out_Char(' '); + } + i += 1; + } + Out_Ln(); + Out_String((CHAR*)"reserved: ", 11); + Out_Hex(desc->reserved, 1); + Out_Ln(); + Out_String((CHAR*)"blksz: ", 11); + Out_Hex(desc->blksz, 1); + Out_Ln(); + Out_String((CHAR*)"ptr0: ", 11); + Out_Hex(desc->ptr0, 1); + Out_Ln(); +} + static void Out_digit (INT64 n, CHAR *s, ADDRESS s__len, INT16 *i) { *i -= 1; @@ -380,15 +472,18 @@ void Out_LongReal (LONGREAL x, INT16 n) Out_RealP(x, n, 1); } +__TDESC(typedesc__5, 1, 0) = {__TDFLDS("typedesc__5", 116), {-4}}; export void *Out__init(void) { __DEFMOD; + __MODULE_IMPORT(Heap); __MODULE_IMPORT(Platform); __REGMOD("Out", 0); __REGCMD("Flush", Out_Flush); __REGCMD("Ln", Out_Ln); __REGCMD("Open", Out_Open); + __INITYP(typedesc__5, typedesc__5, 0); /* BEGIN */ Out_IsConsole = Platform_IsConsole(1); Out_in = 0; diff --git a/bootstrap/unix-44/Out.h b/bootstrap/unix-44/Out.h index 1db1f1b3..0b3a93df 100644 --- a/bootstrap/unix-44/Out.h +++ b/bootstrap/unix-44/Out.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Out__h #define Out__h @@ -10,6 +10,7 @@ import BOOLEAN Out_IsConsole; import void Out_Char (CHAR ch); +import void Out_DumpType (SYSTEM_BYTE *o, ADDRESS o__len); import void Out_Flush (void); import void Out_Hex (INT64 x, INT64 n); import void Out_HexDump (SYSTEM_BYTE *m, ADDRESS m__len); diff --git a/bootstrap/unix-44/Platform.c b/bootstrap/unix-44/Platform.c index 22eb3138..a825b8ec 100644 --- a/bootstrap/unix-44/Platform.c +++ b/bootstrap/unix-44/Platform.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/Platform.h b/bootstrap/unix-44/Platform.h index cd9d9890..5d752192 100644 --- a/bootstrap/unix-44/Platform.h +++ b/bootstrap/unix-44/Platform.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/unix-44/Reals.c b/bootstrap/unix-44/Reals.c index f5ee1490..0a2d220b 100644 --- a/bootstrap/unix-44/Reals.c +++ b/bootstrap/unix-44/Reals.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/Reals.h b/bootstrap/unix-44/Reals.h index 6d0ec38b..0c564f0e 100644 --- a/bootstrap/unix-44/Reals.h +++ b/bootstrap/unix-44/Reals.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/unix-44/Strings.c b/bootstrap/unix-44/Strings.c index 4ee2fc23..ed806db0 100644 --- a/bootstrap/unix-44/Strings.c +++ b/bootstrap/unix-44/Strings.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/Strings.h b/bootstrap/unix-44/Strings.h index ae281477..93b62826 100644 --- a/bootstrap/unix-44/Strings.h +++ b/bootstrap/unix-44/Strings.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/unix-44/Texts.c b/bootstrap/unix-44/Texts.c index 8c4ccea8..bbca112c 100644 --- a/bootstrap/unix-44/Texts.c +++ b/bootstrap/unix-44/Texts.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -390,6 +390,7 @@ void Texts_DumpReader (Texts_Reader re) Texts_DumpRun(re.run); } } + Out_DumpType((void*)&*re.run, 20); } static Texts_FontsFont Texts_FontsThis (CHAR *name, ADDRESS name__len) @@ -1566,8 +1567,8 @@ static void LoadElem__22 (Files_Rider *r, ADDRESS *r__typ, INT32 pos, INT32 span static void LoadElem__22 (Files_Rider *r, ADDRESS *r__typ, INT32 pos, INT32 span, Texts_Elem *e) { - Modules_Module M = NIL; - Modules_Command Cmd; + Heap_Module M = NIL; + Heap_Command Cmd; Texts_Alien a = NIL; INT32 org, ew, eh; INT8 eno; diff --git a/bootstrap/unix-44/Texts.h b/bootstrap/unix-44/Texts.h index dfe60b54..04c8767a 100644 --- a/bootstrap/unix-44/Texts.h +++ b/bootstrap/unix-44/Texts.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/unix-44/VT100.c b/bootstrap/unix-44/VT100.c index 9ab993c9..ed38e4dc 100644 --- a/bootstrap/unix-44/VT100.c +++ b/bootstrap/unix-44/VT100.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/VT100.h b/bootstrap/unix-44/VT100.h index 3de3605c..69601701 100644 --- a/bootstrap/unix-44/VT100.h +++ b/bootstrap/unix-44/VT100.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef VT100__h #define VT100__h diff --git a/bootstrap/unix-44/extTools.c b/bootstrap/unix-44/extTools.c index 213abf27..0b3a981e 100644 --- a/bootstrap/unix-44/extTools.c +++ b/bootstrap/unix-44/extTools.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/extTools.h b/bootstrap/unix-44/extTools.h index 4278a34c..36571c99 100644 --- a/bootstrap/unix-44/extTools.h +++ b/bootstrap/unix-44/extTools.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef extTools__h #define extTools__h diff --git a/bootstrap/unix-48/Compiler.c b/bootstrap/unix-48/Compiler.c index ffd8b03e..65da2216 100644 --- a/bootstrap/unix-48/Compiler.c +++ b/bootstrap/unix-48/Compiler.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspamS */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspamS */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/Configuration.c b/bootstrap/unix-48/Configuration.c index 6db13d09..77782293 100644 --- a/bootstrap/unix-48/Configuration.c +++ b/bootstrap/unix-48/Configuration.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -19,6 +19,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); + __MOVE("2.00 [2016/12/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 4259cfef..438fec28 100644 --- a/bootstrap/unix-48/Configuration.h +++ b/bootstrap/unix-48/Configuration.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Configuration__h #define Configuration__h diff --git a/bootstrap/unix-48/Files.c b/bootstrap/unix-48/Files.c index 652cb128..02716878 100644 --- a/bootstrap/unix-48/Files.c +++ b/bootstrap/unix-48/Files.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/Files.h b/bootstrap/unix-48/Files.h index c548dae1..2270fec0 100644 --- a/bootstrap/unix-48/Files.h +++ b/bootstrap/unix-48/Files.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/unix-48/Heap.c b/bootstrap/unix-48/Heap.c index 125a2854..c9adb169 100644 --- a/bootstrap/unix-48/Heap.c +++ b/bootstrap/unix-48/Heap.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -84,6 +84,7 @@ static void Heap_CheckFin (void); static void Heap_ExtendHeap (INT32 blksz); export void Heap_FINALL (void); static void Heap_Finalize (void); +export INT32 Heap_FreeModule (CHAR *name, ADDRESS name__len); export void Heap_GC (BOOLEAN markStack); static void Heap_HeapSort (INT32 n, INT32 *a, ADDRESS a__len); export void Heap_INCREF (Heap_Module m); @@ -143,6 +144,35 @@ SYSTEM_PTR Heap_REGMOD (Heap_ModuleName name, Heap_EnumProc enumPtrs) return (void*)m; } +INT32 Heap_FreeModule (CHAR *name, ADDRESS name__len) +{ + Heap_Module m, p; + __DUP(name, name__len, CHAR); + m = (Heap_Module)(ADDRESS)Heap_modules; + while ((m != NIL && __STRCMP(m->name, name) != 0)) { + p = m; + m = m->next; + } + if ((m != NIL && m->refcnt == 0)) { + if (m == (Heap_Module)(ADDRESS)Heap_modules) { + Heap_modules = (SYSTEM_PTR)m->next; + } else { + p->next = m->next; + } + __DEL(name); + return 0; + } else { + if (m == NIL) { + __DEL(name); + return -1; + } else { + __DEL(name); + return m->refcnt; + } + } + __RETCHK; +} + void Heap_REGCMD (Heap_Module m, Heap_CmdName name, Heap_Command cmd) { Heap_Cmd c; diff --git a/bootstrap/unix-48/Heap.h b/bootstrap/unix-48/Heap.h index e794a4a3..0df71d54 100644 --- a/bootstrap/unix-48/Heap.h +++ b/bootstrap/unix-48/Heap.h @@ -1,16 +1,26 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ #ifndef Heap__h #define Heap__h #include "SYSTEM.h" +typedef + struct Heap_CmdDesc *Heap_Cmd; + typedef CHAR Heap_CmdName[24]; typedef void (*Heap_Command)(void); +typedef + struct Heap_CmdDesc { + Heap_Cmd next; + Heap_CmdName name; + Heap_Command cmd; + } Heap_CmdDesc; + typedef void (*Heap_EnumProc)(void(*)(SYSTEM_PTR)); @@ -21,13 +31,18 @@ typedef struct Heap_ModuleDesc *Heap_Module; typedef - struct Heap_ModuleDesc { - INT32 _prvt0; - char _prvt1[44]; - } Heap_ModuleDesc; + CHAR Heap_ModuleName[20]; typedef - CHAR Heap_ModuleName[20]; + struct Heap_ModuleDesc { + Heap_Module next; + Heap_ModuleName name; + INT32 refcnt; + Heap_Cmd cmds; + INT32 types; + Heap_EnumProc enumPtrs; + char _prvt0[8]; + } Heap_ModuleDesc; import SYSTEM_PTR Heap_modules; @@ -35,8 +50,10 @@ import INT32 Heap_allocated, Heap_heapsize; import INT16 Heap_FileCount; import ADDRESS *Heap_ModuleDesc__typ; +import ADDRESS *Heap_CmdDesc__typ; import void Heap_FINALL (void); +import INT32 Heap_FreeModule (CHAR *name, ADDRESS name__len); import void Heap_GC (BOOLEAN markStack); import void Heap_INCREF (Heap_Module m); import void Heap_InitHeap (void); diff --git a/bootstrap/unix-48/Modules.c b/bootstrap/unix-48/Modules.c index b27930e7..03d205e0 100644 --- a/bootstrap/unix-48/Modules.c +++ b/bootstrap/unix-48/Modules.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -9,47 +9,15 @@ #include "Heap.h" #include "Platform.h" -typedef - struct Modules_CmdDesc *Modules_Cmd; - -typedef - void (*Modules_Command)(void); - -typedef - struct Modules_CmdDesc { - Modules_Cmd next; - CHAR name[24]; - Modules_Command cmd; - } Modules_CmdDesc; - -typedef - struct Modules_ModuleDesc *Modules_Module; - -typedef - CHAR Modules_ModuleName[20]; - -typedef - struct Modules_ModuleDesc { - Modules_Module next; - Modules_ModuleName name; - INT32 refcnt; - Modules_Cmd cmds; - INT32 types; - void (*enumPtrs)(void(*)(INT32)); - INT32 reserved1, reserved2; - } Modules_ModuleDesc; - export INT16 Modules_res; export CHAR Modules_resMsg[256]; -export Modules_ModuleName Modules_imported, Modules_importing; +export Heap_ModuleName Modules_imported, Modules_importing; export INT32 Modules_MainStackFrame; export INT16 Modules_ArgCount; export INT32 Modules_ArgVector; export CHAR Modules_BinaryDir[1024]; -export ADDRESS *Modules_ModuleDesc__typ; -export ADDRESS *Modules_CmdDesc__typ; static void Modules_Append (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len); static void Modules_AppendPart (CHAR c, CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len); @@ -68,8 +36,8 @@ export void Modules_Init (INT32 argc, INT32 argvadr); static BOOLEAN Modules_IsAbsolute (CHAR *d, ADDRESS d__len); static BOOLEAN Modules_IsFilePresent (CHAR *s, ADDRESS s__len); static BOOLEAN Modules_IsOneOf (CHAR c, CHAR *s, ADDRESS s__len); -export Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, ADDRESS name__len); -export Modules_Module Modules_ThisMod (CHAR *name, ADDRESS name__len); +export Heap_Command Modules_ThisCommand (Heap_Module mod, CHAR *name, ADDRESS name__len); +export Heap_Module Modules_ThisMod (CHAR *name, ADDRESS name__len); static void Modules_Trim (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len); static void Modules_errch (CHAR c); static void Modules_errint (INT32 l); @@ -79,8 +47,7 @@ extern void Heap_InitHeap(); extern void *Modules__init(void); #define Modules_InitHeap() Heap_InitHeap() #define Modules_ModulesInit() Modules__init() -#define Modules_modules() (Modules_Module)Heap_modules -#define Modules_setmodules(m) Heap_modules = m +#define Modules_modules() (Heap_Module)Heap_modules void Modules_Init (INT32 argc, INT32 argvadr) { @@ -334,11 +301,11 @@ static void Modules_FindBinaryDir (CHAR *binarydir, ADDRESS binarydir__len) } } -Modules_Module Modules_ThisMod (CHAR *name, ADDRESS name__len) +Heap_Module Modules_ThisMod (CHAR *name, ADDRESS name__len) { - Modules_Module m = NIL; + Heap_Module m = NIL; CHAR bodyname[64]; - Modules_Command body; + Heap_Command body; __DUP(name, name__len, CHAR); m = Modules_modules(); while ((m != NIL && __STRCMP(m->name, name) != 0)) { @@ -358,9 +325,9 @@ Modules_Module Modules_ThisMod (CHAR *name, ADDRESS name__len) return m; } -Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, ADDRESS name__len) +Heap_Command Modules_ThisCommand (Heap_Module mod, CHAR *name, ADDRESS name__len) { - Modules_Cmd c = NIL; + Heap_Cmd c = NIL; __DUP(name, name__len, CHAR); c = mod->cmds; while ((c != NIL && __STRCMP(c->name, name) != 0)) { @@ -387,31 +354,24 @@ Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, ADDRESS nam void Modules_Free (CHAR *name, ADDRESS name__len, BOOLEAN all) { - Modules_Module m = NIL, p = NIL; + Heap_Module m = NIL, p = NIL; + INT32 refcount; __DUP(name, name__len, CHAR); m = Modules_modules(); if (all) { Modules_res = 1; __MOVE("unloading \"all\" not yet supported", Modules_resMsg, 34); } else { - while ((m != NIL && __STRCMP(m->name, name) != 0)) { - p = m; - m = m->next; - } - if ((m != NIL && m->refcnt == 0)) { - if (m == Modules_modules()) { - Modules_setmodules(m->next); - } else { - p->next = m->next; - } + refcount = Heap_FreeModule(name, name__len); + if (refcount == 0) { Modules_res = 0; } else { - Modules_res = 1; - if (m == NIL) { + if (refcount < 0) { __MOVE("module not found", Modules_resMsg, 17); } else { __MOVE("clients of this module exist", Modules_resMsg, 29); } + Modules_res = 1; } } __DEL(name); @@ -533,8 +493,6 @@ void Modules_AssertFail (INT32 code) } } -__TDESC(Modules_ModuleDesc, 1, 2) = {__TDFLDS("ModuleDesc", 48), {0, 28, -12}}; -__TDESC(Modules_CmdDesc, 1, 1) = {__TDFLDS("CmdDesc", 32), {0, -8}}; export void *Modules__init(void) { @@ -542,8 +500,6 @@ export void *Modules__init(void) __MODULE_IMPORT(Heap); __MODULE_IMPORT(Platform); __REGMOD("Modules", 0); - __INITYP(Modules_ModuleDesc, Modules_ModuleDesc, 0); - __INITYP(Modules_CmdDesc, Modules_CmdDesc, 0); /* BEGIN */ Modules_FindBinaryDir((void*)Modules_BinaryDir, 1024); __ENDMOD; diff --git a/bootstrap/unix-48/Modules.h b/bootstrap/unix-48/Modules.h index 553f80ed..3c1c580d 100644 --- a/bootstrap/unix-48/Modules.h +++ b/bootstrap/unix-48/Modules.h @@ -1,51 +1,20 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Modules__h #define Modules__h #include "SYSTEM.h" - -typedef - struct Modules_CmdDesc *Modules_Cmd; - -typedef - void (*Modules_Command)(void); - -typedef - struct Modules_CmdDesc { - Modules_Cmd next; - CHAR name[24]; - Modules_Command cmd; - } Modules_CmdDesc; - -typedef - struct Modules_ModuleDesc *Modules_Module; - -typedef - CHAR Modules_ModuleName[20]; - -typedef - struct Modules_ModuleDesc { - Modules_Module next; - Modules_ModuleName name; - INT32 refcnt; - Modules_Cmd cmds; - INT32 types; - void (*enumPtrs)(void(*)(INT32)); - char _prvt0[8]; - } Modules_ModuleDesc; +#include "Heap.h" import INT16 Modules_res; import CHAR Modules_resMsg[256]; -import Modules_ModuleName Modules_imported, Modules_importing; +import Heap_ModuleName Modules_imported, Modules_importing; import INT32 Modules_MainStackFrame; import INT16 Modules_ArgCount; import INT32 Modules_ArgVector; import CHAR Modules_BinaryDir[1024]; -import ADDRESS *Modules_ModuleDesc__typ; -import ADDRESS *Modules_CmdDesc__typ; import INT16 Modules_ArgPos (CHAR *s, ADDRESS s__len); import void Modules_AssertFail (INT32 code); @@ -54,8 +23,8 @@ import void Modules_GetArg (INT16 n, CHAR *val, ADDRESS val__len); import void Modules_GetIntArg (INT16 n, INT32 *val); import void Modules_Halt (INT32 code); import void Modules_Init (INT32 argc, INT32 argvadr); -import Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, ADDRESS name__len); -import Modules_Module Modules_ThisMod (CHAR *name, ADDRESS name__len); +import Heap_Command Modules_ThisCommand (Heap_Module mod, CHAR *name, ADDRESS name__len); +import Heap_Module Modules_ThisMod (CHAR *name, ADDRESS name__len); import void *Modules__init(void); diff --git a/bootstrap/unix-48/OPB.c b/bootstrap/unix-48/OPB.c index d83386eb..7e558357 100644 --- a/bootstrap/unix-48/OPB.c +++ b/bootstrap/unix-48/OPB.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/OPB.h b/bootstrap/unix-48/OPB.h index feb85d73..b6d457bd 100644 --- a/bootstrap/unix-48/OPB.h +++ b/bootstrap/unix-48/OPB.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPB__h #define OPB__h diff --git a/bootstrap/unix-48/OPC.c b/bootstrap/unix-48/OPC.c index ab01642c..c09d2e6a 100644 --- a/bootstrap/unix-48/OPC.c +++ b/bootstrap/unix-48/OPC.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/OPC.h b/bootstrap/unix-48/OPC.h index f742f265..7c47ed18 100644 --- a/bootstrap/unix-48/OPC.h +++ b/bootstrap/unix-48/OPC.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPC__h #define OPC__h diff --git a/bootstrap/unix-48/OPM.c b/bootstrap/unix-48/OPM.c index a6c7a5cd..a3718f79 100644 --- a/bootstrap/unix-48/OPM.c +++ b/bootstrap/unix-48/OPM.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/OPM.h b/bootstrap/unix-48/OPM.h index 621dfb51..6d2755d8 100644 --- a/bootstrap/unix-48/OPM.h +++ b/bootstrap/unix-48/OPM.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPM__h #define OPM__h diff --git a/bootstrap/unix-48/OPP.c b/bootstrap/unix-48/OPP.c index 383b6d65..5924f42f 100644 --- a/bootstrap/unix-48/OPP.c +++ b/bootstrap/unix-48/OPP.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/OPP.h b/bootstrap/unix-48/OPP.h index c1fe21fb..c13a4e91 100644 --- a/bootstrap/unix-48/OPP.h +++ b/bootstrap/unix-48/OPP.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/unix-48/OPS.c b/bootstrap/unix-48/OPS.c index 4569c80d..ed3ea3a1 100644 --- a/bootstrap/unix-48/OPS.c +++ b/bootstrap/unix-48/OPS.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/OPS.h b/bootstrap/unix-48/OPS.h index c0707c34..6dae098c 100644 --- a/bootstrap/unix-48/OPS.h +++ b/bootstrap/unix-48/OPS.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/unix-48/OPT.c b/bootstrap/unix-48/OPT.c index 0d32553a..6b6144fc 100644 --- a/bootstrap/unix-48/OPT.c +++ b/bootstrap/unix-48/OPT.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/OPT.h b/bootstrap/unix-48/OPT.h index 6b2b0929..00094b66 100644 --- a/bootstrap/unix-48/OPT.h +++ b/bootstrap/unix-48/OPT.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPT__h #define OPT__h diff --git a/bootstrap/unix-48/OPV.c b/bootstrap/unix-48/OPV.c index 42081077..7e829aa2 100644 --- a/bootstrap/unix-48/OPV.c +++ b/bootstrap/unix-48/OPV.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/OPV.h b/bootstrap/unix-48/OPV.h index d363f022..f83e65fb 100644 --- a/bootstrap/unix-48/OPV.h +++ b/bootstrap/unix-48/OPV.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPV__h #define OPV__h diff --git a/bootstrap/unix-48/Out.c b/bootstrap/unix-48/Out.c index 65e2e307..39900621 100644 --- a/bootstrap/unix-48/Out.c +++ b/bootstrap/unix-48/Out.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -6,6 +6,7 @@ #define SET UINT32 #include "SYSTEM.h" +#include "Heap.h" #include "Platform.h" @@ -13,8 +14,11 @@ export BOOLEAN Out_IsConsole; static CHAR Out_buf[128]; static INT16 Out_in; +static ADDRESS *typedesc__5__typ; export void Out_Char (CHAR ch); +static void Out_DumpModule (Heap_Module m); +export void Out_DumpType (SYSTEM_BYTE *o, ADDRESS o__len); export void Out_Flush (void); export void Out_Hex (INT64 x, INT64 n); export void Out_HexDump (SYSTEM_BYTE *m, ADDRESS m__len); @@ -203,6 +207,94 @@ void Out_HexDump (SYSTEM_BYTE *m, ADDRESS m__len) Out_HexDumpAdr((ADDRESS)m, 0, m__len); } +static void Out_DumpModule (Heap_Module m) +{ + Out_String((CHAR*)" next: ", 13); + Out_Hex((INT32)(ADDRESS)m->next, 1); + Out_Ln(); + Out_String((CHAR*)" name: ", 13); + Out_String(m->name, 20); + Out_Ln(); + Out_String((CHAR*)" refcnt: ", 13); + Out_Hex(m->refcnt, 1); + Out_Ln(); + Out_String((CHAR*)" cmds: ", 13); + Out_Hex((INT32)(ADDRESS)m->cmds, 1); + Out_Ln(); + Out_String((CHAR*)" types: ", 13); + Out_Hex(m->types, 1); + Out_Ln(); + Out_String((CHAR*)" enumPtrs: ", 13); + Out_Hex((INT32)(ADDRESS)m->enumPtrs, 1); + Out_Ln(); +} + +typedef + struct typedesc__5 *tag__4; + +typedef + struct typedesc__5 { + INT32 tag, next, level, module; + CHAR name[24]; + INT32 bases[16]; + INT32 reserved, blksz, ptr0; + } typedesc__5; + +void Out_DumpType (SYSTEM_BYTE *o, ADDRESS o__len) +{ + INT32 addr; + tag__4 desc = NIL; + INT16 i; + __GET((ADDRESS)o - 4, addr, INT32); + Out_String((CHAR*)"obj tag: ", 11); + Out_Hex(addr, 1); + Out_Ln(); + desc = (tag__4)(ADDRESS)(addr - 108); + Out_String((CHAR*)"desc at: ", 11); + Out_Hex((INT32)(ADDRESS)desc, 1); + Out_Ln(); + Out_String((CHAR*)"desc contains:", 15); + Out_Ln(); + Out_String((CHAR*)"tag: ", 11); + Out_Hex(desc->tag, 1); + Out_Ln(); + Out_String((CHAR*)"next: ", 11); + Out_Hex(desc->next, 1); + Out_Ln(); + Out_String((CHAR*)"level: ", 11); + Out_Hex(desc->level, 1); + Out_Ln(); + Out_String((CHAR*)"module: ", 11); + Out_Hex(desc->module, 1); + Out_Ln(); + Out_DumpModule((Heap_Module)(ADDRESS)desc->module); + Out_String((CHAR*)"name: ", 11); + Out_String(desc->name, 24); + Out_Ln(); + Out_String((CHAR*)"bases: ", 11); + i = 0; + while (i < 16) { + Out_Hex(desc->bases[__X(i, 16)], 8); + if (__MASK(i, -4) == 3) { + Out_Ln(); + Out_String((CHAR*)" ", 11); + } else { + Out_Char(' '); + } + i += 1; + } + Out_Ln(); + Out_String((CHAR*)"reserved: ", 11); + Out_Hex(desc->reserved, 1); + Out_Ln(); + Out_String((CHAR*)"blksz: ", 11); + Out_Hex(desc->blksz, 1); + Out_Ln(); + Out_String((CHAR*)"ptr0: ", 11); + Out_Hex(desc->ptr0, 1); + Out_Ln(); +} + static void Out_digit (INT64 n, CHAR *s, ADDRESS s__len, INT16 *i) { *i -= 1; @@ -380,15 +472,18 @@ void Out_LongReal (LONGREAL x, INT16 n) Out_RealP(x, n, 1); } +__TDESC(typedesc__5, 1, 0) = {__TDFLDS("typedesc__5", 116), {-4}}; export void *Out__init(void) { __DEFMOD; + __MODULE_IMPORT(Heap); __MODULE_IMPORT(Platform); __REGMOD("Out", 0); __REGCMD("Flush", Out_Flush); __REGCMD("Ln", Out_Ln); __REGCMD("Open", Out_Open); + __INITYP(typedesc__5, typedesc__5, 0); /* BEGIN */ Out_IsConsole = Platform_IsConsole(1); Out_in = 0; diff --git a/bootstrap/unix-48/Out.h b/bootstrap/unix-48/Out.h index 1db1f1b3..0b3a93df 100644 --- a/bootstrap/unix-48/Out.h +++ b/bootstrap/unix-48/Out.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Out__h #define Out__h @@ -10,6 +10,7 @@ import BOOLEAN Out_IsConsole; import void Out_Char (CHAR ch); +import void Out_DumpType (SYSTEM_BYTE *o, ADDRESS o__len); import void Out_Flush (void); import void Out_Hex (INT64 x, INT64 n); import void Out_HexDump (SYSTEM_BYTE *m, ADDRESS m__len); diff --git a/bootstrap/unix-48/Platform.c b/bootstrap/unix-48/Platform.c index 22eb3138..a825b8ec 100644 --- a/bootstrap/unix-48/Platform.c +++ b/bootstrap/unix-48/Platform.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/Platform.h b/bootstrap/unix-48/Platform.h index cd9d9890..5d752192 100644 --- a/bootstrap/unix-48/Platform.h +++ b/bootstrap/unix-48/Platform.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/unix-48/Reals.c b/bootstrap/unix-48/Reals.c index f5ee1490..0a2d220b 100644 --- a/bootstrap/unix-48/Reals.c +++ b/bootstrap/unix-48/Reals.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/Reals.h b/bootstrap/unix-48/Reals.h index 6d0ec38b..0c564f0e 100644 --- a/bootstrap/unix-48/Reals.h +++ b/bootstrap/unix-48/Reals.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/unix-48/Strings.c b/bootstrap/unix-48/Strings.c index 4ee2fc23..ed806db0 100644 --- a/bootstrap/unix-48/Strings.c +++ b/bootstrap/unix-48/Strings.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/Strings.h b/bootstrap/unix-48/Strings.h index ae281477..93b62826 100644 --- a/bootstrap/unix-48/Strings.h +++ b/bootstrap/unix-48/Strings.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/unix-48/Texts.c b/bootstrap/unix-48/Texts.c index 4825ab70..a91fe173 100644 --- a/bootstrap/unix-48/Texts.c +++ b/bootstrap/unix-48/Texts.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -390,6 +390,7 @@ void Texts_DumpReader (Texts_Reader re) Texts_DumpRun(re.run); } } + Out_DumpType((void*)&*re.run, 20); } static Texts_FontsFont Texts_FontsThis (CHAR *name, ADDRESS name__len) @@ -1566,8 +1567,8 @@ static void LoadElem__22 (Files_Rider *r, ADDRESS *r__typ, INT32 pos, INT32 span static void LoadElem__22 (Files_Rider *r, ADDRESS *r__typ, INT32 pos, INT32 span, Texts_Elem *e) { - Modules_Module M = NIL; - Modules_Command Cmd; + Heap_Module M = NIL; + Heap_Command Cmd; Texts_Alien a = NIL; INT32 org, ew, eh; INT8 eno; diff --git a/bootstrap/unix-48/Texts.h b/bootstrap/unix-48/Texts.h index c7c8d20f..24dacf51 100644 --- a/bootstrap/unix-48/Texts.h +++ b/bootstrap/unix-48/Texts.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/unix-48/VT100.c b/bootstrap/unix-48/VT100.c index 9ab993c9..ed38e4dc 100644 --- a/bootstrap/unix-48/VT100.c +++ b/bootstrap/unix-48/VT100.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/VT100.h b/bootstrap/unix-48/VT100.h index 3de3605c..69601701 100644 --- a/bootstrap/unix-48/VT100.h +++ b/bootstrap/unix-48/VT100.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef VT100__h #define VT100__h diff --git a/bootstrap/unix-48/extTools.c b/bootstrap/unix-48/extTools.c index 213abf27..0b3a981e 100644 --- a/bootstrap/unix-48/extTools.c +++ b/bootstrap/unix-48/extTools.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/extTools.h b/bootstrap/unix-48/extTools.h index 4278a34c..36571c99 100644 --- a/bootstrap/unix-48/extTools.h +++ b/bootstrap/unix-48/extTools.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef extTools__h #define extTools__h diff --git a/bootstrap/unix-88/Compiler.c b/bootstrap/unix-88/Compiler.c index ffd8b03e..65da2216 100644 --- a/bootstrap/unix-88/Compiler.c +++ b/bootstrap/unix-88/Compiler.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspamS */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspamS */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/Configuration.c b/bootstrap/unix-88/Configuration.c index 6db13d09..77782293 100644 --- a/bootstrap/unix-88/Configuration.c +++ b/bootstrap/unix-88/Configuration.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -19,6 +19,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); + __MOVE("2.00 [2016/12/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 4259cfef..438fec28 100644 --- a/bootstrap/unix-88/Configuration.h +++ b/bootstrap/unix-88/Configuration.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Configuration__h #define Configuration__h diff --git a/bootstrap/unix-88/Files.c b/bootstrap/unix-88/Files.c index 92ada350..bed555a5 100644 --- a/bootstrap/unix-88/Files.c +++ b/bootstrap/unix-88/Files.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/Files.h b/bootstrap/unix-88/Files.h index bb6e46df..ba436b23 100644 --- a/bootstrap/unix-88/Files.h +++ b/bootstrap/unix-88/Files.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/unix-88/Heap.c b/bootstrap/unix-88/Heap.c index 4554feac..3e929c3a 100644 --- a/bootstrap/unix-88/Heap.c +++ b/bootstrap/unix-88/Heap.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -84,6 +84,7 @@ static void Heap_CheckFin (void); static void Heap_ExtendHeap (INT64 blksz); export void Heap_FINALL (void); static void Heap_Finalize (void); +export INT32 Heap_FreeModule (CHAR *name, ADDRESS name__len); export void Heap_GC (BOOLEAN markStack); static void Heap_HeapSort (INT64 n, INT64 *a, ADDRESS a__len); export void Heap_INCREF (Heap_Module m); @@ -143,6 +144,35 @@ SYSTEM_PTR Heap_REGMOD (Heap_ModuleName name, Heap_EnumProc enumPtrs) return (void*)m; } +INT32 Heap_FreeModule (CHAR *name, ADDRESS name__len) +{ + Heap_Module m, p; + __DUP(name, name__len, CHAR); + m = (Heap_Module)(ADDRESS)Heap_modules; + while ((m != NIL && __STRCMP(m->name, name) != 0)) { + p = m; + m = m->next; + } + if ((m != NIL && m->refcnt == 0)) { + if (m == (Heap_Module)(ADDRESS)Heap_modules) { + Heap_modules = (SYSTEM_PTR)m->next; + } else { + p->next = m->next; + } + __DEL(name); + return 0; + } else { + if (m == NIL) { + __DEL(name); + return -1; + } else { + __DEL(name); + return m->refcnt; + } + } + __RETCHK; +} + void Heap_REGCMD (Heap_Module m, Heap_CmdName name, Heap_Command cmd) { Heap_Cmd c; diff --git a/bootstrap/unix-88/Heap.h b/bootstrap/unix-88/Heap.h index 0fb80f05..b2018428 100644 --- a/bootstrap/unix-88/Heap.h +++ b/bootstrap/unix-88/Heap.h @@ -1,16 +1,26 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ #ifndef Heap__h #define Heap__h #include "SYSTEM.h" +typedef + struct Heap_CmdDesc *Heap_Cmd; + typedef CHAR Heap_CmdName[24]; typedef void (*Heap_Command)(void); +typedef + struct Heap_CmdDesc { + Heap_Cmd next; + Heap_CmdName name; + Heap_Command cmd; + } Heap_CmdDesc; + typedef void (*Heap_EnumProc)(void(*)(SYSTEM_PTR)); @@ -21,13 +31,18 @@ typedef struct Heap_ModuleDesc *Heap_Module; typedef - struct Heap_ModuleDesc { - INT64 _prvt0; - char _prvt1[56]; - } Heap_ModuleDesc; + CHAR Heap_ModuleName[20]; typedef - CHAR Heap_ModuleName[20]; + struct Heap_ModuleDesc { + Heap_Module next; + Heap_ModuleName name; + INT32 refcnt; + Heap_Cmd cmds; + INT64 types; + Heap_EnumProc enumPtrs; + char _prvt0[8]; + } Heap_ModuleDesc; import SYSTEM_PTR Heap_modules; @@ -35,8 +50,10 @@ import INT64 Heap_allocated, Heap_heapsize; import INT16 Heap_FileCount; import ADDRESS *Heap_ModuleDesc__typ; +import ADDRESS *Heap_CmdDesc__typ; import void Heap_FINALL (void); +import INT32 Heap_FreeModule (CHAR *name, ADDRESS name__len); import void Heap_GC (BOOLEAN markStack); import void Heap_INCREF (Heap_Module m); import void Heap_InitHeap (void); diff --git a/bootstrap/unix-88/Modules.c b/bootstrap/unix-88/Modules.c index eb227d08..884c7b0e 100644 --- a/bootstrap/unix-88/Modules.c +++ b/bootstrap/unix-88/Modules.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -9,47 +9,15 @@ #include "Heap.h" #include "Platform.h" -typedef - struct Modules_CmdDesc *Modules_Cmd; - -typedef - void (*Modules_Command)(void); - -typedef - struct Modules_CmdDesc { - Modules_Cmd next; - CHAR name[24]; - Modules_Command cmd; - } Modules_CmdDesc; - -typedef - struct Modules_ModuleDesc *Modules_Module; - -typedef - CHAR Modules_ModuleName[20]; - -typedef - struct Modules_ModuleDesc { - Modules_Module next; - Modules_ModuleName name; - INT32 refcnt; - Modules_Cmd cmds; - INT32 types; - void (*enumPtrs)(void(*)(INT32)); - INT32 reserved1, reserved2; - } Modules_ModuleDesc; - export INT16 Modules_res; export CHAR Modules_resMsg[256]; -export Modules_ModuleName Modules_imported, Modules_importing; +export Heap_ModuleName Modules_imported, Modules_importing; export INT64 Modules_MainStackFrame; export INT16 Modules_ArgCount; export INT64 Modules_ArgVector; export CHAR Modules_BinaryDir[1024]; -export ADDRESS *Modules_ModuleDesc__typ; -export ADDRESS *Modules_CmdDesc__typ; static void Modules_Append (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len); static void Modules_AppendPart (CHAR c, CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len); @@ -68,8 +36,8 @@ export void Modules_Init (INT32 argc, INT64 argvadr); static BOOLEAN Modules_IsAbsolute (CHAR *d, ADDRESS d__len); static BOOLEAN Modules_IsFilePresent (CHAR *s, ADDRESS s__len); static BOOLEAN Modules_IsOneOf (CHAR c, CHAR *s, ADDRESS s__len); -export Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, ADDRESS name__len); -export Modules_Module Modules_ThisMod (CHAR *name, ADDRESS name__len); +export Heap_Command Modules_ThisCommand (Heap_Module mod, CHAR *name, ADDRESS name__len); +export Heap_Module Modules_ThisMod (CHAR *name, ADDRESS name__len); static void Modules_Trim (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len); static void Modules_errch (CHAR c); static void Modules_errint (INT32 l); @@ -79,8 +47,7 @@ extern void Heap_InitHeap(); extern void *Modules__init(void); #define Modules_InitHeap() Heap_InitHeap() #define Modules_ModulesInit() Modules__init() -#define Modules_modules() (Modules_Module)Heap_modules -#define Modules_setmodules(m) Heap_modules = m +#define Modules_modules() (Heap_Module)Heap_modules void Modules_Init (INT32 argc, INT64 argvadr) { @@ -334,11 +301,11 @@ static void Modules_FindBinaryDir (CHAR *binarydir, ADDRESS binarydir__len) } } -Modules_Module Modules_ThisMod (CHAR *name, ADDRESS name__len) +Heap_Module Modules_ThisMod (CHAR *name, ADDRESS name__len) { - Modules_Module m = NIL; + Heap_Module m = NIL; CHAR bodyname[64]; - Modules_Command body; + Heap_Command body; __DUP(name, name__len, CHAR); m = Modules_modules(); while ((m != NIL && __STRCMP(m->name, name) != 0)) { @@ -358,9 +325,9 @@ Modules_Module Modules_ThisMod (CHAR *name, ADDRESS name__len) return m; } -Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, ADDRESS name__len) +Heap_Command Modules_ThisCommand (Heap_Module mod, CHAR *name, ADDRESS name__len) { - Modules_Cmd c = NIL; + Heap_Cmd c = NIL; __DUP(name, name__len, CHAR); c = mod->cmds; while ((c != NIL && __STRCMP(c->name, name) != 0)) { @@ -387,31 +354,24 @@ Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, ADDRESS nam void Modules_Free (CHAR *name, ADDRESS name__len, BOOLEAN all) { - Modules_Module m = NIL, p = NIL; + Heap_Module m = NIL, p = NIL; + INT32 refcount; __DUP(name, name__len, CHAR); m = Modules_modules(); if (all) { Modules_res = 1; __MOVE("unloading \"all\" not yet supported", Modules_resMsg, 34); } else { - while ((m != NIL && __STRCMP(m->name, name) != 0)) { - p = m; - m = m->next; - } - if ((m != NIL && m->refcnt == 0)) { - if (m == Modules_modules()) { - Modules_setmodules(m->next); - } else { - p->next = m->next; - } + refcount = Heap_FreeModule(name, name__len); + if (refcount == 0) { Modules_res = 0; } else { - Modules_res = 1; - if (m == NIL) { + if (refcount < 0) { __MOVE("module not found", Modules_resMsg, 17); } else { __MOVE("clients of this module exist", Modules_resMsg, 29); } + Modules_res = 1; } } __DEL(name); @@ -533,8 +493,6 @@ void Modules_AssertFail (INT32 code) } } -__TDESC(Modules_ModuleDesc, 1, 2) = {__TDFLDS("ModuleDesc", 64), {0, 32, -24}}; -__TDESC(Modules_CmdDesc, 1, 1) = {__TDFLDS("CmdDesc", 40), {0, -16}}; export void *Modules__init(void) { @@ -542,8 +500,6 @@ export void *Modules__init(void) __MODULE_IMPORT(Heap); __MODULE_IMPORT(Platform); __REGMOD("Modules", 0); - __INITYP(Modules_ModuleDesc, Modules_ModuleDesc, 0); - __INITYP(Modules_CmdDesc, Modules_CmdDesc, 0); /* BEGIN */ Modules_FindBinaryDir((void*)Modules_BinaryDir, 1024); __ENDMOD; diff --git a/bootstrap/unix-88/Modules.h b/bootstrap/unix-88/Modules.h index 3ee70401..e5803d29 100644 --- a/bootstrap/unix-88/Modules.h +++ b/bootstrap/unix-88/Modules.h @@ -1,51 +1,20 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Modules__h #define Modules__h #include "SYSTEM.h" - -typedef - struct Modules_CmdDesc *Modules_Cmd; - -typedef - void (*Modules_Command)(void); - -typedef - struct Modules_CmdDesc { - Modules_Cmd next; - CHAR name[24]; - Modules_Command cmd; - } Modules_CmdDesc; - -typedef - struct Modules_ModuleDesc *Modules_Module; - -typedef - CHAR Modules_ModuleName[20]; - -typedef - struct Modules_ModuleDesc { - Modules_Module next; - Modules_ModuleName name; - INT32 refcnt; - Modules_Cmd cmds; - INT32 types; - void (*enumPtrs)(void(*)(INT32)); - char _prvt0[8]; - } Modules_ModuleDesc; +#include "Heap.h" import INT16 Modules_res; import CHAR Modules_resMsg[256]; -import Modules_ModuleName Modules_imported, Modules_importing; +import Heap_ModuleName Modules_imported, Modules_importing; import INT64 Modules_MainStackFrame; import INT16 Modules_ArgCount; import INT64 Modules_ArgVector; import CHAR Modules_BinaryDir[1024]; -import ADDRESS *Modules_ModuleDesc__typ; -import ADDRESS *Modules_CmdDesc__typ; import INT16 Modules_ArgPos (CHAR *s, ADDRESS s__len); import void Modules_AssertFail (INT32 code); @@ -54,8 +23,8 @@ import void Modules_GetArg (INT16 n, CHAR *val, ADDRESS val__len); import void Modules_GetIntArg (INT16 n, INT32 *val); import void Modules_Halt (INT32 code); import void Modules_Init (INT32 argc, INT64 argvadr); -import Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, ADDRESS name__len); -import Modules_Module Modules_ThisMod (CHAR *name, ADDRESS name__len); +import Heap_Command Modules_ThisCommand (Heap_Module mod, CHAR *name, ADDRESS name__len); +import Heap_Module Modules_ThisMod (CHAR *name, ADDRESS name__len); import void *Modules__init(void); diff --git a/bootstrap/unix-88/OPB.c b/bootstrap/unix-88/OPB.c index d83386eb..7e558357 100644 --- a/bootstrap/unix-88/OPB.c +++ b/bootstrap/unix-88/OPB.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/OPB.h b/bootstrap/unix-88/OPB.h index feb85d73..b6d457bd 100644 --- a/bootstrap/unix-88/OPB.h +++ b/bootstrap/unix-88/OPB.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPB__h #define OPB__h diff --git a/bootstrap/unix-88/OPC.c b/bootstrap/unix-88/OPC.c index ab01642c..c09d2e6a 100644 --- a/bootstrap/unix-88/OPC.c +++ b/bootstrap/unix-88/OPC.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/OPC.h b/bootstrap/unix-88/OPC.h index f742f265..7c47ed18 100644 --- a/bootstrap/unix-88/OPC.h +++ b/bootstrap/unix-88/OPC.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPC__h #define OPC__h diff --git a/bootstrap/unix-88/OPM.c b/bootstrap/unix-88/OPM.c index 1335c494..e3e6f1fe 100644 --- a/bootstrap/unix-88/OPM.c +++ b/bootstrap/unix-88/OPM.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/OPM.h b/bootstrap/unix-88/OPM.h index 621dfb51..6d2755d8 100644 --- a/bootstrap/unix-88/OPM.h +++ b/bootstrap/unix-88/OPM.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPM__h #define OPM__h diff --git a/bootstrap/unix-88/OPP.c b/bootstrap/unix-88/OPP.c index 3f9dfde3..dc87be62 100644 --- a/bootstrap/unix-88/OPP.c +++ b/bootstrap/unix-88/OPP.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/OPP.h b/bootstrap/unix-88/OPP.h index c1fe21fb..c13a4e91 100644 --- a/bootstrap/unix-88/OPP.h +++ b/bootstrap/unix-88/OPP.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/unix-88/OPS.c b/bootstrap/unix-88/OPS.c index 4569c80d..ed3ea3a1 100644 --- a/bootstrap/unix-88/OPS.c +++ b/bootstrap/unix-88/OPS.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/OPS.h b/bootstrap/unix-88/OPS.h index c0707c34..6dae098c 100644 --- a/bootstrap/unix-88/OPS.h +++ b/bootstrap/unix-88/OPS.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/unix-88/OPT.c b/bootstrap/unix-88/OPT.c index 07f8f535..25e2e7c2 100644 --- a/bootstrap/unix-88/OPT.c +++ b/bootstrap/unix-88/OPT.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/OPT.h b/bootstrap/unix-88/OPT.h index 6b2b0929..00094b66 100644 --- a/bootstrap/unix-88/OPT.h +++ b/bootstrap/unix-88/OPT.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPT__h #define OPT__h diff --git a/bootstrap/unix-88/OPV.c b/bootstrap/unix-88/OPV.c index 4506267a..c88953f2 100644 --- a/bootstrap/unix-88/OPV.c +++ b/bootstrap/unix-88/OPV.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/OPV.h b/bootstrap/unix-88/OPV.h index d363f022..f83e65fb 100644 --- a/bootstrap/unix-88/OPV.h +++ b/bootstrap/unix-88/OPV.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPV__h #define OPV__h diff --git a/bootstrap/unix-88/Out.c b/bootstrap/unix-88/Out.c index d4d8e5f4..3129c109 100644 --- a/bootstrap/unix-88/Out.c +++ b/bootstrap/unix-88/Out.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -6,6 +6,7 @@ #define SET UINT32 #include "SYSTEM.h" +#include "Heap.h" #include "Platform.h" @@ -13,8 +14,11 @@ export BOOLEAN Out_IsConsole; static CHAR Out_buf[128]; static INT16 Out_in; +static ADDRESS *typedesc__5__typ; export void Out_Char (CHAR ch); +static void Out_DumpModule (Heap_Module m); +export void Out_DumpType (SYSTEM_BYTE *o, ADDRESS o__len); export void Out_Flush (void); export void Out_Hex (INT64 x, INT64 n); export void Out_HexDump (SYSTEM_BYTE *m, ADDRESS m__len); @@ -203,6 +207,94 @@ void Out_HexDump (SYSTEM_BYTE *m, ADDRESS m__len) Out_HexDumpAdr((ADDRESS)m, 0, m__len); } +static void Out_DumpModule (Heap_Module m) +{ + Out_String((CHAR*)" next: ", 13); + Out_Hex((INT64)(ADDRESS)m->next, 1); + Out_Ln(); + Out_String((CHAR*)" name: ", 13); + Out_String(m->name, 20); + Out_Ln(); + Out_String((CHAR*)" refcnt: ", 13); + Out_Hex(m->refcnt, 1); + Out_Ln(); + Out_String((CHAR*)" cmds: ", 13); + Out_Hex((INT64)(ADDRESS)m->cmds, 1); + Out_Ln(); + Out_String((CHAR*)" types: ", 13); + Out_Hex(m->types, 1); + Out_Ln(); + Out_String((CHAR*)" enumPtrs: ", 13); + Out_Hex((INT64)(ADDRESS)m->enumPtrs, 1); + Out_Ln(); +} + +typedef + struct typedesc__5 *tag__4; + +typedef + struct typedesc__5 { + INT64 tag, next, level, module; + CHAR name[24]; + INT64 bases[16]; + INT64 reserved, blksz, ptr0; + } typedesc__5; + +void Out_DumpType (SYSTEM_BYTE *o, ADDRESS o__len) +{ + INT64 addr; + tag__4 desc = NIL; + INT16 i; + __GET((ADDRESS)o - 8, addr, INT64); + Out_String((CHAR*)"obj tag: ", 11); + Out_Hex(addr, 1); + Out_Ln(); + desc = (tag__4)(ADDRESS)(addr - 192); + Out_String((CHAR*)"desc at: ", 11); + Out_Hex((INT64)(ADDRESS)desc, 1); + Out_Ln(); + Out_String((CHAR*)"desc contains:", 15); + Out_Ln(); + Out_String((CHAR*)"tag: ", 11); + Out_Hex(desc->tag, 1); + Out_Ln(); + Out_String((CHAR*)"next: ", 11); + Out_Hex(desc->next, 1); + Out_Ln(); + Out_String((CHAR*)"level: ", 11); + Out_Hex(desc->level, 1); + Out_Ln(); + Out_String((CHAR*)"module: ", 11); + Out_Hex(desc->module, 1); + Out_Ln(); + Out_DumpModule((Heap_Module)(ADDRESS)desc->module); + Out_String((CHAR*)"name: ", 11); + Out_String(desc->name, 24); + Out_Ln(); + Out_String((CHAR*)"bases: ", 11); + i = 0; + while (i < 16) { + Out_Hex(desc->bases[__X(i, 16)], 16); + if (__MASK(i, -4) == 3) { + Out_Ln(); + Out_String((CHAR*)" ", 11); + } else { + Out_Char(' '); + } + i += 1; + } + Out_Ln(); + Out_String((CHAR*)"reserved: ", 11); + Out_Hex(desc->reserved, 1); + Out_Ln(); + Out_String((CHAR*)"blksz: ", 11); + Out_Hex(desc->blksz, 1); + Out_Ln(); + Out_String((CHAR*)"ptr0: ", 11); + Out_Hex(desc->ptr0, 1); + Out_Ln(); +} + static void Out_digit (INT64 n, CHAR *s, ADDRESS s__len, INT16 *i) { *i -= 1; @@ -380,15 +472,18 @@ void Out_LongReal (LONGREAL x, INT16 n) Out_RealP(x, n, 1); } +__TDESC(typedesc__5, 1, 0) = {__TDFLDS("typedesc__5", 208), {-8}}; export void *Out__init(void) { __DEFMOD; + __MODULE_IMPORT(Heap); __MODULE_IMPORT(Platform); __REGMOD("Out", 0); __REGCMD("Flush", Out_Flush); __REGCMD("Ln", Out_Ln); __REGCMD("Open", Out_Open); + __INITYP(typedesc__5, typedesc__5, 0); /* BEGIN */ Out_IsConsole = Platform_IsConsole(1); Out_in = 0; diff --git a/bootstrap/unix-88/Out.h b/bootstrap/unix-88/Out.h index 24829244..0126ef62 100644 --- a/bootstrap/unix-88/Out.h +++ b/bootstrap/unix-88/Out.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Out__h #define Out__h @@ -10,6 +10,7 @@ import BOOLEAN Out_IsConsole; import void Out_Char (CHAR ch); +import void Out_DumpType (SYSTEM_BYTE *o, ADDRESS o__len); import void Out_Flush (void); import void Out_Hex (INT64 x, INT64 n); import void Out_HexDump (SYSTEM_BYTE *m, ADDRESS m__len); diff --git a/bootstrap/unix-88/Platform.c b/bootstrap/unix-88/Platform.c index 51a8fde7..d695bda2 100644 --- a/bootstrap/unix-88/Platform.c +++ b/bootstrap/unix-88/Platform.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/Platform.h b/bootstrap/unix-88/Platform.h index 56fab736..741cf3f7 100644 --- a/bootstrap/unix-88/Platform.h +++ b/bootstrap/unix-88/Platform.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/unix-88/Reals.c b/bootstrap/unix-88/Reals.c index f5ee1490..0a2d220b 100644 --- a/bootstrap/unix-88/Reals.c +++ b/bootstrap/unix-88/Reals.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/Reals.h b/bootstrap/unix-88/Reals.h index 6d0ec38b..0c564f0e 100644 --- a/bootstrap/unix-88/Reals.h +++ b/bootstrap/unix-88/Reals.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/unix-88/Strings.c b/bootstrap/unix-88/Strings.c index 4ee2fc23..ed806db0 100644 --- a/bootstrap/unix-88/Strings.c +++ b/bootstrap/unix-88/Strings.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/Strings.h b/bootstrap/unix-88/Strings.h index ae281477..93b62826 100644 --- a/bootstrap/unix-88/Strings.h +++ b/bootstrap/unix-88/Strings.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/unix-88/Texts.c b/bootstrap/unix-88/Texts.c index 9887162e..bd19d27b 100644 --- a/bootstrap/unix-88/Texts.c +++ b/bootstrap/unix-88/Texts.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -390,6 +390,7 @@ void Texts_DumpReader (Texts_Reader re) Texts_DumpRun(re.run); } } + Out_DumpType((void*)&*re.run, 40); } static Texts_FontsFont Texts_FontsThis (CHAR *name, ADDRESS name__len) @@ -1566,8 +1567,8 @@ static void LoadElem__22 (Files_Rider *r, ADDRESS *r__typ, INT32 pos, INT32 span static void LoadElem__22 (Files_Rider *r, ADDRESS *r__typ, INT32 pos, INT32 span, Texts_Elem *e) { - Modules_Module M = NIL; - Modules_Command Cmd; + Heap_Module M = NIL; + Heap_Command Cmd; Texts_Alien a = NIL; INT32 org, ew, eh; INT8 eno; diff --git a/bootstrap/unix-88/Texts.h b/bootstrap/unix-88/Texts.h index e14afb26..2cf87339 100644 --- a/bootstrap/unix-88/Texts.h +++ b/bootstrap/unix-88/Texts.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/unix-88/VT100.c b/bootstrap/unix-88/VT100.c index 9ab993c9..ed38e4dc 100644 --- a/bootstrap/unix-88/VT100.c +++ b/bootstrap/unix-88/VT100.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/VT100.h b/bootstrap/unix-88/VT100.h index 3de3605c..69601701 100644 --- a/bootstrap/unix-88/VT100.h +++ b/bootstrap/unix-88/VT100.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef VT100__h #define VT100__h diff --git a/bootstrap/unix-88/extTools.c b/bootstrap/unix-88/extTools.c index 213abf27..0b3a981e 100644 --- a/bootstrap/unix-88/extTools.c +++ b/bootstrap/unix-88/extTools.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/extTools.h b/bootstrap/unix-88/extTools.h index 4278a34c..36571c99 100644 --- a/bootstrap/unix-88/extTools.h +++ b/bootstrap/unix-88/extTools.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef extTools__h #define extTools__h diff --git a/bootstrap/windows-48/Compiler.c b/bootstrap/windows-48/Compiler.c index ffd8b03e..65da2216 100644 --- a/bootstrap/windows-48/Compiler.c +++ b/bootstrap/windows-48/Compiler.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspamS */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspamS */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/Configuration.c b/bootstrap/windows-48/Configuration.c index 6db13d09..77782293 100644 --- a/bootstrap/windows-48/Configuration.c +++ b/bootstrap/windows-48/Configuration.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -19,6 +19,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); + __MOVE("2.00 [2016/12/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 4259cfef..438fec28 100644 --- a/bootstrap/windows-48/Configuration.h +++ b/bootstrap/windows-48/Configuration.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Configuration__h #define Configuration__h diff --git a/bootstrap/windows-48/Files.c b/bootstrap/windows-48/Files.c index 2b8c7919..b4133ede 100644 --- a/bootstrap/windows-48/Files.c +++ b/bootstrap/windows-48/Files.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/Files.h b/bootstrap/windows-48/Files.h index dfeeebb3..7aaa4f5a 100644 --- a/bootstrap/windows-48/Files.h +++ b/bootstrap/windows-48/Files.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/windows-48/Heap.c b/bootstrap/windows-48/Heap.c index 125a2854..c9adb169 100644 --- a/bootstrap/windows-48/Heap.c +++ b/bootstrap/windows-48/Heap.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -84,6 +84,7 @@ static void Heap_CheckFin (void); static void Heap_ExtendHeap (INT32 blksz); export void Heap_FINALL (void); static void Heap_Finalize (void); +export INT32 Heap_FreeModule (CHAR *name, ADDRESS name__len); export void Heap_GC (BOOLEAN markStack); static void Heap_HeapSort (INT32 n, INT32 *a, ADDRESS a__len); export void Heap_INCREF (Heap_Module m); @@ -143,6 +144,35 @@ SYSTEM_PTR Heap_REGMOD (Heap_ModuleName name, Heap_EnumProc enumPtrs) return (void*)m; } +INT32 Heap_FreeModule (CHAR *name, ADDRESS name__len) +{ + Heap_Module m, p; + __DUP(name, name__len, CHAR); + m = (Heap_Module)(ADDRESS)Heap_modules; + while ((m != NIL && __STRCMP(m->name, name) != 0)) { + p = m; + m = m->next; + } + if ((m != NIL && m->refcnt == 0)) { + if (m == (Heap_Module)(ADDRESS)Heap_modules) { + Heap_modules = (SYSTEM_PTR)m->next; + } else { + p->next = m->next; + } + __DEL(name); + return 0; + } else { + if (m == NIL) { + __DEL(name); + return -1; + } else { + __DEL(name); + return m->refcnt; + } + } + __RETCHK; +} + void Heap_REGCMD (Heap_Module m, Heap_CmdName name, Heap_Command cmd) { Heap_Cmd c; diff --git a/bootstrap/windows-48/Heap.h b/bootstrap/windows-48/Heap.h index e794a4a3..0df71d54 100644 --- a/bootstrap/windows-48/Heap.h +++ b/bootstrap/windows-48/Heap.h @@ -1,16 +1,26 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ #ifndef Heap__h #define Heap__h #include "SYSTEM.h" +typedef + struct Heap_CmdDesc *Heap_Cmd; + typedef CHAR Heap_CmdName[24]; typedef void (*Heap_Command)(void); +typedef + struct Heap_CmdDesc { + Heap_Cmd next; + Heap_CmdName name; + Heap_Command cmd; + } Heap_CmdDesc; + typedef void (*Heap_EnumProc)(void(*)(SYSTEM_PTR)); @@ -21,13 +31,18 @@ typedef struct Heap_ModuleDesc *Heap_Module; typedef - struct Heap_ModuleDesc { - INT32 _prvt0; - char _prvt1[44]; - } Heap_ModuleDesc; + CHAR Heap_ModuleName[20]; typedef - CHAR Heap_ModuleName[20]; + struct Heap_ModuleDesc { + Heap_Module next; + Heap_ModuleName name; + INT32 refcnt; + Heap_Cmd cmds; + INT32 types; + Heap_EnumProc enumPtrs; + char _prvt0[8]; + } Heap_ModuleDesc; import SYSTEM_PTR Heap_modules; @@ -35,8 +50,10 @@ import INT32 Heap_allocated, Heap_heapsize; import INT16 Heap_FileCount; import ADDRESS *Heap_ModuleDesc__typ; +import ADDRESS *Heap_CmdDesc__typ; import void Heap_FINALL (void); +import INT32 Heap_FreeModule (CHAR *name, ADDRESS name__len); import void Heap_GC (BOOLEAN markStack); import void Heap_INCREF (Heap_Module m); import void Heap_InitHeap (void); diff --git a/bootstrap/windows-48/Modules.c b/bootstrap/windows-48/Modules.c index ab668fec..6d8570ec 100644 --- a/bootstrap/windows-48/Modules.c +++ b/bootstrap/windows-48/Modules.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -9,47 +9,15 @@ #include "Heap.h" #include "Platform.h" -typedef - struct Modules_CmdDesc *Modules_Cmd; - -typedef - void (*Modules_Command)(void); - -typedef - struct Modules_CmdDesc { - Modules_Cmd next; - CHAR name[24]; - Modules_Command cmd; - } Modules_CmdDesc; - -typedef - struct Modules_ModuleDesc *Modules_Module; - -typedef - CHAR Modules_ModuleName[20]; - -typedef - struct Modules_ModuleDesc { - Modules_Module next; - Modules_ModuleName name; - INT32 refcnt; - Modules_Cmd cmds; - INT32 types; - void (*enumPtrs)(void(*)(INT32)); - INT32 reserved1, reserved2; - } Modules_ModuleDesc; - export INT16 Modules_res; export CHAR Modules_resMsg[256]; -export Modules_ModuleName Modules_imported, Modules_importing; +export Heap_ModuleName Modules_imported, Modules_importing; export INT32 Modules_MainStackFrame; export INT16 Modules_ArgCount; export INT32 Modules_ArgVector; export CHAR Modules_BinaryDir[1024]; -export ADDRESS *Modules_ModuleDesc__typ; -export ADDRESS *Modules_CmdDesc__typ; static void Modules_Append (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len); static void Modules_AppendPart (CHAR c, CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len); @@ -68,8 +36,8 @@ export void Modules_Init (INT32 argc, INT32 argvadr); static BOOLEAN Modules_IsAbsolute (CHAR *d, ADDRESS d__len); static BOOLEAN Modules_IsFilePresent (CHAR *s, ADDRESS s__len); static BOOLEAN Modules_IsOneOf (CHAR c, CHAR *s, ADDRESS s__len); -export Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, ADDRESS name__len); -export Modules_Module Modules_ThisMod (CHAR *name, ADDRESS name__len); +export Heap_Command Modules_ThisCommand (Heap_Module mod, CHAR *name, ADDRESS name__len); +export Heap_Module Modules_ThisMod (CHAR *name, ADDRESS name__len); static void Modules_Trim (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len); static void Modules_errch (CHAR c); static void Modules_errint (INT32 l); @@ -79,8 +47,7 @@ extern void Heap_InitHeap(); extern void *Modules__init(void); #define Modules_InitHeap() Heap_InitHeap() #define Modules_ModulesInit() Modules__init() -#define Modules_modules() (Modules_Module)Heap_modules -#define Modules_setmodules(m) Heap_modules = m +#define Modules_modules() (Heap_Module)Heap_modules void Modules_Init (INT32 argc, INT32 argvadr) { @@ -334,11 +301,11 @@ static void Modules_FindBinaryDir (CHAR *binarydir, ADDRESS binarydir__len) } } -Modules_Module Modules_ThisMod (CHAR *name, ADDRESS name__len) +Heap_Module Modules_ThisMod (CHAR *name, ADDRESS name__len) { - Modules_Module m = NIL; + Heap_Module m = NIL; CHAR bodyname[64]; - Modules_Command body; + Heap_Command body; __DUP(name, name__len, CHAR); m = Modules_modules(); while ((m != NIL && __STRCMP(m->name, name) != 0)) { @@ -358,9 +325,9 @@ Modules_Module Modules_ThisMod (CHAR *name, ADDRESS name__len) return m; } -Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, ADDRESS name__len) +Heap_Command Modules_ThisCommand (Heap_Module mod, CHAR *name, ADDRESS name__len) { - Modules_Cmd c = NIL; + Heap_Cmd c = NIL; __DUP(name, name__len, CHAR); c = mod->cmds; while ((c != NIL && __STRCMP(c->name, name) != 0)) { @@ -387,31 +354,24 @@ Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, ADDRESS nam void Modules_Free (CHAR *name, ADDRESS name__len, BOOLEAN all) { - Modules_Module m = NIL, p = NIL; + Heap_Module m = NIL, p = NIL; + INT32 refcount; __DUP(name, name__len, CHAR); m = Modules_modules(); if (all) { Modules_res = 1; __MOVE("unloading \"all\" not yet supported", Modules_resMsg, 34); } else { - while ((m != NIL && __STRCMP(m->name, name) != 0)) { - p = m; - m = m->next; - } - if ((m != NIL && m->refcnt == 0)) { - if (m == Modules_modules()) { - Modules_setmodules(m->next); - } else { - p->next = m->next; - } + refcount = Heap_FreeModule(name, name__len); + if (refcount == 0) { Modules_res = 0; } else { - Modules_res = 1; - if (m == NIL) { + if (refcount < 0) { __MOVE("module not found", Modules_resMsg, 17); } else { __MOVE("clients of this module exist", Modules_resMsg, 29); } + Modules_res = 1; } } __DEL(name); @@ -533,8 +493,6 @@ void Modules_AssertFail (INT32 code) } } -__TDESC(Modules_ModuleDesc, 1, 2) = {__TDFLDS("ModuleDesc", 48), {0, 28, -12}}; -__TDESC(Modules_CmdDesc, 1, 1) = {__TDFLDS("CmdDesc", 32), {0, -8}}; export void *Modules__init(void) { @@ -542,8 +500,6 @@ export void *Modules__init(void) __MODULE_IMPORT(Heap); __MODULE_IMPORT(Platform); __REGMOD("Modules", 0); - __INITYP(Modules_ModuleDesc, Modules_ModuleDesc, 0); - __INITYP(Modules_CmdDesc, Modules_CmdDesc, 0); /* BEGIN */ Modules_FindBinaryDir((void*)Modules_BinaryDir, 1024); __ENDMOD; diff --git a/bootstrap/windows-48/Modules.h b/bootstrap/windows-48/Modules.h index 553f80ed..3c1c580d 100644 --- a/bootstrap/windows-48/Modules.h +++ b/bootstrap/windows-48/Modules.h @@ -1,51 +1,20 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Modules__h #define Modules__h #include "SYSTEM.h" - -typedef - struct Modules_CmdDesc *Modules_Cmd; - -typedef - void (*Modules_Command)(void); - -typedef - struct Modules_CmdDesc { - Modules_Cmd next; - CHAR name[24]; - Modules_Command cmd; - } Modules_CmdDesc; - -typedef - struct Modules_ModuleDesc *Modules_Module; - -typedef - CHAR Modules_ModuleName[20]; - -typedef - struct Modules_ModuleDesc { - Modules_Module next; - Modules_ModuleName name; - INT32 refcnt; - Modules_Cmd cmds; - INT32 types; - void (*enumPtrs)(void(*)(INT32)); - char _prvt0[8]; - } Modules_ModuleDesc; +#include "Heap.h" import INT16 Modules_res; import CHAR Modules_resMsg[256]; -import Modules_ModuleName Modules_imported, Modules_importing; +import Heap_ModuleName Modules_imported, Modules_importing; import INT32 Modules_MainStackFrame; import INT16 Modules_ArgCount; import INT32 Modules_ArgVector; import CHAR Modules_BinaryDir[1024]; -import ADDRESS *Modules_ModuleDesc__typ; -import ADDRESS *Modules_CmdDesc__typ; import INT16 Modules_ArgPos (CHAR *s, ADDRESS s__len); import void Modules_AssertFail (INT32 code); @@ -54,8 +23,8 @@ import void Modules_GetArg (INT16 n, CHAR *val, ADDRESS val__len); import void Modules_GetIntArg (INT16 n, INT32 *val); import void Modules_Halt (INT32 code); import void Modules_Init (INT32 argc, INT32 argvadr); -import Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, ADDRESS name__len); -import Modules_Module Modules_ThisMod (CHAR *name, ADDRESS name__len); +import Heap_Command Modules_ThisCommand (Heap_Module mod, CHAR *name, ADDRESS name__len); +import Heap_Module Modules_ThisMod (CHAR *name, ADDRESS name__len); import void *Modules__init(void); diff --git a/bootstrap/windows-48/OPB.c b/bootstrap/windows-48/OPB.c index d83386eb..7e558357 100644 --- a/bootstrap/windows-48/OPB.c +++ b/bootstrap/windows-48/OPB.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/OPB.h b/bootstrap/windows-48/OPB.h index feb85d73..b6d457bd 100644 --- a/bootstrap/windows-48/OPB.h +++ b/bootstrap/windows-48/OPB.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPB__h #define OPB__h diff --git a/bootstrap/windows-48/OPC.c b/bootstrap/windows-48/OPC.c index ab01642c..c09d2e6a 100644 --- a/bootstrap/windows-48/OPC.c +++ b/bootstrap/windows-48/OPC.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/OPC.h b/bootstrap/windows-48/OPC.h index f742f265..7c47ed18 100644 --- a/bootstrap/windows-48/OPC.h +++ b/bootstrap/windows-48/OPC.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPC__h #define OPC__h diff --git a/bootstrap/windows-48/OPM.c b/bootstrap/windows-48/OPM.c index a6c7a5cd..a3718f79 100644 --- a/bootstrap/windows-48/OPM.c +++ b/bootstrap/windows-48/OPM.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/OPM.h b/bootstrap/windows-48/OPM.h index 621dfb51..6d2755d8 100644 --- a/bootstrap/windows-48/OPM.h +++ b/bootstrap/windows-48/OPM.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPM__h #define OPM__h diff --git a/bootstrap/windows-48/OPP.c b/bootstrap/windows-48/OPP.c index 383b6d65..5924f42f 100644 --- a/bootstrap/windows-48/OPP.c +++ b/bootstrap/windows-48/OPP.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/OPP.h b/bootstrap/windows-48/OPP.h index c1fe21fb..c13a4e91 100644 --- a/bootstrap/windows-48/OPP.h +++ b/bootstrap/windows-48/OPP.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/windows-48/OPS.c b/bootstrap/windows-48/OPS.c index 4569c80d..ed3ea3a1 100644 --- a/bootstrap/windows-48/OPS.c +++ b/bootstrap/windows-48/OPS.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/OPS.h b/bootstrap/windows-48/OPS.h index c0707c34..6dae098c 100644 --- a/bootstrap/windows-48/OPS.h +++ b/bootstrap/windows-48/OPS.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/windows-48/OPT.c b/bootstrap/windows-48/OPT.c index 0d32553a..6b6144fc 100644 --- a/bootstrap/windows-48/OPT.c +++ b/bootstrap/windows-48/OPT.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/OPT.h b/bootstrap/windows-48/OPT.h index 6b2b0929..00094b66 100644 --- a/bootstrap/windows-48/OPT.h +++ b/bootstrap/windows-48/OPT.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPT__h #define OPT__h diff --git a/bootstrap/windows-48/OPV.c b/bootstrap/windows-48/OPV.c index 42081077..7e829aa2 100644 --- a/bootstrap/windows-48/OPV.c +++ b/bootstrap/windows-48/OPV.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/OPV.h b/bootstrap/windows-48/OPV.h index d363f022..f83e65fb 100644 --- a/bootstrap/windows-48/OPV.h +++ b/bootstrap/windows-48/OPV.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPV__h #define OPV__h diff --git a/bootstrap/windows-48/Out.c b/bootstrap/windows-48/Out.c index 7e1c7459..21e029bd 100644 --- a/bootstrap/windows-48/Out.c +++ b/bootstrap/windows-48/Out.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -6,6 +6,7 @@ #define SET UINT32 #include "SYSTEM.h" +#include "Heap.h" #include "Platform.h" @@ -13,8 +14,11 @@ export BOOLEAN Out_IsConsole; static CHAR Out_buf[128]; static INT16 Out_in; +static ADDRESS *typedesc__5__typ; export void Out_Char (CHAR ch); +static void Out_DumpModule (Heap_Module m); +export void Out_DumpType (SYSTEM_BYTE *o, ADDRESS o__len); export void Out_Flush (void); export void Out_Hex (INT64 x, INT64 n); export void Out_HexDump (SYSTEM_BYTE *m, ADDRESS m__len); @@ -203,6 +207,94 @@ void Out_HexDump (SYSTEM_BYTE *m, ADDRESS m__len) Out_HexDumpAdr((ADDRESS)m, 0, m__len); } +static void Out_DumpModule (Heap_Module m) +{ + Out_String((CHAR*)" next: ", 13); + Out_Hex((INT32)(ADDRESS)m->next, 1); + Out_Ln(); + Out_String((CHAR*)" name: ", 13); + Out_String(m->name, 20); + Out_Ln(); + Out_String((CHAR*)" refcnt: ", 13); + Out_Hex(m->refcnt, 1); + Out_Ln(); + Out_String((CHAR*)" cmds: ", 13); + Out_Hex((INT32)(ADDRESS)m->cmds, 1); + Out_Ln(); + Out_String((CHAR*)" types: ", 13); + Out_Hex(m->types, 1); + Out_Ln(); + Out_String((CHAR*)" enumPtrs: ", 13); + Out_Hex((INT32)(ADDRESS)m->enumPtrs, 1); + Out_Ln(); +} + +typedef + struct typedesc__5 *tag__4; + +typedef + struct typedesc__5 { + INT32 tag, next, level, module; + CHAR name[24]; + INT32 bases[16]; + INT32 reserved, blksz, ptr0; + } typedesc__5; + +void Out_DumpType (SYSTEM_BYTE *o, ADDRESS o__len) +{ + INT32 addr; + tag__4 desc = NIL; + INT16 i; + __GET((ADDRESS)o - 4, addr, INT32); + Out_String((CHAR*)"obj tag: ", 11); + Out_Hex(addr, 1); + Out_Ln(); + desc = (tag__4)(ADDRESS)(addr - 108); + Out_String((CHAR*)"desc at: ", 11); + Out_Hex((INT32)(ADDRESS)desc, 1); + Out_Ln(); + Out_String((CHAR*)"desc contains:", 15); + Out_Ln(); + Out_String((CHAR*)"tag: ", 11); + Out_Hex(desc->tag, 1); + Out_Ln(); + Out_String((CHAR*)"next: ", 11); + Out_Hex(desc->next, 1); + Out_Ln(); + Out_String((CHAR*)"level: ", 11); + Out_Hex(desc->level, 1); + Out_Ln(); + Out_String((CHAR*)"module: ", 11); + Out_Hex(desc->module, 1); + Out_Ln(); + Out_DumpModule((Heap_Module)(ADDRESS)desc->module); + Out_String((CHAR*)"name: ", 11); + Out_String(desc->name, 24); + Out_Ln(); + Out_String((CHAR*)"bases: ", 11); + i = 0; + while (i < 16) { + Out_Hex(desc->bases[__X(i, 16)], 8); + if (__MASK(i, -4) == 3) { + Out_Ln(); + Out_String((CHAR*)" ", 11); + } else { + Out_Char(' '); + } + i += 1; + } + Out_Ln(); + Out_String((CHAR*)"reserved: ", 11); + Out_Hex(desc->reserved, 1); + Out_Ln(); + Out_String((CHAR*)"blksz: ", 11); + Out_Hex(desc->blksz, 1); + Out_Ln(); + Out_String((CHAR*)"ptr0: ", 11); + Out_Hex(desc->ptr0, 1); + Out_Ln(); +} + static void Out_digit (INT64 n, CHAR *s, ADDRESS s__len, INT16 *i) { *i -= 1; @@ -380,15 +472,18 @@ void Out_LongReal (LONGREAL x, INT16 n) Out_RealP(x, n, 1); } +__TDESC(typedesc__5, 1, 0) = {__TDFLDS("typedesc__5", 116), {-4}}; export void *Out__init(void) { __DEFMOD; + __MODULE_IMPORT(Heap); __MODULE_IMPORT(Platform); __REGMOD("Out", 0); __REGCMD("Flush", Out_Flush); __REGCMD("Ln", Out_Ln); __REGCMD("Open", Out_Open); + __INITYP(typedesc__5, typedesc__5, 0); /* BEGIN */ Out_IsConsole = Platform_IsConsole(Platform_StdOut); Out_in = 0; diff --git a/bootstrap/windows-48/Out.h b/bootstrap/windows-48/Out.h index 1db1f1b3..0b3a93df 100644 --- a/bootstrap/windows-48/Out.h +++ b/bootstrap/windows-48/Out.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Out__h #define Out__h @@ -10,6 +10,7 @@ import BOOLEAN Out_IsConsole; import void Out_Char (CHAR ch); +import void Out_DumpType (SYSTEM_BYTE *o, ADDRESS o__len); import void Out_Flush (void); import void Out_Hex (INT64 x, INT64 n); import void Out_HexDump (SYSTEM_BYTE *m, ADDRESS m__len); diff --git a/bootstrap/windows-48/Platform.c b/bootstrap/windows-48/Platform.c index 43a2c695..661a3ff4 100644 --- a/bootstrap/windows-48/Platform.c +++ b/bootstrap/windows-48/Platform.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/Platform.h b/bootstrap/windows-48/Platform.h index ddc997ca..68347c6c 100644 --- a/bootstrap/windows-48/Platform.h +++ b/bootstrap/windows-48/Platform.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/windows-48/Reals.c b/bootstrap/windows-48/Reals.c index f5ee1490..0a2d220b 100644 --- a/bootstrap/windows-48/Reals.c +++ b/bootstrap/windows-48/Reals.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/Reals.h b/bootstrap/windows-48/Reals.h index 6d0ec38b..0c564f0e 100644 --- a/bootstrap/windows-48/Reals.h +++ b/bootstrap/windows-48/Reals.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/windows-48/Strings.c b/bootstrap/windows-48/Strings.c index 4ee2fc23..ed806db0 100644 --- a/bootstrap/windows-48/Strings.c +++ b/bootstrap/windows-48/Strings.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/Strings.h b/bootstrap/windows-48/Strings.h index ae281477..93b62826 100644 --- a/bootstrap/windows-48/Strings.h +++ b/bootstrap/windows-48/Strings.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/windows-48/Texts.c b/bootstrap/windows-48/Texts.c index 4825ab70..a91fe173 100644 --- a/bootstrap/windows-48/Texts.c +++ b/bootstrap/windows-48/Texts.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -390,6 +390,7 @@ void Texts_DumpReader (Texts_Reader re) Texts_DumpRun(re.run); } } + Out_DumpType((void*)&*re.run, 20); } static Texts_FontsFont Texts_FontsThis (CHAR *name, ADDRESS name__len) @@ -1566,8 +1567,8 @@ static void LoadElem__22 (Files_Rider *r, ADDRESS *r__typ, INT32 pos, INT32 span static void LoadElem__22 (Files_Rider *r, ADDRESS *r__typ, INT32 pos, INT32 span, Texts_Elem *e) { - Modules_Module M = NIL; - Modules_Command Cmd; + Heap_Module M = NIL; + Heap_Command Cmd; Texts_Alien a = NIL; INT32 org, ew, eh; INT8 eno; diff --git a/bootstrap/windows-48/Texts.h b/bootstrap/windows-48/Texts.h index c7c8d20f..24dacf51 100644 --- a/bootstrap/windows-48/Texts.h +++ b/bootstrap/windows-48/Texts.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/windows-48/VT100.c b/bootstrap/windows-48/VT100.c index 9ab993c9..ed38e4dc 100644 --- a/bootstrap/windows-48/VT100.c +++ b/bootstrap/windows-48/VT100.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/VT100.h b/bootstrap/windows-48/VT100.h index 3de3605c..69601701 100644 --- a/bootstrap/windows-48/VT100.h +++ b/bootstrap/windows-48/VT100.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef VT100__h #define VT100__h diff --git a/bootstrap/windows-48/extTools.c b/bootstrap/windows-48/extTools.c index 213abf27..0b3a981e 100644 --- a/bootstrap/windows-48/extTools.c +++ b/bootstrap/windows-48/extTools.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/extTools.h b/bootstrap/windows-48/extTools.h index 4278a34c..36571c99 100644 --- a/bootstrap/windows-48/extTools.h +++ b/bootstrap/windows-48/extTools.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef extTools__h #define extTools__h diff --git a/bootstrap/windows-88/Compiler.c b/bootstrap/windows-88/Compiler.c index ffd8b03e..65da2216 100644 --- a/bootstrap/windows-88/Compiler.c +++ b/bootstrap/windows-88/Compiler.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspamS */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspamS */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/Configuration.c b/bootstrap/windows-88/Configuration.c index 6db13d09..77782293 100644 --- a/bootstrap/windows-88/Configuration.c +++ b/bootstrap/windows-88/Configuration.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -19,6 +19,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); + __MOVE("2.00 [2016/12/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 4259cfef..438fec28 100644 --- a/bootstrap/windows-88/Configuration.h +++ b/bootstrap/windows-88/Configuration.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Configuration__h #define Configuration__h diff --git a/bootstrap/windows-88/Files.c b/bootstrap/windows-88/Files.c index fc649cf8..1c505c07 100644 --- a/bootstrap/windows-88/Files.c +++ b/bootstrap/windows-88/Files.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/Files.h b/bootstrap/windows-88/Files.h index 49df83be..337b30b5 100644 --- a/bootstrap/windows-88/Files.h +++ b/bootstrap/windows-88/Files.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/windows-88/Heap.c b/bootstrap/windows-88/Heap.c index 4554feac..3e929c3a 100644 --- a/bootstrap/windows-88/Heap.c +++ b/bootstrap/windows-88/Heap.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -84,6 +84,7 @@ static void Heap_CheckFin (void); static void Heap_ExtendHeap (INT64 blksz); export void Heap_FINALL (void); static void Heap_Finalize (void); +export INT32 Heap_FreeModule (CHAR *name, ADDRESS name__len); export void Heap_GC (BOOLEAN markStack); static void Heap_HeapSort (INT64 n, INT64 *a, ADDRESS a__len); export void Heap_INCREF (Heap_Module m); @@ -143,6 +144,35 @@ SYSTEM_PTR Heap_REGMOD (Heap_ModuleName name, Heap_EnumProc enumPtrs) return (void*)m; } +INT32 Heap_FreeModule (CHAR *name, ADDRESS name__len) +{ + Heap_Module m, p; + __DUP(name, name__len, CHAR); + m = (Heap_Module)(ADDRESS)Heap_modules; + while ((m != NIL && __STRCMP(m->name, name) != 0)) { + p = m; + m = m->next; + } + if ((m != NIL && m->refcnt == 0)) { + if (m == (Heap_Module)(ADDRESS)Heap_modules) { + Heap_modules = (SYSTEM_PTR)m->next; + } else { + p->next = m->next; + } + __DEL(name); + return 0; + } else { + if (m == NIL) { + __DEL(name); + return -1; + } else { + __DEL(name); + return m->refcnt; + } + } + __RETCHK; +} + void Heap_REGCMD (Heap_Module m, Heap_CmdName name, Heap_Command cmd) { Heap_Cmd c; diff --git a/bootstrap/windows-88/Heap.h b/bootstrap/windows-88/Heap.h index 0fb80f05..b2018428 100644 --- a/bootstrap/windows-88/Heap.h +++ b/bootstrap/windows-88/Heap.h @@ -1,16 +1,26 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ #ifndef Heap__h #define Heap__h #include "SYSTEM.h" +typedef + struct Heap_CmdDesc *Heap_Cmd; + typedef CHAR Heap_CmdName[24]; typedef void (*Heap_Command)(void); +typedef + struct Heap_CmdDesc { + Heap_Cmd next; + Heap_CmdName name; + Heap_Command cmd; + } Heap_CmdDesc; + typedef void (*Heap_EnumProc)(void(*)(SYSTEM_PTR)); @@ -21,13 +31,18 @@ typedef struct Heap_ModuleDesc *Heap_Module; typedef - struct Heap_ModuleDesc { - INT64 _prvt0; - char _prvt1[56]; - } Heap_ModuleDesc; + CHAR Heap_ModuleName[20]; typedef - CHAR Heap_ModuleName[20]; + struct Heap_ModuleDesc { + Heap_Module next; + Heap_ModuleName name; + INT32 refcnt; + Heap_Cmd cmds; + INT64 types; + Heap_EnumProc enumPtrs; + char _prvt0[8]; + } Heap_ModuleDesc; import SYSTEM_PTR Heap_modules; @@ -35,8 +50,10 @@ import INT64 Heap_allocated, Heap_heapsize; import INT16 Heap_FileCount; import ADDRESS *Heap_ModuleDesc__typ; +import ADDRESS *Heap_CmdDesc__typ; import void Heap_FINALL (void); +import INT32 Heap_FreeModule (CHAR *name, ADDRESS name__len); import void Heap_GC (BOOLEAN markStack); import void Heap_INCREF (Heap_Module m); import void Heap_InitHeap (void); diff --git a/bootstrap/windows-88/Modules.c b/bootstrap/windows-88/Modules.c index 37cfa0cd..6e92bf1e 100644 --- a/bootstrap/windows-88/Modules.c +++ b/bootstrap/windows-88/Modules.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -9,47 +9,15 @@ #include "Heap.h" #include "Platform.h" -typedef - struct Modules_CmdDesc *Modules_Cmd; - -typedef - void (*Modules_Command)(void); - -typedef - struct Modules_CmdDesc { - Modules_Cmd next; - CHAR name[24]; - Modules_Command cmd; - } Modules_CmdDesc; - -typedef - struct Modules_ModuleDesc *Modules_Module; - -typedef - CHAR Modules_ModuleName[20]; - -typedef - struct Modules_ModuleDesc { - Modules_Module next; - Modules_ModuleName name; - INT32 refcnt; - Modules_Cmd cmds; - INT32 types; - void (*enumPtrs)(void(*)(INT32)); - INT32 reserved1, reserved2; - } Modules_ModuleDesc; - export INT16 Modules_res; export CHAR Modules_resMsg[256]; -export Modules_ModuleName Modules_imported, Modules_importing; +export Heap_ModuleName Modules_imported, Modules_importing; export INT64 Modules_MainStackFrame; export INT16 Modules_ArgCount; export INT64 Modules_ArgVector; export CHAR Modules_BinaryDir[1024]; -export ADDRESS *Modules_ModuleDesc__typ; -export ADDRESS *Modules_CmdDesc__typ; static void Modules_Append (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len); static void Modules_AppendPart (CHAR c, CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len); @@ -68,8 +36,8 @@ export void Modules_Init (INT32 argc, INT64 argvadr); static BOOLEAN Modules_IsAbsolute (CHAR *d, ADDRESS d__len); static BOOLEAN Modules_IsFilePresent (CHAR *s, ADDRESS s__len); static BOOLEAN Modules_IsOneOf (CHAR c, CHAR *s, ADDRESS s__len); -export Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, ADDRESS name__len); -export Modules_Module Modules_ThisMod (CHAR *name, ADDRESS name__len); +export Heap_Command Modules_ThisCommand (Heap_Module mod, CHAR *name, ADDRESS name__len); +export Heap_Module Modules_ThisMod (CHAR *name, ADDRESS name__len); static void Modules_Trim (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len); static void Modules_errch (CHAR c); static void Modules_errint (INT32 l); @@ -79,8 +47,7 @@ extern void Heap_InitHeap(); extern void *Modules__init(void); #define Modules_InitHeap() Heap_InitHeap() #define Modules_ModulesInit() Modules__init() -#define Modules_modules() (Modules_Module)Heap_modules -#define Modules_setmodules(m) Heap_modules = m +#define Modules_modules() (Heap_Module)Heap_modules void Modules_Init (INT32 argc, INT64 argvadr) { @@ -334,11 +301,11 @@ static void Modules_FindBinaryDir (CHAR *binarydir, ADDRESS binarydir__len) } } -Modules_Module Modules_ThisMod (CHAR *name, ADDRESS name__len) +Heap_Module Modules_ThisMod (CHAR *name, ADDRESS name__len) { - Modules_Module m = NIL; + Heap_Module m = NIL; CHAR bodyname[64]; - Modules_Command body; + Heap_Command body; __DUP(name, name__len, CHAR); m = Modules_modules(); while ((m != NIL && __STRCMP(m->name, name) != 0)) { @@ -358,9 +325,9 @@ Modules_Module Modules_ThisMod (CHAR *name, ADDRESS name__len) return m; } -Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, ADDRESS name__len) +Heap_Command Modules_ThisCommand (Heap_Module mod, CHAR *name, ADDRESS name__len) { - Modules_Cmd c = NIL; + Heap_Cmd c = NIL; __DUP(name, name__len, CHAR); c = mod->cmds; while ((c != NIL && __STRCMP(c->name, name) != 0)) { @@ -387,31 +354,24 @@ Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, ADDRESS nam void Modules_Free (CHAR *name, ADDRESS name__len, BOOLEAN all) { - Modules_Module m = NIL, p = NIL; + Heap_Module m = NIL, p = NIL; + INT32 refcount; __DUP(name, name__len, CHAR); m = Modules_modules(); if (all) { Modules_res = 1; __MOVE("unloading \"all\" not yet supported", Modules_resMsg, 34); } else { - while ((m != NIL && __STRCMP(m->name, name) != 0)) { - p = m; - m = m->next; - } - if ((m != NIL && m->refcnt == 0)) { - if (m == Modules_modules()) { - Modules_setmodules(m->next); - } else { - p->next = m->next; - } + refcount = Heap_FreeModule(name, name__len); + if (refcount == 0) { Modules_res = 0; } else { - Modules_res = 1; - if (m == NIL) { + if (refcount < 0) { __MOVE("module not found", Modules_resMsg, 17); } else { __MOVE("clients of this module exist", Modules_resMsg, 29); } + Modules_res = 1; } } __DEL(name); @@ -533,8 +493,6 @@ void Modules_AssertFail (INT32 code) } } -__TDESC(Modules_ModuleDesc, 1, 2) = {__TDFLDS("ModuleDesc", 64), {0, 32, -24}}; -__TDESC(Modules_CmdDesc, 1, 1) = {__TDFLDS("CmdDesc", 40), {0, -16}}; export void *Modules__init(void) { @@ -542,8 +500,6 @@ export void *Modules__init(void) __MODULE_IMPORT(Heap); __MODULE_IMPORT(Platform); __REGMOD("Modules", 0); - __INITYP(Modules_ModuleDesc, Modules_ModuleDesc, 0); - __INITYP(Modules_CmdDesc, Modules_CmdDesc, 0); /* BEGIN */ Modules_FindBinaryDir((void*)Modules_BinaryDir, 1024); __ENDMOD; diff --git a/bootstrap/windows-88/Modules.h b/bootstrap/windows-88/Modules.h index 3ee70401..e5803d29 100644 --- a/bootstrap/windows-88/Modules.h +++ b/bootstrap/windows-88/Modules.h @@ -1,51 +1,20 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Modules__h #define Modules__h #include "SYSTEM.h" - -typedef - struct Modules_CmdDesc *Modules_Cmd; - -typedef - void (*Modules_Command)(void); - -typedef - struct Modules_CmdDesc { - Modules_Cmd next; - CHAR name[24]; - Modules_Command cmd; - } Modules_CmdDesc; - -typedef - struct Modules_ModuleDesc *Modules_Module; - -typedef - CHAR Modules_ModuleName[20]; - -typedef - struct Modules_ModuleDesc { - Modules_Module next; - Modules_ModuleName name; - INT32 refcnt; - Modules_Cmd cmds; - INT32 types; - void (*enumPtrs)(void(*)(INT32)); - char _prvt0[8]; - } Modules_ModuleDesc; +#include "Heap.h" import INT16 Modules_res; import CHAR Modules_resMsg[256]; -import Modules_ModuleName Modules_imported, Modules_importing; +import Heap_ModuleName Modules_imported, Modules_importing; import INT64 Modules_MainStackFrame; import INT16 Modules_ArgCount; import INT64 Modules_ArgVector; import CHAR Modules_BinaryDir[1024]; -import ADDRESS *Modules_ModuleDesc__typ; -import ADDRESS *Modules_CmdDesc__typ; import INT16 Modules_ArgPos (CHAR *s, ADDRESS s__len); import void Modules_AssertFail (INT32 code); @@ -54,8 +23,8 @@ import void Modules_GetArg (INT16 n, CHAR *val, ADDRESS val__len); import void Modules_GetIntArg (INT16 n, INT32 *val); import void Modules_Halt (INT32 code); import void Modules_Init (INT32 argc, INT64 argvadr); -import Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, ADDRESS name__len); -import Modules_Module Modules_ThisMod (CHAR *name, ADDRESS name__len); +import Heap_Command Modules_ThisCommand (Heap_Module mod, CHAR *name, ADDRESS name__len); +import Heap_Module Modules_ThisMod (CHAR *name, ADDRESS name__len); import void *Modules__init(void); diff --git a/bootstrap/windows-88/OPB.c b/bootstrap/windows-88/OPB.c index d83386eb..7e558357 100644 --- a/bootstrap/windows-88/OPB.c +++ b/bootstrap/windows-88/OPB.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/OPB.h b/bootstrap/windows-88/OPB.h index feb85d73..b6d457bd 100644 --- a/bootstrap/windows-88/OPB.h +++ b/bootstrap/windows-88/OPB.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPB__h #define OPB__h diff --git a/bootstrap/windows-88/OPC.c b/bootstrap/windows-88/OPC.c index ab01642c..c09d2e6a 100644 --- a/bootstrap/windows-88/OPC.c +++ b/bootstrap/windows-88/OPC.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/OPC.h b/bootstrap/windows-88/OPC.h index f742f265..7c47ed18 100644 --- a/bootstrap/windows-88/OPC.h +++ b/bootstrap/windows-88/OPC.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPC__h #define OPC__h diff --git a/bootstrap/windows-88/OPM.c b/bootstrap/windows-88/OPM.c index 1335c494..e3e6f1fe 100644 --- a/bootstrap/windows-88/OPM.c +++ b/bootstrap/windows-88/OPM.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/OPM.h b/bootstrap/windows-88/OPM.h index 621dfb51..6d2755d8 100644 --- a/bootstrap/windows-88/OPM.h +++ b/bootstrap/windows-88/OPM.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPM__h #define OPM__h diff --git a/bootstrap/windows-88/OPP.c b/bootstrap/windows-88/OPP.c index 3f9dfde3..dc87be62 100644 --- a/bootstrap/windows-88/OPP.c +++ b/bootstrap/windows-88/OPP.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/OPP.h b/bootstrap/windows-88/OPP.h index c1fe21fb..c13a4e91 100644 --- a/bootstrap/windows-88/OPP.h +++ b/bootstrap/windows-88/OPP.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/windows-88/OPS.c b/bootstrap/windows-88/OPS.c index 4569c80d..ed3ea3a1 100644 --- a/bootstrap/windows-88/OPS.c +++ b/bootstrap/windows-88/OPS.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/OPS.h b/bootstrap/windows-88/OPS.h index c0707c34..6dae098c 100644 --- a/bootstrap/windows-88/OPS.h +++ b/bootstrap/windows-88/OPS.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/windows-88/OPT.c b/bootstrap/windows-88/OPT.c index 07f8f535..25e2e7c2 100644 --- a/bootstrap/windows-88/OPT.c +++ b/bootstrap/windows-88/OPT.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/OPT.h b/bootstrap/windows-88/OPT.h index 6b2b0929..00094b66 100644 --- a/bootstrap/windows-88/OPT.h +++ b/bootstrap/windows-88/OPT.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPT__h #define OPT__h diff --git a/bootstrap/windows-88/OPV.c b/bootstrap/windows-88/OPV.c index 4506267a..c88953f2 100644 --- a/bootstrap/windows-88/OPV.c +++ b/bootstrap/windows-88/OPV.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/OPV.h b/bootstrap/windows-88/OPV.h index d363f022..f83e65fb 100644 --- a/bootstrap/windows-88/OPV.h +++ b/bootstrap/windows-88/OPV.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPV__h #define OPV__h diff --git a/bootstrap/windows-88/Out.c b/bootstrap/windows-88/Out.c index 66c81d4e..cbf124ca 100644 --- a/bootstrap/windows-88/Out.c +++ b/bootstrap/windows-88/Out.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -6,6 +6,7 @@ #define SET UINT32 #include "SYSTEM.h" +#include "Heap.h" #include "Platform.h" @@ -13,8 +14,11 @@ export BOOLEAN Out_IsConsole; static CHAR Out_buf[128]; static INT16 Out_in; +static ADDRESS *typedesc__5__typ; export void Out_Char (CHAR ch); +static void Out_DumpModule (Heap_Module m); +export void Out_DumpType (SYSTEM_BYTE *o, ADDRESS o__len); export void Out_Flush (void); export void Out_Hex (INT64 x, INT64 n); export void Out_HexDump (SYSTEM_BYTE *m, ADDRESS m__len); @@ -203,6 +207,94 @@ void Out_HexDump (SYSTEM_BYTE *m, ADDRESS m__len) Out_HexDumpAdr((ADDRESS)m, 0, m__len); } +static void Out_DumpModule (Heap_Module m) +{ + Out_String((CHAR*)" next: ", 13); + Out_Hex((INT64)(ADDRESS)m->next, 1); + Out_Ln(); + Out_String((CHAR*)" name: ", 13); + Out_String(m->name, 20); + Out_Ln(); + Out_String((CHAR*)" refcnt: ", 13); + Out_Hex(m->refcnt, 1); + Out_Ln(); + Out_String((CHAR*)" cmds: ", 13); + Out_Hex((INT64)(ADDRESS)m->cmds, 1); + Out_Ln(); + Out_String((CHAR*)" types: ", 13); + Out_Hex(m->types, 1); + Out_Ln(); + Out_String((CHAR*)" enumPtrs: ", 13); + Out_Hex((INT64)(ADDRESS)m->enumPtrs, 1); + Out_Ln(); +} + +typedef + struct typedesc__5 *tag__4; + +typedef + struct typedesc__5 { + INT64 tag, next, level, module; + CHAR name[24]; + INT64 bases[16]; + INT64 reserved, blksz, ptr0; + } typedesc__5; + +void Out_DumpType (SYSTEM_BYTE *o, ADDRESS o__len) +{ + INT64 addr; + tag__4 desc = NIL; + INT16 i; + __GET((ADDRESS)o - 8, addr, INT64); + Out_String((CHAR*)"obj tag: ", 11); + Out_Hex(addr, 1); + Out_Ln(); + desc = (tag__4)(ADDRESS)(addr - 192); + Out_String((CHAR*)"desc at: ", 11); + Out_Hex((INT64)(ADDRESS)desc, 1); + Out_Ln(); + Out_String((CHAR*)"desc contains:", 15); + Out_Ln(); + Out_String((CHAR*)"tag: ", 11); + Out_Hex(desc->tag, 1); + Out_Ln(); + Out_String((CHAR*)"next: ", 11); + Out_Hex(desc->next, 1); + Out_Ln(); + Out_String((CHAR*)"level: ", 11); + Out_Hex(desc->level, 1); + Out_Ln(); + Out_String((CHAR*)"module: ", 11); + Out_Hex(desc->module, 1); + Out_Ln(); + Out_DumpModule((Heap_Module)(ADDRESS)desc->module); + Out_String((CHAR*)"name: ", 11); + Out_String(desc->name, 24); + Out_Ln(); + Out_String((CHAR*)"bases: ", 11); + i = 0; + while (i < 16) { + Out_Hex(desc->bases[__X(i, 16)], 16); + if (__MASK(i, -4) == 3) { + Out_Ln(); + Out_String((CHAR*)" ", 11); + } else { + Out_Char(' '); + } + i += 1; + } + Out_Ln(); + Out_String((CHAR*)"reserved: ", 11); + Out_Hex(desc->reserved, 1); + Out_Ln(); + Out_String((CHAR*)"blksz: ", 11); + Out_Hex(desc->blksz, 1); + Out_Ln(); + Out_String((CHAR*)"ptr0: ", 11); + Out_Hex(desc->ptr0, 1); + Out_Ln(); +} + static void Out_digit (INT64 n, CHAR *s, ADDRESS s__len, INT16 *i) { *i -= 1; @@ -380,15 +472,18 @@ void Out_LongReal (LONGREAL x, INT16 n) Out_RealP(x, n, 1); } +__TDESC(typedesc__5, 1, 0) = {__TDFLDS("typedesc__5", 208), {-8}}; export void *Out__init(void) { __DEFMOD; + __MODULE_IMPORT(Heap); __MODULE_IMPORT(Platform); __REGMOD("Out", 0); __REGCMD("Flush", Out_Flush); __REGCMD("Ln", Out_Ln); __REGCMD("Open", Out_Open); + __INITYP(typedesc__5, typedesc__5, 0); /* BEGIN */ Out_IsConsole = Platform_IsConsole(Platform_StdOut); Out_in = 0; diff --git a/bootstrap/windows-88/Out.h b/bootstrap/windows-88/Out.h index 24829244..0126ef62 100644 --- a/bootstrap/windows-88/Out.h +++ b/bootstrap/windows-88/Out.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Out__h #define Out__h @@ -10,6 +10,7 @@ import BOOLEAN Out_IsConsole; import void Out_Char (CHAR ch); +import void Out_DumpType (SYSTEM_BYTE *o, ADDRESS o__len); import void Out_Flush (void); import void Out_Hex (INT64 x, INT64 n); import void Out_HexDump (SYSTEM_BYTE *m, ADDRESS m__len); diff --git a/bootstrap/windows-88/Platform.c b/bootstrap/windows-88/Platform.c index 44691d4d..59a4d3a4 100644 --- a/bootstrap/windows-88/Platform.c +++ b/bootstrap/windows-88/Platform.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/Platform.h b/bootstrap/windows-88/Platform.h index 751980ad..787e2dc2 100644 --- a/bootstrap/windows-88/Platform.h +++ b/bootstrap/windows-88/Platform.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/windows-88/Reals.c b/bootstrap/windows-88/Reals.c index f5ee1490..0a2d220b 100644 --- a/bootstrap/windows-88/Reals.c +++ b/bootstrap/windows-88/Reals.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/Reals.h b/bootstrap/windows-88/Reals.h index 6d0ec38b..0c564f0e 100644 --- a/bootstrap/windows-88/Reals.h +++ b/bootstrap/windows-88/Reals.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/windows-88/Strings.c b/bootstrap/windows-88/Strings.c index 4ee2fc23..ed806db0 100644 --- a/bootstrap/windows-88/Strings.c +++ b/bootstrap/windows-88/Strings.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/Strings.h b/bootstrap/windows-88/Strings.h index ae281477..93b62826 100644 --- a/bootstrap/windows-88/Strings.h +++ b/bootstrap/windows-88/Strings.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/windows-88/Texts.c b/bootstrap/windows-88/Texts.c index 9887162e..bd19d27b 100644 --- a/bootstrap/windows-88/Texts.c +++ b/bootstrap/windows-88/Texts.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -390,6 +390,7 @@ void Texts_DumpReader (Texts_Reader re) Texts_DumpRun(re.run); } } + Out_DumpType((void*)&*re.run, 40); } static Texts_FontsFont Texts_FontsThis (CHAR *name, ADDRESS name__len) @@ -1566,8 +1567,8 @@ static void LoadElem__22 (Files_Rider *r, ADDRESS *r__typ, INT32 pos, INT32 span static void LoadElem__22 (Files_Rider *r, ADDRESS *r__typ, INT32 pos, INT32 span, Texts_Elem *e) { - Modules_Module M = NIL; - Modules_Command Cmd; + Heap_Module M = NIL; + Heap_Command Cmd; Texts_Alien a = NIL; INT32 org, ew, eh; INT8 eno; diff --git a/bootstrap/windows-88/Texts.h b/bootstrap/windows-88/Texts.h index e14afb26..2cf87339 100644 --- a/bootstrap/windows-88/Texts.h +++ b/bootstrap/windows-88/Texts.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/windows-88/VT100.c b/bootstrap/windows-88/VT100.c index 9ab993c9..ed38e4dc 100644 --- a/bootstrap/windows-88/VT100.c +++ b/bootstrap/windows-88/VT100.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/VT100.h b/bootstrap/windows-88/VT100.h index 3de3605c..69601701 100644 --- a/bootstrap/windows-88/VT100.h +++ b/bootstrap/windows-88/VT100.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef VT100__h #define VT100__h diff --git a/bootstrap/windows-88/extTools.c b/bootstrap/windows-88/extTools.c index 213abf27..0b3a981e 100644 --- a/bootstrap/windows-88/extTools.c +++ b/bootstrap/windows-88/extTools.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/extTools.h b/bootstrap/windows-88/extTools.h index 4278a34c..36571c99 100644 --- a/bootstrap/windows-88/extTools.h +++ b/bootstrap/windows-88/extTools.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/12]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef extTools__h #define extTools__h