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

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