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

Diff of /trunk/base/generic/compiler/proc.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   *  Procedure Data Structure   *  Procedure Data Structure
3   *  by Tom Epperly   *  by Tom Epperly
4   *  Created: 1/10/90   *  Created: 1/10/90
# Line 26  Line 26 
26   *  Mass Ave, Cambridge, MA 02139 USA.  Check the file named COPYING.   *  Mass Ave, Cambridge, MA 02139 USA.  Check the file named COPYING.
27   */   */
28    
29  /**<  /** @file
30     *  Procedure Data Structure.
31     *  <pre>
32   *  When #including proc.h, make sure these files are #included first:   *  When #including proc.h, make sure these files are #included first:
33     *         #include "utilities/ascConfig.h"
34   *         #include "compiler.h"   *         #include "compiler.h"
35     *         #include"list.h"
36     *         #include"slist.h"
37     *  </pre>
38   */   */
39    
   
   
40  #ifndef __PROC_H_SEEN__  #ifndef __PROC_H_SEEN__
41  #define __PROC_H_SEEN__  #define __PROC_H_SEEN__
 /**< requires  
 # #include"compiler.h"  
 # #include"list.h"  
 # #include"slist.h"  
 */  
42    
43  struct InitProcedure {  struct InitProcedure {
44    symchar *name;        /**< procedure's name */    symchar *name;                /**< procedure's name */
45    struct StatementList *slist;  /**< statement list */    struct StatementList *slist;  /**< statement list */
46    long int parse_id;            /**< parse id of type desc with which this is defined */    long int parse_id;            /**< parse id of type desc with which this is defined
47                                  /**< 0 if method is not yet associated */                                       0 if method is not yet associated */
48  };  };
49    
50  extern struct InitProcedure *CreateProcedure(symchar *,  extern struct InitProcedure *CreateProcedure(symchar *name,
51            struct StatementList *);                                               struct StatementList *stats);
52  /**<  /**<
53   *  struct InitProcedure *CreateProcedure(name,stats)   *  <!--  struct InitProcedure *CreateProcedure(name,stats)            -->
54   *  symchar *name;   *  <!--  symchar *name;                                               -->
55   *  struct StatementList *stats;   *  <!--  struct StatementList *stats;                                 -->
56   *  Create a procedure data structure with name and stats.   *  Create a procedure data structure with name and stats.
57   */   */
58    
59  extern struct InitProcedure *CopyProcedure(struct InitProcedure *);  extern struct InitProcedure *CopyProcedure(struct InitProcedure *p);
60  /**<  /**<
61   *  struct InitProcedure *CopyProcedure(p)   *  <!--  struct InitProcedure *CopyProcedure(p)                       -->
62   *  struct InitProcedure *p;   *  <!--  struct InitProcedure *p;                                     -->
63   *  Make a copy of procedure p, but this copy should not be modified.   *  Make a copy of procedure p, but this copy should not be modified.
64   *  If you want to change the structure, use CopyProcToModify.  Use   *  If you want to change the structure, use CopyProcToModify.  Use
65   *  DestroyProcedure when you are done with it.   *  DestroyProcedure when you are done with it.
66   */   */
67    
68  extern struct InitProcedure *CopyProcToModify(struct InitProcedure *);  extern struct InitProcedure *CopyProcToModify(struct InitProcedure *p);
69  /**<  /**<
70   *  struct InitProcedure *CopyProcToModify(p)   *  <!--  struct InitProcedure *CopyProcToModify(p)                    -->
71   *  struct InitProcedure *p;   *  <!--  struct InitProcedure *p;                                     -->
72   *  Make a copy, but this copy can be changed.   *  Make a copy, but this copy can be changed.
73   */   */
74    
75  extern struct gl_list_t *MergeProcedureLists(struct gl_list_t *,  extern struct gl_list_t *MergeProcedureLists(struct gl_list_t *old,
76                                               struct gl_list_t *);                                               struct gl_list_t *new);
77  /**<  /**<
78   *  plr = MergeProcedureLists(old,new);   *  <!--  plr = MergeProcedureLists(old,new);                          -->
79   *  struct gl_list_t *plr, *old, *new;   *  <!--  struct gl_list_t *plr, *old, *new;                           -->
  *  old or new may be NULL.  
80   *  Merges the lists of (struct InitProcedure *) given into a third list,   *  Merges the lists of (struct InitProcedure *) given into a third list,
81   *  plr.   *  plr.
82   *  new, if it exists, is destroyed because we move the contents to plr.   *  new, if it exists, is destroyed because we move the contents to plr.
83   *  old is assumed to belong to someone else and is left alone.   *  old is assumed to belong to someone else and is left alone.
84   *  The result is sorted with CmpProcs.   *  old or new may be NULL.
85     *  The result is sorted with CmpProcs.<br><br>
86   *   *
87   * This is where method inheritance rules occur. We keep all the   *  This is where method inheritance rules occur. We keep all the
88   * methods from the new in result, then we search for any method in   *  methods from the new in result, then we search for any method in
89   * the old list which does not have an identically named   *  the old list which does not have an identically named
90   * counterpart in the result list and add it to the result.   *  counterpart in the result list and add it to the result.
91   * Methods in the old result which have be redefined in the new   *  Methods in the old result which have be redefined in the new
92   * list given are thereby ignored and overridden.   *  list given are thereby ignored and overridden.
93   */   */
94    
95  extern struct gl_list_t *GetUniversalProcedureList(void);  extern struct gl_list_t *GetUniversalProcedureList(void);
96  /**<  /**<
97   * Returns the list of methods defined for all MODELs   * Returns the list of methods defined for all MODELs
98   * unless they redefine the methods themselves.   * unless they redefine the methods themselves.
99   */   */
100    
101  extern void SetUniversalProcedureList(struct gl_list_t *);  extern void SetUniversalProcedureList(struct gl_list_t *l);
102  /**<  /**<
103   * Sets the list of procedures defined for all MODELs.   * Sets the list of procedures defined for all MODELs.
104   * If a UPL already exists, it will be destroyed unless it   * If a UPL already exists, it will be destroyed unless it
105   * is the same. If the same, it is resorted.   * is the same. If the same, it is resorted.
106   */   */
107    
108  extern void DestroyProcedure(struct InitProcedure *);  extern void DestroyProcedure(struct InitProcedure *p);
109  /**<  /**<
110   *  void DestroyProcedure(p)   *  <!--  void DestroyProcedure(p)                                     -->
111   *  struct InitProcedure *p;   *  <!--  struct InitProcedure *p;                                     -->
112   *  Destroy this reference to p.  This won't necessary destroy all the parts   *  Destroy this reference to p.  This won't necessary destroy all the parts
113   *  of p.   *  of p.
114   */   */
115    
116  extern void DestroyProcedureList(struct gl_list_t *);  extern void DestroyProcedureList(struct gl_list_t *pl);
117  /**<  /**<
118   *  void DestroyProcedureList(pl)   *  <!--  void DestroyProcedureList(pl)                                -->
119   *  struct gl_list_t *pl contain pointers to   *  <!--  struct gl_list_t *pl contain pointers to                     -->
120   *  struct InitProcedure *p   *  <!--  struct InitProcedure *p                                      -->
121   *  Destroy this reference to p.  This won't necessary destroy all the parts   *  Destroy this reference to p.  This won't necessary destroy all the parts
122   *  of each p unless the parts have no other references. The gl_list is   *  of each p unless the parts have no other references. The gl_list is
123   *  destroyed as are all the p in it.   *  destroyed as are all the p in it.
124   *  Handles NULL input gracefully.   *  Handles NULL input gracefully.
125   */   */
126    
127  extern int CompareProcedureLists(struct gl_list_t *,struct gl_list_t *,  extern int CompareProcedureLists(struct gl_list_t *pl1,
128                                   unsigned long int *);                                   struct gl_list_t *pl2 ,
129  /**<                                   unsigned long int *n);
130   *  CompareProcedureLists(pl1,pl2,&n)  /**<
131   *  struct gl_list_t *pl1, *pl2 contain pointers to   *  <!--  CompareProcedureLists(pl1,pl2,&n)                            -->
132   *  struct InitProcedure *p.   *  <!--  struct gl_list_t *pl1, *pl2 contain pointers to              -->
133   *  unsigned long n;   *  <!--  struct InitProcedure *p.                                     -->
134     *  <!--  unsigned long n;                                             -->
135   *  Returns 0 if pl1,pl2 semantically equivalent, 1 if not.   *  Returns 0 if pl1,pl2 semantically equivalent, 1 if not.
136   *  If return is 1, n contains the index of the first different   *  If return is 1, n contains the index of the first different
137   *  procedure.   *  procedure.
138   */     */
139    
140  #ifdef NDEBUG  #ifdef NDEBUG
141  #define ProcName(p) ((p)->name)  #define ProcName(p) ((p)->name)
142  #else  #else
143  #define ProcName(p) ProcNameF(p)  #define ProcName(p) ProcNameF(p)
144  #endif  #endif
145  extern symchar *ProcNameF(CONST struct InitProcedure *);  /**<
 /**<  
  *  macro ProcName(p)  
  *  symchar *ProcNameF(p)  
  *  const struct InitProcedure *p;  
146   *  Return the name part of a procedure structure.   *  Return the name part of a procedure structure.
147     *  @param p CONST struct InitProcedure*, procedure to query.
148     *  @return name as a symchar*.
149     *  @see ProcNameF()
150     */
151    extern symchar *ProcNameF(CONST struct InitProcedure *p);
152    /**<
153     *  <!--  macro ProcName(p)                                            -->
154     *  <!--  symchar *ProcNameF(p)                                        -->
155     *  <!--  const struct InitProcedure *p;                               -->
156     *  <!--  Return the name part of a procedure structure.               -->
157     *  Implementation function for ProcName().  Do not call this
158     *  function directly - use ProcName() instead.
159   */   */
160    
161  #ifdef NDEBUG  #ifdef NDEBUG
# Line 155  extern symchar *ProcNameF(CONST struct I Line 163  extern symchar *ProcNameF(CONST struct I
163  #else  #else
164  #define ProcStatementList(p) ProcStatementListF(p)  #define ProcStatementList(p) ProcStatementListF(p)
165  #endif  #endif
166  extern struct StatementList *ProcStatementListF(CONST struct InitProcedure *);  /**<
 /**<  
  *  struct StatementList *ProcStatementListF(p)  
  *  const struct InitProcedure *p;  
167   *  Return the statement list part of the procedure structure.   *  Return the statement list part of the procedure structure.
168     *  @param p CONST struct InitProcedure*, procedure to query.
169     *  @return Statement list as a struct StatementList*.
170     *  @see ProcStatementListF()
171     */
172    extern struct StatementList *ProcStatementListF(CONST struct InitProcedure *p);
173    /**<
174     *  <!--  struct StatementList *ProcStatementListF(p)                  -->
175     *  <!--  const struct InitProcedure *p;                               -->
176     *  <!--  Return the statement list part of the procedure structure.   -->
177     *  Implementation function for ProcStatementList().  Do not call this
178     *  function directly - use ProcStatementList() instead.
179   */   */
180    
181  #ifdef NDEBUG  #ifdef NDEBUG
# Line 167  extern struct StatementList *ProcStateme Line 183  extern struct StatementList *ProcStateme
183  #else  #else
184  #define GetProcParseId(p) GetProcParseIdF(p)  #define GetProcParseId(p) GetProcParseIdF(p)
185  #endif  #endif
186  extern long GetProcParseIdF(CONST struct InitProcedure *);  /**<
187  /**<   *  Return the parse id of the type which originally defined this
  *  id = GetProcParseIdF(p);  
  *  const struct InitProcedure *p;  
  *  long id;  
  *  Return the parse id of the type which originally defined this  
188   *  procedure. This may be a copy of that procedure and not the   *  procedure. This may be a copy of that procedure and not the
189   *  original, but this is of no significance.   *  original, but this is of no significance.
190     *  @param p CONST struct InitProcedure*, procedure to query.
191     *  @return Id as a long.
192     *  @see GetProcParseIdF()
193     */
194    extern long GetProcParseIdF(CONST struct InitProcedure *p);
195    /**<
196     *  <!--  id = GetProcParseIdF(p);                                     -->
197     *  <!--  const struct InitProcedure *p;                               -->
198     *  <!--  long id;                                                     -->
199     *  <!--  Return the parse id of the type which originally defined this-->
200     *  <!--  procedure. This may be a copy of that procedure and not the  -->
201     *  <!--  original, but this is of no significance.                    -->
202     *  Implementation function for GetProcParseId().  Do not call this
203     *  function directly - use GetProcParseId() instead.
204   */   */
205    
206  #ifdef NDEBUG  #ifdef NDEBUG
# Line 182  extern long GetProcParseIdF(CONST struct Line 208  extern long GetProcParseIdF(CONST struct
208  #else  #else
209  #define SetProcParseId(p,id) SetProcParseIdF((p),(id))  #define SetProcParseId(p,id) SetProcParseIdF((p),(id))
210  #endif  #endif
211  extern void SetProcParseIdF(struct InitProcedure *,long);  /**<
 /**<  
  *  SetProcParseIdF(p,id);  
  *  const struct InitProcedure *p;  
  *  long id.  
212   *  Sets the parse id of the procedure. The wisdom of this move   *  Sets the parse id of the procedure. The wisdom of this move
213   *  is not investigated. The rules should be:   *  is not investigated. The rules should be:
214   *  Procs normally get id's at the type desc creation step once   *  Procs normally get id's at the type desc creation step once
# Line 196  extern void SetProcParseIdF(struct InitP Line 218  extern void SetProcParseIdF(struct InitP
218   *  in a type, all the refiners of that type which contain an   *  in a type, all the refiners of that type which contain an
219   *  inherited copy of the method also get replaced and this id   *  inherited copy of the method also get replaced and this id
220   *  helps us figure out which method was inherited efficiently.   *  helps us figure out which method was inherited efficiently.
221   */   *  @param p  CONST struct InitProcedure*, procedure to query.
222     *  @param id long, new parse id.
223  extern int CmpProcs(CONST struct InitProcedure *,CONST struct InitProcedure *);   *  @return No return value.
224  /**<   *  @see SetProcParseIdF()
225   *  int CmpProcs(p1,p2)   */
226   *  const struct InitProcedure *p1,*p2;  extern void SetProcParseIdF(struct InitProcedure *p, long id);
227    /**<
228     *  <!--  SetProcParseIdF(p,id);                                       -->
229     *  <!--  const struct InitProcedure *p;                               -->
230     *  <!--  long id.                                                     -->
231     *  <!--  Sets the parse id of the procedure. The wisdom of this move  -->
232     *  <!--  is not investigated. The rules should be:                    -->
233     *  <!--  Procs normally get id's at the type desc creation step once  -->
234     *  <!--  parseid is known. When a proc is inherited (by copy) the copy         -->
235     *  <!--  retains the id of the original. If a method is added after the        -->
236     *  <!--  type's creation, it should get that types id. If a method is replaced -->
237     *  <!--  in a type, all the refiners of that type which contain an    -->
238     *  <!--  inherited copy of the method also get replaced and this id   -->
239     *  <!--  helps us figure out which method was inherited efficiently.  -->
240     *  Implementation function for SetProcParseId().  Do not call this
241     *  function directly - use SetProcParseId() instead.
242     */
243    
244    extern int CmpProcs(CONST struct InitProcedure *p1, CONST struct InitProcedure *p2);
245    /**<
246     *  <!--  int CmpProcs(p1,p2)                                          -->
247     *  <!--  const struct InitProcedure *p1,*p2;                          -->
248   *  Compare the two procedures to provide an ordering for them.   *  Compare the two procedures to provide an ordering for them.
249   *  Simply alphabetizing.   *  Simply alphabetizing.
250   */   */
251  #endif /**< __PROC_H_SEEN__ */  
252    #endif  /* __PROC_H_SEEN__ */
253    

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

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