mirror of
https://github.com/vishapoberon/compiler.git
synced 2026-04-05 23:22:25 +00:00
Add bootstrap and master make files.
This commit is contained in:
parent
be80ad7ae3
commit
43c5f44c10
212 changed files with 97056 additions and 0 deletions
16
bootstrap/unix-44/Configuration.c
Normal file
16
bootstrap/unix-44/Configuration.c
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
#include "SYSTEM.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export void *Configuration__init(void)
|
||||
{
|
||||
__DEFMOD;
|
||||
__REGMOD("Configuration", 0);
|
||||
/* BEGIN */
|
||||
__ENDMOD;
|
||||
}
|
||||
14
bootstrap/unix-44/Configuration.h
Normal file
14
bootstrap/unix-44/Configuration.h
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#ifndef Configuration__h
|
||||
#define Configuration__h
|
||||
|
||||
#include "SYSTEM.h"
|
||||
|
||||
|
||||
|
||||
|
||||
import void *Configuration__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
150
bootstrap/unix-44/Console.c
Normal file
150
bootstrap/unix-44/Console.c
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
#include "SYSTEM.h"
|
||||
#include "Platform.h"
|
||||
|
||||
|
||||
static CHAR Console_line[128];
|
||||
static INTEGER Console_pos;
|
||||
|
||||
|
||||
export void Console_Bool (BOOLEAN b);
|
||||
export void Console_Char (CHAR ch);
|
||||
export void Console_Flush (void);
|
||||
export void Console_Hex (LONGINT i);
|
||||
export void Console_Int (LONGINT i, LONGINT n);
|
||||
export void Console_Ln (void);
|
||||
export void Console_Read (CHAR *ch);
|
||||
export void Console_ReadLine (CHAR *line, LONGINT line__len);
|
||||
export void Console_String (CHAR *s, LONGINT s__len);
|
||||
|
||||
|
||||
void Console_Flush (void)
|
||||
{
|
||||
INTEGER error;
|
||||
error = Platform_Write(((LONGINT)(1)), (LONGINT)(uintptr_t)Console_line, Console_pos);
|
||||
Console_pos = 0;
|
||||
}
|
||||
|
||||
void Console_Char (CHAR ch)
|
||||
{
|
||||
if (Console_pos == 128) {
|
||||
Console_Flush();
|
||||
}
|
||||
Console_line[__X(Console_pos, ((LONGINT)(128)))] = ch;
|
||||
Console_pos += 1;
|
||||
if (ch == 0x0a) {
|
||||
Console_Flush();
|
||||
}
|
||||
}
|
||||
|
||||
void Console_String (CHAR *s, LONGINT s__len)
|
||||
{
|
||||
INTEGER i;
|
||||
__DUP(s, s__len, CHAR);
|
||||
i = 0;
|
||||
while (s[__X(i, s__len)] != 0x00) {
|
||||
Console_Char(s[__X(i, s__len)]);
|
||||
i += 1;
|
||||
}
|
||||
__DEL(s);
|
||||
}
|
||||
|
||||
void Console_Int (LONGINT i, LONGINT n)
|
||||
{
|
||||
CHAR s[32];
|
||||
LONGINT i1, k;
|
||||
if (i == __LSHL(1, 31, LONGINT)) {
|
||||
__MOVE("8463847412", s, 11);
|
||||
k = 10;
|
||||
} else {
|
||||
i1 = __ABS(i);
|
||||
s[0] = (CHAR)(__MOD(i1, 10) + 48);
|
||||
i1 = __DIV(i1, 10);
|
||||
k = 1;
|
||||
while (i1 > 0) {
|
||||
s[__X(k, ((LONGINT)(32)))] = (CHAR)(__MOD(i1, 10) + 48);
|
||||
i1 = __DIV(i1, 10);
|
||||
k += 1;
|
||||
}
|
||||
}
|
||||
if (i < 0) {
|
||||
s[__X(k, ((LONGINT)(32)))] = '-';
|
||||
k += 1;
|
||||
}
|
||||
while (n > k) {
|
||||
Console_Char(' ');
|
||||
n -= 1;
|
||||
}
|
||||
while (k > 0) {
|
||||
k -= 1;
|
||||
Console_Char(s[__X(k, ((LONGINT)(32)))]);
|
||||
}
|
||||
}
|
||||
|
||||
void Console_Ln (void)
|
||||
{
|
||||
Console_Char(0x0a);
|
||||
}
|
||||
|
||||
void Console_Bool (BOOLEAN b)
|
||||
{
|
||||
if (b) {
|
||||
Console_String((CHAR*)"TRUE", (LONGINT)5);
|
||||
} else {
|
||||
Console_String((CHAR*)"FALSE", (LONGINT)6);
|
||||
}
|
||||
}
|
||||
|
||||
void Console_Hex (LONGINT i)
|
||||
{
|
||||
LONGINT k, n;
|
||||
k = -28;
|
||||
while (k <= 0) {
|
||||
n = __MASK(__ASH(i, k), -16);
|
||||
if (n <= 9) {
|
||||
Console_Char((CHAR)(48 + n));
|
||||
} else {
|
||||
Console_Char((CHAR)(55 + n));
|
||||
}
|
||||
k += 4;
|
||||
}
|
||||
}
|
||||
|
||||
void Console_Read (CHAR *ch)
|
||||
{
|
||||
LONGINT n;
|
||||
INTEGER error;
|
||||
Console_Flush();
|
||||
error = Platform_ReadBuf(((LONGINT)(0)), (void*)&*ch, ((LONGINT)(1)), &n);
|
||||
if (n != 1) {
|
||||
*ch = 0x00;
|
||||
}
|
||||
}
|
||||
|
||||
void Console_ReadLine (CHAR *line, LONGINT line__len)
|
||||
{
|
||||
LONGINT i;
|
||||
CHAR ch;
|
||||
Console_Flush();
|
||||
i = 0;
|
||||
Console_Read(&ch);
|
||||
while ((((i < line__len - 1 && ch != 0x0a)) && ch != 0x00)) {
|
||||
line[__X(i, line__len)] = ch;
|
||||
i += 1;
|
||||
Console_Read(&ch);
|
||||
}
|
||||
line[__X(i, line__len)] = 0x00;
|
||||
}
|
||||
|
||||
|
||||
export void *Console__init(void)
|
||||
{
|
||||
__DEFMOD;
|
||||
__MODULE_IMPORT(Platform);
|
||||
__REGMOD("Console", 0);
|
||||
__REGCMD("Flush", Console_Flush);
|
||||
__REGCMD("Ln", Console_Ln);
|
||||
/* BEGIN */
|
||||
Console_pos = 0;
|
||||
__ENDMOD;
|
||||
}
|
||||
23
bootstrap/unix-44/Console.h
Normal file
23
bootstrap/unix-44/Console.h
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#ifndef Console__h
|
||||
#define Console__h
|
||||
|
||||
#include "SYSTEM.h"
|
||||
|
||||
|
||||
|
||||
|
||||
import void Console_Bool (BOOLEAN b);
|
||||
import void Console_Char (CHAR ch);
|
||||
import void Console_Flush (void);
|
||||
import void Console_Hex (LONGINT i);
|
||||
import void Console_Int (LONGINT i, LONGINT n);
|
||||
import void Console_Ln (void);
|
||||
import void Console_Read (CHAR *ch);
|
||||
import void Console_ReadLine (CHAR *line, LONGINT line__len);
|
||||
import void Console_String (CHAR *s, LONGINT s__len);
|
||||
import void *Console__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
1078
bootstrap/unix-44/Files.c
Normal file
1078
bootstrap/unix-44/Files.c
Normal file
File diff suppressed because it is too large
Load diff
70
bootstrap/unix-44/Files.h
Normal file
70
bootstrap/unix-44/Files.h
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin tspkaSfF */
|
||||
|
||||
#ifndef Files__h
|
||||
#define Files__h
|
||||
|
||||
#include "SYSTEM.h"
|
||||
|
||||
typedef
|
||||
struct Files_Handle *Files_File;
|
||||
|
||||
typedef
|
||||
struct Files_Handle {
|
||||
char _prvt0[216];
|
||||
LONGINT fd;
|
||||
char _prvt1[28];
|
||||
} Files_Handle;
|
||||
|
||||
typedef
|
||||
struct Files_Rider {
|
||||
LONGINT res;
|
||||
BOOLEAN eof;
|
||||
char _prvt0[15];
|
||||
} Files_Rider;
|
||||
|
||||
|
||||
|
||||
import LONGINT *Files_Handle__typ;
|
||||
import LONGINT *Files_Rider__typ;
|
||||
|
||||
import Files_File Files_Base (Files_Rider *r, LONGINT *r__typ);
|
||||
import void Files_ChangeDirectory (CHAR *path, LONGINT path__len, INTEGER *res);
|
||||
import void Files_Close (Files_File f);
|
||||
import void Files_Delete (CHAR *name, LONGINT name__len, INTEGER *res);
|
||||
import void Files_GetDate (Files_File f, LONGINT *t, LONGINT *d);
|
||||
import void Files_GetName (Files_File f, CHAR *name, LONGINT name__len);
|
||||
import LONGINT Files_Length (Files_File f);
|
||||
import Files_File Files_New (CHAR *name, LONGINT name__len);
|
||||
import Files_File Files_Old (CHAR *name, LONGINT name__len);
|
||||
import LONGINT Files_Pos (Files_Rider *r, LONGINT *r__typ);
|
||||
import void Files_Purge (Files_File f);
|
||||
import void Files_Read (Files_Rider *r, LONGINT *r__typ, SYSTEM_BYTE *x);
|
||||
import void Files_ReadBool (Files_Rider *R, LONGINT *R__typ, BOOLEAN *x);
|
||||
import void Files_ReadByte (Files_Rider *r, LONGINT *r__typ, SYSTEM_BYTE *x, LONGINT x__len);
|
||||
import void Files_ReadBytes (Files_Rider *r, LONGINT *r__typ, SYSTEM_BYTE *x, LONGINT x__len, LONGINT n);
|
||||
import void Files_ReadInt (Files_Rider *R, LONGINT *R__typ, INTEGER *x);
|
||||
import void Files_ReadLInt (Files_Rider *R, LONGINT *R__typ, LONGINT *x);
|
||||
import void Files_ReadLReal (Files_Rider *R, LONGINT *R__typ, LONGREAL *x);
|
||||
import void Files_ReadLine (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len);
|
||||
import void Files_ReadNum (Files_Rider *R, LONGINT *R__typ, LONGINT *x);
|
||||
import void Files_ReadReal (Files_Rider *R, LONGINT *R__typ, REAL *x);
|
||||
import void Files_ReadSet (Files_Rider *R, LONGINT *R__typ, SET *x);
|
||||
import void Files_ReadString (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len);
|
||||
import void Files_Register (Files_File f);
|
||||
import void Files_Rename (CHAR *old, LONGINT old__len, CHAR *new, LONGINT new__len, INTEGER *res);
|
||||
import void Files_Set (Files_Rider *r, LONGINT *r__typ, Files_File f, LONGINT pos);
|
||||
import void Files_SetSearchPath (CHAR *path, LONGINT path__len);
|
||||
import void Files_Write (Files_Rider *r, LONGINT *r__typ, SYSTEM_BYTE x);
|
||||
import void Files_WriteBool (Files_Rider *R, LONGINT *R__typ, BOOLEAN x);
|
||||
import void Files_WriteBytes (Files_Rider *r, LONGINT *r__typ, SYSTEM_BYTE *x, LONGINT x__len, LONGINT n);
|
||||
import void Files_WriteInt (Files_Rider *R, LONGINT *R__typ, INTEGER x);
|
||||
import void Files_WriteLInt (Files_Rider *R, LONGINT *R__typ, LONGINT x);
|
||||
import void Files_WriteLReal (Files_Rider *R, LONGINT *R__typ, LONGREAL x);
|
||||
import void Files_WriteNum (Files_Rider *R, LONGINT *R__typ, LONGINT x);
|
||||
import void Files_WriteReal (Files_Rider *R, LONGINT *R__typ, REAL x);
|
||||
import void Files_WriteSet (Files_Rider *R, LONGINT *R__typ, SET x);
|
||||
import void Files_WriteString (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len);
|
||||
import void *Files__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
752
bootstrap/unix-44/Heap.c
Normal file
752
bootstrap/unix-44/Heap.c
Normal file
|
|
@ -0,0 +1,752 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin tskSfF */
|
||||
#include "SYSTEM.h"
|
||||
|
||||
struct Heap__1 {
|
||||
CHAR ch;
|
||||
SYSTEM_PTR p;
|
||||
};
|
||||
|
||||
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));
|
||||
|
||||
typedef
|
||||
struct Heap_FinDesc *Heap_FinNode;
|
||||
|
||||
typedef
|
||||
void (*Heap_Finalizer)(SYSTEM_PTR);
|
||||
|
||||
typedef
|
||||
struct Heap_FinDesc {
|
||||
Heap_FinNode next;
|
||||
LONGINT obj;
|
||||
BOOLEAN marked;
|
||||
Heap_Finalizer finalize;
|
||||
} Heap_FinDesc;
|
||||
|
||||
typedef
|
||||
struct Heap_ModuleDesc *Heap_Module;
|
||||
|
||||
typedef
|
||||
CHAR Heap_ModuleName[20];
|
||||
|
||||
typedef
|
||||
struct Heap_ModuleDesc {
|
||||
Heap_Module next;
|
||||
Heap_ModuleName name;
|
||||
LONGINT refcnt;
|
||||
Heap_Cmd cmds;
|
||||
LONGINT types;
|
||||
Heap_EnumProc enumPtrs;
|
||||
LONGINT reserved1, reserved2;
|
||||
} Heap_ModuleDesc;
|
||||
|
||||
|
||||
export SYSTEM_PTR Heap_modules;
|
||||
static LONGINT Heap_freeList[10];
|
||||
static LONGINT Heap_bigBlocks;
|
||||
export LONGINT Heap_allocated;
|
||||
static BOOLEAN Heap_firstTry;
|
||||
static LONGINT Heap_heap, Heap_heapend;
|
||||
export LONGINT Heap_heapsize;
|
||||
static Heap_FinNode Heap_fin;
|
||||
static INTEGER Heap_lockdepth;
|
||||
static BOOLEAN Heap_interrupted;
|
||||
export INTEGER Heap_FileCount;
|
||||
|
||||
export LONGINT *Heap_ModuleDesc__typ;
|
||||
export LONGINT *Heap_CmdDesc__typ;
|
||||
export LONGINT *Heap_FinDesc__typ;
|
||||
export LONGINT *Heap__1__typ;
|
||||
|
||||
static void Heap_CheckFin (void);
|
||||
static void Heap_ExtendHeap (LONGINT blksz);
|
||||
export void Heap_FINALL (void);
|
||||
static void Heap_Finalize (void);
|
||||
export void Heap_GC (BOOLEAN markStack);
|
||||
static void Heap_HeapSort (LONGINT n, LONGINT *a, LONGINT a__len);
|
||||
export void Heap_INCREF (Heap_Module m);
|
||||
export void Heap_InitHeap (void);
|
||||
export void Heap_Lock (void);
|
||||
static void Heap_Mark (LONGINT q);
|
||||
static void Heap_MarkCandidates (LONGINT n, LONGINT *cand, LONGINT cand__len);
|
||||
static void Heap_MarkP (SYSTEM_PTR p);
|
||||
static void Heap_MarkStack (LONGINT n, LONGINT *cand, LONGINT cand__len);
|
||||
export SYSTEM_PTR Heap_NEWBLK (LONGINT size);
|
||||
export SYSTEM_PTR Heap_NEWREC (LONGINT tag);
|
||||
static LONGINT Heap_NewChunk (LONGINT blksz);
|
||||
export void Heap_REGCMD (Heap_Module m, Heap_CmdName name, Heap_Command cmd);
|
||||
export SYSTEM_PTR Heap_REGMOD (Heap_ModuleName name, Heap_EnumProc enumPtrs);
|
||||
export void Heap_REGTYP (Heap_Module m, LONGINT typ);
|
||||
export void Heap_RegisterFinalizer (SYSTEM_PTR obj, Heap_Finalizer finalize);
|
||||
static void Heap_Scan (void);
|
||||
static void Heap_Sift (LONGINT l, LONGINT r, LONGINT *a, LONGINT a__len);
|
||||
export void Heap_Unlock (void);
|
||||
|
||||
extern void *Heap__init();
|
||||
extern LONGINT Platform_MainStackFrame;
|
||||
extern LONGINT Platform_OSAllocate(LONGINT size);
|
||||
#define Heap_FetchAddress(pointer) (LONGINT)(uintptr_t)(*((void**)((uintptr_t)pointer)))
|
||||
#define Heap_HeapModuleInit() Heap__init()
|
||||
#define Heap_OSAllocate(size) Platform_OSAllocate(size)
|
||||
#define Heap_PlatformHalt(code) Platform_Halt(code)
|
||||
#define Heap_PlatformMainStackFrame() Platform_MainStackFrame
|
||||
|
||||
void Heap_Lock (void)
|
||||
{
|
||||
Heap_lockdepth += 1;
|
||||
}
|
||||
|
||||
void Heap_Unlock (void)
|
||||
{
|
||||
Heap_lockdepth -= 1;
|
||||
if ((Heap_interrupted && Heap_lockdepth == 0)) {
|
||||
Heap_PlatformHalt(((LONGINT)(-9)));
|
||||
}
|
||||
}
|
||||
|
||||
SYSTEM_PTR Heap_REGMOD (Heap_ModuleName name, Heap_EnumProc enumPtrs)
|
||||
{
|
||||
SYSTEM_PTR _o_result;
|
||||
Heap_Module m;
|
||||
if (__STRCMP(name, "Heap") == 0) {
|
||||
__SYSNEW(m, 48);
|
||||
} else {
|
||||
__NEW(m, Heap_ModuleDesc);
|
||||
}
|
||||
m->types = 0;
|
||||
m->cmds = NIL;
|
||||
__COPY(name, m->name, ((LONGINT)(20)));
|
||||
m->refcnt = 0;
|
||||
m->enumPtrs = enumPtrs;
|
||||
m->next = (Heap_Module)(uintptr_t)Heap_modules;
|
||||
Heap_modules = (SYSTEM_PTR)m;
|
||||
_o_result = (void*)m;
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
void Heap_REGCMD (Heap_Module m, Heap_CmdName name, Heap_Command cmd)
|
||||
{
|
||||
Heap_Cmd c;
|
||||
if (__STRCMP(m->name, "Heap") == 0) {
|
||||
__SYSNEW(c, 32);
|
||||
} else {
|
||||
__NEW(c, Heap_CmdDesc);
|
||||
}
|
||||
__COPY(name, c->name, ((LONGINT)(24)));
|
||||
c->cmd = cmd;
|
||||
c->next = m->cmds;
|
||||
m->cmds = c;
|
||||
}
|
||||
|
||||
void Heap_REGTYP (Heap_Module m, LONGINT typ)
|
||||
{
|
||||
__PUT(typ, m->types, LONGINT);
|
||||
m->types = typ;
|
||||
}
|
||||
|
||||
void Heap_INCREF (Heap_Module m)
|
||||
{
|
||||
m->refcnt += 1;
|
||||
}
|
||||
|
||||
static LONGINT Heap_NewChunk (LONGINT blksz)
|
||||
{
|
||||
LONGINT _o_result;
|
||||
LONGINT chnk;
|
||||
chnk = Heap_OSAllocate(blksz + 12);
|
||||
if (chnk != 0) {
|
||||
__PUT(chnk + 4, chnk + (12 + blksz), LONGINT);
|
||||
__PUT(chnk + 12, chnk + 16, LONGINT);
|
||||
__PUT(chnk + 16, blksz, LONGINT);
|
||||
__PUT(chnk + 20, -4, LONGINT);
|
||||
__PUT(chnk + 24, Heap_bigBlocks, LONGINT);
|
||||
Heap_bigBlocks = chnk + 12;
|
||||
Heap_heapsize += blksz;
|
||||
}
|
||||
_o_result = chnk;
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
static void Heap_ExtendHeap (LONGINT blksz)
|
||||
{
|
||||
LONGINT size, chnk, j, next;
|
||||
if (blksz > 160000) {
|
||||
size = blksz;
|
||||
} else {
|
||||
size = 160000;
|
||||
}
|
||||
chnk = Heap_NewChunk(size);
|
||||
if (chnk != 0) {
|
||||
if (chnk < Heap_heap) {
|
||||
__PUT(chnk, Heap_heap, LONGINT);
|
||||
Heap_heap = chnk;
|
||||
} else {
|
||||
j = Heap_heap;
|
||||
next = Heap_FetchAddress(j);
|
||||
while ((next != 0 && chnk > next)) {
|
||||
j = next;
|
||||
next = Heap_FetchAddress(j);
|
||||
}
|
||||
__PUT(chnk, next, LONGINT);
|
||||
__PUT(j, chnk, LONGINT);
|
||||
}
|
||||
if (next == 0) {
|
||||
Heap_heapend = Heap_FetchAddress(chnk + 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SYSTEM_PTR Heap_NEWREC (LONGINT tag)
|
||||
{
|
||||
SYSTEM_PTR _o_result;
|
||||
LONGINT i, i0, di, blksz, restsize, t, adr, end, next, prev;
|
||||
SYSTEM_PTR new;
|
||||
Heap_Lock();
|
||||
blksz = Heap_FetchAddress(tag);
|
||||
i0 = __ASHR(blksz, 4);
|
||||
i = i0;
|
||||
if (i < 9) {
|
||||
adr = Heap_freeList[i];
|
||||
while (adr == 0) {
|
||||
i += 1;
|
||||
adr = Heap_freeList[i];
|
||||
}
|
||||
}
|
||||
if (i < 9) {
|
||||
next = Heap_FetchAddress(adr + 12);
|
||||
Heap_freeList[i] = next;
|
||||
if (i != i0) {
|
||||
di = i - i0;
|
||||
restsize = __ASHL(di, 4);
|
||||
end = adr + restsize;
|
||||
__PUT(end + 4, blksz, LONGINT);
|
||||
__PUT(end + 8, -4, LONGINT);
|
||||
__PUT(end, end + 4, LONGINT);
|
||||
__PUT(adr + 4, restsize, LONGINT);
|
||||
__PUT(adr + 12, Heap_freeList[di], LONGINT);
|
||||
Heap_freeList[di] = adr;
|
||||
adr += restsize;
|
||||
}
|
||||
} else {
|
||||
adr = Heap_bigBlocks;
|
||||
prev = 0;
|
||||
for (;;) {
|
||||
if (adr == 0) {
|
||||
if (Heap_firstTry) {
|
||||
Heap_GC(1);
|
||||
blksz += 16;
|
||||
if (__ASHL((Heap_heapsize - Heap_allocated) - blksz, 2) < Heap_heapsize) {
|
||||
Heap_ExtendHeap(__ASHL(__DIV(Heap_allocated + blksz, 48), 6) - Heap_heapsize);
|
||||
}
|
||||
Heap_firstTry = 0;
|
||||
new = Heap_NEWREC(tag);
|
||||
Heap_firstTry = 1;
|
||||
if (new == NIL) {
|
||||
Heap_ExtendHeap(__ASHL(__DIV(Heap_allocated + blksz, 48), 6) - Heap_heapsize);
|
||||
new = Heap_NEWREC(tag);
|
||||
}
|
||||
Heap_Unlock();
|
||||
_o_result = new;
|
||||
return _o_result;
|
||||
} else {
|
||||
Heap_Unlock();
|
||||
_o_result = NIL;
|
||||
return _o_result;
|
||||
}
|
||||
}
|
||||
t = Heap_FetchAddress(adr + 4);
|
||||
if (t >= blksz) {
|
||||
break;
|
||||
}
|
||||
prev = adr;
|
||||
adr = Heap_FetchAddress(adr + 12);
|
||||
}
|
||||
restsize = t - blksz;
|
||||
end = adr + restsize;
|
||||
__PUT(end + 4, blksz, LONGINT);
|
||||
__PUT(end + 8, -4, LONGINT);
|
||||
__PUT(end, end + 4, LONGINT);
|
||||
if (restsize > 144) {
|
||||
__PUT(adr + 4, restsize, LONGINT);
|
||||
} else {
|
||||
next = Heap_FetchAddress(adr + 12);
|
||||
if (prev == 0) {
|
||||
Heap_bigBlocks = next;
|
||||
} else {
|
||||
__PUT(prev + 12, next, LONGINT);
|
||||
}
|
||||
if (restsize > 0) {
|
||||
di = __ASHR(restsize, 4);
|
||||
__PUT(adr + 4, restsize, LONGINT);
|
||||
__PUT(adr + 12, Heap_freeList[di], LONGINT);
|
||||
Heap_freeList[di] = adr;
|
||||
}
|
||||
}
|
||||
adr += restsize;
|
||||
}
|
||||
i = adr + 16;
|
||||
end = adr + blksz;
|
||||
while (i < end) {
|
||||
__PUT(i, 0, LONGINT);
|
||||
__PUT(i + 4, 0, LONGINT);
|
||||
__PUT(i + 8, 0, LONGINT);
|
||||
__PUT(i + 12, 0, LONGINT);
|
||||
i += 16;
|
||||
}
|
||||
__PUT(adr + 12, 0, LONGINT);
|
||||
__PUT(adr, tag, LONGINT);
|
||||
__PUT(adr + 4, 0, LONGINT);
|
||||
__PUT(adr + 8, 0, LONGINT);
|
||||
Heap_allocated += blksz;
|
||||
Heap_Unlock();
|
||||
_o_result = (SYSTEM_PTR)(uintptr_t)(adr + 4);
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
SYSTEM_PTR Heap_NEWBLK (LONGINT size)
|
||||
{
|
||||
SYSTEM_PTR _o_result;
|
||||
LONGINT blksz, tag;
|
||||
SYSTEM_PTR new;
|
||||
Heap_Lock();
|
||||
blksz = __ASHL(__ASHR(size + 31, 4), 4);
|
||||
new = Heap_NEWREC((LONGINT)(uintptr_t)&blksz);
|
||||
tag = ((LONGINT)(uintptr_t)new + blksz) - 12;
|
||||
__PUT(tag - 4, 0, LONGINT);
|
||||
__PUT(tag, blksz, LONGINT);
|
||||
__PUT(tag + 4, -4, LONGINT);
|
||||
__PUT((LONGINT)(uintptr_t)new - 4, tag, LONGINT);
|
||||
Heap_Unlock();
|
||||
_o_result = new;
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
static void Heap_Mark (LONGINT q)
|
||||
{
|
||||
LONGINT p, tag, fld, n, offset, tagbits;
|
||||
if (q != 0) {
|
||||
tagbits = Heap_FetchAddress(q - 4);
|
||||
if (!__ODD(tagbits)) {
|
||||
__PUT(q - 4, tagbits + 1, LONGINT);
|
||||
p = 0;
|
||||
tag = tagbits + 4;
|
||||
for (;;) {
|
||||
__GET(tag, offset, LONGINT);
|
||||
if (offset < 0) {
|
||||
__PUT(q - 4, (tag + offset) + 1, LONGINT);
|
||||
if (p == 0) {
|
||||
break;
|
||||
}
|
||||
n = q;
|
||||
q = p;
|
||||
tag = Heap_FetchAddress(q - 4);
|
||||
tag -= 1;
|
||||
__GET(tag, offset, LONGINT);
|
||||
fld = q + offset;
|
||||
p = Heap_FetchAddress(fld);
|
||||
__PUT(fld, (SYSTEM_PTR)(uintptr_t)n, SYSTEM_PTR);
|
||||
} else {
|
||||
fld = q + offset;
|
||||
n = Heap_FetchAddress(fld);
|
||||
if (n != 0) {
|
||||
tagbits = Heap_FetchAddress(n - 4);
|
||||
if (!__ODD(tagbits)) {
|
||||
__PUT(n - 4, tagbits + 1, LONGINT);
|
||||
__PUT(q - 4, tag + 1, LONGINT);
|
||||
__PUT(fld, (SYSTEM_PTR)(uintptr_t)p, SYSTEM_PTR);
|
||||
p = q;
|
||||
q = n;
|
||||
tag = tagbits;
|
||||
}
|
||||
}
|
||||
}
|
||||
tag += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void Heap_MarkP (SYSTEM_PTR p)
|
||||
{
|
||||
Heap_Mark((LONGINT)(uintptr_t)p);
|
||||
}
|
||||
|
||||
static void Heap_Scan (void)
|
||||
{
|
||||
LONGINT chnk, adr, end, start, tag, i, size, freesize;
|
||||
Heap_bigBlocks = 0;
|
||||
i = 1;
|
||||
while (i < 9) {
|
||||
Heap_freeList[i] = 0;
|
||||
i += 1;
|
||||
}
|
||||
freesize = 0;
|
||||
Heap_allocated = 0;
|
||||
chnk = Heap_heap;
|
||||
while (chnk != 0) {
|
||||
adr = chnk + 12;
|
||||
end = Heap_FetchAddress(chnk + 4);
|
||||
while (adr < end) {
|
||||
tag = Heap_FetchAddress(adr);
|
||||
if (__ODD(tag)) {
|
||||
if (freesize > 0) {
|
||||
start = adr - freesize;
|
||||
__PUT(start, start + 4, LONGINT);
|
||||
__PUT(start + 4, freesize, LONGINT);
|
||||
__PUT(start + 8, -4, LONGINT);
|
||||
i = __ASHR(freesize, 4);
|
||||
freesize = 0;
|
||||
if (i < 9) {
|
||||
__PUT(start + 12, Heap_freeList[i], LONGINT);
|
||||
Heap_freeList[i] = start;
|
||||
} else {
|
||||
__PUT(start + 12, Heap_bigBlocks, LONGINT);
|
||||
Heap_bigBlocks = start;
|
||||
}
|
||||
}
|
||||
tag -= 1;
|
||||
__PUT(adr, tag, LONGINT);
|
||||
size = Heap_FetchAddress(tag);
|
||||
Heap_allocated += size;
|
||||
adr += size;
|
||||
} else {
|
||||
size = Heap_FetchAddress(tag);
|
||||
freesize += size;
|
||||
adr += size;
|
||||
}
|
||||
}
|
||||
if (freesize > 0) {
|
||||
start = adr - freesize;
|
||||
__PUT(start, start + 4, LONGINT);
|
||||
__PUT(start + 4, freesize, LONGINT);
|
||||
__PUT(start + 8, -4, LONGINT);
|
||||
i = __ASHR(freesize, 4);
|
||||
freesize = 0;
|
||||
if (i < 9) {
|
||||
__PUT(start + 12, Heap_freeList[i], LONGINT);
|
||||
Heap_freeList[i] = start;
|
||||
} else {
|
||||
__PUT(start + 12, Heap_bigBlocks, LONGINT);
|
||||
Heap_bigBlocks = start;
|
||||
}
|
||||
}
|
||||
chnk = Heap_FetchAddress(chnk);
|
||||
}
|
||||
}
|
||||
|
||||
static void Heap_Sift (LONGINT l, LONGINT r, LONGINT *a, LONGINT a__len)
|
||||
{
|
||||
LONGINT i, j, x;
|
||||
j = l;
|
||||
x = a[j];
|
||||
for (;;) {
|
||||
i = j;
|
||||
j = __ASHL(j, 1) + 1;
|
||||
if ((j < r && a[j] < a[j + 1])) {
|
||||
j += 1;
|
||||
}
|
||||
if (j > r || a[j] <= x) {
|
||||
break;
|
||||
}
|
||||
a[i] = a[j];
|
||||
}
|
||||
a[i] = x;
|
||||
}
|
||||
|
||||
static void Heap_HeapSort (LONGINT n, LONGINT *a, LONGINT a__len)
|
||||
{
|
||||
LONGINT l, r, x;
|
||||
l = __ASHR(n, 1);
|
||||
r = n - 1;
|
||||
while (l > 0) {
|
||||
l -= 1;
|
||||
Heap_Sift(l, r, (void*)a, a__len);
|
||||
}
|
||||
while (r > 0) {
|
||||
x = a[0];
|
||||
a[0] = a[r];
|
||||
a[r] = x;
|
||||
r -= 1;
|
||||
Heap_Sift(l, r, (void*)a, a__len);
|
||||
}
|
||||
}
|
||||
|
||||
static void Heap_MarkCandidates (LONGINT n, LONGINT *cand, LONGINT cand__len)
|
||||
{
|
||||
LONGINT chnk, adr, tag, next, lim, lim1, i, ptr, size;
|
||||
chnk = Heap_heap;
|
||||
i = 0;
|
||||
lim = cand[n - 1];
|
||||
while ((chnk != 0 && chnk < lim)) {
|
||||
adr = chnk + 12;
|
||||
lim1 = Heap_FetchAddress(chnk + 4);
|
||||
if (lim < lim1) {
|
||||
lim1 = lim;
|
||||
}
|
||||
while (adr < lim1) {
|
||||
tag = Heap_FetchAddress(adr);
|
||||
if (__ODD(tag)) {
|
||||
size = Heap_FetchAddress(tag - 1);
|
||||
adr += size;
|
||||
} else {
|
||||
size = Heap_FetchAddress(tag);
|
||||
ptr = adr + 4;
|
||||
while (cand[i] < ptr) {
|
||||
i += 1;
|
||||
}
|
||||
if (i == n) {
|
||||
return;
|
||||
}
|
||||
next = adr + size;
|
||||
if (cand[i] < next) {
|
||||
Heap_Mark(ptr);
|
||||
}
|
||||
adr = next;
|
||||
}
|
||||
}
|
||||
chnk = Heap_FetchAddress(chnk);
|
||||
}
|
||||
}
|
||||
|
||||
static void Heap_CheckFin (void)
|
||||
{
|
||||
Heap_FinNode n;
|
||||
LONGINT tag;
|
||||
n = Heap_fin;
|
||||
while (n != NIL) {
|
||||
tag = Heap_FetchAddress(n->obj - 4);
|
||||
if (!__ODD(tag)) {
|
||||
n->marked = 0;
|
||||
Heap_Mark(n->obj);
|
||||
} else {
|
||||
n->marked = 1;
|
||||
}
|
||||
n = n->next;
|
||||
}
|
||||
}
|
||||
|
||||
static void Heap_Finalize (void)
|
||||
{
|
||||
Heap_FinNode n, prev;
|
||||
n = Heap_fin;
|
||||
prev = NIL;
|
||||
while (n != NIL) {
|
||||
if (!n->marked) {
|
||||
if (n == Heap_fin) {
|
||||
Heap_fin = Heap_fin->next;
|
||||
} else {
|
||||
prev->next = n->next;
|
||||
}
|
||||
(*n->finalize)((SYSTEM_PTR)(uintptr_t)n->obj);
|
||||
if (prev == NIL) {
|
||||
n = Heap_fin;
|
||||
} else {
|
||||
n = n->next;
|
||||
}
|
||||
} else {
|
||||
prev = n;
|
||||
n = n->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Heap_FINALL (void)
|
||||
{
|
||||
Heap_FinNode n;
|
||||
while (Heap_fin != NIL) {
|
||||
n = Heap_fin;
|
||||
Heap_fin = Heap_fin->next;
|
||||
(*n->finalize)((SYSTEM_PTR)(uintptr_t)n->obj);
|
||||
}
|
||||
}
|
||||
|
||||
static void Heap_MarkStack (LONGINT n, LONGINT *cand, LONGINT cand__len)
|
||||
{
|
||||
SYSTEM_PTR frame;
|
||||
LONGINT inc, nofcand, sp, p, stack0, ptr;
|
||||
struct Heap__1 align;
|
||||
if (n > 0) {
|
||||
Heap_MarkStack(n - 1, cand, cand__len);
|
||||
if (n > 100) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (n == 0) {
|
||||
nofcand = 0;
|
||||
sp = (LONGINT)(uintptr_t)&frame;
|
||||
stack0 = Heap_PlatformMainStackFrame();
|
||||
inc = (LONGINT)(uintptr_t)&align.p - (LONGINT)(uintptr_t)&align;
|
||||
if (sp > stack0) {
|
||||
inc = -inc;
|
||||
}
|
||||
while (sp != stack0) {
|
||||
__GET(sp, p, LONGINT);
|
||||
if ((p > Heap_heap && p < Heap_heapend)) {
|
||||
if (nofcand == cand__len) {
|
||||
Heap_HeapSort(nofcand, (void*)cand, cand__len);
|
||||
Heap_MarkCandidates(nofcand, (void*)cand, cand__len);
|
||||
nofcand = 0;
|
||||
}
|
||||
cand[nofcand] = p;
|
||||
nofcand += 1;
|
||||
}
|
||||
sp += inc;
|
||||
}
|
||||
if (nofcand > 0) {
|
||||
Heap_HeapSort(nofcand, (void*)cand, cand__len);
|
||||
Heap_MarkCandidates(nofcand, (void*)cand, cand__len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Heap_GC (BOOLEAN markStack)
|
||||
{
|
||||
Heap_Module m;
|
||||
LONGINT i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, i20, i21, i22, i23;
|
||||
LONGINT cand[10000];
|
||||
if (Heap_lockdepth == 0 || (Heap_lockdepth == 1 && !markStack)) {
|
||||
Heap_Lock();
|
||||
m = (Heap_Module)(uintptr_t)Heap_modules;
|
||||
while (m != NIL) {
|
||||
if (m->enumPtrs != NIL) {
|
||||
(*m->enumPtrs)(Heap_MarkP);
|
||||
}
|
||||
m = m->next;
|
||||
}
|
||||
if (markStack) {
|
||||
i0 = -100;
|
||||
i1 = -101;
|
||||
i2 = -102;
|
||||
i3 = -103;
|
||||
i4 = -104;
|
||||
i5 = -105;
|
||||
i6 = -106;
|
||||
i7 = -107;
|
||||
i8 = 1;
|
||||
i9 = 2;
|
||||
i10 = 3;
|
||||
i11 = 4;
|
||||
i12 = 5;
|
||||
i13 = 6;
|
||||
i14 = 7;
|
||||
i15 = 8;
|
||||
i16 = 9;
|
||||
i17 = 10;
|
||||
i18 = 11;
|
||||
i19 = 12;
|
||||
i20 = 13;
|
||||
i21 = 14;
|
||||
i22 = 15;
|
||||
i23 = 16;
|
||||
for (;;) {
|
||||
i0 += 1;
|
||||
i1 += 2;
|
||||
i2 += 3;
|
||||
i3 += 4;
|
||||
i4 += 5;
|
||||
i5 += 6;
|
||||
i6 += 7;
|
||||
i7 += 8;
|
||||
i8 += 9;
|
||||
i9 += 10;
|
||||
i10 += 11;
|
||||
i11 += 12;
|
||||
i12 += 13;
|
||||
i13 += 14;
|
||||
i14 += 15;
|
||||
i15 += 16;
|
||||
i16 += 17;
|
||||
i17 += 18;
|
||||
i18 += 19;
|
||||
i19 += 20;
|
||||
i20 += 21;
|
||||
i21 += 22;
|
||||
i22 += 23;
|
||||
i23 += 24;
|
||||
if ((i0 == -99 && i15 == 24)) {
|
||||
Heap_MarkStack(((LONGINT)(32)), (void*)cand, ((LONGINT)(10000)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (((((((((((((((((((((((i0 + i1) + i2) + i3) + i4) + i5) + i6) + i7) + i8) + i9) + i10) + i11) + i12) + i13) + i14) + i15) + i16) + i17) + i18) + i19) + i20) + i21) + i22) + i23 > 10000) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
Heap_CheckFin();
|
||||
Heap_Scan();
|
||||
Heap_Finalize();
|
||||
Heap_Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
void Heap_RegisterFinalizer (SYSTEM_PTR obj, Heap_Finalizer finalize)
|
||||
{
|
||||
Heap_FinNode f;
|
||||
__NEW(f, Heap_FinDesc);
|
||||
f->obj = (LONGINT)(uintptr_t)obj;
|
||||
f->finalize = finalize;
|
||||
f->marked = 1;
|
||||
f->next = Heap_fin;
|
||||
Heap_fin = f;
|
||||
}
|
||||
|
||||
void Heap_InitHeap (void)
|
||||
{
|
||||
Heap_heap = Heap_NewChunk(128000);
|
||||
Heap_heapend = Heap_FetchAddress(Heap_heap + 4);
|
||||
__PUT(Heap_heap, 0, LONGINT);
|
||||
Heap_allocated = 0;
|
||||
Heap_firstTry = 1;
|
||||
Heap_freeList[9] = 1;
|
||||
Heap_lockdepth = 0;
|
||||
Heap_FileCount = 0;
|
||||
Heap_modules = NIL;
|
||||
Heap_heapsize = 0;
|
||||
Heap_bigBlocks = 0;
|
||||
Heap_fin = NIL;
|
||||
Heap_interrupted = 0;
|
||||
Heap_HeapModuleInit();
|
||||
}
|
||||
|
||||
static void EnumPtrs(void (*P)(void*))
|
||||
{
|
||||
P(Heap_modules);
|
||||
P(Heap_fin);
|
||||
}
|
||||
|
||||
__TDESC(Heap_ModuleDesc, 1, 2) = {__TDFLDS("ModuleDesc", 48), {0, 28, -12}};
|
||||
__TDESC(Heap_CmdDesc, 1, 1) = {__TDFLDS("CmdDesc", 32), {0, -8}};
|
||||
__TDESC(Heap_FinDesc, 1, 1) = {__TDFLDS("FinDesc", 16), {0, -8}};
|
||||
__TDESC(Heap__1, 1, 1) = {__TDFLDS("", 8), {4, -8}};
|
||||
|
||||
export void *Heap__init(void)
|
||||
{
|
||||
__DEFMOD;
|
||||
__REGMOD("Heap", EnumPtrs);
|
||||
__REGCMD("FINALL", Heap_FINALL);
|
||||
__REGCMD("InitHeap", Heap_InitHeap);
|
||||
__REGCMD("Lock", Heap_Lock);
|
||||
__REGCMD("Unlock", Heap_Unlock);
|
||||
__INITYP(Heap_ModuleDesc, Heap_ModuleDesc, 0);
|
||||
__INITYP(Heap_CmdDesc, Heap_CmdDesc, 0);
|
||||
__INITYP(Heap_FinDesc, Heap_FinDesc, 0);
|
||||
__INITYP(Heap__1, Heap__1, 0);
|
||||
/* BEGIN */
|
||||
__ENDMOD;
|
||||
}
|
||||
54
bootstrap/unix-44/Heap.h
Normal file
54
bootstrap/unix-44/Heap.h
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin tskSfF */
|
||||
|
||||
#ifndef Heap__h
|
||||
#define Heap__h
|
||||
|
||||
#include "SYSTEM.h"
|
||||
|
||||
typedef
|
||||
CHAR Heap_CmdName[24];
|
||||
|
||||
typedef
|
||||
void (*Heap_Command)(void);
|
||||
|
||||
typedef
|
||||
void (*Heap_EnumProc)(void(*)(SYSTEM_PTR));
|
||||
|
||||
typedef
|
||||
void (*Heap_Finalizer)(SYSTEM_PTR);
|
||||
|
||||
typedef
|
||||
struct Heap_ModuleDesc *Heap_Module;
|
||||
|
||||
typedef
|
||||
struct Heap_ModuleDesc {
|
||||
LONGINT _prvt0;
|
||||
char _prvt1[44];
|
||||
} Heap_ModuleDesc;
|
||||
|
||||
typedef
|
||||
CHAR Heap_ModuleName[20];
|
||||
|
||||
|
||||
import SYSTEM_PTR Heap_modules;
|
||||
import LONGINT Heap_allocated, Heap_heapsize;
|
||||
import INTEGER Heap_FileCount;
|
||||
|
||||
import LONGINT *Heap_ModuleDesc__typ;
|
||||
|
||||
import void Heap_FINALL (void);
|
||||
import void Heap_GC (BOOLEAN markStack);
|
||||
import void Heap_INCREF (Heap_Module m);
|
||||
import void Heap_InitHeap (void);
|
||||
import void Heap_Lock (void);
|
||||
import SYSTEM_PTR Heap_NEWBLK (LONGINT size);
|
||||
import SYSTEM_PTR Heap_NEWREC (LONGINT tag);
|
||||
import void Heap_REGCMD (Heap_Module m, Heap_CmdName name, Heap_Command cmd);
|
||||
import SYSTEM_PTR Heap_REGMOD (Heap_ModuleName name, Heap_EnumProc enumPtrs);
|
||||
import void Heap_REGTYP (Heap_Module m, LONGINT typ);
|
||||
import void Heap_RegisterFinalizer (SYSTEM_PTR obj, Heap_Finalizer finalize);
|
||||
import void Heap_Unlock (void);
|
||||
import void *Heap__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
171
bootstrap/unix-44/Modules.c
Normal file
171
bootstrap/unix-44/Modules.c
Normal file
|
|
@ -0,0 +1,171 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
#include "SYSTEM.h"
|
||||
#include "Console.h"
|
||||
#include "Heap.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;
|
||||
LONGINT refcnt;
|
||||
Modules_Cmd cmds;
|
||||
LONGINT types;
|
||||
void (*enumPtrs)(void(*)(LONGINT));
|
||||
LONGINT reserved1, reserved2;
|
||||
} Modules_ModuleDesc;
|
||||
|
||||
|
||||
export INTEGER Modules_res;
|
||||
export CHAR Modules_resMsg[256];
|
||||
export Modules_ModuleName Modules_imported, Modules_importing;
|
||||
|
||||
export LONGINT *Modules_ModuleDesc__typ;
|
||||
export LONGINT *Modules_CmdDesc__typ;
|
||||
|
||||
static void Modules_Append (CHAR *a, LONGINT a__len, CHAR *b, LONGINT b__len);
|
||||
export void Modules_Free (CHAR *name, LONGINT name__len, BOOLEAN all);
|
||||
export Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, LONGINT name__len);
|
||||
export Modules_Module Modules_ThisMod (CHAR *name, LONGINT name__len);
|
||||
|
||||
#define Modules_modules() (Modules_Module)Heap_modules
|
||||
#define Modules_setmodules(m) Heap_modules = m
|
||||
|
||||
static void Modules_Append (CHAR *a, LONGINT a__len, CHAR *b, LONGINT b__len)
|
||||
{
|
||||
INTEGER i, j;
|
||||
__DUP(b, b__len, CHAR);
|
||||
i = 0;
|
||||
while (a[__X(i, a__len)] != 0x00) {
|
||||
i += 1;
|
||||
}
|
||||
j = 0;
|
||||
while (b[__X(j, b__len)] != 0x00) {
|
||||
a[__X(i, a__len)] = b[__X(j, b__len)];
|
||||
i += 1;
|
||||
j += 1;
|
||||
}
|
||||
a[__X(i, a__len)] = 0x00;
|
||||
__DEL(b);
|
||||
}
|
||||
|
||||
Modules_Module Modules_ThisMod (CHAR *name, LONGINT name__len)
|
||||
{
|
||||
Modules_Module _o_result;
|
||||
Modules_Module m = NIL;
|
||||
CHAR bodyname[64];
|
||||
Modules_Command body;
|
||||
__DUP(name, name__len, CHAR);
|
||||
m = Modules_modules();
|
||||
while ((m != NIL && __STRCMP(m->name, name) != 0)) {
|
||||
m = m->next;
|
||||
}
|
||||
if (m != NIL) {
|
||||
Modules_res = 0;
|
||||
Modules_resMsg[0] = 0x00;
|
||||
} else {
|
||||
Modules_res = 1;
|
||||
__COPY(name, Modules_importing, ((LONGINT)(20)));
|
||||
__MOVE(" module \"", Modules_resMsg, 10);
|
||||
Modules_Append((void*)Modules_resMsg, ((LONGINT)(256)), name, name__len);
|
||||
Modules_Append((void*)Modules_resMsg, ((LONGINT)(256)), (CHAR*)"\" not found", (LONGINT)12);
|
||||
}
|
||||
_o_result = m;
|
||||
__DEL(name);
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, LONGINT name__len)
|
||||
{
|
||||
Modules_Command _o_result;
|
||||
Modules_Cmd c = NIL;
|
||||
__DUP(name, name__len, CHAR);
|
||||
c = mod->cmds;
|
||||
while ((c != NIL && __STRCMP(c->name, name) != 0)) {
|
||||
c = c->next;
|
||||
}
|
||||
if (c != NIL) {
|
||||
Modules_res = 0;
|
||||
Modules_resMsg[0] = 0x00;
|
||||
_o_result = c->cmd;
|
||||
__DEL(name);
|
||||
return _o_result;
|
||||
} else {
|
||||
Modules_res = 2;
|
||||
__MOVE(" command \"", Modules_resMsg, 11);
|
||||
__COPY(name, Modules_importing, ((LONGINT)(20)));
|
||||
Modules_Append((void*)Modules_resMsg, ((LONGINT)(256)), mod->name, ((LONGINT)(20)));
|
||||
Modules_Append((void*)Modules_resMsg, ((LONGINT)(256)), (CHAR*)".", (LONGINT)2);
|
||||
Modules_Append((void*)Modules_resMsg, ((LONGINT)(256)), name, name__len);
|
||||
Modules_Append((void*)Modules_resMsg, ((LONGINT)(256)), (CHAR*)"\" not found", (LONGINT)12);
|
||||
_o_result = NIL;
|
||||
__DEL(name);
|
||||
return _o_result;
|
||||
}
|
||||
__RETCHK;
|
||||
}
|
||||
|
||||
void Modules_Free (CHAR *name, LONGINT name__len, BOOLEAN all)
|
||||
{
|
||||
Modules_Module m = NIL, p = NIL;
|
||||
__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;
|
||||
}
|
||||
Modules_res = 0;
|
||||
} else {
|
||||
Modules_res = 1;
|
||||
if (m == NIL) {
|
||||
__MOVE("module not found", Modules_resMsg, 17);
|
||||
} else {
|
||||
__MOVE("clients of this module exist", Modules_resMsg, 29);
|
||||
}
|
||||
}
|
||||
}
|
||||
__DEL(name);
|
||||
}
|
||||
|
||||
__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)
|
||||
{
|
||||
__DEFMOD;
|
||||
__MODULE_IMPORT(Console);
|
||||
__MODULE_IMPORT(Heap);
|
||||
__REGMOD("Modules", 0);
|
||||
__INITYP(Modules_ModuleDesc, Modules_ModuleDesc, 0);
|
||||
__INITYP(Modules_CmdDesc, Modules_CmdDesc, 0);
|
||||
/* BEGIN */
|
||||
__ENDMOD;
|
||||
}
|
||||
54
bootstrap/unix-44/Modules.h
Normal file
54
bootstrap/unix-44/Modules.h
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#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;
|
||||
LONGINT refcnt;
|
||||
Modules_Cmd cmds;
|
||||
LONGINT types;
|
||||
void (*enumPtrs)(void(*)(LONGINT));
|
||||
char _prvt0[8];
|
||||
} Modules_ModuleDesc;
|
||||
|
||||
|
||||
import INTEGER Modules_res;
|
||||
import CHAR Modules_resMsg[256];
|
||||
import Modules_ModuleName Modules_imported, Modules_importing;
|
||||
|
||||
import LONGINT *Modules_ModuleDesc__typ;
|
||||
import LONGINT *Modules_CmdDesc__typ;
|
||||
|
||||
import void Modules_Free (CHAR *name, LONGINT name__len, BOOLEAN all);
|
||||
import Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, LONGINT name__len);
|
||||
import Modules_Module Modules_ThisMod (CHAR *name, LONGINT name__len);
|
||||
import void *Modules__init(void);
|
||||
|
||||
#define Modules_modules() (Modules_Module)Heap_modules
|
||||
#define Modules_setmodules(m) Heap_modules = m
|
||||
|
||||
#endif
|
||||
2677
bootstrap/unix-44/OPB.c
Normal file
2677
bootstrap/unix-44/OPB.c
Normal file
File diff suppressed because it is too large
Load diff
49
bootstrap/unix-44/OPB.h
Normal file
49
bootstrap/unix-44/OPB.h
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#ifndef OPB__h
|
||||
#define OPB__h
|
||||
|
||||
#include "SYSTEM.h"
|
||||
#include "OPS.h"
|
||||
#include "OPT.h"
|
||||
|
||||
|
||||
import void (*OPB_typSize)(OPT_Struct);
|
||||
|
||||
|
||||
import void OPB_Assign (OPT_Node *x, OPT_Node y);
|
||||
import void OPB_Call (OPT_Node *x, OPT_Node apar, OPT_Object fp);
|
||||
import void OPB_CheckParameters (OPT_Object fp, OPT_Object ap, BOOLEAN checkNames);
|
||||
import void OPB_Construct (SHORTINT class, OPT_Node *x, OPT_Node y);
|
||||
import void OPB_DeRef (OPT_Node *x);
|
||||
import OPT_Node OPB_EmptySet (void);
|
||||
import void OPB_Enter (OPT_Node *procdec, OPT_Node stat, OPT_Object proc);
|
||||
import void OPB_Field (OPT_Node *x, OPT_Object y);
|
||||
import void OPB_In (OPT_Node *x, OPT_Node y);
|
||||
import void OPB_Index (OPT_Node *x, OPT_Node y);
|
||||
import void OPB_Inittd (OPT_Node *inittd, OPT_Node *last, OPT_Struct typ);
|
||||
import void OPB_Link (OPT_Node *x, OPT_Node *last, OPT_Node y);
|
||||
import void OPB_MOp (SHORTINT op, OPT_Node *x);
|
||||
import OPT_Node OPB_NewBoolConst (BOOLEAN boolval);
|
||||
import OPT_Node OPB_NewIntConst (LONGINT intval);
|
||||
import OPT_Node OPB_NewLeaf (OPT_Object obj);
|
||||
import OPT_Node OPB_NewRealConst (LONGREAL realval, OPT_Struct typ);
|
||||
import OPT_Node OPB_NewString (OPS_String str, LONGINT len);
|
||||
import OPT_Node OPB_Nil (void);
|
||||
import void OPB_Op (SHORTINT op, OPT_Node *x, OPT_Node y);
|
||||
import void OPB_OptIf (OPT_Node *x);
|
||||
import void OPB_Param (OPT_Node ap, OPT_Object fp);
|
||||
import void OPB_PrepCall (OPT_Node *x, OPT_Object *fpar);
|
||||
import void OPB_Return (OPT_Node *x, OPT_Object proc);
|
||||
import void OPB_SetElem (OPT_Node *x);
|
||||
import void OPB_SetRange (OPT_Node *x, OPT_Node y);
|
||||
import void OPB_StFct (OPT_Node *par0, SHORTINT fctno, INTEGER parno);
|
||||
import void OPB_StPar0 (OPT_Node *par0, INTEGER fctno);
|
||||
import void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno);
|
||||
import void OPB_StParN (OPT_Node *par0, OPT_Node x, INTEGER fctno, INTEGER n);
|
||||
import void OPB_StaticLink (SHORTINT dlev);
|
||||
import void OPB_TypTest (OPT_Node *x, OPT_Object obj, BOOLEAN guard);
|
||||
import void *OPB__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
2108
bootstrap/unix-44/OPC.c
Normal file
2108
bootstrap/unix-44/OPC.c
Normal file
File diff suppressed because it is too large
Load diff
49
bootstrap/unix-44/OPC.h
Normal file
49
bootstrap/unix-44/OPC.h
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#ifndef OPC__h
|
||||
#define OPC__h
|
||||
|
||||
#include "SYSTEM.h"
|
||||
#include "OPT.h"
|
||||
|
||||
|
||||
|
||||
|
||||
import void OPC_Align (LONGINT *adr, LONGINT base);
|
||||
import void OPC_Andent (OPT_Struct typ);
|
||||
import LONGINT OPC_Base (OPT_Struct typ);
|
||||
import OPT_Object OPC_BaseTProc (OPT_Object obj);
|
||||
import void OPC_BegBlk (void);
|
||||
import void OPC_BegStat (void);
|
||||
import void OPC_Case (LONGINT caseVal, INTEGER form);
|
||||
import void OPC_Cmp (INTEGER rel);
|
||||
import void OPC_CompleteIdent (OPT_Object obj);
|
||||
import void OPC_Constant (OPT_Const con, INTEGER form);
|
||||
import void OPC_DefineInter (OPT_Object proc);
|
||||
import void OPC_EndBlk (void);
|
||||
import void OPC_EndBlk0 (void);
|
||||
import void OPC_EndStat (void);
|
||||
import void OPC_EnterBody (void);
|
||||
import void OPC_EnterProc (OPT_Object proc);
|
||||
import void OPC_ExitBody (void);
|
||||
import void OPC_ExitProc (OPT_Object proc, BOOLEAN eoBlock, BOOLEAN implicitRet);
|
||||
import void OPC_GenBdy (OPT_Node n);
|
||||
import void OPC_GenEnumPtrs (OPT_Object var);
|
||||
import void OPC_GenHdr (OPT_Node n);
|
||||
import void OPC_GenHdrIncludes (void);
|
||||
import void OPC_Halt (LONGINT n);
|
||||
import void OPC_Ident (OPT_Object obj);
|
||||
import void OPC_Increment (BOOLEAN decrement);
|
||||
import void OPC_Indent (INTEGER count);
|
||||
import void OPC_Init (void);
|
||||
import void OPC_InitTDesc (OPT_Struct typ);
|
||||
import void OPC_Len (OPT_Object obj, OPT_Struct array, LONGINT dim);
|
||||
import LONGINT OPC_NofPtrs (OPT_Struct typ);
|
||||
import void OPC_SetInclude (BOOLEAN exclude);
|
||||
import void OPC_TDescDecl (OPT_Struct typ);
|
||||
import void OPC_TypeDefs (OPT_Object obj, INTEGER vis);
|
||||
import void OPC_TypeOf (OPT_Object ap);
|
||||
import void *OPC__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
1091
bootstrap/unix-44/OPM.c
Normal file
1091
bootstrap/unix-44/OPM.c
Normal file
File diff suppressed because it is too large
Load diff
63
bootstrap/unix-44/OPM.h
Normal file
63
bootstrap/unix-44/OPM.h
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#ifndef OPM__h
|
||||
#define OPM__h
|
||||
|
||||
#include "SYSTEM.h"
|
||||
|
||||
|
||||
import INTEGER OPM_Alignment, OPM_ByteSize, OPM_CharSize, OPM_BoolSize, OPM_SIntSize, OPM_IntSize, OPM_LIntSize, OPM_SetSize, OPM_RealSize, OPM_LRealSize, OPM_PointerSize, OPM_ProcSize, OPM_RecSize, OPM_CharAlign, OPM_BoolAlign, OPM_SIntAlign, OPM_IntAlign, OPM_LIntAlign, OPM_SetAlign, OPM_RealAlign, OPM_LRealAlign, OPM_PointerAlign, OPM_ProcAlign, OPM_RecAlign, OPM_MaxSet;
|
||||
import LONGINT OPM_MinSInt, OPM_MinInt, OPM_MinLInt, OPM_MaxSInt, OPM_MaxInt, OPM_MaxLInt, OPM_MaxIndex;
|
||||
import LONGREAL OPM_MinReal, OPM_MaxReal, OPM_MinLReal, OPM_MaxLReal;
|
||||
import BOOLEAN OPM_noerr;
|
||||
import LONGINT OPM_curpos, OPM_errpos, OPM_breakpc;
|
||||
import INTEGER OPM_currFile, OPM_level, OPM_pc, OPM_entno;
|
||||
import CHAR OPM_modName[32];
|
||||
import CHAR OPM_objname[64];
|
||||
import SET OPM_opt, OPM_glbopt;
|
||||
import BOOLEAN OPM_dontAsm, OPM_dontLink, OPM_mainProg, OPM_mainLinkStat, OPM_notColorOutput, OPM_forceNewSym, OPM_Verbose;
|
||||
|
||||
|
||||
import void OPM_CloseFiles (void);
|
||||
import void OPM_CloseOldSym (void);
|
||||
import void OPM_DeleteNewSym (void);
|
||||
import void OPM_FPrint (LONGINT *fp, LONGINT val);
|
||||
import void OPM_FPrintLReal (LONGINT *fp, LONGREAL lr);
|
||||
import void OPM_FPrintReal (LONGINT *fp, REAL real);
|
||||
import void OPM_FPrintSet (LONGINT *fp, SET set);
|
||||
import void OPM_Get (CHAR *ch);
|
||||
import void OPM_Init (BOOLEAN *done, CHAR *mname, LONGINT mname__len);
|
||||
import void OPM_InitOptions (void);
|
||||
import void OPM_LogW (CHAR ch);
|
||||
import void OPM_LogWLn (void);
|
||||
import void OPM_LogWNum (LONGINT i, LONGINT len);
|
||||
import void OPM_LogWStr (CHAR *s, LONGINT s__len);
|
||||
import void OPM_Mark (INTEGER n, LONGINT pos);
|
||||
import void OPM_NewSym (CHAR *modName, LONGINT modName__len);
|
||||
import void OPM_OldSym (CHAR *modName, LONGINT modName__len, BOOLEAN *done);
|
||||
import void OPM_OpenFiles (CHAR *moduleName, LONGINT moduleName__len);
|
||||
import BOOLEAN OPM_OpenPar (void);
|
||||
import void OPM_RegisterNewSym (void);
|
||||
import void OPM_SymRCh (CHAR *ch);
|
||||
import LONGINT OPM_SymRInt (void);
|
||||
import void OPM_SymRLReal (LONGREAL *lr);
|
||||
import void OPM_SymRReal (REAL *r);
|
||||
import void OPM_SymRSet (SET *s);
|
||||
import void OPM_SymWCh (CHAR ch);
|
||||
import void OPM_SymWInt (LONGINT i);
|
||||
import void OPM_SymWLReal (LONGREAL lr);
|
||||
import void OPM_SymWReal (REAL r);
|
||||
import void OPM_SymWSet (SET s);
|
||||
import void OPM_Write (CHAR ch);
|
||||
import void OPM_WriteHex (LONGINT i);
|
||||
import void OPM_WriteInt (LONGINT i);
|
||||
import void OPM_WriteLn (void);
|
||||
import void OPM_WriteReal (LONGREAL r, CHAR suffx);
|
||||
import void OPM_WriteString (CHAR *s, LONGINT s__len);
|
||||
import void OPM_WriteStringVar (CHAR *s, LONGINT s__len);
|
||||
import BOOLEAN OPM_eofSF (void);
|
||||
import void OPM_err (INTEGER n);
|
||||
import void *OPM__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
1873
bootstrap/unix-44/OPP.c
Normal file
1873
bootstrap/unix-44/OPP.c
Normal file
File diff suppressed because it is too large
Load diff
16
bootstrap/unix-44/OPP.h
Normal file
16
bootstrap/unix-44/OPP.h
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#ifndef OPP__h
|
||||
#define OPP__h
|
||||
|
||||
#include "SYSTEM.h"
|
||||
#include "OPT.h"
|
||||
|
||||
|
||||
|
||||
|
||||
import void OPP_Module (OPT_Node *prog, SET opt);
|
||||
import void *OPP__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
623
bootstrap/unix-44/OPS.c
Normal file
623
bootstrap/unix-44/OPS.c
Normal file
|
|
@ -0,0 +1,623 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin tspkaSfF */
|
||||
#include "SYSTEM.h"
|
||||
#include "OPM.h"
|
||||
|
||||
typedef
|
||||
CHAR OPS_Name[256];
|
||||
|
||||
typedef
|
||||
CHAR OPS_String[256];
|
||||
|
||||
|
||||
export OPS_Name OPS_name;
|
||||
export OPS_String OPS_str;
|
||||
export INTEGER OPS_numtyp;
|
||||
export LONGINT OPS_intval;
|
||||
export REAL OPS_realval;
|
||||
export LONGREAL OPS_lrlval;
|
||||
static CHAR OPS_ch;
|
||||
|
||||
|
||||
export void OPS_Get (SHORTINT *sym);
|
||||
static void OPS_Identifier (SHORTINT *sym);
|
||||
export void OPS_Init (void);
|
||||
static void OPS_Number (void);
|
||||
static void OPS_Str (SHORTINT *sym);
|
||||
static void OPS_err (INTEGER n);
|
||||
|
||||
|
||||
static void OPS_err (INTEGER n)
|
||||
{
|
||||
OPM_err(n);
|
||||
}
|
||||
|
||||
static void OPS_Str (SHORTINT *sym)
|
||||
{
|
||||
INTEGER i;
|
||||
CHAR och;
|
||||
i = 0;
|
||||
och = OPS_ch;
|
||||
for (;;) {
|
||||
OPM_Get(&OPS_ch);
|
||||
if (OPS_ch == och) {
|
||||
break;
|
||||
}
|
||||
if (OPS_ch < ' ') {
|
||||
OPS_err(3);
|
||||
break;
|
||||
}
|
||||
if (i == 255) {
|
||||
OPS_err(241);
|
||||
break;
|
||||
}
|
||||
OPS_str[i] = OPS_ch;
|
||||
i += 1;
|
||||
}
|
||||
OPM_Get(&OPS_ch);
|
||||
OPS_str[i] = 0x00;
|
||||
OPS_intval = i + 1;
|
||||
if (OPS_intval == 2) {
|
||||
*sym = 35;
|
||||
OPS_numtyp = 1;
|
||||
OPS_intval = (int)OPS_str[0];
|
||||
} else {
|
||||
*sym = 37;
|
||||
}
|
||||
}
|
||||
|
||||
static void OPS_Identifier (SHORTINT *sym)
|
||||
{
|
||||
INTEGER i;
|
||||
i = 0;
|
||||
do {
|
||||
OPS_name[i] = OPS_ch;
|
||||
i += 1;
|
||||
OPM_Get(&OPS_ch);
|
||||
} while (!(((OPS_ch < '0' || ('9' < OPS_ch && __CAP(OPS_ch) < 'A')) || 'Z' < __CAP(OPS_ch)) || i == 256));
|
||||
if (i == 256) {
|
||||
OPS_err(240);
|
||||
i -= 1;
|
||||
}
|
||||
OPS_name[i] = 0x00;
|
||||
*sym = 38;
|
||||
}
|
||||
|
||||
static struct Number__6 {
|
||||
struct Number__6 *lnk;
|
||||
} *Number__6_s;
|
||||
|
||||
static INTEGER Ord__7 (CHAR ch, BOOLEAN hex);
|
||||
static LONGREAL Ten__9 (INTEGER e);
|
||||
|
||||
static LONGREAL Ten__9 (INTEGER e)
|
||||
{
|
||||
LONGREAL _o_result;
|
||||
LONGREAL x, p;
|
||||
x = (LONGREAL)1;
|
||||
p = (LONGREAL)10;
|
||||
while (e > 0) {
|
||||
if (__ODD(e)) {
|
||||
x = x * p;
|
||||
}
|
||||
e = __ASHR(e, 1);
|
||||
if (e > 0) {
|
||||
p = p * p;
|
||||
}
|
||||
}
|
||||
_o_result = x;
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
static INTEGER Ord__7 (CHAR ch, BOOLEAN hex)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
if (ch <= '9') {
|
||||
_o_result = (int)ch - 48;
|
||||
return _o_result;
|
||||
} else if (hex) {
|
||||
_o_result = ((int)ch - 65) + 10;
|
||||
return _o_result;
|
||||
} else {
|
||||
OPS_err(2);
|
||||
_o_result = 0;
|
||||
return _o_result;
|
||||
}
|
||||
__RETCHK;
|
||||
}
|
||||
|
||||
static void OPS_Number (void)
|
||||
{
|
||||
INTEGER i, m, n, d, e;
|
||||
CHAR dig[24];
|
||||
LONGREAL f;
|
||||
CHAR expCh;
|
||||
BOOLEAN neg;
|
||||
struct Number__6 _s;
|
||||
_s.lnk = Number__6_s;
|
||||
Number__6_s = &_s;
|
||||
i = 0;
|
||||
m = 0;
|
||||
n = 0;
|
||||
d = 0;
|
||||
for (;;) {
|
||||
if (('0' <= OPS_ch && OPS_ch <= '9') || (((d == 0 && 'A' <= OPS_ch)) && OPS_ch <= 'F')) {
|
||||
if (m > 0 || OPS_ch != '0') {
|
||||
if (n < 24) {
|
||||
dig[n] = OPS_ch;
|
||||
n += 1;
|
||||
}
|
||||
m += 1;
|
||||
}
|
||||
OPM_Get(&OPS_ch);
|
||||
i += 1;
|
||||
} else if (OPS_ch == '.') {
|
||||
OPM_Get(&OPS_ch);
|
||||
if (OPS_ch == '.') {
|
||||
OPS_ch = 0x7f;
|
||||
break;
|
||||
} else if (d == 0) {
|
||||
d = i;
|
||||
} else {
|
||||
OPS_err(2);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (d == 0) {
|
||||
if (n == m) {
|
||||
OPS_intval = 0;
|
||||
i = 0;
|
||||
if (OPS_ch == 'X') {
|
||||
OPM_Get(&OPS_ch);
|
||||
OPS_numtyp = 1;
|
||||
if (n <= 2) {
|
||||
while (i < n) {
|
||||
OPS_intval = __ASHL(OPS_intval, 4) + (LONGINT)Ord__7(dig[i], 1);
|
||||
i += 1;
|
||||
}
|
||||
} else {
|
||||
OPS_err(203);
|
||||
}
|
||||
} else if (OPS_ch == 'H') {
|
||||
OPM_Get(&OPS_ch);
|
||||
OPS_numtyp = 2;
|
||||
if (n <= 8) {
|
||||
if ((n == 8 && dig[0] > '7')) {
|
||||
OPS_intval = -1;
|
||||
}
|
||||
while (i < n) {
|
||||
OPS_intval = __ASHL(OPS_intval, 4) + (LONGINT)Ord__7(dig[i], 1);
|
||||
i += 1;
|
||||
}
|
||||
} else {
|
||||
OPS_err(203);
|
||||
}
|
||||
} else {
|
||||
OPS_numtyp = 2;
|
||||
while (i < n) {
|
||||
d = Ord__7(dig[i], 0);
|
||||
i += 1;
|
||||
if (OPS_intval <= __DIV(2147483647 - (LONGINT)d, 10)) {
|
||||
OPS_intval = OPS_intval * 10 + (LONGINT)d;
|
||||
} else {
|
||||
OPS_err(203);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
OPS_err(203);
|
||||
}
|
||||
} else {
|
||||
f = (LONGREAL)0;
|
||||
e = 0;
|
||||
expCh = 'E';
|
||||
while (n > 0) {
|
||||
n -= 1;
|
||||
f = (Ord__7(dig[n], 0) + f) / (LONGREAL)(LONGREAL)10;
|
||||
}
|
||||
if (OPS_ch == 'E' || OPS_ch == 'D') {
|
||||
expCh = OPS_ch;
|
||||
OPM_Get(&OPS_ch);
|
||||
neg = 0;
|
||||
if (OPS_ch == '-') {
|
||||
neg = 1;
|
||||
OPM_Get(&OPS_ch);
|
||||
} else if (OPS_ch == '+') {
|
||||
OPM_Get(&OPS_ch);
|
||||
}
|
||||
if (('0' <= OPS_ch && OPS_ch <= '9')) {
|
||||
do {
|
||||
n = Ord__7(OPS_ch, 0);
|
||||
OPM_Get(&OPS_ch);
|
||||
if (e <= __DIV(32767 - n, 10)) {
|
||||
e = e * 10 + n;
|
||||
} else {
|
||||
OPS_err(203);
|
||||
}
|
||||
} while (!(OPS_ch < '0' || '9' < OPS_ch));
|
||||
if (neg) {
|
||||
e = -e;
|
||||
}
|
||||
} else {
|
||||
OPS_err(2);
|
||||
}
|
||||
}
|
||||
e -= (i - d) - m;
|
||||
if (expCh == 'E') {
|
||||
OPS_numtyp = 3;
|
||||
if ((-37 < e && e <= 38)) {
|
||||
if (e < 0) {
|
||||
OPS_realval = (f / (LONGREAL)Ten__9(-e));
|
||||
} else {
|
||||
OPS_realval = (f * Ten__9(e));
|
||||
}
|
||||
} else {
|
||||
OPS_err(203);
|
||||
}
|
||||
} else {
|
||||
OPS_numtyp = 4;
|
||||
if ((-307 < e && e <= 308)) {
|
||||
if (e < 0) {
|
||||
OPS_lrlval = f / (LONGREAL)Ten__9(-e);
|
||||
} else {
|
||||
OPS_lrlval = f * Ten__9(e);
|
||||
}
|
||||
} else {
|
||||
OPS_err(203);
|
||||
}
|
||||
}
|
||||
}
|
||||
Number__6_s = _s.lnk;
|
||||
}
|
||||
|
||||
static struct Get__1 {
|
||||
struct Get__1 *lnk;
|
||||
} *Get__1_s;
|
||||
|
||||
static void Comment__2 (void);
|
||||
|
||||
static void Comment__2 (void)
|
||||
{
|
||||
OPM_Get(&OPS_ch);
|
||||
for (;;) {
|
||||
for (;;) {
|
||||
while (OPS_ch == '(') {
|
||||
OPM_Get(&OPS_ch);
|
||||
if (OPS_ch == '*') {
|
||||
Comment__2();
|
||||
}
|
||||
}
|
||||
if (OPS_ch == '*') {
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
}
|
||||
if (OPS_ch == 0x00) {
|
||||
break;
|
||||
}
|
||||
OPM_Get(&OPS_ch);
|
||||
}
|
||||
if (OPS_ch == ')') {
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
}
|
||||
if (OPS_ch == 0x00) {
|
||||
OPS_err(5);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OPS_Get (SHORTINT *sym)
|
||||
{
|
||||
SHORTINT s;
|
||||
struct Get__1 _s;
|
||||
_s.lnk = Get__1_s;
|
||||
Get__1_s = &_s;
|
||||
OPM_errpos = OPM_curpos - 1;
|
||||
while (OPS_ch <= ' ') {
|
||||
if (OPS_ch == 0x00) {
|
||||
*sym = 64;
|
||||
return;
|
||||
} else {
|
||||
OPM_Get(&OPS_ch);
|
||||
}
|
||||
}
|
||||
switch (OPS_ch) {
|
||||
case '\"': case '\'':
|
||||
OPS_Str(&s);
|
||||
break;
|
||||
case '#':
|
||||
s = 10;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
case '&':
|
||||
s = 5;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
case '(':
|
||||
OPM_Get(&OPS_ch);
|
||||
if (OPS_ch == '*') {
|
||||
Comment__2();
|
||||
OPS_Get(&s);
|
||||
} else {
|
||||
s = 30;
|
||||
}
|
||||
break;
|
||||
case ')':
|
||||
s = 22;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
case '*':
|
||||
s = 1;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
case '+':
|
||||
s = 6;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
case ',':
|
||||
s = 19;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
case '-':
|
||||
s = 7;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
case '.':
|
||||
OPM_Get(&OPS_ch);
|
||||
if (OPS_ch == '.') {
|
||||
OPM_Get(&OPS_ch);
|
||||
s = 21;
|
||||
} else {
|
||||
s = 18;
|
||||
}
|
||||
break;
|
||||
case '/':
|
||||
s = 2;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
OPS_Number();
|
||||
s = 35;
|
||||
break;
|
||||
case ':':
|
||||
OPM_Get(&OPS_ch);
|
||||
if (OPS_ch == '=') {
|
||||
OPM_Get(&OPS_ch);
|
||||
s = 34;
|
||||
} else {
|
||||
s = 20;
|
||||
}
|
||||
break;
|
||||
case ';':
|
||||
s = 39;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
case '<':
|
||||
OPM_Get(&OPS_ch);
|
||||
if (OPS_ch == '=') {
|
||||
OPM_Get(&OPS_ch);
|
||||
s = 12;
|
||||
} else {
|
||||
s = 11;
|
||||
}
|
||||
break;
|
||||
case '=':
|
||||
s = 9;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
case '>':
|
||||
OPM_Get(&OPS_ch);
|
||||
if (OPS_ch == '=') {
|
||||
OPM_Get(&OPS_ch);
|
||||
s = 14;
|
||||
} else {
|
||||
s = 13;
|
||||
}
|
||||
break;
|
||||
case 'A':
|
||||
OPS_Identifier(&s);
|
||||
if (__STRCMP(OPS_name, "ARRAY") == 0) {
|
||||
s = 54;
|
||||
}
|
||||
break;
|
||||
case 'B':
|
||||
OPS_Identifier(&s);
|
||||
if (__STRCMP(OPS_name, "BEGIN") == 0) {
|
||||
s = 57;
|
||||
} else if (__STRCMP(OPS_name, "BY") == 0) {
|
||||
s = 29;
|
||||
}
|
||||
break;
|
||||
case 'C':
|
||||
OPS_Identifier(&s);
|
||||
if (__STRCMP(OPS_name, "CASE") == 0) {
|
||||
s = 46;
|
||||
} else if (__STRCMP(OPS_name, "CONST") == 0) {
|
||||
s = 58;
|
||||
}
|
||||
break;
|
||||
case 'D':
|
||||
OPS_Identifier(&s);
|
||||
if (__STRCMP(OPS_name, "DO") == 0) {
|
||||
s = 27;
|
||||
} else if (__STRCMP(OPS_name, "DIV") == 0) {
|
||||
s = 3;
|
||||
}
|
||||
break;
|
||||
case 'E':
|
||||
OPS_Identifier(&s);
|
||||
if (__STRCMP(OPS_name, "END") == 0) {
|
||||
s = 41;
|
||||
} else if (__STRCMP(OPS_name, "ELSE") == 0) {
|
||||
s = 42;
|
||||
} else if (__STRCMP(OPS_name, "ELSIF") == 0) {
|
||||
s = 43;
|
||||
} else if (__STRCMP(OPS_name, "EXIT") == 0) {
|
||||
s = 52;
|
||||
}
|
||||
break;
|
||||
case 'F':
|
||||
OPS_Identifier(&s);
|
||||
if (__STRCMP(OPS_name, "FOR") == 0) {
|
||||
s = 49;
|
||||
}
|
||||
break;
|
||||
case 'I':
|
||||
OPS_Identifier(&s);
|
||||
if (__STRCMP(OPS_name, "IF") == 0) {
|
||||
s = 45;
|
||||
} else if (__STRCMP(OPS_name, "IN") == 0) {
|
||||
s = 15;
|
||||
} else if (__STRCMP(OPS_name, "IS") == 0) {
|
||||
s = 16;
|
||||
} else if (__STRCMP(OPS_name, "IMPORT") == 0) {
|
||||
s = 62;
|
||||
}
|
||||
break;
|
||||
case 'L':
|
||||
OPS_Identifier(&s);
|
||||
if (__STRCMP(OPS_name, "LOOP") == 0) {
|
||||
s = 50;
|
||||
}
|
||||
break;
|
||||
case 'M':
|
||||
OPS_Identifier(&s);
|
||||
if (__STRCMP(OPS_name, "MOD") == 0) {
|
||||
s = 4;
|
||||
} else if (__STRCMP(OPS_name, "MODULE") == 0) {
|
||||
s = 63;
|
||||
}
|
||||
break;
|
||||
case 'N':
|
||||
OPS_Identifier(&s);
|
||||
if (__STRCMP(OPS_name, "NIL") == 0) {
|
||||
s = 36;
|
||||
}
|
||||
break;
|
||||
case 'O':
|
||||
OPS_Identifier(&s);
|
||||
if (__STRCMP(OPS_name, "OR") == 0) {
|
||||
s = 8;
|
||||
} else if (__STRCMP(OPS_name, "OF") == 0) {
|
||||
s = 25;
|
||||
}
|
||||
break;
|
||||
case 'P':
|
||||
OPS_Identifier(&s);
|
||||
if (__STRCMP(OPS_name, "PROCEDURE") == 0) {
|
||||
s = 61;
|
||||
} else if (__STRCMP(OPS_name, "POINTER") == 0) {
|
||||
s = 56;
|
||||
}
|
||||
break;
|
||||
case 'R':
|
||||
OPS_Identifier(&s);
|
||||
if (__STRCMP(OPS_name, "RECORD") == 0) {
|
||||
s = 55;
|
||||
} else if (__STRCMP(OPS_name, "REPEAT") == 0) {
|
||||
s = 48;
|
||||
} else if (__STRCMP(OPS_name, "RETURN") == 0) {
|
||||
s = 53;
|
||||
}
|
||||
break;
|
||||
case 'T':
|
||||
OPS_Identifier(&s);
|
||||
if (__STRCMP(OPS_name, "THEN") == 0) {
|
||||
s = 26;
|
||||
} else if (__STRCMP(OPS_name, "TO") == 0) {
|
||||
s = 28;
|
||||
} else if (__STRCMP(OPS_name, "TYPE") == 0) {
|
||||
s = 59;
|
||||
}
|
||||
break;
|
||||
case 'U':
|
||||
OPS_Identifier(&s);
|
||||
if (__STRCMP(OPS_name, "UNTIL") == 0) {
|
||||
s = 44;
|
||||
}
|
||||
break;
|
||||
case 'V':
|
||||
OPS_Identifier(&s);
|
||||
if (__STRCMP(OPS_name, "VAR") == 0) {
|
||||
s = 60;
|
||||
}
|
||||
break;
|
||||
case 'W':
|
||||
OPS_Identifier(&s);
|
||||
if (__STRCMP(OPS_name, "WHILE") == 0) {
|
||||
s = 47;
|
||||
} else if (__STRCMP(OPS_name, "WITH") == 0) {
|
||||
s = 51;
|
||||
}
|
||||
break;
|
||||
case 'G': case 'H': case 'J': case 'K': case 'Q':
|
||||
case 'S': case 'X': case 'Y': case 'Z':
|
||||
OPS_Identifier(&s);
|
||||
break;
|
||||
case '[':
|
||||
s = 31;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
case ']':
|
||||
s = 23;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
case '^':
|
||||
s = 17;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
case 'a': case 'b': case 'c': case 'd': case 'e':
|
||||
case 'f': case 'g': case 'h': case 'i': case 'j':
|
||||
case 'k': case 'l': case 'm': case 'n': case 'o':
|
||||
case 'p': case 'q': case 'r': case 's': case 't':
|
||||
case 'u': case 'v': case 'w': case 'x': case 'y':
|
||||
case 'z':
|
||||
OPS_Identifier(&s);
|
||||
break;
|
||||
case '{':
|
||||
s = 32;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
case '|':
|
||||
s = 40;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
case '}':
|
||||
s = 24;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
case '~':
|
||||
s = 33;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
case 0x7f:
|
||||
s = 21;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
default:
|
||||
s = 0;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
}
|
||||
*sym = s;
|
||||
Get__1_s = _s.lnk;
|
||||
}
|
||||
|
||||
void OPS_Init (void)
|
||||
{
|
||||
OPS_ch = ' ';
|
||||
}
|
||||
|
||||
|
||||
export void *OPS__init(void)
|
||||
{
|
||||
__DEFMOD;
|
||||
__MODULE_IMPORT(OPM);
|
||||
__REGMOD("OPS", 0);
|
||||
__REGCMD("Init", OPS_Init);
|
||||
/* BEGIN */
|
||||
__ENDMOD;
|
||||
}
|
||||
28
bootstrap/unix-44/OPS.h
Normal file
28
bootstrap/unix-44/OPS.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin tspkaSfF */
|
||||
|
||||
#ifndef OPS__h
|
||||
#define OPS__h
|
||||
|
||||
#include "SYSTEM.h"
|
||||
|
||||
typedef
|
||||
CHAR OPS_Name[256];
|
||||
|
||||
typedef
|
||||
CHAR OPS_String[256];
|
||||
|
||||
|
||||
import OPS_Name OPS_name;
|
||||
import OPS_String OPS_str;
|
||||
import INTEGER OPS_numtyp;
|
||||
import LONGINT OPS_intval;
|
||||
import REAL OPS_realval;
|
||||
import LONGREAL OPS_lrlval;
|
||||
|
||||
|
||||
import void OPS_Get (SHORTINT *sym);
|
||||
import void OPS_Init (void);
|
||||
import void *OPS__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
1858
bootstrap/unix-44/OPT.c
Normal file
1858
bootstrap/unix-44/OPT.c
Normal file
File diff suppressed because it is too large
Load diff
105
bootstrap/unix-44/OPT.h
Normal file
105
bootstrap/unix-44/OPT.h
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#ifndef OPT__h
|
||||
#define OPT__h
|
||||
|
||||
#include "SYSTEM.h"
|
||||
#include "OPS.h"
|
||||
|
||||
typedef
|
||||
struct OPT_ConstDesc *OPT_Const;
|
||||
|
||||
typedef
|
||||
OPS_String *OPT_ConstExt;
|
||||
|
||||
typedef
|
||||
struct OPT_ConstDesc {
|
||||
OPT_ConstExt ext;
|
||||
LONGINT intval, intval2;
|
||||
SET setval;
|
||||
LONGREAL realval;
|
||||
} OPT_ConstDesc;
|
||||
|
||||
typedef
|
||||
struct OPT_NodeDesc *OPT_Node;
|
||||
|
||||
typedef
|
||||
struct OPT_StrDesc *OPT_Struct;
|
||||
|
||||
typedef
|
||||
struct OPT_ObjDesc *OPT_Object;
|
||||
|
||||
typedef
|
||||
struct OPT_NodeDesc {
|
||||
OPT_Node left, right, link;
|
||||
SHORTINT class, subcl;
|
||||
BOOLEAN readonly;
|
||||
OPT_Struct typ;
|
||||
OPT_Object obj;
|
||||
OPT_Const conval;
|
||||
} OPT_NodeDesc;
|
||||
|
||||
typedef
|
||||
struct OPT_ObjDesc {
|
||||
OPT_Object left, right, link, scope;
|
||||
OPS_Name name;
|
||||
BOOLEAN leaf;
|
||||
SHORTINT mode, mnolev, vis, history;
|
||||
BOOLEAN used, fpdone;
|
||||
LONGINT fprint;
|
||||
OPT_Struct typ;
|
||||
OPT_Const conval;
|
||||
LONGINT adr, linkadr;
|
||||
INTEGER x;
|
||||
} OPT_ObjDesc;
|
||||
|
||||
typedef
|
||||
struct OPT_StrDesc {
|
||||
SHORTINT form, comp, mno, extlev;
|
||||
INTEGER ref, sysflag;
|
||||
LONGINT n, size, align, txtpos;
|
||||
BOOLEAN allocated, pbused, pvused;
|
||||
char _prvt0[8];
|
||||
LONGINT pbfp, pvfp;
|
||||
OPT_Struct BaseTyp;
|
||||
OPT_Object link, strobj;
|
||||
} OPT_StrDesc;
|
||||
|
||||
|
||||
import void (*OPT_typSize)(OPT_Struct);
|
||||
import OPT_Object OPT_topScope;
|
||||
import OPT_Struct OPT_undftyp, OPT_bytetyp, OPT_booltyp, OPT_chartyp, OPT_sinttyp, OPT_inttyp, OPT_linttyp, OPT_realtyp, OPT_lrltyp, OPT_settyp, OPT_stringtyp, OPT_niltyp, OPT_notyp, OPT_sysptrtyp;
|
||||
import SHORTINT OPT_nofGmod;
|
||||
import OPT_Object OPT_GlbMod[64];
|
||||
import OPS_Name OPT_SelfName;
|
||||
import BOOLEAN OPT_SYSimported;
|
||||
|
||||
import LONGINT *OPT_ConstDesc__typ;
|
||||
import LONGINT *OPT_ObjDesc__typ;
|
||||
import LONGINT *OPT_StrDesc__typ;
|
||||
import LONGINT *OPT_NodeDesc__typ;
|
||||
|
||||
import void OPT_Close (void);
|
||||
import void OPT_CloseScope (void);
|
||||
import void OPT_Export (BOOLEAN *ext, BOOLEAN *new);
|
||||
import void OPT_FPrintErr (OPT_Object obj, INTEGER errcode);
|
||||
import void OPT_FPrintObj (OPT_Object obj);
|
||||
import void OPT_FPrintStr (OPT_Struct typ);
|
||||
import void OPT_Find (OPT_Object *res);
|
||||
import void OPT_FindField (OPS_Name name, OPT_Struct typ, OPT_Object *res);
|
||||
import void OPT_FindImport (OPT_Object mod, OPT_Object *res);
|
||||
import void OPT_IdFPrint (OPT_Struct typ);
|
||||
import void OPT_Import (OPS_Name aliasName, OPS_Name name, BOOLEAN *done);
|
||||
import void OPT_Init (OPS_Name name, SET opt);
|
||||
import void OPT_Insert (OPS_Name name, OPT_Object *obj);
|
||||
import void OPT_InsertImport (OPT_Object obj, OPT_Object *root, OPT_Object *old);
|
||||
import OPT_Const OPT_NewConst (void);
|
||||
import OPT_ConstExt OPT_NewExt (void);
|
||||
import OPT_Node OPT_NewNode (SHORTINT class);
|
||||
import OPT_Object OPT_NewObj (void);
|
||||
import OPT_Struct OPT_NewStr (SHORTINT form, SHORTINT comp);
|
||||
import void OPT_OpenScope (SHORTINT level, OPT_Object owner);
|
||||
import void *OPT__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
1688
bootstrap/unix-44/OPV.c
Normal file
1688
bootstrap/unix-44/OPV.c
Normal file
File diff suppressed because it is too large
Load diff
19
bootstrap/unix-44/OPV.h
Normal file
19
bootstrap/unix-44/OPV.h
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#ifndef OPV__h
|
||||
#define OPV__h
|
||||
|
||||
#include "SYSTEM.h"
|
||||
#include "OPT.h"
|
||||
|
||||
|
||||
|
||||
|
||||
import void OPV_AdrAndSize (OPT_Object topScope);
|
||||
import void OPV_Init (void);
|
||||
import void OPV_Module (OPT_Node prog);
|
||||
import void OPV_TypSize (OPT_Struct typ);
|
||||
import void *OPV__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
792
bootstrap/unix-44/Platform.c
Normal file
792
bootstrap/unix-44/Platform.c
Normal file
|
|
@ -0,0 +1,792 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
#include "SYSTEM.h"
|
||||
|
||||
typedef
|
||||
CHAR (*Platform_ArgPtr)[1024];
|
||||
|
||||
typedef
|
||||
Platform_ArgPtr (*Platform_ArgVec)[1024];
|
||||
|
||||
typedef
|
||||
LONGINT (*Platform_ArgVecPtr)[1];
|
||||
|
||||
typedef
|
||||
CHAR (*Platform_EnvPtr)[1024];
|
||||
|
||||
typedef
|
||||
struct Platform_FileIdentity {
|
||||
LONGINT volume, index, mtime;
|
||||
} Platform_FileIdentity;
|
||||
|
||||
typedef
|
||||
void (*Platform_HaltProcedure)(LONGINT);
|
||||
|
||||
typedef
|
||||
void (*Platform_SignalHandler)(INTEGER);
|
||||
|
||||
|
||||
export BOOLEAN Platform_LittleEndian;
|
||||
export LONGINT Platform_MainStackFrame, Platform_HaltCode;
|
||||
export INTEGER Platform_PID;
|
||||
export CHAR Platform_CWD[256];
|
||||
export INTEGER Platform_ArgCount;
|
||||
export LONGINT Platform_ArgVector;
|
||||
static Platform_HaltProcedure Platform_HaltHandler;
|
||||
static LONGINT Platform_TimeStart;
|
||||
export INTEGER Platform_SeekSet, Platform_SeekCur, Platform_SeekEnd;
|
||||
export CHAR Platform_nl[3];
|
||||
|
||||
export LONGINT *Platform_FileIdentity__typ;
|
||||
|
||||
export BOOLEAN Platform_Absent (INTEGER e);
|
||||
export INTEGER Platform_ArgPos (CHAR *s, LONGINT s__len);
|
||||
export void Platform_AssertFail (LONGINT code);
|
||||
export INTEGER Platform_Chdir (CHAR *n, LONGINT n__len);
|
||||
export INTEGER Platform_Close (LONGINT h);
|
||||
export BOOLEAN Platform_ConnectionFailed (INTEGER e);
|
||||
export void Platform_Delay (LONGINT ms);
|
||||
export BOOLEAN Platform_DifferentFilesystems (INTEGER e);
|
||||
static void Platform_DisplayHaltCode (LONGINT code);
|
||||
export INTEGER Platform_Error (void);
|
||||
export void Platform_Exit (INTEGER code);
|
||||
export void Platform_GetArg (INTEGER n, CHAR *val, LONGINT val__len);
|
||||
export void Platform_GetClock (LONGINT *t, LONGINT *d);
|
||||
export void Platform_GetEnv (CHAR *var, LONGINT var__len, CHAR *val, LONGINT val__len);
|
||||
export void Platform_GetIntArg (INTEGER n, LONGINT *val);
|
||||
export void Platform_GetTimeOfDay (LONGINT *sec, LONGINT *usec);
|
||||
export void Platform_Halt (LONGINT code);
|
||||
export INTEGER Platform_Identify (LONGINT h, Platform_FileIdentity *identity, LONGINT *identity__typ);
|
||||
export INTEGER Platform_IdentifyByName (CHAR *n, LONGINT n__len, Platform_FileIdentity *identity, LONGINT *identity__typ);
|
||||
export BOOLEAN Platform_Inaccessible (INTEGER e);
|
||||
export void Platform_Init (INTEGER argc, LONGINT argvadr);
|
||||
export void Platform_MTimeAsClock (Platform_FileIdentity i, LONGINT *t, LONGINT *d);
|
||||
export INTEGER Platform_New (CHAR *n, LONGINT n__len, LONGINT *h);
|
||||
export BOOLEAN Platform_NoSuchDirectory (INTEGER e);
|
||||
export LONGINT Platform_OSAllocate (LONGINT size);
|
||||
export void Platform_OSFree (LONGINT address);
|
||||
export INTEGER Platform_OldRO (CHAR *n, LONGINT n__len, LONGINT *h);
|
||||
export INTEGER Platform_OldRW (CHAR *n, LONGINT n__len, LONGINT *h);
|
||||
export INTEGER Platform_Read (LONGINT h, LONGINT p, LONGINT l, LONGINT *n);
|
||||
export INTEGER Platform_ReadBuf (LONGINT h, SYSTEM_BYTE *b, LONGINT b__len, LONGINT *n);
|
||||
export INTEGER Platform_Rename (CHAR *o, LONGINT o__len, CHAR *n, LONGINT n__len);
|
||||
export BOOLEAN Platform_SameFile (Platform_FileIdentity i1, Platform_FileIdentity i2);
|
||||
export BOOLEAN Platform_SameFileTime (Platform_FileIdentity i1, Platform_FileIdentity i2);
|
||||
export INTEGER Platform_Seek (LONGINT h, LONGINT offset, INTEGER whence);
|
||||
export void Platform_SetBadInstructionHandler (Platform_SignalHandler handler);
|
||||
export void Platform_SetHalt (Platform_HaltProcedure p);
|
||||
export void Platform_SetInterruptHandler (Platform_SignalHandler handler);
|
||||
export void Platform_SetMTime (Platform_FileIdentity *target, LONGINT *target__typ, Platform_FileIdentity source);
|
||||
export void Platform_SetQuitHandler (Platform_SignalHandler handler);
|
||||
export INTEGER Platform_Size (LONGINT h, LONGINT *l);
|
||||
export INTEGER Platform_Sync (LONGINT h);
|
||||
export INTEGER Platform_System (CHAR *cmd, LONGINT cmd__len);
|
||||
static void Platform_TestLittleEndian (void);
|
||||
export LONGINT Platform_Time (void);
|
||||
export BOOLEAN Platform_TimedOut (INTEGER e);
|
||||
export BOOLEAN Platform_TooManyFiles (INTEGER e);
|
||||
export INTEGER Platform_Truncate (LONGINT h, LONGINT l);
|
||||
export INTEGER Platform_Unlink (CHAR *n, LONGINT n__len);
|
||||
export INTEGER Platform_Write (LONGINT h, LONGINT p, LONGINT l);
|
||||
static void Platform_YMDHMStoClock (LONGINT ye, LONGINT mo, LONGINT da, LONGINT ho, LONGINT mi, LONGINT se, LONGINT *t, LONGINT *d);
|
||||
static void Platform_errch (CHAR c);
|
||||
static void Platform_errint (LONGINT l);
|
||||
static void Platform_errln (void);
|
||||
static void Platform_errposint (LONGINT l);
|
||||
export BOOLEAN Platform_getEnv (CHAR *var, LONGINT var__len, CHAR *val, LONGINT val__len);
|
||||
|
||||
#include <errno.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#define Platform_EACCES() EACCES
|
||||
#define Platform_EAGAIN() EAGAIN
|
||||
#define Platform_ECONNABORTED() ECONNABORTED
|
||||
#define Platform_ECONNREFUSED() ECONNREFUSED
|
||||
#define Platform_EHOSTUNREACH() EHOSTUNREACH
|
||||
#define Platform_EMFILE() EMFILE
|
||||
#define Platform_ENETUNREACH() ENETUNREACH
|
||||
#define Platform_ENFILE() ENFILE
|
||||
#define Platform_ENOENT() ENOENT
|
||||
#define Platform_EROFS() EROFS
|
||||
#define Platform_ETIMEDOUT() ETIMEDOUT
|
||||
#define Platform_EXDEV() EXDEV
|
||||
extern void Heap_InitHeap();
|
||||
#define Platform_HeapInitHeap() Heap_InitHeap()
|
||||
#define Platform_allocate(size) (LONGINT)(uintptr_t)((void*)malloc((size_t)size))
|
||||
#define Platform_chdir(n, n__len) chdir((char*)n)
|
||||
#define Platform_closefile(fd) close(fd)
|
||||
#define Platform_err() errno
|
||||
#define Platform_errc(c) write(1, &c, 1)
|
||||
#define Platform_errstring(s, s__len) write(1, s, s__len-1)
|
||||
#define Platform_exit(code) exit(code)
|
||||
#define Platform_free(address) free((void*)(uintptr_t)address)
|
||||
#define Platform_fstat(fd) fstat(fd, &s)
|
||||
#define Platform_fsync(fd) fsync(fd)
|
||||
#define Platform_ftruncate(fd, l) ftruncate(fd, l)
|
||||
#define Platform_getcwd(cwd, cwd__len) getcwd((char*)cwd, cwd__len)
|
||||
#define Platform_getenv(var, var__len) (Platform_EnvPtr)getenv((char*)var)
|
||||
#define Platform_getpid() (INTEGER)getpid()
|
||||
#define Platform_gettimeval() struct timeval tv; gettimeofday(&tv,0)
|
||||
#define Platform_lseek(fd, o, w) lseek(fd, o, w)
|
||||
#define Platform_nanosleep(s, ns) struct timespec req, rem; req.tv_sec = s; req.tv_nsec = ns; nanosleep(&req, &rem)
|
||||
#define Platform_opennew(n, n__len) open((char*)n, O_CREAT | O_TRUNC | O_RDWR, 0664)
|
||||
#define Platform_openro(n, n__len) open((char*)n, O_RDONLY)
|
||||
#define Platform_openrw(n, n__len) open((char*)n, O_RDWR)
|
||||
#define Platform_readfile(fd, p, l) read(fd, (void*)(uintptr_t)(p), l)
|
||||
#define Platform_rename(o, o__len, n, n__len) rename((char*)o, (char*)n)
|
||||
#define Platform_sectotm(s) struct tm *time = localtime((time_t*)&s)
|
||||
#define Platform_seekcur() SEEK_CUR
|
||||
#define Platform_seekend() SEEK_END
|
||||
#define Platform_seekset() SEEK_SET
|
||||
#define Platform_sethandler(s, h) SystemSetHandler(s, (uintptr_t)h)
|
||||
#define Platform_stat(n, n__len) stat((char*)n, &s)
|
||||
#define Platform_statdev() (LONGINT)s.st_dev
|
||||
#define Platform_statino() (LONGINT)s.st_ino
|
||||
#define Platform_statmtime() (LONGINT)s.st_mtime
|
||||
#define Platform_statsize() (LONGINT)s.st_size
|
||||
#define Platform_structstats() struct stat s
|
||||
#define Platform_system(str, str__len) system((char*)str)
|
||||
#define Platform_tmhour() (LONGINT)time->tm_hour
|
||||
#define Platform_tmmday() (LONGINT)time->tm_mday
|
||||
#define Platform_tmmin() (LONGINT)time->tm_min
|
||||
#define Platform_tmmon() (LONGINT)time->tm_mon
|
||||
#define Platform_tmsec() (LONGINT)time->tm_sec
|
||||
#define Platform_tmyear() (LONGINT)time->tm_year
|
||||
#define Platform_tvsec() tv.tv_sec
|
||||
#define Platform_tvusec() tv.tv_usec
|
||||
#define Platform_unlink(n, n__len) unlink((char*)n)
|
||||
#define Platform_writefile(fd, p, l) write(fd, (void*)(uintptr_t)(p), l)
|
||||
|
||||
BOOLEAN Platform_TooManyFiles (INTEGER e)
|
||||
{
|
||||
BOOLEAN _o_result;
|
||||
_o_result = e == Platform_EMFILE() || e == Platform_ENFILE();
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
BOOLEAN Platform_NoSuchDirectory (INTEGER e)
|
||||
{
|
||||
BOOLEAN _o_result;
|
||||
_o_result = e == Platform_ENOENT();
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
BOOLEAN Platform_DifferentFilesystems (INTEGER e)
|
||||
{
|
||||
BOOLEAN _o_result;
|
||||
_o_result = e == Platform_EXDEV();
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
BOOLEAN Platform_Inaccessible (INTEGER e)
|
||||
{
|
||||
BOOLEAN _o_result;
|
||||
_o_result = (e == Platform_EACCES() || e == Platform_EROFS()) || e == Platform_EAGAIN();
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
BOOLEAN Platform_Absent (INTEGER e)
|
||||
{
|
||||
BOOLEAN _o_result;
|
||||
_o_result = e == Platform_ENOENT();
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
BOOLEAN Platform_TimedOut (INTEGER e)
|
||||
{
|
||||
BOOLEAN _o_result;
|
||||
_o_result = e == Platform_ETIMEDOUT();
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
BOOLEAN Platform_ConnectionFailed (INTEGER e)
|
||||
{
|
||||
BOOLEAN _o_result;
|
||||
_o_result = ((e == Platform_ECONNREFUSED() || e == Platform_ECONNABORTED()) || e == Platform_ENETUNREACH()) || e == Platform_EHOSTUNREACH();
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
LONGINT Platform_OSAllocate (LONGINT size)
|
||||
{
|
||||
LONGINT _o_result;
|
||||
_o_result = Platform_allocate(size);
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
void Platform_OSFree (LONGINT address)
|
||||
{
|
||||
Platform_free(address);
|
||||
}
|
||||
|
||||
void Platform_Init (INTEGER argc, LONGINT argvadr)
|
||||
{
|
||||
Platform_ArgVecPtr av = NIL;
|
||||
Platform_MainStackFrame = argvadr;
|
||||
Platform_ArgCount = argc;
|
||||
av = (Platform_ArgVecPtr)(uintptr_t)argvadr;
|
||||
Platform_ArgVector = (*av)[0];
|
||||
Platform_HaltCode = -128;
|
||||
Platform_HeapInitHeap();
|
||||
}
|
||||
|
||||
BOOLEAN Platform_getEnv (CHAR *var, LONGINT var__len, CHAR *val, LONGINT val__len)
|
||||
{
|
||||
BOOLEAN _o_result;
|
||||
Platform_EnvPtr p = NIL;
|
||||
__DUP(var, var__len, CHAR);
|
||||
p = Platform_getenv(var, var__len);
|
||||
if (p != NIL) {
|
||||
__COPY(*p, val, val__len);
|
||||
}
|
||||
_o_result = p != NIL;
|
||||
__DEL(var);
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
void Platform_GetEnv (CHAR *var, LONGINT var__len, CHAR *val, LONGINT val__len)
|
||||
{
|
||||
__DUP(var, var__len, CHAR);
|
||||
if (!Platform_getEnv(var, var__len, (void*)val, val__len)) {
|
||||
val[0] = 0x00;
|
||||
}
|
||||
__DEL(var);
|
||||
}
|
||||
|
||||
void Platform_GetArg (INTEGER n, CHAR *val, LONGINT val__len)
|
||||
{
|
||||
Platform_ArgVec av = NIL;
|
||||
if (n < Platform_ArgCount) {
|
||||
av = (Platform_ArgVec)(uintptr_t)Platform_ArgVector;
|
||||
__COPY(*(*av)[__X(n, ((LONGINT)(1024)))], val, val__len);
|
||||
}
|
||||
}
|
||||
|
||||
void Platform_GetIntArg (INTEGER n, LONGINT *val)
|
||||
{
|
||||
CHAR s[64];
|
||||
LONGINT k, d, i;
|
||||
s[0] = 0x00;
|
||||
Platform_GetArg(n, (void*)s, ((LONGINT)(64)));
|
||||
i = 0;
|
||||
if (s[0] == '-') {
|
||||
i = 1;
|
||||
}
|
||||
k = 0;
|
||||
d = (int)s[__X(i, ((LONGINT)(64)))] - 48;
|
||||
while ((d >= 0 && d <= 9)) {
|
||||
k = k * 10 + d;
|
||||
i += 1;
|
||||
d = (int)s[__X(i, ((LONGINT)(64)))] - 48;
|
||||
}
|
||||
if (s[0] == '-') {
|
||||
k = -k;
|
||||
i -= 1;
|
||||
}
|
||||
if (i > 0) {
|
||||
*val = k;
|
||||
}
|
||||
}
|
||||
|
||||
INTEGER Platform_ArgPos (CHAR *s, LONGINT s__len)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
INTEGER i;
|
||||
CHAR arg[256];
|
||||
__DUP(s, s__len, CHAR);
|
||||
i = 0;
|
||||
Platform_GetArg(i, (void*)arg, ((LONGINT)(256)));
|
||||
while ((i < Platform_ArgCount && __STRCMP(s, arg) != 0)) {
|
||||
i += 1;
|
||||
Platform_GetArg(i, (void*)arg, ((LONGINT)(256)));
|
||||
}
|
||||
_o_result = i;
|
||||
__DEL(s);
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
void Platform_SetInterruptHandler (Platform_SignalHandler handler)
|
||||
{
|
||||
Platform_sethandler(2, handler);
|
||||
}
|
||||
|
||||
void Platform_SetQuitHandler (Platform_SignalHandler handler)
|
||||
{
|
||||
Platform_sethandler(3, handler);
|
||||
}
|
||||
|
||||
void Platform_SetBadInstructionHandler (Platform_SignalHandler handler)
|
||||
{
|
||||
Platform_sethandler(4, handler);
|
||||
}
|
||||
|
||||
static void Platform_YMDHMStoClock (LONGINT ye, LONGINT mo, LONGINT da, LONGINT ho, LONGINT mi, LONGINT se, LONGINT *t, LONGINT *d)
|
||||
{
|
||||
*d = (__ASHL(__MOD(ye, 100), 9) + __ASHL(mo + 1, 5)) + da;
|
||||
*t = (__ASHL(ho, 12) + __ASHL(mi, 6)) + se;
|
||||
}
|
||||
|
||||
void Platform_GetClock (LONGINT *t, LONGINT *d)
|
||||
{
|
||||
Platform_gettimeval();
|
||||
Platform_sectotm(Platform_tvsec());
|
||||
Platform_YMDHMStoClock(Platform_tmyear(), Platform_tmmon(), Platform_tmmday(), Platform_tmhour(), Platform_tmmin(), Platform_tmsec(), &*t, &*d);
|
||||
}
|
||||
|
||||
void Platform_GetTimeOfDay (LONGINT *sec, LONGINT *usec)
|
||||
{
|
||||
Platform_gettimeval();
|
||||
*sec = Platform_tvsec();
|
||||
*usec = Platform_tvusec();
|
||||
}
|
||||
|
||||
LONGINT Platform_Time (void)
|
||||
{
|
||||
LONGINT _o_result;
|
||||
LONGINT ms;
|
||||
Platform_gettimeval();
|
||||
ms = __DIVF(Platform_tvusec(), 1000) + Platform_tvsec() * 1000;
|
||||
_o_result = __MOD(ms - Platform_TimeStart, 2147483647);
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
void Platform_Delay (LONGINT ms)
|
||||
{
|
||||
LONGINT s, ns;
|
||||
s = __DIV(ms, 1000);
|
||||
ns = __MOD(ms, 1000) * 1000000;
|
||||
Platform_nanosleep(s, ns);
|
||||
}
|
||||
|
||||
INTEGER Platform_System (CHAR *cmd, LONGINT cmd__len)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
__DUP(cmd, cmd__len, CHAR);
|
||||
_o_result = Platform_system(cmd, cmd__len);
|
||||
__DEL(cmd);
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
INTEGER Platform_Error (void)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
_o_result = Platform_err();
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
INTEGER Platform_OldRO (CHAR *n, LONGINT n__len, LONGINT *h)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
INTEGER fd;
|
||||
fd = Platform_openro(n, n__len);
|
||||
if (fd < 0) {
|
||||
_o_result = Platform_err();
|
||||
return _o_result;
|
||||
} else {
|
||||
*h = fd;
|
||||
_o_result = 0;
|
||||
return _o_result;
|
||||
}
|
||||
__RETCHK;
|
||||
}
|
||||
|
||||
INTEGER Platform_OldRW (CHAR *n, LONGINT n__len, LONGINT *h)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
INTEGER fd;
|
||||
fd = Platform_openrw(n, n__len);
|
||||
if (fd < 0) {
|
||||
_o_result = Platform_err();
|
||||
return _o_result;
|
||||
} else {
|
||||
*h = fd;
|
||||
_o_result = 0;
|
||||
return _o_result;
|
||||
}
|
||||
__RETCHK;
|
||||
}
|
||||
|
||||
INTEGER Platform_New (CHAR *n, LONGINT n__len, LONGINT *h)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
INTEGER fd;
|
||||
fd = Platform_opennew(n, n__len);
|
||||
if (fd < 0) {
|
||||
_o_result = Platform_err();
|
||||
return _o_result;
|
||||
} else {
|
||||
*h = fd;
|
||||
_o_result = 0;
|
||||
return _o_result;
|
||||
}
|
||||
__RETCHK;
|
||||
}
|
||||
|
||||
INTEGER Platform_Close (LONGINT h)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
if (Platform_closefile(h) < 0) {
|
||||
_o_result = Platform_err();
|
||||
return _o_result;
|
||||
} else {
|
||||
_o_result = 0;
|
||||
return _o_result;
|
||||
}
|
||||
__RETCHK;
|
||||
}
|
||||
|
||||
INTEGER Platform_Identify (LONGINT h, Platform_FileIdentity *identity, LONGINT *identity__typ)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
Platform_structstats();
|
||||
if (Platform_fstat(h) < 0) {
|
||||
_o_result = Platform_err();
|
||||
return _o_result;
|
||||
}
|
||||
(*identity).volume = Platform_statdev();
|
||||
(*identity).index = Platform_statino();
|
||||
(*identity).mtime = Platform_statmtime();
|
||||
_o_result = 0;
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
INTEGER Platform_IdentifyByName (CHAR *n, LONGINT n__len, Platform_FileIdentity *identity, LONGINT *identity__typ)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
__DUP(n, n__len, CHAR);
|
||||
Platform_structstats();
|
||||
if (Platform_stat(n, n__len) < 0) {
|
||||
_o_result = Platform_err();
|
||||
__DEL(n);
|
||||
return _o_result;
|
||||
}
|
||||
(*identity).volume = Platform_statdev();
|
||||
(*identity).index = Platform_statino();
|
||||
(*identity).mtime = Platform_statmtime();
|
||||
_o_result = 0;
|
||||
__DEL(n);
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
BOOLEAN Platform_SameFile (Platform_FileIdentity i1, Platform_FileIdentity i2)
|
||||
{
|
||||
BOOLEAN _o_result;
|
||||
_o_result = (i1.index == i2.index && i1.volume == i2.volume);
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
BOOLEAN Platform_SameFileTime (Platform_FileIdentity i1, Platform_FileIdentity i2)
|
||||
{
|
||||
BOOLEAN _o_result;
|
||||
_o_result = i1.mtime == i2.mtime;
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
void Platform_SetMTime (Platform_FileIdentity *target, LONGINT *target__typ, Platform_FileIdentity source)
|
||||
{
|
||||
(*target).mtime = source.mtime;
|
||||
}
|
||||
|
||||
void Platform_MTimeAsClock (Platform_FileIdentity i, LONGINT *t, LONGINT *d)
|
||||
{
|
||||
Platform_sectotm(i.mtime);
|
||||
Platform_YMDHMStoClock(Platform_tmyear(), Platform_tmmon(), Platform_tmmday(), Platform_tmhour(), Platform_tmmin(), Platform_tmsec(), &*t, &*d);
|
||||
}
|
||||
|
||||
INTEGER Platform_Size (LONGINT h, LONGINT *l)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
Platform_structstats();
|
||||
if (Platform_fstat(h) < 0) {
|
||||
_o_result = Platform_err();
|
||||
return _o_result;
|
||||
}
|
||||
*l = Platform_statsize();
|
||||
_o_result = 0;
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
INTEGER Platform_Read (LONGINT h, LONGINT p, LONGINT l, LONGINT *n)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
*n = Platform_readfile(h, p, l);
|
||||
if (*n < 0) {
|
||||
*n = 0;
|
||||
_o_result = Platform_err();
|
||||
return _o_result;
|
||||
} else {
|
||||
_o_result = 0;
|
||||
return _o_result;
|
||||
}
|
||||
__RETCHK;
|
||||
}
|
||||
|
||||
INTEGER Platform_ReadBuf (LONGINT h, SYSTEM_BYTE *b, LONGINT b__len, LONGINT *n)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
*n = Platform_readfile(h, (LONGINT)(uintptr_t)b, b__len);
|
||||
if (*n < 0) {
|
||||
*n = 0;
|
||||
_o_result = Platform_err();
|
||||
return _o_result;
|
||||
} else {
|
||||
_o_result = 0;
|
||||
return _o_result;
|
||||
}
|
||||
__RETCHK;
|
||||
}
|
||||
|
||||
INTEGER Platform_Write (LONGINT h, LONGINT p, LONGINT l)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
LONGINT written;
|
||||
written = Platform_writefile(h, p, l);
|
||||
if (written < 0) {
|
||||
_o_result = Platform_err();
|
||||
return _o_result;
|
||||
} else {
|
||||
_o_result = 0;
|
||||
return _o_result;
|
||||
}
|
||||
__RETCHK;
|
||||
}
|
||||
|
||||
INTEGER Platform_Sync (LONGINT h)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
if (Platform_fsync(h) < 0) {
|
||||
_o_result = Platform_err();
|
||||
return _o_result;
|
||||
} else {
|
||||
_o_result = 0;
|
||||
return _o_result;
|
||||
}
|
||||
__RETCHK;
|
||||
}
|
||||
|
||||
INTEGER Platform_Seek (LONGINT h, LONGINT offset, INTEGER whence)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
if (Platform_lseek(h, offset, whence) < 0) {
|
||||
_o_result = Platform_err();
|
||||
return _o_result;
|
||||
} else {
|
||||
_o_result = 0;
|
||||
return _o_result;
|
||||
}
|
||||
__RETCHK;
|
||||
}
|
||||
|
||||
INTEGER Platform_Truncate (LONGINT h, LONGINT l)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
if (Platform_ftruncate(h, l) < 0) {
|
||||
_o_result = Platform_err();
|
||||
return _o_result;
|
||||
} else {
|
||||
_o_result = 0;
|
||||
return _o_result;
|
||||
}
|
||||
__RETCHK;
|
||||
}
|
||||
|
||||
INTEGER Platform_Unlink (CHAR *n, LONGINT n__len)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
if (Platform_unlink(n, n__len) < 0) {
|
||||
_o_result = Platform_err();
|
||||
return _o_result;
|
||||
} else {
|
||||
_o_result = 0;
|
||||
return _o_result;
|
||||
}
|
||||
__RETCHK;
|
||||
}
|
||||
|
||||
INTEGER Platform_Chdir (CHAR *n, LONGINT n__len)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
INTEGER r;
|
||||
r = Platform_chdir(n, n__len);
|
||||
Platform_getcwd((void*)Platform_CWD, ((LONGINT)(256)));
|
||||
if (r < 0) {
|
||||
_o_result = Platform_err();
|
||||
return _o_result;
|
||||
} else {
|
||||
_o_result = 0;
|
||||
return _o_result;
|
||||
}
|
||||
__RETCHK;
|
||||
}
|
||||
|
||||
INTEGER Platform_Rename (CHAR *o, LONGINT o__len, CHAR *n, LONGINT n__len)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
if (Platform_rename(o, o__len, n, n__len) < 0) {
|
||||
_o_result = Platform_err();
|
||||
return _o_result;
|
||||
} else {
|
||||
_o_result = 0;
|
||||
return _o_result;
|
||||
}
|
||||
__RETCHK;
|
||||
}
|
||||
|
||||
void Platform_Exit (INTEGER code)
|
||||
{
|
||||
Platform_exit(code);
|
||||
}
|
||||
|
||||
static void Platform_errch (CHAR c)
|
||||
{
|
||||
Platform_errc(c);
|
||||
}
|
||||
|
||||
static void Platform_errln (void)
|
||||
{
|
||||
Platform_errch(0x0d);
|
||||
Platform_errch(0x0a);
|
||||
}
|
||||
|
||||
static void Platform_errposint (LONGINT l)
|
||||
{
|
||||
if (l > 10) {
|
||||
Platform_errposint(__DIV(l, 10));
|
||||
}
|
||||
Platform_errch((CHAR)(48 + __MOD(l, 10)));
|
||||
}
|
||||
|
||||
static void Platform_errint (LONGINT l)
|
||||
{
|
||||
if (l < 0) {
|
||||
Platform_errch('-');
|
||||
l = -l;
|
||||
}
|
||||
Platform_errposint(l);
|
||||
}
|
||||
|
||||
static void Platform_DisplayHaltCode (LONGINT code)
|
||||
{
|
||||
switch (code) {
|
||||
case -1:
|
||||
Platform_errstring((CHAR*)"Assertion failure.", (LONGINT)19);
|
||||
break;
|
||||
case -2:
|
||||
Platform_errstring((CHAR*)"Index out of range.", (LONGINT)20);
|
||||
break;
|
||||
case -3:
|
||||
Platform_errstring((CHAR*)"Reached end of function without reaching RETURN.", (LONGINT)49);
|
||||
break;
|
||||
case -4:
|
||||
Platform_errstring((CHAR*)"CASE statement: no matching label and no ELSE.", (LONGINT)47);
|
||||
break;
|
||||
case -5:
|
||||
Platform_errstring((CHAR*)"Type guard failed.", (LONGINT)19);
|
||||
break;
|
||||
case -6:
|
||||
Platform_errstring((CHAR*)"Implicit type guard in record assignment failed.", (LONGINT)49);
|
||||
break;
|
||||
case -7:
|
||||
Platform_errstring((CHAR*)"Invalid case in WITH statement.", (LONGINT)32);
|
||||
break;
|
||||
case -8:
|
||||
Platform_errstring((CHAR*)"Value out of range.", (LONGINT)20);
|
||||
break;
|
||||
case -9:
|
||||
Platform_errstring((CHAR*)"Heap interrupted while locked, but lockdepth = 0 at unlock.", (LONGINT)60);
|
||||
break;
|
||||
case -10:
|
||||
Platform_errstring((CHAR*)"NIL access.", (LONGINT)12);
|
||||
break;
|
||||
case -11:
|
||||
Platform_errstring((CHAR*)"Alignment error.", (LONGINT)17);
|
||||
break;
|
||||
case -12:
|
||||
Platform_errstring((CHAR*)"Divide by zero.", (LONGINT)16);
|
||||
break;
|
||||
case -13:
|
||||
Platform_errstring((CHAR*)"Arithmetic overflow/underflow.", (LONGINT)31);
|
||||
break;
|
||||
case -14:
|
||||
Platform_errstring((CHAR*)"Invalid function argument.", (LONGINT)27);
|
||||
break;
|
||||
case -15:
|
||||
Platform_errstring((CHAR*)"Internal error, e.g. Type descriptor size mismatch.", (LONGINT)52);
|
||||
break;
|
||||
case -20:
|
||||
Platform_errstring((CHAR*)"Too many, or negative number of, elements in dynamic array.", (LONGINT)60);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Platform_Halt (LONGINT code)
|
||||
{
|
||||
INTEGER e;
|
||||
Platform_HaltCode = code;
|
||||
if (Platform_HaltHandler != NIL) {
|
||||
(*Platform_HaltHandler)(code);
|
||||
}
|
||||
Platform_errstring((CHAR*)"Terminated by Halt(", (LONGINT)20);
|
||||
Platform_errint(code);
|
||||
Platform_errstring((CHAR*)"). ", (LONGINT)4);
|
||||
if (code < 0) {
|
||||
Platform_DisplayHaltCode(code);
|
||||
}
|
||||
Platform_errln();
|
||||
Platform_exit(__VAL(INTEGER, code));
|
||||
}
|
||||
|
||||
void Platform_AssertFail (LONGINT code)
|
||||
{
|
||||
INTEGER e;
|
||||
Platform_errstring((CHAR*)"Assertion failure.", (LONGINT)19);
|
||||
if (code != 0) {
|
||||
Platform_errstring((CHAR*)" ASSERT code ", (LONGINT)14);
|
||||
Platform_errint(code);
|
||||
Platform_errstring((CHAR*)".", (LONGINT)2);
|
||||
}
|
||||
Platform_errln();
|
||||
Platform_exit(__VAL(INTEGER, code));
|
||||
}
|
||||
|
||||
void Platform_SetHalt (Platform_HaltProcedure p)
|
||||
{
|
||||
Platform_HaltHandler = p;
|
||||
}
|
||||
|
||||
static void Platform_TestLittleEndian (void)
|
||||
{
|
||||
INTEGER i;
|
||||
i = 1;
|
||||
__GET((LONGINT)(uintptr_t)&i, Platform_LittleEndian, BOOLEAN);
|
||||
}
|
||||
|
||||
__TDESC(Platform_FileIdentity, 1, 0) = {__TDFLDS("FileIdentity", 12), {-4}};
|
||||
|
||||
export void *Platform__init(void)
|
||||
{
|
||||
__DEFMOD;
|
||||
__REGMOD("Platform", 0);
|
||||
__INITYP(Platform_FileIdentity, Platform_FileIdentity, 0);
|
||||
/* BEGIN */
|
||||
Platform_TestLittleEndian();
|
||||
Platform_HaltCode = -128;
|
||||
Platform_HaltHandler = NIL;
|
||||
Platform_TimeStart = Platform_Time();
|
||||
Platform_CWD[0] = 0x00;
|
||||
Platform_getcwd((void*)Platform_CWD, ((LONGINT)(256)));
|
||||
Platform_PID = Platform_getpid();
|
||||
Platform_SeekSet = Platform_seekset();
|
||||
Platform_SeekCur = Platform_seekcur();
|
||||
Platform_SeekEnd = Platform_seekend();
|
||||
Platform_nl[0] = 0x0a;
|
||||
Platform_nl[1] = 0x00;
|
||||
__ENDMOD;
|
||||
}
|
||||
82
bootstrap/unix-44/Platform.h
Normal file
82
bootstrap/unix-44/Platform.h
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#ifndef Platform__h
|
||||
#define Platform__h
|
||||
|
||||
#include "SYSTEM.h"
|
||||
|
||||
typedef
|
||||
struct Platform_FileIdentity {
|
||||
LONGINT volume, index, mtime;
|
||||
} Platform_FileIdentity;
|
||||
|
||||
typedef
|
||||
void (*Platform_HaltProcedure)(LONGINT);
|
||||
|
||||
typedef
|
||||
void (*Platform_SignalHandler)(INTEGER);
|
||||
|
||||
|
||||
import BOOLEAN Platform_LittleEndian;
|
||||
import LONGINT Platform_MainStackFrame, Platform_HaltCode;
|
||||
import INTEGER Platform_PID;
|
||||
import CHAR Platform_CWD[256];
|
||||
import INTEGER Platform_ArgCount;
|
||||
import LONGINT Platform_ArgVector;
|
||||
import INTEGER Platform_SeekSet, Platform_SeekCur, Platform_SeekEnd;
|
||||
import CHAR Platform_nl[3];
|
||||
|
||||
import LONGINT *Platform_FileIdentity__typ;
|
||||
|
||||
import BOOLEAN Platform_Absent (INTEGER e);
|
||||
import INTEGER Platform_ArgPos (CHAR *s, LONGINT s__len);
|
||||
import void Platform_AssertFail (LONGINT code);
|
||||
import INTEGER Platform_Chdir (CHAR *n, LONGINT n__len);
|
||||
import INTEGER Platform_Close (LONGINT h);
|
||||
import BOOLEAN Platform_ConnectionFailed (INTEGER e);
|
||||
import void Platform_Delay (LONGINT ms);
|
||||
import BOOLEAN Platform_DifferentFilesystems (INTEGER e);
|
||||
import INTEGER Platform_Error (void);
|
||||
import void Platform_Exit (INTEGER code);
|
||||
import void Platform_GetArg (INTEGER n, CHAR *val, LONGINT val__len);
|
||||
import void Platform_GetClock (LONGINT *t, LONGINT *d);
|
||||
import void Platform_GetEnv (CHAR *var, LONGINT var__len, CHAR *val, LONGINT val__len);
|
||||
import void Platform_GetIntArg (INTEGER n, LONGINT *val);
|
||||
import void Platform_GetTimeOfDay (LONGINT *sec, LONGINT *usec);
|
||||
import void Platform_Halt (LONGINT code);
|
||||
import INTEGER Platform_Identify (LONGINT h, Platform_FileIdentity *identity, LONGINT *identity__typ);
|
||||
import INTEGER Platform_IdentifyByName (CHAR *n, LONGINT n__len, Platform_FileIdentity *identity, LONGINT *identity__typ);
|
||||
import BOOLEAN Platform_Inaccessible (INTEGER e);
|
||||
import void Platform_Init (INTEGER argc, LONGINT argvadr);
|
||||
import void Platform_MTimeAsClock (Platform_FileIdentity i, LONGINT *t, LONGINT *d);
|
||||
import INTEGER Platform_New (CHAR *n, LONGINT n__len, LONGINT *h);
|
||||
import BOOLEAN Platform_NoSuchDirectory (INTEGER e);
|
||||
import LONGINT Platform_OSAllocate (LONGINT size);
|
||||
import void Platform_OSFree (LONGINT address);
|
||||
import INTEGER Platform_OldRO (CHAR *n, LONGINT n__len, LONGINT *h);
|
||||
import INTEGER Platform_OldRW (CHAR *n, LONGINT n__len, LONGINT *h);
|
||||
import INTEGER Platform_Read (LONGINT h, LONGINT p, LONGINT l, LONGINT *n);
|
||||
import INTEGER Platform_ReadBuf (LONGINT h, SYSTEM_BYTE *b, LONGINT b__len, LONGINT *n);
|
||||
import INTEGER Platform_Rename (CHAR *o, LONGINT o__len, CHAR *n, LONGINT n__len);
|
||||
import BOOLEAN Platform_SameFile (Platform_FileIdentity i1, Platform_FileIdentity i2);
|
||||
import BOOLEAN Platform_SameFileTime (Platform_FileIdentity i1, Platform_FileIdentity i2);
|
||||
import INTEGER Platform_Seek (LONGINT h, LONGINT offset, INTEGER whence);
|
||||
import void Platform_SetBadInstructionHandler (Platform_SignalHandler handler);
|
||||
import void Platform_SetHalt (Platform_HaltProcedure p);
|
||||
import void Platform_SetInterruptHandler (Platform_SignalHandler handler);
|
||||
import void Platform_SetMTime (Platform_FileIdentity *target, LONGINT *target__typ, Platform_FileIdentity source);
|
||||
import void Platform_SetQuitHandler (Platform_SignalHandler handler);
|
||||
import INTEGER Platform_Size (LONGINT h, LONGINT *l);
|
||||
import INTEGER Platform_Sync (LONGINT h);
|
||||
import INTEGER Platform_System (CHAR *cmd, LONGINT cmd__len);
|
||||
import LONGINT Platform_Time (void);
|
||||
import BOOLEAN Platform_TimedOut (INTEGER e);
|
||||
import BOOLEAN Platform_TooManyFiles (INTEGER e);
|
||||
import INTEGER Platform_Truncate (LONGINT h, LONGINT l);
|
||||
import INTEGER Platform_Unlink (CHAR *n, LONGINT n__len);
|
||||
import INTEGER Platform_Write (LONGINT h, LONGINT p, LONGINT l);
|
||||
import BOOLEAN Platform_getEnv (CHAR *var, LONGINT var__len, CHAR *val, LONGINT val__len);
|
||||
import void *Platform__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
155
bootstrap/unix-44/Reals.c
Normal file
155
bootstrap/unix-44/Reals.c
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
#include "SYSTEM.h"
|
||||
|
||||
|
||||
|
||||
|
||||
export void Reals_Convert (REAL x, INTEGER n, CHAR *d, LONGINT d__len);
|
||||
export void Reals_ConvertH (REAL y, CHAR *d, LONGINT d__len);
|
||||
export void Reals_ConvertHL (LONGREAL y, CHAR *d, LONGINT d__len);
|
||||
export void Reals_ConvertL (LONGREAL x, INTEGER n, CHAR *d, LONGINT d__len);
|
||||
export INTEGER Reals_Expo (REAL x);
|
||||
export INTEGER Reals_ExpoL (LONGREAL x);
|
||||
export REAL Reals_Ten (INTEGER e);
|
||||
export LONGREAL Reals_TenL (INTEGER e);
|
||||
static CHAR Reals_ToHex (INTEGER i);
|
||||
|
||||
|
||||
REAL Reals_Ten (INTEGER e)
|
||||
{
|
||||
REAL _o_result;
|
||||
LONGREAL r, power;
|
||||
r = (LONGREAL)1;
|
||||
power = (LONGREAL)10;
|
||||
while (e > 0) {
|
||||
if (__ODD(e)) {
|
||||
r = r * power;
|
||||
}
|
||||
power = power * power;
|
||||
e = __ASHR(e, 1);
|
||||
}
|
||||
_o_result = r;
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
LONGREAL Reals_TenL (INTEGER e)
|
||||
{
|
||||
LONGREAL _o_result;
|
||||
LONGREAL r, power;
|
||||
r = (LONGREAL)1;
|
||||
power = (LONGREAL)10;
|
||||
for (;;) {
|
||||
if (__ODD(e)) {
|
||||
r = r * power;
|
||||
}
|
||||
e = __ASHR(e, 1);
|
||||
if (e <= 0) {
|
||||
_o_result = r;
|
||||
return _o_result;
|
||||
}
|
||||
power = power * power;
|
||||
}
|
||||
__RETCHK;
|
||||
}
|
||||
|
||||
INTEGER Reals_Expo (REAL x)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
_o_result = (int)__MASK(__ASHR((LONGINT)(__VAL(INTEGER, x)), 23), -256);
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
INTEGER Reals_ExpoL (LONGREAL x)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
INTEGER i;
|
||||
LONGINT l;
|
||||
__GET((LONGINT)(uintptr_t)&x + 4, l, LONGINT);
|
||||
_o_result = (int)__MASK(__ASHR(l, 20), -2048);
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
void Reals_ConvertL (LONGREAL x, INTEGER n, CHAR *d, LONGINT d__len)
|
||||
{
|
||||
LONGINT i, j, k;
|
||||
if (x < (LONGREAL)0) {
|
||||
x = -x;
|
||||
}
|
||||
k = 0;
|
||||
if (n > 9) {
|
||||
i = __ENTIER(x / (LONGREAL)(LONGREAL)1000000000);
|
||||
j = __ENTIER(x - i * (LONGREAL)1000000000);
|
||||
if (j < 0) {
|
||||
j = 0;
|
||||
}
|
||||
while (k < 9) {
|
||||
d[__X(k, d__len)] = (CHAR)(__MOD(j, 10) + 48);
|
||||
j = __DIV(j, 10);
|
||||
k += 1;
|
||||
}
|
||||
} else {
|
||||
i = __ENTIER(x);
|
||||
}
|
||||
while (k < (LONGINT)n) {
|
||||
d[__X(k, d__len)] = (CHAR)(__MOD(i, 10) + 48);
|
||||
i = __DIV(i, 10);
|
||||
k += 1;
|
||||
}
|
||||
}
|
||||
|
||||
void Reals_Convert (REAL x, INTEGER n, CHAR *d, LONGINT d__len)
|
||||
{
|
||||
Reals_ConvertL(x, n, (void*)d, d__len);
|
||||
}
|
||||
|
||||
static CHAR Reals_ToHex (INTEGER i)
|
||||
{
|
||||
CHAR _o_result;
|
||||
if (i < 10) {
|
||||
_o_result = (CHAR)(i + 48);
|
||||
return _o_result;
|
||||
} else {
|
||||
_o_result = (CHAR)(i + 55);
|
||||
return _o_result;
|
||||
}
|
||||
__RETCHK;
|
||||
}
|
||||
|
||||
typedef
|
||||
CHAR (*pc4__3)[4];
|
||||
|
||||
void Reals_ConvertH (REAL y, CHAR *d, LONGINT d__len)
|
||||
{
|
||||
pc4__3 p = NIL;
|
||||
INTEGER i;
|
||||
p = (pc4__3)(uintptr_t)((LONGINT)(uintptr_t)&y);
|
||||
i = 0;
|
||||
while (i < 4) {
|
||||
d[__X(__ASHL(i, 1), d__len)] = Reals_ToHex(__ASHR((int)(*p)[__X(i, ((LONGINT)(4)))], 4));
|
||||
d[__X(__ASHL(i, 1) + 1, d__len)] = Reals_ToHex(__MASK((int)(*p)[__X(i, ((LONGINT)(4)))], -16));
|
||||
}
|
||||
}
|
||||
|
||||
typedef
|
||||
CHAR (*pc8__5)[8];
|
||||
|
||||
void Reals_ConvertHL (LONGREAL y, CHAR *d, LONGINT d__len)
|
||||
{
|
||||
pc8__5 p = NIL;
|
||||
INTEGER i;
|
||||
p = (pc8__5)(uintptr_t)((LONGINT)(uintptr_t)&y);
|
||||
i = 0;
|
||||
while (i < 8) {
|
||||
d[__X(__ASHL(i, 1), d__len)] = Reals_ToHex(__ASHR((int)(*p)[__X(i, ((LONGINT)(8)))], 4));
|
||||
d[__X(__ASHL(i, 1) + 1, d__len)] = Reals_ToHex(__MASK((int)(*p)[__X(i, ((LONGINT)(8)))], -16));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export void *Reals__init(void)
|
||||
{
|
||||
__DEFMOD;
|
||||
__REGMOD("Reals", 0);
|
||||
/* BEGIN */
|
||||
__ENDMOD;
|
||||
}
|
||||
22
bootstrap/unix-44/Reals.h
Normal file
22
bootstrap/unix-44/Reals.h
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#ifndef Reals__h
|
||||
#define Reals__h
|
||||
|
||||
#include "SYSTEM.h"
|
||||
|
||||
|
||||
|
||||
|
||||
import void Reals_Convert (REAL x, INTEGER n, CHAR *d, LONGINT d__len);
|
||||
import void Reals_ConvertH (REAL y, CHAR *d, LONGINT d__len);
|
||||
import void Reals_ConvertHL (LONGREAL y, CHAR *d, LONGINT d__len);
|
||||
import void Reals_ConvertL (LONGREAL x, INTEGER n, CHAR *d, LONGINT d__len);
|
||||
import INTEGER Reals_Expo (REAL x);
|
||||
import INTEGER Reals_ExpoL (LONGREAL x);
|
||||
import REAL Reals_Ten (INTEGER e);
|
||||
import LONGREAL Reals_TenL (INTEGER e);
|
||||
import void *Reals__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
207
bootstrap/unix-44/SYSTEM.c
Normal file
207
bootstrap/unix-44/SYSTEM.c
Normal file
|
|
@ -0,0 +1,207 @@
|
|||
/*
|
||||
* The body prefix file of the voc(jet backend) runtime system, Version 1.0
|
||||
*
|
||||
* Copyright (c) Software Templ, 1994, 1995
|
||||
*
|
||||
* Module SYSTEM is subject to change any time without prior notification.
|
||||
* Software Templ disclaims all warranties with regard to module SYSTEM,
|
||||
* in particular shall Software Templ not be liable for any damage resulting
|
||||
* from inappropriate use or modification of module SYSTEM.
|
||||
*
|
||||
* Version 1.1 jt, 24.11.95 fixes for correct pointer arithmetic on Cray computers
|
||||
* jt 31.1.2007 ANSI prototypes for malloc and exit in order to avoid cc warnings
|
||||
*
|
||||
*/
|
||||
|
||||
#include "SYSTEM.h"
|
||||
#include "stdarg.h"
|
||||
#include <signal.h>
|
||||
|
||||
|
||||
LONGINT SYSTEM_XCHK(LONGINT i, LONGINT ub) {return __X(i, ub);}
|
||||
LONGINT SYSTEM_RCHK(LONGINT i, LONGINT ub) {return __R(i, ub);}
|
||||
LONGINT SYSTEM_ASH (LONGINT i, LONGINT n) {return __ASH(i, n);}
|
||||
LONGINT SYSTEM_ABS (LONGINT i) {return __ABS(i);}
|
||||
double SYSTEM_ABSD(double i) {return __ABS(i);}
|
||||
|
||||
void SYSTEM_INHERIT(LONGINT *t, LONGINT *t0)
|
||||
{
|
||||
t -= __TPROC0OFF;
|
||||
t0 -= __TPROC0OFF;
|
||||
while (*t0 != __EOM) {*t = *t0; t--; t0--;}
|
||||
}
|
||||
|
||||
|
||||
void SYSTEM_ENUMP(void *adr, LONGINT n, void (*P)())
|
||||
{
|
||||
while (n > 0) {
|
||||
P((LONGINT)(uintptr_t)(*((void**)(adr))));
|
||||
adr = ((void**)adr) + 1;
|
||||
n--;
|
||||
}
|
||||
}
|
||||
|
||||
void SYSTEM_ENUMR(void *adr, LONGINT *typ, LONGINT size, LONGINT n, void (*P)())
|
||||
{
|
||||
LONGINT *t, off;
|
||||
typ++;
|
||||
while (n > 0) {
|
||||
t = typ;
|
||||
off = *t;
|
||||
while (off >= 0) {P(*(LONGINT*)((char*)adr+off)); t++; off = *t;}
|
||||
adr = ((char*)adr) + size;
|
||||
n--;
|
||||
}
|
||||
}
|
||||
|
||||
LONGINT SYSTEM_DIV(unsigned LONGINT x, unsigned LONGINT y)
|
||||
{ if ((LONGINT) x >= 0) return (x / y);
|
||||
else return -((y - 1 - x) / y);
|
||||
}
|
||||
|
||||
LONGINT SYSTEM_MOD(unsigned LONGINT x, unsigned LONGINT y)
|
||||
{ unsigned LONGINT m;
|
||||
if ((LONGINT) x >= 0) return (x % y);
|
||||
else { m = (-x) % y;
|
||||
if (m != 0) return (y - m); else return 0;
|
||||
}
|
||||
}
|
||||
|
||||
LONGINT SYSTEM_ENTIER(double x)
|
||||
{
|
||||
LONGINT y;
|
||||
if (x >= 0)
|
||||
return (LONGINT)x;
|
||||
else {
|
||||
y = (LONGINT)x;
|
||||
if (y <= x) return y; else return y - 1;
|
||||
}
|
||||
}
|
||||
|
||||
extern void Heap_Lock();
|
||||
extern void Heap_Unlock();
|
||||
|
||||
SYSTEM_PTR SYSTEM_NEWARR(LONGINT *typ, LONGINT elemsz, int elemalgn, int nofdim, int nofdyn, ...)
|
||||
{
|
||||
LONGINT nofelems, size, dataoff, n, nptr, *x, *p, nofptrs, i, *ptab, off;
|
||||
va_list ap;
|
||||
va_start(ap, nofdyn);
|
||||
nofelems = 1;
|
||||
while (nofdim > 0) {
|
||||
nofelems = nofelems * va_arg(ap, LONGINT); nofdim--;
|
||||
if (nofelems <= 0) __HALT(-20);
|
||||
}
|
||||
va_end(ap);
|
||||
dataoff = nofdyn * sizeof(LONGINT);
|
||||
if (elemalgn > sizeof(LONGINT)) {
|
||||
n = dataoff % elemalgn;
|
||||
if (n != 0) dataoff += elemalgn - n;
|
||||
}
|
||||
size = dataoff + nofelems * elemsz;
|
||||
Heap_Lock();
|
||||
if (typ == NIL) {
|
||||
/* element typ does not contain pointers */
|
||||
x = Heap_NEWBLK(size);
|
||||
}
|
||||
else if (typ == (LONGINT*)POINTER__typ) {
|
||||
/* element type is a pointer */
|
||||
x = Heap_NEWBLK(size + nofelems * sizeof(LONGINT));
|
||||
p = (LONGINT*)(uintptr_t)x[-1];
|
||||
p[-nofelems] = *p; /* build new type desc in situ: 1. copy block size; 2. setup ptr tab; 3. set sentinel; 4. patch tag */
|
||||
p -= nofelems - 1; n = 1; /* n =1 for skipping the size field */
|
||||
while (n <= nofelems) {*p = n*sizeof(LONGINT); p++; n++;}
|
||||
*p = - (nofelems + 1) * sizeof(LONGINT); /* sentinel */
|
||||
x[-1] -= nofelems * sizeof(LONGINT);
|
||||
}
|
||||
else {
|
||||
/* element type is a record that contains pointers */
|
||||
ptab = typ + 1; nofptrs = 0;
|
||||
while (ptab[nofptrs] >= 0) {nofptrs++;} /* number of pointers per element */
|
||||
nptr = nofelems * nofptrs; /* total number of pointers */
|
||||
x = Heap_NEWBLK(size + nptr * sizeof(LONGINT));
|
||||
p = (LONGINT*)(uintptr_t)x[- 1];
|
||||
p[-nptr] = *p; /* build new type desc in situ; 1. copy block size; 2. setup ptr tab; 3. set sentinel; 4. patch tag */
|
||||
p -= nptr - 1; n = 0; off = dataoff;
|
||||
while (n < nofelems) {i = 0;
|
||||
while (i < nofptrs) {*p = off + ptab[i]; p++; i++;}
|
||||
off += elemsz; n++;
|
||||
}
|
||||
*p = - (nptr + 1) * sizeof(LONGINT); /* sentinel */
|
||||
x[-1] -= nptr * sizeof(LONGINT);
|
||||
}
|
||||
if (nofdyn != 0) {
|
||||
/* setup len vector for index checks */
|
||||
va_start(ap, nofdyn);
|
||||
p = x;
|
||||
while (nofdyn > 0) {*p = va_arg(ap, LONGINT); p++, nofdyn--;}
|
||||
va_end(ap);
|
||||
}
|
||||
Heap_Unlock();
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
typedef void (*SystemSignalHandler)(INTEGER); // = Platform_SignalHandler
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
SystemSignalHandler handler[3] = {0};
|
||||
|
||||
// Provide signal handling for Unix based systems
|
||||
void signalHandler(int s) {
|
||||
if (s >= 2 && s <= 4) handler[s-2](s);
|
||||
// (Ignore other signals)
|
||||
}
|
||||
|
||||
void SystemSetHandler(int s, uintptr_t h) {
|
||||
if (s >= 2 && s <= 4) {
|
||||
int needtosetsystemhandler = handler[s-2] == 0;
|
||||
handler[s-2] = (SystemSignalHandler)h;
|
||||
if (needtosetsystemhandler) {signal(s, signalHandler);}
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// Provides Windows callback handlers for signal-like scenarios
|
||||
#include "WindowsWrapper.h"
|
||||
|
||||
SystemSignalHandler SystemInterruptHandler = 0;
|
||||
SystemSignalHandler SystemQuitHandler = 0;
|
||||
BOOL ConsoleCtrlHandlerSet = FALSE;
|
||||
|
||||
BOOL WINAPI SystemConsoleCtrlHandler(DWORD ctrlType) {
|
||||
if ((ctrlType == CTRL_C_EVENT) || (ctrlType == CTRL_BREAK_EVENT)) {
|
||||
if (SystemInterruptHandler) {
|
||||
SystemInterruptHandler(2); // SIGINT
|
||||
return TRUE;
|
||||
}
|
||||
} else { // Close, logoff or shutdown
|
||||
if (SystemQuitHandler) {
|
||||
SystemQuitHandler(3); // SIGQUIT
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void EnsureConsoleCtrlHandler() {
|
||||
if (!ConsoleCtrlHandlerSet) {
|
||||
SetConsoleCtrlHandler(SystemConsoleCtrlHandler, TRUE);
|
||||
ConsoleCtrlHandlerSet = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void SystemSetInterruptHandler(uintptr_t h) {
|
||||
EnsureConsoleCtrlHandler();
|
||||
SystemInterruptHandler = (SystemSignalHandler)h;
|
||||
}
|
||||
|
||||
void SystemSetQuitHandler(uintptr_t h) {
|
||||
EnsureConsoleCtrlHandler();
|
||||
SystemQuitHandler = (SystemSignalHandler)h;
|
||||
}
|
||||
|
||||
#endif
|
||||
275
bootstrap/unix-44/SYSTEM.h
Normal file
275
bootstrap/unix-44/SYSTEM.h
Normal file
|
|
@ -0,0 +1,275 @@
|
|||
#ifndef SYSTEM__h
|
||||
#define SYSTEM__h
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
// Building for a Unix/Linux based system
|
||||
#include <string.h> // For memcpy ...
|
||||
#include <stdint.h> // For uintptr_t ...
|
||||
|
||||
#else
|
||||
|
||||
// Building for Windows platform with either mingw under cygwin, or the MS C compiler
|
||||
#ifdef _WIN64
|
||||
typedef unsigned long long size_t;
|
||||
typedef unsigned long long uintptr_t;
|
||||
#else
|
||||
typedef unsigned int size_t;
|
||||
typedef unsigned int uintptr_t;
|
||||
#endif /* _WIN64 */
|
||||
|
||||
typedef unsigned int uint32_t;
|
||||
void * __cdecl memcpy(void * dest, const void * source, size_t size);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// The compiler uses 'import' and 'export' which translate to 'extern' and
|
||||
// nothing respectively.
|
||||
|
||||
#define import extern
|
||||
#define export
|
||||
|
||||
|
||||
|
||||
// Known constants
|
||||
|
||||
#define NIL ((void*)0)
|
||||
#define __MAXEXT 16
|
||||
#define POINTER__typ ((LONGINT*)(1)) // not NIL and not a valid type
|
||||
|
||||
|
||||
// Oberon types
|
||||
|
||||
#define BOOLEAN char
|
||||
#define SYSTEM_BYTE unsigned char
|
||||
#define CHAR unsigned char
|
||||
#define SHORTINT signed char
|
||||
#define REAL float
|
||||
#define LONGREAL double
|
||||
#define SYSTEM_PTR void*
|
||||
|
||||
// For 32 bit builds, the size of LONGINT depends on a make option:
|
||||
|
||||
#if (__SIZEOF_POINTER__ == 8) || defined(LARGE) || defined(_WIN64)
|
||||
#define INTEGER int // INTEGER is 32 bit.
|
||||
#define LONGINT long long // LONGINT is 64 bit. (long long is always 64 bits, while long can be 32 bits e.g. under MSC/MingW)
|
||||
#else
|
||||
#define INTEGER short int // INTEGER is 16 bit.
|
||||
#define LONGINT long // LONGINT is 32 bit.
|
||||
#endif
|
||||
|
||||
#define SET unsigned LONGINT
|
||||
|
||||
|
||||
// OS Memory allocation interfaces are in PlatformXXX.Mod
|
||||
|
||||
extern LONGINT Platform_OSAllocate (LONGINT size);
|
||||
extern void Platform_OSFree (LONGINT addr);
|
||||
|
||||
|
||||
// Run time system routines in SYSTEM.c
|
||||
|
||||
extern LONGINT SYSTEM_XCHK (LONGINT i, LONGINT ub);
|
||||
extern LONGINT SYSTEM_RCHK (LONGINT i, LONGINT ub);
|
||||
extern LONGINT SYSTEM_ASH (LONGINT i, LONGINT n);
|
||||
extern LONGINT SYSTEM_ABS (LONGINT i);
|
||||
extern double SYSTEM_ABSD (double i);
|
||||
extern void SYSTEM_INHERIT(LONGINT *t, LONGINT *t0);
|
||||
extern void SYSTEM_ENUMP (void *adr, LONGINT n, void (*P)());
|
||||
extern void SYSTEM_ENUMR (void *adr, LONGINT *typ, LONGINT size, LONGINT n, void (*P)());
|
||||
extern LONGINT SYSTEM_DIV (unsigned LONGINT x, unsigned LONGINT y);
|
||||
extern LONGINT SYSTEM_MOD (unsigned LONGINT x, unsigned LONGINT y);
|
||||
extern LONGINT SYSTEM_ENTIER (double x);
|
||||
|
||||
|
||||
// Signal handling in SYSTEM.c
|
||||
|
||||
#ifndef _WIN32
|
||||
extern void SystemSetHandler(int s, uintptr_t h);
|
||||
#else
|
||||
extern void SystemSetInterruptHandler(uintptr_t h);
|
||||
extern void SystemSetQuitHandler (uintptr_t h);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// String comparison
|
||||
|
||||
static int __str_cmp(CHAR *x, CHAR *y){
|
||||
LONGINT i = 0;
|
||||
CHAR ch1, ch2;
|
||||
do {ch1 = x[i]; ch2 = y[i]; i++;
|
||||
if (!ch1) return -(int)ch2;
|
||||
} while (ch1==ch2);
|
||||
return (int)ch1 - (int)ch2;
|
||||
}
|
||||
#define __STRCMP(a,b) __str_cmp((CHAR*)(a), (CHAR*)(b))
|
||||
|
||||
|
||||
|
||||
// Inline string, record and array copy
|
||||
|
||||
#define __COPY(s, d, n) {char*_a=(void*)s,*_b=(void*)d; LONGINT _i=0,_t=n-1; \
|
||||
while(_i<_t&&((_b[_i]=_a[_i])!=0)){_i++;};_b[_i]=0;}
|
||||
#define __DUP(x, l, t) x=(void*)memcpy((void*)(uintptr_t)Platform_OSAllocate(l*sizeof(t)),x,l*sizeof(t))
|
||||
#define __DUPARR(v, t) v=(void*)memcpy(v##__copy,v,sizeof(t))
|
||||
#define __DEL(x) Platform_OSFree((LONGINT)(uintptr_t)x)
|
||||
|
||||
|
||||
|
||||
|
||||
/* SYSTEM ops */
|
||||
|
||||
#define __VAL(t, x) ((t)(x))
|
||||
#define __VALP(t, x) ((t)(uintptr_t)(x))
|
||||
|
||||
#define __GET(a, x, t) x= *(t*)(uintptr_t)(a)
|
||||
#define __PUT(a, x, t) *(t*)(uintptr_t)(a)=x
|
||||
#define __LSHL(x, n, t) ((t)((unsigned t)(x)<<(n)))
|
||||
#define __LSHR(x, n, t) ((t)((unsigned t)(x)>>(n)))
|
||||
#define __LSH(x, n, t) ((n)>=0? __LSHL(x, n, t): __LSHR(x, -(n), t))
|
||||
#define __ROTL(x, n, t) ((t)((unsigned t)(x)<<(n)|(unsigned t)(x)>>(8*sizeof(t)-(n))))
|
||||
#define __ROTR(x, n, t) ((t)((unsigned t)(x)>>(n)|(unsigned t)(x)<<(8*sizeof(t)-(n))))
|
||||
#define __LSHR(x, n, t) ((t)((unsigned t)(x)>>(n)))
|
||||
#define __LSH(x, n, t) ((n)>=0? __LSHL(x, n, t): __LSHR(x, -(n), t))
|
||||
#define __ROTL(x, n, t) ((t)((unsigned t)(x)<<(n)|(unsigned t)(x)>>(8*sizeof(t)-(n))))
|
||||
#define __ROTR(x, n, t) ((t)((unsigned t)(x)>>(n)|(unsigned t)(x)<<(8*sizeof(t)-(n))))
|
||||
#define __ROT(x, n, t) ((n)>=0? __ROTL(x, n, t): __ROTR(x, -(n), t))
|
||||
#define __BIT(x, n) (*(unsigned LONGINT*)(x)>>(n)&1)
|
||||
#define __MOVE(s, d, n) memcpy((char*)(uintptr_t)(d),(char*)(uintptr_t)(s),n)
|
||||
#define __ASHL(x, n) ((LONGINT)(x)<<(n))
|
||||
#define __ASHR(x, n) ((LONGINT)(x)>>(n))
|
||||
#define __ASH(x, n) ((n)>=0?__ASHL(x,n):__ASHR(x,-(n)))
|
||||
#define __ASHF(x, n) SYSTEM_ASH((LONGINT)(x), (LONGINT)(n))
|
||||
#define __SHORT(x, y) ((int)((unsigned LONGINT)(x)+(y)<(y)+(y)?(x):(__HALT(-8),0)))
|
||||
#define __SHORTF(x, y) ((int)(__RF((x)+(y),(y)+(y))-(y)))
|
||||
#define __CHR(x) ((CHAR)__R(x, 256))
|
||||
#define __CHRF(x) ((CHAR)__RF(x, 256))
|
||||
#define __DIV(x, y) ((x)>=0?(x)/(y):-(((y)-1-(x))/(y)))
|
||||
#define __DIVF(x, y) SYSTEM_DIV((LONGINT)(x),(LONGINT)(y))
|
||||
#define __MOD(x, y) ((x)>=0?(x)%(y):__MODF(x,y))
|
||||
#define __MODF(x, y) SYSTEM_MOD((LONGINT)(x),(LONGINT)(y))
|
||||
#define __ENTIER(x) SYSTEM_ENTIER(x)
|
||||
#define __ABS(x) (((x)<0)?-(x):(x))
|
||||
#define __ABSF(x) SYSTEM_ABS((LONGINT)(x))
|
||||
#define __ABSFD(x) SYSTEM_ABSD((double)(x))
|
||||
#define __CAP(ch) ((CHAR)((ch)&0x5f))
|
||||
#define __ODD(x) ((x)&1)
|
||||
#define __IN(x, s) (((s)>>(x))&1)
|
||||
#define __SETOF(x) ((SET)1<<(x))
|
||||
#define __SETRNG(l, h) ((~(SET)0<<(l))&~(SET)0>>(8*sizeof(SET)-1-(h)))
|
||||
#define __MASK(x, m) ((x)&~(m))
|
||||
|
||||
|
||||
|
||||
// Runtime checks
|
||||
|
||||
#define __X(i, ub) (((unsigned LONGINT)(i)<(unsigned LONGINT)(ub))?i:(__HALT(-2),0))
|
||||
#define __XF(i, ub) SYSTEM_XCHK((LONGINT)(i), (LONGINT)(ub))
|
||||
#define __R(i, ub) (((unsigned LONGINT)(i)<(unsigned LONGINT)(ub))?i:(__HALT(-8),0))
|
||||
#define __RF(i, ub) SYSTEM_RCHK((LONGINT)(i),(LONGINT)(ub))
|
||||
#define __RETCHK __retchk: __HALT(-3); return 0;
|
||||
#define __CASECHK __HALT(-4)
|
||||
#define __WITHCHK __HALT(-7)
|
||||
|
||||
#define __GUARDP(p, typ, level) ((typ*)(__ISP(p,typ,level)?p:(__HALT(-5),p)))
|
||||
#define __GUARDR(r, typ, level) (*((typ*)(__IS(r##__typ,typ,level)?r:(__HALT(-5),r))))
|
||||
#define __GUARDA(p, typ, level) ((struct typ*)(__IS(__TYPEOF(p),typ,level)?p:(__HALT(-5),p)))
|
||||
#define __GUARDEQR(p, dyntyp, typ) if(dyntyp!=typ##__typ) __HALT(-6);*(p)
|
||||
#define __GUARDEQP(p, typ) if(__TYPEOF(p)!=typ##__typ)__HALT(-6);*(p)
|
||||
|
||||
|
||||
|
||||
// Module entry/registration/exit
|
||||
|
||||
extern void Heap_REGCMD();
|
||||
extern SYSTEM_PTR Heap_REGMOD();
|
||||
extern void Heap_REGTYP();
|
||||
extern void Heap_INCREF();
|
||||
|
||||
#define __DEFMOD static void *m; if (m!=0) {return m;}
|
||||
#define __REGCMD(name, cmd) Heap_REGCMD(m, (CHAR*)name, cmd)
|
||||
#define __REGMOD(name, enum) if (m==0) {m = Heap_REGMOD((CHAR*)name,enum);}
|
||||
#define __ENDMOD return m
|
||||
#define __MODULE_IMPORT(name) Heap_INCREF(name##__init())
|
||||
|
||||
|
||||
|
||||
// Main module initialisation, registration and finalisation
|
||||
|
||||
extern void Platform_Init(INTEGER argc, LONGINT argv);
|
||||
extern void *Platform_MainModule;
|
||||
extern void Heap_FINALL();
|
||||
|
||||
#define __INIT(argc, argv) static void *m; Platform_Init((INTEGER)argc, (LONGINT)(uintptr_t)&argv);
|
||||
#define __REGMAIN(name, enum) m = Heap_REGMOD((CHAR*)name,enum)
|
||||
#define __FINI Heap_FINALL(); return 0
|
||||
|
||||
|
||||
// Assertions and Halts
|
||||
|
||||
extern void Platform_Halt(LONGINT x);
|
||||
extern void Platform_AssertFail(LONGINT x);
|
||||
|
||||
#define __HALT(x) Platform_Halt(x)
|
||||
#define __ASSERT(cond, x) if (!(cond)) Platform_AssertFail((LONGINT)(x))
|
||||
|
||||
|
||||
// Memory allocation
|
||||
|
||||
extern SYSTEM_PTR Heap_NEWBLK (LONGINT size);
|
||||
extern SYSTEM_PTR Heap_NEWREC (LONGINT tag);
|
||||
extern SYSTEM_PTR SYSTEM_NEWARR(LONGINT*, LONGINT, int, int, int, ...);
|
||||
|
||||
#define __SYSNEW(p, len) p = Heap_NEWBLK((LONGINT)(len))
|
||||
#define __NEW(p, t) p = Heap_NEWREC((LONGINT)(uintptr_t)t##__typ)
|
||||
#define __NEWARR SYSTEM_NEWARR
|
||||
|
||||
|
||||
|
||||
/* Type handling */
|
||||
|
||||
#define __TDESC(t, m, n) \
|
||||
static struct t##__desc { \
|
||||
LONGINT tproc[m]; /* Proc for each ptr field */ \
|
||||
LONGINT tag; \
|
||||
LONGINT next; /* Module table type list points here */ \
|
||||
LONGINT level; \
|
||||
LONGINT module; \
|
||||
char name[24]; \
|
||||
LONGINT basep[__MAXEXT]; /* List of bases this extends */ \
|
||||
LONGINT reserved; \
|
||||
LONGINT blksz; /* xxx_typ points here */ \
|
||||
LONGINT ptr[n+1]; /* Offsets of ptrs up to -ve sentinel */ \
|
||||
} t##__desc
|
||||
|
||||
#define __BASEOFF (__MAXEXT+1) // blksz as index to base.
|
||||
#define __TPROC0OFF (__BASEOFF+24/sizeof(LONGINT)+5) // blksz as index to tproc IFF m=1.
|
||||
#define __EOM 1
|
||||
#define __TDFLDS(name, size) {__EOM}, 1, 0, 0, 0, name, {0}, 0, size
|
||||
#define __ENUMP(adr, n, P) SYSTEM_ENUMP(adr, (LONGINT)(n), P)
|
||||
#define __ENUMR(adr, typ, size, n, P) SYSTEM_ENUMR(adr, typ, (LONGINT)(size), (LONGINT)(n), P)
|
||||
|
||||
#define __INITYP(t, t0, level) \
|
||||
t##__typ = (LONGINT*)&t##__desc.blksz; \
|
||||
memcpy(t##__desc.basep, t0##__typ - __BASEOFF, level*sizeof(LONGINT)); \
|
||||
t##__desc.basep[level] = (LONGINT)(uintptr_t)t##__typ; \
|
||||
t##__desc.module = (LONGINT)(uintptr_t)m; \
|
||||
if(t##__desc.blksz!=sizeof(struct t)) __HALT(-15); \
|
||||
t##__desc.blksz = (t##__desc.blksz+5*sizeof(LONGINT)-1)/(4*sizeof(LONGINT))*(4*sizeof(LONGINT)); \
|
||||
Heap_REGTYP(m, (LONGINT)(uintptr_t)&t##__desc.next); \
|
||||
SYSTEM_INHERIT(t##__typ, t0##__typ)
|
||||
|
||||
#define __IS(tag, typ, level) (*(tag-(__BASEOFF-level))==(LONGINT)(uintptr_t)typ##__typ)
|
||||
#define __TYPEOF(p) ((LONGINT*)(uintptr_t)(*(((LONGINT*)(p))-1)))
|
||||
#define __ISP(p, typ, level) __IS(__TYPEOF(p),typ,level)
|
||||
|
||||
// Oberon-2 type bound procedures support
|
||||
#define __INITBP(t, proc, num) *(t##__typ-(__TPROC0OFF+num))=(LONGINT)(uintptr_t)proc
|
||||
#define __SEND(typ, num, funtyp, parlist) ((funtyp)((uintptr_t)*(typ-(__TPROC0OFF+num))))parlist
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
243
bootstrap/unix-44/Strings.c
Normal file
243
bootstrap/unix-44/Strings.c
Normal file
|
|
@ -0,0 +1,243 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
#include "SYSTEM.h"
|
||||
|
||||
|
||||
|
||||
|
||||
export void Strings_Append (CHAR *extra, LONGINT extra__len, CHAR *dest, LONGINT dest__len);
|
||||
export void Strings_Cap (CHAR *s, LONGINT s__len);
|
||||
export void Strings_Delete (CHAR *s, LONGINT s__len, INTEGER pos, INTEGER n);
|
||||
export void Strings_Extract (CHAR *source, LONGINT source__len, INTEGER pos, INTEGER n, CHAR *dest, LONGINT dest__len);
|
||||
export void Strings_Insert (CHAR *source, LONGINT source__len, INTEGER pos, CHAR *dest, LONGINT dest__len);
|
||||
export INTEGER Strings_Length (CHAR *s, LONGINT s__len);
|
||||
export BOOLEAN Strings_Match (CHAR *string, LONGINT string__len, CHAR *pattern, LONGINT pattern__len);
|
||||
export INTEGER Strings_Pos (CHAR *pattern, LONGINT pattern__len, CHAR *s, LONGINT s__len, INTEGER pos);
|
||||
export void Strings_Replace (CHAR *source, LONGINT source__len, INTEGER pos, CHAR *dest, LONGINT dest__len);
|
||||
|
||||
|
||||
INTEGER Strings_Length (CHAR *s, LONGINT s__len)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
INTEGER i;
|
||||
__DUP(s, s__len, CHAR);
|
||||
i = 0;
|
||||
while (((LONGINT)i < s__len && s[__X(i, s__len)] != 0x00)) {
|
||||
i += 1;
|
||||
}
|
||||
_o_result = i;
|
||||
__DEL(s);
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
void Strings_Append (CHAR *extra, LONGINT extra__len, CHAR *dest, LONGINT dest__len)
|
||||
{
|
||||
INTEGER n1, n2, i;
|
||||
__DUP(extra, extra__len, CHAR);
|
||||
n1 = Strings_Length(dest, dest__len);
|
||||
n2 = Strings_Length(extra, extra__len);
|
||||
i = 0;
|
||||
while ((i < n2 && (LONGINT)(i + n1) < dest__len)) {
|
||||
dest[__X(i + n1, dest__len)] = extra[__X(i, extra__len)];
|
||||
i += 1;
|
||||
}
|
||||
if ((LONGINT)(i + n1) < dest__len) {
|
||||
dest[__X(i + n1, dest__len)] = 0x00;
|
||||
}
|
||||
__DEL(extra);
|
||||
}
|
||||
|
||||
void Strings_Insert (CHAR *source, LONGINT source__len, INTEGER pos, CHAR *dest, LONGINT dest__len)
|
||||
{
|
||||
INTEGER n1, n2, i;
|
||||
__DUP(source, source__len, CHAR);
|
||||
n1 = Strings_Length(dest, dest__len);
|
||||
n2 = Strings_Length(source, source__len);
|
||||
if (pos < 0) {
|
||||
pos = 0;
|
||||
}
|
||||
if (pos > n1) {
|
||||
Strings_Append(dest, dest__len, (void*)source, source__len);
|
||||
return;
|
||||
}
|
||||
if ((LONGINT)(pos + n2) < dest__len) {
|
||||
i = n1;
|
||||
while (i >= pos) {
|
||||
if ((LONGINT)(i + n2) < dest__len) {
|
||||
dest[__X(i + n2, dest__len)] = dest[__X(i, dest__len)];
|
||||
}
|
||||
i -= 1;
|
||||
}
|
||||
}
|
||||
i = 0;
|
||||
while (i < n2) {
|
||||
dest[__X(pos + i, dest__len)] = source[__X(i, source__len)];
|
||||
i += 1;
|
||||
}
|
||||
__DEL(source);
|
||||
}
|
||||
|
||||
void Strings_Delete (CHAR *s, LONGINT s__len, INTEGER pos, INTEGER n)
|
||||
{
|
||||
INTEGER len, i;
|
||||
len = Strings_Length(s, s__len);
|
||||
if (pos < 0) {
|
||||
pos = 0;
|
||||
} else if (pos >= len) {
|
||||
return;
|
||||
}
|
||||
if (pos + n < len) {
|
||||
i = pos + n;
|
||||
while (i < len) {
|
||||
s[__X(i - n, s__len)] = s[__X(i, s__len)];
|
||||
i += 1;
|
||||
}
|
||||
if ((LONGINT)(i - n) < s__len) {
|
||||
s[__X(i - n, s__len)] = 0x00;
|
||||
}
|
||||
} else {
|
||||
s[__X(pos, s__len)] = 0x00;
|
||||
}
|
||||
}
|
||||
|
||||
void Strings_Replace (CHAR *source, LONGINT source__len, INTEGER pos, CHAR *dest, LONGINT dest__len)
|
||||
{
|
||||
__DUP(source, source__len, CHAR);
|
||||
Strings_Delete((void*)dest, dest__len, pos, pos + Strings_Length(source, source__len));
|
||||
Strings_Insert(source, source__len, pos, (void*)dest, dest__len);
|
||||
__DEL(source);
|
||||
}
|
||||
|
||||
void Strings_Extract (CHAR *source, LONGINT source__len, INTEGER pos, INTEGER n, CHAR *dest, LONGINT dest__len)
|
||||
{
|
||||
INTEGER len, destLen, i;
|
||||
__DUP(source, source__len, CHAR);
|
||||
len = Strings_Length(source, source__len);
|
||||
destLen = (int)dest__len - 1;
|
||||
if (pos < 0) {
|
||||
pos = 0;
|
||||
}
|
||||
if (pos >= len) {
|
||||
dest[0] = 0x00;
|
||||
return;
|
||||
}
|
||||
i = 0;
|
||||
while (((((LONGINT)(pos + i) <= source__len && source[__X(pos + i, source__len)] != 0x00)) && i < n)) {
|
||||
if (i < destLen) {
|
||||
dest[__X(i, dest__len)] = source[__X(pos + i, source__len)];
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
dest[__X(i, dest__len)] = 0x00;
|
||||
__DEL(source);
|
||||
}
|
||||
|
||||
INTEGER Strings_Pos (CHAR *pattern, LONGINT pattern__len, CHAR *s, LONGINT s__len, INTEGER pos)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
INTEGER n1, n2, i, j;
|
||||
__DUP(pattern, pattern__len, CHAR);
|
||||
__DUP(s, s__len, CHAR);
|
||||
n1 = Strings_Length(s, s__len);
|
||||
n2 = Strings_Length(pattern, pattern__len);
|
||||
if (n2 == 0) {
|
||||
_o_result = 0;
|
||||
__DEL(pattern);
|
||||
__DEL(s);
|
||||
return _o_result;
|
||||
}
|
||||
i = pos;
|
||||
while (i <= n1 - n2) {
|
||||
if (s[__X(i, s__len)] == pattern[0]) {
|
||||
j = 1;
|
||||
while ((j < n2 && s[__X(i + j, s__len)] == pattern[__X(j, pattern__len)])) {
|
||||
j += 1;
|
||||
}
|
||||
if (j == n2) {
|
||||
_o_result = i;
|
||||
__DEL(pattern);
|
||||
__DEL(s);
|
||||
return _o_result;
|
||||
}
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
_o_result = -1;
|
||||
__DEL(pattern);
|
||||
__DEL(s);
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
void Strings_Cap (CHAR *s, LONGINT s__len)
|
||||
{
|
||||
INTEGER i;
|
||||
i = 0;
|
||||
while (s[__X(i, s__len)] != 0x00) {
|
||||
if (('a' <= s[__X(i, s__len)] && s[__X(i, s__len)] <= 'z')) {
|
||||
s[__X(i, s__len)] = __CAP(s[__X(i, s__len)]);
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
static struct Match__7 {
|
||||
struct Match__7 *lnk;
|
||||
} *Match__7_s;
|
||||
|
||||
static BOOLEAN M__8 (CHAR *name, LONGINT name__len, CHAR *mask, LONGINT mask__len, INTEGER n, INTEGER m);
|
||||
|
||||
static BOOLEAN M__8 (CHAR *name, LONGINT name__len, CHAR *mask, LONGINT mask__len, INTEGER n, INTEGER m)
|
||||
{
|
||||
BOOLEAN _o_result;
|
||||
while ((((n >= 0 && m >= 0)) && mask[__X(m, mask__len)] != '*')) {
|
||||
if (name[__X(n, name__len)] != mask[__X(m, mask__len)]) {
|
||||
_o_result = 0;
|
||||
return _o_result;
|
||||
}
|
||||
n -= 1;
|
||||
m -= 1;
|
||||
}
|
||||
if (m < 0) {
|
||||
_o_result = n < 0;
|
||||
return _o_result;
|
||||
}
|
||||
while ((m >= 0 && mask[__X(m, mask__len)] == '*')) {
|
||||
m -= 1;
|
||||
}
|
||||
if (m < 0) {
|
||||
_o_result = 1;
|
||||
return _o_result;
|
||||
}
|
||||
while (n >= 0) {
|
||||
if (M__8(name, name__len, mask, mask__len, n, m)) {
|
||||
_o_result = 1;
|
||||
return _o_result;
|
||||
}
|
||||
n -= 1;
|
||||
}
|
||||
_o_result = 0;
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
BOOLEAN Strings_Match (CHAR *string, LONGINT string__len, CHAR *pattern, LONGINT pattern__len)
|
||||
{
|
||||
BOOLEAN _o_result;
|
||||
struct Match__7 _s;
|
||||
__DUP(string, string__len, CHAR);
|
||||
__DUP(pattern, pattern__len, CHAR);
|
||||
_s.lnk = Match__7_s;
|
||||
Match__7_s = &_s;
|
||||
_o_result = M__8((void*)string, string__len, (void*)pattern, pattern__len, Strings_Length(string, string__len) - 1, Strings_Length(pattern, pattern__len) - 1);
|
||||
Match__7_s = _s.lnk;
|
||||
__DEL(string);
|
||||
__DEL(pattern);
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
|
||||
export void *Strings__init(void)
|
||||
{
|
||||
__DEFMOD;
|
||||
__REGMOD("Strings", 0);
|
||||
/* BEGIN */
|
||||
__ENDMOD;
|
||||
}
|
||||
23
bootstrap/unix-44/Strings.h
Normal file
23
bootstrap/unix-44/Strings.h
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#ifndef Strings__h
|
||||
#define Strings__h
|
||||
|
||||
#include "SYSTEM.h"
|
||||
|
||||
|
||||
|
||||
|
||||
import void Strings_Append (CHAR *extra, LONGINT extra__len, CHAR *dest, LONGINT dest__len);
|
||||
import void Strings_Cap (CHAR *s, LONGINT s__len);
|
||||
import void Strings_Delete (CHAR *s, LONGINT s__len, INTEGER pos, INTEGER n);
|
||||
import void Strings_Extract (CHAR *source, LONGINT source__len, INTEGER pos, INTEGER n, CHAR *dest, LONGINT dest__len);
|
||||
import void Strings_Insert (CHAR *source, LONGINT source__len, INTEGER pos, CHAR *dest, LONGINT dest__len);
|
||||
import INTEGER Strings_Length (CHAR *s, LONGINT s__len);
|
||||
import BOOLEAN Strings_Match (CHAR *string, LONGINT string__len, CHAR *pattern, LONGINT pattern__len);
|
||||
import INTEGER Strings_Pos (CHAR *pattern, LONGINT pattern__len, CHAR *s, LONGINT s__len, INTEGER pos);
|
||||
import void Strings_Replace (CHAR *source, LONGINT source__len, INTEGER pos, CHAR *dest, LONGINT dest__len);
|
||||
import void *Strings__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
1838
bootstrap/unix-44/Texts.c
Normal file
1838
bootstrap/unix-44/Texts.c
Normal file
File diff suppressed because it is too large
Load diff
172
bootstrap/unix-44/Texts.h
Normal file
172
bootstrap/unix-44/Texts.h
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#ifndef Texts__h
|
||||
#define Texts__h
|
||||
|
||||
#include "SYSTEM.h"
|
||||
#include "Files.h"
|
||||
|
||||
typedef
|
||||
struct Texts_BufDesc {
|
||||
LONGINT len;
|
||||
char _prvt0[4];
|
||||
} Texts_BufDesc;
|
||||
|
||||
typedef
|
||||
Texts_BufDesc *Texts_Buffer;
|
||||
|
||||
typedef
|
||||
struct Texts_ElemMsg {
|
||||
char _prvt0[1];
|
||||
} Texts_ElemMsg;
|
||||
|
||||
typedef
|
||||
struct Texts_ElemDesc *Texts_Elem;
|
||||
|
||||
typedef
|
||||
struct Texts_CopyMsg { /* Texts_ElemMsg */
|
||||
Texts_Elem e;
|
||||
} Texts_CopyMsg;
|
||||
|
||||
typedef
|
||||
struct Texts_RunDesc {
|
||||
LONGINT _prvt0;
|
||||
char _prvt1[15];
|
||||
} Texts_RunDesc;
|
||||
|
||||
typedef
|
||||
void (*Texts_Handler)(Texts_Elem, Texts_ElemMsg*, LONGINT *);
|
||||
|
||||
typedef
|
||||
struct Texts_ElemDesc {
|
||||
char _prvt0[20];
|
||||
LONGINT W, H;
|
||||
Texts_Handler handle;
|
||||
char _prvt1[4];
|
||||
} Texts_ElemDesc;
|
||||
|
||||
typedef
|
||||
struct Texts_FileMsg { /* Texts_ElemMsg */
|
||||
INTEGER id;
|
||||
LONGINT pos;
|
||||
Files_Rider r;
|
||||
} Texts_FileMsg;
|
||||
|
||||
typedef
|
||||
struct Texts_FontDesc {
|
||||
char _prvt0[32];
|
||||
} Texts_FontDesc;
|
||||
|
||||
typedef
|
||||
Texts_FontDesc *Texts_FontsFont;
|
||||
|
||||
typedef
|
||||
struct Texts_IdentifyMsg { /* Texts_ElemMsg */
|
||||
CHAR mod[32], proc[32];
|
||||
} Texts_IdentifyMsg;
|
||||
|
||||
typedef
|
||||
struct Texts_TextDesc *Texts_Text;
|
||||
|
||||
typedef
|
||||
void (*Texts_Notifier)(Texts_Text, INTEGER, LONGINT, LONGINT);
|
||||
|
||||
typedef
|
||||
struct Texts_Reader {
|
||||
BOOLEAN eot;
|
||||
Texts_FontsFont fnt;
|
||||
SHORTINT col, voff;
|
||||
Texts_Elem elem;
|
||||
char _prvt0[32];
|
||||
} Texts_Reader;
|
||||
|
||||
typedef
|
||||
struct Texts_Scanner { /* Texts_Reader */
|
||||
BOOLEAN eot;
|
||||
Texts_FontsFont fnt;
|
||||
SHORTINT col, voff;
|
||||
Texts_Elem elem;
|
||||
char _prvt0[32];
|
||||
CHAR nextCh;
|
||||
INTEGER line, class;
|
||||
LONGINT i;
|
||||
REAL x;
|
||||
LONGREAL y;
|
||||
CHAR c;
|
||||
SHORTINT len;
|
||||
CHAR s[64];
|
||||
} Texts_Scanner;
|
||||
|
||||
typedef
|
||||
struct Texts_TextDesc {
|
||||
LONGINT len;
|
||||
Texts_Notifier notify;
|
||||
char _prvt0[12];
|
||||
} Texts_TextDesc;
|
||||
|
||||
typedef
|
||||
struct Texts_Writer {
|
||||
Texts_Buffer buf;
|
||||
Texts_FontsFont fnt;
|
||||
SHORTINT col, voff;
|
||||
char _prvt0[26];
|
||||
} Texts_Writer;
|
||||
|
||||
|
||||
import Texts_Elem Texts_new;
|
||||
|
||||
import LONGINT *Texts_FontDesc__typ;
|
||||
import LONGINT *Texts_RunDesc__typ;
|
||||
import LONGINT *Texts_ElemMsg__typ;
|
||||
import LONGINT *Texts_ElemDesc__typ;
|
||||
import LONGINT *Texts_FileMsg__typ;
|
||||
import LONGINT *Texts_CopyMsg__typ;
|
||||
import LONGINT *Texts_IdentifyMsg__typ;
|
||||
import LONGINT *Texts_BufDesc__typ;
|
||||
import LONGINT *Texts_TextDesc__typ;
|
||||
import LONGINT *Texts_Reader__typ;
|
||||
import LONGINT *Texts_Scanner__typ;
|
||||
import LONGINT *Texts_Writer__typ;
|
||||
|
||||
import void Texts_Append (Texts_Text T, Texts_Buffer B);
|
||||
import void Texts_ChangeLooks (Texts_Text T, LONGINT beg, LONGINT end, SET sel, Texts_FontsFont fnt, SHORTINT col, SHORTINT voff);
|
||||
import void Texts_Close (Texts_Text T, CHAR *name, LONGINT name__len);
|
||||
import void Texts_Copy (Texts_Buffer SB, Texts_Buffer DB);
|
||||
import void Texts_CopyElem (Texts_Elem SE, Texts_Elem DE);
|
||||
import void Texts_Delete (Texts_Text T, LONGINT beg, LONGINT end);
|
||||
import Texts_Text Texts_ElemBase (Texts_Elem E);
|
||||
import LONGINT Texts_ElemPos (Texts_Elem E);
|
||||
import void Texts_Insert (Texts_Text T, LONGINT pos, Texts_Buffer B);
|
||||
import void Texts_Load (Files_Rider *r, LONGINT *r__typ, Texts_Text T);
|
||||
import void Texts_Open (Texts_Text T, CHAR *name, LONGINT name__len);
|
||||
import void Texts_OpenBuf (Texts_Buffer B);
|
||||
import void Texts_OpenReader (Texts_Reader *R, LONGINT *R__typ, Texts_Text T, LONGINT pos);
|
||||
import void Texts_OpenScanner (Texts_Scanner *S, LONGINT *S__typ, Texts_Text T, LONGINT pos);
|
||||
import void Texts_OpenWriter (Texts_Writer *W, LONGINT *W__typ);
|
||||
import LONGINT Texts_Pos (Texts_Reader *R, LONGINT *R__typ);
|
||||
import void Texts_Read (Texts_Reader *R, LONGINT *R__typ, CHAR *ch);
|
||||
import void Texts_ReadElem (Texts_Reader *R, LONGINT *R__typ);
|
||||
import void Texts_ReadPrevElem (Texts_Reader *R, LONGINT *R__typ);
|
||||
import void Texts_Recall (Texts_Buffer *B);
|
||||
import void Texts_Save (Texts_Text T, LONGINT beg, LONGINT end, Texts_Buffer B);
|
||||
import void Texts_Scan (Texts_Scanner *S, LONGINT *S__typ);
|
||||
import void Texts_SetColor (Texts_Writer *W, LONGINT *W__typ, SHORTINT col);
|
||||
import void Texts_SetFont (Texts_Writer *W, LONGINT *W__typ, Texts_FontsFont fnt);
|
||||
import void Texts_SetOffset (Texts_Writer *W, LONGINT *W__typ, SHORTINT voff);
|
||||
import void Texts_Store (Files_Rider *r, LONGINT *r__typ, Texts_Text T);
|
||||
import void Texts_Write (Texts_Writer *W, LONGINT *W__typ, CHAR ch);
|
||||
import void Texts_WriteDate (Texts_Writer *W, LONGINT *W__typ, LONGINT t, LONGINT d);
|
||||
import void Texts_WriteElem (Texts_Writer *W, LONGINT *W__typ, Texts_Elem e);
|
||||
import void Texts_WriteHex (Texts_Writer *W, LONGINT *W__typ, LONGINT x);
|
||||
import void Texts_WriteInt (Texts_Writer *W, LONGINT *W__typ, LONGINT x, LONGINT n);
|
||||
import void Texts_WriteLn (Texts_Writer *W, LONGINT *W__typ);
|
||||
import void Texts_WriteLongReal (Texts_Writer *W, LONGINT *W__typ, LONGREAL x, INTEGER n);
|
||||
import void Texts_WriteLongRealHex (Texts_Writer *W, LONGINT *W__typ, LONGREAL x);
|
||||
import void Texts_WriteReal (Texts_Writer *W, LONGINT *W__typ, REAL x, INTEGER n);
|
||||
import void Texts_WriteRealFix (Texts_Writer *W, LONGINT *W__typ, REAL x, INTEGER n, INTEGER k);
|
||||
import void Texts_WriteRealHex (Texts_Writer *W, LONGINT *W__typ, REAL x);
|
||||
import void Texts_WriteString (Texts_Writer *W, LONGINT *W__typ, CHAR *s, LONGINT s__len);
|
||||
import void *Texts__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
168
bootstrap/unix-44/Vishap.c
Normal file
168
bootstrap/unix-44/Vishap.c
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkamSf */
|
||||
#include "SYSTEM.h"
|
||||
#include "Configuration.h"
|
||||
#include "Heap.h"
|
||||
#include "OPB.h"
|
||||
#include "OPC.h"
|
||||
#include "OPM.h"
|
||||
#include "OPP.h"
|
||||
#include "OPT.h"
|
||||
#include "OPV.h"
|
||||
#include "Platform.h"
|
||||
#include "Strings.h"
|
||||
#include "extTools.h"
|
||||
#include "vt100.h"
|
||||
|
||||
|
||||
static CHAR Vishap_mname[256];
|
||||
|
||||
|
||||
export void Vishap_Module (BOOLEAN *done);
|
||||
static void Vishap_PropagateElementaryTypeSizes (void);
|
||||
export void Vishap_Translate (void);
|
||||
static void Vishap_Trap (INTEGER sig);
|
||||
|
||||
|
||||
void Vishap_Module (BOOLEAN *done)
|
||||
{
|
||||
BOOLEAN ext, new;
|
||||
OPT_Node p = NIL;
|
||||
OPP_Module(&p, OPM_opt);
|
||||
if (OPM_noerr) {
|
||||
OPV_Init();
|
||||
OPV_AdrAndSize(OPT_topScope);
|
||||
OPT_Export(&ext, &new);
|
||||
if (OPM_noerr) {
|
||||
OPM_OpenFiles((void*)OPT_SelfName, ((LONGINT)(256)));
|
||||
OPC_Init();
|
||||
OPV_Module(p);
|
||||
if (OPM_noerr) {
|
||||
if (((OPM_mainProg || OPM_mainLinkStat) && __STRCMP(OPM_modName, "SYSTEM") != 0)) {
|
||||
OPM_DeleteNewSym();
|
||||
if (!OPM_notColorOutput) {
|
||||
vt100_SetAttr((CHAR*)"32m", (LONGINT)4);
|
||||
}
|
||||
OPM_LogWStr((CHAR*)" Main program.", (LONGINT)16);
|
||||
if (!OPM_notColorOutput) {
|
||||
vt100_SetAttr((CHAR*)"0m", (LONGINT)3);
|
||||
}
|
||||
} else {
|
||||
if (new) {
|
||||
if (!OPM_notColorOutput) {
|
||||
vt100_SetAttr((CHAR*)"32m", (LONGINT)4);
|
||||
}
|
||||
OPM_LogWStr((CHAR*)" New symbol file.", (LONGINT)19);
|
||||
if (!OPM_notColorOutput) {
|
||||
vt100_SetAttr((CHAR*)"0m", (LONGINT)3);
|
||||
}
|
||||
OPM_RegisterNewSym();
|
||||
} else if (ext) {
|
||||
OPM_LogWStr((CHAR*)" Extended symbol file.", (LONGINT)24);
|
||||
OPM_RegisterNewSym();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
OPM_DeleteNewSym();
|
||||
}
|
||||
}
|
||||
}
|
||||
OPM_CloseFiles();
|
||||
OPT_Close();
|
||||
OPM_LogWLn();
|
||||
*done = OPM_noerr;
|
||||
}
|
||||
|
||||
static void Vishap_PropagateElementaryTypeSizes (void)
|
||||
{
|
||||
OPT_bytetyp->size = OPM_ByteSize;
|
||||
OPT_sysptrtyp->size = OPM_PointerSize;
|
||||
OPT_chartyp->size = OPM_CharSize;
|
||||
OPT_settyp->size = OPM_SetSize;
|
||||
OPT_realtyp->size = OPM_RealSize;
|
||||
OPT_inttyp->size = OPM_IntSize;
|
||||
OPT_linttyp->size = OPM_LIntSize;
|
||||
OPT_lrltyp->size = OPM_LRealSize;
|
||||
OPT_sinttyp->size = OPM_SIntSize;
|
||||
OPT_booltyp->size = OPM_BoolSize;
|
||||
}
|
||||
|
||||
void Vishap_Translate (void)
|
||||
{
|
||||
BOOLEAN done;
|
||||
CHAR modulesobj[2048];
|
||||
modulesobj[0] = 0x00;
|
||||
if (OPM_OpenPar()) {
|
||||
for (;;) {
|
||||
OPM_Init(&done, (void*)Vishap_mname, ((LONGINT)(256)));
|
||||
if (!done) {
|
||||
return;
|
||||
}
|
||||
OPM_InitOptions();
|
||||
Vishap_PropagateElementaryTypeSizes();
|
||||
Heap_GC(0);
|
||||
Vishap_Module(&done);
|
||||
if (!done) {
|
||||
OPM_LogWLn();
|
||||
OPM_LogWStr((CHAR*)"Module compilation failed.", (LONGINT)27);
|
||||
OPM_LogWLn();
|
||||
Platform_Exit(1);
|
||||
}
|
||||
if (!OPM_dontAsm) {
|
||||
if (OPM_dontLink) {
|
||||
extTools_Assemble(OPM_modName, ((LONGINT)(32)));
|
||||
} else {
|
||||
if (!(OPM_mainProg || OPM_mainLinkStat)) {
|
||||
extTools_Assemble(OPM_modName, ((LONGINT)(32)));
|
||||
Strings_Append((CHAR*)" ", (LONGINT)2, (void*)modulesobj, ((LONGINT)(2048)));
|
||||
Strings_Append(OPM_modName, ((LONGINT)(32)), (void*)modulesobj, ((LONGINT)(2048)));
|
||||
Strings_Append((CHAR*)".o", (LONGINT)3, (void*)modulesobj, ((LONGINT)(2048)));
|
||||
} else {
|
||||
extTools_LinkMain((void*)OPM_modName, ((LONGINT)(32)), OPM_mainLinkStat, modulesobj, ((LONGINT)(2048)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void Vishap_Trap (INTEGER sig)
|
||||
{
|
||||
Heap_FINALL();
|
||||
if (sig == 3) {
|
||||
Platform_Exit(0);
|
||||
} else {
|
||||
if ((sig == 4 && Platform_HaltCode == -15)) {
|
||||
OPM_LogWStr((CHAR*)" --- Vishap Oberon: internal error", (LONGINT)35);
|
||||
OPM_LogWLn();
|
||||
}
|
||||
Platform_Exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export int main(int argc, char **argv)
|
||||
{
|
||||
__INIT(argc, argv);
|
||||
__MODULE_IMPORT(Configuration);
|
||||
__MODULE_IMPORT(Heap);
|
||||
__MODULE_IMPORT(OPB);
|
||||
__MODULE_IMPORT(OPC);
|
||||
__MODULE_IMPORT(OPM);
|
||||
__MODULE_IMPORT(OPP);
|
||||
__MODULE_IMPORT(OPT);
|
||||
__MODULE_IMPORT(OPV);
|
||||
__MODULE_IMPORT(Platform);
|
||||
__MODULE_IMPORT(Strings);
|
||||
__MODULE_IMPORT(extTools);
|
||||
__MODULE_IMPORT(vt100);
|
||||
__REGMAIN("Vishap", 0);
|
||||
__REGCMD("Translate", Vishap_Translate);
|
||||
/* BEGIN */
|
||||
Platform_SetInterruptHandler(Vishap_Trap);
|
||||
Platform_SetQuitHandler(Vishap_Trap);
|
||||
Platform_SetBadInstructionHandler(Vishap_Trap);
|
||||
OPB_typSize = OPV_TypSize;
|
||||
OPT_typSize = OPV_TypSize;
|
||||
Vishap_Translate();
|
||||
__FINI;
|
||||
}
|
||||
9
bootstrap/unix-44/WindowsWrapper.h
Normal file
9
bootstrap/unix-44/WindowsWrapper.h
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// WindowsWrapper.h
|
||||
//
|
||||
// Includes Windows.h while avoiding conflicts with Oberon types.
|
||||
|
||||
#undef BOOLEAN
|
||||
#undef CHAR
|
||||
#include <windows.h>
|
||||
#define BOOLEAN char
|
||||
#define CHAR unsigned char
|
||||
198
bootstrap/unix-44/errors.c
Normal file
198
bootstrap/unix-44/errors.c
Normal file
|
|
@ -0,0 +1,198 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
#include "SYSTEM.h"
|
||||
|
||||
typedef
|
||||
CHAR errors_string[128];
|
||||
|
||||
|
||||
export errors_string errors_errors[350];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export void *errors__init(void)
|
||||
{
|
||||
__DEFMOD;
|
||||
__REGMOD("errors", 0);
|
||||
/* BEGIN */
|
||||
__MOVE("undeclared identifier", errors_errors[0], 22);
|
||||
__MOVE("multiply defined identifier", errors_errors[1], 28);
|
||||
__MOVE("illegal character in number", errors_errors[2], 28);
|
||||
__MOVE("illegal character in string", errors_errors[3], 28);
|
||||
__MOVE("identifier does not match procedure name", errors_errors[4], 41);
|
||||
__MOVE("comment not closed", errors_errors[5], 19);
|
||||
errors_errors[6][0] = 0x00;
|
||||
errors_errors[7][0] = 0x00;
|
||||
errors_errors[8][0] = 0x00;
|
||||
__MOVE("\'=\' expected", errors_errors[9], 13);
|
||||
errors_errors[10][0] = 0x00;
|
||||
errors_errors[11][0] = 0x00;
|
||||
__MOVE("type definition starts with incorrect symbol", errors_errors[12], 45);
|
||||
__MOVE("factor starts with incorrect symbol", errors_errors[13], 36);
|
||||
__MOVE("statement starts with incorrect symbol", errors_errors[14], 39);
|
||||
__MOVE("declaration followed by incorrect symbol", errors_errors[15], 41);
|
||||
__MOVE("MODULE expected", errors_errors[16], 16);
|
||||
errors_errors[17][0] = 0x00;
|
||||
__MOVE("\'.\' missing", errors_errors[18], 12);
|
||||
__MOVE("\',\' missing", errors_errors[19], 12);
|
||||
__MOVE("\':\' missing", errors_errors[20], 12);
|
||||
errors_errors[21][0] = 0x00;
|
||||
__MOVE("\')\' missing", errors_errors[22], 12);
|
||||
__MOVE("\']\' missing", errors_errors[23], 12);
|
||||
__MOVE("\'}\' missing", errors_errors[24], 12);
|
||||
__MOVE("OF missing", errors_errors[25], 11);
|
||||
__MOVE("THEN missing", errors_errors[26], 13);
|
||||
__MOVE("DO missing", errors_errors[27], 11);
|
||||
__MOVE("TO missing", errors_errors[28], 11);
|
||||
errors_errors[29][0] = 0x00;
|
||||
__MOVE("\'(\' missing", errors_errors[30], 12);
|
||||
errors_errors[31][0] = 0x00;
|
||||
errors_errors[32][0] = 0x00;
|
||||
errors_errors[33][0] = 0x00;
|
||||
__MOVE("\':=\' missing", errors_errors[34], 13);
|
||||
__MOVE("\',\' or OF expected", errors_errors[35], 19);
|
||||
errors_errors[36][0] = 0x00;
|
||||
errors_errors[37][0] = 0x00;
|
||||
__MOVE("identifier expected", errors_errors[38], 20);
|
||||
__MOVE("\';\' missing", errors_errors[39], 12);
|
||||
errors_errors[40][0] = 0x00;
|
||||
__MOVE("END missing", errors_errors[41], 12);
|
||||
errors_errors[42][0] = 0x00;
|
||||
errors_errors[43][0] = 0x00;
|
||||
__MOVE("UNTIL missing", errors_errors[44], 14);
|
||||
errors_errors[45][0] = 0x00;
|
||||
__MOVE("EXIT not within loop statement", errors_errors[46], 31);
|
||||
__MOVE("illegally marked identifier", errors_errors[47], 28);
|
||||
errors_errors[48][0] = 0x00;
|
||||
errors_errors[49][0] = 0x00;
|
||||
__MOVE("expression should be constant", errors_errors[50], 30);
|
||||
__MOVE("constant not an integer", errors_errors[51], 24);
|
||||
__MOVE("identifier does not denote a type", errors_errors[52], 34);
|
||||
__MOVE("identifier does not denote a record type", errors_errors[53], 41);
|
||||
__MOVE("result type of procedure is not a basic type", errors_errors[54], 45);
|
||||
__MOVE("procedure call of a function", errors_errors[55], 29);
|
||||
__MOVE("assignment to non-variable", errors_errors[56], 27);
|
||||
__MOVE("pointer not bound to record or array type", errors_errors[57], 42);
|
||||
__MOVE("recursive type definition", errors_errors[58], 26);
|
||||
__MOVE("illegal open array parameter", errors_errors[59], 29);
|
||||
__MOVE("wrong type of case label", errors_errors[60], 25);
|
||||
__MOVE("inadmissible type of case label", errors_errors[61], 32);
|
||||
__MOVE("case label defined more than once", errors_errors[62], 34);
|
||||
__MOVE("illegal value of constant", errors_errors[63], 26);
|
||||
__MOVE("more actual than formal parameters", errors_errors[64], 35);
|
||||
__MOVE("fewer actual than formal parameters", errors_errors[65], 36);
|
||||
__MOVE("element types of actual array and formal open array differ", errors_errors[66], 59);
|
||||
__MOVE("actual parameter corresponding to open array is not an array", errors_errors[67], 61);
|
||||
__MOVE("control variable must be integer", errors_errors[68], 33);
|
||||
__MOVE("parameter must be an integer constant", errors_errors[69], 38);
|
||||
__MOVE("pointer or VAR record required as formal receiver", errors_errors[70], 50);
|
||||
__MOVE("pointer expected as actual receiver", errors_errors[71], 36);
|
||||
__MOVE("procedure must be bound to a record of the same scope", errors_errors[72], 54);
|
||||
__MOVE("procedure must have level 0", errors_errors[73], 28);
|
||||
__MOVE("procedure unknown in base type", errors_errors[74], 31);
|
||||
__MOVE("invalid call of base procedure", errors_errors[75], 31);
|
||||
__MOVE("this variable (field) is read only", errors_errors[76], 35);
|
||||
__MOVE("object is not a record", errors_errors[77], 23);
|
||||
__MOVE("dereferenced object is not a variable", errors_errors[78], 38);
|
||||
__MOVE("indexed object is not a variable", errors_errors[79], 33);
|
||||
__MOVE("index expression is not an integer", errors_errors[80], 35);
|
||||
__MOVE("index out of specified bounds", errors_errors[81], 30);
|
||||
__MOVE("indexed variable is not an array", errors_errors[82], 33);
|
||||
__MOVE("undefined record field", errors_errors[83], 23);
|
||||
__MOVE("dereferenced variable is not a pointer", errors_errors[84], 39);
|
||||
__MOVE("guard or test type is not an extension of variable type", errors_errors[85], 56);
|
||||
__MOVE("guard or testtype is not a pointer", errors_errors[86], 35);
|
||||
__MOVE("guarded or tested variable is neither a pointer nor a VAR-parameter record", errors_errors[87], 75);
|
||||
__MOVE("open array not allowed as variable, record field or array element", errors_errors[88], 66);
|
||||
errors_errors[89][0] = 0x00;
|
||||
errors_errors[90][0] = 0x00;
|
||||
errors_errors[91][0] = 0x00;
|
||||
__MOVE("operand of IN not an integer, or not a set", errors_errors[92], 43);
|
||||
__MOVE("set element type is not an integer", errors_errors[93], 35);
|
||||
__MOVE("operand of & is not of type BOOLEAN", errors_errors[94], 36);
|
||||
__MOVE("operand of OR is not of type BOOLEAN", errors_errors[95], 37);
|
||||
__MOVE("operand not applicable to (unary) +", errors_errors[96], 36);
|
||||
__MOVE("operand not applicable to (unary) -", errors_errors[97], 36);
|
||||
__MOVE("operand of ~ is not of type BOOLEAN", errors_errors[98], 36);
|
||||
__MOVE("ASSERT fault", errors_errors[99], 13);
|
||||
__MOVE("incompatible operands of dyadic operator", errors_errors[100], 41);
|
||||
__MOVE("operand type inapplicable to *", errors_errors[101], 31);
|
||||
__MOVE("operand type inapplicable to /", errors_errors[102], 31);
|
||||
__MOVE("operand type inapplicable to DIV", errors_errors[103], 33);
|
||||
__MOVE("operand type inapplicable to MOD", errors_errors[104], 33);
|
||||
__MOVE("operand type inapplicable to +", errors_errors[105], 31);
|
||||
__MOVE("operand type inapplicable to -", errors_errors[106], 31);
|
||||
__MOVE("operand type inapplicable to = or #", errors_errors[107], 36);
|
||||
__MOVE("operand type inapplicable to relation", errors_errors[108], 38);
|
||||
__MOVE("overriding method must be exported", errors_errors[109], 35);
|
||||
__MOVE("operand is not a type", errors_errors[110], 22);
|
||||
__MOVE("operand inapplicable to (this) function", errors_errors[111], 40);
|
||||
__MOVE("operand is not a variable", errors_errors[112], 26);
|
||||
__MOVE("incompatible assignment", errors_errors[113], 24);
|
||||
__MOVE("string too long to be assigned", errors_errors[114], 31);
|
||||
__MOVE("parameter doesn\'t match", errors_errors[115], 24);
|
||||
__MOVE("number of parameters doesn\'t match", errors_errors[116], 35);
|
||||
__MOVE("result type doesn\'t match", errors_errors[117], 26);
|
||||
__MOVE("export mark doesn\'t match with forward declaration", errors_errors[118], 51);
|
||||
__MOVE("redefinition textually precedes procedure bound to base type", errors_errors[119], 61);
|
||||
__MOVE("type of expression following IF, WHILE, UNTIL or ASSERT is not BOOLEAN", errors_errors[120], 71);
|
||||
__MOVE("called object is not a procedure (or is an interrupt procedure)", errors_errors[121], 64);
|
||||
__MOVE("actual VAR-parameter is not a variable", errors_errors[122], 39);
|
||||
__MOVE("type of actual parameter is not identical with that of formal VAR-parameter", errors_errors[123], 76);
|
||||
__MOVE("type of result expression differs from that of procedure", errors_errors[124], 57);
|
||||
__MOVE("type of case expression is neither INTEGER nor CHAR", errors_errors[125], 52);
|
||||
__MOVE("this expression cannot be a type or a procedure", errors_errors[126], 48);
|
||||
__MOVE("illegal use of object", errors_errors[127], 22);
|
||||
__MOVE("unsatisfied forward reference", errors_errors[128], 30);
|
||||
__MOVE("unsatisfied forward procedure", errors_errors[129], 30);
|
||||
__MOVE("WITH clause does not specify a variable", errors_errors[130], 40);
|
||||
__MOVE("LEN not applied to array", errors_errors[131], 25);
|
||||
__MOVE("dimension in LEN too large or negative", errors_errors[132], 39);
|
||||
__MOVE("SYSTEM not imported", errors_errors[135], 20);
|
||||
__MOVE("key inconsistency of imported module", errors_errors[150], 37);
|
||||
__MOVE("incorrect symbol file", errors_errors[151], 22);
|
||||
__MOVE("symbol file of imported module not found", errors_errors[152], 41);
|
||||
__MOVE("object or symbol file not opened (disk full\?)", errors_errors[153], 46);
|
||||
__MOVE("recursive import not allowed", errors_errors[154], 29);
|
||||
__MOVE("generation of new symbol file not allowed", errors_errors[155], 42);
|
||||
__MOVE("parameter file not found", errors_errors[156], 25);
|
||||
__MOVE("syntax error in parameter file", errors_errors[157], 31);
|
||||
__MOVE("not yet implemented", errors_errors[200], 20);
|
||||
__MOVE("lower bound of set range greater than higher bound", errors_errors[201], 51);
|
||||
__MOVE("set element greater than MAX(SET) or less than 0", errors_errors[202], 49);
|
||||
__MOVE("number too large", errors_errors[203], 17);
|
||||
__MOVE("product too large", errors_errors[204], 18);
|
||||
__MOVE("division by zero", errors_errors[205], 17);
|
||||
__MOVE("sum too large", errors_errors[206], 14);
|
||||
__MOVE("difference too large", errors_errors[207], 21);
|
||||
__MOVE("overflow in arithmetic shift", errors_errors[208], 29);
|
||||
__MOVE("case range too large", errors_errors[209], 21);
|
||||
__MOVE("too many cases in case statement", errors_errors[213], 33);
|
||||
__MOVE("illegal value of parameter (0 <= p < 256)", errors_errors[218], 42);
|
||||
__MOVE("machine registers cannot be accessed", errors_errors[219], 37);
|
||||
__MOVE("illegal value of parameter", errors_errors[220], 27);
|
||||
__MOVE("too many pointers in a record", errors_errors[221], 30);
|
||||
__MOVE("too many global pointers", errors_errors[222], 25);
|
||||
__MOVE("too many record types", errors_errors[223], 22);
|
||||
__MOVE("too many pointer types", errors_errors[224], 23);
|
||||
__MOVE("address of pointer variable too large (move forward in text)", errors_errors[225], 61);
|
||||
__MOVE("too many exported procedures", errors_errors[226], 29);
|
||||
__MOVE("too many imported modules", errors_errors[227], 26);
|
||||
__MOVE("too many exported structures", errors_errors[228], 29);
|
||||
__MOVE("too many nested records for import", errors_errors[229], 35);
|
||||
__MOVE("too many constants (strings) in module", errors_errors[230], 39);
|
||||
__MOVE("too many link table entries (external procedures)", errors_errors[231], 50);
|
||||
__MOVE("too many commands in module", errors_errors[232], 28);
|
||||
__MOVE("record extension hierarchy too high", errors_errors[233], 36);
|
||||
__MOVE("export of recursive type not allowed", errors_errors[234], 37);
|
||||
__MOVE("identifier too long", errors_errors[240], 20);
|
||||
__MOVE("string too long", errors_errors[241], 16);
|
||||
__MOVE("address overflow", errors_errors[242], 17);
|
||||
__MOVE("cyclic type definition not allowed", errors_errors[244], 35);
|
||||
__MOVE("guarded pointer variable may be manipulated by non-local operations; use auxiliary pointer variable", errors_errors[245], 100);
|
||||
__MOVE("implicit type cast", errors_errors[301], 19);
|
||||
__MOVE("inappropriate symbol file ignored", errors_errors[306], 34);
|
||||
__MOVE("no ELSE symbol after CASE statement sequence may lead to trap", errors_errors[307], 62);
|
||||
__ENDMOD;
|
||||
}
|
||||
18
bootstrap/unix-44/errors.h
Normal file
18
bootstrap/unix-44/errors.h
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#ifndef errors__h
|
||||
#define errors__h
|
||||
|
||||
#include "SYSTEM.h"
|
||||
|
||||
typedef
|
||||
CHAR errors_string[128];
|
||||
|
||||
|
||||
import errors_string errors_errors[350];
|
||||
|
||||
|
||||
import void *errors__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
112
bootstrap/unix-44/extTools.c
Normal file
112
bootstrap/unix-44/extTools.c
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
#include "SYSTEM.h"
|
||||
#include "Configuration.h"
|
||||
#include "Console.h"
|
||||
#include "OPM.h"
|
||||
#include "Platform.h"
|
||||
#include "Strings.h"
|
||||
|
||||
|
||||
static CHAR extTools_compilationOptions[1023], extTools_CFLAGS[1023];
|
||||
|
||||
|
||||
export void extTools_Assemble (CHAR *moduleName, LONGINT moduleName__len);
|
||||
export void extTools_LinkMain (CHAR *moduleName, LONGINT moduleName__len, BOOLEAN statically, CHAR *additionalopts, LONGINT additionalopts__len);
|
||||
static void extTools_execute (CHAR *title, LONGINT title__len, CHAR *cmd, LONGINT cmd__len);
|
||||
|
||||
|
||||
static void extTools_execute (CHAR *title, LONGINT title__len, CHAR *cmd, LONGINT cmd__len)
|
||||
{
|
||||
INTEGER r, status, exitcode;
|
||||
__DUP(title, title__len, CHAR);
|
||||
__DUP(cmd, cmd__len, CHAR);
|
||||
if (OPM_Verbose) {
|
||||
Console_String(title, title__len);
|
||||
Console_String(cmd, cmd__len);
|
||||
Console_Ln();
|
||||
}
|
||||
r = Platform_System(cmd, cmd__len);
|
||||
status = __MASK(r, -128);
|
||||
exitcode = __ASHR(r, 8);
|
||||
if (exitcode > 127) {
|
||||
exitcode = exitcode - 256;
|
||||
}
|
||||
if (r != 0) {
|
||||
Console_String(title, title__len);
|
||||
Console_String(cmd, cmd__len);
|
||||
Console_Ln();
|
||||
Console_String((CHAR*)"-- failed: status ", (LONGINT)19);
|
||||
Console_Int(status, ((LONGINT)(1)));
|
||||
Console_String((CHAR*)", exitcode ", (LONGINT)12);
|
||||
Console_Int(exitcode, ((LONGINT)(1)));
|
||||
Console_String((CHAR*)".", (LONGINT)2);
|
||||
Console_Ln();
|
||||
if ((status == 0 && exitcode == 127)) {
|
||||
Console_String((CHAR*)"Is the C compiler in the current command path\?", (LONGINT)47);
|
||||
Console_Ln();
|
||||
}
|
||||
if (status != 0) {
|
||||
Platform_Halt(status);
|
||||
} else {
|
||||
Platform_Halt(exitcode);
|
||||
}
|
||||
}
|
||||
__DEL(title);
|
||||
__DEL(cmd);
|
||||
}
|
||||
|
||||
void extTools_Assemble (CHAR *moduleName, LONGINT moduleName__len)
|
||||
{
|
||||
CHAR cmd[1023];
|
||||
__DUP(moduleName, moduleName__len, CHAR);
|
||||
__MOVE("gcc -g", cmd, 7);
|
||||
Strings_Append(extTools_compilationOptions, ((LONGINT)(1023)), (void*)cmd, ((LONGINT)(1023)));
|
||||
Strings_Append((CHAR*)"-c ", (LONGINT)4, (void*)cmd, ((LONGINT)(1023)));
|
||||
Strings_Append(moduleName, moduleName__len, (void*)cmd, ((LONGINT)(1023)));
|
||||
Strings_Append((CHAR*)".c", (LONGINT)3, (void*)cmd, ((LONGINT)(1023)));
|
||||
extTools_execute((CHAR*)"Assemble: ", (LONGINT)11, cmd, ((LONGINT)(1023)));
|
||||
__DEL(moduleName);
|
||||
}
|
||||
|
||||
void extTools_LinkMain (CHAR *moduleName, LONGINT moduleName__len, BOOLEAN statically, CHAR *additionalopts, LONGINT additionalopts__len)
|
||||
{
|
||||
CHAR cmd[1023];
|
||||
__DUP(additionalopts, additionalopts__len, CHAR);
|
||||
__MOVE("gcc -g", cmd, 7);
|
||||
Strings_Append((CHAR*)" ", (LONGINT)2, (void*)cmd, ((LONGINT)(1023)));
|
||||
Strings_Append(extTools_compilationOptions, ((LONGINT)(1023)), (void*)cmd, ((LONGINT)(1023)));
|
||||
Strings_Append(moduleName, moduleName__len, (void*)cmd, ((LONGINT)(1023)));
|
||||
Strings_Append((CHAR*)".c ", (LONGINT)4, (void*)cmd, ((LONGINT)(1023)));
|
||||
Strings_Append(additionalopts, additionalopts__len, (void*)cmd, ((LONGINT)(1023)));
|
||||
if (statically) {
|
||||
Strings_Append((CHAR*)"-static", (LONGINT)8, (void*)cmd, ((LONGINT)(1023)));
|
||||
}
|
||||
Strings_Append((CHAR*)" -o ", (LONGINT)5, (void*)cmd, ((LONGINT)(1023)));
|
||||
Strings_Append(moduleName, moduleName__len, (void*)cmd, ((LONGINT)(1023)));
|
||||
Strings_Append((CHAR*)" -L\"", (LONGINT)5, (void*)cmd, ((LONGINT)(1023)));
|
||||
Strings_Append((CHAR*)"/opt/voc", (LONGINT)9, (void*)cmd, ((LONGINT)(1023)));
|
||||
Strings_Append((CHAR*)"/lib\"", (LONGINT)6, (void*)cmd, ((LONGINT)(1023)));
|
||||
Strings_Append((CHAR*)" -l voc", (LONGINT)8, (void*)cmd, ((LONGINT)(1023)));
|
||||
extTools_execute((CHAR*)"Assemble and link: ", (LONGINT)20, cmd, ((LONGINT)(1023)));
|
||||
__DEL(additionalopts);
|
||||
}
|
||||
|
||||
|
||||
export void *extTools__init(void)
|
||||
{
|
||||
__DEFMOD;
|
||||
__MODULE_IMPORT(Configuration);
|
||||
__MODULE_IMPORT(Console);
|
||||
__MODULE_IMPORT(OPM);
|
||||
__MODULE_IMPORT(Platform);
|
||||
__MODULE_IMPORT(Strings);
|
||||
__REGMOD("extTools", 0);
|
||||
/* BEGIN */
|
||||
Strings_Append((CHAR*)" -I \"", (LONGINT)6, (void*)extTools_compilationOptions, ((LONGINT)(1023)));
|
||||
Strings_Append((CHAR*)"/opt/voc", (LONGINT)9, (void*)extTools_compilationOptions, ((LONGINT)(1023)));
|
||||
Strings_Append((CHAR*)"/include\" ", (LONGINT)11, (void*)extTools_compilationOptions, ((LONGINT)(1023)));
|
||||
Platform_GetEnv((CHAR*)"CFLAGS", (LONGINT)7, (void*)extTools_CFLAGS, ((LONGINT)(1023)));
|
||||
Strings_Append(extTools_CFLAGS, ((LONGINT)(1023)), (void*)extTools_compilationOptions, ((LONGINT)(1023)));
|
||||
Strings_Append((CHAR*)" ", (LONGINT)2, (void*)extTools_compilationOptions, ((LONGINT)(1023)));
|
||||
__ENDMOD;
|
||||
}
|
||||
16
bootstrap/unix-44/extTools.h
Normal file
16
bootstrap/unix-44/extTools.h
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#ifndef extTools__h
|
||||
#define extTools__h
|
||||
|
||||
#include "SYSTEM.h"
|
||||
|
||||
|
||||
|
||||
|
||||
import void extTools_Assemble (CHAR *moduleName, LONGINT moduleName__len);
|
||||
import void extTools_LinkMain (CHAR *moduleName, LONGINT moduleName__len, BOOLEAN statically, CHAR *additionalopts, LONGINT additionalopts__len);
|
||||
import void *extTools__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
258
bootstrap/unix-44/vt100.c
Normal file
258
bootstrap/unix-44/vt100.c
Normal file
|
|
@ -0,0 +1,258 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
#include "SYSTEM.h"
|
||||
#include "Console.h"
|
||||
#include "Strings.h"
|
||||
|
||||
|
||||
export CHAR vt100_CSI[5];
|
||||
static CHAR vt100_tmpstr[32];
|
||||
|
||||
|
||||
export void vt100_CHA (INTEGER n);
|
||||
export void vt100_CNL (INTEGER n);
|
||||
export void vt100_CPL (INTEGER n);
|
||||
export void vt100_CUB (INTEGER n);
|
||||
export void vt100_CUD (INTEGER n);
|
||||
export void vt100_CUF (INTEGER n);
|
||||
export void vt100_CUP (INTEGER n, INTEGER m);
|
||||
export void vt100_CUU (INTEGER n);
|
||||
export void vt100_DECTCEMh (void);
|
||||
export void vt100_DECTCEMl (void);
|
||||
export void vt100_DSR (INTEGER n);
|
||||
export void vt100_ED (INTEGER n);
|
||||
export void vt100_EL (INTEGER n);
|
||||
static void vt100_EscSeq (INTEGER n, CHAR *letter, LONGINT letter__len);
|
||||
static void vt100_EscSeq0 (CHAR *letter, LONGINT letter__len);
|
||||
static void vt100_EscSeq2 (INTEGER n, INTEGER m, CHAR *letter, LONGINT letter__len);
|
||||
static void vt100_EscSeqSwapped (INTEGER n, CHAR *letter, LONGINT letter__len);
|
||||
export void vt100_HVP (INTEGER n, INTEGER m);
|
||||
export void vt100_IntToStr (LONGINT int_, CHAR *str, LONGINT str__len);
|
||||
export void vt100_RCP (void);
|
||||
static void vt100_Reverse0 (CHAR *str, LONGINT str__len, INTEGER start, INTEGER end);
|
||||
export void vt100_SCP (void);
|
||||
export void vt100_SD (INTEGER n);
|
||||
export void vt100_SGR (INTEGER n);
|
||||
export void vt100_SGR2 (INTEGER n, INTEGER m);
|
||||
export void vt100_SU (INTEGER n);
|
||||
export void vt100_SetAttr (CHAR *attr, LONGINT attr__len);
|
||||
|
||||
|
||||
static void vt100_Reverse0 (CHAR *str, LONGINT str__len, INTEGER start, INTEGER end)
|
||||
{
|
||||
CHAR h;
|
||||
while (start < end) {
|
||||
h = str[__X(start, str__len)];
|
||||
str[__X(start, str__len)] = str[__X(end, str__len)];
|
||||
str[__X(end, str__len)] = h;
|
||||
start += 1;
|
||||
end -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
void vt100_IntToStr (LONGINT int_, CHAR *str, LONGINT str__len)
|
||||
{
|
||||
CHAR b[21];
|
||||
INTEGER s, e;
|
||||
SHORTINT maxLength;
|
||||
maxLength = 11;
|
||||
if (int_ == (-2147483647-1)) {
|
||||
__MOVE("-2147483648", b, 12);
|
||||
e = 11;
|
||||
} else {
|
||||
if (int_ < 0) {
|
||||
b[0] = '-';
|
||||
int_ = -int_;
|
||||
s = 1;
|
||||
} else {
|
||||
s = 0;
|
||||
}
|
||||
e = s;
|
||||
do {
|
||||
b[__X(e, ((LONGINT)(21)))] = (CHAR)(__MOD(int_, 10) + 48);
|
||||
int_ = __DIV(int_, 10);
|
||||
e += 1;
|
||||
} while (!(int_ == 0));
|
||||
b[__X(e, ((LONGINT)(21)))] = 0x00;
|
||||
vt100_Reverse0((void*)b, ((LONGINT)(21)), s, e - 1);
|
||||
}
|
||||
__COPY(b, str, str__len);
|
||||
}
|
||||
|
||||
static void vt100_EscSeq0 (CHAR *letter, LONGINT letter__len)
|
||||
{
|
||||
CHAR cmd[9];
|
||||
__DUP(letter, letter__len, CHAR);
|
||||
__COPY(vt100_CSI, cmd, ((LONGINT)(9)));
|
||||
Strings_Append(letter, letter__len, (void*)cmd, ((LONGINT)(9)));
|
||||
Console_String(cmd, ((LONGINT)(9)));
|
||||
__DEL(letter);
|
||||
}
|
||||
|
||||
static void vt100_EscSeq (INTEGER n, CHAR *letter, LONGINT letter__len)
|
||||
{
|
||||
CHAR nstr[2];
|
||||
CHAR cmd[7];
|
||||
__DUP(letter, letter__len, CHAR);
|
||||
vt100_IntToStr(n, (void*)nstr, ((LONGINT)(2)));
|
||||
__COPY(vt100_CSI, cmd, ((LONGINT)(7)));
|
||||
Strings_Append(nstr, ((LONGINT)(2)), (void*)cmd, ((LONGINT)(7)));
|
||||
Strings_Append(letter, letter__len, (void*)cmd, ((LONGINT)(7)));
|
||||
Console_String(cmd, ((LONGINT)(7)));
|
||||
__DEL(letter);
|
||||
}
|
||||
|
||||
static void vt100_EscSeqSwapped (INTEGER n, CHAR *letter, LONGINT letter__len)
|
||||
{
|
||||
CHAR nstr[2];
|
||||
CHAR cmd[7];
|
||||
__DUP(letter, letter__len, CHAR);
|
||||
vt100_IntToStr(n, (void*)nstr, ((LONGINT)(2)));
|
||||
__COPY(vt100_CSI, cmd, ((LONGINT)(7)));
|
||||
Strings_Append(letter, letter__len, (void*)cmd, ((LONGINT)(7)));
|
||||
Strings_Append(nstr, ((LONGINT)(2)), (void*)cmd, ((LONGINT)(7)));
|
||||
Console_String(cmd, ((LONGINT)(7)));
|
||||
__DEL(letter);
|
||||
}
|
||||
|
||||
static void vt100_EscSeq2 (INTEGER n, INTEGER m, CHAR *letter, LONGINT letter__len)
|
||||
{
|
||||
CHAR nstr[5], mstr[5];
|
||||
CHAR cmd[12];
|
||||
__DUP(letter, letter__len, CHAR);
|
||||
vt100_IntToStr(n, (void*)nstr, ((LONGINT)(5)));
|
||||
vt100_IntToStr(m, (void*)mstr, ((LONGINT)(5)));
|
||||
__COPY(vt100_CSI, cmd, ((LONGINT)(12)));
|
||||
Strings_Append(nstr, ((LONGINT)(5)), (void*)cmd, ((LONGINT)(12)));
|
||||
Strings_Append((CHAR*)";", (LONGINT)2, (void*)cmd, ((LONGINT)(12)));
|
||||
Strings_Append(mstr, ((LONGINT)(5)), (void*)cmd, ((LONGINT)(12)));
|
||||
Strings_Append(letter, letter__len, (void*)cmd, ((LONGINT)(12)));
|
||||
Console_String(cmd, ((LONGINT)(12)));
|
||||
__DEL(letter);
|
||||
}
|
||||
|
||||
void vt100_CUU (INTEGER n)
|
||||
{
|
||||
vt100_EscSeq(n, (CHAR*)"A", (LONGINT)2);
|
||||
}
|
||||
|
||||
void vt100_CUD (INTEGER n)
|
||||
{
|
||||
vt100_EscSeq(n, (CHAR*)"B", (LONGINT)2);
|
||||
}
|
||||
|
||||
void vt100_CUF (INTEGER n)
|
||||
{
|
||||
vt100_EscSeq(n, (CHAR*)"C", (LONGINT)2);
|
||||
}
|
||||
|
||||
void vt100_CUB (INTEGER n)
|
||||
{
|
||||
vt100_EscSeq(n, (CHAR*)"D", (LONGINT)2);
|
||||
}
|
||||
|
||||
void vt100_CNL (INTEGER n)
|
||||
{
|
||||
vt100_EscSeq(n, (CHAR*)"E", (LONGINT)2);
|
||||
}
|
||||
|
||||
void vt100_CPL (INTEGER n)
|
||||
{
|
||||
vt100_EscSeq(n, (CHAR*)"F", (LONGINT)2);
|
||||
}
|
||||
|
||||
void vt100_CHA (INTEGER n)
|
||||
{
|
||||
vt100_EscSeq(n, (CHAR*)"G", (LONGINT)2);
|
||||
}
|
||||
|
||||
void vt100_CUP (INTEGER n, INTEGER m)
|
||||
{
|
||||
vt100_EscSeq2(n, m, (CHAR*)"H", (LONGINT)2);
|
||||
}
|
||||
|
||||
void vt100_ED (INTEGER n)
|
||||
{
|
||||
vt100_EscSeq(n, (CHAR*)"J", (LONGINT)2);
|
||||
}
|
||||
|
||||
void vt100_EL (INTEGER n)
|
||||
{
|
||||
vt100_EscSeq(n, (CHAR*)"K", (LONGINT)2);
|
||||
}
|
||||
|
||||
void vt100_SU (INTEGER n)
|
||||
{
|
||||
vt100_EscSeq(n, (CHAR*)"S", (LONGINT)2);
|
||||
}
|
||||
|
||||
void vt100_SD (INTEGER n)
|
||||
{
|
||||
vt100_EscSeq(n, (CHAR*)"T", (LONGINT)2);
|
||||
}
|
||||
|
||||
void vt100_HVP (INTEGER n, INTEGER m)
|
||||
{
|
||||
vt100_EscSeq2(n, m, (CHAR*)"f", (LONGINT)2);
|
||||
}
|
||||
|
||||
void vt100_SGR (INTEGER n)
|
||||
{
|
||||
vt100_EscSeq(n, (CHAR*)"m", (LONGINT)2);
|
||||
}
|
||||
|
||||
void vt100_SGR2 (INTEGER n, INTEGER m)
|
||||
{
|
||||
vt100_EscSeq2(n, m, (CHAR*)"m", (LONGINT)2);
|
||||
}
|
||||
|
||||
void vt100_DSR (INTEGER n)
|
||||
{
|
||||
vt100_EscSeq(6, (CHAR*)"n", (LONGINT)2);
|
||||
}
|
||||
|
||||
void vt100_SCP (void)
|
||||
{
|
||||
vt100_EscSeq0((CHAR*)"s", (LONGINT)2);
|
||||
}
|
||||
|
||||
void vt100_RCP (void)
|
||||
{
|
||||
vt100_EscSeq0((CHAR*)"u", (LONGINT)2);
|
||||
}
|
||||
|
||||
void vt100_DECTCEMl (void)
|
||||
{
|
||||
vt100_EscSeq0((CHAR*)"\?25l", (LONGINT)5);
|
||||
}
|
||||
|
||||
void vt100_DECTCEMh (void)
|
||||
{
|
||||
vt100_EscSeq0((CHAR*)"\?25h", (LONGINT)5);
|
||||
}
|
||||
|
||||
void vt100_SetAttr (CHAR *attr, LONGINT attr__len)
|
||||
{
|
||||
CHAR tmpstr[16];
|
||||
__DUP(attr, attr__len, CHAR);
|
||||
__COPY(vt100_CSI, tmpstr, ((LONGINT)(16)));
|
||||
Strings_Append(attr, attr__len, (void*)tmpstr, ((LONGINT)(16)));
|
||||
Console_String(tmpstr, ((LONGINT)(16)));
|
||||
__DEL(attr);
|
||||
}
|
||||
|
||||
|
||||
export void *vt100__init(void)
|
||||
{
|
||||
__DEFMOD;
|
||||
__MODULE_IMPORT(Console);
|
||||
__MODULE_IMPORT(Strings);
|
||||
__REGMOD("vt100", 0);
|
||||
__REGCMD("DECTCEMh", vt100_DECTCEMh);
|
||||
__REGCMD("DECTCEMl", vt100_DECTCEMl);
|
||||
__REGCMD("RCP", vt100_RCP);
|
||||
__REGCMD("SCP", vt100_SCP);
|
||||
/* BEGIN */
|
||||
__COPY("", vt100_CSI, ((LONGINT)(5)));
|
||||
Strings_Append((CHAR*)"[", (LONGINT)2, (void*)vt100_CSI, ((LONGINT)(5)));
|
||||
__ENDMOD;
|
||||
}
|
||||
37
bootstrap/unix-44/vt100.h
Normal file
37
bootstrap/unix-44/vt100.h
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#ifndef vt100__h
|
||||
#define vt100__h
|
||||
|
||||
#include "SYSTEM.h"
|
||||
|
||||
|
||||
import CHAR vt100_CSI[5];
|
||||
|
||||
|
||||
import void vt100_CHA (INTEGER n);
|
||||
import void vt100_CNL (INTEGER n);
|
||||
import void vt100_CPL (INTEGER n);
|
||||
import void vt100_CUB (INTEGER n);
|
||||
import void vt100_CUD (INTEGER n);
|
||||
import void vt100_CUF (INTEGER n);
|
||||
import void vt100_CUP (INTEGER n, INTEGER m);
|
||||
import void vt100_CUU (INTEGER n);
|
||||
import void vt100_DECTCEMh (void);
|
||||
import void vt100_DECTCEMl (void);
|
||||
import void vt100_DSR (INTEGER n);
|
||||
import void vt100_ED (INTEGER n);
|
||||
import void vt100_EL (INTEGER n);
|
||||
import void vt100_HVP (INTEGER n, INTEGER m);
|
||||
import void vt100_IntToStr (LONGINT int_, CHAR *str, LONGINT str__len);
|
||||
import void vt100_RCP (void);
|
||||
import void vt100_SCP (void);
|
||||
import void vt100_SD (INTEGER n);
|
||||
import void vt100_SGR (INTEGER n);
|
||||
import void vt100_SGR2 (INTEGER n, INTEGER m);
|
||||
import void vt100_SU (INTEGER n);
|
||||
import void vt100_SetAttr (CHAR *attr, LONGINT attr__len);
|
||||
import void *vt100__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
16
bootstrap/unix-48/Configuration.c
Normal file
16
bootstrap/unix-48/Configuration.c
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
#include "SYSTEM.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export void *Configuration__init(void)
|
||||
{
|
||||
__DEFMOD;
|
||||
__REGMOD("Configuration", 0);
|
||||
/* BEGIN */
|
||||
__ENDMOD;
|
||||
}
|
||||
14
bootstrap/unix-48/Configuration.h
Normal file
14
bootstrap/unix-48/Configuration.h
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#ifndef Configuration__h
|
||||
#define Configuration__h
|
||||
|
||||
#include "SYSTEM.h"
|
||||
|
||||
|
||||
|
||||
|
||||
import void *Configuration__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
150
bootstrap/unix-48/Console.c
Normal file
150
bootstrap/unix-48/Console.c
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
#include "SYSTEM.h"
|
||||
#include "Platform.h"
|
||||
|
||||
|
||||
static CHAR Console_line[128];
|
||||
static INTEGER Console_pos;
|
||||
|
||||
|
||||
export void Console_Bool (BOOLEAN b);
|
||||
export void Console_Char (CHAR ch);
|
||||
export void Console_Flush (void);
|
||||
export void Console_Hex (LONGINT i);
|
||||
export void Console_Int (LONGINT i, LONGINT n);
|
||||
export void Console_Ln (void);
|
||||
export void Console_Read (CHAR *ch);
|
||||
export void Console_ReadLine (CHAR *line, LONGINT line__len);
|
||||
export void Console_String (CHAR *s, LONGINT s__len);
|
||||
|
||||
|
||||
void Console_Flush (void)
|
||||
{
|
||||
INTEGER error;
|
||||
error = Platform_Write(((LONGINT)(1)), (LONGINT)(uintptr_t)Console_line, Console_pos);
|
||||
Console_pos = 0;
|
||||
}
|
||||
|
||||
void Console_Char (CHAR ch)
|
||||
{
|
||||
if (Console_pos == 128) {
|
||||
Console_Flush();
|
||||
}
|
||||
Console_line[__X(Console_pos, ((LONGINT)(128)))] = ch;
|
||||
Console_pos += 1;
|
||||
if (ch == 0x0a) {
|
||||
Console_Flush();
|
||||
}
|
||||
}
|
||||
|
||||
void Console_String (CHAR *s, LONGINT s__len)
|
||||
{
|
||||
INTEGER i;
|
||||
__DUP(s, s__len, CHAR);
|
||||
i = 0;
|
||||
while (s[__X(i, s__len)] != 0x00) {
|
||||
Console_Char(s[__X(i, s__len)]);
|
||||
i += 1;
|
||||
}
|
||||
__DEL(s);
|
||||
}
|
||||
|
||||
void Console_Int (LONGINT i, LONGINT n)
|
||||
{
|
||||
CHAR s[32];
|
||||
LONGINT i1, k;
|
||||
if (i == __LSHL(1, 31, LONGINT)) {
|
||||
__MOVE("8463847412", s, 11);
|
||||
k = 10;
|
||||
} else {
|
||||
i1 = __ABS(i);
|
||||
s[0] = (CHAR)(__MOD(i1, 10) + 48);
|
||||
i1 = __DIV(i1, 10);
|
||||
k = 1;
|
||||
while (i1 > 0) {
|
||||
s[__X(k, ((LONGINT)(32)))] = (CHAR)(__MOD(i1, 10) + 48);
|
||||
i1 = __DIV(i1, 10);
|
||||
k += 1;
|
||||
}
|
||||
}
|
||||
if (i < 0) {
|
||||
s[__X(k, ((LONGINT)(32)))] = '-';
|
||||
k += 1;
|
||||
}
|
||||
while (n > k) {
|
||||
Console_Char(' ');
|
||||
n -= 1;
|
||||
}
|
||||
while (k > 0) {
|
||||
k -= 1;
|
||||
Console_Char(s[__X(k, ((LONGINT)(32)))]);
|
||||
}
|
||||
}
|
||||
|
||||
void Console_Ln (void)
|
||||
{
|
||||
Console_Char(0x0a);
|
||||
}
|
||||
|
||||
void Console_Bool (BOOLEAN b)
|
||||
{
|
||||
if (b) {
|
||||
Console_String((CHAR*)"TRUE", (LONGINT)5);
|
||||
} else {
|
||||
Console_String((CHAR*)"FALSE", (LONGINT)6);
|
||||
}
|
||||
}
|
||||
|
||||
void Console_Hex (LONGINT i)
|
||||
{
|
||||
LONGINT k, n;
|
||||
k = -28;
|
||||
while (k <= 0) {
|
||||
n = __MASK(__ASH(i, k), -16);
|
||||
if (n <= 9) {
|
||||
Console_Char((CHAR)(48 + n));
|
||||
} else {
|
||||
Console_Char((CHAR)(55 + n));
|
||||
}
|
||||
k += 4;
|
||||
}
|
||||
}
|
||||
|
||||
void Console_Read (CHAR *ch)
|
||||
{
|
||||
LONGINT n;
|
||||
INTEGER error;
|
||||
Console_Flush();
|
||||
error = Platform_ReadBuf(((LONGINT)(0)), (void*)&*ch, ((LONGINT)(1)), &n);
|
||||
if (n != 1) {
|
||||
*ch = 0x00;
|
||||
}
|
||||
}
|
||||
|
||||
void Console_ReadLine (CHAR *line, LONGINT line__len)
|
||||
{
|
||||
LONGINT i;
|
||||
CHAR ch;
|
||||
Console_Flush();
|
||||
i = 0;
|
||||
Console_Read(&ch);
|
||||
while ((((i < line__len - 1 && ch != 0x0a)) && ch != 0x00)) {
|
||||
line[__X(i, line__len)] = ch;
|
||||
i += 1;
|
||||
Console_Read(&ch);
|
||||
}
|
||||
line[__X(i, line__len)] = 0x00;
|
||||
}
|
||||
|
||||
|
||||
export void *Console__init(void)
|
||||
{
|
||||
__DEFMOD;
|
||||
__MODULE_IMPORT(Platform);
|
||||
__REGMOD("Console", 0);
|
||||
__REGCMD("Flush", Console_Flush);
|
||||
__REGCMD("Ln", Console_Ln);
|
||||
/* BEGIN */
|
||||
Console_pos = 0;
|
||||
__ENDMOD;
|
||||
}
|
||||
23
bootstrap/unix-48/Console.h
Normal file
23
bootstrap/unix-48/Console.h
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#ifndef Console__h
|
||||
#define Console__h
|
||||
|
||||
#include "SYSTEM.h"
|
||||
|
||||
|
||||
|
||||
|
||||
import void Console_Bool (BOOLEAN b);
|
||||
import void Console_Char (CHAR ch);
|
||||
import void Console_Flush (void);
|
||||
import void Console_Hex (LONGINT i);
|
||||
import void Console_Int (LONGINT i, LONGINT n);
|
||||
import void Console_Ln (void);
|
||||
import void Console_Read (CHAR *ch);
|
||||
import void Console_ReadLine (CHAR *line, LONGINT line__len);
|
||||
import void Console_String (CHAR *s, LONGINT s__len);
|
||||
import void *Console__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
1078
bootstrap/unix-48/Files.c
Normal file
1078
bootstrap/unix-48/Files.c
Normal file
File diff suppressed because it is too large
Load diff
70
bootstrap/unix-48/Files.h
Normal file
70
bootstrap/unix-48/Files.h
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin tspkaSfF */
|
||||
|
||||
#ifndef Files__h
|
||||
#define Files__h
|
||||
|
||||
#include "SYSTEM.h"
|
||||
|
||||
typedef
|
||||
struct Files_Handle *Files_File;
|
||||
|
||||
typedef
|
||||
struct Files_Handle {
|
||||
char _prvt0[216];
|
||||
LONGINT fd;
|
||||
char _prvt1[28];
|
||||
} Files_Handle;
|
||||
|
||||
typedef
|
||||
struct Files_Rider {
|
||||
LONGINT res;
|
||||
BOOLEAN eof;
|
||||
char _prvt0[15];
|
||||
} Files_Rider;
|
||||
|
||||
|
||||
|
||||
import LONGINT *Files_Handle__typ;
|
||||
import LONGINT *Files_Rider__typ;
|
||||
|
||||
import Files_File Files_Base (Files_Rider *r, LONGINT *r__typ);
|
||||
import void Files_ChangeDirectory (CHAR *path, LONGINT path__len, INTEGER *res);
|
||||
import void Files_Close (Files_File f);
|
||||
import void Files_Delete (CHAR *name, LONGINT name__len, INTEGER *res);
|
||||
import void Files_GetDate (Files_File f, LONGINT *t, LONGINT *d);
|
||||
import void Files_GetName (Files_File f, CHAR *name, LONGINT name__len);
|
||||
import LONGINT Files_Length (Files_File f);
|
||||
import Files_File Files_New (CHAR *name, LONGINT name__len);
|
||||
import Files_File Files_Old (CHAR *name, LONGINT name__len);
|
||||
import LONGINT Files_Pos (Files_Rider *r, LONGINT *r__typ);
|
||||
import void Files_Purge (Files_File f);
|
||||
import void Files_Read (Files_Rider *r, LONGINT *r__typ, SYSTEM_BYTE *x);
|
||||
import void Files_ReadBool (Files_Rider *R, LONGINT *R__typ, BOOLEAN *x);
|
||||
import void Files_ReadByte (Files_Rider *r, LONGINT *r__typ, SYSTEM_BYTE *x, LONGINT x__len);
|
||||
import void Files_ReadBytes (Files_Rider *r, LONGINT *r__typ, SYSTEM_BYTE *x, LONGINT x__len, LONGINT n);
|
||||
import void Files_ReadInt (Files_Rider *R, LONGINT *R__typ, INTEGER *x);
|
||||
import void Files_ReadLInt (Files_Rider *R, LONGINT *R__typ, LONGINT *x);
|
||||
import void Files_ReadLReal (Files_Rider *R, LONGINT *R__typ, LONGREAL *x);
|
||||
import void Files_ReadLine (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len);
|
||||
import void Files_ReadNum (Files_Rider *R, LONGINT *R__typ, LONGINT *x);
|
||||
import void Files_ReadReal (Files_Rider *R, LONGINT *R__typ, REAL *x);
|
||||
import void Files_ReadSet (Files_Rider *R, LONGINT *R__typ, SET *x);
|
||||
import void Files_ReadString (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len);
|
||||
import void Files_Register (Files_File f);
|
||||
import void Files_Rename (CHAR *old, LONGINT old__len, CHAR *new, LONGINT new__len, INTEGER *res);
|
||||
import void Files_Set (Files_Rider *r, LONGINT *r__typ, Files_File f, LONGINT pos);
|
||||
import void Files_SetSearchPath (CHAR *path, LONGINT path__len);
|
||||
import void Files_Write (Files_Rider *r, LONGINT *r__typ, SYSTEM_BYTE x);
|
||||
import void Files_WriteBool (Files_Rider *R, LONGINT *R__typ, BOOLEAN x);
|
||||
import void Files_WriteBytes (Files_Rider *r, LONGINT *r__typ, SYSTEM_BYTE *x, LONGINT x__len, LONGINT n);
|
||||
import void Files_WriteInt (Files_Rider *R, LONGINT *R__typ, INTEGER x);
|
||||
import void Files_WriteLInt (Files_Rider *R, LONGINT *R__typ, LONGINT x);
|
||||
import void Files_WriteLReal (Files_Rider *R, LONGINT *R__typ, LONGREAL x);
|
||||
import void Files_WriteNum (Files_Rider *R, LONGINT *R__typ, LONGINT x);
|
||||
import void Files_WriteReal (Files_Rider *R, LONGINT *R__typ, REAL x);
|
||||
import void Files_WriteSet (Files_Rider *R, LONGINT *R__typ, SET x);
|
||||
import void Files_WriteString (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len);
|
||||
import void *Files__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
752
bootstrap/unix-48/Heap.c
Normal file
752
bootstrap/unix-48/Heap.c
Normal file
|
|
@ -0,0 +1,752 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin tskSfF */
|
||||
#include "SYSTEM.h"
|
||||
|
||||
struct Heap__1 {
|
||||
CHAR ch;
|
||||
SYSTEM_PTR p;
|
||||
};
|
||||
|
||||
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));
|
||||
|
||||
typedef
|
||||
struct Heap_FinDesc *Heap_FinNode;
|
||||
|
||||
typedef
|
||||
void (*Heap_Finalizer)(SYSTEM_PTR);
|
||||
|
||||
typedef
|
||||
struct Heap_FinDesc {
|
||||
Heap_FinNode next;
|
||||
LONGINT obj;
|
||||
BOOLEAN marked;
|
||||
Heap_Finalizer finalize;
|
||||
} Heap_FinDesc;
|
||||
|
||||
typedef
|
||||
struct Heap_ModuleDesc *Heap_Module;
|
||||
|
||||
typedef
|
||||
CHAR Heap_ModuleName[20];
|
||||
|
||||
typedef
|
||||
struct Heap_ModuleDesc {
|
||||
Heap_Module next;
|
||||
Heap_ModuleName name;
|
||||
LONGINT refcnt;
|
||||
Heap_Cmd cmds;
|
||||
LONGINT types;
|
||||
Heap_EnumProc enumPtrs;
|
||||
LONGINT reserved1, reserved2;
|
||||
} Heap_ModuleDesc;
|
||||
|
||||
|
||||
export SYSTEM_PTR Heap_modules;
|
||||
static LONGINT Heap_freeList[10];
|
||||
static LONGINT Heap_bigBlocks;
|
||||
export LONGINT Heap_allocated;
|
||||
static BOOLEAN Heap_firstTry;
|
||||
static LONGINT Heap_heap, Heap_heapend;
|
||||
export LONGINT Heap_heapsize;
|
||||
static Heap_FinNode Heap_fin;
|
||||
static INTEGER Heap_lockdepth;
|
||||
static BOOLEAN Heap_interrupted;
|
||||
export INTEGER Heap_FileCount;
|
||||
|
||||
export LONGINT *Heap_ModuleDesc__typ;
|
||||
export LONGINT *Heap_CmdDesc__typ;
|
||||
export LONGINT *Heap_FinDesc__typ;
|
||||
export LONGINT *Heap__1__typ;
|
||||
|
||||
static void Heap_CheckFin (void);
|
||||
static void Heap_ExtendHeap (LONGINT blksz);
|
||||
export void Heap_FINALL (void);
|
||||
static void Heap_Finalize (void);
|
||||
export void Heap_GC (BOOLEAN markStack);
|
||||
static void Heap_HeapSort (LONGINT n, LONGINT *a, LONGINT a__len);
|
||||
export void Heap_INCREF (Heap_Module m);
|
||||
export void Heap_InitHeap (void);
|
||||
export void Heap_Lock (void);
|
||||
static void Heap_Mark (LONGINT q);
|
||||
static void Heap_MarkCandidates (LONGINT n, LONGINT *cand, LONGINT cand__len);
|
||||
static void Heap_MarkP (SYSTEM_PTR p);
|
||||
static void Heap_MarkStack (LONGINT n, LONGINT *cand, LONGINT cand__len);
|
||||
export SYSTEM_PTR Heap_NEWBLK (LONGINT size);
|
||||
export SYSTEM_PTR Heap_NEWREC (LONGINT tag);
|
||||
static LONGINT Heap_NewChunk (LONGINT blksz);
|
||||
export void Heap_REGCMD (Heap_Module m, Heap_CmdName name, Heap_Command cmd);
|
||||
export SYSTEM_PTR Heap_REGMOD (Heap_ModuleName name, Heap_EnumProc enumPtrs);
|
||||
export void Heap_REGTYP (Heap_Module m, LONGINT typ);
|
||||
export void Heap_RegisterFinalizer (SYSTEM_PTR obj, Heap_Finalizer finalize);
|
||||
static void Heap_Scan (void);
|
||||
static void Heap_Sift (LONGINT l, LONGINT r, LONGINT *a, LONGINT a__len);
|
||||
export void Heap_Unlock (void);
|
||||
|
||||
extern void *Heap__init();
|
||||
extern LONGINT Platform_MainStackFrame;
|
||||
extern LONGINT Platform_OSAllocate(LONGINT size);
|
||||
#define Heap_FetchAddress(pointer) (LONGINT)(uintptr_t)(*((void**)((uintptr_t)pointer)))
|
||||
#define Heap_HeapModuleInit() Heap__init()
|
||||
#define Heap_OSAllocate(size) Platform_OSAllocate(size)
|
||||
#define Heap_PlatformHalt(code) Platform_Halt(code)
|
||||
#define Heap_PlatformMainStackFrame() Platform_MainStackFrame
|
||||
|
||||
void Heap_Lock (void)
|
||||
{
|
||||
Heap_lockdepth += 1;
|
||||
}
|
||||
|
||||
void Heap_Unlock (void)
|
||||
{
|
||||
Heap_lockdepth -= 1;
|
||||
if ((Heap_interrupted && Heap_lockdepth == 0)) {
|
||||
Heap_PlatformHalt(((LONGINT)(-9)));
|
||||
}
|
||||
}
|
||||
|
||||
SYSTEM_PTR Heap_REGMOD (Heap_ModuleName name, Heap_EnumProc enumPtrs)
|
||||
{
|
||||
SYSTEM_PTR _o_result;
|
||||
Heap_Module m;
|
||||
if (__STRCMP(name, "Heap") == 0) {
|
||||
__SYSNEW(m, 48);
|
||||
} else {
|
||||
__NEW(m, Heap_ModuleDesc);
|
||||
}
|
||||
m->types = 0;
|
||||
m->cmds = NIL;
|
||||
__COPY(name, m->name, ((LONGINT)(20)));
|
||||
m->refcnt = 0;
|
||||
m->enumPtrs = enumPtrs;
|
||||
m->next = (Heap_Module)(uintptr_t)Heap_modules;
|
||||
Heap_modules = (SYSTEM_PTR)m;
|
||||
_o_result = (void*)m;
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
void Heap_REGCMD (Heap_Module m, Heap_CmdName name, Heap_Command cmd)
|
||||
{
|
||||
Heap_Cmd c;
|
||||
if (__STRCMP(m->name, "Heap") == 0) {
|
||||
__SYSNEW(c, 32);
|
||||
} else {
|
||||
__NEW(c, Heap_CmdDesc);
|
||||
}
|
||||
__COPY(name, c->name, ((LONGINT)(24)));
|
||||
c->cmd = cmd;
|
||||
c->next = m->cmds;
|
||||
m->cmds = c;
|
||||
}
|
||||
|
||||
void Heap_REGTYP (Heap_Module m, LONGINT typ)
|
||||
{
|
||||
__PUT(typ, m->types, LONGINT);
|
||||
m->types = typ;
|
||||
}
|
||||
|
||||
void Heap_INCREF (Heap_Module m)
|
||||
{
|
||||
m->refcnt += 1;
|
||||
}
|
||||
|
||||
static LONGINT Heap_NewChunk (LONGINT blksz)
|
||||
{
|
||||
LONGINT _o_result;
|
||||
LONGINT chnk;
|
||||
chnk = Heap_OSAllocate(blksz + 12);
|
||||
if (chnk != 0) {
|
||||
__PUT(chnk + 4, chnk + (12 + blksz), LONGINT);
|
||||
__PUT(chnk + 12, chnk + 16, LONGINT);
|
||||
__PUT(chnk + 16, blksz, LONGINT);
|
||||
__PUT(chnk + 20, -4, LONGINT);
|
||||
__PUT(chnk + 24, Heap_bigBlocks, LONGINT);
|
||||
Heap_bigBlocks = chnk + 12;
|
||||
Heap_heapsize += blksz;
|
||||
}
|
||||
_o_result = chnk;
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
static void Heap_ExtendHeap (LONGINT blksz)
|
||||
{
|
||||
LONGINT size, chnk, j, next;
|
||||
if (blksz > 160000) {
|
||||
size = blksz;
|
||||
} else {
|
||||
size = 160000;
|
||||
}
|
||||
chnk = Heap_NewChunk(size);
|
||||
if (chnk != 0) {
|
||||
if (chnk < Heap_heap) {
|
||||
__PUT(chnk, Heap_heap, LONGINT);
|
||||
Heap_heap = chnk;
|
||||
} else {
|
||||
j = Heap_heap;
|
||||
next = Heap_FetchAddress(j);
|
||||
while ((next != 0 && chnk > next)) {
|
||||
j = next;
|
||||
next = Heap_FetchAddress(j);
|
||||
}
|
||||
__PUT(chnk, next, LONGINT);
|
||||
__PUT(j, chnk, LONGINT);
|
||||
}
|
||||
if (next == 0) {
|
||||
Heap_heapend = Heap_FetchAddress(chnk + 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SYSTEM_PTR Heap_NEWREC (LONGINT tag)
|
||||
{
|
||||
SYSTEM_PTR _o_result;
|
||||
LONGINT i, i0, di, blksz, restsize, t, adr, end, next, prev;
|
||||
SYSTEM_PTR new;
|
||||
Heap_Lock();
|
||||
blksz = Heap_FetchAddress(tag);
|
||||
i0 = __ASHR(blksz, 4);
|
||||
i = i0;
|
||||
if (i < 9) {
|
||||
adr = Heap_freeList[i];
|
||||
while (adr == 0) {
|
||||
i += 1;
|
||||
adr = Heap_freeList[i];
|
||||
}
|
||||
}
|
||||
if (i < 9) {
|
||||
next = Heap_FetchAddress(adr + 12);
|
||||
Heap_freeList[i] = next;
|
||||
if (i != i0) {
|
||||
di = i - i0;
|
||||
restsize = __ASHL(di, 4);
|
||||
end = adr + restsize;
|
||||
__PUT(end + 4, blksz, LONGINT);
|
||||
__PUT(end + 8, -4, LONGINT);
|
||||
__PUT(end, end + 4, LONGINT);
|
||||
__PUT(adr + 4, restsize, LONGINT);
|
||||
__PUT(adr + 12, Heap_freeList[di], LONGINT);
|
||||
Heap_freeList[di] = adr;
|
||||
adr += restsize;
|
||||
}
|
||||
} else {
|
||||
adr = Heap_bigBlocks;
|
||||
prev = 0;
|
||||
for (;;) {
|
||||
if (adr == 0) {
|
||||
if (Heap_firstTry) {
|
||||
Heap_GC(1);
|
||||
blksz += 16;
|
||||
if (__ASHL((Heap_heapsize - Heap_allocated) - blksz, 2) < Heap_heapsize) {
|
||||
Heap_ExtendHeap(__ASHL(__DIV(Heap_allocated + blksz, 48), 6) - Heap_heapsize);
|
||||
}
|
||||
Heap_firstTry = 0;
|
||||
new = Heap_NEWREC(tag);
|
||||
Heap_firstTry = 1;
|
||||
if (new == NIL) {
|
||||
Heap_ExtendHeap(__ASHL(__DIV(Heap_allocated + blksz, 48), 6) - Heap_heapsize);
|
||||
new = Heap_NEWREC(tag);
|
||||
}
|
||||
Heap_Unlock();
|
||||
_o_result = new;
|
||||
return _o_result;
|
||||
} else {
|
||||
Heap_Unlock();
|
||||
_o_result = NIL;
|
||||
return _o_result;
|
||||
}
|
||||
}
|
||||
t = Heap_FetchAddress(adr + 4);
|
||||
if (t >= blksz) {
|
||||
break;
|
||||
}
|
||||
prev = adr;
|
||||
adr = Heap_FetchAddress(adr + 12);
|
||||
}
|
||||
restsize = t - blksz;
|
||||
end = adr + restsize;
|
||||
__PUT(end + 4, blksz, LONGINT);
|
||||
__PUT(end + 8, -4, LONGINT);
|
||||
__PUT(end, end + 4, LONGINT);
|
||||
if (restsize > 144) {
|
||||
__PUT(adr + 4, restsize, LONGINT);
|
||||
} else {
|
||||
next = Heap_FetchAddress(adr + 12);
|
||||
if (prev == 0) {
|
||||
Heap_bigBlocks = next;
|
||||
} else {
|
||||
__PUT(prev + 12, next, LONGINT);
|
||||
}
|
||||
if (restsize > 0) {
|
||||
di = __ASHR(restsize, 4);
|
||||
__PUT(adr + 4, restsize, LONGINT);
|
||||
__PUT(adr + 12, Heap_freeList[di], LONGINT);
|
||||
Heap_freeList[di] = adr;
|
||||
}
|
||||
}
|
||||
adr += restsize;
|
||||
}
|
||||
i = adr + 16;
|
||||
end = adr + blksz;
|
||||
while (i < end) {
|
||||
__PUT(i, 0, LONGINT);
|
||||
__PUT(i + 4, 0, LONGINT);
|
||||
__PUT(i + 8, 0, LONGINT);
|
||||
__PUT(i + 12, 0, LONGINT);
|
||||
i += 16;
|
||||
}
|
||||
__PUT(adr + 12, 0, LONGINT);
|
||||
__PUT(adr, tag, LONGINT);
|
||||
__PUT(adr + 4, 0, LONGINT);
|
||||
__PUT(adr + 8, 0, LONGINT);
|
||||
Heap_allocated += blksz;
|
||||
Heap_Unlock();
|
||||
_o_result = (SYSTEM_PTR)(uintptr_t)(adr + 4);
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
SYSTEM_PTR Heap_NEWBLK (LONGINT size)
|
||||
{
|
||||
SYSTEM_PTR _o_result;
|
||||
LONGINT blksz, tag;
|
||||
SYSTEM_PTR new;
|
||||
Heap_Lock();
|
||||
blksz = __ASHL(__ASHR(size + 31, 4), 4);
|
||||
new = Heap_NEWREC((LONGINT)(uintptr_t)&blksz);
|
||||
tag = ((LONGINT)(uintptr_t)new + blksz) - 12;
|
||||
__PUT(tag - 4, 0, LONGINT);
|
||||
__PUT(tag, blksz, LONGINT);
|
||||
__PUT(tag + 4, -4, LONGINT);
|
||||
__PUT((LONGINT)(uintptr_t)new - 4, tag, LONGINT);
|
||||
Heap_Unlock();
|
||||
_o_result = new;
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
static void Heap_Mark (LONGINT q)
|
||||
{
|
||||
LONGINT p, tag, fld, n, offset, tagbits;
|
||||
if (q != 0) {
|
||||
tagbits = Heap_FetchAddress(q - 4);
|
||||
if (!__ODD(tagbits)) {
|
||||
__PUT(q - 4, tagbits + 1, LONGINT);
|
||||
p = 0;
|
||||
tag = tagbits + 4;
|
||||
for (;;) {
|
||||
__GET(tag, offset, LONGINT);
|
||||
if (offset < 0) {
|
||||
__PUT(q - 4, (tag + offset) + 1, LONGINT);
|
||||
if (p == 0) {
|
||||
break;
|
||||
}
|
||||
n = q;
|
||||
q = p;
|
||||
tag = Heap_FetchAddress(q - 4);
|
||||
tag -= 1;
|
||||
__GET(tag, offset, LONGINT);
|
||||
fld = q + offset;
|
||||
p = Heap_FetchAddress(fld);
|
||||
__PUT(fld, (SYSTEM_PTR)(uintptr_t)n, SYSTEM_PTR);
|
||||
} else {
|
||||
fld = q + offset;
|
||||
n = Heap_FetchAddress(fld);
|
||||
if (n != 0) {
|
||||
tagbits = Heap_FetchAddress(n - 4);
|
||||
if (!__ODD(tagbits)) {
|
||||
__PUT(n - 4, tagbits + 1, LONGINT);
|
||||
__PUT(q - 4, tag + 1, LONGINT);
|
||||
__PUT(fld, (SYSTEM_PTR)(uintptr_t)p, SYSTEM_PTR);
|
||||
p = q;
|
||||
q = n;
|
||||
tag = tagbits;
|
||||
}
|
||||
}
|
||||
}
|
||||
tag += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void Heap_MarkP (SYSTEM_PTR p)
|
||||
{
|
||||
Heap_Mark((LONGINT)(uintptr_t)p);
|
||||
}
|
||||
|
||||
static void Heap_Scan (void)
|
||||
{
|
||||
LONGINT chnk, adr, end, start, tag, i, size, freesize;
|
||||
Heap_bigBlocks = 0;
|
||||
i = 1;
|
||||
while (i < 9) {
|
||||
Heap_freeList[i] = 0;
|
||||
i += 1;
|
||||
}
|
||||
freesize = 0;
|
||||
Heap_allocated = 0;
|
||||
chnk = Heap_heap;
|
||||
while (chnk != 0) {
|
||||
adr = chnk + 12;
|
||||
end = Heap_FetchAddress(chnk + 4);
|
||||
while (adr < end) {
|
||||
tag = Heap_FetchAddress(adr);
|
||||
if (__ODD(tag)) {
|
||||
if (freesize > 0) {
|
||||
start = adr - freesize;
|
||||
__PUT(start, start + 4, LONGINT);
|
||||
__PUT(start + 4, freesize, LONGINT);
|
||||
__PUT(start + 8, -4, LONGINT);
|
||||
i = __ASHR(freesize, 4);
|
||||
freesize = 0;
|
||||
if (i < 9) {
|
||||
__PUT(start + 12, Heap_freeList[i], LONGINT);
|
||||
Heap_freeList[i] = start;
|
||||
} else {
|
||||
__PUT(start + 12, Heap_bigBlocks, LONGINT);
|
||||
Heap_bigBlocks = start;
|
||||
}
|
||||
}
|
||||
tag -= 1;
|
||||
__PUT(adr, tag, LONGINT);
|
||||
size = Heap_FetchAddress(tag);
|
||||
Heap_allocated += size;
|
||||
adr += size;
|
||||
} else {
|
||||
size = Heap_FetchAddress(tag);
|
||||
freesize += size;
|
||||
adr += size;
|
||||
}
|
||||
}
|
||||
if (freesize > 0) {
|
||||
start = adr - freesize;
|
||||
__PUT(start, start + 4, LONGINT);
|
||||
__PUT(start + 4, freesize, LONGINT);
|
||||
__PUT(start + 8, -4, LONGINT);
|
||||
i = __ASHR(freesize, 4);
|
||||
freesize = 0;
|
||||
if (i < 9) {
|
||||
__PUT(start + 12, Heap_freeList[i], LONGINT);
|
||||
Heap_freeList[i] = start;
|
||||
} else {
|
||||
__PUT(start + 12, Heap_bigBlocks, LONGINT);
|
||||
Heap_bigBlocks = start;
|
||||
}
|
||||
}
|
||||
chnk = Heap_FetchAddress(chnk);
|
||||
}
|
||||
}
|
||||
|
||||
static void Heap_Sift (LONGINT l, LONGINT r, LONGINT *a, LONGINT a__len)
|
||||
{
|
||||
LONGINT i, j, x;
|
||||
j = l;
|
||||
x = a[j];
|
||||
for (;;) {
|
||||
i = j;
|
||||
j = __ASHL(j, 1) + 1;
|
||||
if ((j < r && a[j] < a[j + 1])) {
|
||||
j += 1;
|
||||
}
|
||||
if (j > r || a[j] <= x) {
|
||||
break;
|
||||
}
|
||||
a[i] = a[j];
|
||||
}
|
||||
a[i] = x;
|
||||
}
|
||||
|
||||
static void Heap_HeapSort (LONGINT n, LONGINT *a, LONGINT a__len)
|
||||
{
|
||||
LONGINT l, r, x;
|
||||
l = __ASHR(n, 1);
|
||||
r = n - 1;
|
||||
while (l > 0) {
|
||||
l -= 1;
|
||||
Heap_Sift(l, r, (void*)a, a__len);
|
||||
}
|
||||
while (r > 0) {
|
||||
x = a[0];
|
||||
a[0] = a[r];
|
||||
a[r] = x;
|
||||
r -= 1;
|
||||
Heap_Sift(l, r, (void*)a, a__len);
|
||||
}
|
||||
}
|
||||
|
||||
static void Heap_MarkCandidates (LONGINT n, LONGINT *cand, LONGINT cand__len)
|
||||
{
|
||||
LONGINT chnk, adr, tag, next, lim, lim1, i, ptr, size;
|
||||
chnk = Heap_heap;
|
||||
i = 0;
|
||||
lim = cand[n - 1];
|
||||
while ((chnk != 0 && chnk < lim)) {
|
||||
adr = chnk + 12;
|
||||
lim1 = Heap_FetchAddress(chnk + 4);
|
||||
if (lim < lim1) {
|
||||
lim1 = lim;
|
||||
}
|
||||
while (adr < lim1) {
|
||||
tag = Heap_FetchAddress(adr);
|
||||
if (__ODD(tag)) {
|
||||
size = Heap_FetchAddress(tag - 1);
|
||||
adr += size;
|
||||
} else {
|
||||
size = Heap_FetchAddress(tag);
|
||||
ptr = adr + 4;
|
||||
while (cand[i] < ptr) {
|
||||
i += 1;
|
||||
}
|
||||
if (i == n) {
|
||||
return;
|
||||
}
|
||||
next = adr + size;
|
||||
if (cand[i] < next) {
|
||||
Heap_Mark(ptr);
|
||||
}
|
||||
adr = next;
|
||||
}
|
||||
}
|
||||
chnk = Heap_FetchAddress(chnk);
|
||||
}
|
||||
}
|
||||
|
||||
static void Heap_CheckFin (void)
|
||||
{
|
||||
Heap_FinNode n;
|
||||
LONGINT tag;
|
||||
n = Heap_fin;
|
||||
while (n != NIL) {
|
||||
tag = Heap_FetchAddress(n->obj - 4);
|
||||
if (!__ODD(tag)) {
|
||||
n->marked = 0;
|
||||
Heap_Mark(n->obj);
|
||||
} else {
|
||||
n->marked = 1;
|
||||
}
|
||||
n = n->next;
|
||||
}
|
||||
}
|
||||
|
||||
static void Heap_Finalize (void)
|
||||
{
|
||||
Heap_FinNode n, prev;
|
||||
n = Heap_fin;
|
||||
prev = NIL;
|
||||
while (n != NIL) {
|
||||
if (!n->marked) {
|
||||
if (n == Heap_fin) {
|
||||
Heap_fin = Heap_fin->next;
|
||||
} else {
|
||||
prev->next = n->next;
|
||||
}
|
||||
(*n->finalize)((SYSTEM_PTR)(uintptr_t)n->obj);
|
||||
if (prev == NIL) {
|
||||
n = Heap_fin;
|
||||
} else {
|
||||
n = n->next;
|
||||
}
|
||||
} else {
|
||||
prev = n;
|
||||
n = n->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Heap_FINALL (void)
|
||||
{
|
||||
Heap_FinNode n;
|
||||
while (Heap_fin != NIL) {
|
||||
n = Heap_fin;
|
||||
Heap_fin = Heap_fin->next;
|
||||
(*n->finalize)((SYSTEM_PTR)(uintptr_t)n->obj);
|
||||
}
|
||||
}
|
||||
|
||||
static void Heap_MarkStack (LONGINT n, LONGINT *cand, LONGINT cand__len)
|
||||
{
|
||||
SYSTEM_PTR frame;
|
||||
LONGINT inc, nofcand, sp, p, stack0, ptr;
|
||||
struct Heap__1 align;
|
||||
if (n > 0) {
|
||||
Heap_MarkStack(n - 1, cand, cand__len);
|
||||
if (n > 100) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (n == 0) {
|
||||
nofcand = 0;
|
||||
sp = (LONGINT)(uintptr_t)&frame;
|
||||
stack0 = Heap_PlatformMainStackFrame();
|
||||
inc = (LONGINT)(uintptr_t)&align.p - (LONGINT)(uintptr_t)&align;
|
||||
if (sp > stack0) {
|
||||
inc = -inc;
|
||||
}
|
||||
while (sp != stack0) {
|
||||
__GET(sp, p, LONGINT);
|
||||
if ((p > Heap_heap && p < Heap_heapend)) {
|
||||
if (nofcand == cand__len) {
|
||||
Heap_HeapSort(nofcand, (void*)cand, cand__len);
|
||||
Heap_MarkCandidates(nofcand, (void*)cand, cand__len);
|
||||
nofcand = 0;
|
||||
}
|
||||
cand[nofcand] = p;
|
||||
nofcand += 1;
|
||||
}
|
||||
sp += inc;
|
||||
}
|
||||
if (nofcand > 0) {
|
||||
Heap_HeapSort(nofcand, (void*)cand, cand__len);
|
||||
Heap_MarkCandidates(nofcand, (void*)cand, cand__len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Heap_GC (BOOLEAN markStack)
|
||||
{
|
||||
Heap_Module m;
|
||||
LONGINT i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, i20, i21, i22, i23;
|
||||
LONGINT cand[10000];
|
||||
if (Heap_lockdepth == 0 || (Heap_lockdepth == 1 && !markStack)) {
|
||||
Heap_Lock();
|
||||
m = (Heap_Module)(uintptr_t)Heap_modules;
|
||||
while (m != NIL) {
|
||||
if (m->enumPtrs != NIL) {
|
||||
(*m->enumPtrs)(Heap_MarkP);
|
||||
}
|
||||
m = m->next;
|
||||
}
|
||||
if (markStack) {
|
||||
i0 = -100;
|
||||
i1 = -101;
|
||||
i2 = -102;
|
||||
i3 = -103;
|
||||
i4 = -104;
|
||||
i5 = -105;
|
||||
i6 = -106;
|
||||
i7 = -107;
|
||||
i8 = 1;
|
||||
i9 = 2;
|
||||
i10 = 3;
|
||||
i11 = 4;
|
||||
i12 = 5;
|
||||
i13 = 6;
|
||||
i14 = 7;
|
||||
i15 = 8;
|
||||
i16 = 9;
|
||||
i17 = 10;
|
||||
i18 = 11;
|
||||
i19 = 12;
|
||||
i20 = 13;
|
||||
i21 = 14;
|
||||
i22 = 15;
|
||||
i23 = 16;
|
||||
for (;;) {
|
||||
i0 += 1;
|
||||
i1 += 2;
|
||||
i2 += 3;
|
||||
i3 += 4;
|
||||
i4 += 5;
|
||||
i5 += 6;
|
||||
i6 += 7;
|
||||
i7 += 8;
|
||||
i8 += 9;
|
||||
i9 += 10;
|
||||
i10 += 11;
|
||||
i11 += 12;
|
||||
i12 += 13;
|
||||
i13 += 14;
|
||||
i14 += 15;
|
||||
i15 += 16;
|
||||
i16 += 17;
|
||||
i17 += 18;
|
||||
i18 += 19;
|
||||
i19 += 20;
|
||||
i20 += 21;
|
||||
i21 += 22;
|
||||
i22 += 23;
|
||||
i23 += 24;
|
||||
if ((i0 == -99 && i15 == 24)) {
|
||||
Heap_MarkStack(((LONGINT)(32)), (void*)cand, ((LONGINT)(10000)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (((((((((((((((((((((((i0 + i1) + i2) + i3) + i4) + i5) + i6) + i7) + i8) + i9) + i10) + i11) + i12) + i13) + i14) + i15) + i16) + i17) + i18) + i19) + i20) + i21) + i22) + i23 > 10000) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
Heap_CheckFin();
|
||||
Heap_Scan();
|
||||
Heap_Finalize();
|
||||
Heap_Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
void Heap_RegisterFinalizer (SYSTEM_PTR obj, Heap_Finalizer finalize)
|
||||
{
|
||||
Heap_FinNode f;
|
||||
__NEW(f, Heap_FinDesc);
|
||||
f->obj = (LONGINT)(uintptr_t)obj;
|
||||
f->finalize = finalize;
|
||||
f->marked = 1;
|
||||
f->next = Heap_fin;
|
||||
Heap_fin = f;
|
||||
}
|
||||
|
||||
void Heap_InitHeap (void)
|
||||
{
|
||||
Heap_heap = Heap_NewChunk(128000);
|
||||
Heap_heapend = Heap_FetchAddress(Heap_heap + 4);
|
||||
__PUT(Heap_heap, 0, LONGINT);
|
||||
Heap_allocated = 0;
|
||||
Heap_firstTry = 1;
|
||||
Heap_freeList[9] = 1;
|
||||
Heap_lockdepth = 0;
|
||||
Heap_FileCount = 0;
|
||||
Heap_modules = NIL;
|
||||
Heap_heapsize = 0;
|
||||
Heap_bigBlocks = 0;
|
||||
Heap_fin = NIL;
|
||||
Heap_interrupted = 0;
|
||||
Heap_HeapModuleInit();
|
||||
}
|
||||
|
||||
static void EnumPtrs(void (*P)(void*))
|
||||
{
|
||||
P(Heap_modules);
|
||||
P(Heap_fin);
|
||||
}
|
||||
|
||||
__TDESC(Heap_ModuleDesc, 1, 2) = {__TDFLDS("ModuleDesc", 48), {0, 28, -12}};
|
||||
__TDESC(Heap_CmdDesc, 1, 1) = {__TDFLDS("CmdDesc", 32), {0, -8}};
|
||||
__TDESC(Heap_FinDesc, 1, 1) = {__TDFLDS("FinDesc", 16), {0, -8}};
|
||||
__TDESC(Heap__1, 1, 1) = {__TDFLDS("", 8), {4, -8}};
|
||||
|
||||
export void *Heap__init(void)
|
||||
{
|
||||
__DEFMOD;
|
||||
__REGMOD("Heap", EnumPtrs);
|
||||
__REGCMD("FINALL", Heap_FINALL);
|
||||
__REGCMD("InitHeap", Heap_InitHeap);
|
||||
__REGCMD("Lock", Heap_Lock);
|
||||
__REGCMD("Unlock", Heap_Unlock);
|
||||
__INITYP(Heap_ModuleDesc, Heap_ModuleDesc, 0);
|
||||
__INITYP(Heap_CmdDesc, Heap_CmdDesc, 0);
|
||||
__INITYP(Heap_FinDesc, Heap_FinDesc, 0);
|
||||
__INITYP(Heap__1, Heap__1, 0);
|
||||
/* BEGIN */
|
||||
__ENDMOD;
|
||||
}
|
||||
54
bootstrap/unix-48/Heap.h
Normal file
54
bootstrap/unix-48/Heap.h
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin tskSfF */
|
||||
|
||||
#ifndef Heap__h
|
||||
#define Heap__h
|
||||
|
||||
#include "SYSTEM.h"
|
||||
|
||||
typedef
|
||||
CHAR Heap_CmdName[24];
|
||||
|
||||
typedef
|
||||
void (*Heap_Command)(void);
|
||||
|
||||
typedef
|
||||
void (*Heap_EnumProc)(void(*)(SYSTEM_PTR));
|
||||
|
||||
typedef
|
||||
void (*Heap_Finalizer)(SYSTEM_PTR);
|
||||
|
||||
typedef
|
||||
struct Heap_ModuleDesc *Heap_Module;
|
||||
|
||||
typedef
|
||||
struct Heap_ModuleDesc {
|
||||
LONGINT _prvt0;
|
||||
char _prvt1[44];
|
||||
} Heap_ModuleDesc;
|
||||
|
||||
typedef
|
||||
CHAR Heap_ModuleName[20];
|
||||
|
||||
|
||||
import SYSTEM_PTR Heap_modules;
|
||||
import LONGINT Heap_allocated, Heap_heapsize;
|
||||
import INTEGER Heap_FileCount;
|
||||
|
||||
import LONGINT *Heap_ModuleDesc__typ;
|
||||
|
||||
import void Heap_FINALL (void);
|
||||
import void Heap_GC (BOOLEAN markStack);
|
||||
import void Heap_INCREF (Heap_Module m);
|
||||
import void Heap_InitHeap (void);
|
||||
import void Heap_Lock (void);
|
||||
import SYSTEM_PTR Heap_NEWBLK (LONGINT size);
|
||||
import SYSTEM_PTR Heap_NEWREC (LONGINT tag);
|
||||
import void Heap_REGCMD (Heap_Module m, Heap_CmdName name, Heap_Command cmd);
|
||||
import SYSTEM_PTR Heap_REGMOD (Heap_ModuleName name, Heap_EnumProc enumPtrs);
|
||||
import void Heap_REGTYP (Heap_Module m, LONGINT typ);
|
||||
import void Heap_RegisterFinalizer (SYSTEM_PTR obj, Heap_Finalizer finalize);
|
||||
import void Heap_Unlock (void);
|
||||
import void *Heap__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
171
bootstrap/unix-48/Modules.c
Normal file
171
bootstrap/unix-48/Modules.c
Normal file
|
|
@ -0,0 +1,171 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
#include "SYSTEM.h"
|
||||
#include "Console.h"
|
||||
#include "Heap.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;
|
||||
LONGINT refcnt;
|
||||
Modules_Cmd cmds;
|
||||
LONGINT types;
|
||||
void (*enumPtrs)(void(*)(LONGINT));
|
||||
LONGINT reserved1, reserved2;
|
||||
} Modules_ModuleDesc;
|
||||
|
||||
|
||||
export INTEGER Modules_res;
|
||||
export CHAR Modules_resMsg[256];
|
||||
export Modules_ModuleName Modules_imported, Modules_importing;
|
||||
|
||||
export LONGINT *Modules_ModuleDesc__typ;
|
||||
export LONGINT *Modules_CmdDesc__typ;
|
||||
|
||||
static void Modules_Append (CHAR *a, LONGINT a__len, CHAR *b, LONGINT b__len);
|
||||
export void Modules_Free (CHAR *name, LONGINT name__len, BOOLEAN all);
|
||||
export Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, LONGINT name__len);
|
||||
export Modules_Module Modules_ThisMod (CHAR *name, LONGINT name__len);
|
||||
|
||||
#define Modules_modules() (Modules_Module)Heap_modules
|
||||
#define Modules_setmodules(m) Heap_modules = m
|
||||
|
||||
static void Modules_Append (CHAR *a, LONGINT a__len, CHAR *b, LONGINT b__len)
|
||||
{
|
||||
INTEGER i, j;
|
||||
__DUP(b, b__len, CHAR);
|
||||
i = 0;
|
||||
while (a[__X(i, a__len)] != 0x00) {
|
||||
i += 1;
|
||||
}
|
||||
j = 0;
|
||||
while (b[__X(j, b__len)] != 0x00) {
|
||||
a[__X(i, a__len)] = b[__X(j, b__len)];
|
||||
i += 1;
|
||||
j += 1;
|
||||
}
|
||||
a[__X(i, a__len)] = 0x00;
|
||||
__DEL(b);
|
||||
}
|
||||
|
||||
Modules_Module Modules_ThisMod (CHAR *name, LONGINT name__len)
|
||||
{
|
||||
Modules_Module _o_result;
|
||||
Modules_Module m = NIL;
|
||||
CHAR bodyname[64];
|
||||
Modules_Command body;
|
||||
__DUP(name, name__len, CHAR);
|
||||
m = Modules_modules();
|
||||
while ((m != NIL && __STRCMP(m->name, name) != 0)) {
|
||||
m = m->next;
|
||||
}
|
||||
if (m != NIL) {
|
||||
Modules_res = 0;
|
||||
Modules_resMsg[0] = 0x00;
|
||||
} else {
|
||||
Modules_res = 1;
|
||||
__COPY(name, Modules_importing, ((LONGINT)(20)));
|
||||
__MOVE(" module \"", Modules_resMsg, 10);
|
||||
Modules_Append((void*)Modules_resMsg, ((LONGINT)(256)), name, name__len);
|
||||
Modules_Append((void*)Modules_resMsg, ((LONGINT)(256)), (CHAR*)"\" not found", (LONGINT)12);
|
||||
}
|
||||
_o_result = m;
|
||||
__DEL(name);
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, LONGINT name__len)
|
||||
{
|
||||
Modules_Command _o_result;
|
||||
Modules_Cmd c = NIL;
|
||||
__DUP(name, name__len, CHAR);
|
||||
c = mod->cmds;
|
||||
while ((c != NIL && __STRCMP(c->name, name) != 0)) {
|
||||
c = c->next;
|
||||
}
|
||||
if (c != NIL) {
|
||||
Modules_res = 0;
|
||||
Modules_resMsg[0] = 0x00;
|
||||
_o_result = c->cmd;
|
||||
__DEL(name);
|
||||
return _o_result;
|
||||
} else {
|
||||
Modules_res = 2;
|
||||
__MOVE(" command \"", Modules_resMsg, 11);
|
||||
__COPY(name, Modules_importing, ((LONGINT)(20)));
|
||||
Modules_Append((void*)Modules_resMsg, ((LONGINT)(256)), mod->name, ((LONGINT)(20)));
|
||||
Modules_Append((void*)Modules_resMsg, ((LONGINT)(256)), (CHAR*)".", (LONGINT)2);
|
||||
Modules_Append((void*)Modules_resMsg, ((LONGINT)(256)), name, name__len);
|
||||
Modules_Append((void*)Modules_resMsg, ((LONGINT)(256)), (CHAR*)"\" not found", (LONGINT)12);
|
||||
_o_result = NIL;
|
||||
__DEL(name);
|
||||
return _o_result;
|
||||
}
|
||||
__RETCHK;
|
||||
}
|
||||
|
||||
void Modules_Free (CHAR *name, LONGINT name__len, BOOLEAN all)
|
||||
{
|
||||
Modules_Module m = NIL, p = NIL;
|
||||
__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;
|
||||
}
|
||||
Modules_res = 0;
|
||||
} else {
|
||||
Modules_res = 1;
|
||||
if (m == NIL) {
|
||||
__MOVE("module not found", Modules_resMsg, 17);
|
||||
} else {
|
||||
__MOVE("clients of this module exist", Modules_resMsg, 29);
|
||||
}
|
||||
}
|
||||
}
|
||||
__DEL(name);
|
||||
}
|
||||
|
||||
__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)
|
||||
{
|
||||
__DEFMOD;
|
||||
__MODULE_IMPORT(Console);
|
||||
__MODULE_IMPORT(Heap);
|
||||
__REGMOD("Modules", 0);
|
||||
__INITYP(Modules_ModuleDesc, Modules_ModuleDesc, 0);
|
||||
__INITYP(Modules_CmdDesc, Modules_CmdDesc, 0);
|
||||
/* BEGIN */
|
||||
__ENDMOD;
|
||||
}
|
||||
54
bootstrap/unix-48/Modules.h
Normal file
54
bootstrap/unix-48/Modules.h
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#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;
|
||||
LONGINT refcnt;
|
||||
Modules_Cmd cmds;
|
||||
LONGINT types;
|
||||
void (*enumPtrs)(void(*)(LONGINT));
|
||||
char _prvt0[8];
|
||||
} Modules_ModuleDesc;
|
||||
|
||||
|
||||
import INTEGER Modules_res;
|
||||
import CHAR Modules_resMsg[256];
|
||||
import Modules_ModuleName Modules_imported, Modules_importing;
|
||||
|
||||
import LONGINT *Modules_ModuleDesc__typ;
|
||||
import LONGINT *Modules_CmdDesc__typ;
|
||||
|
||||
import void Modules_Free (CHAR *name, LONGINT name__len, BOOLEAN all);
|
||||
import Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, LONGINT name__len);
|
||||
import Modules_Module Modules_ThisMod (CHAR *name, LONGINT name__len);
|
||||
import void *Modules__init(void);
|
||||
|
||||
#define Modules_modules() (Modules_Module)Heap_modules
|
||||
#define Modules_setmodules(m) Heap_modules = m
|
||||
|
||||
#endif
|
||||
2677
bootstrap/unix-48/OPB.c
Normal file
2677
bootstrap/unix-48/OPB.c
Normal file
File diff suppressed because it is too large
Load diff
49
bootstrap/unix-48/OPB.h
Normal file
49
bootstrap/unix-48/OPB.h
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#ifndef OPB__h
|
||||
#define OPB__h
|
||||
|
||||
#include "SYSTEM.h"
|
||||
#include "OPS.h"
|
||||
#include "OPT.h"
|
||||
|
||||
|
||||
import void (*OPB_typSize)(OPT_Struct);
|
||||
|
||||
|
||||
import void OPB_Assign (OPT_Node *x, OPT_Node y);
|
||||
import void OPB_Call (OPT_Node *x, OPT_Node apar, OPT_Object fp);
|
||||
import void OPB_CheckParameters (OPT_Object fp, OPT_Object ap, BOOLEAN checkNames);
|
||||
import void OPB_Construct (SHORTINT class, OPT_Node *x, OPT_Node y);
|
||||
import void OPB_DeRef (OPT_Node *x);
|
||||
import OPT_Node OPB_EmptySet (void);
|
||||
import void OPB_Enter (OPT_Node *procdec, OPT_Node stat, OPT_Object proc);
|
||||
import void OPB_Field (OPT_Node *x, OPT_Object y);
|
||||
import void OPB_In (OPT_Node *x, OPT_Node y);
|
||||
import void OPB_Index (OPT_Node *x, OPT_Node y);
|
||||
import void OPB_Inittd (OPT_Node *inittd, OPT_Node *last, OPT_Struct typ);
|
||||
import void OPB_Link (OPT_Node *x, OPT_Node *last, OPT_Node y);
|
||||
import void OPB_MOp (SHORTINT op, OPT_Node *x);
|
||||
import OPT_Node OPB_NewBoolConst (BOOLEAN boolval);
|
||||
import OPT_Node OPB_NewIntConst (LONGINT intval);
|
||||
import OPT_Node OPB_NewLeaf (OPT_Object obj);
|
||||
import OPT_Node OPB_NewRealConst (LONGREAL realval, OPT_Struct typ);
|
||||
import OPT_Node OPB_NewString (OPS_String str, LONGINT len);
|
||||
import OPT_Node OPB_Nil (void);
|
||||
import void OPB_Op (SHORTINT op, OPT_Node *x, OPT_Node y);
|
||||
import void OPB_OptIf (OPT_Node *x);
|
||||
import void OPB_Param (OPT_Node ap, OPT_Object fp);
|
||||
import void OPB_PrepCall (OPT_Node *x, OPT_Object *fpar);
|
||||
import void OPB_Return (OPT_Node *x, OPT_Object proc);
|
||||
import void OPB_SetElem (OPT_Node *x);
|
||||
import void OPB_SetRange (OPT_Node *x, OPT_Node y);
|
||||
import void OPB_StFct (OPT_Node *par0, SHORTINT fctno, INTEGER parno);
|
||||
import void OPB_StPar0 (OPT_Node *par0, INTEGER fctno);
|
||||
import void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno);
|
||||
import void OPB_StParN (OPT_Node *par0, OPT_Node x, INTEGER fctno, INTEGER n);
|
||||
import void OPB_StaticLink (SHORTINT dlev);
|
||||
import void OPB_TypTest (OPT_Node *x, OPT_Object obj, BOOLEAN guard);
|
||||
import void *OPB__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
2108
bootstrap/unix-48/OPC.c
Normal file
2108
bootstrap/unix-48/OPC.c
Normal file
File diff suppressed because it is too large
Load diff
49
bootstrap/unix-48/OPC.h
Normal file
49
bootstrap/unix-48/OPC.h
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#ifndef OPC__h
|
||||
#define OPC__h
|
||||
|
||||
#include "SYSTEM.h"
|
||||
#include "OPT.h"
|
||||
|
||||
|
||||
|
||||
|
||||
import void OPC_Align (LONGINT *adr, LONGINT base);
|
||||
import void OPC_Andent (OPT_Struct typ);
|
||||
import LONGINT OPC_Base (OPT_Struct typ);
|
||||
import OPT_Object OPC_BaseTProc (OPT_Object obj);
|
||||
import void OPC_BegBlk (void);
|
||||
import void OPC_BegStat (void);
|
||||
import void OPC_Case (LONGINT caseVal, INTEGER form);
|
||||
import void OPC_Cmp (INTEGER rel);
|
||||
import void OPC_CompleteIdent (OPT_Object obj);
|
||||
import void OPC_Constant (OPT_Const con, INTEGER form);
|
||||
import void OPC_DefineInter (OPT_Object proc);
|
||||
import void OPC_EndBlk (void);
|
||||
import void OPC_EndBlk0 (void);
|
||||
import void OPC_EndStat (void);
|
||||
import void OPC_EnterBody (void);
|
||||
import void OPC_EnterProc (OPT_Object proc);
|
||||
import void OPC_ExitBody (void);
|
||||
import void OPC_ExitProc (OPT_Object proc, BOOLEAN eoBlock, BOOLEAN implicitRet);
|
||||
import void OPC_GenBdy (OPT_Node n);
|
||||
import void OPC_GenEnumPtrs (OPT_Object var);
|
||||
import void OPC_GenHdr (OPT_Node n);
|
||||
import void OPC_GenHdrIncludes (void);
|
||||
import void OPC_Halt (LONGINT n);
|
||||
import void OPC_Ident (OPT_Object obj);
|
||||
import void OPC_Increment (BOOLEAN decrement);
|
||||
import void OPC_Indent (INTEGER count);
|
||||
import void OPC_Init (void);
|
||||
import void OPC_InitTDesc (OPT_Struct typ);
|
||||
import void OPC_Len (OPT_Object obj, OPT_Struct array, LONGINT dim);
|
||||
import LONGINT OPC_NofPtrs (OPT_Struct typ);
|
||||
import void OPC_SetInclude (BOOLEAN exclude);
|
||||
import void OPC_TDescDecl (OPT_Struct typ);
|
||||
import void OPC_TypeDefs (OPT_Object obj, INTEGER vis);
|
||||
import void OPC_TypeOf (OPT_Object ap);
|
||||
import void *OPC__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
1091
bootstrap/unix-48/OPM.c
Normal file
1091
bootstrap/unix-48/OPM.c
Normal file
File diff suppressed because it is too large
Load diff
63
bootstrap/unix-48/OPM.h
Normal file
63
bootstrap/unix-48/OPM.h
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#ifndef OPM__h
|
||||
#define OPM__h
|
||||
|
||||
#include "SYSTEM.h"
|
||||
|
||||
|
||||
import INTEGER OPM_Alignment, OPM_ByteSize, OPM_CharSize, OPM_BoolSize, OPM_SIntSize, OPM_IntSize, OPM_LIntSize, OPM_SetSize, OPM_RealSize, OPM_LRealSize, OPM_PointerSize, OPM_ProcSize, OPM_RecSize, OPM_CharAlign, OPM_BoolAlign, OPM_SIntAlign, OPM_IntAlign, OPM_LIntAlign, OPM_SetAlign, OPM_RealAlign, OPM_LRealAlign, OPM_PointerAlign, OPM_ProcAlign, OPM_RecAlign, OPM_MaxSet;
|
||||
import LONGINT OPM_MinSInt, OPM_MinInt, OPM_MinLInt, OPM_MaxSInt, OPM_MaxInt, OPM_MaxLInt, OPM_MaxIndex;
|
||||
import LONGREAL OPM_MinReal, OPM_MaxReal, OPM_MinLReal, OPM_MaxLReal;
|
||||
import BOOLEAN OPM_noerr;
|
||||
import LONGINT OPM_curpos, OPM_errpos, OPM_breakpc;
|
||||
import INTEGER OPM_currFile, OPM_level, OPM_pc, OPM_entno;
|
||||
import CHAR OPM_modName[32];
|
||||
import CHAR OPM_objname[64];
|
||||
import SET OPM_opt, OPM_glbopt;
|
||||
import BOOLEAN OPM_dontAsm, OPM_dontLink, OPM_mainProg, OPM_mainLinkStat, OPM_notColorOutput, OPM_forceNewSym, OPM_Verbose;
|
||||
|
||||
|
||||
import void OPM_CloseFiles (void);
|
||||
import void OPM_CloseOldSym (void);
|
||||
import void OPM_DeleteNewSym (void);
|
||||
import void OPM_FPrint (LONGINT *fp, LONGINT val);
|
||||
import void OPM_FPrintLReal (LONGINT *fp, LONGREAL lr);
|
||||
import void OPM_FPrintReal (LONGINT *fp, REAL real);
|
||||
import void OPM_FPrintSet (LONGINT *fp, SET set);
|
||||
import void OPM_Get (CHAR *ch);
|
||||
import void OPM_Init (BOOLEAN *done, CHAR *mname, LONGINT mname__len);
|
||||
import void OPM_InitOptions (void);
|
||||
import void OPM_LogW (CHAR ch);
|
||||
import void OPM_LogWLn (void);
|
||||
import void OPM_LogWNum (LONGINT i, LONGINT len);
|
||||
import void OPM_LogWStr (CHAR *s, LONGINT s__len);
|
||||
import void OPM_Mark (INTEGER n, LONGINT pos);
|
||||
import void OPM_NewSym (CHAR *modName, LONGINT modName__len);
|
||||
import void OPM_OldSym (CHAR *modName, LONGINT modName__len, BOOLEAN *done);
|
||||
import void OPM_OpenFiles (CHAR *moduleName, LONGINT moduleName__len);
|
||||
import BOOLEAN OPM_OpenPar (void);
|
||||
import void OPM_RegisterNewSym (void);
|
||||
import void OPM_SymRCh (CHAR *ch);
|
||||
import LONGINT OPM_SymRInt (void);
|
||||
import void OPM_SymRLReal (LONGREAL *lr);
|
||||
import void OPM_SymRReal (REAL *r);
|
||||
import void OPM_SymRSet (SET *s);
|
||||
import void OPM_SymWCh (CHAR ch);
|
||||
import void OPM_SymWInt (LONGINT i);
|
||||
import void OPM_SymWLReal (LONGREAL lr);
|
||||
import void OPM_SymWReal (REAL r);
|
||||
import void OPM_SymWSet (SET s);
|
||||
import void OPM_Write (CHAR ch);
|
||||
import void OPM_WriteHex (LONGINT i);
|
||||
import void OPM_WriteInt (LONGINT i);
|
||||
import void OPM_WriteLn (void);
|
||||
import void OPM_WriteReal (LONGREAL r, CHAR suffx);
|
||||
import void OPM_WriteString (CHAR *s, LONGINT s__len);
|
||||
import void OPM_WriteStringVar (CHAR *s, LONGINT s__len);
|
||||
import BOOLEAN OPM_eofSF (void);
|
||||
import void OPM_err (INTEGER n);
|
||||
import void *OPM__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
1873
bootstrap/unix-48/OPP.c
Normal file
1873
bootstrap/unix-48/OPP.c
Normal file
File diff suppressed because it is too large
Load diff
16
bootstrap/unix-48/OPP.h
Normal file
16
bootstrap/unix-48/OPP.h
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#ifndef OPP__h
|
||||
#define OPP__h
|
||||
|
||||
#include "SYSTEM.h"
|
||||
#include "OPT.h"
|
||||
|
||||
|
||||
|
||||
|
||||
import void OPP_Module (OPT_Node *prog, SET opt);
|
||||
import void *OPP__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
623
bootstrap/unix-48/OPS.c
Normal file
623
bootstrap/unix-48/OPS.c
Normal file
|
|
@ -0,0 +1,623 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin tspkaSfF */
|
||||
#include "SYSTEM.h"
|
||||
#include "OPM.h"
|
||||
|
||||
typedef
|
||||
CHAR OPS_Name[256];
|
||||
|
||||
typedef
|
||||
CHAR OPS_String[256];
|
||||
|
||||
|
||||
export OPS_Name OPS_name;
|
||||
export OPS_String OPS_str;
|
||||
export INTEGER OPS_numtyp;
|
||||
export LONGINT OPS_intval;
|
||||
export REAL OPS_realval;
|
||||
export LONGREAL OPS_lrlval;
|
||||
static CHAR OPS_ch;
|
||||
|
||||
|
||||
export void OPS_Get (SHORTINT *sym);
|
||||
static void OPS_Identifier (SHORTINT *sym);
|
||||
export void OPS_Init (void);
|
||||
static void OPS_Number (void);
|
||||
static void OPS_Str (SHORTINT *sym);
|
||||
static void OPS_err (INTEGER n);
|
||||
|
||||
|
||||
static void OPS_err (INTEGER n)
|
||||
{
|
||||
OPM_err(n);
|
||||
}
|
||||
|
||||
static void OPS_Str (SHORTINT *sym)
|
||||
{
|
||||
INTEGER i;
|
||||
CHAR och;
|
||||
i = 0;
|
||||
och = OPS_ch;
|
||||
for (;;) {
|
||||
OPM_Get(&OPS_ch);
|
||||
if (OPS_ch == och) {
|
||||
break;
|
||||
}
|
||||
if (OPS_ch < ' ') {
|
||||
OPS_err(3);
|
||||
break;
|
||||
}
|
||||
if (i == 255) {
|
||||
OPS_err(241);
|
||||
break;
|
||||
}
|
||||
OPS_str[i] = OPS_ch;
|
||||
i += 1;
|
||||
}
|
||||
OPM_Get(&OPS_ch);
|
||||
OPS_str[i] = 0x00;
|
||||
OPS_intval = i + 1;
|
||||
if (OPS_intval == 2) {
|
||||
*sym = 35;
|
||||
OPS_numtyp = 1;
|
||||
OPS_intval = (int)OPS_str[0];
|
||||
} else {
|
||||
*sym = 37;
|
||||
}
|
||||
}
|
||||
|
||||
static void OPS_Identifier (SHORTINT *sym)
|
||||
{
|
||||
INTEGER i;
|
||||
i = 0;
|
||||
do {
|
||||
OPS_name[i] = OPS_ch;
|
||||
i += 1;
|
||||
OPM_Get(&OPS_ch);
|
||||
} while (!(((OPS_ch < '0' || ('9' < OPS_ch && __CAP(OPS_ch) < 'A')) || 'Z' < __CAP(OPS_ch)) || i == 256));
|
||||
if (i == 256) {
|
||||
OPS_err(240);
|
||||
i -= 1;
|
||||
}
|
||||
OPS_name[i] = 0x00;
|
||||
*sym = 38;
|
||||
}
|
||||
|
||||
static struct Number__6 {
|
||||
struct Number__6 *lnk;
|
||||
} *Number__6_s;
|
||||
|
||||
static INTEGER Ord__7 (CHAR ch, BOOLEAN hex);
|
||||
static LONGREAL Ten__9 (INTEGER e);
|
||||
|
||||
static LONGREAL Ten__9 (INTEGER e)
|
||||
{
|
||||
LONGREAL _o_result;
|
||||
LONGREAL x, p;
|
||||
x = (LONGREAL)1;
|
||||
p = (LONGREAL)10;
|
||||
while (e > 0) {
|
||||
if (__ODD(e)) {
|
||||
x = x * p;
|
||||
}
|
||||
e = __ASHR(e, 1);
|
||||
if (e > 0) {
|
||||
p = p * p;
|
||||
}
|
||||
}
|
||||
_o_result = x;
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
static INTEGER Ord__7 (CHAR ch, BOOLEAN hex)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
if (ch <= '9') {
|
||||
_o_result = (int)ch - 48;
|
||||
return _o_result;
|
||||
} else if (hex) {
|
||||
_o_result = ((int)ch - 65) + 10;
|
||||
return _o_result;
|
||||
} else {
|
||||
OPS_err(2);
|
||||
_o_result = 0;
|
||||
return _o_result;
|
||||
}
|
||||
__RETCHK;
|
||||
}
|
||||
|
||||
static void OPS_Number (void)
|
||||
{
|
||||
INTEGER i, m, n, d, e;
|
||||
CHAR dig[24];
|
||||
LONGREAL f;
|
||||
CHAR expCh;
|
||||
BOOLEAN neg;
|
||||
struct Number__6 _s;
|
||||
_s.lnk = Number__6_s;
|
||||
Number__6_s = &_s;
|
||||
i = 0;
|
||||
m = 0;
|
||||
n = 0;
|
||||
d = 0;
|
||||
for (;;) {
|
||||
if (('0' <= OPS_ch && OPS_ch <= '9') || (((d == 0 && 'A' <= OPS_ch)) && OPS_ch <= 'F')) {
|
||||
if (m > 0 || OPS_ch != '0') {
|
||||
if (n < 24) {
|
||||
dig[n] = OPS_ch;
|
||||
n += 1;
|
||||
}
|
||||
m += 1;
|
||||
}
|
||||
OPM_Get(&OPS_ch);
|
||||
i += 1;
|
||||
} else if (OPS_ch == '.') {
|
||||
OPM_Get(&OPS_ch);
|
||||
if (OPS_ch == '.') {
|
||||
OPS_ch = 0x7f;
|
||||
break;
|
||||
} else if (d == 0) {
|
||||
d = i;
|
||||
} else {
|
||||
OPS_err(2);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (d == 0) {
|
||||
if (n == m) {
|
||||
OPS_intval = 0;
|
||||
i = 0;
|
||||
if (OPS_ch == 'X') {
|
||||
OPM_Get(&OPS_ch);
|
||||
OPS_numtyp = 1;
|
||||
if (n <= 2) {
|
||||
while (i < n) {
|
||||
OPS_intval = __ASHL(OPS_intval, 4) + (LONGINT)Ord__7(dig[i], 1);
|
||||
i += 1;
|
||||
}
|
||||
} else {
|
||||
OPS_err(203);
|
||||
}
|
||||
} else if (OPS_ch == 'H') {
|
||||
OPM_Get(&OPS_ch);
|
||||
OPS_numtyp = 2;
|
||||
if (n <= 8) {
|
||||
if ((n == 8 && dig[0] > '7')) {
|
||||
OPS_intval = -1;
|
||||
}
|
||||
while (i < n) {
|
||||
OPS_intval = __ASHL(OPS_intval, 4) + (LONGINT)Ord__7(dig[i], 1);
|
||||
i += 1;
|
||||
}
|
||||
} else {
|
||||
OPS_err(203);
|
||||
}
|
||||
} else {
|
||||
OPS_numtyp = 2;
|
||||
while (i < n) {
|
||||
d = Ord__7(dig[i], 0);
|
||||
i += 1;
|
||||
if (OPS_intval <= __DIV(2147483647 - (LONGINT)d, 10)) {
|
||||
OPS_intval = OPS_intval * 10 + (LONGINT)d;
|
||||
} else {
|
||||
OPS_err(203);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
OPS_err(203);
|
||||
}
|
||||
} else {
|
||||
f = (LONGREAL)0;
|
||||
e = 0;
|
||||
expCh = 'E';
|
||||
while (n > 0) {
|
||||
n -= 1;
|
||||
f = (Ord__7(dig[n], 0) + f) / (LONGREAL)(LONGREAL)10;
|
||||
}
|
||||
if (OPS_ch == 'E' || OPS_ch == 'D') {
|
||||
expCh = OPS_ch;
|
||||
OPM_Get(&OPS_ch);
|
||||
neg = 0;
|
||||
if (OPS_ch == '-') {
|
||||
neg = 1;
|
||||
OPM_Get(&OPS_ch);
|
||||
} else if (OPS_ch == '+') {
|
||||
OPM_Get(&OPS_ch);
|
||||
}
|
||||
if (('0' <= OPS_ch && OPS_ch <= '9')) {
|
||||
do {
|
||||
n = Ord__7(OPS_ch, 0);
|
||||
OPM_Get(&OPS_ch);
|
||||
if (e <= __DIV(32767 - n, 10)) {
|
||||
e = e * 10 + n;
|
||||
} else {
|
||||
OPS_err(203);
|
||||
}
|
||||
} while (!(OPS_ch < '0' || '9' < OPS_ch));
|
||||
if (neg) {
|
||||
e = -e;
|
||||
}
|
||||
} else {
|
||||
OPS_err(2);
|
||||
}
|
||||
}
|
||||
e -= (i - d) - m;
|
||||
if (expCh == 'E') {
|
||||
OPS_numtyp = 3;
|
||||
if ((-37 < e && e <= 38)) {
|
||||
if (e < 0) {
|
||||
OPS_realval = (f / (LONGREAL)Ten__9(-e));
|
||||
} else {
|
||||
OPS_realval = (f * Ten__9(e));
|
||||
}
|
||||
} else {
|
||||
OPS_err(203);
|
||||
}
|
||||
} else {
|
||||
OPS_numtyp = 4;
|
||||
if ((-307 < e && e <= 308)) {
|
||||
if (e < 0) {
|
||||
OPS_lrlval = f / (LONGREAL)Ten__9(-e);
|
||||
} else {
|
||||
OPS_lrlval = f * Ten__9(e);
|
||||
}
|
||||
} else {
|
||||
OPS_err(203);
|
||||
}
|
||||
}
|
||||
}
|
||||
Number__6_s = _s.lnk;
|
||||
}
|
||||
|
||||
static struct Get__1 {
|
||||
struct Get__1 *lnk;
|
||||
} *Get__1_s;
|
||||
|
||||
static void Comment__2 (void);
|
||||
|
||||
static void Comment__2 (void)
|
||||
{
|
||||
OPM_Get(&OPS_ch);
|
||||
for (;;) {
|
||||
for (;;) {
|
||||
while (OPS_ch == '(') {
|
||||
OPM_Get(&OPS_ch);
|
||||
if (OPS_ch == '*') {
|
||||
Comment__2();
|
||||
}
|
||||
}
|
||||
if (OPS_ch == '*') {
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
}
|
||||
if (OPS_ch == 0x00) {
|
||||
break;
|
||||
}
|
||||
OPM_Get(&OPS_ch);
|
||||
}
|
||||
if (OPS_ch == ')') {
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
}
|
||||
if (OPS_ch == 0x00) {
|
||||
OPS_err(5);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OPS_Get (SHORTINT *sym)
|
||||
{
|
||||
SHORTINT s;
|
||||
struct Get__1 _s;
|
||||
_s.lnk = Get__1_s;
|
||||
Get__1_s = &_s;
|
||||
OPM_errpos = OPM_curpos - 1;
|
||||
while (OPS_ch <= ' ') {
|
||||
if (OPS_ch == 0x00) {
|
||||
*sym = 64;
|
||||
return;
|
||||
} else {
|
||||
OPM_Get(&OPS_ch);
|
||||
}
|
||||
}
|
||||
switch (OPS_ch) {
|
||||
case '\"': case '\'':
|
||||
OPS_Str(&s);
|
||||
break;
|
||||
case '#':
|
||||
s = 10;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
case '&':
|
||||
s = 5;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
case '(':
|
||||
OPM_Get(&OPS_ch);
|
||||
if (OPS_ch == '*') {
|
||||
Comment__2();
|
||||
OPS_Get(&s);
|
||||
} else {
|
||||
s = 30;
|
||||
}
|
||||
break;
|
||||
case ')':
|
||||
s = 22;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
case '*':
|
||||
s = 1;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
case '+':
|
||||
s = 6;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
case ',':
|
||||
s = 19;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
case '-':
|
||||
s = 7;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
case '.':
|
||||
OPM_Get(&OPS_ch);
|
||||
if (OPS_ch == '.') {
|
||||
OPM_Get(&OPS_ch);
|
||||
s = 21;
|
||||
} else {
|
||||
s = 18;
|
||||
}
|
||||
break;
|
||||
case '/':
|
||||
s = 2;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
OPS_Number();
|
||||
s = 35;
|
||||
break;
|
||||
case ':':
|
||||
OPM_Get(&OPS_ch);
|
||||
if (OPS_ch == '=') {
|
||||
OPM_Get(&OPS_ch);
|
||||
s = 34;
|
||||
} else {
|
||||
s = 20;
|
||||
}
|
||||
break;
|
||||
case ';':
|
||||
s = 39;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
case '<':
|
||||
OPM_Get(&OPS_ch);
|
||||
if (OPS_ch == '=') {
|
||||
OPM_Get(&OPS_ch);
|
||||
s = 12;
|
||||
} else {
|
||||
s = 11;
|
||||
}
|
||||
break;
|
||||
case '=':
|
||||
s = 9;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
case '>':
|
||||
OPM_Get(&OPS_ch);
|
||||
if (OPS_ch == '=') {
|
||||
OPM_Get(&OPS_ch);
|
||||
s = 14;
|
||||
} else {
|
||||
s = 13;
|
||||
}
|
||||
break;
|
||||
case 'A':
|
||||
OPS_Identifier(&s);
|
||||
if (__STRCMP(OPS_name, "ARRAY") == 0) {
|
||||
s = 54;
|
||||
}
|
||||
break;
|
||||
case 'B':
|
||||
OPS_Identifier(&s);
|
||||
if (__STRCMP(OPS_name, "BEGIN") == 0) {
|
||||
s = 57;
|
||||
} else if (__STRCMP(OPS_name, "BY") == 0) {
|
||||
s = 29;
|
||||
}
|
||||
break;
|
||||
case 'C':
|
||||
OPS_Identifier(&s);
|
||||
if (__STRCMP(OPS_name, "CASE") == 0) {
|
||||
s = 46;
|
||||
} else if (__STRCMP(OPS_name, "CONST") == 0) {
|
||||
s = 58;
|
||||
}
|
||||
break;
|
||||
case 'D':
|
||||
OPS_Identifier(&s);
|
||||
if (__STRCMP(OPS_name, "DO") == 0) {
|
||||
s = 27;
|
||||
} else if (__STRCMP(OPS_name, "DIV") == 0) {
|
||||
s = 3;
|
||||
}
|
||||
break;
|
||||
case 'E':
|
||||
OPS_Identifier(&s);
|
||||
if (__STRCMP(OPS_name, "END") == 0) {
|
||||
s = 41;
|
||||
} else if (__STRCMP(OPS_name, "ELSE") == 0) {
|
||||
s = 42;
|
||||
} else if (__STRCMP(OPS_name, "ELSIF") == 0) {
|
||||
s = 43;
|
||||
} else if (__STRCMP(OPS_name, "EXIT") == 0) {
|
||||
s = 52;
|
||||
}
|
||||
break;
|
||||
case 'F':
|
||||
OPS_Identifier(&s);
|
||||
if (__STRCMP(OPS_name, "FOR") == 0) {
|
||||
s = 49;
|
||||
}
|
||||
break;
|
||||
case 'I':
|
||||
OPS_Identifier(&s);
|
||||
if (__STRCMP(OPS_name, "IF") == 0) {
|
||||
s = 45;
|
||||
} else if (__STRCMP(OPS_name, "IN") == 0) {
|
||||
s = 15;
|
||||
} else if (__STRCMP(OPS_name, "IS") == 0) {
|
||||
s = 16;
|
||||
} else if (__STRCMP(OPS_name, "IMPORT") == 0) {
|
||||
s = 62;
|
||||
}
|
||||
break;
|
||||
case 'L':
|
||||
OPS_Identifier(&s);
|
||||
if (__STRCMP(OPS_name, "LOOP") == 0) {
|
||||
s = 50;
|
||||
}
|
||||
break;
|
||||
case 'M':
|
||||
OPS_Identifier(&s);
|
||||
if (__STRCMP(OPS_name, "MOD") == 0) {
|
||||
s = 4;
|
||||
} else if (__STRCMP(OPS_name, "MODULE") == 0) {
|
||||
s = 63;
|
||||
}
|
||||
break;
|
||||
case 'N':
|
||||
OPS_Identifier(&s);
|
||||
if (__STRCMP(OPS_name, "NIL") == 0) {
|
||||
s = 36;
|
||||
}
|
||||
break;
|
||||
case 'O':
|
||||
OPS_Identifier(&s);
|
||||
if (__STRCMP(OPS_name, "OR") == 0) {
|
||||
s = 8;
|
||||
} else if (__STRCMP(OPS_name, "OF") == 0) {
|
||||
s = 25;
|
||||
}
|
||||
break;
|
||||
case 'P':
|
||||
OPS_Identifier(&s);
|
||||
if (__STRCMP(OPS_name, "PROCEDURE") == 0) {
|
||||
s = 61;
|
||||
} else if (__STRCMP(OPS_name, "POINTER") == 0) {
|
||||
s = 56;
|
||||
}
|
||||
break;
|
||||
case 'R':
|
||||
OPS_Identifier(&s);
|
||||
if (__STRCMP(OPS_name, "RECORD") == 0) {
|
||||
s = 55;
|
||||
} else if (__STRCMP(OPS_name, "REPEAT") == 0) {
|
||||
s = 48;
|
||||
} else if (__STRCMP(OPS_name, "RETURN") == 0) {
|
||||
s = 53;
|
||||
}
|
||||
break;
|
||||
case 'T':
|
||||
OPS_Identifier(&s);
|
||||
if (__STRCMP(OPS_name, "THEN") == 0) {
|
||||
s = 26;
|
||||
} else if (__STRCMP(OPS_name, "TO") == 0) {
|
||||
s = 28;
|
||||
} else if (__STRCMP(OPS_name, "TYPE") == 0) {
|
||||
s = 59;
|
||||
}
|
||||
break;
|
||||
case 'U':
|
||||
OPS_Identifier(&s);
|
||||
if (__STRCMP(OPS_name, "UNTIL") == 0) {
|
||||
s = 44;
|
||||
}
|
||||
break;
|
||||
case 'V':
|
||||
OPS_Identifier(&s);
|
||||
if (__STRCMP(OPS_name, "VAR") == 0) {
|
||||
s = 60;
|
||||
}
|
||||
break;
|
||||
case 'W':
|
||||
OPS_Identifier(&s);
|
||||
if (__STRCMP(OPS_name, "WHILE") == 0) {
|
||||
s = 47;
|
||||
} else if (__STRCMP(OPS_name, "WITH") == 0) {
|
||||
s = 51;
|
||||
}
|
||||
break;
|
||||
case 'G': case 'H': case 'J': case 'K': case 'Q':
|
||||
case 'S': case 'X': case 'Y': case 'Z':
|
||||
OPS_Identifier(&s);
|
||||
break;
|
||||
case '[':
|
||||
s = 31;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
case ']':
|
||||
s = 23;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
case '^':
|
||||
s = 17;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
case 'a': case 'b': case 'c': case 'd': case 'e':
|
||||
case 'f': case 'g': case 'h': case 'i': case 'j':
|
||||
case 'k': case 'l': case 'm': case 'n': case 'o':
|
||||
case 'p': case 'q': case 'r': case 's': case 't':
|
||||
case 'u': case 'v': case 'w': case 'x': case 'y':
|
||||
case 'z':
|
||||
OPS_Identifier(&s);
|
||||
break;
|
||||
case '{':
|
||||
s = 32;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
case '|':
|
||||
s = 40;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
case '}':
|
||||
s = 24;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
case '~':
|
||||
s = 33;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
case 0x7f:
|
||||
s = 21;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
default:
|
||||
s = 0;
|
||||
OPM_Get(&OPS_ch);
|
||||
break;
|
||||
}
|
||||
*sym = s;
|
||||
Get__1_s = _s.lnk;
|
||||
}
|
||||
|
||||
void OPS_Init (void)
|
||||
{
|
||||
OPS_ch = ' ';
|
||||
}
|
||||
|
||||
|
||||
export void *OPS__init(void)
|
||||
{
|
||||
__DEFMOD;
|
||||
__MODULE_IMPORT(OPM);
|
||||
__REGMOD("OPS", 0);
|
||||
__REGCMD("Init", OPS_Init);
|
||||
/* BEGIN */
|
||||
__ENDMOD;
|
||||
}
|
||||
28
bootstrap/unix-48/OPS.h
Normal file
28
bootstrap/unix-48/OPS.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin tspkaSfF */
|
||||
|
||||
#ifndef OPS__h
|
||||
#define OPS__h
|
||||
|
||||
#include "SYSTEM.h"
|
||||
|
||||
typedef
|
||||
CHAR OPS_Name[256];
|
||||
|
||||
typedef
|
||||
CHAR OPS_String[256];
|
||||
|
||||
|
||||
import OPS_Name OPS_name;
|
||||
import OPS_String OPS_str;
|
||||
import INTEGER OPS_numtyp;
|
||||
import LONGINT OPS_intval;
|
||||
import REAL OPS_realval;
|
||||
import LONGREAL OPS_lrlval;
|
||||
|
||||
|
||||
import void OPS_Get (SHORTINT *sym);
|
||||
import void OPS_Init (void);
|
||||
import void *OPS__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
1858
bootstrap/unix-48/OPT.c
Normal file
1858
bootstrap/unix-48/OPT.c
Normal file
File diff suppressed because it is too large
Load diff
105
bootstrap/unix-48/OPT.h
Normal file
105
bootstrap/unix-48/OPT.h
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#ifndef OPT__h
|
||||
#define OPT__h
|
||||
|
||||
#include "SYSTEM.h"
|
||||
#include "OPS.h"
|
||||
|
||||
typedef
|
||||
struct OPT_ConstDesc *OPT_Const;
|
||||
|
||||
typedef
|
||||
OPS_String *OPT_ConstExt;
|
||||
|
||||
typedef
|
||||
struct OPT_ConstDesc {
|
||||
OPT_ConstExt ext;
|
||||
LONGINT intval, intval2;
|
||||
SET setval;
|
||||
LONGREAL realval;
|
||||
} OPT_ConstDesc;
|
||||
|
||||
typedef
|
||||
struct OPT_NodeDesc *OPT_Node;
|
||||
|
||||
typedef
|
||||
struct OPT_StrDesc *OPT_Struct;
|
||||
|
||||
typedef
|
||||
struct OPT_ObjDesc *OPT_Object;
|
||||
|
||||
typedef
|
||||
struct OPT_NodeDesc {
|
||||
OPT_Node left, right, link;
|
||||
SHORTINT class, subcl;
|
||||
BOOLEAN readonly;
|
||||
OPT_Struct typ;
|
||||
OPT_Object obj;
|
||||
OPT_Const conval;
|
||||
} OPT_NodeDesc;
|
||||
|
||||
typedef
|
||||
struct OPT_ObjDesc {
|
||||
OPT_Object left, right, link, scope;
|
||||
OPS_Name name;
|
||||
BOOLEAN leaf;
|
||||
SHORTINT mode, mnolev, vis, history;
|
||||
BOOLEAN used, fpdone;
|
||||
LONGINT fprint;
|
||||
OPT_Struct typ;
|
||||
OPT_Const conval;
|
||||
LONGINT adr, linkadr;
|
||||
INTEGER x;
|
||||
} OPT_ObjDesc;
|
||||
|
||||
typedef
|
||||
struct OPT_StrDesc {
|
||||
SHORTINT form, comp, mno, extlev;
|
||||
INTEGER ref, sysflag;
|
||||
LONGINT n, size, align, txtpos;
|
||||
BOOLEAN allocated, pbused, pvused;
|
||||
char _prvt0[8];
|
||||
LONGINT pbfp, pvfp;
|
||||
OPT_Struct BaseTyp;
|
||||
OPT_Object link, strobj;
|
||||
} OPT_StrDesc;
|
||||
|
||||
|
||||
import void (*OPT_typSize)(OPT_Struct);
|
||||
import OPT_Object OPT_topScope;
|
||||
import OPT_Struct OPT_undftyp, OPT_bytetyp, OPT_booltyp, OPT_chartyp, OPT_sinttyp, OPT_inttyp, OPT_linttyp, OPT_realtyp, OPT_lrltyp, OPT_settyp, OPT_stringtyp, OPT_niltyp, OPT_notyp, OPT_sysptrtyp;
|
||||
import SHORTINT OPT_nofGmod;
|
||||
import OPT_Object OPT_GlbMod[64];
|
||||
import OPS_Name OPT_SelfName;
|
||||
import BOOLEAN OPT_SYSimported;
|
||||
|
||||
import LONGINT *OPT_ConstDesc__typ;
|
||||
import LONGINT *OPT_ObjDesc__typ;
|
||||
import LONGINT *OPT_StrDesc__typ;
|
||||
import LONGINT *OPT_NodeDesc__typ;
|
||||
|
||||
import void OPT_Close (void);
|
||||
import void OPT_CloseScope (void);
|
||||
import void OPT_Export (BOOLEAN *ext, BOOLEAN *new);
|
||||
import void OPT_FPrintErr (OPT_Object obj, INTEGER errcode);
|
||||
import void OPT_FPrintObj (OPT_Object obj);
|
||||
import void OPT_FPrintStr (OPT_Struct typ);
|
||||
import void OPT_Find (OPT_Object *res);
|
||||
import void OPT_FindField (OPS_Name name, OPT_Struct typ, OPT_Object *res);
|
||||
import void OPT_FindImport (OPT_Object mod, OPT_Object *res);
|
||||
import void OPT_IdFPrint (OPT_Struct typ);
|
||||
import void OPT_Import (OPS_Name aliasName, OPS_Name name, BOOLEAN *done);
|
||||
import void OPT_Init (OPS_Name name, SET opt);
|
||||
import void OPT_Insert (OPS_Name name, OPT_Object *obj);
|
||||
import void OPT_InsertImport (OPT_Object obj, OPT_Object *root, OPT_Object *old);
|
||||
import OPT_Const OPT_NewConst (void);
|
||||
import OPT_ConstExt OPT_NewExt (void);
|
||||
import OPT_Node OPT_NewNode (SHORTINT class);
|
||||
import OPT_Object OPT_NewObj (void);
|
||||
import OPT_Struct OPT_NewStr (SHORTINT form, SHORTINT comp);
|
||||
import void OPT_OpenScope (SHORTINT level, OPT_Object owner);
|
||||
import void *OPT__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
1688
bootstrap/unix-48/OPV.c
Normal file
1688
bootstrap/unix-48/OPV.c
Normal file
File diff suppressed because it is too large
Load diff
19
bootstrap/unix-48/OPV.h
Normal file
19
bootstrap/unix-48/OPV.h
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#ifndef OPV__h
|
||||
#define OPV__h
|
||||
|
||||
#include "SYSTEM.h"
|
||||
#include "OPT.h"
|
||||
|
||||
|
||||
|
||||
|
||||
import void OPV_AdrAndSize (OPT_Object topScope);
|
||||
import void OPV_Init (void);
|
||||
import void OPV_Module (OPT_Node prog);
|
||||
import void OPV_TypSize (OPT_Struct typ);
|
||||
import void *OPV__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
792
bootstrap/unix-48/Platform.c
Normal file
792
bootstrap/unix-48/Platform.c
Normal file
|
|
@ -0,0 +1,792 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
#include "SYSTEM.h"
|
||||
|
||||
typedef
|
||||
CHAR (*Platform_ArgPtr)[1024];
|
||||
|
||||
typedef
|
||||
Platform_ArgPtr (*Platform_ArgVec)[1024];
|
||||
|
||||
typedef
|
||||
LONGINT (*Platform_ArgVecPtr)[1];
|
||||
|
||||
typedef
|
||||
CHAR (*Platform_EnvPtr)[1024];
|
||||
|
||||
typedef
|
||||
struct Platform_FileIdentity {
|
||||
LONGINT volume, index, mtime;
|
||||
} Platform_FileIdentity;
|
||||
|
||||
typedef
|
||||
void (*Platform_HaltProcedure)(LONGINT);
|
||||
|
||||
typedef
|
||||
void (*Platform_SignalHandler)(INTEGER);
|
||||
|
||||
|
||||
export BOOLEAN Platform_LittleEndian;
|
||||
export LONGINT Platform_MainStackFrame, Platform_HaltCode;
|
||||
export INTEGER Platform_PID;
|
||||
export CHAR Platform_CWD[256];
|
||||
export INTEGER Platform_ArgCount;
|
||||
export LONGINT Platform_ArgVector;
|
||||
static Platform_HaltProcedure Platform_HaltHandler;
|
||||
static LONGINT Platform_TimeStart;
|
||||
export INTEGER Platform_SeekSet, Platform_SeekCur, Platform_SeekEnd;
|
||||
export CHAR Platform_nl[3];
|
||||
|
||||
export LONGINT *Platform_FileIdentity__typ;
|
||||
|
||||
export BOOLEAN Platform_Absent (INTEGER e);
|
||||
export INTEGER Platform_ArgPos (CHAR *s, LONGINT s__len);
|
||||
export void Platform_AssertFail (LONGINT code);
|
||||
export INTEGER Platform_Chdir (CHAR *n, LONGINT n__len);
|
||||
export INTEGER Platform_Close (LONGINT h);
|
||||
export BOOLEAN Platform_ConnectionFailed (INTEGER e);
|
||||
export void Platform_Delay (LONGINT ms);
|
||||
export BOOLEAN Platform_DifferentFilesystems (INTEGER e);
|
||||
static void Platform_DisplayHaltCode (LONGINT code);
|
||||
export INTEGER Platform_Error (void);
|
||||
export void Platform_Exit (INTEGER code);
|
||||
export void Platform_GetArg (INTEGER n, CHAR *val, LONGINT val__len);
|
||||
export void Platform_GetClock (LONGINT *t, LONGINT *d);
|
||||
export void Platform_GetEnv (CHAR *var, LONGINT var__len, CHAR *val, LONGINT val__len);
|
||||
export void Platform_GetIntArg (INTEGER n, LONGINT *val);
|
||||
export void Platform_GetTimeOfDay (LONGINT *sec, LONGINT *usec);
|
||||
export void Platform_Halt (LONGINT code);
|
||||
export INTEGER Platform_Identify (LONGINT h, Platform_FileIdentity *identity, LONGINT *identity__typ);
|
||||
export INTEGER Platform_IdentifyByName (CHAR *n, LONGINT n__len, Platform_FileIdentity *identity, LONGINT *identity__typ);
|
||||
export BOOLEAN Platform_Inaccessible (INTEGER e);
|
||||
export void Platform_Init (INTEGER argc, LONGINT argvadr);
|
||||
export void Platform_MTimeAsClock (Platform_FileIdentity i, LONGINT *t, LONGINT *d);
|
||||
export INTEGER Platform_New (CHAR *n, LONGINT n__len, LONGINT *h);
|
||||
export BOOLEAN Platform_NoSuchDirectory (INTEGER e);
|
||||
export LONGINT Platform_OSAllocate (LONGINT size);
|
||||
export void Platform_OSFree (LONGINT address);
|
||||
export INTEGER Platform_OldRO (CHAR *n, LONGINT n__len, LONGINT *h);
|
||||
export INTEGER Platform_OldRW (CHAR *n, LONGINT n__len, LONGINT *h);
|
||||
export INTEGER Platform_Read (LONGINT h, LONGINT p, LONGINT l, LONGINT *n);
|
||||
export INTEGER Platform_ReadBuf (LONGINT h, SYSTEM_BYTE *b, LONGINT b__len, LONGINT *n);
|
||||
export INTEGER Platform_Rename (CHAR *o, LONGINT o__len, CHAR *n, LONGINT n__len);
|
||||
export BOOLEAN Platform_SameFile (Platform_FileIdentity i1, Platform_FileIdentity i2);
|
||||
export BOOLEAN Platform_SameFileTime (Platform_FileIdentity i1, Platform_FileIdentity i2);
|
||||
export INTEGER Platform_Seek (LONGINT h, LONGINT offset, INTEGER whence);
|
||||
export void Platform_SetBadInstructionHandler (Platform_SignalHandler handler);
|
||||
export void Platform_SetHalt (Platform_HaltProcedure p);
|
||||
export void Platform_SetInterruptHandler (Platform_SignalHandler handler);
|
||||
export void Platform_SetMTime (Platform_FileIdentity *target, LONGINT *target__typ, Platform_FileIdentity source);
|
||||
export void Platform_SetQuitHandler (Platform_SignalHandler handler);
|
||||
export INTEGER Platform_Size (LONGINT h, LONGINT *l);
|
||||
export INTEGER Platform_Sync (LONGINT h);
|
||||
export INTEGER Platform_System (CHAR *cmd, LONGINT cmd__len);
|
||||
static void Platform_TestLittleEndian (void);
|
||||
export LONGINT Platform_Time (void);
|
||||
export BOOLEAN Platform_TimedOut (INTEGER e);
|
||||
export BOOLEAN Platform_TooManyFiles (INTEGER e);
|
||||
export INTEGER Platform_Truncate (LONGINT h, LONGINT l);
|
||||
export INTEGER Platform_Unlink (CHAR *n, LONGINT n__len);
|
||||
export INTEGER Platform_Write (LONGINT h, LONGINT p, LONGINT l);
|
||||
static void Platform_YMDHMStoClock (LONGINT ye, LONGINT mo, LONGINT da, LONGINT ho, LONGINT mi, LONGINT se, LONGINT *t, LONGINT *d);
|
||||
static void Platform_errch (CHAR c);
|
||||
static void Platform_errint (LONGINT l);
|
||||
static void Platform_errln (void);
|
||||
static void Platform_errposint (LONGINT l);
|
||||
export BOOLEAN Platform_getEnv (CHAR *var, LONGINT var__len, CHAR *val, LONGINT val__len);
|
||||
|
||||
#include <errno.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#define Platform_EACCES() EACCES
|
||||
#define Platform_EAGAIN() EAGAIN
|
||||
#define Platform_ECONNABORTED() ECONNABORTED
|
||||
#define Platform_ECONNREFUSED() ECONNREFUSED
|
||||
#define Platform_EHOSTUNREACH() EHOSTUNREACH
|
||||
#define Platform_EMFILE() EMFILE
|
||||
#define Platform_ENETUNREACH() ENETUNREACH
|
||||
#define Platform_ENFILE() ENFILE
|
||||
#define Platform_ENOENT() ENOENT
|
||||
#define Platform_EROFS() EROFS
|
||||
#define Platform_ETIMEDOUT() ETIMEDOUT
|
||||
#define Platform_EXDEV() EXDEV
|
||||
extern void Heap_InitHeap();
|
||||
#define Platform_HeapInitHeap() Heap_InitHeap()
|
||||
#define Platform_allocate(size) (LONGINT)(uintptr_t)((void*)malloc((size_t)size))
|
||||
#define Platform_chdir(n, n__len) chdir((char*)n)
|
||||
#define Platform_closefile(fd) close(fd)
|
||||
#define Platform_err() errno
|
||||
#define Platform_errc(c) write(1, &c, 1)
|
||||
#define Platform_errstring(s, s__len) write(1, s, s__len-1)
|
||||
#define Platform_exit(code) exit(code)
|
||||
#define Platform_free(address) free((void*)(uintptr_t)address)
|
||||
#define Platform_fstat(fd) fstat(fd, &s)
|
||||
#define Platform_fsync(fd) fsync(fd)
|
||||
#define Platform_ftruncate(fd, l) ftruncate(fd, l)
|
||||
#define Platform_getcwd(cwd, cwd__len) getcwd((char*)cwd, cwd__len)
|
||||
#define Platform_getenv(var, var__len) (Platform_EnvPtr)getenv((char*)var)
|
||||
#define Platform_getpid() (INTEGER)getpid()
|
||||
#define Platform_gettimeval() struct timeval tv; gettimeofday(&tv,0)
|
||||
#define Platform_lseek(fd, o, w) lseek(fd, o, w)
|
||||
#define Platform_nanosleep(s, ns) struct timespec req, rem; req.tv_sec = s; req.tv_nsec = ns; nanosleep(&req, &rem)
|
||||
#define Platform_opennew(n, n__len) open((char*)n, O_CREAT | O_TRUNC | O_RDWR, 0664)
|
||||
#define Platform_openro(n, n__len) open((char*)n, O_RDONLY)
|
||||
#define Platform_openrw(n, n__len) open((char*)n, O_RDWR)
|
||||
#define Platform_readfile(fd, p, l) read(fd, (void*)(uintptr_t)(p), l)
|
||||
#define Platform_rename(o, o__len, n, n__len) rename((char*)o, (char*)n)
|
||||
#define Platform_sectotm(s) struct tm *time = localtime((time_t*)&s)
|
||||
#define Platform_seekcur() SEEK_CUR
|
||||
#define Platform_seekend() SEEK_END
|
||||
#define Platform_seekset() SEEK_SET
|
||||
#define Platform_sethandler(s, h) SystemSetHandler(s, (uintptr_t)h)
|
||||
#define Platform_stat(n, n__len) stat((char*)n, &s)
|
||||
#define Platform_statdev() (LONGINT)s.st_dev
|
||||
#define Platform_statino() (LONGINT)s.st_ino
|
||||
#define Platform_statmtime() (LONGINT)s.st_mtime
|
||||
#define Platform_statsize() (LONGINT)s.st_size
|
||||
#define Platform_structstats() struct stat s
|
||||
#define Platform_system(str, str__len) system((char*)str)
|
||||
#define Platform_tmhour() (LONGINT)time->tm_hour
|
||||
#define Platform_tmmday() (LONGINT)time->tm_mday
|
||||
#define Platform_tmmin() (LONGINT)time->tm_min
|
||||
#define Platform_tmmon() (LONGINT)time->tm_mon
|
||||
#define Platform_tmsec() (LONGINT)time->tm_sec
|
||||
#define Platform_tmyear() (LONGINT)time->tm_year
|
||||
#define Platform_tvsec() tv.tv_sec
|
||||
#define Platform_tvusec() tv.tv_usec
|
||||
#define Platform_unlink(n, n__len) unlink((char*)n)
|
||||
#define Platform_writefile(fd, p, l) write(fd, (void*)(uintptr_t)(p), l)
|
||||
|
||||
BOOLEAN Platform_TooManyFiles (INTEGER e)
|
||||
{
|
||||
BOOLEAN _o_result;
|
||||
_o_result = e == Platform_EMFILE() || e == Platform_ENFILE();
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
BOOLEAN Platform_NoSuchDirectory (INTEGER e)
|
||||
{
|
||||
BOOLEAN _o_result;
|
||||
_o_result = e == Platform_ENOENT();
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
BOOLEAN Platform_DifferentFilesystems (INTEGER e)
|
||||
{
|
||||
BOOLEAN _o_result;
|
||||
_o_result = e == Platform_EXDEV();
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
BOOLEAN Platform_Inaccessible (INTEGER e)
|
||||
{
|
||||
BOOLEAN _o_result;
|
||||
_o_result = (e == Platform_EACCES() || e == Platform_EROFS()) || e == Platform_EAGAIN();
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
BOOLEAN Platform_Absent (INTEGER e)
|
||||
{
|
||||
BOOLEAN _o_result;
|
||||
_o_result = e == Platform_ENOENT();
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
BOOLEAN Platform_TimedOut (INTEGER e)
|
||||
{
|
||||
BOOLEAN _o_result;
|
||||
_o_result = e == Platform_ETIMEDOUT();
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
BOOLEAN Platform_ConnectionFailed (INTEGER e)
|
||||
{
|
||||
BOOLEAN _o_result;
|
||||
_o_result = ((e == Platform_ECONNREFUSED() || e == Platform_ECONNABORTED()) || e == Platform_ENETUNREACH()) || e == Platform_EHOSTUNREACH();
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
LONGINT Platform_OSAllocate (LONGINT size)
|
||||
{
|
||||
LONGINT _o_result;
|
||||
_o_result = Platform_allocate(size);
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
void Platform_OSFree (LONGINT address)
|
||||
{
|
||||
Platform_free(address);
|
||||
}
|
||||
|
||||
void Platform_Init (INTEGER argc, LONGINT argvadr)
|
||||
{
|
||||
Platform_ArgVecPtr av = NIL;
|
||||
Platform_MainStackFrame = argvadr;
|
||||
Platform_ArgCount = argc;
|
||||
av = (Platform_ArgVecPtr)(uintptr_t)argvadr;
|
||||
Platform_ArgVector = (*av)[0];
|
||||
Platform_HaltCode = -128;
|
||||
Platform_HeapInitHeap();
|
||||
}
|
||||
|
||||
BOOLEAN Platform_getEnv (CHAR *var, LONGINT var__len, CHAR *val, LONGINT val__len)
|
||||
{
|
||||
BOOLEAN _o_result;
|
||||
Platform_EnvPtr p = NIL;
|
||||
__DUP(var, var__len, CHAR);
|
||||
p = Platform_getenv(var, var__len);
|
||||
if (p != NIL) {
|
||||
__COPY(*p, val, val__len);
|
||||
}
|
||||
_o_result = p != NIL;
|
||||
__DEL(var);
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
void Platform_GetEnv (CHAR *var, LONGINT var__len, CHAR *val, LONGINT val__len)
|
||||
{
|
||||
__DUP(var, var__len, CHAR);
|
||||
if (!Platform_getEnv(var, var__len, (void*)val, val__len)) {
|
||||
val[0] = 0x00;
|
||||
}
|
||||
__DEL(var);
|
||||
}
|
||||
|
||||
void Platform_GetArg (INTEGER n, CHAR *val, LONGINT val__len)
|
||||
{
|
||||
Platform_ArgVec av = NIL;
|
||||
if (n < Platform_ArgCount) {
|
||||
av = (Platform_ArgVec)(uintptr_t)Platform_ArgVector;
|
||||
__COPY(*(*av)[__X(n, ((LONGINT)(1024)))], val, val__len);
|
||||
}
|
||||
}
|
||||
|
||||
void Platform_GetIntArg (INTEGER n, LONGINT *val)
|
||||
{
|
||||
CHAR s[64];
|
||||
LONGINT k, d, i;
|
||||
s[0] = 0x00;
|
||||
Platform_GetArg(n, (void*)s, ((LONGINT)(64)));
|
||||
i = 0;
|
||||
if (s[0] == '-') {
|
||||
i = 1;
|
||||
}
|
||||
k = 0;
|
||||
d = (int)s[__X(i, ((LONGINT)(64)))] - 48;
|
||||
while ((d >= 0 && d <= 9)) {
|
||||
k = k * 10 + d;
|
||||
i += 1;
|
||||
d = (int)s[__X(i, ((LONGINT)(64)))] - 48;
|
||||
}
|
||||
if (s[0] == '-') {
|
||||
k = -k;
|
||||
i -= 1;
|
||||
}
|
||||
if (i > 0) {
|
||||
*val = k;
|
||||
}
|
||||
}
|
||||
|
||||
INTEGER Platform_ArgPos (CHAR *s, LONGINT s__len)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
INTEGER i;
|
||||
CHAR arg[256];
|
||||
__DUP(s, s__len, CHAR);
|
||||
i = 0;
|
||||
Platform_GetArg(i, (void*)arg, ((LONGINT)(256)));
|
||||
while ((i < Platform_ArgCount && __STRCMP(s, arg) != 0)) {
|
||||
i += 1;
|
||||
Platform_GetArg(i, (void*)arg, ((LONGINT)(256)));
|
||||
}
|
||||
_o_result = i;
|
||||
__DEL(s);
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
void Platform_SetInterruptHandler (Platform_SignalHandler handler)
|
||||
{
|
||||
Platform_sethandler(2, handler);
|
||||
}
|
||||
|
||||
void Platform_SetQuitHandler (Platform_SignalHandler handler)
|
||||
{
|
||||
Platform_sethandler(3, handler);
|
||||
}
|
||||
|
||||
void Platform_SetBadInstructionHandler (Platform_SignalHandler handler)
|
||||
{
|
||||
Platform_sethandler(4, handler);
|
||||
}
|
||||
|
||||
static void Platform_YMDHMStoClock (LONGINT ye, LONGINT mo, LONGINT da, LONGINT ho, LONGINT mi, LONGINT se, LONGINT *t, LONGINT *d)
|
||||
{
|
||||
*d = (__ASHL(__MOD(ye, 100), 9) + __ASHL(mo + 1, 5)) + da;
|
||||
*t = (__ASHL(ho, 12) + __ASHL(mi, 6)) + se;
|
||||
}
|
||||
|
||||
void Platform_GetClock (LONGINT *t, LONGINT *d)
|
||||
{
|
||||
Platform_gettimeval();
|
||||
Platform_sectotm(Platform_tvsec());
|
||||
Platform_YMDHMStoClock(Platform_tmyear(), Platform_tmmon(), Platform_tmmday(), Platform_tmhour(), Platform_tmmin(), Platform_tmsec(), &*t, &*d);
|
||||
}
|
||||
|
||||
void Platform_GetTimeOfDay (LONGINT *sec, LONGINT *usec)
|
||||
{
|
||||
Platform_gettimeval();
|
||||
*sec = Platform_tvsec();
|
||||
*usec = Platform_tvusec();
|
||||
}
|
||||
|
||||
LONGINT Platform_Time (void)
|
||||
{
|
||||
LONGINT _o_result;
|
||||
LONGINT ms;
|
||||
Platform_gettimeval();
|
||||
ms = __DIVF(Platform_tvusec(), 1000) + Platform_tvsec() * 1000;
|
||||
_o_result = __MOD(ms - Platform_TimeStart, 2147483647);
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
void Platform_Delay (LONGINT ms)
|
||||
{
|
||||
LONGINT s, ns;
|
||||
s = __DIV(ms, 1000);
|
||||
ns = __MOD(ms, 1000) * 1000000;
|
||||
Platform_nanosleep(s, ns);
|
||||
}
|
||||
|
||||
INTEGER Platform_System (CHAR *cmd, LONGINT cmd__len)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
__DUP(cmd, cmd__len, CHAR);
|
||||
_o_result = Platform_system(cmd, cmd__len);
|
||||
__DEL(cmd);
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
INTEGER Platform_Error (void)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
_o_result = Platform_err();
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
INTEGER Platform_OldRO (CHAR *n, LONGINT n__len, LONGINT *h)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
INTEGER fd;
|
||||
fd = Platform_openro(n, n__len);
|
||||
if (fd < 0) {
|
||||
_o_result = Platform_err();
|
||||
return _o_result;
|
||||
} else {
|
||||
*h = fd;
|
||||
_o_result = 0;
|
||||
return _o_result;
|
||||
}
|
||||
__RETCHK;
|
||||
}
|
||||
|
||||
INTEGER Platform_OldRW (CHAR *n, LONGINT n__len, LONGINT *h)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
INTEGER fd;
|
||||
fd = Platform_openrw(n, n__len);
|
||||
if (fd < 0) {
|
||||
_o_result = Platform_err();
|
||||
return _o_result;
|
||||
} else {
|
||||
*h = fd;
|
||||
_o_result = 0;
|
||||
return _o_result;
|
||||
}
|
||||
__RETCHK;
|
||||
}
|
||||
|
||||
INTEGER Platform_New (CHAR *n, LONGINT n__len, LONGINT *h)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
INTEGER fd;
|
||||
fd = Platform_opennew(n, n__len);
|
||||
if (fd < 0) {
|
||||
_o_result = Platform_err();
|
||||
return _o_result;
|
||||
} else {
|
||||
*h = fd;
|
||||
_o_result = 0;
|
||||
return _o_result;
|
||||
}
|
||||
__RETCHK;
|
||||
}
|
||||
|
||||
INTEGER Platform_Close (LONGINT h)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
if (Platform_closefile(h) < 0) {
|
||||
_o_result = Platform_err();
|
||||
return _o_result;
|
||||
} else {
|
||||
_o_result = 0;
|
||||
return _o_result;
|
||||
}
|
||||
__RETCHK;
|
||||
}
|
||||
|
||||
INTEGER Platform_Identify (LONGINT h, Platform_FileIdentity *identity, LONGINT *identity__typ)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
Platform_structstats();
|
||||
if (Platform_fstat(h) < 0) {
|
||||
_o_result = Platform_err();
|
||||
return _o_result;
|
||||
}
|
||||
(*identity).volume = Platform_statdev();
|
||||
(*identity).index = Platform_statino();
|
||||
(*identity).mtime = Platform_statmtime();
|
||||
_o_result = 0;
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
INTEGER Platform_IdentifyByName (CHAR *n, LONGINT n__len, Platform_FileIdentity *identity, LONGINT *identity__typ)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
__DUP(n, n__len, CHAR);
|
||||
Platform_structstats();
|
||||
if (Platform_stat(n, n__len) < 0) {
|
||||
_o_result = Platform_err();
|
||||
__DEL(n);
|
||||
return _o_result;
|
||||
}
|
||||
(*identity).volume = Platform_statdev();
|
||||
(*identity).index = Platform_statino();
|
||||
(*identity).mtime = Platform_statmtime();
|
||||
_o_result = 0;
|
||||
__DEL(n);
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
BOOLEAN Platform_SameFile (Platform_FileIdentity i1, Platform_FileIdentity i2)
|
||||
{
|
||||
BOOLEAN _o_result;
|
||||
_o_result = (i1.index == i2.index && i1.volume == i2.volume);
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
BOOLEAN Platform_SameFileTime (Platform_FileIdentity i1, Platform_FileIdentity i2)
|
||||
{
|
||||
BOOLEAN _o_result;
|
||||
_o_result = i1.mtime == i2.mtime;
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
void Platform_SetMTime (Platform_FileIdentity *target, LONGINT *target__typ, Platform_FileIdentity source)
|
||||
{
|
||||
(*target).mtime = source.mtime;
|
||||
}
|
||||
|
||||
void Platform_MTimeAsClock (Platform_FileIdentity i, LONGINT *t, LONGINT *d)
|
||||
{
|
||||
Platform_sectotm(i.mtime);
|
||||
Platform_YMDHMStoClock(Platform_tmyear(), Platform_tmmon(), Platform_tmmday(), Platform_tmhour(), Platform_tmmin(), Platform_tmsec(), &*t, &*d);
|
||||
}
|
||||
|
||||
INTEGER Platform_Size (LONGINT h, LONGINT *l)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
Platform_structstats();
|
||||
if (Platform_fstat(h) < 0) {
|
||||
_o_result = Platform_err();
|
||||
return _o_result;
|
||||
}
|
||||
*l = Platform_statsize();
|
||||
_o_result = 0;
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
INTEGER Platform_Read (LONGINT h, LONGINT p, LONGINT l, LONGINT *n)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
*n = Platform_readfile(h, p, l);
|
||||
if (*n < 0) {
|
||||
*n = 0;
|
||||
_o_result = Platform_err();
|
||||
return _o_result;
|
||||
} else {
|
||||
_o_result = 0;
|
||||
return _o_result;
|
||||
}
|
||||
__RETCHK;
|
||||
}
|
||||
|
||||
INTEGER Platform_ReadBuf (LONGINT h, SYSTEM_BYTE *b, LONGINT b__len, LONGINT *n)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
*n = Platform_readfile(h, (LONGINT)(uintptr_t)b, b__len);
|
||||
if (*n < 0) {
|
||||
*n = 0;
|
||||
_o_result = Platform_err();
|
||||
return _o_result;
|
||||
} else {
|
||||
_o_result = 0;
|
||||
return _o_result;
|
||||
}
|
||||
__RETCHK;
|
||||
}
|
||||
|
||||
INTEGER Platform_Write (LONGINT h, LONGINT p, LONGINT l)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
LONGINT written;
|
||||
written = Platform_writefile(h, p, l);
|
||||
if (written < 0) {
|
||||
_o_result = Platform_err();
|
||||
return _o_result;
|
||||
} else {
|
||||
_o_result = 0;
|
||||
return _o_result;
|
||||
}
|
||||
__RETCHK;
|
||||
}
|
||||
|
||||
INTEGER Platform_Sync (LONGINT h)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
if (Platform_fsync(h) < 0) {
|
||||
_o_result = Platform_err();
|
||||
return _o_result;
|
||||
} else {
|
||||
_o_result = 0;
|
||||
return _o_result;
|
||||
}
|
||||
__RETCHK;
|
||||
}
|
||||
|
||||
INTEGER Platform_Seek (LONGINT h, LONGINT offset, INTEGER whence)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
if (Platform_lseek(h, offset, whence) < 0) {
|
||||
_o_result = Platform_err();
|
||||
return _o_result;
|
||||
} else {
|
||||
_o_result = 0;
|
||||
return _o_result;
|
||||
}
|
||||
__RETCHK;
|
||||
}
|
||||
|
||||
INTEGER Platform_Truncate (LONGINT h, LONGINT l)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
if (Platform_ftruncate(h, l) < 0) {
|
||||
_o_result = Platform_err();
|
||||
return _o_result;
|
||||
} else {
|
||||
_o_result = 0;
|
||||
return _o_result;
|
||||
}
|
||||
__RETCHK;
|
||||
}
|
||||
|
||||
INTEGER Platform_Unlink (CHAR *n, LONGINT n__len)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
if (Platform_unlink(n, n__len) < 0) {
|
||||
_o_result = Platform_err();
|
||||
return _o_result;
|
||||
} else {
|
||||
_o_result = 0;
|
||||
return _o_result;
|
||||
}
|
||||
__RETCHK;
|
||||
}
|
||||
|
||||
INTEGER Platform_Chdir (CHAR *n, LONGINT n__len)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
INTEGER r;
|
||||
r = Platform_chdir(n, n__len);
|
||||
Platform_getcwd((void*)Platform_CWD, ((LONGINT)(256)));
|
||||
if (r < 0) {
|
||||
_o_result = Platform_err();
|
||||
return _o_result;
|
||||
} else {
|
||||
_o_result = 0;
|
||||
return _o_result;
|
||||
}
|
||||
__RETCHK;
|
||||
}
|
||||
|
||||
INTEGER Platform_Rename (CHAR *o, LONGINT o__len, CHAR *n, LONGINT n__len)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
if (Platform_rename(o, o__len, n, n__len) < 0) {
|
||||
_o_result = Platform_err();
|
||||
return _o_result;
|
||||
} else {
|
||||
_o_result = 0;
|
||||
return _o_result;
|
||||
}
|
||||
__RETCHK;
|
||||
}
|
||||
|
||||
void Platform_Exit (INTEGER code)
|
||||
{
|
||||
Platform_exit(code);
|
||||
}
|
||||
|
||||
static void Platform_errch (CHAR c)
|
||||
{
|
||||
Platform_errc(c);
|
||||
}
|
||||
|
||||
static void Platform_errln (void)
|
||||
{
|
||||
Platform_errch(0x0d);
|
||||
Platform_errch(0x0a);
|
||||
}
|
||||
|
||||
static void Platform_errposint (LONGINT l)
|
||||
{
|
||||
if (l > 10) {
|
||||
Platform_errposint(__DIV(l, 10));
|
||||
}
|
||||
Platform_errch((CHAR)(48 + __MOD(l, 10)));
|
||||
}
|
||||
|
||||
static void Platform_errint (LONGINT l)
|
||||
{
|
||||
if (l < 0) {
|
||||
Platform_errch('-');
|
||||
l = -l;
|
||||
}
|
||||
Platform_errposint(l);
|
||||
}
|
||||
|
||||
static void Platform_DisplayHaltCode (LONGINT code)
|
||||
{
|
||||
switch (code) {
|
||||
case -1:
|
||||
Platform_errstring((CHAR*)"Assertion failure.", (LONGINT)19);
|
||||
break;
|
||||
case -2:
|
||||
Platform_errstring((CHAR*)"Index out of range.", (LONGINT)20);
|
||||
break;
|
||||
case -3:
|
||||
Platform_errstring((CHAR*)"Reached end of function without reaching RETURN.", (LONGINT)49);
|
||||
break;
|
||||
case -4:
|
||||
Platform_errstring((CHAR*)"CASE statement: no matching label and no ELSE.", (LONGINT)47);
|
||||
break;
|
||||
case -5:
|
||||
Platform_errstring((CHAR*)"Type guard failed.", (LONGINT)19);
|
||||
break;
|
||||
case -6:
|
||||
Platform_errstring((CHAR*)"Implicit type guard in record assignment failed.", (LONGINT)49);
|
||||
break;
|
||||
case -7:
|
||||
Platform_errstring((CHAR*)"Invalid case in WITH statement.", (LONGINT)32);
|
||||
break;
|
||||
case -8:
|
||||
Platform_errstring((CHAR*)"Value out of range.", (LONGINT)20);
|
||||
break;
|
||||
case -9:
|
||||
Platform_errstring((CHAR*)"Heap interrupted while locked, but lockdepth = 0 at unlock.", (LONGINT)60);
|
||||
break;
|
||||
case -10:
|
||||
Platform_errstring((CHAR*)"NIL access.", (LONGINT)12);
|
||||
break;
|
||||
case -11:
|
||||
Platform_errstring((CHAR*)"Alignment error.", (LONGINT)17);
|
||||
break;
|
||||
case -12:
|
||||
Platform_errstring((CHAR*)"Divide by zero.", (LONGINT)16);
|
||||
break;
|
||||
case -13:
|
||||
Platform_errstring((CHAR*)"Arithmetic overflow/underflow.", (LONGINT)31);
|
||||
break;
|
||||
case -14:
|
||||
Platform_errstring((CHAR*)"Invalid function argument.", (LONGINT)27);
|
||||
break;
|
||||
case -15:
|
||||
Platform_errstring((CHAR*)"Internal error, e.g. Type descriptor size mismatch.", (LONGINT)52);
|
||||
break;
|
||||
case -20:
|
||||
Platform_errstring((CHAR*)"Too many, or negative number of, elements in dynamic array.", (LONGINT)60);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Platform_Halt (LONGINT code)
|
||||
{
|
||||
INTEGER e;
|
||||
Platform_HaltCode = code;
|
||||
if (Platform_HaltHandler != NIL) {
|
||||
(*Platform_HaltHandler)(code);
|
||||
}
|
||||
Platform_errstring((CHAR*)"Terminated by Halt(", (LONGINT)20);
|
||||
Platform_errint(code);
|
||||
Platform_errstring((CHAR*)"). ", (LONGINT)4);
|
||||
if (code < 0) {
|
||||
Platform_DisplayHaltCode(code);
|
||||
}
|
||||
Platform_errln();
|
||||
Platform_exit(__VAL(INTEGER, code));
|
||||
}
|
||||
|
||||
void Platform_AssertFail (LONGINT code)
|
||||
{
|
||||
INTEGER e;
|
||||
Platform_errstring((CHAR*)"Assertion failure.", (LONGINT)19);
|
||||
if (code != 0) {
|
||||
Platform_errstring((CHAR*)" ASSERT code ", (LONGINT)14);
|
||||
Platform_errint(code);
|
||||
Platform_errstring((CHAR*)".", (LONGINT)2);
|
||||
}
|
||||
Platform_errln();
|
||||
Platform_exit(__VAL(INTEGER, code));
|
||||
}
|
||||
|
||||
void Platform_SetHalt (Platform_HaltProcedure p)
|
||||
{
|
||||
Platform_HaltHandler = p;
|
||||
}
|
||||
|
||||
static void Platform_TestLittleEndian (void)
|
||||
{
|
||||
INTEGER i;
|
||||
i = 1;
|
||||
__GET((LONGINT)(uintptr_t)&i, Platform_LittleEndian, BOOLEAN);
|
||||
}
|
||||
|
||||
__TDESC(Platform_FileIdentity, 1, 0) = {__TDFLDS("FileIdentity", 12), {-4}};
|
||||
|
||||
export void *Platform__init(void)
|
||||
{
|
||||
__DEFMOD;
|
||||
__REGMOD("Platform", 0);
|
||||
__INITYP(Platform_FileIdentity, Platform_FileIdentity, 0);
|
||||
/* BEGIN */
|
||||
Platform_TestLittleEndian();
|
||||
Platform_HaltCode = -128;
|
||||
Platform_HaltHandler = NIL;
|
||||
Platform_TimeStart = Platform_Time();
|
||||
Platform_CWD[0] = 0x00;
|
||||
Platform_getcwd((void*)Platform_CWD, ((LONGINT)(256)));
|
||||
Platform_PID = Platform_getpid();
|
||||
Platform_SeekSet = Platform_seekset();
|
||||
Platform_SeekCur = Platform_seekcur();
|
||||
Platform_SeekEnd = Platform_seekend();
|
||||
Platform_nl[0] = 0x0a;
|
||||
Platform_nl[1] = 0x00;
|
||||
__ENDMOD;
|
||||
}
|
||||
82
bootstrap/unix-48/Platform.h
Normal file
82
bootstrap/unix-48/Platform.h
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#ifndef Platform__h
|
||||
#define Platform__h
|
||||
|
||||
#include "SYSTEM.h"
|
||||
|
||||
typedef
|
||||
struct Platform_FileIdentity {
|
||||
LONGINT volume, index, mtime;
|
||||
} Platform_FileIdentity;
|
||||
|
||||
typedef
|
||||
void (*Platform_HaltProcedure)(LONGINT);
|
||||
|
||||
typedef
|
||||
void (*Platform_SignalHandler)(INTEGER);
|
||||
|
||||
|
||||
import BOOLEAN Platform_LittleEndian;
|
||||
import LONGINT Platform_MainStackFrame, Platform_HaltCode;
|
||||
import INTEGER Platform_PID;
|
||||
import CHAR Platform_CWD[256];
|
||||
import INTEGER Platform_ArgCount;
|
||||
import LONGINT Platform_ArgVector;
|
||||
import INTEGER Platform_SeekSet, Platform_SeekCur, Platform_SeekEnd;
|
||||
import CHAR Platform_nl[3];
|
||||
|
||||
import LONGINT *Platform_FileIdentity__typ;
|
||||
|
||||
import BOOLEAN Platform_Absent (INTEGER e);
|
||||
import INTEGER Platform_ArgPos (CHAR *s, LONGINT s__len);
|
||||
import void Platform_AssertFail (LONGINT code);
|
||||
import INTEGER Platform_Chdir (CHAR *n, LONGINT n__len);
|
||||
import INTEGER Platform_Close (LONGINT h);
|
||||
import BOOLEAN Platform_ConnectionFailed (INTEGER e);
|
||||
import void Platform_Delay (LONGINT ms);
|
||||
import BOOLEAN Platform_DifferentFilesystems (INTEGER e);
|
||||
import INTEGER Platform_Error (void);
|
||||
import void Platform_Exit (INTEGER code);
|
||||
import void Platform_GetArg (INTEGER n, CHAR *val, LONGINT val__len);
|
||||
import void Platform_GetClock (LONGINT *t, LONGINT *d);
|
||||
import void Platform_GetEnv (CHAR *var, LONGINT var__len, CHAR *val, LONGINT val__len);
|
||||
import void Platform_GetIntArg (INTEGER n, LONGINT *val);
|
||||
import void Platform_GetTimeOfDay (LONGINT *sec, LONGINT *usec);
|
||||
import void Platform_Halt (LONGINT code);
|
||||
import INTEGER Platform_Identify (LONGINT h, Platform_FileIdentity *identity, LONGINT *identity__typ);
|
||||
import INTEGER Platform_IdentifyByName (CHAR *n, LONGINT n__len, Platform_FileIdentity *identity, LONGINT *identity__typ);
|
||||
import BOOLEAN Platform_Inaccessible (INTEGER e);
|
||||
import void Platform_Init (INTEGER argc, LONGINT argvadr);
|
||||
import void Platform_MTimeAsClock (Platform_FileIdentity i, LONGINT *t, LONGINT *d);
|
||||
import INTEGER Platform_New (CHAR *n, LONGINT n__len, LONGINT *h);
|
||||
import BOOLEAN Platform_NoSuchDirectory (INTEGER e);
|
||||
import LONGINT Platform_OSAllocate (LONGINT size);
|
||||
import void Platform_OSFree (LONGINT address);
|
||||
import INTEGER Platform_OldRO (CHAR *n, LONGINT n__len, LONGINT *h);
|
||||
import INTEGER Platform_OldRW (CHAR *n, LONGINT n__len, LONGINT *h);
|
||||
import INTEGER Platform_Read (LONGINT h, LONGINT p, LONGINT l, LONGINT *n);
|
||||
import INTEGER Platform_ReadBuf (LONGINT h, SYSTEM_BYTE *b, LONGINT b__len, LONGINT *n);
|
||||
import INTEGER Platform_Rename (CHAR *o, LONGINT o__len, CHAR *n, LONGINT n__len);
|
||||
import BOOLEAN Platform_SameFile (Platform_FileIdentity i1, Platform_FileIdentity i2);
|
||||
import BOOLEAN Platform_SameFileTime (Platform_FileIdentity i1, Platform_FileIdentity i2);
|
||||
import INTEGER Platform_Seek (LONGINT h, LONGINT offset, INTEGER whence);
|
||||
import void Platform_SetBadInstructionHandler (Platform_SignalHandler handler);
|
||||
import void Platform_SetHalt (Platform_HaltProcedure p);
|
||||
import void Platform_SetInterruptHandler (Platform_SignalHandler handler);
|
||||
import void Platform_SetMTime (Platform_FileIdentity *target, LONGINT *target__typ, Platform_FileIdentity source);
|
||||
import void Platform_SetQuitHandler (Platform_SignalHandler handler);
|
||||
import INTEGER Platform_Size (LONGINT h, LONGINT *l);
|
||||
import INTEGER Platform_Sync (LONGINT h);
|
||||
import INTEGER Platform_System (CHAR *cmd, LONGINT cmd__len);
|
||||
import LONGINT Platform_Time (void);
|
||||
import BOOLEAN Platform_TimedOut (INTEGER e);
|
||||
import BOOLEAN Platform_TooManyFiles (INTEGER e);
|
||||
import INTEGER Platform_Truncate (LONGINT h, LONGINT l);
|
||||
import INTEGER Platform_Unlink (CHAR *n, LONGINT n__len);
|
||||
import INTEGER Platform_Write (LONGINT h, LONGINT p, LONGINT l);
|
||||
import BOOLEAN Platform_getEnv (CHAR *var, LONGINT var__len, CHAR *val, LONGINT val__len);
|
||||
import void *Platform__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
155
bootstrap/unix-48/Reals.c
Normal file
155
bootstrap/unix-48/Reals.c
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
#include "SYSTEM.h"
|
||||
|
||||
|
||||
|
||||
|
||||
export void Reals_Convert (REAL x, INTEGER n, CHAR *d, LONGINT d__len);
|
||||
export void Reals_ConvertH (REAL y, CHAR *d, LONGINT d__len);
|
||||
export void Reals_ConvertHL (LONGREAL y, CHAR *d, LONGINT d__len);
|
||||
export void Reals_ConvertL (LONGREAL x, INTEGER n, CHAR *d, LONGINT d__len);
|
||||
export INTEGER Reals_Expo (REAL x);
|
||||
export INTEGER Reals_ExpoL (LONGREAL x);
|
||||
export REAL Reals_Ten (INTEGER e);
|
||||
export LONGREAL Reals_TenL (INTEGER e);
|
||||
static CHAR Reals_ToHex (INTEGER i);
|
||||
|
||||
|
||||
REAL Reals_Ten (INTEGER e)
|
||||
{
|
||||
REAL _o_result;
|
||||
LONGREAL r, power;
|
||||
r = (LONGREAL)1;
|
||||
power = (LONGREAL)10;
|
||||
while (e > 0) {
|
||||
if (__ODD(e)) {
|
||||
r = r * power;
|
||||
}
|
||||
power = power * power;
|
||||
e = __ASHR(e, 1);
|
||||
}
|
||||
_o_result = r;
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
LONGREAL Reals_TenL (INTEGER e)
|
||||
{
|
||||
LONGREAL _o_result;
|
||||
LONGREAL r, power;
|
||||
r = (LONGREAL)1;
|
||||
power = (LONGREAL)10;
|
||||
for (;;) {
|
||||
if (__ODD(e)) {
|
||||
r = r * power;
|
||||
}
|
||||
e = __ASHR(e, 1);
|
||||
if (e <= 0) {
|
||||
_o_result = r;
|
||||
return _o_result;
|
||||
}
|
||||
power = power * power;
|
||||
}
|
||||
__RETCHK;
|
||||
}
|
||||
|
||||
INTEGER Reals_Expo (REAL x)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
_o_result = (int)__MASK(__ASHR((LONGINT)(__VAL(INTEGER, x)), 23), -256);
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
INTEGER Reals_ExpoL (LONGREAL x)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
INTEGER i;
|
||||
LONGINT l;
|
||||
__GET((LONGINT)(uintptr_t)&x + 4, l, LONGINT);
|
||||
_o_result = (int)__MASK(__ASHR(l, 20), -2048);
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
void Reals_ConvertL (LONGREAL x, INTEGER n, CHAR *d, LONGINT d__len)
|
||||
{
|
||||
LONGINT i, j, k;
|
||||
if (x < (LONGREAL)0) {
|
||||
x = -x;
|
||||
}
|
||||
k = 0;
|
||||
if (n > 9) {
|
||||
i = __ENTIER(x / (LONGREAL)(LONGREAL)1000000000);
|
||||
j = __ENTIER(x - i * (LONGREAL)1000000000);
|
||||
if (j < 0) {
|
||||
j = 0;
|
||||
}
|
||||
while (k < 9) {
|
||||
d[__X(k, d__len)] = (CHAR)(__MOD(j, 10) + 48);
|
||||
j = __DIV(j, 10);
|
||||
k += 1;
|
||||
}
|
||||
} else {
|
||||
i = __ENTIER(x);
|
||||
}
|
||||
while (k < (LONGINT)n) {
|
||||
d[__X(k, d__len)] = (CHAR)(__MOD(i, 10) + 48);
|
||||
i = __DIV(i, 10);
|
||||
k += 1;
|
||||
}
|
||||
}
|
||||
|
||||
void Reals_Convert (REAL x, INTEGER n, CHAR *d, LONGINT d__len)
|
||||
{
|
||||
Reals_ConvertL(x, n, (void*)d, d__len);
|
||||
}
|
||||
|
||||
static CHAR Reals_ToHex (INTEGER i)
|
||||
{
|
||||
CHAR _o_result;
|
||||
if (i < 10) {
|
||||
_o_result = (CHAR)(i + 48);
|
||||
return _o_result;
|
||||
} else {
|
||||
_o_result = (CHAR)(i + 55);
|
||||
return _o_result;
|
||||
}
|
||||
__RETCHK;
|
||||
}
|
||||
|
||||
typedef
|
||||
CHAR (*pc4__3)[4];
|
||||
|
||||
void Reals_ConvertH (REAL y, CHAR *d, LONGINT d__len)
|
||||
{
|
||||
pc4__3 p = NIL;
|
||||
INTEGER i;
|
||||
p = (pc4__3)(uintptr_t)((LONGINT)(uintptr_t)&y);
|
||||
i = 0;
|
||||
while (i < 4) {
|
||||
d[__X(__ASHL(i, 1), d__len)] = Reals_ToHex(__ASHR((int)(*p)[__X(i, ((LONGINT)(4)))], 4));
|
||||
d[__X(__ASHL(i, 1) + 1, d__len)] = Reals_ToHex(__MASK((int)(*p)[__X(i, ((LONGINT)(4)))], -16));
|
||||
}
|
||||
}
|
||||
|
||||
typedef
|
||||
CHAR (*pc8__5)[8];
|
||||
|
||||
void Reals_ConvertHL (LONGREAL y, CHAR *d, LONGINT d__len)
|
||||
{
|
||||
pc8__5 p = NIL;
|
||||
INTEGER i;
|
||||
p = (pc8__5)(uintptr_t)((LONGINT)(uintptr_t)&y);
|
||||
i = 0;
|
||||
while (i < 8) {
|
||||
d[__X(__ASHL(i, 1), d__len)] = Reals_ToHex(__ASHR((int)(*p)[__X(i, ((LONGINT)(8)))], 4));
|
||||
d[__X(__ASHL(i, 1) + 1, d__len)] = Reals_ToHex(__MASK((int)(*p)[__X(i, ((LONGINT)(8)))], -16));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export void *Reals__init(void)
|
||||
{
|
||||
__DEFMOD;
|
||||
__REGMOD("Reals", 0);
|
||||
/* BEGIN */
|
||||
__ENDMOD;
|
||||
}
|
||||
22
bootstrap/unix-48/Reals.h
Normal file
22
bootstrap/unix-48/Reals.h
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#ifndef Reals__h
|
||||
#define Reals__h
|
||||
|
||||
#include "SYSTEM.h"
|
||||
|
||||
|
||||
|
||||
|
||||
import void Reals_Convert (REAL x, INTEGER n, CHAR *d, LONGINT d__len);
|
||||
import void Reals_ConvertH (REAL y, CHAR *d, LONGINT d__len);
|
||||
import void Reals_ConvertHL (LONGREAL y, CHAR *d, LONGINT d__len);
|
||||
import void Reals_ConvertL (LONGREAL x, INTEGER n, CHAR *d, LONGINT d__len);
|
||||
import INTEGER Reals_Expo (REAL x);
|
||||
import INTEGER Reals_ExpoL (LONGREAL x);
|
||||
import REAL Reals_Ten (INTEGER e);
|
||||
import LONGREAL Reals_TenL (INTEGER e);
|
||||
import void *Reals__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
207
bootstrap/unix-48/SYSTEM.c
Normal file
207
bootstrap/unix-48/SYSTEM.c
Normal file
|
|
@ -0,0 +1,207 @@
|
|||
/*
|
||||
* The body prefix file of the voc(jet backend) runtime system, Version 1.0
|
||||
*
|
||||
* Copyright (c) Software Templ, 1994, 1995
|
||||
*
|
||||
* Module SYSTEM is subject to change any time without prior notification.
|
||||
* Software Templ disclaims all warranties with regard to module SYSTEM,
|
||||
* in particular shall Software Templ not be liable for any damage resulting
|
||||
* from inappropriate use or modification of module SYSTEM.
|
||||
*
|
||||
* Version 1.1 jt, 24.11.95 fixes for correct pointer arithmetic on Cray computers
|
||||
* jt 31.1.2007 ANSI prototypes for malloc and exit in order to avoid cc warnings
|
||||
*
|
||||
*/
|
||||
|
||||
#include "SYSTEM.h"
|
||||
#include "stdarg.h"
|
||||
#include <signal.h>
|
||||
|
||||
|
||||
LONGINT SYSTEM_XCHK(LONGINT i, LONGINT ub) {return __X(i, ub);}
|
||||
LONGINT SYSTEM_RCHK(LONGINT i, LONGINT ub) {return __R(i, ub);}
|
||||
LONGINT SYSTEM_ASH (LONGINT i, LONGINT n) {return __ASH(i, n);}
|
||||
LONGINT SYSTEM_ABS (LONGINT i) {return __ABS(i);}
|
||||
double SYSTEM_ABSD(double i) {return __ABS(i);}
|
||||
|
||||
void SYSTEM_INHERIT(LONGINT *t, LONGINT *t0)
|
||||
{
|
||||
t -= __TPROC0OFF;
|
||||
t0 -= __TPROC0OFF;
|
||||
while (*t0 != __EOM) {*t = *t0; t--; t0--;}
|
||||
}
|
||||
|
||||
|
||||
void SYSTEM_ENUMP(void *adr, LONGINT n, void (*P)())
|
||||
{
|
||||
while (n > 0) {
|
||||
P((LONGINT)(uintptr_t)(*((void**)(adr))));
|
||||
adr = ((void**)adr) + 1;
|
||||
n--;
|
||||
}
|
||||
}
|
||||
|
||||
void SYSTEM_ENUMR(void *adr, LONGINT *typ, LONGINT size, LONGINT n, void (*P)())
|
||||
{
|
||||
LONGINT *t, off;
|
||||
typ++;
|
||||
while (n > 0) {
|
||||
t = typ;
|
||||
off = *t;
|
||||
while (off >= 0) {P(*(LONGINT*)((char*)adr+off)); t++; off = *t;}
|
||||
adr = ((char*)adr) + size;
|
||||
n--;
|
||||
}
|
||||
}
|
||||
|
||||
LONGINT SYSTEM_DIV(unsigned LONGINT x, unsigned LONGINT y)
|
||||
{ if ((LONGINT) x >= 0) return (x / y);
|
||||
else return -((y - 1 - x) / y);
|
||||
}
|
||||
|
||||
LONGINT SYSTEM_MOD(unsigned LONGINT x, unsigned LONGINT y)
|
||||
{ unsigned LONGINT m;
|
||||
if ((LONGINT) x >= 0) return (x % y);
|
||||
else { m = (-x) % y;
|
||||
if (m != 0) return (y - m); else return 0;
|
||||
}
|
||||
}
|
||||
|
||||
LONGINT SYSTEM_ENTIER(double x)
|
||||
{
|
||||
LONGINT y;
|
||||
if (x >= 0)
|
||||
return (LONGINT)x;
|
||||
else {
|
||||
y = (LONGINT)x;
|
||||
if (y <= x) return y; else return y - 1;
|
||||
}
|
||||
}
|
||||
|
||||
extern void Heap_Lock();
|
||||
extern void Heap_Unlock();
|
||||
|
||||
SYSTEM_PTR SYSTEM_NEWARR(LONGINT *typ, LONGINT elemsz, int elemalgn, int nofdim, int nofdyn, ...)
|
||||
{
|
||||
LONGINT nofelems, size, dataoff, n, nptr, *x, *p, nofptrs, i, *ptab, off;
|
||||
va_list ap;
|
||||
va_start(ap, nofdyn);
|
||||
nofelems = 1;
|
||||
while (nofdim > 0) {
|
||||
nofelems = nofelems * va_arg(ap, LONGINT); nofdim--;
|
||||
if (nofelems <= 0) __HALT(-20);
|
||||
}
|
||||
va_end(ap);
|
||||
dataoff = nofdyn * sizeof(LONGINT);
|
||||
if (elemalgn > sizeof(LONGINT)) {
|
||||
n = dataoff % elemalgn;
|
||||
if (n != 0) dataoff += elemalgn - n;
|
||||
}
|
||||
size = dataoff + nofelems * elemsz;
|
||||
Heap_Lock();
|
||||
if (typ == NIL) {
|
||||
/* element typ does not contain pointers */
|
||||
x = Heap_NEWBLK(size);
|
||||
}
|
||||
else if (typ == (LONGINT*)POINTER__typ) {
|
||||
/* element type is a pointer */
|
||||
x = Heap_NEWBLK(size + nofelems * sizeof(LONGINT));
|
||||
p = (LONGINT*)(uintptr_t)x[-1];
|
||||
p[-nofelems] = *p; /* build new type desc in situ: 1. copy block size; 2. setup ptr tab; 3. set sentinel; 4. patch tag */
|
||||
p -= nofelems - 1; n = 1; /* n =1 for skipping the size field */
|
||||
while (n <= nofelems) {*p = n*sizeof(LONGINT); p++; n++;}
|
||||
*p = - (nofelems + 1) * sizeof(LONGINT); /* sentinel */
|
||||
x[-1] -= nofelems * sizeof(LONGINT);
|
||||
}
|
||||
else {
|
||||
/* element type is a record that contains pointers */
|
||||
ptab = typ + 1; nofptrs = 0;
|
||||
while (ptab[nofptrs] >= 0) {nofptrs++;} /* number of pointers per element */
|
||||
nptr = nofelems * nofptrs; /* total number of pointers */
|
||||
x = Heap_NEWBLK(size + nptr * sizeof(LONGINT));
|
||||
p = (LONGINT*)(uintptr_t)x[- 1];
|
||||
p[-nptr] = *p; /* build new type desc in situ; 1. copy block size; 2. setup ptr tab; 3. set sentinel; 4. patch tag */
|
||||
p -= nptr - 1; n = 0; off = dataoff;
|
||||
while (n < nofelems) {i = 0;
|
||||
while (i < nofptrs) {*p = off + ptab[i]; p++; i++;}
|
||||
off += elemsz; n++;
|
||||
}
|
||||
*p = - (nptr + 1) * sizeof(LONGINT); /* sentinel */
|
||||
x[-1] -= nptr * sizeof(LONGINT);
|
||||
}
|
||||
if (nofdyn != 0) {
|
||||
/* setup len vector for index checks */
|
||||
va_start(ap, nofdyn);
|
||||
p = x;
|
||||
while (nofdyn > 0) {*p = va_arg(ap, LONGINT); p++, nofdyn--;}
|
||||
va_end(ap);
|
||||
}
|
||||
Heap_Unlock();
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
typedef void (*SystemSignalHandler)(INTEGER); // = Platform_SignalHandler
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
SystemSignalHandler handler[3] = {0};
|
||||
|
||||
// Provide signal handling for Unix based systems
|
||||
void signalHandler(int s) {
|
||||
if (s >= 2 && s <= 4) handler[s-2](s);
|
||||
// (Ignore other signals)
|
||||
}
|
||||
|
||||
void SystemSetHandler(int s, uintptr_t h) {
|
||||
if (s >= 2 && s <= 4) {
|
||||
int needtosetsystemhandler = handler[s-2] == 0;
|
||||
handler[s-2] = (SystemSignalHandler)h;
|
||||
if (needtosetsystemhandler) {signal(s, signalHandler);}
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// Provides Windows callback handlers for signal-like scenarios
|
||||
#include "WindowsWrapper.h"
|
||||
|
||||
SystemSignalHandler SystemInterruptHandler = 0;
|
||||
SystemSignalHandler SystemQuitHandler = 0;
|
||||
BOOL ConsoleCtrlHandlerSet = FALSE;
|
||||
|
||||
BOOL WINAPI SystemConsoleCtrlHandler(DWORD ctrlType) {
|
||||
if ((ctrlType == CTRL_C_EVENT) || (ctrlType == CTRL_BREAK_EVENT)) {
|
||||
if (SystemInterruptHandler) {
|
||||
SystemInterruptHandler(2); // SIGINT
|
||||
return TRUE;
|
||||
}
|
||||
} else { // Close, logoff or shutdown
|
||||
if (SystemQuitHandler) {
|
||||
SystemQuitHandler(3); // SIGQUIT
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void EnsureConsoleCtrlHandler() {
|
||||
if (!ConsoleCtrlHandlerSet) {
|
||||
SetConsoleCtrlHandler(SystemConsoleCtrlHandler, TRUE);
|
||||
ConsoleCtrlHandlerSet = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void SystemSetInterruptHandler(uintptr_t h) {
|
||||
EnsureConsoleCtrlHandler();
|
||||
SystemInterruptHandler = (SystemSignalHandler)h;
|
||||
}
|
||||
|
||||
void SystemSetQuitHandler(uintptr_t h) {
|
||||
EnsureConsoleCtrlHandler();
|
||||
SystemQuitHandler = (SystemSignalHandler)h;
|
||||
}
|
||||
|
||||
#endif
|
||||
275
bootstrap/unix-48/SYSTEM.h
Normal file
275
bootstrap/unix-48/SYSTEM.h
Normal file
|
|
@ -0,0 +1,275 @@
|
|||
#ifndef SYSTEM__h
|
||||
#define SYSTEM__h
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
// Building for a Unix/Linux based system
|
||||
#include <string.h> // For memcpy ...
|
||||
#include <stdint.h> // For uintptr_t ...
|
||||
|
||||
#else
|
||||
|
||||
// Building for Windows platform with either mingw under cygwin, or the MS C compiler
|
||||
#ifdef _WIN64
|
||||
typedef unsigned long long size_t;
|
||||
typedef unsigned long long uintptr_t;
|
||||
#else
|
||||
typedef unsigned int size_t;
|
||||
typedef unsigned int uintptr_t;
|
||||
#endif /* _WIN64 */
|
||||
|
||||
typedef unsigned int uint32_t;
|
||||
void * __cdecl memcpy(void * dest, const void * source, size_t size);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// The compiler uses 'import' and 'export' which translate to 'extern' and
|
||||
// nothing respectively.
|
||||
|
||||
#define import extern
|
||||
#define export
|
||||
|
||||
|
||||
|
||||
// Known constants
|
||||
|
||||
#define NIL ((void*)0)
|
||||
#define __MAXEXT 16
|
||||
#define POINTER__typ ((LONGINT*)(1)) // not NIL and not a valid type
|
||||
|
||||
|
||||
// Oberon types
|
||||
|
||||
#define BOOLEAN char
|
||||
#define SYSTEM_BYTE unsigned char
|
||||
#define CHAR unsigned char
|
||||
#define SHORTINT signed char
|
||||
#define REAL float
|
||||
#define LONGREAL double
|
||||
#define SYSTEM_PTR void*
|
||||
|
||||
// For 32 bit builds, the size of LONGINT depends on a make option:
|
||||
|
||||
#if (__SIZEOF_POINTER__ == 8) || defined(LARGE) || defined(_WIN64)
|
||||
#define INTEGER int // INTEGER is 32 bit.
|
||||
#define LONGINT long long // LONGINT is 64 bit. (long long is always 64 bits, while long can be 32 bits e.g. under MSC/MingW)
|
||||
#else
|
||||
#define INTEGER short int // INTEGER is 16 bit.
|
||||
#define LONGINT long // LONGINT is 32 bit.
|
||||
#endif
|
||||
|
||||
#define SET unsigned LONGINT
|
||||
|
||||
|
||||
// OS Memory allocation interfaces are in PlatformXXX.Mod
|
||||
|
||||
extern LONGINT Platform_OSAllocate (LONGINT size);
|
||||
extern void Platform_OSFree (LONGINT addr);
|
||||
|
||||
|
||||
// Run time system routines in SYSTEM.c
|
||||
|
||||
extern LONGINT SYSTEM_XCHK (LONGINT i, LONGINT ub);
|
||||
extern LONGINT SYSTEM_RCHK (LONGINT i, LONGINT ub);
|
||||
extern LONGINT SYSTEM_ASH (LONGINT i, LONGINT n);
|
||||
extern LONGINT SYSTEM_ABS (LONGINT i);
|
||||
extern double SYSTEM_ABSD (double i);
|
||||
extern void SYSTEM_INHERIT(LONGINT *t, LONGINT *t0);
|
||||
extern void SYSTEM_ENUMP (void *adr, LONGINT n, void (*P)());
|
||||
extern void SYSTEM_ENUMR (void *adr, LONGINT *typ, LONGINT size, LONGINT n, void (*P)());
|
||||
extern LONGINT SYSTEM_DIV (unsigned LONGINT x, unsigned LONGINT y);
|
||||
extern LONGINT SYSTEM_MOD (unsigned LONGINT x, unsigned LONGINT y);
|
||||
extern LONGINT SYSTEM_ENTIER (double x);
|
||||
|
||||
|
||||
// Signal handling in SYSTEM.c
|
||||
|
||||
#ifndef _WIN32
|
||||
extern void SystemSetHandler(int s, uintptr_t h);
|
||||
#else
|
||||
extern void SystemSetInterruptHandler(uintptr_t h);
|
||||
extern void SystemSetQuitHandler (uintptr_t h);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// String comparison
|
||||
|
||||
static int __str_cmp(CHAR *x, CHAR *y){
|
||||
LONGINT i = 0;
|
||||
CHAR ch1, ch2;
|
||||
do {ch1 = x[i]; ch2 = y[i]; i++;
|
||||
if (!ch1) return -(int)ch2;
|
||||
} while (ch1==ch2);
|
||||
return (int)ch1 - (int)ch2;
|
||||
}
|
||||
#define __STRCMP(a,b) __str_cmp((CHAR*)(a), (CHAR*)(b))
|
||||
|
||||
|
||||
|
||||
// Inline string, record and array copy
|
||||
|
||||
#define __COPY(s, d, n) {char*_a=(void*)s,*_b=(void*)d; LONGINT _i=0,_t=n-1; \
|
||||
while(_i<_t&&((_b[_i]=_a[_i])!=0)){_i++;};_b[_i]=0;}
|
||||
#define __DUP(x, l, t) x=(void*)memcpy((void*)(uintptr_t)Platform_OSAllocate(l*sizeof(t)),x,l*sizeof(t))
|
||||
#define __DUPARR(v, t) v=(void*)memcpy(v##__copy,v,sizeof(t))
|
||||
#define __DEL(x) Platform_OSFree((LONGINT)(uintptr_t)x)
|
||||
|
||||
|
||||
|
||||
|
||||
/* SYSTEM ops */
|
||||
|
||||
#define __VAL(t, x) ((t)(x))
|
||||
#define __VALP(t, x) ((t)(uintptr_t)(x))
|
||||
|
||||
#define __GET(a, x, t) x= *(t*)(uintptr_t)(a)
|
||||
#define __PUT(a, x, t) *(t*)(uintptr_t)(a)=x
|
||||
#define __LSHL(x, n, t) ((t)((unsigned t)(x)<<(n)))
|
||||
#define __LSHR(x, n, t) ((t)((unsigned t)(x)>>(n)))
|
||||
#define __LSH(x, n, t) ((n)>=0? __LSHL(x, n, t): __LSHR(x, -(n), t))
|
||||
#define __ROTL(x, n, t) ((t)((unsigned t)(x)<<(n)|(unsigned t)(x)>>(8*sizeof(t)-(n))))
|
||||
#define __ROTR(x, n, t) ((t)((unsigned t)(x)>>(n)|(unsigned t)(x)<<(8*sizeof(t)-(n))))
|
||||
#define __LSHR(x, n, t) ((t)((unsigned t)(x)>>(n)))
|
||||
#define __LSH(x, n, t) ((n)>=0? __LSHL(x, n, t): __LSHR(x, -(n), t))
|
||||
#define __ROTL(x, n, t) ((t)((unsigned t)(x)<<(n)|(unsigned t)(x)>>(8*sizeof(t)-(n))))
|
||||
#define __ROTR(x, n, t) ((t)((unsigned t)(x)>>(n)|(unsigned t)(x)<<(8*sizeof(t)-(n))))
|
||||
#define __ROT(x, n, t) ((n)>=0? __ROTL(x, n, t): __ROTR(x, -(n), t))
|
||||
#define __BIT(x, n) (*(unsigned LONGINT*)(x)>>(n)&1)
|
||||
#define __MOVE(s, d, n) memcpy((char*)(uintptr_t)(d),(char*)(uintptr_t)(s),n)
|
||||
#define __ASHL(x, n) ((LONGINT)(x)<<(n))
|
||||
#define __ASHR(x, n) ((LONGINT)(x)>>(n))
|
||||
#define __ASH(x, n) ((n)>=0?__ASHL(x,n):__ASHR(x,-(n)))
|
||||
#define __ASHF(x, n) SYSTEM_ASH((LONGINT)(x), (LONGINT)(n))
|
||||
#define __SHORT(x, y) ((int)((unsigned LONGINT)(x)+(y)<(y)+(y)?(x):(__HALT(-8),0)))
|
||||
#define __SHORTF(x, y) ((int)(__RF((x)+(y),(y)+(y))-(y)))
|
||||
#define __CHR(x) ((CHAR)__R(x, 256))
|
||||
#define __CHRF(x) ((CHAR)__RF(x, 256))
|
||||
#define __DIV(x, y) ((x)>=0?(x)/(y):-(((y)-1-(x))/(y)))
|
||||
#define __DIVF(x, y) SYSTEM_DIV((LONGINT)(x),(LONGINT)(y))
|
||||
#define __MOD(x, y) ((x)>=0?(x)%(y):__MODF(x,y))
|
||||
#define __MODF(x, y) SYSTEM_MOD((LONGINT)(x),(LONGINT)(y))
|
||||
#define __ENTIER(x) SYSTEM_ENTIER(x)
|
||||
#define __ABS(x) (((x)<0)?-(x):(x))
|
||||
#define __ABSF(x) SYSTEM_ABS((LONGINT)(x))
|
||||
#define __ABSFD(x) SYSTEM_ABSD((double)(x))
|
||||
#define __CAP(ch) ((CHAR)((ch)&0x5f))
|
||||
#define __ODD(x) ((x)&1)
|
||||
#define __IN(x, s) (((s)>>(x))&1)
|
||||
#define __SETOF(x) ((SET)1<<(x))
|
||||
#define __SETRNG(l, h) ((~(SET)0<<(l))&~(SET)0>>(8*sizeof(SET)-1-(h)))
|
||||
#define __MASK(x, m) ((x)&~(m))
|
||||
|
||||
|
||||
|
||||
// Runtime checks
|
||||
|
||||
#define __X(i, ub) (((unsigned LONGINT)(i)<(unsigned LONGINT)(ub))?i:(__HALT(-2),0))
|
||||
#define __XF(i, ub) SYSTEM_XCHK((LONGINT)(i), (LONGINT)(ub))
|
||||
#define __R(i, ub) (((unsigned LONGINT)(i)<(unsigned LONGINT)(ub))?i:(__HALT(-8),0))
|
||||
#define __RF(i, ub) SYSTEM_RCHK((LONGINT)(i),(LONGINT)(ub))
|
||||
#define __RETCHK __retchk: __HALT(-3); return 0;
|
||||
#define __CASECHK __HALT(-4)
|
||||
#define __WITHCHK __HALT(-7)
|
||||
|
||||
#define __GUARDP(p, typ, level) ((typ*)(__ISP(p,typ,level)?p:(__HALT(-5),p)))
|
||||
#define __GUARDR(r, typ, level) (*((typ*)(__IS(r##__typ,typ,level)?r:(__HALT(-5),r))))
|
||||
#define __GUARDA(p, typ, level) ((struct typ*)(__IS(__TYPEOF(p),typ,level)?p:(__HALT(-5),p)))
|
||||
#define __GUARDEQR(p, dyntyp, typ) if(dyntyp!=typ##__typ) __HALT(-6);*(p)
|
||||
#define __GUARDEQP(p, typ) if(__TYPEOF(p)!=typ##__typ)__HALT(-6);*(p)
|
||||
|
||||
|
||||
|
||||
// Module entry/registration/exit
|
||||
|
||||
extern void Heap_REGCMD();
|
||||
extern SYSTEM_PTR Heap_REGMOD();
|
||||
extern void Heap_REGTYP();
|
||||
extern void Heap_INCREF();
|
||||
|
||||
#define __DEFMOD static void *m; if (m!=0) {return m;}
|
||||
#define __REGCMD(name, cmd) Heap_REGCMD(m, (CHAR*)name, cmd)
|
||||
#define __REGMOD(name, enum) if (m==0) {m = Heap_REGMOD((CHAR*)name,enum);}
|
||||
#define __ENDMOD return m
|
||||
#define __MODULE_IMPORT(name) Heap_INCREF(name##__init())
|
||||
|
||||
|
||||
|
||||
// Main module initialisation, registration and finalisation
|
||||
|
||||
extern void Platform_Init(INTEGER argc, LONGINT argv);
|
||||
extern void *Platform_MainModule;
|
||||
extern void Heap_FINALL();
|
||||
|
||||
#define __INIT(argc, argv) static void *m; Platform_Init((INTEGER)argc, (LONGINT)(uintptr_t)&argv);
|
||||
#define __REGMAIN(name, enum) m = Heap_REGMOD((CHAR*)name,enum)
|
||||
#define __FINI Heap_FINALL(); return 0
|
||||
|
||||
|
||||
// Assertions and Halts
|
||||
|
||||
extern void Platform_Halt(LONGINT x);
|
||||
extern void Platform_AssertFail(LONGINT x);
|
||||
|
||||
#define __HALT(x) Platform_Halt(x)
|
||||
#define __ASSERT(cond, x) if (!(cond)) Platform_AssertFail((LONGINT)(x))
|
||||
|
||||
|
||||
// Memory allocation
|
||||
|
||||
extern SYSTEM_PTR Heap_NEWBLK (LONGINT size);
|
||||
extern SYSTEM_PTR Heap_NEWREC (LONGINT tag);
|
||||
extern SYSTEM_PTR SYSTEM_NEWARR(LONGINT*, LONGINT, int, int, int, ...);
|
||||
|
||||
#define __SYSNEW(p, len) p = Heap_NEWBLK((LONGINT)(len))
|
||||
#define __NEW(p, t) p = Heap_NEWREC((LONGINT)(uintptr_t)t##__typ)
|
||||
#define __NEWARR SYSTEM_NEWARR
|
||||
|
||||
|
||||
|
||||
/* Type handling */
|
||||
|
||||
#define __TDESC(t, m, n) \
|
||||
static struct t##__desc { \
|
||||
LONGINT tproc[m]; /* Proc for each ptr field */ \
|
||||
LONGINT tag; \
|
||||
LONGINT next; /* Module table type list points here */ \
|
||||
LONGINT level; \
|
||||
LONGINT module; \
|
||||
char name[24]; \
|
||||
LONGINT basep[__MAXEXT]; /* List of bases this extends */ \
|
||||
LONGINT reserved; \
|
||||
LONGINT blksz; /* xxx_typ points here */ \
|
||||
LONGINT ptr[n+1]; /* Offsets of ptrs up to -ve sentinel */ \
|
||||
} t##__desc
|
||||
|
||||
#define __BASEOFF (__MAXEXT+1) // blksz as index to base.
|
||||
#define __TPROC0OFF (__BASEOFF+24/sizeof(LONGINT)+5) // blksz as index to tproc IFF m=1.
|
||||
#define __EOM 1
|
||||
#define __TDFLDS(name, size) {__EOM}, 1, 0, 0, 0, name, {0}, 0, size
|
||||
#define __ENUMP(adr, n, P) SYSTEM_ENUMP(adr, (LONGINT)(n), P)
|
||||
#define __ENUMR(adr, typ, size, n, P) SYSTEM_ENUMR(adr, typ, (LONGINT)(size), (LONGINT)(n), P)
|
||||
|
||||
#define __INITYP(t, t0, level) \
|
||||
t##__typ = (LONGINT*)&t##__desc.blksz; \
|
||||
memcpy(t##__desc.basep, t0##__typ - __BASEOFF, level*sizeof(LONGINT)); \
|
||||
t##__desc.basep[level] = (LONGINT)(uintptr_t)t##__typ; \
|
||||
t##__desc.module = (LONGINT)(uintptr_t)m; \
|
||||
if(t##__desc.blksz!=sizeof(struct t)) __HALT(-15); \
|
||||
t##__desc.blksz = (t##__desc.blksz+5*sizeof(LONGINT)-1)/(4*sizeof(LONGINT))*(4*sizeof(LONGINT)); \
|
||||
Heap_REGTYP(m, (LONGINT)(uintptr_t)&t##__desc.next); \
|
||||
SYSTEM_INHERIT(t##__typ, t0##__typ)
|
||||
|
||||
#define __IS(tag, typ, level) (*(tag-(__BASEOFF-level))==(LONGINT)(uintptr_t)typ##__typ)
|
||||
#define __TYPEOF(p) ((LONGINT*)(uintptr_t)(*(((LONGINT*)(p))-1)))
|
||||
#define __ISP(p, typ, level) __IS(__TYPEOF(p),typ,level)
|
||||
|
||||
// Oberon-2 type bound procedures support
|
||||
#define __INITBP(t, proc, num) *(t##__typ-(__TPROC0OFF+num))=(LONGINT)(uintptr_t)proc
|
||||
#define __SEND(typ, num, funtyp, parlist) ((funtyp)((uintptr_t)*(typ-(__TPROC0OFF+num))))parlist
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
243
bootstrap/unix-48/Strings.c
Normal file
243
bootstrap/unix-48/Strings.c
Normal file
|
|
@ -0,0 +1,243 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
#include "SYSTEM.h"
|
||||
|
||||
|
||||
|
||||
|
||||
export void Strings_Append (CHAR *extra, LONGINT extra__len, CHAR *dest, LONGINT dest__len);
|
||||
export void Strings_Cap (CHAR *s, LONGINT s__len);
|
||||
export void Strings_Delete (CHAR *s, LONGINT s__len, INTEGER pos, INTEGER n);
|
||||
export void Strings_Extract (CHAR *source, LONGINT source__len, INTEGER pos, INTEGER n, CHAR *dest, LONGINT dest__len);
|
||||
export void Strings_Insert (CHAR *source, LONGINT source__len, INTEGER pos, CHAR *dest, LONGINT dest__len);
|
||||
export INTEGER Strings_Length (CHAR *s, LONGINT s__len);
|
||||
export BOOLEAN Strings_Match (CHAR *string, LONGINT string__len, CHAR *pattern, LONGINT pattern__len);
|
||||
export INTEGER Strings_Pos (CHAR *pattern, LONGINT pattern__len, CHAR *s, LONGINT s__len, INTEGER pos);
|
||||
export void Strings_Replace (CHAR *source, LONGINT source__len, INTEGER pos, CHAR *dest, LONGINT dest__len);
|
||||
|
||||
|
||||
INTEGER Strings_Length (CHAR *s, LONGINT s__len)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
INTEGER i;
|
||||
__DUP(s, s__len, CHAR);
|
||||
i = 0;
|
||||
while (((LONGINT)i < s__len && s[__X(i, s__len)] != 0x00)) {
|
||||
i += 1;
|
||||
}
|
||||
_o_result = i;
|
||||
__DEL(s);
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
void Strings_Append (CHAR *extra, LONGINT extra__len, CHAR *dest, LONGINT dest__len)
|
||||
{
|
||||
INTEGER n1, n2, i;
|
||||
__DUP(extra, extra__len, CHAR);
|
||||
n1 = Strings_Length(dest, dest__len);
|
||||
n2 = Strings_Length(extra, extra__len);
|
||||
i = 0;
|
||||
while ((i < n2 && (LONGINT)(i + n1) < dest__len)) {
|
||||
dest[__X(i + n1, dest__len)] = extra[__X(i, extra__len)];
|
||||
i += 1;
|
||||
}
|
||||
if ((LONGINT)(i + n1) < dest__len) {
|
||||
dest[__X(i + n1, dest__len)] = 0x00;
|
||||
}
|
||||
__DEL(extra);
|
||||
}
|
||||
|
||||
void Strings_Insert (CHAR *source, LONGINT source__len, INTEGER pos, CHAR *dest, LONGINT dest__len)
|
||||
{
|
||||
INTEGER n1, n2, i;
|
||||
__DUP(source, source__len, CHAR);
|
||||
n1 = Strings_Length(dest, dest__len);
|
||||
n2 = Strings_Length(source, source__len);
|
||||
if (pos < 0) {
|
||||
pos = 0;
|
||||
}
|
||||
if (pos > n1) {
|
||||
Strings_Append(dest, dest__len, (void*)source, source__len);
|
||||
return;
|
||||
}
|
||||
if ((LONGINT)(pos + n2) < dest__len) {
|
||||
i = n1;
|
||||
while (i >= pos) {
|
||||
if ((LONGINT)(i + n2) < dest__len) {
|
||||
dest[__X(i + n2, dest__len)] = dest[__X(i, dest__len)];
|
||||
}
|
||||
i -= 1;
|
||||
}
|
||||
}
|
||||
i = 0;
|
||||
while (i < n2) {
|
||||
dest[__X(pos + i, dest__len)] = source[__X(i, source__len)];
|
||||
i += 1;
|
||||
}
|
||||
__DEL(source);
|
||||
}
|
||||
|
||||
void Strings_Delete (CHAR *s, LONGINT s__len, INTEGER pos, INTEGER n)
|
||||
{
|
||||
INTEGER len, i;
|
||||
len = Strings_Length(s, s__len);
|
||||
if (pos < 0) {
|
||||
pos = 0;
|
||||
} else if (pos >= len) {
|
||||
return;
|
||||
}
|
||||
if (pos + n < len) {
|
||||
i = pos + n;
|
||||
while (i < len) {
|
||||
s[__X(i - n, s__len)] = s[__X(i, s__len)];
|
||||
i += 1;
|
||||
}
|
||||
if ((LONGINT)(i - n) < s__len) {
|
||||
s[__X(i - n, s__len)] = 0x00;
|
||||
}
|
||||
} else {
|
||||
s[__X(pos, s__len)] = 0x00;
|
||||
}
|
||||
}
|
||||
|
||||
void Strings_Replace (CHAR *source, LONGINT source__len, INTEGER pos, CHAR *dest, LONGINT dest__len)
|
||||
{
|
||||
__DUP(source, source__len, CHAR);
|
||||
Strings_Delete((void*)dest, dest__len, pos, pos + Strings_Length(source, source__len));
|
||||
Strings_Insert(source, source__len, pos, (void*)dest, dest__len);
|
||||
__DEL(source);
|
||||
}
|
||||
|
||||
void Strings_Extract (CHAR *source, LONGINT source__len, INTEGER pos, INTEGER n, CHAR *dest, LONGINT dest__len)
|
||||
{
|
||||
INTEGER len, destLen, i;
|
||||
__DUP(source, source__len, CHAR);
|
||||
len = Strings_Length(source, source__len);
|
||||
destLen = (int)dest__len - 1;
|
||||
if (pos < 0) {
|
||||
pos = 0;
|
||||
}
|
||||
if (pos >= len) {
|
||||
dest[0] = 0x00;
|
||||
return;
|
||||
}
|
||||
i = 0;
|
||||
while (((((LONGINT)(pos + i) <= source__len && source[__X(pos + i, source__len)] != 0x00)) && i < n)) {
|
||||
if (i < destLen) {
|
||||
dest[__X(i, dest__len)] = source[__X(pos + i, source__len)];
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
dest[__X(i, dest__len)] = 0x00;
|
||||
__DEL(source);
|
||||
}
|
||||
|
||||
INTEGER Strings_Pos (CHAR *pattern, LONGINT pattern__len, CHAR *s, LONGINT s__len, INTEGER pos)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
INTEGER n1, n2, i, j;
|
||||
__DUP(pattern, pattern__len, CHAR);
|
||||
__DUP(s, s__len, CHAR);
|
||||
n1 = Strings_Length(s, s__len);
|
||||
n2 = Strings_Length(pattern, pattern__len);
|
||||
if (n2 == 0) {
|
||||
_o_result = 0;
|
||||
__DEL(pattern);
|
||||
__DEL(s);
|
||||
return _o_result;
|
||||
}
|
||||
i = pos;
|
||||
while (i <= n1 - n2) {
|
||||
if (s[__X(i, s__len)] == pattern[0]) {
|
||||
j = 1;
|
||||
while ((j < n2 && s[__X(i + j, s__len)] == pattern[__X(j, pattern__len)])) {
|
||||
j += 1;
|
||||
}
|
||||
if (j == n2) {
|
||||
_o_result = i;
|
||||
__DEL(pattern);
|
||||
__DEL(s);
|
||||
return _o_result;
|
||||
}
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
_o_result = -1;
|
||||
__DEL(pattern);
|
||||
__DEL(s);
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
void Strings_Cap (CHAR *s, LONGINT s__len)
|
||||
{
|
||||
INTEGER i;
|
||||
i = 0;
|
||||
while (s[__X(i, s__len)] != 0x00) {
|
||||
if (('a' <= s[__X(i, s__len)] && s[__X(i, s__len)] <= 'z')) {
|
||||
s[__X(i, s__len)] = __CAP(s[__X(i, s__len)]);
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
static struct Match__7 {
|
||||
struct Match__7 *lnk;
|
||||
} *Match__7_s;
|
||||
|
||||
static BOOLEAN M__8 (CHAR *name, LONGINT name__len, CHAR *mask, LONGINT mask__len, INTEGER n, INTEGER m);
|
||||
|
||||
static BOOLEAN M__8 (CHAR *name, LONGINT name__len, CHAR *mask, LONGINT mask__len, INTEGER n, INTEGER m)
|
||||
{
|
||||
BOOLEAN _o_result;
|
||||
while ((((n >= 0 && m >= 0)) && mask[__X(m, mask__len)] != '*')) {
|
||||
if (name[__X(n, name__len)] != mask[__X(m, mask__len)]) {
|
||||
_o_result = 0;
|
||||
return _o_result;
|
||||
}
|
||||
n -= 1;
|
||||
m -= 1;
|
||||
}
|
||||
if (m < 0) {
|
||||
_o_result = n < 0;
|
||||
return _o_result;
|
||||
}
|
||||
while ((m >= 0 && mask[__X(m, mask__len)] == '*')) {
|
||||
m -= 1;
|
||||
}
|
||||
if (m < 0) {
|
||||
_o_result = 1;
|
||||
return _o_result;
|
||||
}
|
||||
while (n >= 0) {
|
||||
if (M__8(name, name__len, mask, mask__len, n, m)) {
|
||||
_o_result = 1;
|
||||
return _o_result;
|
||||
}
|
||||
n -= 1;
|
||||
}
|
||||
_o_result = 0;
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
BOOLEAN Strings_Match (CHAR *string, LONGINT string__len, CHAR *pattern, LONGINT pattern__len)
|
||||
{
|
||||
BOOLEAN _o_result;
|
||||
struct Match__7 _s;
|
||||
__DUP(string, string__len, CHAR);
|
||||
__DUP(pattern, pattern__len, CHAR);
|
||||
_s.lnk = Match__7_s;
|
||||
Match__7_s = &_s;
|
||||
_o_result = M__8((void*)string, string__len, (void*)pattern, pattern__len, Strings_Length(string, string__len) - 1, Strings_Length(pattern, pattern__len) - 1);
|
||||
Match__7_s = _s.lnk;
|
||||
__DEL(string);
|
||||
__DEL(pattern);
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
|
||||
export void *Strings__init(void)
|
||||
{
|
||||
__DEFMOD;
|
||||
__REGMOD("Strings", 0);
|
||||
/* BEGIN */
|
||||
__ENDMOD;
|
||||
}
|
||||
23
bootstrap/unix-48/Strings.h
Normal file
23
bootstrap/unix-48/Strings.h
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#ifndef Strings__h
|
||||
#define Strings__h
|
||||
|
||||
#include "SYSTEM.h"
|
||||
|
||||
|
||||
|
||||
|
||||
import void Strings_Append (CHAR *extra, LONGINT extra__len, CHAR *dest, LONGINT dest__len);
|
||||
import void Strings_Cap (CHAR *s, LONGINT s__len);
|
||||
import void Strings_Delete (CHAR *s, LONGINT s__len, INTEGER pos, INTEGER n);
|
||||
import void Strings_Extract (CHAR *source, LONGINT source__len, INTEGER pos, INTEGER n, CHAR *dest, LONGINT dest__len);
|
||||
import void Strings_Insert (CHAR *source, LONGINT source__len, INTEGER pos, CHAR *dest, LONGINT dest__len);
|
||||
import INTEGER Strings_Length (CHAR *s, LONGINT s__len);
|
||||
import BOOLEAN Strings_Match (CHAR *string, LONGINT string__len, CHAR *pattern, LONGINT pattern__len);
|
||||
import INTEGER Strings_Pos (CHAR *pattern, LONGINT pattern__len, CHAR *s, LONGINT s__len, INTEGER pos);
|
||||
import void Strings_Replace (CHAR *source, LONGINT source__len, INTEGER pos, CHAR *dest, LONGINT dest__len);
|
||||
import void *Strings__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
1838
bootstrap/unix-48/Texts.c
Normal file
1838
bootstrap/unix-48/Texts.c
Normal file
File diff suppressed because it is too large
Load diff
173
bootstrap/unix-48/Texts.h
Normal file
173
bootstrap/unix-48/Texts.h
Normal file
|
|
@ -0,0 +1,173 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#ifndef Texts__h
|
||||
#define Texts__h
|
||||
|
||||
#include "SYSTEM.h"
|
||||
#include "Files.h"
|
||||
|
||||
typedef
|
||||
struct Texts_BufDesc {
|
||||
LONGINT len;
|
||||
char _prvt0[4];
|
||||
} Texts_BufDesc;
|
||||
|
||||
typedef
|
||||
Texts_BufDesc *Texts_Buffer;
|
||||
|
||||
typedef
|
||||
struct Texts_ElemMsg {
|
||||
char _prvt0[1];
|
||||
} Texts_ElemMsg;
|
||||
|
||||
typedef
|
||||
struct Texts_ElemDesc *Texts_Elem;
|
||||
|
||||
typedef
|
||||
struct Texts_CopyMsg { /* Texts_ElemMsg */
|
||||
Texts_Elem e;
|
||||
} Texts_CopyMsg;
|
||||
|
||||
typedef
|
||||
struct Texts_RunDesc {
|
||||
LONGINT _prvt0;
|
||||
char _prvt1[15];
|
||||
} Texts_RunDesc;
|
||||
|
||||
typedef
|
||||
void (*Texts_Handler)(Texts_Elem, Texts_ElemMsg*, LONGINT *);
|
||||
|
||||
typedef
|
||||
struct Texts_ElemDesc {
|
||||
char _prvt0[20];
|
||||
LONGINT W, H;
|
||||
Texts_Handler handle;
|
||||
char _prvt1[4];
|
||||
} Texts_ElemDesc;
|
||||
|
||||
typedef
|
||||
struct Texts_FileMsg { /* Texts_ElemMsg */
|
||||
INTEGER id;
|
||||
LONGINT pos;
|
||||
Files_Rider r;
|
||||
} Texts_FileMsg;
|
||||
|
||||
typedef
|
||||
struct Texts_FontDesc {
|
||||
char _prvt0[32];
|
||||
} Texts_FontDesc;
|
||||
|
||||
typedef
|
||||
Texts_FontDesc *Texts_FontsFont;
|
||||
|
||||
typedef
|
||||
struct Texts_IdentifyMsg { /* Texts_ElemMsg */
|
||||
CHAR mod[32], proc[32];
|
||||
} Texts_IdentifyMsg;
|
||||
|
||||
typedef
|
||||
struct Texts_TextDesc *Texts_Text;
|
||||
|
||||
typedef
|
||||
void (*Texts_Notifier)(Texts_Text, INTEGER, LONGINT, LONGINT);
|
||||
|
||||
typedef
|
||||
struct Texts_Reader {
|
||||
BOOLEAN eot;
|
||||
Texts_FontsFont fnt;
|
||||
SHORTINT col, voff;
|
||||
Texts_Elem elem;
|
||||
char _prvt0[32];
|
||||
} Texts_Reader;
|
||||
|
||||
typedef
|
||||
struct Texts_Scanner { /* Texts_Reader */
|
||||
BOOLEAN eot;
|
||||
Texts_FontsFont fnt;
|
||||
SHORTINT col, voff;
|
||||
Texts_Elem elem;
|
||||
LONGREAL _prvt0;
|
||||
char _prvt1[24];
|
||||
CHAR nextCh;
|
||||
INTEGER line, class;
|
||||
LONGINT i;
|
||||
REAL x;
|
||||
LONGREAL y;
|
||||
CHAR c;
|
||||
SHORTINT len;
|
||||
CHAR s[64];
|
||||
} Texts_Scanner;
|
||||
|
||||
typedef
|
||||
struct Texts_TextDesc {
|
||||
LONGINT len;
|
||||
Texts_Notifier notify;
|
||||
char _prvt0[12];
|
||||
} Texts_TextDesc;
|
||||
|
||||
typedef
|
||||
struct Texts_Writer {
|
||||
Texts_Buffer buf;
|
||||
Texts_FontsFont fnt;
|
||||
SHORTINT col, voff;
|
||||
char _prvt0[26];
|
||||
} Texts_Writer;
|
||||
|
||||
|
||||
import Texts_Elem Texts_new;
|
||||
|
||||
import LONGINT *Texts_FontDesc__typ;
|
||||
import LONGINT *Texts_RunDesc__typ;
|
||||
import LONGINT *Texts_ElemMsg__typ;
|
||||
import LONGINT *Texts_ElemDesc__typ;
|
||||
import LONGINT *Texts_FileMsg__typ;
|
||||
import LONGINT *Texts_CopyMsg__typ;
|
||||
import LONGINT *Texts_IdentifyMsg__typ;
|
||||
import LONGINT *Texts_BufDesc__typ;
|
||||
import LONGINT *Texts_TextDesc__typ;
|
||||
import LONGINT *Texts_Reader__typ;
|
||||
import LONGINT *Texts_Scanner__typ;
|
||||
import LONGINT *Texts_Writer__typ;
|
||||
|
||||
import void Texts_Append (Texts_Text T, Texts_Buffer B);
|
||||
import void Texts_ChangeLooks (Texts_Text T, LONGINT beg, LONGINT end, SET sel, Texts_FontsFont fnt, SHORTINT col, SHORTINT voff);
|
||||
import void Texts_Close (Texts_Text T, CHAR *name, LONGINT name__len);
|
||||
import void Texts_Copy (Texts_Buffer SB, Texts_Buffer DB);
|
||||
import void Texts_CopyElem (Texts_Elem SE, Texts_Elem DE);
|
||||
import void Texts_Delete (Texts_Text T, LONGINT beg, LONGINT end);
|
||||
import Texts_Text Texts_ElemBase (Texts_Elem E);
|
||||
import LONGINT Texts_ElemPos (Texts_Elem E);
|
||||
import void Texts_Insert (Texts_Text T, LONGINT pos, Texts_Buffer B);
|
||||
import void Texts_Load (Files_Rider *r, LONGINT *r__typ, Texts_Text T);
|
||||
import void Texts_Open (Texts_Text T, CHAR *name, LONGINT name__len);
|
||||
import void Texts_OpenBuf (Texts_Buffer B);
|
||||
import void Texts_OpenReader (Texts_Reader *R, LONGINT *R__typ, Texts_Text T, LONGINT pos);
|
||||
import void Texts_OpenScanner (Texts_Scanner *S, LONGINT *S__typ, Texts_Text T, LONGINT pos);
|
||||
import void Texts_OpenWriter (Texts_Writer *W, LONGINT *W__typ);
|
||||
import LONGINT Texts_Pos (Texts_Reader *R, LONGINT *R__typ);
|
||||
import void Texts_Read (Texts_Reader *R, LONGINT *R__typ, CHAR *ch);
|
||||
import void Texts_ReadElem (Texts_Reader *R, LONGINT *R__typ);
|
||||
import void Texts_ReadPrevElem (Texts_Reader *R, LONGINT *R__typ);
|
||||
import void Texts_Recall (Texts_Buffer *B);
|
||||
import void Texts_Save (Texts_Text T, LONGINT beg, LONGINT end, Texts_Buffer B);
|
||||
import void Texts_Scan (Texts_Scanner *S, LONGINT *S__typ);
|
||||
import void Texts_SetColor (Texts_Writer *W, LONGINT *W__typ, SHORTINT col);
|
||||
import void Texts_SetFont (Texts_Writer *W, LONGINT *W__typ, Texts_FontsFont fnt);
|
||||
import void Texts_SetOffset (Texts_Writer *W, LONGINT *W__typ, SHORTINT voff);
|
||||
import void Texts_Store (Files_Rider *r, LONGINT *r__typ, Texts_Text T);
|
||||
import void Texts_Write (Texts_Writer *W, LONGINT *W__typ, CHAR ch);
|
||||
import void Texts_WriteDate (Texts_Writer *W, LONGINT *W__typ, LONGINT t, LONGINT d);
|
||||
import void Texts_WriteElem (Texts_Writer *W, LONGINT *W__typ, Texts_Elem e);
|
||||
import void Texts_WriteHex (Texts_Writer *W, LONGINT *W__typ, LONGINT x);
|
||||
import void Texts_WriteInt (Texts_Writer *W, LONGINT *W__typ, LONGINT x, LONGINT n);
|
||||
import void Texts_WriteLn (Texts_Writer *W, LONGINT *W__typ);
|
||||
import void Texts_WriteLongReal (Texts_Writer *W, LONGINT *W__typ, LONGREAL x, INTEGER n);
|
||||
import void Texts_WriteLongRealHex (Texts_Writer *W, LONGINT *W__typ, LONGREAL x);
|
||||
import void Texts_WriteReal (Texts_Writer *W, LONGINT *W__typ, REAL x, INTEGER n);
|
||||
import void Texts_WriteRealFix (Texts_Writer *W, LONGINT *W__typ, REAL x, INTEGER n, INTEGER k);
|
||||
import void Texts_WriteRealHex (Texts_Writer *W, LONGINT *W__typ, REAL x);
|
||||
import void Texts_WriteString (Texts_Writer *W, LONGINT *W__typ, CHAR *s, LONGINT s__len);
|
||||
import void *Texts__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
168
bootstrap/unix-48/Vishap.c
Normal file
168
bootstrap/unix-48/Vishap.c
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkamSf */
|
||||
#include "SYSTEM.h"
|
||||
#include "Configuration.h"
|
||||
#include "Heap.h"
|
||||
#include "OPB.h"
|
||||
#include "OPC.h"
|
||||
#include "OPM.h"
|
||||
#include "OPP.h"
|
||||
#include "OPT.h"
|
||||
#include "OPV.h"
|
||||
#include "Platform.h"
|
||||
#include "Strings.h"
|
||||
#include "extTools.h"
|
||||
#include "vt100.h"
|
||||
|
||||
|
||||
static CHAR Vishap_mname[256];
|
||||
|
||||
|
||||
export void Vishap_Module (BOOLEAN *done);
|
||||
static void Vishap_PropagateElementaryTypeSizes (void);
|
||||
export void Vishap_Translate (void);
|
||||
static void Vishap_Trap (INTEGER sig);
|
||||
|
||||
|
||||
void Vishap_Module (BOOLEAN *done)
|
||||
{
|
||||
BOOLEAN ext, new;
|
||||
OPT_Node p = NIL;
|
||||
OPP_Module(&p, OPM_opt);
|
||||
if (OPM_noerr) {
|
||||
OPV_Init();
|
||||
OPV_AdrAndSize(OPT_topScope);
|
||||
OPT_Export(&ext, &new);
|
||||
if (OPM_noerr) {
|
||||
OPM_OpenFiles((void*)OPT_SelfName, ((LONGINT)(256)));
|
||||
OPC_Init();
|
||||
OPV_Module(p);
|
||||
if (OPM_noerr) {
|
||||
if (((OPM_mainProg || OPM_mainLinkStat) && __STRCMP(OPM_modName, "SYSTEM") != 0)) {
|
||||
OPM_DeleteNewSym();
|
||||
if (!OPM_notColorOutput) {
|
||||
vt100_SetAttr((CHAR*)"32m", (LONGINT)4);
|
||||
}
|
||||
OPM_LogWStr((CHAR*)" Main program.", (LONGINT)16);
|
||||
if (!OPM_notColorOutput) {
|
||||
vt100_SetAttr((CHAR*)"0m", (LONGINT)3);
|
||||
}
|
||||
} else {
|
||||
if (new) {
|
||||
if (!OPM_notColorOutput) {
|
||||
vt100_SetAttr((CHAR*)"32m", (LONGINT)4);
|
||||
}
|
||||
OPM_LogWStr((CHAR*)" New symbol file.", (LONGINT)19);
|
||||
if (!OPM_notColorOutput) {
|
||||
vt100_SetAttr((CHAR*)"0m", (LONGINT)3);
|
||||
}
|
||||
OPM_RegisterNewSym();
|
||||
} else if (ext) {
|
||||
OPM_LogWStr((CHAR*)" Extended symbol file.", (LONGINT)24);
|
||||
OPM_RegisterNewSym();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
OPM_DeleteNewSym();
|
||||
}
|
||||
}
|
||||
}
|
||||
OPM_CloseFiles();
|
||||
OPT_Close();
|
||||
OPM_LogWLn();
|
||||
*done = OPM_noerr;
|
||||
}
|
||||
|
||||
static void Vishap_PropagateElementaryTypeSizes (void)
|
||||
{
|
||||
OPT_bytetyp->size = OPM_ByteSize;
|
||||
OPT_sysptrtyp->size = OPM_PointerSize;
|
||||
OPT_chartyp->size = OPM_CharSize;
|
||||
OPT_settyp->size = OPM_SetSize;
|
||||
OPT_realtyp->size = OPM_RealSize;
|
||||
OPT_inttyp->size = OPM_IntSize;
|
||||
OPT_linttyp->size = OPM_LIntSize;
|
||||
OPT_lrltyp->size = OPM_LRealSize;
|
||||
OPT_sinttyp->size = OPM_SIntSize;
|
||||
OPT_booltyp->size = OPM_BoolSize;
|
||||
}
|
||||
|
||||
void Vishap_Translate (void)
|
||||
{
|
||||
BOOLEAN done;
|
||||
CHAR modulesobj[2048];
|
||||
modulesobj[0] = 0x00;
|
||||
if (OPM_OpenPar()) {
|
||||
for (;;) {
|
||||
OPM_Init(&done, (void*)Vishap_mname, ((LONGINT)(256)));
|
||||
if (!done) {
|
||||
return;
|
||||
}
|
||||
OPM_InitOptions();
|
||||
Vishap_PropagateElementaryTypeSizes();
|
||||
Heap_GC(0);
|
||||
Vishap_Module(&done);
|
||||
if (!done) {
|
||||
OPM_LogWLn();
|
||||
OPM_LogWStr((CHAR*)"Module compilation failed.", (LONGINT)27);
|
||||
OPM_LogWLn();
|
||||
Platform_Exit(1);
|
||||
}
|
||||
if (!OPM_dontAsm) {
|
||||
if (OPM_dontLink) {
|
||||
extTools_Assemble(OPM_modName, ((LONGINT)(32)));
|
||||
} else {
|
||||
if (!(OPM_mainProg || OPM_mainLinkStat)) {
|
||||
extTools_Assemble(OPM_modName, ((LONGINT)(32)));
|
||||
Strings_Append((CHAR*)" ", (LONGINT)2, (void*)modulesobj, ((LONGINT)(2048)));
|
||||
Strings_Append(OPM_modName, ((LONGINT)(32)), (void*)modulesobj, ((LONGINT)(2048)));
|
||||
Strings_Append((CHAR*)".o", (LONGINT)3, (void*)modulesobj, ((LONGINT)(2048)));
|
||||
} else {
|
||||
extTools_LinkMain((void*)OPM_modName, ((LONGINT)(32)), OPM_mainLinkStat, modulesobj, ((LONGINT)(2048)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void Vishap_Trap (INTEGER sig)
|
||||
{
|
||||
Heap_FINALL();
|
||||
if (sig == 3) {
|
||||
Platform_Exit(0);
|
||||
} else {
|
||||
if ((sig == 4 && Platform_HaltCode == -15)) {
|
||||
OPM_LogWStr((CHAR*)" --- Vishap Oberon: internal error", (LONGINT)35);
|
||||
OPM_LogWLn();
|
||||
}
|
||||
Platform_Exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export int main(int argc, char **argv)
|
||||
{
|
||||
__INIT(argc, argv);
|
||||
__MODULE_IMPORT(Configuration);
|
||||
__MODULE_IMPORT(Heap);
|
||||
__MODULE_IMPORT(OPB);
|
||||
__MODULE_IMPORT(OPC);
|
||||
__MODULE_IMPORT(OPM);
|
||||
__MODULE_IMPORT(OPP);
|
||||
__MODULE_IMPORT(OPT);
|
||||
__MODULE_IMPORT(OPV);
|
||||
__MODULE_IMPORT(Platform);
|
||||
__MODULE_IMPORT(Strings);
|
||||
__MODULE_IMPORT(extTools);
|
||||
__MODULE_IMPORT(vt100);
|
||||
__REGMAIN("Vishap", 0);
|
||||
__REGCMD("Translate", Vishap_Translate);
|
||||
/* BEGIN */
|
||||
Platform_SetInterruptHandler(Vishap_Trap);
|
||||
Platform_SetQuitHandler(Vishap_Trap);
|
||||
Platform_SetBadInstructionHandler(Vishap_Trap);
|
||||
OPB_typSize = OPV_TypSize;
|
||||
OPT_typSize = OPV_TypSize;
|
||||
Vishap_Translate();
|
||||
__FINI;
|
||||
}
|
||||
9
bootstrap/unix-48/WindowsWrapper.h
Normal file
9
bootstrap/unix-48/WindowsWrapper.h
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// WindowsWrapper.h
|
||||
//
|
||||
// Includes Windows.h while avoiding conflicts with Oberon types.
|
||||
|
||||
#undef BOOLEAN
|
||||
#undef CHAR
|
||||
#include <windows.h>
|
||||
#define BOOLEAN char
|
||||
#define CHAR unsigned char
|
||||
198
bootstrap/unix-48/errors.c
Normal file
198
bootstrap/unix-48/errors.c
Normal file
|
|
@ -0,0 +1,198 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
#include "SYSTEM.h"
|
||||
|
||||
typedef
|
||||
CHAR errors_string[128];
|
||||
|
||||
|
||||
export errors_string errors_errors[350];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export void *errors__init(void)
|
||||
{
|
||||
__DEFMOD;
|
||||
__REGMOD("errors", 0);
|
||||
/* BEGIN */
|
||||
__MOVE("undeclared identifier", errors_errors[0], 22);
|
||||
__MOVE("multiply defined identifier", errors_errors[1], 28);
|
||||
__MOVE("illegal character in number", errors_errors[2], 28);
|
||||
__MOVE("illegal character in string", errors_errors[3], 28);
|
||||
__MOVE("identifier does not match procedure name", errors_errors[4], 41);
|
||||
__MOVE("comment not closed", errors_errors[5], 19);
|
||||
errors_errors[6][0] = 0x00;
|
||||
errors_errors[7][0] = 0x00;
|
||||
errors_errors[8][0] = 0x00;
|
||||
__MOVE("\'=\' expected", errors_errors[9], 13);
|
||||
errors_errors[10][0] = 0x00;
|
||||
errors_errors[11][0] = 0x00;
|
||||
__MOVE("type definition starts with incorrect symbol", errors_errors[12], 45);
|
||||
__MOVE("factor starts with incorrect symbol", errors_errors[13], 36);
|
||||
__MOVE("statement starts with incorrect symbol", errors_errors[14], 39);
|
||||
__MOVE("declaration followed by incorrect symbol", errors_errors[15], 41);
|
||||
__MOVE("MODULE expected", errors_errors[16], 16);
|
||||
errors_errors[17][0] = 0x00;
|
||||
__MOVE("\'.\' missing", errors_errors[18], 12);
|
||||
__MOVE("\',\' missing", errors_errors[19], 12);
|
||||
__MOVE("\':\' missing", errors_errors[20], 12);
|
||||
errors_errors[21][0] = 0x00;
|
||||
__MOVE("\')\' missing", errors_errors[22], 12);
|
||||
__MOVE("\']\' missing", errors_errors[23], 12);
|
||||
__MOVE("\'}\' missing", errors_errors[24], 12);
|
||||
__MOVE("OF missing", errors_errors[25], 11);
|
||||
__MOVE("THEN missing", errors_errors[26], 13);
|
||||
__MOVE("DO missing", errors_errors[27], 11);
|
||||
__MOVE("TO missing", errors_errors[28], 11);
|
||||
errors_errors[29][0] = 0x00;
|
||||
__MOVE("\'(\' missing", errors_errors[30], 12);
|
||||
errors_errors[31][0] = 0x00;
|
||||
errors_errors[32][0] = 0x00;
|
||||
errors_errors[33][0] = 0x00;
|
||||
__MOVE("\':=\' missing", errors_errors[34], 13);
|
||||
__MOVE("\',\' or OF expected", errors_errors[35], 19);
|
||||
errors_errors[36][0] = 0x00;
|
||||
errors_errors[37][0] = 0x00;
|
||||
__MOVE("identifier expected", errors_errors[38], 20);
|
||||
__MOVE("\';\' missing", errors_errors[39], 12);
|
||||
errors_errors[40][0] = 0x00;
|
||||
__MOVE("END missing", errors_errors[41], 12);
|
||||
errors_errors[42][0] = 0x00;
|
||||
errors_errors[43][0] = 0x00;
|
||||
__MOVE("UNTIL missing", errors_errors[44], 14);
|
||||
errors_errors[45][0] = 0x00;
|
||||
__MOVE("EXIT not within loop statement", errors_errors[46], 31);
|
||||
__MOVE("illegally marked identifier", errors_errors[47], 28);
|
||||
errors_errors[48][0] = 0x00;
|
||||
errors_errors[49][0] = 0x00;
|
||||
__MOVE("expression should be constant", errors_errors[50], 30);
|
||||
__MOVE("constant not an integer", errors_errors[51], 24);
|
||||
__MOVE("identifier does not denote a type", errors_errors[52], 34);
|
||||
__MOVE("identifier does not denote a record type", errors_errors[53], 41);
|
||||
__MOVE("result type of procedure is not a basic type", errors_errors[54], 45);
|
||||
__MOVE("procedure call of a function", errors_errors[55], 29);
|
||||
__MOVE("assignment to non-variable", errors_errors[56], 27);
|
||||
__MOVE("pointer not bound to record or array type", errors_errors[57], 42);
|
||||
__MOVE("recursive type definition", errors_errors[58], 26);
|
||||
__MOVE("illegal open array parameter", errors_errors[59], 29);
|
||||
__MOVE("wrong type of case label", errors_errors[60], 25);
|
||||
__MOVE("inadmissible type of case label", errors_errors[61], 32);
|
||||
__MOVE("case label defined more than once", errors_errors[62], 34);
|
||||
__MOVE("illegal value of constant", errors_errors[63], 26);
|
||||
__MOVE("more actual than formal parameters", errors_errors[64], 35);
|
||||
__MOVE("fewer actual than formal parameters", errors_errors[65], 36);
|
||||
__MOVE("element types of actual array and formal open array differ", errors_errors[66], 59);
|
||||
__MOVE("actual parameter corresponding to open array is not an array", errors_errors[67], 61);
|
||||
__MOVE("control variable must be integer", errors_errors[68], 33);
|
||||
__MOVE("parameter must be an integer constant", errors_errors[69], 38);
|
||||
__MOVE("pointer or VAR record required as formal receiver", errors_errors[70], 50);
|
||||
__MOVE("pointer expected as actual receiver", errors_errors[71], 36);
|
||||
__MOVE("procedure must be bound to a record of the same scope", errors_errors[72], 54);
|
||||
__MOVE("procedure must have level 0", errors_errors[73], 28);
|
||||
__MOVE("procedure unknown in base type", errors_errors[74], 31);
|
||||
__MOVE("invalid call of base procedure", errors_errors[75], 31);
|
||||
__MOVE("this variable (field) is read only", errors_errors[76], 35);
|
||||
__MOVE("object is not a record", errors_errors[77], 23);
|
||||
__MOVE("dereferenced object is not a variable", errors_errors[78], 38);
|
||||
__MOVE("indexed object is not a variable", errors_errors[79], 33);
|
||||
__MOVE("index expression is not an integer", errors_errors[80], 35);
|
||||
__MOVE("index out of specified bounds", errors_errors[81], 30);
|
||||
__MOVE("indexed variable is not an array", errors_errors[82], 33);
|
||||
__MOVE("undefined record field", errors_errors[83], 23);
|
||||
__MOVE("dereferenced variable is not a pointer", errors_errors[84], 39);
|
||||
__MOVE("guard or test type is not an extension of variable type", errors_errors[85], 56);
|
||||
__MOVE("guard or testtype is not a pointer", errors_errors[86], 35);
|
||||
__MOVE("guarded or tested variable is neither a pointer nor a VAR-parameter record", errors_errors[87], 75);
|
||||
__MOVE("open array not allowed as variable, record field or array element", errors_errors[88], 66);
|
||||
errors_errors[89][0] = 0x00;
|
||||
errors_errors[90][0] = 0x00;
|
||||
errors_errors[91][0] = 0x00;
|
||||
__MOVE("operand of IN not an integer, or not a set", errors_errors[92], 43);
|
||||
__MOVE("set element type is not an integer", errors_errors[93], 35);
|
||||
__MOVE("operand of & is not of type BOOLEAN", errors_errors[94], 36);
|
||||
__MOVE("operand of OR is not of type BOOLEAN", errors_errors[95], 37);
|
||||
__MOVE("operand not applicable to (unary) +", errors_errors[96], 36);
|
||||
__MOVE("operand not applicable to (unary) -", errors_errors[97], 36);
|
||||
__MOVE("operand of ~ is not of type BOOLEAN", errors_errors[98], 36);
|
||||
__MOVE("ASSERT fault", errors_errors[99], 13);
|
||||
__MOVE("incompatible operands of dyadic operator", errors_errors[100], 41);
|
||||
__MOVE("operand type inapplicable to *", errors_errors[101], 31);
|
||||
__MOVE("operand type inapplicable to /", errors_errors[102], 31);
|
||||
__MOVE("operand type inapplicable to DIV", errors_errors[103], 33);
|
||||
__MOVE("operand type inapplicable to MOD", errors_errors[104], 33);
|
||||
__MOVE("operand type inapplicable to +", errors_errors[105], 31);
|
||||
__MOVE("operand type inapplicable to -", errors_errors[106], 31);
|
||||
__MOVE("operand type inapplicable to = or #", errors_errors[107], 36);
|
||||
__MOVE("operand type inapplicable to relation", errors_errors[108], 38);
|
||||
__MOVE("overriding method must be exported", errors_errors[109], 35);
|
||||
__MOVE("operand is not a type", errors_errors[110], 22);
|
||||
__MOVE("operand inapplicable to (this) function", errors_errors[111], 40);
|
||||
__MOVE("operand is not a variable", errors_errors[112], 26);
|
||||
__MOVE("incompatible assignment", errors_errors[113], 24);
|
||||
__MOVE("string too long to be assigned", errors_errors[114], 31);
|
||||
__MOVE("parameter doesn\'t match", errors_errors[115], 24);
|
||||
__MOVE("number of parameters doesn\'t match", errors_errors[116], 35);
|
||||
__MOVE("result type doesn\'t match", errors_errors[117], 26);
|
||||
__MOVE("export mark doesn\'t match with forward declaration", errors_errors[118], 51);
|
||||
__MOVE("redefinition textually precedes procedure bound to base type", errors_errors[119], 61);
|
||||
__MOVE("type of expression following IF, WHILE, UNTIL or ASSERT is not BOOLEAN", errors_errors[120], 71);
|
||||
__MOVE("called object is not a procedure (or is an interrupt procedure)", errors_errors[121], 64);
|
||||
__MOVE("actual VAR-parameter is not a variable", errors_errors[122], 39);
|
||||
__MOVE("type of actual parameter is not identical with that of formal VAR-parameter", errors_errors[123], 76);
|
||||
__MOVE("type of result expression differs from that of procedure", errors_errors[124], 57);
|
||||
__MOVE("type of case expression is neither INTEGER nor CHAR", errors_errors[125], 52);
|
||||
__MOVE("this expression cannot be a type or a procedure", errors_errors[126], 48);
|
||||
__MOVE("illegal use of object", errors_errors[127], 22);
|
||||
__MOVE("unsatisfied forward reference", errors_errors[128], 30);
|
||||
__MOVE("unsatisfied forward procedure", errors_errors[129], 30);
|
||||
__MOVE("WITH clause does not specify a variable", errors_errors[130], 40);
|
||||
__MOVE("LEN not applied to array", errors_errors[131], 25);
|
||||
__MOVE("dimension in LEN too large or negative", errors_errors[132], 39);
|
||||
__MOVE("SYSTEM not imported", errors_errors[135], 20);
|
||||
__MOVE("key inconsistency of imported module", errors_errors[150], 37);
|
||||
__MOVE("incorrect symbol file", errors_errors[151], 22);
|
||||
__MOVE("symbol file of imported module not found", errors_errors[152], 41);
|
||||
__MOVE("object or symbol file not opened (disk full\?)", errors_errors[153], 46);
|
||||
__MOVE("recursive import not allowed", errors_errors[154], 29);
|
||||
__MOVE("generation of new symbol file not allowed", errors_errors[155], 42);
|
||||
__MOVE("parameter file not found", errors_errors[156], 25);
|
||||
__MOVE("syntax error in parameter file", errors_errors[157], 31);
|
||||
__MOVE("not yet implemented", errors_errors[200], 20);
|
||||
__MOVE("lower bound of set range greater than higher bound", errors_errors[201], 51);
|
||||
__MOVE("set element greater than MAX(SET) or less than 0", errors_errors[202], 49);
|
||||
__MOVE("number too large", errors_errors[203], 17);
|
||||
__MOVE("product too large", errors_errors[204], 18);
|
||||
__MOVE("division by zero", errors_errors[205], 17);
|
||||
__MOVE("sum too large", errors_errors[206], 14);
|
||||
__MOVE("difference too large", errors_errors[207], 21);
|
||||
__MOVE("overflow in arithmetic shift", errors_errors[208], 29);
|
||||
__MOVE("case range too large", errors_errors[209], 21);
|
||||
__MOVE("too many cases in case statement", errors_errors[213], 33);
|
||||
__MOVE("illegal value of parameter (0 <= p < 256)", errors_errors[218], 42);
|
||||
__MOVE("machine registers cannot be accessed", errors_errors[219], 37);
|
||||
__MOVE("illegal value of parameter", errors_errors[220], 27);
|
||||
__MOVE("too many pointers in a record", errors_errors[221], 30);
|
||||
__MOVE("too many global pointers", errors_errors[222], 25);
|
||||
__MOVE("too many record types", errors_errors[223], 22);
|
||||
__MOVE("too many pointer types", errors_errors[224], 23);
|
||||
__MOVE("address of pointer variable too large (move forward in text)", errors_errors[225], 61);
|
||||
__MOVE("too many exported procedures", errors_errors[226], 29);
|
||||
__MOVE("too many imported modules", errors_errors[227], 26);
|
||||
__MOVE("too many exported structures", errors_errors[228], 29);
|
||||
__MOVE("too many nested records for import", errors_errors[229], 35);
|
||||
__MOVE("too many constants (strings) in module", errors_errors[230], 39);
|
||||
__MOVE("too many link table entries (external procedures)", errors_errors[231], 50);
|
||||
__MOVE("too many commands in module", errors_errors[232], 28);
|
||||
__MOVE("record extension hierarchy too high", errors_errors[233], 36);
|
||||
__MOVE("export of recursive type not allowed", errors_errors[234], 37);
|
||||
__MOVE("identifier too long", errors_errors[240], 20);
|
||||
__MOVE("string too long", errors_errors[241], 16);
|
||||
__MOVE("address overflow", errors_errors[242], 17);
|
||||
__MOVE("cyclic type definition not allowed", errors_errors[244], 35);
|
||||
__MOVE("guarded pointer variable may be manipulated by non-local operations; use auxiliary pointer variable", errors_errors[245], 100);
|
||||
__MOVE("implicit type cast", errors_errors[301], 19);
|
||||
__MOVE("inappropriate symbol file ignored", errors_errors[306], 34);
|
||||
__MOVE("no ELSE symbol after CASE statement sequence may lead to trap", errors_errors[307], 62);
|
||||
__ENDMOD;
|
||||
}
|
||||
18
bootstrap/unix-48/errors.h
Normal file
18
bootstrap/unix-48/errors.h
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#ifndef errors__h
|
||||
#define errors__h
|
||||
|
||||
#include "SYSTEM.h"
|
||||
|
||||
typedef
|
||||
CHAR errors_string[128];
|
||||
|
||||
|
||||
import errors_string errors_errors[350];
|
||||
|
||||
|
||||
import void *errors__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
112
bootstrap/unix-48/extTools.c
Normal file
112
bootstrap/unix-48/extTools.c
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
#include "SYSTEM.h"
|
||||
#include "Configuration.h"
|
||||
#include "Console.h"
|
||||
#include "OPM.h"
|
||||
#include "Platform.h"
|
||||
#include "Strings.h"
|
||||
|
||||
|
||||
static CHAR extTools_compilationOptions[1023], extTools_CFLAGS[1023];
|
||||
|
||||
|
||||
export void extTools_Assemble (CHAR *moduleName, LONGINT moduleName__len);
|
||||
export void extTools_LinkMain (CHAR *moduleName, LONGINT moduleName__len, BOOLEAN statically, CHAR *additionalopts, LONGINT additionalopts__len);
|
||||
static void extTools_execute (CHAR *title, LONGINT title__len, CHAR *cmd, LONGINT cmd__len);
|
||||
|
||||
|
||||
static void extTools_execute (CHAR *title, LONGINT title__len, CHAR *cmd, LONGINT cmd__len)
|
||||
{
|
||||
INTEGER r, status, exitcode;
|
||||
__DUP(title, title__len, CHAR);
|
||||
__DUP(cmd, cmd__len, CHAR);
|
||||
if (OPM_Verbose) {
|
||||
Console_String(title, title__len);
|
||||
Console_String(cmd, cmd__len);
|
||||
Console_Ln();
|
||||
}
|
||||
r = Platform_System(cmd, cmd__len);
|
||||
status = __MASK(r, -128);
|
||||
exitcode = __ASHR(r, 8);
|
||||
if (exitcode > 127) {
|
||||
exitcode = exitcode - 256;
|
||||
}
|
||||
if (r != 0) {
|
||||
Console_String(title, title__len);
|
||||
Console_String(cmd, cmd__len);
|
||||
Console_Ln();
|
||||
Console_String((CHAR*)"-- failed: status ", (LONGINT)19);
|
||||
Console_Int(status, ((LONGINT)(1)));
|
||||
Console_String((CHAR*)", exitcode ", (LONGINT)12);
|
||||
Console_Int(exitcode, ((LONGINT)(1)));
|
||||
Console_String((CHAR*)".", (LONGINT)2);
|
||||
Console_Ln();
|
||||
if ((status == 0 && exitcode == 127)) {
|
||||
Console_String((CHAR*)"Is the C compiler in the current command path\?", (LONGINT)47);
|
||||
Console_Ln();
|
||||
}
|
||||
if (status != 0) {
|
||||
Platform_Halt(status);
|
||||
} else {
|
||||
Platform_Halt(exitcode);
|
||||
}
|
||||
}
|
||||
__DEL(title);
|
||||
__DEL(cmd);
|
||||
}
|
||||
|
||||
void extTools_Assemble (CHAR *moduleName, LONGINT moduleName__len)
|
||||
{
|
||||
CHAR cmd[1023];
|
||||
__DUP(moduleName, moduleName__len, CHAR);
|
||||
__MOVE("gcc -g", cmd, 7);
|
||||
Strings_Append(extTools_compilationOptions, ((LONGINT)(1023)), (void*)cmd, ((LONGINT)(1023)));
|
||||
Strings_Append((CHAR*)"-c ", (LONGINT)4, (void*)cmd, ((LONGINT)(1023)));
|
||||
Strings_Append(moduleName, moduleName__len, (void*)cmd, ((LONGINT)(1023)));
|
||||
Strings_Append((CHAR*)".c", (LONGINT)3, (void*)cmd, ((LONGINT)(1023)));
|
||||
extTools_execute((CHAR*)"Assemble: ", (LONGINT)11, cmd, ((LONGINT)(1023)));
|
||||
__DEL(moduleName);
|
||||
}
|
||||
|
||||
void extTools_LinkMain (CHAR *moduleName, LONGINT moduleName__len, BOOLEAN statically, CHAR *additionalopts, LONGINT additionalopts__len)
|
||||
{
|
||||
CHAR cmd[1023];
|
||||
__DUP(additionalopts, additionalopts__len, CHAR);
|
||||
__MOVE("gcc -g", cmd, 7);
|
||||
Strings_Append((CHAR*)" ", (LONGINT)2, (void*)cmd, ((LONGINT)(1023)));
|
||||
Strings_Append(extTools_compilationOptions, ((LONGINT)(1023)), (void*)cmd, ((LONGINT)(1023)));
|
||||
Strings_Append(moduleName, moduleName__len, (void*)cmd, ((LONGINT)(1023)));
|
||||
Strings_Append((CHAR*)".c ", (LONGINT)4, (void*)cmd, ((LONGINT)(1023)));
|
||||
Strings_Append(additionalopts, additionalopts__len, (void*)cmd, ((LONGINT)(1023)));
|
||||
if (statically) {
|
||||
Strings_Append((CHAR*)"-static", (LONGINT)8, (void*)cmd, ((LONGINT)(1023)));
|
||||
}
|
||||
Strings_Append((CHAR*)" -o ", (LONGINT)5, (void*)cmd, ((LONGINT)(1023)));
|
||||
Strings_Append(moduleName, moduleName__len, (void*)cmd, ((LONGINT)(1023)));
|
||||
Strings_Append((CHAR*)" -L\"", (LONGINT)5, (void*)cmd, ((LONGINT)(1023)));
|
||||
Strings_Append((CHAR*)"/opt/voc", (LONGINT)9, (void*)cmd, ((LONGINT)(1023)));
|
||||
Strings_Append((CHAR*)"/lib\"", (LONGINT)6, (void*)cmd, ((LONGINT)(1023)));
|
||||
Strings_Append((CHAR*)" -l voc", (LONGINT)8, (void*)cmd, ((LONGINT)(1023)));
|
||||
extTools_execute((CHAR*)"Assemble and link: ", (LONGINT)20, cmd, ((LONGINT)(1023)));
|
||||
__DEL(additionalopts);
|
||||
}
|
||||
|
||||
|
||||
export void *extTools__init(void)
|
||||
{
|
||||
__DEFMOD;
|
||||
__MODULE_IMPORT(Configuration);
|
||||
__MODULE_IMPORT(Console);
|
||||
__MODULE_IMPORT(OPM);
|
||||
__MODULE_IMPORT(Platform);
|
||||
__MODULE_IMPORT(Strings);
|
||||
__REGMOD("extTools", 0);
|
||||
/* BEGIN */
|
||||
Strings_Append((CHAR*)" -I \"", (LONGINT)6, (void*)extTools_compilationOptions, ((LONGINT)(1023)));
|
||||
Strings_Append((CHAR*)"/opt/voc", (LONGINT)9, (void*)extTools_compilationOptions, ((LONGINT)(1023)));
|
||||
Strings_Append((CHAR*)"/include\" ", (LONGINT)11, (void*)extTools_compilationOptions, ((LONGINT)(1023)));
|
||||
Platform_GetEnv((CHAR*)"CFLAGS", (LONGINT)7, (void*)extTools_CFLAGS, ((LONGINT)(1023)));
|
||||
Strings_Append(extTools_CFLAGS, ((LONGINT)(1023)), (void*)extTools_compilationOptions, ((LONGINT)(1023)));
|
||||
Strings_Append((CHAR*)" ", (LONGINT)2, (void*)extTools_compilationOptions, ((LONGINT)(1023)));
|
||||
__ENDMOD;
|
||||
}
|
||||
16
bootstrap/unix-48/extTools.h
Normal file
16
bootstrap/unix-48/extTools.h
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#ifndef extTools__h
|
||||
#define extTools__h
|
||||
|
||||
#include "SYSTEM.h"
|
||||
|
||||
|
||||
|
||||
|
||||
import void extTools_Assemble (CHAR *moduleName, LONGINT moduleName__len);
|
||||
import void extTools_LinkMain (CHAR *moduleName, LONGINT moduleName__len, BOOLEAN statically, CHAR *additionalopts, LONGINT additionalopts__len);
|
||||
import void *extTools__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
258
bootstrap/unix-48/vt100.c
Normal file
258
bootstrap/unix-48/vt100.c
Normal file
|
|
@ -0,0 +1,258 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
#include "SYSTEM.h"
|
||||
#include "Console.h"
|
||||
#include "Strings.h"
|
||||
|
||||
|
||||
export CHAR vt100_CSI[5];
|
||||
static CHAR vt100_tmpstr[32];
|
||||
|
||||
|
||||
export void vt100_CHA (INTEGER n);
|
||||
export void vt100_CNL (INTEGER n);
|
||||
export void vt100_CPL (INTEGER n);
|
||||
export void vt100_CUB (INTEGER n);
|
||||
export void vt100_CUD (INTEGER n);
|
||||
export void vt100_CUF (INTEGER n);
|
||||
export void vt100_CUP (INTEGER n, INTEGER m);
|
||||
export void vt100_CUU (INTEGER n);
|
||||
export void vt100_DECTCEMh (void);
|
||||
export void vt100_DECTCEMl (void);
|
||||
export void vt100_DSR (INTEGER n);
|
||||
export void vt100_ED (INTEGER n);
|
||||
export void vt100_EL (INTEGER n);
|
||||
static void vt100_EscSeq (INTEGER n, CHAR *letter, LONGINT letter__len);
|
||||
static void vt100_EscSeq0 (CHAR *letter, LONGINT letter__len);
|
||||
static void vt100_EscSeq2 (INTEGER n, INTEGER m, CHAR *letter, LONGINT letter__len);
|
||||
static void vt100_EscSeqSwapped (INTEGER n, CHAR *letter, LONGINT letter__len);
|
||||
export void vt100_HVP (INTEGER n, INTEGER m);
|
||||
export void vt100_IntToStr (LONGINT int_, CHAR *str, LONGINT str__len);
|
||||
export void vt100_RCP (void);
|
||||
static void vt100_Reverse0 (CHAR *str, LONGINT str__len, INTEGER start, INTEGER end);
|
||||
export void vt100_SCP (void);
|
||||
export void vt100_SD (INTEGER n);
|
||||
export void vt100_SGR (INTEGER n);
|
||||
export void vt100_SGR2 (INTEGER n, INTEGER m);
|
||||
export void vt100_SU (INTEGER n);
|
||||
export void vt100_SetAttr (CHAR *attr, LONGINT attr__len);
|
||||
|
||||
|
||||
static void vt100_Reverse0 (CHAR *str, LONGINT str__len, INTEGER start, INTEGER end)
|
||||
{
|
||||
CHAR h;
|
||||
while (start < end) {
|
||||
h = str[__X(start, str__len)];
|
||||
str[__X(start, str__len)] = str[__X(end, str__len)];
|
||||
str[__X(end, str__len)] = h;
|
||||
start += 1;
|
||||
end -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
void vt100_IntToStr (LONGINT int_, CHAR *str, LONGINT str__len)
|
||||
{
|
||||
CHAR b[21];
|
||||
INTEGER s, e;
|
||||
SHORTINT maxLength;
|
||||
maxLength = 11;
|
||||
if (int_ == (-2147483647-1)) {
|
||||
__MOVE("-2147483648", b, 12);
|
||||
e = 11;
|
||||
} else {
|
||||
if (int_ < 0) {
|
||||
b[0] = '-';
|
||||
int_ = -int_;
|
||||
s = 1;
|
||||
} else {
|
||||
s = 0;
|
||||
}
|
||||
e = s;
|
||||
do {
|
||||
b[__X(e, ((LONGINT)(21)))] = (CHAR)(__MOD(int_, 10) + 48);
|
||||
int_ = __DIV(int_, 10);
|
||||
e += 1;
|
||||
} while (!(int_ == 0));
|
||||
b[__X(e, ((LONGINT)(21)))] = 0x00;
|
||||
vt100_Reverse0((void*)b, ((LONGINT)(21)), s, e - 1);
|
||||
}
|
||||
__COPY(b, str, str__len);
|
||||
}
|
||||
|
||||
static void vt100_EscSeq0 (CHAR *letter, LONGINT letter__len)
|
||||
{
|
||||
CHAR cmd[9];
|
||||
__DUP(letter, letter__len, CHAR);
|
||||
__COPY(vt100_CSI, cmd, ((LONGINT)(9)));
|
||||
Strings_Append(letter, letter__len, (void*)cmd, ((LONGINT)(9)));
|
||||
Console_String(cmd, ((LONGINT)(9)));
|
||||
__DEL(letter);
|
||||
}
|
||||
|
||||
static void vt100_EscSeq (INTEGER n, CHAR *letter, LONGINT letter__len)
|
||||
{
|
||||
CHAR nstr[2];
|
||||
CHAR cmd[7];
|
||||
__DUP(letter, letter__len, CHAR);
|
||||
vt100_IntToStr(n, (void*)nstr, ((LONGINT)(2)));
|
||||
__COPY(vt100_CSI, cmd, ((LONGINT)(7)));
|
||||
Strings_Append(nstr, ((LONGINT)(2)), (void*)cmd, ((LONGINT)(7)));
|
||||
Strings_Append(letter, letter__len, (void*)cmd, ((LONGINT)(7)));
|
||||
Console_String(cmd, ((LONGINT)(7)));
|
||||
__DEL(letter);
|
||||
}
|
||||
|
||||
static void vt100_EscSeqSwapped (INTEGER n, CHAR *letter, LONGINT letter__len)
|
||||
{
|
||||
CHAR nstr[2];
|
||||
CHAR cmd[7];
|
||||
__DUP(letter, letter__len, CHAR);
|
||||
vt100_IntToStr(n, (void*)nstr, ((LONGINT)(2)));
|
||||
__COPY(vt100_CSI, cmd, ((LONGINT)(7)));
|
||||
Strings_Append(letter, letter__len, (void*)cmd, ((LONGINT)(7)));
|
||||
Strings_Append(nstr, ((LONGINT)(2)), (void*)cmd, ((LONGINT)(7)));
|
||||
Console_String(cmd, ((LONGINT)(7)));
|
||||
__DEL(letter);
|
||||
}
|
||||
|
||||
static void vt100_EscSeq2 (INTEGER n, INTEGER m, CHAR *letter, LONGINT letter__len)
|
||||
{
|
||||
CHAR nstr[5], mstr[5];
|
||||
CHAR cmd[12];
|
||||
__DUP(letter, letter__len, CHAR);
|
||||
vt100_IntToStr(n, (void*)nstr, ((LONGINT)(5)));
|
||||
vt100_IntToStr(m, (void*)mstr, ((LONGINT)(5)));
|
||||
__COPY(vt100_CSI, cmd, ((LONGINT)(12)));
|
||||
Strings_Append(nstr, ((LONGINT)(5)), (void*)cmd, ((LONGINT)(12)));
|
||||
Strings_Append((CHAR*)";", (LONGINT)2, (void*)cmd, ((LONGINT)(12)));
|
||||
Strings_Append(mstr, ((LONGINT)(5)), (void*)cmd, ((LONGINT)(12)));
|
||||
Strings_Append(letter, letter__len, (void*)cmd, ((LONGINT)(12)));
|
||||
Console_String(cmd, ((LONGINT)(12)));
|
||||
__DEL(letter);
|
||||
}
|
||||
|
||||
void vt100_CUU (INTEGER n)
|
||||
{
|
||||
vt100_EscSeq(n, (CHAR*)"A", (LONGINT)2);
|
||||
}
|
||||
|
||||
void vt100_CUD (INTEGER n)
|
||||
{
|
||||
vt100_EscSeq(n, (CHAR*)"B", (LONGINT)2);
|
||||
}
|
||||
|
||||
void vt100_CUF (INTEGER n)
|
||||
{
|
||||
vt100_EscSeq(n, (CHAR*)"C", (LONGINT)2);
|
||||
}
|
||||
|
||||
void vt100_CUB (INTEGER n)
|
||||
{
|
||||
vt100_EscSeq(n, (CHAR*)"D", (LONGINT)2);
|
||||
}
|
||||
|
||||
void vt100_CNL (INTEGER n)
|
||||
{
|
||||
vt100_EscSeq(n, (CHAR*)"E", (LONGINT)2);
|
||||
}
|
||||
|
||||
void vt100_CPL (INTEGER n)
|
||||
{
|
||||
vt100_EscSeq(n, (CHAR*)"F", (LONGINT)2);
|
||||
}
|
||||
|
||||
void vt100_CHA (INTEGER n)
|
||||
{
|
||||
vt100_EscSeq(n, (CHAR*)"G", (LONGINT)2);
|
||||
}
|
||||
|
||||
void vt100_CUP (INTEGER n, INTEGER m)
|
||||
{
|
||||
vt100_EscSeq2(n, m, (CHAR*)"H", (LONGINT)2);
|
||||
}
|
||||
|
||||
void vt100_ED (INTEGER n)
|
||||
{
|
||||
vt100_EscSeq(n, (CHAR*)"J", (LONGINT)2);
|
||||
}
|
||||
|
||||
void vt100_EL (INTEGER n)
|
||||
{
|
||||
vt100_EscSeq(n, (CHAR*)"K", (LONGINT)2);
|
||||
}
|
||||
|
||||
void vt100_SU (INTEGER n)
|
||||
{
|
||||
vt100_EscSeq(n, (CHAR*)"S", (LONGINT)2);
|
||||
}
|
||||
|
||||
void vt100_SD (INTEGER n)
|
||||
{
|
||||
vt100_EscSeq(n, (CHAR*)"T", (LONGINT)2);
|
||||
}
|
||||
|
||||
void vt100_HVP (INTEGER n, INTEGER m)
|
||||
{
|
||||
vt100_EscSeq2(n, m, (CHAR*)"f", (LONGINT)2);
|
||||
}
|
||||
|
||||
void vt100_SGR (INTEGER n)
|
||||
{
|
||||
vt100_EscSeq(n, (CHAR*)"m", (LONGINT)2);
|
||||
}
|
||||
|
||||
void vt100_SGR2 (INTEGER n, INTEGER m)
|
||||
{
|
||||
vt100_EscSeq2(n, m, (CHAR*)"m", (LONGINT)2);
|
||||
}
|
||||
|
||||
void vt100_DSR (INTEGER n)
|
||||
{
|
||||
vt100_EscSeq(6, (CHAR*)"n", (LONGINT)2);
|
||||
}
|
||||
|
||||
void vt100_SCP (void)
|
||||
{
|
||||
vt100_EscSeq0((CHAR*)"s", (LONGINT)2);
|
||||
}
|
||||
|
||||
void vt100_RCP (void)
|
||||
{
|
||||
vt100_EscSeq0((CHAR*)"u", (LONGINT)2);
|
||||
}
|
||||
|
||||
void vt100_DECTCEMl (void)
|
||||
{
|
||||
vt100_EscSeq0((CHAR*)"\?25l", (LONGINT)5);
|
||||
}
|
||||
|
||||
void vt100_DECTCEMh (void)
|
||||
{
|
||||
vt100_EscSeq0((CHAR*)"\?25h", (LONGINT)5);
|
||||
}
|
||||
|
||||
void vt100_SetAttr (CHAR *attr, LONGINT attr__len)
|
||||
{
|
||||
CHAR tmpstr[16];
|
||||
__DUP(attr, attr__len, CHAR);
|
||||
__COPY(vt100_CSI, tmpstr, ((LONGINT)(16)));
|
||||
Strings_Append(attr, attr__len, (void*)tmpstr, ((LONGINT)(16)));
|
||||
Console_String(tmpstr, ((LONGINT)(16)));
|
||||
__DEL(attr);
|
||||
}
|
||||
|
||||
|
||||
export void *vt100__init(void)
|
||||
{
|
||||
__DEFMOD;
|
||||
__MODULE_IMPORT(Console);
|
||||
__MODULE_IMPORT(Strings);
|
||||
__REGMOD("vt100", 0);
|
||||
__REGCMD("DECTCEMh", vt100_DECTCEMh);
|
||||
__REGCMD("DECTCEMl", vt100_DECTCEMl);
|
||||
__REGCMD("RCP", vt100_RCP);
|
||||
__REGCMD("SCP", vt100_SCP);
|
||||
/* BEGIN */
|
||||
__COPY("", vt100_CSI, ((LONGINT)(5)));
|
||||
Strings_Append((CHAR*)"[", (LONGINT)2, (void*)vt100_CSI, ((LONGINT)(5)));
|
||||
__ENDMOD;
|
||||
}
|
||||
37
bootstrap/unix-48/vt100.h
Normal file
37
bootstrap/unix-48/vt100.h
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#ifndef vt100__h
|
||||
#define vt100__h
|
||||
|
||||
#include "SYSTEM.h"
|
||||
|
||||
|
||||
import CHAR vt100_CSI[5];
|
||||
|
||||
|
||||
import void vt100_CHA (INTEGER n);
|
||||
import void vt100_CNL (INTEGER n);
|
||||
import void vt100_CPL (INTEGER n);
|
||||
import void vt100_CUB (INTEGER n);
|
||||
import void vt100_CUD (INTEGER n);
|
||||
import void vt100_CUF (INTEGER n);
|
||||
import void vt100_CUP (INTEGER n, INTEGER m);
|
||||
import void vt100_CUU (INTEGER n);
|
||||
import void vt100_DECTCEMh (void);
|
||||
import void vt100_DECTCEMl (void);
|
||||
import void vt100_DSR (INTEGER n);
|
||||
import void vt100_ED (INTEGER n);
|
||||
import void vt100_EL (INTEGER n);
|
||||
import void vt100_HVP (INTEGER n, INTEGER m);
|
||||
import void vt100_IntToStr (LONGINT int_, CHAR *str, LONGINT str__len);
|
||||
import void vt100_RCP (void);
|
||||
import void vt100_SCP (void);
|
||||
import void vt100_SD (INTEGER n);
|
||||
import void vt100_SGR (INTEGER n);
|
||||
import void vt100_SGR2 (INTEGER n, INTEGER m);
|
||||
import void vt100_SU (INTEGER n);
|
||||
import void vt100_SetAttr (CHAR *attr, LONGINT attr__len);
|
||||
import void *vt100__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
17
bootstrap/unix-88/Configuration.c
Normal file
17
bootstrap/unix-88/Configuration.c
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
#define LARGE
|
||||
#include "SYSTEM.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export void *Configuration__init(void)
|
||||
{
|
||||
__DEFMOD;
|
||||
__REGMOD("Configuration", 0);
|
||||
/* BEGIN */
|
||||
__ENDMOD;
|
||||
}
|
||||
15
bootstrap/unix-88/Configuration.h
Normal file
15
bootstrap/unix-88/Configuration.h
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#ifndef Configuration__h
|
||||
#define Configuration__h
|
||||
|
||||
#define LARGE
|
||||
#include "SYSTEM.h"
|
||||
|
||||
|
||||
|
||||
|
||||
import void *Configuration__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
151
bootstrap/unix-88/Console.c
Normal file
151
bootstrap/unix-88/Console.c
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
#define LARGE
|
||||
#include "SYSTEM.h"
|
||||
#include "Platform.h"
|
||||
|
||||
|
||||
static CHAR Console_line[128];
|
||||
static INTEGER Console_pos;
|
||||
|
||||
|
||||
export void Console_Bool (BOOLEAN b);
|
||||
export void Console_Char (CHAR ch);
|
||||
export void Console_Flush (void);
|
||||
export void Console_Hex (LONGINT i);
|
||||
export void Console_Int (LONGINT i, LONGINT n);
|
||||
export void Console_Ln (void);
|
||||
export void Console_Read (CHAR *ch);
|
||||
export void Console_ReadLine (CHAR *line, LONGINT line__len);
|
||||
export void Console_String (CHAR *s, LONGINT s__len);
|
||||
|
||||
|
||||
void Console_Flush (void)
|
||||
{
|
||||
INTEGER error;
|
||||
error = Platform_Write(((LONGINT)(1)), (LONGINT)(uintptr_t)Console_line, Console_pos);
|
||||
Console_pos = 0;
|
||||
}
|
||||
|
||||
void Console_Char (CHAR ch)
|
||||
{
|
||||
if (Console_pos == 128) {
|
||||
Console_Flush();
|
||||
}
|
||||
Console_line[__X(Console_pos, ((LONGINT)(128)))] = ch;
|
||||
Console_pos += 1;
|
||||
if (ch == 0x0a) {
|
||||
Console_Flush();
|
||||
}
|
||||
}
|
||||
|
||||
void Console_String (CHAR *s, LONGINT s__len)
|
||||
{
|
||||
INTEGER i;
|
||||
__DUP(s, s__len, CHAR);
|
||||
i = 0;
|
||||
while (s[__X(i, s__len)] != 0x00) {
|
||||
Console_Char(s[__X(i, s__len)]);
|
||||
i += 1;
|
||||
}
|
||||
__DEL(s);
|
||||
}
|
||||
|
||||
void Console_Int (LONGINT i, LONGINT n)
|
||||
{
|
||||
CHAR s[32];
|
||||
LONGINT i1, k;
|
||||
if (i == __LSHL(1, 63, LONGINT)) {
|
||||
__MOVE("8085774586302733229", s, 20);
|
||||
k = 19;
|
||||
} else {
|
||||
i1 = __ABS(i);
|
||||
s[0] = (CHAR)(__MOD(i1, 10) + 48);
|
||||
i1 = __DIV(i1, 10);
|
||||
k = 1;
|
||||
while (i1 > 0) {
|
||||
s[__X(k, ((LONGINT)(32)))] = (CHAR)(__MOD(i1, 10) + 48);
|
||||
i1 = __DIV(i1, 10);
|
||||
k += 1;
|
||||
}
|
||||
}
|
||||
if (i < 0) {
|
||||
s[__X(k, ((LONGINT)(32)))] = '-';
|
||||
k += 1;
|
||||
}
|
||||
while (n > k) {
|
||||
Console_Char(' ');
|
||||
n -= 1;
|
||||
}
|
||||
while (k > 0) {
|
||||
k -= 1;
|
||||
Console_Char(s[__X(k, ((LONGINT)(32)))]);
|
||||
}
|
||||
}
|
||||
|
||||
void Console_Ln (void)
|
||||
{
|
||||
Console_Char(0x0a);
|
||||
}
|
||||
|
||||
void Console_Bool (BOOLEAN b)
|
||||
{
|
||||
if (b) {
|
||||
Console_String((CHAR*)"TRUE", (LONGINT)5);
|
||||
} else {
|
||||
Console_String((CHAR*)"FALSE", (LONGINT)6);
|
||||
}
|
||||
}
|
||||
|
||||
void Console_Hex (LONGINT i)
|
||||
{
|
||||
LONGINT k, n;
|
||||
k = -28;
|
||||
while (k <= 0) {
|
||||
n = __MASK(__ASH(i, k), -16);
|
||||
if (n <= 9) {
|
||||
Console_Char((CHAR)(48 + n));
|
||||
} else {
|
||||
Console_Char((CHAR)(55 + n));
|
||||
}
|
||||
k += 4;
|
||||
}
|
||||
}
|
||||
|
||||
void Console_Read (CHAR *ch)
|
||||
{
|
||||
LONGINT n;
|
||||
INTEGER error;
|
||||
Console_Flush();
|
||||
error = Platform_ReadBuf(((LONGINT)(0)), (void*)&*ch, ((LONGINT)(1)), &n);
|
||||
if (n != 1) {
|
||||
*ch = 0x00;
|
||||
}
|
||||
}
|
||||
|
||||
void Console_ReadLine (CHAR *line, LONGINT line__len)
|
||||
{
|
||||
LONGINT i;
|
||||
CHAR ch;
|
||||
Console_Flush();
|
||||
i = 0;
|
||||
Console_Read(&ch);
|
||||
while ((((i < line__len - 1 && ch != 0x0a)) && ch != 0x00)) {
|
||||
line[__X(i, line__len)] = ch;
|
||||
i += 1;
|
||||
Console_Read(&ch);
|
||||
}
|
||||
line[__X(i, line__len)] = 0x00;
|
||||
}
|
||||
|
||||
|
||||
export void *Console__init(void)
|
||||
{
|
||||
__DEFMOD;
|
||||
__MODULE_IMPORT(Platform);
|
||||
__REGMOD("Console", 0);
|
||||
__REGCMD("Flush", Console_Flush);
|
||||
__REGCMD("Ln", Console_Ln);
|
||||
/* BEGIN */
|
||||
Console_pos = 0;
|
||||
__ENDMOD;
|
||||
}
|
||||
24
bootstrap/unix-88/Console.h
Normal file
24
bootstrap/unix-88/Console.h
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#ifndef Console__h
|
||||
#define Console__h
|
||||
|
||||
#define LARGE
|
||||
#include "SYSTEM.h"
|
||||
|
||||
|
||||
|
||||
|
||||
import void Console_Bool (BOOLEAN b);
|
||||
import void Console_Char (CHAR ch);
|
||||
import void Console_Flush (void);
|
||||
import void Console_Hex (LONGINT i);
|
||||
import void Console_Int (LONGINT i, LONGINT n);
|
||||
import void Console_Ln (void);
|
||||
import void Console_Read (CHAR *ch);
|
||||
import void Console_ReadLine (CHAR *line, LONGINT line__len);
|
||||
import void Console_String (CHAR *s, LONGINT s__len);
|
||||
import void *Console__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
1079
bootstrap/unix-88/Files.c
Normal file
1079
bootstrap/unix-88/Files.c
Normal file
File diff suppressed because it is too large
Load diff
71
bootstrap/unix-88/Files.h
Normal file
71
bootstrap/unix-88/Files.h
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin tspkaSfF */
|
||||
|
||||
#ifndef Files__h
|
||||
#define Files__h
|
||||
|
||||
#define LARGE
|
||||
#include "SYSTEM.h"
|
||||
|
||||
typedef
|
||||
struct Files_Handle *Files_File;
|
||||
|
||||
typedef
|
||||
struct Files_Handle {
|
||||
char _prvt0[232];
|
||||
LONGINT fd;
|
||||
char _prvt1[56];
|
||||
} Files_Handle;
|
||||
|
||||
typedef
|
||||
struct Files_Rider {
|
||||
LONGINT res;
|
||||
BOOLEAN eof;
|
||||
char _prvt0[31];
|
||||
} Files_Rider;
|
||||
|
||||
|
||||
|
||||
import LONGINT *Files_Handle__typ;
|
||||
import LONGINT *Files_Rider__typ;
|
||||
|
||||
import Files_File Files_Base (Files_Rider *r, LONGINT *r__typ);
|
||||
import void Files_ChangeDirectory (CHAR *path, LONGINT path__len, INTEGER *res);
|
||||
import void Files_Close (Files_File f);
|
||||
import void Files_Delete (CHAR *name, LONGINT name__len, INTEGER *res);
|
||||
import void Files_GetDate (Files_File f, LONGINT *t, LONGINT *d);
|
||||
import void Files_GetName (Files_File f, CHAR *name, LONGINT name__len);
|
||||
import LONGINT Files_Length (Files_File f);
|
||||
import Files_File Files_New (CHAR *name, LONGINT name__len);
|
||||
import Files_File Files_Old (CHAR *name, LONGINT name__len);
|
||||
import LONGINT Files_Pos (Files_Rider *r, LONGINT *r__typ);
|
||||
import void Files_Purge (Files_File f);
|
||||
import void Files_Read (Files_Rider *r, LONGINT *r__typ, SYSTEM_BYTE *x);
|
||||
import void Files_ReadBool (Files_Rider *R, LONGINT *R__typ, BOOLEAN *x);
|
||||
import void Files_ReadByte (Files_Rider *r, LONGINT *r__typ, SYSTEM_BYTE *x, LONGINT x__len);
|
||||
import void Files_ReadBytes (Files_Rider *r, LONGINT *r__typ, SYSTEM_BYTE *x, LONGINT x__len, LONGINT n);
|
||||
import void Files_ReadInt (Files_Rider *R, LONGINT *R__typ, INTEGER *x);
|
||||
import void Files_ReadLInt (Files_Rider *R, LONGINT *R__typ, LONGINT *x);
|
||||
import void Files_ReadLReal (Files_Rider *R, LONGINT *R__typ, LONGREAL *x);
|
||||
import void Files_ReadLine (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len);
|
||||
import void Files_ReadNum (Files_Rider *R, LONGINT *R__typ, LONGINT *x);
|
||||
import void Files_ReadReal (Files_Rider *R, LONGINT *R__typ, REAL *x);
|
||||
import void Files_ReadSet (Files_Rider *R, LONGINT *R__typ, SET *x);
|
||||
import void Files_ReadString (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len);
|
||||
import void Files_Register (Files_File f);
|
||||
import void Files_Rename (CHAR *old, LONGINT old__len, CHAR *new, LONGINT new__len, INTEGER *res);
|
||||
import void Files_Set (Files_Rider *r, LONGINT *r__typ, Files_File f, LONGINT pos);
|
||||
import void Files_SetSearchPath (CHAR *path, LONGINT path__len);
|
||||
import void Files_Write (Files_Rider *r, LONGINT *r__typ, SYSTEM_BYTE x);
|
||||
import void Files_WriteBool (Files_Rider *R, LONGINT *R__typ, BOOLEAN x);
|
||||
import void Files_WriteBytes (Files_Rider *r, LONGINT *r__typ, SYSTEM_BYTE *x, LONGINT x__len, LONGINT n);
|
||||
import void Files_WriteInt (Files_Rider *R, LONGINT *R__typ, INTEGER x);
|
||||
import void Files_WriteLInt (Files_Rider *R, LONGINT *R__typ, LONGINT x);
|
||||
import void Files_WriteLReal (Files_Rider *R, LONGINT *R__typ, LONGREAL x);
|
||||
import void Files_WriteNum (Files_Rider *R, LONGINT *R__typ, LONGINT x);
|
||||
import void Files_WriteReal (Files_Rider *R, LONGINT *R__typ, REAL x);
|
||||
import void Files_WriteSet (Files_Rider *R, LONGINT *R__typ, SET x);
|
||||
import void Files_WriteString (Files_Rider *R, LONGINT *R__typ, CHAR *x, LONGINT x__len);
|
||||
import void *Files__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
753
bootstrap/unix-88/Heap.c
Normal file
753
bootstrap/unix-88/Heap.c
Normal file
|
|
@ -0,0 +1,753 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin tskSfF */
|
||||
#define LARGE
|
||||
#include "SYSTEM.h"
|
||||
|
||||
struct Heap__1 {
|
||||
CHAR ch;
|
||||
SYSTEM_PTR p;
|
||||
};
|
||||
|
||||
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));
|
||||
|
||||
typedef
|
||||
struct Heap_FinDesc *Heap_FinNode;
|
||||
|
||||
typedef
|
||||
void (*Heap_Finalizer)(SYSTEM_PTR);
|
||||
|
||||
typedef
|
||||
struct Heap_FinDesc {
|
||||
Heap_FinNode next;
|
||||
LONGINT obj;
|
||||
BOOLEAN marked;
|
||||
Heap_Finalizer finalize;
|
||||
} Heap_FinDesc;
|
||||
|
||||
typedef
|
||||
struct Heap_ModuleDesc *Heap_Module;
|
||||
|
||||
typedef
|
||||
CHAR Heap_ModuleName[20];
|
||||
|
||||
typedef
|
||||
struct Heap_ModuleDesc {
|
||||
Heap_Module next;
|
||||
Heap_ModuleName name;
|
||||
LONGINT refcnt;
|
||||
Heap_Cmd cmds;
|
||||
LONGINT types;
|
||||
Heap_EnumProc enumPtrs;
|
||||
LONGINT reserved1, reserved2;
|
||||
} Heap_ModuleDesc;
|
||||
|
||||
|
||||
export SYSTEM_PTR Heap_modules;
|
||||
static LONGINT Heap_freeList[10];
|
||||
static LONGINT Heap_bigBlocks;
|
||||
export LONGINT Heap_allocated;
|
||||
static BOOLEAN Heap_firstTry;
|
||||
static LONGINT Heap_heap, Heap_heapend;
|
||||
export LONGINT Heap_heapsize;
|
||||
static Heap_FinNode Heap_fin;
|
||||
static INTEGER Heap_lockdepth;
|
||||
static BOOLEAN Heap_interrupted;
|
||||
export INTEGER Heap_FileCount;
|
||||
|
||||
export LONGINT *Heap_ModuleDesc__typ;
|
||||
export LONGINT *Heap_CmdDesc__typ;
|
||||
export LONGINT *Heap_FinDesc__typ;
|
||||
export LONGINT *Heap__1__typ;
|
||||
|
||||
static void Heap_CheckFin (void);
|
||||
static void Heap_ExtendHeap (LONGINT blksz);
|
||||
export void Heap_FINALL (void);
|
||||
static void Heap_Finalize (void);
|
||||
export void Heap_GC (BOOLEAN markStack);
|
||||
static void Heap_HeapSort (LONGINT n, LONGINT *a, LONGINT a__len);
|
||||
export void Heap_INCREF (Heap_Module m);
|
||||
export void Heap_InitHeap (void);
|
||||
export void Heap_Lock (void);
|
||||
static void Heap_Mark (LONGINT q);
|
||||
static void Heap_MarkCandidates (LONGINT n, LONGINT *cand, LONGINT cand__len);
|
||||
static void Heap_MarkP (SYSTEM_PTR p);
|
||||
static void Heap_MarkStack (LONGINT n, LONGINT *cand, LONGINT cand__len);
|
||||
export SYSTEM_PTR Heap_NEWBLK (LONGINT size);
|
||||
export SYSTEM_PTR Heap_NEWREC (LONGINT tag);
|
||||
static LONGINT Heap_NewChunk (LONGINT blksz);
|
||||
export void Heap_REGCMD (Heap_Module m, Heap_CmdName name, Heap_Command cmd);
|
||||
export SYSTEM_PTR Heap_REGMOD (Heap_ModuleName name, Heap_EnumProc enumPtrs);
|
||||
export void Heap_REGTYP (Heap_Module m, LONGINT typ);
|
||||
export void Heap_RegisterFinalizer (SYSTEM_PTR obj, Heap_Finalizer finalize);
|
||||
static void Heap_Scan (void);
|
||||
static void Heap_Sift (LONGINT l, LONGINT r, LONGINT *a, LONGINT a__len);
|
||||
export void Heap_Unlock (void);
|
||||
|
||||
extern void *Heap__init();
|
||||
extern LONGINT Platform_MainStackFrame;
|
||||
extern LONGINT Platform_OSAllocate(LONGINT size);
|
||||
#define Heap_FetchAddress(pointer) (LONGINT)(uintptr_t)(*((void**)((uintptr_t)pointer)))
|
||||
#define Heap_HeapModuleInit() Heap__init()
|
||||
#define Heap_OSAllocate(size) Platform_OSAllocate(size)
|
||||
#define Heap_PlatformHalt(code) Platform_Halt(code)
|
||||
#define Heap_PlatformMainStackFrame() Platform_MainStackFrame
|
||||
|
||||
void Heap_Lock (void)
|
||||
{
|
||||
Heap_lockdepth += 1;
|
||||
}
|
||||
|
||||
void Heap_Unlock (void)
|
||||
{
|
||||
Heap_lockdepth -= 1;
|
||||
if ((Heap_interrupted && Heap_lockdepth == 0)) {
|
||||
Heap_PlatformHalt(((LONGINT)(-9)));
|
||||
}
|
||||
}
|
||||
|
||||
SYSTEM_PTR Heap_REGMOD (Heap_ModuleName name, Heap_EnumProc enumPtrs)
|
||||
{
|
||||
SYSTEM_PTR _o_result;
|
||||
Heap_Module m;
|
||||
if (__STRCMP(name, "Heap") == 0) {
|
||||
__SYSNEW(m, 80);
|
||||
} else {
|
||||
__NEW(m, Heap_ModuleDesc);
|
||||
}
|
||||
m->types = 0;
|
||||
m->cmds = NIL;
|
||||
__COPY(name, m->name, ((LONGINT)(20)));
|
||||
m->refcnt = 0;
|
||||
m->enumPtrs = enumPtrs;
|
||||
m->next = (Heap_Module)(uintptr_t)Heap_modules;
|
||||
Heap_modules = (SYSTEM_PTR)m;
|
||||
_o_result = (void*)m;
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
void Heap_REGCMD (Heap_Module m, Heap_CmdName name, Heap_Command cmd)
|
||||
{
|
||||
Heap_Cmd c;
|
||||
if (__STRCMP(m->name, "Heap") == 0) {
|
||||
__SYSNEW(c, 40);
|
||||
} else {
|
||||
__NEW(c, Heap_CmdDesc);
|
||||
}
|
||||
__COPY(name, c->name, ((LONGINT)(24)));
|
||||
c->cmd = cmd;
|
||||
c->next = m->cmds;
|
||||
m->cmds = c;
|
||||
}
|
||||
|
||||
void Heap_REGTYP (Heap_Module m, LONGINT typ)
|
||||
{
|
||||
__PUT(typ, m->types, LONGINT);
|
||||
m->types = typ;
|
||||
}
|
||||
|
||||
void Heap_INCREF (Heap_Module m)
|
||||
{
|
||||
m->refcnt += 1;
|
||||
}
|
||||
|
||||
static LONGINT Heap_NewChunk (LONGINT blksz)
|
||||
{
|
||||
LONGINT _o_result;
|
||||
LONGINT chnk;
|
||||
chnk = Heap_OSAllocate(blksz + 24);
|
||||
if (chnk != 0) {
|
||||
__PUT(chnk + 8, chnk + (24 + blksz), LONGINT);
|
||||
__PUT(chnk + 24, chnk + 32, LONGINT);
|
||||
__PUT(chnk + 32, blksz, LONGINT);
|
||||
__PUT(chnk + 40, -8, LONGINT);
|
||||
__PUT(chnk + 48, Heap_bigBlocks, LONGINT);
|
||||
Heap_bigBlocks = chnk + 24;
|
||||
Heap_heapsize += blksz;
|
||||
}
|
||||
_o_result = chnk;
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
static void Heap_ExtendHeap (LONGINT blksz)
|
||||
{
|
||||
LONGINT size, chnk, j, next;
|
||||
if (blksz > 320000) {
|
||||
size = blksz;
|
||||
} else {
|
||||
size = 320000;
|
||||
}
|
||||
chnk = Heap_NewChunk(size);
|
||||
if (chnk != 0) {
|
||||
if (chnk < Heap_heap) {
|
||||
__PUT(chnk, Heap_heap, LONGINT);
|
||||
Heap_heap = chnk;
|
||||
} else {
|
||||
j = Heap_heap;
|
||||
next = Heap_FetchAddress(j);
|
||||
while ((next != 0 && chnk > next)) {
|
||||
j = next;
|
||||
next = Heap_FetchAddress(j);
|
||||
}
|
||||
__PUT(chnk, next, LONGINT);
|
||||
__PUT(j, chnk, LONGINT);
|
||||
}
|
||||
if (next == 0) {
|
||||
Heap_heapend = Heap_FetchAddress(chnk + 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SYSTEM_PTR Heap_NEWREC (LONGINT tag)
|
||||
{
|
||||
SYSTEM_PTR _o_result;
|
||||
LONGINT i, i0, di, blksz, restsize, t, adr, end, next, prev;
|
||||
SYSTEM_PTR new;
|
||||
Heap_Lock();
|
||||
blksz = Heap_FetchAddress(tag);
|
||||
i0 = __ASHR(blksz, 5);
|
||||
i = i0;
|
||||
if (i < 9) {
|
||||
adr = Heap_freeList[i];
|
||||
while (adr == 0) {
|
||||
i += 1;
|
||||
adr = Heap_freeList[i];
|
||||
}
|
||||
}
|
||||
if (i < 9) {
|
||||
next = Heap_FetchAddress(adr + 24);
|
||||
Heap_freeList[i] = next;
|
||||
if (i != i0) {
|
||||
di = i - i0;
|
||||
restsize = __ASHL(di, 5);
|
||||
end = adr + restsize;
|
||||
__PUT(end + 8, blksz, LONGINT);
|
||||
__PUT(end + 16, -8, LONGINT);
|
||||
__PUT(end, end + 8, LONGINT);
|
||||
__PUT(adr + 8, restsize, LONGINT);
|
||||
__PUT(adr + 24, Heap_freeList[di], LONGINT);
|
||||
Heap_freeList[di] = adr;
|
||||
adr += restsize;
|
||||
}
|
||||
} else {
|
||||
adr = Heap_bigBlocks;
|
||||
prev = 0;
|
||||
for (;;) {
|
||||
if (adr == 0) {
|
||||
if (Heap_firstTry) {
|
||||
Heap_GC(1);
|
||||
blksz += 32;
|
||||
if (__ASHL((Heap_heapsize - Heap_allocated) - blksz, 2) < Heap_heapsize) {
|
||||
Heap_ExtendHeap(__ASHL(__DIV(Heap_allocated + blksz, 96), 7) - Heap_heapsize);
|
||||
}
|
||||
Heap_firstTry = 0;
|
||||
new = Heap_NEWREC(tag);
|
||||
Heap_firstTry = 1;
|
||||
if (new == NIL) {
|
||||
Heap_ExtendHeap(__ASHL(__DIV(Heap_allocated + blksz, 96), 7) - Heap_heapsize);
|
||||
new = Heap_NEWREC(tag);
|
||||
}
|
||||
Heap_Unlock();
|
||||
_o_result = new;
|
||||
return _o_result;
|
||||
} else {
|
||||
Heap_Unlock();
|
||||
_o_result = NIL;
|
||||
return _o_result;
|
||||
}
|
||||
}
|
||||
t = Heap_FetchAddress(adr + 8);
|
||||
if (t >= blksz) {
|
||||
break;
|
||||
}
|
||||
prev = adr;
|
||||
adr = Heap_FetchAddress(adr + 24);
|
||||
}
|
||||
restsize = t - blksz;
|
||||
end = adr + restsize;
|
||||
__PUT(end + 8, blksz, LONGINT);
|
||||
__PUT(end + 16, -8, LONGINT);
|
||||
__PUT(end, end + 8, LONGINT);
|
||||
if (restsize > 288) {
|
||||
__PUT(adr + 8, restsize, LONGINT);
|
||||
} else {
|
||||
next = Heap_FetchAddress(adr + 24);
|
||||
if (prev == 0) {
|
||||
Heap_bigBlocks = next;
|
||||
} else {
|
||||
__PUT(prev + 24, next, LONGINT);
|
||||
}
|
||||
if (restsize > 0) {
|
||||
di = __ASHR(restsize, 5);
|
||||
__PUT(adr + 8, restsize, LONGINT);
|
||||
__PUT(adr + 24, Heap_freeList[di], LONGINT);
|
||||
Heap_freeList[di] = adr;
|
||||
}
|
||||
}
|
||||
adr += restsize;
|
||||
}
|
||||
i = adr + 32;
|
||||
end = adr + blksz;
|
||||
while (i < end) {
|
||||
__PUT(i, 0, LONGINT);
|
||||
__PUT(i + 8, 0, LONGINT);
|
||||
__PUT(i + 16, 0, LONGINT);
|
||||
__PUT(i + 24, 0, LONGINT);
|
||||
i += 32;
|
||||
}
|
||||
__PUT(adr + 24, 0, LONGINT);
|
||||
__PUT(adr, tag, LONGINT);
|
||||
__PUT(adr + 8, 0, LONGINT);
|
||||
__PUT(adr + 16, 0, LONGINT);
|
||||
Heap_allocated += blksz;
|
||||
Heap_Unlock();
|
||||
_o_result = (SYSTEM_PTR)(uintptr_t)(adr + 8);
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
SYSTEM_PTR Heap_NEWBLK (LONGINT size)
|
||||
{
|
||||
SYSTEM_PTR _o_result;
|
||||
LONGINT blksz, tag;
|
||||
SYSTEM_PTR new;
|
||||
Heap_Lock();
|
||||
blksz = __ASHL(__ASHR(size + 63, 5), 5);
|
||||
new = Heap_NEWREC((LONGINT)(uintptr_t)&blksz);
|
||||
tag = ((LONGINT)(uintptr_t)new + blksz) - 24;
|
||||
__PUT(tag - 8, 0, LONGINT);
|
||||
__PUT(tag, blksz, LONGINT);
|
||||
__PUT(tag + 8, -8, LONGINT);
|
||||
__PUT((LONGINT)(uintptr_t)new - 8, tag, LONGINT);
|
||||
Heap_Unlock();
|
||||
_o_result = new;
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
static void Heap_Mark (LONGINT q)
|
||||
{
|
||||
LONGINT p, tag, fld, n, offset, tagbits;
|
||||
if (q != 0) {
|
||||
tagbits = Heap_FetchAddress(q - 8);
|
||||
if (!__ODD(tagbits)) {
|
||||
__PUT(q - 8, tagbits + 1, LONGINT);
|
||||
p = 0;
|
||||
tag = tagbits + 8;
|
||||
for (;;) {
|
||||
__GET(tag, offset, LONGINT);
|
||||
if (offset < 0) {
|
||||
__PUT(q - 8, (tag + offset) + 1, LONGINT);
|
||||
if (p == 0) {
|
||||
break;
|
||||
}
|
||||
n = q;
|
||||
q = p;
|
||||
tag = Heap_FetchAddress(q - 8);
|
||||
tag -= 1;
|
||||
__GET(tag, offset, LONGINT);
|
||||
fld = q + offset;
|
||||
p = Heap_FetchAddress(fld);
|
||||
__PUT(fld, (SYSTEM_PTR)(uintptr_t)n, SYSTEM_PTR);
|
||||
} else {
|
||||
fld = q + offset;
|
||||
n = Heap_FetchAddress(fld);
|
||||
if (n != 0) {
|
||||
tagbits = Heap_FetchAddress(n - 8);
|
||||
if (!__ODD(tagbits)) {
|
||||
__PUT(n - 8, tagbits + 1, LONGINT);
|
||||
__PUT(q - 8, tag + 1, LONGINT);
|
||||
__PUT(fld, (SYSTEM_PTR)(uintptr_t)p, SYSTEM_PTR);
|
||||
p = q;
|
||||
q = n;
|
||||
tag = tagbits;
|
||||
}
|
||||
}
|
||||
}
|
||||
tag += 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void Heap_MarkP (SYSTEM_PTR p)
|
||||
{
|
||||
Heap_Mark((LONGINT)(uintptr_t)p);
|
||||
}
|
||||
|
||||
static void Heap_Scan (void)
|
||||
{
|
||||
LONGINT chnk, adr, end, start, tag, i, size, freesize;
|
||||
Heap_bigBlocks = 0;
|
||||
i = 1;
|
||||
while (i < 9) {
|
||||
Heap_freeList[i] = 0;
|
||||
i += 1;
|
||||
}
|
||||
freesize = 0;
|
||||
Heap_allocated = 0;
|
||||
chnk = Heap_heap;
|
||||
while (chnk != 0) {
|
||||
adr = chnk + 24;
|
||||
end = Heap_FetchAddress(chnk + 8);
|
||||
while (adr < end) {
|
||||
tag = Heap_FetchAddress(adr);
|
||||
if (__ODD(tag)) {
|
||||
if (freesize > 0) {
|
||||
start = adr - freesize;
|
||||
__PUT(start, start + 8, LONGINT);
|
||||
__PUT(start + 8, freesize, LONGINT);
|
||||
__PUT(start + 16, -8, LONGINT);
|
||||
i = __ASHR(freesize, 5);
|
||||
freesize = 0;
|
||||
if (i < 9) {
|
||||
__PUT(start + 24, Heap_freeList[i], LONGINT);
|
||||
Heap_freeList[i] = start;
|
||||
} else {
|
||||
__PUT(start + 24, Heap_bigBlocks, LONGINT);
|
||||
Heap_bigBlocks = start;
|
||||
}
|
||||
}
|
||||
tag -= 1;
|
||||
__PUT(adr, tag, LONGINT);
|
||||
size = Heap_FetchAddress(tag);
|
||||
Heap_allocated += size;
|
||||
adr += size;
|
||||
} else {
|
||||
size = Heap_FetchAddress(tag);
|
||||
freesize += size;
|
||||
adr += size;
|
||||
}
|
||||
}
|
||||
if (freesize > 0) {
|
||||
start = adr - freesize;
|
||||
__PUT(start, start + 8, LONGINT);
|
||||
__PUT(start + 8, freesize, LONGINT);
|
||||
__PUT(start + 16, -8, LONGINT);
|
||||
i = __ASHR(freesize, 5);
|
||||
freesize = 0;
|
||||
if (i < 9) {
|
||||
__PUT(start + 24, Heap_freeList[i], LONGINT);
|
||||
Heap_freeList[i] = start;
|
||||
} else {
|
||||
__PUT(start + 24, Heap_bigBlocks, LONGINT);
|
||||
Heap_bigBlocks = start;
|
||||
}
|
||||
}
|
||||
chnk = Heap_FetchAddress(chnk);
|
||||
}
|
||||
}
|
||||
|
||||
static void Heap_Sift (LONGINT l, LONGINT r, LONGINT *a, LONGINT a__len)
|
||||
{
|
||||
LONGINT i, j, x;
|
||||
j = l;
|
||||
x = a[j];
|
||||
for (;;) {
|
||||
i = j;
|
||||
j = __ASHL(j, 1) + 1;
|
||||
if ((j < r && a[j] < a[j + 1])) {
|
||||
j += 1;
|
||||
}
|
||||
if (j > r || a[j] <= x) {
|
||||
break;
|
||||
}
|
||||
a[i] = a[j];
|
||||
}
|
||||
a[i] = x;
|
||||
}
|
||||
|
||||
static void Heap_HeapSort (LONGINT n, LONGINT *a, LONGINT a__len)
|
||||
{
|
||||
LONGINT l, r, x;
|
||||
l = __ASHR(n, 1);
|
||||
r = n - 1;
|
||||
while (l > 0) {
|
||||
l -= 1;
|
||||
Heap_Sift(l, r, (void*)a, a__len);
|
||||
}
|
||||
while (r > 0) {
|
||||
x = a[0];
|
||||
a[0] = a[r];
|
||||
a[r] = x;
|
||||
r -= 1;
|
||||
Heap_Sift(l, r, (void*)a, a__len);
|
||||
}
|
||||
}
|
||||
|
||||
static void Heap_MarkCandidates (LONGINT n, LONGINT *cand, LONGINT cand__len)
|
||||
{
|
||||
LONGINT chnk, adr, tag, next, lim, lim1, i, ptr, size;
|
||||
chnk = Heap_heap;
|
||||
i = 0;
|
||||
lim = cand[n - 1];
|
||||
while ((chnk != 0 && chnk < lim)) {
|
||||
adr = chnk + 24;
|
||||
lim1 = Heap_FetchAddress(chnk + 8);
|
||||
if (lim < lim1) {
|
||||
lim1 = lim;
|
||||
}
|
||||
while (adr < lim1) {
|
||||
tag = Heap_FetchAddress(adr);
|
||||
if (__ODD(tag)) {
|
||||
size = Heap_FetchAddress(tag - 1);
|
||||
adr += size;
|
||||
} else {
|
||||
size = Heap_FetchAddress(tag);
|
||||
ptr = adr + 8;
|
||||
while (cand[i] < ptr) {
|
||||
i += 1;
|
||||
}
|
||||
if (i == n) {
|
||||
return;
|
||||
}
|
||||
next = adr + size;
|
||||
if (cand[i] < next) {
|
||||
Heap_Mark(ptr);
|
||||
}
|
||||
adr = next;
|
||||
}
|
||||
}
|
||||
chnk = Heap_FetchAddress(chnk);
|
||||
}
|
||||
}
|
||||
|
||||
static void Heap_CheckFin (void)
|
||||
{
|
||||
Heap_FinNode n;
|
||||
LONGINT tag;
|
||||
n = Heap_fin;
|
||||
while (n != NIL) {
|
||||
tag = Heap_FetchAddress(n->obj - 8);
|
||||
if (!__ODD(tag)) {
|
||||
n->marked = 0;
|
||||
Heap_Mark(n->obj);
|
||||
} else {
|
||||
n->marked = 1;
|
||||
}
|
||||
n = n->next;
|
||||
}
|
||||
}
|
||||
|
||||
static void Heap_Finalize (void)
|
||||
{
|
||||
Heap_FinNode n, prev;
|
||||
n = Heap_fin;
|
||||
prev = NIL;
|
||||
while (n != NIL) {
|
||||
if (!n->marked) {
|
||||
if (n == Heap_fin) {
|
||||
Heap_fin = Heap_fin->next;
|
||||
} else {
|
||||
prev->next = n->next;
|
||||
}
|
||||
(*n->finalize)((SYSTEM_PTR)(uintptr_t)n->obj);
|
||||
if (prev == NIL) {
|
||||
n = Heap_fin;
|
||||
} else {
|
||||
n = n->next;
|
||||
}
|
||||
} else {
|
||||
prev = n;
|
||||
n = n->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Heap_FINALL (void)
|
||||
{
|
||||
Heap_FinNode n;
|
||||
while (Heap_fin != NIL) {
|
||||
n = Heap_fin;
|
||||
Heap_fin = Heap_fin->next;
|
||||
(*n->finalize)((SYSTEM_PTR)(uintptr_t)n->obj);
|
||||
}
|
||||
}
|
||||
|
||||
static void Heap_MarkStack (LONGINT n, LONGINT *cand, LONGINT cand__len)
|
||||
{
|
||||
SYSTEM_PTR frame;
|
||||
LONGINT inc, nofcand, sp, p, stack0, ptr;
|
||||
struct Heap__1 align;
|
||||
if (n > 0) {
|
||||
Heap_MarkStack(n - 1, cand, cand__len);
|
||||
if (n > 100) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (n == 0) {
|
||||
nofcand = 0;
|
||||
sp = (LONGINT)(uintptr_t)&frame;
|
||||
stack0 = Heap_PlatformMainStackFrame();
|
||||
inc = (LONGINT)(uintptr_t)&align.p - (LONGINT)(uintptr_t)&align;
|
||||
if (sp > stack0) {
|
||||
inc = -inc;
|
||||
}
|
||||
while (sp != stack0) {
|
||||
__GET(sp, p, LONGINT);
|
||||
if ((p > Heap_heap && p < Heap_heapend)) {
|
||||
if (nofcand == cand__len) {
|
||||
Heap_HeapSort(nofcand, (void*)cand, cand__len);
|
||||
Heap_MarkCandidates(nofcand, (void*)cand, cand__len);
|
||||
nofcand = 0;
|
||||
}
|
||||
cand[nofcand] = p;
|
||||
nofcand += 1;
|
||||
}
|
||||
sp += inc;
|
||||
}
|
||||
if (nofcand > 0) {
|
||||
Heap_HeapSort(nofcand, (void*)cand, cand__len);
|
||||
Heap_MarkCandidates(nofcand, (void*)cand, cand__len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Heap_GC (BOOLEAN markStack)
|
||||
{
|
||||
Heap_Module m;
|
||||
LONGINT i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, i20, i21, i22, i23;
|
||||
LONGINT cand[10000];
|
||||
if (Heap_lockdepth == 0 || (Heap_lockdepth == 1 && !markStack)) {
|
||||
Heap_Lock();
|
||||
m = (Heap_Module)(uintptr_t)Heap_modules;
|
||||
while (m != NIL) {
|
||||
if (m->enumPtrs != NIL) {
|
||||
(*m->enumPtrs)(Heap_MarkP);
|
||||
}
|
||||
m = m->next;
|
||||
}
|
||||
if (markStack) {
|
||||
i0 = -100;
|
||||
i1 = -101;
|
||||
i2 = -102;
|
||||
i3 = -103;
|
||||
i4 = -104;
|
||||
i5 = -105;
|
||||
i6 = -106;
|
||||
i7 = -107;
|
||||
i8 = 1;
|
||||
i9 = 2;
|
||||
i10 = 3;
|
||||
i11 = 4;
|
||||
i12 = 5;
|
||||
i13 = 6;
|
||||
i14 = 7;
|
||||
i15 = 8;
|
||||
i16 = 9;
|
||||
i17 = 10;
|
||||
i18 = 11;
|
||||
i19 = 12;
|
||||
i20 = 13;
|
||||
i21 = 14;
|
||||
i22 = 15;
|
||||
i23 = 16;
|
||||
for (;;) {
|
||||
i0 += 1;
|
||||
i1 += 2;
|
||||
i2 += 3;
|
||||
i3 += 4;
|
||||
i4 += 5;
|
||||
i5 += 6;
|
||||
i6 += 7;
|
||||
i7 += 8;
|
||||
i8 += 9;
|
||||
i9 += 10;
|
||||
i10 += 11;
|
||||
i11 += 12;
|
||||
i12 += 13;
|
||||
i13 += 14;
|
||||
i14 += 15;
|
||||
i15 += 16;
|
||||
i16 += 17;
|
||||
i17 += 18;
|
||||
i18 += 19;
|
||||
i19 += 20;
|
||||
i20 += 21;
|
||||
i21 += 22;
|
||||
i22 += 23;
|
||||
i23 += 24;
|
||||
if ((i0 == -99 && i15 == 24)) {
|
||||
Heap_MarkStack(((LONGINT)(32)), (void*)cand, ((LONGINT)(10000)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (((((((((((((((((((((((i0 + i1) + i2) + i3) + i4) + i5) + i6) + i7) + i8) + i9) + i10) + i11) + i12) + i13) + i14) + i15) + i16) + i17) + i18) + i19) + i20) + i21) + i22) + i23 > 10000) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
Heap_CheckFin();
|
||||
Heap_Scan();
|
||||
Heap_Finalize();
|
||||
Heap_Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
void Heap_RegisterFinalizer (SYSTEM_PTR obj, Heap_Finalizer finalize)
|
||||
{
|
||||
Heap_FinNode f;
|
||||
__NEW(f, Heap_FinDesc);
|
||||
f->obj = (LONGINT)(uintptr_t)obj;
|
||||
f->finalize = finalize;
|
||||
f->marked = 1;
|
||||
f->next = Heap_fin;
|
||||
Heap_fin = f;
|
||||
}
|
||||
|
||||
void Heap_InitHeap (void)
|
||||
{
|
||||
Heap_heap = Heap_NewChunk(((LONGINT)(256000)));
|
||||
Heap_heapend = Heap_FetchAddress(Heap_heap + 8);
|
||||
__PUT(Heap_heap, 0, LONGINT);
|
||||
Heap_allocated = 0;
|
||||
Heap_firstTry = 1;
|
||||
Heap_freeList[9] = 1;
|
||||
Heap_lockdepth = 0;
|
||||
Heap_FileCount = 0;
|
||||
Heap_modules = NIL;
|
||||
Heap_heapsize = 0;
|
||||
Heap_bigBlocks = 0;
|
||||
Heap_fin = NIL;
|
||||
Heap_interrupted = 0;
|
||||
Heap_HeapModuleInit();
|
||||
}
|
||||
|
||||
static void EnumPtrs(void (*P)(void*))
|
||||
{
|
||||
P(Heap_modules);
|
||||
P(Heap_fin);
|
||||
}
|
||||
|
||||
__TDESC(Heap_ModuleDesc, 1, 2) = {__TDFLDS("ModuleDesc", 80), {0, 40, -24}};
|
||||
__TDESC(Heap_CmdDesc, 1, 1) = {__TDFLDS("CmdDesc", 40), {0, -16}};
|
||||
__TDESC(Heap_FinDesc, 1, 1) = {__TDFLDS("FinDesc", 32), {0, -16}};
|
||||
__TDESC(Heap__1, 1, 1) = {__TDFLDS("", 16), {8, -16}};
|
||||
|
||||
export void *Heap__init(void)
|
||||
{
|
||||
__DEFMOD;
|
||||
__REGMOD("Heap", EnumPtrs);
|
||||
__REGCMD("FINALL", Heap_FINALL);
|
||||
__REGCMD("InitHeap", Heap_InitHeap);
|
||||
__REGCMD("Lock", Heap_Lock);
|
||||
__REGCMD("Unlock", Heap_Unlock);
|
||||
__INITYP(Heap_ModuleDesc, Heap_ModuleDesc, 0);
|
||||
__INITYP(Heap_CmdDesc, Heap_CmdDesc, 0);
|
||||
__INITYP(Heap_FinDesc, Heap_FinDesc, 0);
|
||||
__INITYP(Heap__1, Heap__1, 0);
|
||||
/* BEGIN */
|
||||
__ENDMOD;
|
||||
}
|
||||
55
bootstrap/unix-88/Heap.h
Normal file
55
bootstrap/unix-88/Heap.h
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin tskSfF */
|
||||
|
||||
#ifndef Heap__h
|
||||
#define Heap__h
|
||||
|
||||
#define LARGE
|
||||
#include "SYSTEM.h"
|
||||
|
||||
typedef
|
||||
CHAR Heap_CmdName[24];
|
||||
|
||||
typedef
|
||||
void (*Heap_Command)(void);
|
||||
|
||||
typedef
|
||||
void (*Heap_EnumProc)(void(*)(SYSTEM_PTR));
|
||||
|
||||
typedef
|
||||
void (*Heap_Finalizer)(SYSTEM_PTR);
|
||||
|
||||
typedef
|
||||
struct Heap_ModuleDesc *Heap_Module;
|
||||
|
||||
typedef
|
||||
struct Heap_ModuleDesc {
|
||||
LONGINT _prvt0;
|
||||
char _prvt1[72];
|
||||
} Heap_ModuleDesc;
|
||||
|
||||
typedef
|
||||
CHAR Heap_ModuleName[20];
|
||||
|
||||
|
||||
import SYSTEM_PTR Heap_modules;
|
||||
import LONGINT Heap_allocated, Heap_heapsize;
|
||||
import INTEGER Heap_FileCount;
|
||||
|
||||
import LONGINT *Heap_ModuleDesc__typ;
|
||||
|
||||
import void Heap_FINALL (void);
|
||||
import void Heap_GC (BOOLEAN markStack);
|
||||
import void Heap_INCREF (Heap_Module m);
|
||||
import void Heap_InitHeap (void);
|
||||
import void Heap_Lock (void);
|
||||
import SYSTEM_PTR Heap_NEWBLK (LONGINT size);
|
||||
import SYSTEM_PTR Heap_NEWREC (LONGINT tag);
|
||||
import void Heap_REGCMD (Heap_Module m, Heap_CmdName name, Heap_Command cmd);
|
||||
import SYSTEM_PTR Heap_REGMOD (Heap_ModuleName name, Heap_EnumProc enumPtrs);
|
||||
import void Heap_REGTYP (Heap_Module m, LONGINT typ);
|
||||
import void Heap_RegisterFinalizer (SYSTEM_PTR obj, Heap_Finalizer finalize);
|
||||
import void Heap_Unlock (void);
|
||||
import void *Heap__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
172
bootstrap/unix-88/Modules.c
Normal file
172
bootstrap/unix-88/Modules.c
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
#define LARGE
|
||||
#include "SYSTEM.h"
|
||||
#include "Console.h"
|
||||
#include "Heap.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;
|
||||
LONGINT refcnt;
|
||||
Modules_Cmd cmds;
|
||||
LONGINT types;
|
||||
void (*enumPtrs)(void(*)(LONGINT));
|
||||
LONGINT reserved1, reserved2;
|
||||
} Modules_ModuleDesc;
|
||||
|
||||
|
||||
export INTEGER Modules_res;
|
||||
export CHAR Modules_resMsg[256];
|
||||
export Modules_ModuleName Modules_imported, Modules_importing;
|
||||
|
||||
export LONGINT *Modules_ModuleDesc__typ;
|
||||
export LONGINT *Modules_CmdDesc__typ;
|
||||
|
||||
static void Modules_Append (CHAR *a, LONGINT a__len, CHAR *b, LONGINT b__len);
|
||||
export void Modules_Free (CHAR *name, LONGINT name__len, BOOLEAN all);
|
||||
export Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, LONGINT name__len);
|
||||
export Modules_Module Modules_ThisMod (CHAR *name, LONGINT name__len);
|
||||
|
||||
#define Modules_modules() (Modules_Module)Heap_modules
|
||||
#define Modules_setmodules(m) Heap_modules = m
|
||||
|
||||
static void Modules_Append (CHAR *a, LONGINT a__len, CHAR *b, LONGINT b__len)
|
||||
{
|
||||
INTEGER i, j;
|
||||
__DUP(b, b__len, CHAR);
|
||||
i = 0;
|
||||
while (a[__X(i, a__len)] != 0x00) {
|
||||
i += 1;
|
||||
}
|
||||
j = 0;
|
||||
while (b[__X(j, b__len)] != 0x00) {
|
||||
a[__X(i, a__len)] = b[__X(j, b__len)];
|
||||
i += 1;
|
||||
j += 1;
|
||||
}
|
||||
a[__X(i, a__len)] = 0x00;
|
||||
__DEL(b);
|
||||
}
|
||||
|
||||
Modules_Module Modules_ThisMod (CHAR *name, LONGINT name__len)
|
||||
{
|
||||
Modules_Module _o_result;
|
||||
Modules_Module m = NIL;
|
||||
CHAR bodyname[64];
|
||||
Modules_Command body;
|
||||
__DUP(name, name__len, CHAR);
|
||||
m = Modules_modules();
|
||||
while ((m != NIL && __STRCMP(m->name, name) != 0)) {
|
||||
m = m->next;
|
||||
}
|
||||
if (m != NIL) {
|
||||
Modules_res = 0;
|
||||
Modules_resMsg[0] = 0x00;
|
||||
} else {
|
||||
Modules_res = 1;
|
||||
__COPY(name, Modules_importing, ((LONGINT)(20)));
|
||||
__MOVE(" module \"", Modules_resMsg, 10);
|
||||
Modules_Append((void*)Modules_resMsg, ((LONGINT)(256)), name, name__len);
|
||||
Modules_Append((void*)Modules_resMsg, ((LONGINT)(256)), (CHAR*)"\" not found", (LONGINT)12);
|
||||
}
|
||||
_o_result = m;
|
||||
__DEL(name);
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, LONGINT name__len)
|
||||
{
|
||||
Modules_Command _o_result;
|
||||
Modules_Cmd c = NIL;
|
||||
__DUP(name, name__len, CHAR);
|
||||
c = mod->cmds;
|
||||
while ((c != NIL && __STRCMP(c->name, name) != 0)) {
|
||||
c = c->next;
|
||||
}
|
||||
if (c != NIL) {
|
||||
Modules_res = 0;
|
||||
Modules_resMsg[0] = 0x00;
|
||||
_o_result = c->cmd;
|
||||
__DEL(name);
|
||||
return _o_result;
|
||||
} else {
|
||||
Modules_res = 2;
|
||||
__MOVE(" command \"", Modules_resMsg, 11);
|
||||
__COPY(name, Modules_importing, ((LONGINT)(20)));
|
||||
Modules_Append((void*)Modules_resMsg, ((LONGINT)(256)), mod->name, ((LONGINT)(20)));
|
||||
Modules_Append((void*)Modules_resMsg, ((LONGINT)(256)), (CHAR*)".", (LONGINT)2);
|
||||
Modules_Append((void*)Modules_resMsg, ((LONGINT)(256)), name, name__len);
|
||||
Modules_Append((void*)Modules_resMsg, ((LONGINT)(256)), (CHAR*)"\" not found", (LONGINT)12);
|
||||
_o_result = NIL;
|
||||
__DEL(name);
|
||||
return _o_result;
|
||||
}
|
||||
__RETCHK;
|
||||
}
|
||||
|
||||
void Modules_Free (CHAR *name, LONGINT name__len, BOOLEAN all)
|
||||
{
|
||||
Modules_Module m = NIL, p = NIL;
|
||||
__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;
|
||||
}
|
||||
Modules_res = 0;
|
||||
} else {
|
||||
Modules_res = 1;
|
||||
if (m == NIL) {
|
||||
__MOVE("module not found", Modules_resMsg, 17);
|
||||
} else {
|
||||
__MOVE("clients of this module exist", Modules_resMsg, 29);
|
||||
}
|
||||
}
|
||||
}
|
||||
__DEL(name);
|
||||
}
|
||||
|
||||
__TDESC(Modules_ModuleDesc, 1, 2) = {__TDFLDS("ModuleDesc", 80), {0, 40, -24}};
|
||||
__TDESC(Modules_CmdDesc, 1, 1) = {__TDFLDS("CmdDesc", 40), {0, -16}};
|
||||
|
||||
export void *Modules__init(void)
|
||||
{
|
||||
__DEFMOD;
|
||||
__MODULE_IMPORT(Console);
|
||||
__MODULE_IMPORT(Heap);
|
||||
__REGMOD("Modules", 0);
|
||||
__INITYP(Modules_ModuleDesc, Modules_ModuleDesc, 0);
|
||||
__INITYP(Modules_CmdDesc, Modules_CmdDesc, 0);
|
||||
/* BEGIN */
|
||||
__ENDMOD;
|
||||
}
|
||||
55
bootstrap/unix-88/Modules.h
Normal file
55
bootstrap/unix-88/Modules.h
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#ifndef Modules__h
|
||||
#define Modules__h
|
||||
|
||||
#define LARGE
|
||||
#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;
|
||||
LONGINT refcnt;
|
||||
Modules_Cmd cmds;
|
||||
LONGINT types;
|
||||
void (*enumPtrs)(void(*)(LONGINT));
|
||||
char _prvt0[16];
|
||||
} Modules_ModuleDesc;
|
||||
|
||||
|
||||
import INTEGER Modules_res;
|
||||
import CHAR Modules_resMsg[256];
|
||||
import Modules_ModuleName Modules_imported, Modules_importing;
|
||||
|
||||
import LONGINT *Modules_ModuleDesc__typ;
|
||||
import LONGINT *Modules_CmdDesc__typ;
|
||||
|
||||
import void Modules_Free (CHAR *name, LONGINT name__len, BOOLEAN all);
|
||||
import Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, LONGINT name__len);
|
||||
import Modules_Module Modules_ThisMod (CHAR *name, LONGINT name__len);
|
||||
import void *Modules__init(void);
|
||||
|
||||
#define Modules_modules() (Modules_Module)Heap_modules
|
||||
#define Modules_setmodules(m) Heap_modules = m
|
||||
|
||||
#endif
|
||||
2678
bootstrap/unix-88/OPB.c
Normal file
2678
bootstrap/unix-88/OPB.c
Normal file
File diff suppressed because it is too large
Load diff
50
bootstrap/unix-88/OPB.h
Normal file
50
bootstrap/unix-88/OPB.h
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#ifndef OPB__h
|
||||
#define OPB__h
|
||||
|
||||
#define LARGE
|
||||
#include "SYSTEM.h"
|
||||
#include "OPS.h"
|
||||
#include "OPT.h"
|
||||
|
||||
|
||||
import void (*OPB_typSize)(OPT_Struct);
|
||||
|
||||
|
||||
import void OPB_Assign (OPT_Node *x, OPT_Node y);
|
||||
import void OPB_Call (OPT_Node *x, OPT_Node apar, OPT_Object fp);
|
||||
import void OPB_CheckParameters (OPT_Object fp, OPT_Object ap, BOOLEAN checkNames);
|
||||
import void OPB_Construct (SHORTINT class, OPT_Node *x, OPT_Node y);
|
||||
import void OPB_DeRef (OPT_Node *x);
|
||||
import OPT_Node OPB_EmptySet (void);
|
||||
import void OPB_Enter (OPT_Node *procdec, OPT_Node stat, OPT_Object proc);
|
||||
import void OPB_Field (OPT_Node *x, OPT_Object y);
|
||||
import void OPB_In (OPT_Node *x, OPT_Node y);
|
||||
import void OPB_Index (OPT_Node *x, OPT_Node y);
|
||||
import void OPB_Inittd (OPT_Node *inittd, OPT_Node *last, OPT_Struct typ);
|
||||
import void OPB_Link (OPT_Node *x, OPT_Node *last, OPT_Node y);
|
||||
import void OPB_MOp (SHORTINT op, OPT_Node *x);
|
||||
import OPT_Node OPB_NewBoolConst (BOOLEAN boolval);
|
||||
import OPT_Node OPB_NewIntConst (LONGINT intval);
|
||||
import OPT_Node OPB_NewLeaf (OPT_Object obj);
|
||||
import OPT_Node OPB_NewRealConst (LONGREAL realval, OPT_Struct typ);
|
||||
import OPT_Node OPB_NewString (OPS_String str, LONGINT len);
|
||||
import OPT_Node OPB_Nil (void);
|
||||
import void OPB_Op (SHORTINT op, OPT_Node *x, OPT_Node y);
|
||||
import void OPB_OptIf (OPT_Node *x);
|
||||
import void OPB_Param (OPT_Node ap, OPT_Object fp);
|
||||
import void OPB_PrepCall (OPT_Node *x, OPT_Object *fpar);
|
||||
import void OPB_Return (OPT_Node *x, OPT_Object proc);
|
||||
import void OPB_SetElem (OPT_Node *x);
|
||||
import void OPB_SetRange (OPT_Node *x, OPT_Node y);
|
||||
import void OPB_StFct (OPT_Node *par0, SHORTINT fctno, INTEGER parno);
|
||||
import void OPB_StPar0 (OPT_Node *par0, INTEGER fctno);
|
||||
import void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno);
|
||||
import void OPB_StParN (OPT_Node *par0, OPT_Node x, INTEGER fctno, INTEGER n);
|
||||
import void OPB_StaticLink (SHORTINT dlev);
|
||||
import void OPB_TypTest (OPT_Node *x, OPT_Object obj, BOOLEAN guard);
|
||||
import void *OPB__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
2109
bootstrap/unix-88/OPC.c
Normal file
2109
bootstrap/unix-88/OPC.c
Normal file
File diff suppressed because it is too large
Load diff
50
bootstrap/unix-88/OPC.h
Normal file
50
bootstrap/unix-88/OPC.h
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#ifndef OPC__h
|
||||
#define OPC__h
|
||||
|
||||
#define LARGE
|
||||
#include "SYSTEM.h"
|
||||
#include "OPT.h"
|
||||
|
||||
|
||||
|
||||
|
||||
import void OPC_Align (LONGINT *adr, LONGINT base);
|
||||
import void OPC_Andent (OPT_Struct typ);
|
||||
import LONGINT OPC_Base (OPT_Struct typ);
|
||||
import OPT_Object OPC_BaseTProc (OPT_Object obj);
|
||||
import void OPC_BegBlk (void);
|
||||
import void OPC_BegStat (void);
|
||||
import void OPC_Case (LONGINT caseVal, INTEGER form);
|
||||
import void OPC_Cmp (INTEGER rel);
|
||||
import void OPC_CompleteIdent (OPT_Object obj);
|
||||
import void OPC_Constant (OPT_Const con, INTEGER form);
|
||||
import void OPC_DefineInter (OPT_Object proc);
|
||||
import void OPC_EndBlk (void);
|
||||
import void OPC_EndBlk0 (void);
|
||||
import void OPC_EndStat (void);
|
||||
import void OPC_EnterBody (void);
|
||||
import void OPC_EnterProc (OPT_Object proc);
|
||||
import void OPC_ExitBody (void);
|
||||
import void OPC_ExitProc (OPT_Object proc, BOOLEAN eoBlock, BOOLEAN implicitRet);
|
||||
import void OPC_GenBdy (OPT_Node n);
|
||||
import void OPC_GenEnumPtrs (OPT_Object var);
|
||||
import void OPC_GenHdr (OPT_Node n);
|
||||
import void OPC_GenHdrIncludes (void);
|
||||
import void OPC_Halt (LONGINT n);
|
||||
import void OPC_Ident (OPT_Object obj);
|
||||
import void OPC_Increment (BOOLEAN decrement);
|
||||
import void OPC_Indent (INTEGER count);
|
||||
import void OPC_Init (void);
|
||||
import void OPC_InitTDesc (OPT_Struct typ);
|
||||
import void OPC_Len (OPT_Object obj, OPT_Struct array, LONGINT dim);
|
||||
import LONGINT OPC_NofPtrs (OPT_Struct typ);
|
||||
import void OPC_SetInclude (BOOLEAN exclude);
|
||||
import void OPC_TDescDecl (OPT_Struct typ);
|
||||
import void OPC_TypeDefs (OPT_Object obj, INTEGER vis);
|
||||
import void OPC_TypeOf (OPT_Object ap);
|
||||
import void *OPC__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
1092
bootstrap/unix-88/OPM.c
Normal file
1092
bootstrap/unix-88/OPM.c
Normal file
File diff suppressed because it is too large
Load diff
64
bootstrap/unix-88/OPM.h
Normal file
64
bootstrap/unix-88/OPM.h
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
/* voc 1.2 [2016/06/15] for gcc LP64 on cygwin xtspkaSfF */
|
||||
|
||||
#ifndef OPM__h
|
||||
#define OPM__h
|
||||
|
||||
#define LARGE
|
||||
#include "SYSTEM.h"
|
||||
|
||||
|
||||
import INTEGER OPM_Alignment, OPM_ByteSize, OPM_CharSize, OPM_BoolSize, OPM_SIntSize, OPM_IntSize, OPM_LIntSize, OPM_SetSize, OPM_RealSize, OPM_LRealSize, OPM_PointerSize, OPM_ProcSize, OPM_RecSize, OPM_CharAlign, OPM_BoolAlign, OPM_SIntAlign, OPM_IntAlign, OPM_LIntAlign, OPM_SetAlign, OPM_RealAlign, OPM_LRealAlign, OPM_PointerAlign, OPM_ProcAlign, OPM_RecAlign, OPM_MaxSet;
|
||||
import LONGINT OPM_MinSInt, OPM_MinInt, OPM_MinLInt, OPM_MaxSInt, OPM_MaxInt, OPM_MaxLInt, OPM_MaxIndex;
|
||||
import LONGREAL OPM_MinReal, OPM_MaxReal, OPM_MinLReal, OPM_MaxLReal;
|
||||
import BOOLEAN OPM_noerr;
|
||||
import LONGINT OPM_curpos, OPM_errpos, OPM_breakpc;
|
||||
import INTEGER OPM_currFile, OPM_level, OPM_pc, OPM_entno;
|
||||
import CHAR OPM_modName[32];
|
||||
import CHAR OPM_objname[64];
|
||||
import SET OPM_opt, OPM_glbopt;
|
||||
import BOOLEAN OPM_dontAsm, OPM_dontLink, OPM_mainProg, OPM_mainLinkStat, OPM_notColorOutput, OPM_forceNewSym, OPM_Verbose;
|
||||
|
||||
|
||||
import void OPM_CloseFiles (void);
|
||||
import void OPM_CloseOldSym (void);
|
||||
import void OPM_DeleteNewSym (void);
|
||||
import void OPM_FPrint (LONGINT *fp, LONGINT val);
|
||||
import void OPM_FPrintLReal (LONGINT *fp, LONGREAL lr);
|
||||
import void OPM_FPrintReal (LONGINT *fp, REAL real);
|
||||
import void OPM_FPrintSet (LONGINT *fp, SET set);
|
||||
import void OPM_Get (CHAR *ch);
|
||||
import void OPM_Init (BOOLEAN *done, CHAR *mname, LONGINT mname__len);
|
||||
import void OPM_InitOptions (void);
|
||||
import void OPM_LogW (CHAR ch);
|
||||
import void OPM_LogWLn (void);
|
||||
import void OPM_LogWNum (LONGINT i, LONGINT len);
|
||||
import void OPM_LogWStr (CHAR *s, LONGINT s__len);
|
||||
import void OPM_Mark (INTEGER n, LONGINT pos);
|
||||
import void OPM_NewSym (CHAR *modName, LONGINT modName__len);
|
||||
import void OPM_OldSym (CHAR *modName, LONGINT modName__len, BOOLEAN *done);
|
||||
import void OPM_OpenFiles (CHAR *moduleName, LONGINT moduleName__len);
|
||||
import BOOLEAN OPM_OpenPar (void);
|
||||
import void OPM_RegisterNewSym (void);
|
||||
import void OPM_SymRCh (CHAR *ch);
|
||||
import LONGINT OPM_SymRInt (void);
|
||||
import void OPM_SymRLReal (LONGREAL *lr);
|
||||
import void OPM_SymRReal (REAL *r);
|
||||
import void OPM_SymRSet (SET *s);
|
||||
import void OPM_SymWCh (CHAR ch);
|
||||
import void OPM_SymWInt (LONGINT i);
|
||||
import void OPM_SymWLReal (LONGREAL lr);
|
||||
import void OPM_SymWReal (REAL r);
|
||||
import void OPM_SymWSet (SET s);
|
||||
import void OPM_Write (CHAR ch);
|
||||
import void OPM_WriteHex (LONGINT i);
|
||||
import void OPM_WriteInt (LONGINT i);
|
||||
import void OPM_WriteLn (void);
|
||||
import void OPM_WriteReal (LONGREAL r, CHAR suffx);
|
||||
import void OPM_WriteString (CHAR *s, LONGINT s__len);
|
||||
import void OPM_WriteStringVar (CHAR *s, LONGINT s__len);
|
||||
import BOOLEAN OPM_eofSF (void);
|
||||
import void OPM_err (INTEGER n);
|
||||
import void *OPM__init(void);
|
||||
|
||||
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue