SourceForge has been redesigned. Learn more.
Close

[28e18d]: / Backend / If2mem / if2level.c  Maximize  Restore  History

Download this file

90 lines (67 with data), 3.0 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/**************************************************************************/
/* FILE ************** if2level.c ************************/
/**************************************************************************/
/* Author: Dave Cann */
/* Update: Patrick Miller -- Ansi support (Dec 2000) */
/* Copyright (C) University of California Regents */
/**************************************************************************/
/*
* $Log:
*
* Revision 12.7 1992/11/04 22:05:06 miller
* Initial revision
*
* Revision 12.7 1992/10/21 18:09:22 miller
* Initial RCS Version by Cann
*/
/**************************************************************************/
#include "world.h"
#define SIZE_LEVEL_STACK 400
static int level = -1; /* TOP OF LEVEL STACK */
static PNODE lstack[SIZE_LEVEL_STACK]; /* LEVEL STACK */
/**************************************************************************/
/* LOCAL ************** CopyLevelStack ************************/
/**************************************************************************/
/* PURPOSE: RETURN A COPY OF THE CURRENT LEVEL STACK. */
/**************************************************************************/
static PPNODE CopyLevelStack()
{
register PPNODE ls;
register int i;
ls = (PPNODE) MyAlloc( (int) ((level+1) * sizeof(PNODE)) );
for ( i = 0; i <= level; i++ )
ls[i] = lstack[i];
return( ls );
}
/**************************************************************************/
/* GLOBAL ************** AssignLevelNumbers ************************/
/**************************************************************************/
/* PURPOSE: ASSIGN LEVEL NUMBERS AND LEVEL STACKS TO EACH NODE IN GRAPH g.*/
/* FIRST THE LEVEL IS INCREMENTED SINCE WE ARE ENTERING A NEW */
/* SCOPE. GRAPH g IS THEN PUSHED ONTO THE LEVEL STACK. AFTER */
/* LEVEL INFORMATION IS ASSIGNED TO ALL NODES AT THIS LEVEL AND */
/* ALL DEEPER LEVELS ACCESSABLE FROM IT, THE LEVEL IS POPPED */
/* FROM THE LEVEL STACK. */
/**************************************************************************/
void AssignLevelNumbers( g )
PNODE g;
{
register PNODE n;
register PPNODE ls;
/* PUSH A NEW LEVEL */
if ( (++level) >= SIZE_LEVEL_STACK )
Error2( "AssignLevelNumbers", "LEVEL STACK OVERFLOW" );
lstack[level] = g;
ls = CopyLevelStack();
g->lstack = ls;
g->level = level;
for ( n = g->G_NODES; n != NULL; n = n->nsucc ) {
n->lstack = ls;
n->level = level;
if ( IsCompound( n ) )
for ( g = n->C_SUBS; g != NULL; g = g->gsucc )
AssignLevelNumbers( g );
}
/* POP THE NEW LEVEL */
level--;
}