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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1066 - (show annotations) (download) (as text)
Sun Jan 7 10:02:41 2007 UTC (17 years, 9 months ago) by johnpye
File MIME type: text/x-chdr
File size: 7407 byte(s)
Adding doxygen 'addtogroup' for Solver, Compiler, Integrator.
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 *//** @file
20 Relation Output Routines.
21
22 Requires:
23 #include <stdio.h>
24 #include "utilities/ascConfig.h"
25 #include "instance_enum.h"
26 #include "fractions.h"
27 #include "compiler.h"
28 #include "dimen.h"
29 #include "expr_types.h"
30 #include "relation_type.h"
31 #include "exprs.h"
32 #include "relation.h"
33 *//*
34 by Tom Epperly
35 Created: 2/8/90
36 Version: $Revision: 1.9 $
37 Date last modified: $Date: 1998/01/27 11:00:18 $
38 Last modified by: $Author: ballan $
39 */
40
41 #ifndef ASC_RELATION_IO_H
42 #define ASC_RELATION_IO_H
43
44 /** addtogroup compiler Compiler
45 @{
46 */
47
48 #include <utilities/ascConfig.h>
49
50 /**<
51 * This enum controls the format of function names and other
52 * minor operator variations in the supported languages.
53 *
54 * Add others here as desired and then update RelationWriteString.
55 */
56 enum rel_lang_format {
57 relio_ascend,
58 relio_C
59 };
60
61 typedef char * (*WRSNameFunc)(CONST struct relation *,unsigned long,void *);
62 /**<
63 * For use with WriteRelationString() and token relations.
64 * Func should return a name for varnum in tokenrel.
65 * Userdata will be that which the caller of WriteRelationString provides.
66 * We do not keep the name returned or free it -- it is the func's
67 * responsibility to track this memory.
68 */
69
70 struct RXNameData{
71 char *prefix;
72 int *indices;
73 char *suffix;
74 };
75
76 extern char *RelationVarXName(CONST struct relation *r,
77 unsigned long varnum,
78 struct RXNameData *rxndata);
79 /**<
80 * Returns names like x23.
81 * Returns a character string (which we own, not the caller, but it won't
82 * change until we're called again) with the name of the
83 * the variable in "Prefix%luSuffix" format. prefix and suffix are limited
84 * to 110 characters and are taken from rxndata.
85 * If indices is not NULL, then the number printed will be
86 * (unsigned long)indices[varnum] (remember: varnums go from 1 and
87 * C arrays from 0!) else number printed will be varnum.
88 * If prefix is NULL, "x" will be assumed and suffix will be assumed "".
89 * If prefix is not NULL, suffix must not be NULL.
90 * r is ignored entirely.<br><br>
91 *
92 * This function is compatible with WriteRelationString().
93 */
94
95 extern int NeedParen(enum Expr_enum parent, enum Expr_enum child, int rhs);
96 /**<
97 * Given a unary or binary expression, will determine whether, the
98 * child expression needs parentheses. "rhs" tells if we are looking
99 * at the left or right side of a binary token.
100 * E.g x ^ (2/y), would need parens exactly as shown to give the
101 * correct precedence.
102 * This would be called as : NeedParen(e_power,e_divide,right);
103 * and would return nonzero.
104 */
105
106 extern void WriteRelation(FILE *f,
107 CONST struct Instance *relinst,
108 CONST struct Instance *ref);
109 /**<
110 * Write the relation in infix to the file indicated.
111 * This function comfortably handles all the relation types.
112 * Variables are written with names relative to ref.
113 */
114
115 ASC_DLLSPEC char*WriteRelationString(
116 CONST struct Instance *relinst,
117 CONST struct Instance *ref,
118 WRSNameFunc func,
119 void *userdata,
120 enum rel_lang_format lang,
121 int *lenptr
122 );
123 /**<
124 * Write the token relation in infix to a char using the
125 * variable names as generated by func.
126 * If func is NULL, name will be written in ascend form
127 * from ref to the variable.
128 * This function comfortably handles all the relation types,
129 * but glassbox and blackbox do not use func or userdata.
130 * lenptr contains the length of the string returned, or -1
131 * if string is NULL. If lenptr is NULL, it is ignored.
132 */
133
134 extern void WriteRelationPostfix(FILE *f,
135 CONST struct Instance *relinst,
136 CONST struct Instance *ref);
137 /**<
138 * Write the relation in postfix to the file indicated.
139 * This function at the moment is only applicable to token relations.
140 */
141
142 ASC_DLLSPEC char *WriteRelationPostfixString(CONST struct Instance *relinst,
143 CONST struct Instance *ref);
144 /**<
145 * Write the relation in postfix to the file indicated.
146 * This function at the moment is only applicable to token relations.
147 */
148
149 extern void Infix_WriteRelation(FILE *f,
150 CONST struct Instance *r,
151 CONST struct Instance *ref);
152 /**<
153 * Write the relation in infixe to the file indicated.
154 * This function uses the "new" infix representation of relations.
155 * This function at the moment is only applicable to token relations.
156 */
157
158 extern void WriteRelationsInTree(FILE *f, struct Instance *relinst);
159 /**<
160 * Search for relations in an instance and write them to the
161 * file given in various formats.
162 */
163
164 extern void WriteRelationsInList(FILE *f, struct gl_list_t *l);
165 /**<
166 * Search for relations in an instance list and write them to the
167 * file given in various formats.
168 */
169
170 extern void SaveRelationVariables(FILE *fp, CONST struct relation *r);
171 /**<
172 * Given a relation will save its variable list in the ASCEND condensed
173 * format.
174 */
175
176 extern void SaveGlassBoxRelation(FILE *fp, CONST struct Instance *relinst);
177 /**<
178 * Given a glassbox relation will save it in the ASCEND condensed
179 * format.
180 */
181
182 extern void SaveTokenRelation(FILE *fp, CONST struct Instance *relinst);
183 /**<
184 * Given a token relation will save it in the ASCEND condensed
185 * format.
186 */
187
188 extern void SaveReln2GlassBox(FILE *fp,
189 CONST struct Instance *relinst,
190 char *prefix,
191 unsigned long index_);
192 /**<
193 * Given a relation will save it and perform conversion to the glassbox
194 * format.
195 */
196
197 extern int ConversionIsValid(enum Expr_enum old, enum Expr_enum new_enum);
198 /**<
199 * Given a relation format will return TRUE if conversion to another
200 * format is valid. It assumes that new is a valid relation type.
201 */
202
203 extern void RelationIO_init_pool(void);
204 /**<
205 * starts memory recycle. Do not call twice before stopping recycle.
206 */
207
208 extern void RelationIO_destroy_pool(void);
209 /**<
210 * Stops memory recycle. Do not call while ANY Expr are outstanding.
211 */
212
213 extern void RelationIO_report_pool(void);
214 /**<
215 * Write the pool report to ASCERR for the ppe pool.
216 */
217
218 extern void WriteNamesInList(FILE *f, struct gl_list_t *l, CONST char *sep);
219 /**<
220 * Write each element of l as a struct Name * on file separated by sep.
221 */
222
223 extern void WriteNamesInList2D(FILE *f, struct gl_list_t *l, CONST char *sep, CONST char *sep2);
224 /**<
225 * Write each element of l as a list of struct Name * on file separated by sep2.
226 */
227
228 /* @} */
229
230 #endif /* ASC_RELATION_IO_H */
231

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