ack/util/ego/share/init_glob.c

64 lines
1.4 KiB
C
Raw Permalink Normal View History

1994-06-24 11:31:16 +00:00
/* $Id$ */
1987-03-09 19:15:41 +00:00
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
1984-11-26 15:04:22 +00:00
/* S H A R E D F I L E
*
* I N I T _ G L O B L S
*
*/
1991-03-05 12:44:05 +00:00
#include "types.h"
#include "debug.h"
#include "global.h"
#include "alloc.h"
#include "map.h"
1984-11-26 15:04:22 +00:00
extern short nrglobals;
/* ARGSUSED */
void init_globals(void *vp)
1984-11-26 15:04:22 +00:00
{
/* Assign a 'global variable number (o_globnr) to
* every global variable for which we want to
* maintain ud-info. We do not maintain ud-info
* for a global variable if:
* - it is part of a ROM data block (so it will never be changed)
* - it's size is not known
* - it overlaps another variable (e.g. LOE X+2 ; LDE X)
*/
dblock_p d;
1993-11-16 11:35:23 +00:00
obj_p obj, prev = 0;
1984-11-26 15:04:22 +00:00
short nr = 1;
offset ill_zone, x;
for (d = fdblock; d != (dblock_p) 0; d = d->d_next) {
ill_zone = (offset) 0;
for (obj = d->d_objlist; obj != (obj_p) 0; obj = obj->o_next) {
if (d->d_pseudo == DROM ||
obj->o_size == UNKNOWN_SIZE) {
obj->o_globnr = 0; /* var. not considered */
continue;
}
if (obj->o_off < ill_zone) {
obj->o_globnr = 0; /* var. not considered */
if (prev != (obj_p) 0 && prev->o_globnr != 0) {
prev->o_globnr = 0;
nr--;
}
} else {
obj->o_globnr = nr++;
}
if ((x = obj->o_off + obj->o_size) > ill_zone) {
ill_zone = x;
}
prev = obj;
}
}
nrglobals = nr -1;
}