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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 74 - (show annotations) (download) (as text)
Fri Dec 2 23:33:32 2005 UTC (18 years, 6 months ago) by jds
File MIME type: text/x-chdr
File size: 9185 byte(s)
Doxygen comment update for a few headers.
1 /*
2 * Type Definition Library
3 * by Tom Epperly
4 * Created: 1/12/90
5 * Version: $Revision: 1.17 $
6 * Version control file: $RCSfile: library.h,v $
7 * Date last modified: $Date: 1998/04/16 00:43:24 $
8 * Last modified by: $Author: ballan $
9 *
10 * This file is part of the Ascend Language Interpreter.
11 *
12 * Copyright (C) 1990, 1993, 1994 Thomas Guthrie Epperly
13 *
14 * The Ascend Language Interpreter is free software; you can redistribute
15 * it and/or modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of the
17 * License, or (at your option) any later version.
18 *
19 * The Ascend Language Interpreter is distributed in hope that it will be
20 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License along
25 * with the program; if not, write to the Free Software Foundation, Inc., 675
26 * Mass Ave, Cambridge, MA 02139 USA. Check the file named COPYING.
27 */
28
29 /** @file
30 * Type Definition Library.
31 *
32 * Implements a type definition library for use by the ASCEND compiler.
33 * Each type encountered during parsing is converted to a TypeDescription
34 * and stored in the main type library maintained by this module.
35 * The type library will only maintain one definition for a given type
36 * name. The library will complain if you try to add two types with the
37 * same name unless it happens when reloading a module.
38 * <pre>
39 * When #including library.h, make sure these files are #included first:
40 * #include "utilities/ascConfig.h"
41 * #include "compiler/compiler.h"
42 * #include "compiler/type_desc.h"
43 * #include "compiler/module.h"
44 * #include "general/list.h"
45 * </pre>
46 */
47
48 #ifndef library_h_seen__
49 #define library_h_seen__
50
51 /** For use in constructing hierarchies. */
52 struct HierarchyNode {
53 struct TypeDescription *desc; /**< The type at this node. */
54 struct gl_list_t *descendents; /**< The list of refinements of desc. */
55 };
56
57 extern void InitializeLibrary(void);
58 /**<
59 * Initializes the library.
60 * This should be called before using any other functions
61 * or globals in this module. Call DestroyLibrary() when
62 * finished with the library.
63 */
64
65 extern void DestroyLibrary(void);
66 /**<
67 * Cleans up after library use.
68 * Do not use any other functions or globals in this module after
69 * using this function until InitializeLibrary() is called.
70 */
71
72 extern struct TypeDescription *FindType(symchar *name);
73 /**<
74 * Finds the type description associated with name.
75 * Returns NULL if unable to locate the type.
76 * Handles NULL input gracefully.
77 *
78 * @param name The type name to look up.
79 * @return The type description having the specified name,
80 * or NULL if none have that name.
81 */
82
83 extern struct TypeDescription *FindRelationType(void);
84 /**<
85 * Finds the type description associated with real relations.
86 * Returns NULL if never defined, which means someone forgot to
87 * load a system.lib equivalent.
88 */
89
90 extern struct TypeDescription *FindLogRelType(void);
91 /**<
92 * Finds the type description associated with logical relations.
93 * Returns NULL if never defined, which means someone forgot to
94 * load a system.lib equivalent.
95 */
96
97 extern struct TypeDescription *FindSetType(void);
98 /**<
99 * Finds the type description associated with set statements.
100 * Returns NULL if never defined, which is an extreme error.
101 */
102
103 extern struct TypeDescription *FindDummyType(void);
104 /**<
105 * Finds the type description associated with unselected statements.
106 * Returns NULL if never defined, which is an extreme error.
107 */
108
109 extern struct TypeDescription *FindWhenType(void);
110 /**<
111 * Finds the type description associated with WHEN statements.
112 * Returns NULL if never defined, which is an extreme error.
113 */
114
115 extern struct TypeDescription *FindExternalType(void);
116 /**<
117 * Finds the type description associated with external statements.
118 * Returns NULL if never defined, which is an extreme error.
119 */
120
121 extern int AddType(struct TypeDescription *desc);
122 /**<
123 * Adds a type to the library.
124 * The type is not added if it is already present in the
125 * type library. Otherwise, the library takes ownership of
126 * desc and adds it to the library.
127 *
128 * @param desc The type to add to the library.
129 * @return Returns 1 if the new type is added and kept,
130 * 0 if it was already present.
131 */
132
133 extern struct gl_list_t *FindFundamentalTypes(void);
134 /**<
135 * Creates a gl_list_t containing pointers to the fundamental
136 * types. Destruction of the returned list (but not it's
137 * contents) is the responsibility of the caller.
138 *
139 * @return A gl_list_t of (struct TypeDescription *) to the
140 * fundamental types.
141 */
142
143 extern struct gl_list_t *Asc_TypeByModule(CONST struct module_t *module);
144 /**<
145 * Builds a list of type names defined in module that are already
146 * present in the main type library. Destruction of the returned
147 * list (but not its contents) is the responsibility of the caller.
148 *
149 * @param module The module to parse for defined type names.
150 * @return A gl_list_t of (symchar *) to the names of types found
151 * both in module and in the main type library.
152 */
153
154 extern struct gl_list_t *TypesThatRefineMe (symchar *name);
155 /**<
156 * Builds a list of type names in the main type library which refine
157 * the type having the specified name. The returned list includes
158 * immediate refinements only, not all of the refinements in a chain
159 * such as a<-b<-c<-d. Given a, only b is included in the list.
160 * This should be an expensive function and could be made more
161 * efficient for certain atomic types. Destruction of the returned
162 * list (but not its contents) is the responsibility of the caller.
163 *
164 * @param name The type name to check for registered refinements.
165 * @return A gl_list_t of (symchar *) to the names of types in the main
166 * type library which refine the specified type.
167 */
168
169 extern struct gl_list_t *AllTypesThatRefineMe_Flat (symchar *name);
170 /**<
171 * Builds a list of all type names in the main type library which
172 * refine the type having the specified name. The returned list
173 * includes all refinements in a chain such as a<-b<-c<-d. Given a,
174 * b, c, and d are all included in the list. This is only slightly
175 * more expensive than TypesThatRefineMe(). For efficiency atoms
176 * and models are handled differently. Destruction of the returned
177 * list (but not its contents) is the responsibility of the caller.
178 *
179 * @param name The type name to check for registered refinements.
180 * @return A gl_list_t of (symchar *) to the names of types in the main
181 * type library which refine the specified type.
182 */
183
184 extern struct HierarchyNode *AllTypesThatRefineMe_Tree (symchar *name);
185 /**<
186 * Builds a tree of HierarchyNodes all types in the main type library
187 * which refine the type having the specified name. This is similar to
188 * AllTypesThatRefineMe_Flat() except that the results are returned in
189 * a HierarchyNodes tree. This is somewhat pricey in terms of the number
190 * of pointer comparisons. For efficiency atoms and models are handled
191 * separately. The first node returned is the node of the type given.
192 * If it is null, the type given was not found. Destruction of the
193 * returned tree is the responsibility of the caller. Use
194 * DestroyHierarchyNode() for this purpose.
195 *
196 * @param name The type name to check for registered refinements.
197 * @return A tree of HierarchyNodes containing the types in the main
198 * type library which refine the specified type.
199 */
200
201 extern void DestroyHierarchyNode(struct HierarchyNode *heir);
202 /**<
203 * Deallocates (recursively) all the memory associated with a
204 * HierarchyNode. Use this function to destroy the tree returned
205 * by AllTypesThatRefineMe_Tree().
206 *
207 * @param heir Head of the HeirarchyNode tree to destroy.
208 */
209
210 extern int IsTypeRefined(CONST struct TypeDescription *desc);
211 /**<
212 * Check whether the specified type is refined by any other type in
213 * the main type library.
214 *
215 * @param desc The type to check for refinements.
216 * @return Returns 1 if desc is refined, 0 otherwise.
217 */
218
219 extern struct gl_list_t *DefinitionList(void);
220 /**<
221 * Makes a sorted list of all registered definitions.
222 * In the case of there being two versions of a given type,
223 * the latest version is used. This doesn't include array type
224 * definitions. The user is responsible for destroying the
225 * returned list (but not its content).
226 *
227 * @return A gl_list_t of (struct TypeDescription *) containing
228 * the sorted types.
229 */
230
231 extern unsigned int CheckFundamental(symchar *f);
232 /**<
233 * Checks whether string f is a fundamental type name.
234 * f must be from the symbol table (i.e. not an externally-defined
235 * character string).
236 *
237 * @param f The string to check.
238 * @return Returns 1 if f is a fundamental type name, 0 if not.
239 */
240
241 #endif /* library_h_seen__ */
242

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