Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – tendra.SVN – Blame – //branches/tendra5/src/installers/common/construct/label_ops.c – Rev 2

Subversion Repositories tendra.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 7u83 1
/*
2
    		 Crown Copyright (c) 1997
3
 
4
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
12
 
13
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
15
 
16
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
19
 
20
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
22
        these conditions;
23
 
24
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
27
        it may be put.
28
*/
29
 
30
 
31
/**********************************************************************
32
$Author: release $
33
$Date: 1998/01/17 15:55:47 $
34
$Revision: 1.1.1.1 $
35
$Log: label_ops.c,v $
36
 * Revision 1.1.1.1  1998/01/17  15:55:47  release
37
 * First version to be checked into rolling release.
38
 *
39
 * Revision 1.5  1997/08/06  10:58:32  currie
40
 * Catch overflowed constants, PlumHall requirement
41
 *
42
 * Revision 1.4  1997/04/18  10:58:47  currie
43
 * another pathelogical case
44
 *
45
 * Revision 1.3  1996/05/21  12:53:54  currie
46
 * Pathological gotos
47
 *
48
 * Revision 1.2  1995/10/11  17:10:07  currie
49
 * avs errors
50
 *
51
 * Revision 1.1  1995/04/06  10:44:05  currie
52
 * Initial revision
53
 *
54
***********************************************************************/
55
 
56
 
57
 
58
#include "config.h"
59
#include "common_types.h"
60
#include "expmacs.h"
61
#include "tags.h"
62
#include "label_ops.h"
63
#include "check.h"
64
#include "externs.h"
65
#include "exp.h"
66
#include "installglob.h"
67
#include "shapemacs.h"
68
 
69
 
70
/* label_is_next returns 1 if lab is a labst which immediately
71
   follows e, otherwise 0. e will not be nilexp
72
*/
73
int label_is_next
74
    PROTO_N ( (lab, e) )
75
    PROTO_T ( exp lab X exp e )
76
{
77
  if (!indirect_jumps)
78
    return 0;
79
  while (last(e)) {
80
    e = bro(e);
81
    if (e == nilexp || name(e) >= ass_tag || name(sh(e)) != bothd)
82
      return 0;
83
  };
84
  if (name(bro(e)) == labst_tag)
85
    return bro(e) == lab;
86
  return 0;
87
}
88
 
89
static exp is_jumper
90
    PROTO_N ( (e) )
91
    PROTO_T ( exp e )
92
{
93
  if (name(e) == test_tag || name(e) == goto_tag ||
94
	name(e) == testbit_tag || name(e) == res_tag)
95
    return e;
96
  return nilexp;
97
}
98
 
99
static exp down
100
    PROTO_N ( (e) )
101
    PROTO_T ( exp e )
102
{
103
  if (name(e) == seq_tag)
104
    return down(son(son(e)));
105
  if (name(e) == cond_tag)
106
    return down(son(e));
107
  return e;
108
}
109
 
110
/* next_jump delivers a goto, res, test or testbit exp if this
111
   is certain to be the next thing obeyed after e. nilexp
112
   otherwise.
113
*/
114
static exp next_jump
115
    PROTO_N ( (e) )
116
    PROTO_T ( exp e )
117
{
118
  if (!indirect_jumps)
119
    return nilexp;
120
 
121
  do {
122
    while (last(e)) {
123
      e = bro(e);
124
      if (e == nilexp || name(e) >= goto_tag)
125
        return nilexp;
126
    };
127
    e = bro(e);
128
  } while (name(e) == labst_tag && (e = father(e), name(e)!=rep_tag));
129
 
130
  if (is_jumper(e))
131
    return e;
132
  if (name(e) == seq_tag || name(e) == cond_tag)
133
    return is_jumper(down(e));
134
  if (name(e) == top_tag)
135
    return next_jump(e);
136
  return nilexp;
137
}
138
 
139
/* next_jump delivers a goto, res, test or testbit exp if this
140
   is certain to be the next thing obeyed after e and there is no
141
   other route to the goto (etc.). nilexp otherwise.
142
*/
143
exp short_next_jump
144
    PROTO_N ( (e) )
145
    PROTO_T ( exp e )
146
{
147
  if (!indirect_jumps)
148
    return nilexp;
149
 
150
    while (last(e)) {
151
      e = bro(e);
152
      if (e == nilexp || name(e) >= cond_tag)
153
        return nilexp;
154
    };
155
    e = bro(e);
156
 
157
  if (is_jumper(e))
158
    return e;
159
  if (name(e) == seq_tag || name(e) == cond_tag)
160
    return is_jumper(down(e));
161
  if (name(e) == top_tag)
162
    return short_next_jump(e);
163
  return nilexp;
164
}
165
 
166
exp jump_dest
167
    PROTO_N ( (lab) )
168
    PROTO_T ( exp lab )
169
{
170
  return next_jump(son(lab));
171
}
172
 
173
exp final_dest
174
    PROTO_N ( (lab) )
175
    PROTO_T ( exp lab )
176
{
177
  exp final = lab;
178
  exp temp, ll;
179
  while (name(final) == labst_tag) {
180
    temp = jump_dest(final);
181
    if (temp != nilexp && name(temp) == goto_tag && pt(temp) != final) {
182
      ll = lab;
183
      while (ll != final) {
184
	if (pt(temp) == ll)
185
	  return final;		/* pathological loop */
186
	ll = pt(jump_dest(ll));
187
      }
188
      final = pt(temp);
189
    }
190
    else
191
      break;
192
  };
193
  return final;
194
}
195
 
196
/* delivers 1 iff when a jumps, b also jumps
197
   a and b will be test or testbit
198
*/
199
static int subsumes
200
    PROTO_N ( (a, b) )
201
    PROTO_T ( exp a X exp b )
202
{
203
  if (name(a) == name(b) &&
204
	test_number(a) == test_number(b) &&
205
	eq_exp(son(a), son(b)) &&
206
	eq_exp(bro(son(a)), bro(son(b))))
207
    return 1;
208
  return 0;
209
}
210
 
211
exp final_dest_test
212
    PROTO_N ( (lab, e) )
213
    PROTO_T ( exp lab X exp e )
214
{
215
  exp final = lab;
216
  exp temp, ll;
217
  while (name(final) == labst_tag) {
218
    temp = jump_dest(final);
219
    if (temp == nilexp || final == pt(temp))
220
      return final;
221
    if (name(temp) == goto_tag || (name(temp) == name(e) && subsumes(e, temp))) {
222
      ll = lab;
223
      while (ll != final) {
224
	if (pt(temp) == ll)
225
	  return final;		/* pathological loop */
226
	ll = pt(jump_dest(ll));
227
      }
228
      final = pt(temp);
229
    }
230
    else
231
      break;
232
  };
233
  return final;
234
}
235