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

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