1988-02-19 15:54:01 +00:00
|
|
|
/*
|
|
|
|
(c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
|
|
|
See the copyright notice in the ACK home directory, in the file "Copyright".
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
Module: runtime support for conformant arrays
|
|
|
|
Author: Ceriel J.H. Jacobs
|
1994-06-24 14:02:31 +00:00
|
|
|
Version: $Id$
|
1988-02-19 15:54:01 +00:00
|
|
|
*/
|
2018-06-25 20:22:37 +00:00
|
|
|
#include "libm2.h"
|
1987-07-09 15:15:22 +00:00
|
|
|
#include <m2_traps.h>
|
|
|
|
|
1990-11-02 14:29:02 +00:00
|
|
|
#ifndef EM_WSIZE
|
|
|
|
#define EM_WSIZE _EM_WSIZE
|
|
|
|
#define EM_PSIZE _EM_PSIZE
|
|
|
|
#endif
|
|
|
|
|
2018-06-25 20:22:37 +00:00
|
|
|
static struct stack_descr* descrs[10];
|
|
|
|
static struct stack_descr** ppdescr = descrs;
|
1987-06-23 17:12:42 +00:00
|
|
|
|
2018-06-25 20:22:37 +00:00
|
|
|
size_t new_stackptr(struct stack_descr* pdescr, int a)
|
1987-06-23 17:12:42 +00:00
|
|
|
{
|
2018-06-25 20:22:37 +00:00
|
|
|
size_t size = (((pdescr->highminlow + 1) * pdescr->size + (EM_WSIZE - 1)) & ~(EM_WSIZE - 1));
|
1987-06-23 17:12:42 +00:00
|
|
|
|
2018-06-25 20:22:37 +00:00
|
|
|
if (ppdescr >= &descrs[10])
|
|
|
|
{
|
1987-06-23 17:12:42 +00:00
|
|
|
/* to many nested traps + handlers ! */
|
1987-07-09 15:15:22 +00:00
|
|
|
TRP(M2_TOOMANY);
|
1987-06-23 17:12:42 +00:00
|
|
|
}
|
|
|
|
*ppdescr++ = pdescr;
|
2018-06-25 20:22:37 +00:00
|
|
|
if ((char*)&a - (char*)&pdescr > 0)
|
|
|
|
{
|
1987-06-23 17:12:42 +00:00
|
|
|
/* stack grows downwards */
|
2018-06-25 20:22:37 +00:00
|
|
|
return -size;
|
1987-06-23 17:12:42 +00:00
|
|
|
}
|
1988-06-13 10:34:14 +00:00
|
|
|
return size;
|
1987-06-23 17:12:42 +00:00
|
|
|
}
|
|
|
|
|
2018-06-25 20:22:37 +00:00
|
|
|
void copy_array(char* p, int a)
|
1987-06-23 17:12:42 +00:00
|
|
|
{
|
2018-06-25 20:22:37 +00:00
|
|
|
char* q;
|
|
|
|
size_t sz;
|
1987-06-23 17:12:42 +00:00
|
|
|
char dummy;
|
|
|
|
|
|
|
|
ppdescr--;
|
1987-11-03 15:04:21 +00:00
|
|
|
sz = ((*ppdescr)->highminlow + 1) * (*ppdescr)->size;
|
2018-06-25 20:22:37 +00:00
|
|
|
|
|
|
|
if ((char*)&a - (char*)&p > 0)
|
|
|
|
{
|
|
|
|
(*ppdescr)->addr = q = (char*)&a;
|
1987-06-23 17:12:42 +00:00
|
|
|
}
|
2018-06-25 20:22:37 +00:00
|
|
|
else
|
|
|
|
(*ppdescr)->addr = q = (char*)&a - ((sz + (EM_WSIZE - 1)) & ~(EM_WSIZE - 1));
|
1987-06-23 17:12:42 +00:00
|
|
|
|
2018-06-25 20:22:37 +00:00
|
|
|
while (sz--)
|
|
|
|
*q++ = *p++;
|
1987-06-23 17:12:42 +00:00
|
|
|
}
|