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

Contents of /trunk/base/generic/compiler/pending.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1063 - (show annotations) (download) (as text)
Sun Jan 7 07:54:06 2007 UTC (17 years, 9 months ago) by johnpye
File MIME type: text/x-chdr
File size: 7279 byte(s)
Changed ASC_DLLSPEC(TYPE) to ASC_DLLSPEC TYPE, because it was causing havoc with doxygen and ctags.
1 /* ASCEND modelling environment
2 Copyright (C) 1990, 1993, 1994 Thomas Guthrie Epperly
3 Copyright (C) 2006 Carnegie Mellon University
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19 *//**
20 @file
21 Ascend Pending Instance Routines.
22
23 The pending list is implemented as a doubly linked list.
24 Clients of this module should NOT access the internals of this list.
25 They should not access next and prev in particular.
26 Note that only complex types (models, arrays) and not atomic ones
27 (atoms, relations, constants) should ever be put on the list.
28 No client should ever free a struct pending_t *. That is our job.
29
30 Requires:
31 #include <stdio.h>
32 #include "utilities/ascConfig.h"
33 #include "instance_enum.h"
34 #include "compiler.h"
35 *//*
36 by Tom Epperly
37 Created: 1/24/90
38 Version: $Revision: 1.6 $
39 Version control file: $RCSfile: pending.h,v $
40 Date last modified: $Date: 1997/07/18 12:32:40 $
41 Last modified by: $Author: mthomas $
42 */
43
44 #ifndef ASC_PENDING_H
45 #define ASC_PENDING_H
46
47 #include <utilities/ascConfig.h>
48
49 struct pending_t {
50 struct pending_t *next, *prev;
51 struct Instance *inst;
52 };
53
54 extern void InitPendingPool(void);
55 /**<
56 * <!-- InitPendingPool(); -->
57 * Sets up pending structure data management
58 * before anything can be built, ideally at startup time.
59 * Do not call it again unless DestroyPendingPool is called first.
60 * If insufficient memory to compile anything at all, does exit(2).
61 */
62
63 extern void DestroyPendingPool(void);
64 /**<
65 * <!-- DestroyPendingPool(); -->
66 * Destroy pending structure data management. This must be called to
67 * clean up before shutting down ASCEND.
68 * Do not call this function while there are any instances actively
69 * pending unless you are shutting down.
70 * Do not attempt to instantiate anything after you call this unless you
71 * have recalled InitPendingPool.
72 */
73
74 extern void ReportPendingPool(FILE *f);
75 /**<
76 * <!-- ReportPendingPool(f); -->
77 * <!-- FILE *f; -->
78 * Reports on the pending pool to f.
79 */
80
81 #ifdef NDEBUG
82 #define PendingInstance(pt) ((pt)->inst)
83 #else
84 #define PendingInstance(pt) PendingInstanceF(pt)
85 #endif
86 /**<
87 * Returns the instance part of a pending_t structure.
88 * @param pt CONST struct pending_t*, pending instance to query.
89 * @return Returns the instance as a <code>struct Instance*</code>.
90 * @see PendingInstanceF()
91 */
92 extern struct Instance *PendingInstanceF(CONST struct pending_t *pt);
93 /**<
94 * <!-- macro PendingInstance(pt) -->
95 * <!-- struct Instance PendingInstanceF(pt) -->
96 * <!-- const struct pending_t *pt; -->
97 *
98 * <!-- This returns the instance part of a pending_t structure. -->
99 * Implementation function for PendingInstance(). Do not call this
100 * function directly - use PendingInstance() instead.
101 */
102
103 extern void ClearList(void);
104 /**<
105 * <!-- void ClearList() -->
106 * Prepare an empty list. This gets rid of any remaining list and makes
107 * a new empty list ready for use.
108 * Causes any instance remaining in the list to forget that they are
109 * pending.
110 */
111
112 extern unsigned long NumberPending(void);
113 /**<
114 * <!-- unsigned long NumberPending() -->
115 * Return the number of instances in the pending instance list.
116 */
117
118 extern void AddBelow(struct pending_t *pt, struct Instance *i);
119 /**<
120 * <!-- void AddBelow(pt,i) -->
121 * <!-- struct pending_t *pt; -->
122 * <!-- struct Instance *i; -->
123 * This adds i into the pending list just below the entry pt. If pt
124 * is NULL, this adds i to the top.
125 * i should be a MODEL_INST or ARRAY_*_INST
126 */
127
128 extern void AddToEnd(struct Instance *i);
129 /**<
130 * <!-- void AddToEnd(i) -->
131 * <!-- struct Instance *i; -->
132 * Insert instance i at the end of the pending instance list.
133 * i should be a MODEL_INST or ARRAY_*_INST
134 */
135
136 extern void RemoveInstance(struct Instance *i);
137 /**<
138 * <!-- void RemoveInstance(i) -->
139 * <!-- struct Instance *i; -->
140 * Remove instance i from the pending instance list if it is in it.
141 * i should be a MODEL_INST or ARRAY_*_INST
142 */
143
144 extern void PendingInstanceRealloced(struct Instance *old_inst, struct Instance *new_inst);
145 /**<
146 * <!-- void PendingInstanceRealloced(old,new) -->
147 * <!-- struct Instance *old,*new; -->
148 * Change references to old to new.
149 * Assumes the old instance will never be used by anyone at all ever again.
150 * new should be a MODEL_INST or ARRAY_*_INST recently realloced.
151 */
152
153 extern int InstanceInList(struct Instance *i);
154 /**<
155 * <!-- int InstanceInList(i) -->
156 * <!-- struct Instance *i; -->
157 * Return true iff i is in the list.
158 * i should be a MODEL_INST or ARRAY_*_INST as any other kind cannot be
159 * pending.
160 */
161
162 extern struct pending_t *TopEntry(void);
163 /**<
164 * <!-- struct pending_t *TopEntry() -->
165 * Return the top item in the pending list.
166 */
167
168 extern struct pending_t *ListEntry(unsigned long n);
169 /**<
170 * <!-- struct pending_t *ListEntry(n) -->
171 * <!-- unsigned long n; -->
172 * Return the n'th entry in the list. This returns NULL if n is less
173 * than one or greater than the length of the list.
174 */
175
176 extern struct pending_t *BottomEntry(void);
177 /**<
178 * <!-- struct pending_t *BottomEntry() -->
179 * Return the bottom item in the pending list.
180 */
181
182 extern void MoveToBottom(struct pending_t *pt);
183 /**<
184 * <!-- void MoveToBottom(struct pending_t *pt) -->
185 * Move the item pt to the bottom of the list.
186 */
187
188 ASC_DLLSPEC unsigned long NumberPendingInstances(struct Instance *i);
189 /**<
190 * <!-- unsigned long NumberPendingInstances; -->
191 * <!-- struct Instance *i; -->
192 * Visits the Instance Tree seatch for instances with pending statements.
193 * Increments g_unresolved_count for each pending instance found.
194 * Returns the total count of pendings.
195 */
196
197 #endif /* ASC_PENDING_H */
198

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