Subversion Repositories tendra.SVN

Rev

Rev 2 | Go to most recent revision | Details | Compare with Previous | 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
/*** rule-mutate.c --- Compute mutation effects.
32
 *
33
 ** Author: Steve Folkes <smf@hermes.mod.uk>
34
 *
35
 *** Commentary:
36
 *
37
 * This file implements the functions that compute the propogation of mutation
38
 * effects from actions that mutate their parameters.
39
 *
40
 *** Change Log:
41
 * $Log: rule-mutate.c,v $
42
 * Revision 1.1.1.1  1998/01/17  15:57:47  release
43
 * First version to be checked into rolling release.
44
 *
45
 * Revision 1.2  1994/12/15  09:58:48  smf
46
 * Brought into line with OSSG C Coding Standards Document, as per
47
 * "CR94_178.sid+tld-update".
48
 *
49
 * Revision 1.1.1.1  1994/07/25  16:04:40  smf
50
 * Initial import of SID 1.8 non shared files.
51
 *
52
**/
53
 
54
/****************************************************************************/
55
 
56
#include "rule.h"
57
#include "action.h"
58
#include "types.h"
59
 
60
/*--------------------------------------------------------------------------*/
61
 
62
static void			rule_compute_mutations_3
63
	PROTO_S ((EntryP, GenericP));
64
 
65
static void
66
rule_compute_mutations_4 PROTO_N ((rule, alt, from_rule))
67
			 PROTO_T (RuleP rule X
68
				  AltP  alt X
69
				  RuleP from_rule)
70
{
71
    BoolT  propogate = FALSE;
72
    ItemP  item;
73
 
74
    for (item = alt_item_head (alt); item; item = item_next (item)) {
75
	switch (item_type (item)) EXHAUSTIVE {
76
	  case ET_RULE:
77
	    if (entry_get_rule (item_entry (item)) == from_rule) {
78
		if (types_compute_mutations (rule_param (rule),
79
					     item_param (item),
80
					     rule_param (from_rule))) {
81
		    propogate = TRUE;
82
		}
83
	    }
84
	    break;
85
	  case ET_ACTION:
86
	  case ET_PREDICATE:
87
	  case ET_RENAME:
88
	  case ET_BASIC:
89
	    break;
90
	  case ET_NON_LOCAL:
91
	  case ET_TYPE:
92
	  case ET_NAME:
93
	    UNREACHED;
94
	}
95
    }
96
    if (propogate) {
97
	entry_list_iter (rule_reverse_list (rule), rule_compute_mutations_3,
98
			 (GenericP) rule);
99
    }
100
}
101
 
102
static void
103
rule_compute_mutations_3 PROTO_N ((entry, gclosure))
104
			 PROTO_T (EntryP   entry X
105
				  GenericP gclosure)
106
{
107
    RuleP rule      = entry_get_rule (entry);
108
    RuleP from_rule = (RuleP) gclosure;
109
    AltP  alt;
110
 
111
    if ((alt = rule_get_handler (rule)) != NIL (AltP)) {
112
	rule_compute_mutations_4 (rule, alt, from_rule);
113
    }
114
    for (alt = rule_alt_head (rule); alt; alt = alt_next (alt)) {
115
	rule_compute_mutations_4 (rule, alt, from_rule);
116
    }
117
}
118
 
119
static void
120
rule_compute_mutations_2 PROTO_N ((rule, alt))
121
			 PROTO_T (RuleP rule X
122
				  AltP  alt)
123
{
124
    BoolT   propogate = FALSE;
125
    ItemP   item;
126
    ActionP action;
127
 
128
    for (item = alt_item_head (alt); item; item = item_next (item)) {
129
	switch (item_type (item)) EXHAUSTIVE {
130
	  case ET_ACTION:
131
	  case ET_PREDICATE:
132
	    action = entry_get_action (item_entry (item));
133
	    if (types_compute_mutations (rule_param (rule), item_param (item),
134
					 action_param (action))) {
135
		propogate = TRUE;
136
	    }
137
	    break;
138
	  case ET_RENAME:
139
	  case ET_BASIC:
140
	  case ET_RULE:
141
	    break;
142
	  case ET_NON_LOCAL:
143
	  case ET_TYPE:
144
	  case ET_NAME:
145
	    UNREACHED;
146
	}
147
	if (types_compute_assign_mutations (rule_param (rule),
148
					    item_param (item))) {
149
	    propogate = TRUE;
150
	}
151
    }
152
    if (propogate) {
153
	entry_list_iter (rule_reverse_list (rule), rule_compute_mutations_3,
154
			 (GenericP) rule);
155
    }
156
}
157
 
158
static void
159
rule_compute_mutations_1 PROTO_N ((rule))
160
			 PROTO_T (RuleP rule)
161
{
162
    AltP alt;
163
 
164
    if ((alt = rule_get_handler (rule)) != NIL (AltP)) {
165
	rule_compute_mutations_2 (rule, alt);
166
    }
167
    for (alt = rule_alt_head (rule); alt; alt = alt_next (alt)) {
168
	rule_compute_mutations_2 (rule, alt);
169
    }
170
}
171
 
172
/*--------------------------------------------------------------------------*/
173
 
174
void
175
rule_compute_mutations PROTO_N ((entry, gclosure))
176
		       PROTO_T (EntryP   entry X
177
				GenericP gclosure)
178
{
179
    UNUSED (gclosure);
180
    if (entry_is_rule (entry)) {
181
	RuleP rule = entry_get_rule (entry);
182
 
183
	rule_compute_mutations_1 (rule);
184
    }
185
}
186
 
187
/*
188
 * Local variables(smf):
189
 * eval: (include::add-path-entry "../os-interface" "../library")
190
 * eval: (include::add-path-entry "../generated")
191
 * end:
192
**/