/[ascend]/trunk/base/generic/compiler/linkinst.h
ViewVC logotype

Diff of /trunk/base/generic/compiler/linkinst.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 53 by ben.allan, Sun Dec 26 20:06:01 2004 UTC revision 54 by jds, Tue Aug 2 11:20:09 2005 UTC
# Line 1  Line 1 
1  /**<  /*
2   *  Ascend Instance Tree Link Management   *  Ascend Instance Tree Link Management
3   *  by Tom Epperly & Ben Allan   *  by Tom Epperly & Ben Allan
4   *  8/16/89   *  8/16/89
# Line 29  Line 29 
29   *  COPYING.   *  COPYING.
30   */   */
31    
32    /** @file
33     *  Ascend Instance Tree Link Management.
34     *  <pre>
35     *  When #including linkinst.h, make sure these files are #included first:
36     *         #include "utilities/ascConfig.h"
37     *         #include "instance_enum.h"
38     *  </pre>
39     */
40    
41  #ifndef __LINKINST_H_SEEN__  #ifndef __LINKINST_H_SEEN__
42  #define __LINKINST_H_SEEN__  #define __LINKINST_H_SEEN__
43    
44  extern void ChangeRelationPointers(struct Instance *, struct Instance *,  extern void ChangeRelationPointers(struct Instance *rel,
45                                     struct Instance *);                                     struct Instance *old,
46  /**<                                     struct Instance *new);
47   *  ChangeRelationPointers(rel,old,new)  /**<
48     *  <!--  ChangeRelationPointers(rel,old,new)                          -->
49   *  This procedure changes all references of "old" in relation   *  This procedure changes all references of "old" in relation
50   *  instance rel to "new".   *  instance rel to "new".
51   */   */
52    
53  extern void ChangeLogRelPointers(struct Instance *,  extern void ChangeLogRelPointers(struct Instance *lrel,
54                                   struct Instance *,struct Instance *);                                   struct Instance *old,
55  /**<                                   struct Instance *new);
56   *  ChangeLogRelPointers(lrel,old,new)  /**<
57     *  <!--  ChangeLogRelPointers(lrel,old,new)                           -->
58   *  This procedure changes all references of "old" in logical relation   *  This procedure changes all references of "old" in logical relation
59   *  instance lrel to "new".   *  instance lrel to "new".
60   */   */
61    
62  extern void ChangeWhenPointers(struct Instance *,  extern void ChangeWhenPointers(struct Instance *when,
63                                 struct Instance *, struct Instance *);                                 struct Instance *old,
64  /**<                                 struct Instance *new);
65   *  ChangeWhenPointers(when,old,new)  /**<
66     *  <!--  ChangeWhenPointers(when,old,new)                             -->
67   *  This procedure changes all references of "old" in when   *  This procedure changes all references of "old" in when
68   *  instance when to "new".   *  instance when to "new".
69   */   */
70    
71  extern void ChangeParent(struct Instance *, struct Instance *,  extern void ChangeParent(struct Instance *parent,
72                           struct Instance *);                           struct Instance *oldchild,
73  /**<                           struct Instance *newchild);
74   *  ChangeParent(parent,oldchild,newchild);  /**<
75   *  struct Instance *parent;   *  <!--  ChangeParent(parent,oldchild,newchild);                      -->
76   *  struct Instance *oldchild;   *  <!--  struct Instance *parent;                                     -->
77   *  struct Instance *newchild;   *  <!--  struct Instance *oldchild;                                   -->
78     *  <!--  struct Instance *newchild;                                   -->
79   *  Tell a parent to point to newchild instead of pointing to oldchild   *  Tell a parent to point to newchild instead of pointing to oldchild
80   */   */
81    
82  extern void ReDirectParents(struct Instance *, struct Instance *);  extern void ReDirectParents(struct Instance *old, struct Instance *new);
83  /**<  /**<
84   *  ReDirectParents(old,new);   *  <!--  ReDirectParents(old,new);                                    -->
85   *  struct Instance *old;   *  <!--  struct Instance *old;                                        -->
86   *  struct Instance *new;   *  <!--  struct Instance *new;                                        -->
87   *  Tell to all the parent of the oldchild, to point to newchild rather   *  Tell to all the parent of the oldchild, to point to newchild rather
88   *  than to point to oldchild.   *  than to point to oldchild.
89   */   */
90    
91  extern void ReDirectChildren(struct Instance *, struct Instance *);  extern void ReDirectChildren(struct Instance *old, struct Instance *new);
92  /**<  /**<
93   *  ReDirectChildren(old,new);   *  <!--  ReDirectChildren(old,new);                                   -->
94   *  struct Instance *old;   *  <!--  struct Instance *old;                                        -->
95   *  struct Instance *new;   *  <!--  struct Instance *new;                                        -->
96   *  Look at all of the children of the instance new; if old is one of   *  Look at all of the children of the instance new; if old is one of
97   *  their parents, delete the parent old and add the parent new.   *  their parents, delete the parent old and add the parent new.
98   */   */
99    
100  extern void ReorderChildrenPtrs(struct Instance **,  extern void ReorderChildrenPtrs(struct Instance **c,
101                                  CONST ChildListPtr,                                  CONST ChildListPtr old,
102                                  CONST ChildListPtr,                                  CONST ChildListPtr new,
103                                  unsigned long int, unsigned long int);                                  unsigned long int oldlen,
104  /**<                                  unsigned long int newlen);
105   *  ReorderChildrenPtrs(c,old,new,oldlen,newlen);  /**<
106   *  struct Instance **c;   *  <!--  ReorderChildrenPtrs(c,old,new,oldlen,newlen);                -->
107   *  CONST ChildListPtr old;   *  <!--  struct Instance **c;                                         -->
108   *  CONST ChildListPtr new;   *  <!--  CONST ChildListPtr old;                                      -->
109   *  unsigned long int oldlen;   *  <!--  CONST ChildListPtr new;                                      -->
110   *  unsigned long int newlen;   *  <!--  unsigned long int oldlen;                                    -->
111     *  <!--  unsigned long int newlen;                                    -->
112   *   *
113   *  This expands the old child pointers packed into a MODEL   *  This expands the old child pointers packed into a MODEL
114   *  struct into the new list, starting at the tail of the instance   *  struct into the new list, starting at the tail of the instance
# Line 103  extern void ReorderChildrenPtrs(struct I Line 117  extern void ReorderChildrenPtrs(struct I
117   *  on up toward the top of the child list which comes right   *  on up toward the top of the child list which comes right
118   *  after the end of the struct ModelInstance defined in the header   *  after the end of the struct ModelInstance defined in the header
119   *  instance_types.h   *  instance_types.h
  *  
120   */   */
121    
122  extern void FixCliques(struct Instance *, struct Instance *);  extern void FixCliques(struct Instance *old, struct Instance *new);
123  /**<  /**<
124   *  FixCliques(old,new);   *  <!--  FixCliques(old,new);                                         -->
125   *  struct Instance *old;   *  <!--  struct Instance *old;                                        -->
126   *  struct Instance *new;   *  <!--  struct Instance *new;                                        -->
127   *   *
128   *  Substitute the old instance in a clique by the new instance. It is   *  Substitute the old instance in a clique by the new instance. It is
129   *  required after merging or refinement an instance, task which implies   *  required after merging or refinement an instance, task which implies
130   *  some instance is going to be destroyed.   *  some instance is going to be destroyed.
131   */   */
132    
133  extern void FixRelations(struct RealAtomInstance *, struct RealAtomInstance *);  extern void FixRelations(struct RealAtomInstance *old, struct RealAtomInstance *new);
134  /**<  /**<
135   *  FixRelations(old,new);   *  <!--  FixRelations(old,new);                                       -->
136   *  struct RealAtomInstance *new;   *  <!--  struct RealAtomInstance *new;                                -->
137   *  struct RealAtomInstance *old;   *  <!--  struct RealAtomInstance *old;                                -->
138   *   *
139   *  This is called to tell relations about a change in variable location   *  This is called to tell relations about a change in variable location
140   *  e.g. If two atoms are merged, point all the relations that know about   *  e.g. If two atoms are merged, point all the relations that know about
141   *  ATOM old to ATOM new.   *  ATOM old to ATOM new.<br><br>
142   *   *
143   *  A RealAtomInstance contains a gl_list of relations. Such a gl_list tells   *  A RealAtomInstance contains a gl_list of relations. Such a gl_list tells
144   *  us in which relations this real atom appears. Basically it is a list   *  us in which relations this real atom appears. Basically it is a list
# Line 140  extern void FixRelations(struct RealAtom Line 153  extern void FixRelations(struct RealAtom
153   *  of relations instances rather than a list of when instances.   *  of relations instances rather than a list of when instances.
154   */   */
155    
156  extern void FixLogRelations(struct Instance *,  extern void FixLogRelations(struct Instance *old, struct Instance *new);
157                              struct Instance *);  /**<
158  /**<   *  <!--  FixLogRelations(old,new);                                    -->
159   *  FixLogRelations(old,new);   *  <!--  struct Instance *new;                                        -->
160   *  struct Instance *new;   *  <!--  struct Instance *old;                                        -->
  *  struct Instance *old;  
161   *   *
162   *  This is called to tell logrelations about a change in the location of a   *  This is called to tell logrelations about a change in the location of a
163   *  variable or a relation referenced in the logrelation. For example:   *  variable or a relation referenced in the logrelation. For example:
# Line 157  extern void FixLogRelations(struct Insta Line 169  extern void FixLogRelations(struct Insta
169   *  case (and in many other involving merging and refinement) the logrelation   *  case (and in many other involving merging and refinement) the logrelation
170   *  using such a variable must be notified about the change. This is the   *  using such a variable must be notified about the change. This is the
171   *  goal of this function. Similar situation applies for REL_INST and   *  goal of this function. Similar situation applies for REL_INST and
172   *  LREL_INST.   *  LREL_INST.<br><br>
173   *   *
174   *  It will vist the list of logrelations of the instance and it will tell   *  It will vist the list of logrelations of the instance and it will tell
175   *  them to use the  the "new" instance instead of the "old" instance.   *  them to use the  the "new" instance instead of the "old" instance.<br><br>
176   *   *
177   *  For an explanation about how to handle different   *  For an explanation about how to handle different
178   *  cases, see the function FixWhens below, thinking of course in list   *  cases, see the function FixWhens below, thinking of course in list
179   *  of logrelations instances rather than a list of when instances.   *  of logrelations instances rather than a list of when instances.
180   */   */
181    
182  extern void FixWhens(struct Instance *, struct Instance *);  extern void FixWhens(struct Instance *old, struct Instance *new);
183  /**<  /**<
184   *  FixWhens(old,new);   *  <!--  FixWhens(old,new);                                           -->
185   *  struct Instance *new;   *  <!--  struct Instance *new;                                        -->
186   *  struct Instance *old;   *  <!--  struct Instance *old;                                        -->
187   *   *
188   *  A WHEN instance contains a list of variables and a list of CASEs. Also,   *  A WHEN instance contains a list of variables and a list of CASEs. Also,
189   *  each CASE contains a list of model and relation instances to be   *  each CASE contains a list of model and relation instances to be
190   *  used if such a CASE applies. In the list of variables, instances   *  used if such a CASE applies. In the list of variables, instances
191   *  allowed are   *  allowed are
192   *         BOOLEAN_ATOM_INST,   *         - BOOLEAN_ATOM_INST,
193   *         INTEGER_ATOM_INST,   *         - INTEGER_ATOM_INST,
194   *         SYMBOL_ATOM_INST,   *         - SYMBOL_ATOM_INST,
195   *         BOOLEAN_CONSTANT_INST,   *         - BOOLEAN_CONSTANT_INST,
196   *         INTEGER_CONSTANT_INST, and   *         - INTEGER_CONSTANT_INST, and
197   *         SYMBOL_CONSTANT_INST.   *         - SYMBOL_CONSTANT_INST.
198     *
199   *  In the list of instances of each CASE, we allow   *  In the list of instances of each CASE, we allow
200   *         MODEL_INST,   *         - MODEL_INST,
201   *         REL_INST,   *         - REL_INST,
202   *         LREL_INST,   *         - LREL_INST,
203   *         WHEN_INST.   *         - WHEN_INST.
204   *   *
205   *  For purposes of Merging and refining, an instance must know if it   *  For purposes of Merging and refining, an instance must know if it
206   *  appears in some of the lists of instances of a WHEN instance. That is,   *  appears in some of the lists of instances of a WHEN instance. That is,
207   *  all the instances listed above contain a when field, which is a   *  all the instances listed above contain a when field, which is a
208   *  gl_list. This gl_list tells us which and how many WHEN statements use   *  gl_list. This gl_list tells us which and how many WHEN statements use
209   *  the instance.   *  the instance.<br><br>
210     *
211   *  So, in the process of merging two instances , for example,  we keep   *  So, in the process of merging two instances , for example,  we keep
212   *  only one of the instances (the most refined) and destroy the other.   *  only one of the instances (the most refined) and destroy the other.
213   *  If the instance that we are going to destroy is used in some   *  If the instance that we are going to destroy is used in some
214   *  WHEN statement, then we should tell those WHEN about the change.   *  WHEN statement, then we should tell those WHEN about the change.
215   *  That is what this function does. It takes two instance structures   *  That is what this function does. It takes two instance structures
216   *  as argument, old and new. Then,   *  as argument, old and new. Then,
217   *  i) it goes through the list of whens of the NEW instance and tells   *  -# It goes through the list of whens of the NEW instance and tells
218   *  the WHENs contained in such a list that they must point to the instance   *     the WHENs contained in such a list that they must point to the instance
219   *  new instead of the instance old.   *     new instead of the instance old.
220   *  ii) Actually there are some modifications to the previous case i)   *  -# Actually there are some modifications to the previous case.
221   *  The function can also go through the list of whens of the   *     The function can also go through the list of whens of the
222   *  OLD instance and tell the WHENs contained in such a list that   *     OLD instance and tell the WHENs contained in such a list that
223   *  they must point to the instance new instead of the instance old.   *     they must point to the instance new instead of the instance old.
224   *   *
225   *  So, which list of when we are going to visit depends in what we want.   *  So, which list of when we are going to visit depends in what we want.
226   *  What is always the same however, is the fact that the WHEN has to   *  What is always the same however, is the fact that the WHEN has to
227   *  point the instance new rather than the instance old at the end of   *  point the instance new rather than the instance old at the end of
228   *  the process, since the instance old is, in general, going to be   *  the process, since the instance old is, in general, going to be
229   *  destroyed.   *  destroyed.<br><br>
230   *   *
231   *  The following cases were anticipated:   *  The following cases were anticipated:
232   *  1) If the list of whens of the instance new is NULL, this list will   *  -# If the list of whens of the instance new is NULL, this list will
233   *  be set equal to the list of whens of the old instance and then   *     be set equal to the list of whens of the old instance and then
234   *  the list of whens of the instance new should be visited.   *     the list of whens of the instance new should be visited.
235   *  This may happen when we are refining ( booleans, integer, symbols   *     This may happen when we are refining ( booleans, integer, symbols
236   *  or relations, but not models)   *     or relations, but not models)
237   *   *
238   *  2) If the list of when of new and old is the same, it does not   *  -# If the list of when of new and old is the same, it does not
239   *  matter which list of when we have to visit, we visit the list   *     matter which list of when we have to visit, we visit the list
240   *  of whens of the new instance. This may happen when we are   *     of whens of the new instance. This may happen when we are
241   *  merging instances of the same type.   *     merging instances of the same type.
242   *   *
243   *  3) If the list of whens of the new instance is not null and is   *  -# If the list of whens of the new instance is not null and is
244   *  different to the list of whens of the old instance, we will   *     different to the list of whens of the old instance, we will
245   *  visit the list of whens of the old instance, perform the   *     visit the list of whens of the old instance, perform the
246   *  change of the pointers (new instead of old), and then enlarge   *     change of the pointers (new instead of old), and then enlarge
247   *  the list of whens of the new instance with the WHENs of the   *     the list of whens of the new instance with the WHENs of the
248   *  old instance. Example   *     old instance. Example
249   *   *  <pre>
250   *  old->whens contains   when1, when2  (also when1 and when2 point to old)   *  old->whens contains   when1, when2  (also when1 and when2 point to old)
251   *  new->whens contains   when3, when4  (also when3 and when4 point to new)   *  new->whens contains   when3, when4  (also when3 and when4 point to new)
252   *   *
# Line 247  extern void FixWhens(struct Instance *, Line 261  extern void FixWhens(struct Instance *,
261   *   *
262   *  This may happen when we are merging two instances, one more   *  This may happen when we are merging two instances, one more
263   *  refined than another. Remeber again, old is going to be destroyed.   *  refined than another. Remeber again, old is going to be destroyed.
264     *  </pre>
265   */   */
266    
267  extern void FixWhensForRefinement(struct Instance *, struct Instance *);  extern void FixWhensForRefinement(struct Instance *old, struct Instance *new);
268  /**<  /**<
269   *  FixWhensForRefinement(old,new);   *  <!--  FixWhensForRefinement(old,new);                              -->
270   *  struct Instance *new;   *  <!--  struct Instance *new;                                        -->
271   *  struct Instance *old;   *  <!--  struct Instance *old;                                        -->
272   *   *
273   *  This function is almost equal to the previous function, the difference   *  This function is almost equal to the previous function, the difference
274   *  is that it is specific for the refinement of a MODEL. In such a case,   *  is that it is specific for the refinement of a MODEL. In such a case,
# Line 264  extern void FixWhensForRefinement(struct Line 279  extern void FixWhensForRefinement(struct
279   *  of whens of the old instance (which is NULL).That is precisely   *  of whens of the old instance (which is NULL).That is precisely
280   *  the reason for which we wrote this other function, we want to visit   *  the reason for which we wrote this other function, we want to visit
281   *  the list of whens of the new instance instead.   *  the list of whens of the new instance instead.
  *  
282   */   */
283    
284  #endif  #endif  /* __LINKINST_H_SEEN__ */
285  /**< __LINKINST_H_SEEN__ */  

Legend:
Removed from v.53  
changed lines
  Added in v.54

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22