mirror of
https://github.com/vishapoberon/compiler.git
synced 2026-04-06 01:42:24 +00:00
More LONGINTS changed to Address. Remove special FetchAddress code in Heap.
This commit is contained in:
parent
f13130bbd3
commit
7efd5a0158
201 changed files with 1227 additions and 1132 deletions
|
|
@ -23,9 +23,6 @@
|
|||
|
||||
|
||||
|
||||
LONGINT SYSTEM_ABS (LONGINT i) {return __ABS(i);}
|
||||
double SYSTEM_ABSD(double i) {return __ABS(i);}
|
||||
|
||||
|
||||
int64 SYSTEM_DIV(int64 x, int64 y)
|
||||
{
|
||||
|
|
@ -49,37 +46,6 @@ int64 SYSTEM_MOD(int64 x, int64 y)
|
|||
else {return -((-x) % (-y));}
|
||||
}
|
||||
|
||||
|
||||
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((address)(*((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(*(address*)((char*)adr+off)); t++; off = *t;}
|
||||
adr = ((char*)adr) + size;
|
||||
n--;
|
||||
}
|
||||
}
|
||||
|
||||
LONGINT SYSTEM_ENTIER(double x)
|
||||
{
|
||||
LONGINT y;
|
||||
|
|
@ -91,22 +57,55 @@ LONGINT SYSTEM_ENTIER(double x)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void SYSTEM_INHERIT(address *t, address *t0)
|
||||
{
|
||||
t -= __TPROC0OFF;
|
||||
t0 -= __TPROC0OFF;
|
||||
while (*t0 != __EOM) {*t = *t0; t--; t0--;}
|
||||
}
|
||||
|
||||
|
||||
void SYSTEM_ENUMP(void *adr, address n, void (*P)())
|
||||
{
|
||||
while (n > 0) {
|
||||
P((address)(*((void**)(adr))));
|
||||
adr = ((void**)adr) + 1;
|
||||
n--;
|
||||
}
|
||||
}
|
||||
|
||||
void SYSTEM_ENUMR(void *adr, address *typ, address size, address n, void (*P)())
|
||||
{
|
||||
address *t, off;
|
||||
typ++;
|
||||
while (n > 0) {
|
||||
t = typ;
|
||||
off = *t;
|
||||
while (off >= 0) {P(*(address*)((char*)adr+off)); t++; off = *t;}
|
||||
adr = ((char*)adr) + size;
|
||||
n--;
|
||||
}
|
||||
}
|
||||
|
||||
extern void Heap_Lock();
|
||||
extern void Heap_Unlock();
|
||||
|
||||
SYSTEM_PTR SYSTEM_NEWARR(LONGINT *typ, LONGINT elemsz, int elemalgn, int nofdim, int nofdyn, ...)
|
||||
SYSTEM_PTR SYSTEM_NEWARR(address *typ, address elemsz, int elemalgn, int nofdim, int nofdyn, ...)
|
||||
{
|
||||
LONGINT nofelems, size, dataoff, n, nptr, *x, *p, nofptrs, i, *ptab, off;
|
||||
address 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--;
|
||||
nofelems = nofelems * va_arg(ap, address); nofdim--;
|
||||
if (nofelems <= 0) __HALT(-20);
|
||||
}
|
||||
va_end(ap);
|
||||
dataoff = nofdyn * sizeof(LONGINT);
|
||||
if (elemalgn > sizeof(LONGINT)) {
|
||||
dataoff = nofdyn * sizeof(address);
|
||||
if (elemalgn > sizeof(address)) {
|
||||
n = dataoff % elemalgn;
|
||||
if (n != 0) dataoff += elemalgn - n;
|
||||
}
|
||||
|
|
@ -116,37 +115,37 @@ SYSTEM_PTR SYSTEM_NEWARR(LONGINT *typ, LONGINT elemsz, int elemalgn, int nofdim,
|
|||
/* element typ does not contain pointers */
|
||||
x = Heap_NEWBLK(size);
|
||||
}
|
||||
else if (typ == (LONGINT*)POINTER__typ) {
|
||||
else if (typ == (address*)POINTER__typ) {
|
||||
/* element type is a pointer */
|
||||
x = Heap_NEWBLK(size + nofelems * sizeof(LONGINT));
|
||||
p = (LONGINT*)(address)x[-1];
|
||||
x = Heap_NEWBLK(size + nofelems * sizeof(address));
|
||||
p = (address*)(address)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);
|
||||
while (n <= nofelems) {*p = n*sizeof(address); p++; n++;}
|
||||
*p = - (nofelems + 1) * sizeof(address); /* sentinel */
|
||||
x[-1] -= nofelems * sizeof(address);
|
||||
}
|
||||
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*)(address)x[- 1];
|
||||
x = Heap_NEWBLK(size + nptr * sizeof(address));
|
||||
p = (address*)(address)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);
|
||||
*p = - (nptr + 1) * sizeof(address); /* sentinel */
|
||||
x[-1] -= nptr * sizeof(address);
|
||||
}
|
||||
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--;}
|
||||
while (nofdyn > 0) {*p = va_arg(ap, address); p++, nofdyn--;}
|
||||
va_end(ap);
|
||||
}
|
||||
Heap_Unlock();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue