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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 768 - (show annotations) (download) (as text)
Thu Jul 13 07:39:30 2006 UTC (14 years ago) by johnpye
File MIME type: text/x-chdr
File size: 7235 byte(s)
Tidying up, comments only.
1 /* ASCEND modelling environment
2 Copyright (C) 2006 Carnegie Mellon University
3 Copyright (C) 1990, 1993, 1994 Thomas Guthrie Epperly
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 Ascend Instance Tree Search Routines.
21
22 Requires:
23 #include "utilities/ascConfig.h"
24 #include "fractions.h"
25 #include "compiler.h"
26 #include "instance_enum.h"
27 #include "dimen.h"
28 #include "expr_types.h"
29 *//*
30 by Tom Epperly
31 Created: 1/24/90
32 Last in CVS: $Revision: 1.12 $ $Date: 1998/03/26 20:39:45 $ $Author: ballan $
33 */
34
35 #ifndef ASC_FIND_H
36 #define ASC_FIND_H
37
38 #include <compiler/value_type.h>
39
40 /**
41 * Search error codes.
42 * At present, there is a GREAT DEAL of insanity between find_errors and
43 * evaluation_error (value_type.h). In particular there is a lot of idiocy
44 * mapping undefined_instance <--> undefined_value which is just plain wrong
45 * in most cases.
46 */
47 enum find_errors {
48 unmade_instance, /**< Found an unmade instance (NULL child). */
49 undefined_instance, /**< Unstance in an expression is unknown child. */
50 impossible_instance, /**< Name cannot possibily exist(real error),often sets. */
51 correct_instance /**< Return value when everything went okay. */
52 };
53
54 extern int ListMode;
55 /**<
56 * Tells whether to evaluate a set strictly as a set i.e no order,
57 * or as a list, i.e., with order important.
58 */
59
60 extern int EvaluatingSets;
61 /**<
62 * Tells whether the evaluation of a set is in place. Used for marking
63 * atoms as mutable or not.
64 */
65
66 extern int g_DeclarativeContext;
67 /**<
68 * Tells whether declarative processing, the default = 0 , is in effect,
69 * or procedural processing as when doing initializations.
70 * Access this varible only by GetDeclarativeContext() and
71 * SetDeclarativeContext() below.
72 */
73
74 #define FINDEBUG 0
75 #if (FINDEBUG==0)
76 # define GetDeclarativeContext() g_DeclarativeContext
77 /**< retrieve the declarative context */
78 # define SetDeclarativeContext(n) g_DeclarativeContext = (n)
79 /**< set the declarative context */
80 #else
81 # define GetDeclarativeContext() GetDeclarativeContextF()
82 /** retrieve the declarative context */
83 extern int GetDeclarativeContextF(void);
84 /**< retrieve the declarative context (for debugging) */
85 # define SetDeclarativeContext(n) SetDeclarativeContextF((n),__FILE__,__LINE__)
86 /**< set the declarative context */
87 extern void SetDeclarativeContextF(int value, char *file, int line);
88 /**< set the declarative context (for debugging) */
89 #endif
90
91 extern CONST struct Instance *g_EvaluationContext;
92 /**<
93 * Global variable used throughout semantic analysis to
94 * indicate context of evaluation. Do Not reference this
95 * directly, but use GetEvaluationContext() and
96 * SetEvaluationContext() instead.
97 */
98
99 extern struct for_table_t *g_EvaluationForTable;
100 /**<
101 * Global variable used throughout semantic analysis to
102 * indicate context of evaluation. Do Not reference this
103 * directly, but use GetEvaluationForTable() and
104 * SetEvaluationForTable() instead.
105 */
106
107 #ifndef NDEBUG
108 # define EVALDEBUG 0 /**< 1 = contextnoisy, 2 = fornoisy, 3 = both */
109 # define GetEvaluationContext() GetEvaluationContextF()
110 # define GetEvaluationForTable() GetEvaluationForTableF()
111 # if EVALDEBUG
112 # if (EVALDEBUG == 1 || EVALDEBUG == 3)
113 # define SetEvaluationContext(i) SetEvaluationContextF((i),__FILE__,__LINE__)
114 # else
115 # define SetEvaluationContext(i) SetEvaluationContextF(i)
116 # endif
117 # if (EVALDEBUG == 2 || EVALDEBUG == 3)
118 # define SetEvaluationForTable(ft) SetEvaluationForTableF((ft),__FILE__,__LINE__)
119 # else
120 # define SetEvaluationForTable(ft) SetEvaluationForTableF(ft)
121 # endif
122 # else
123 # define SetEvaluationContext(i) SetEvaluationContextF(i)
124 # define SetEvaluationForTable(ft) SetEvaluationForTableF(ft)
125 # endif
126 #else
127 # define GetEvaluationContext() g_EvaluationContext
128 # define SetEvaluationContext(i) g_EvaluationContext = (i)
129 # define GetEvaluationForTable() g_EvaluationForTable
130 # define SetEvaluationForTable(ft) g_EvaluationForTable = (ft)
131 #endif
132
133 /*
134 * Wrappers mainly for break point purposes of g_EvaluationContext
135 * and g_EvaluationForTable.
136 */
137 extern struct Instance *GetEvaluationContextF(void);
138 /**< retrieve the evaluation context (mainly for debugging) */
139
140 extern struct for_table_t *GetEvaluationForTableF(void);
141 /**< retrieve the evaluation for table (mainly for debugging) */
142
143 #if EVALDEBUG /* version printing file/line when setting globals */
144 extern void SetEvaluationContextF(CONST struct Instance *i
145 #if (EVALDEBUG == 1 || EVALDEBUG == 3)
146 ,char *file, int line
147 #endif /* evaldebug 13 */
148 );
149 /**< set the evaluation context (mainly for debugging) */
150
151 extern void SetEvaluationForTableF(struct for_table_t *ft
152 #if (EVALDEBUG == 2 || EVALDEBUG == 3)
153 ,char *file, int line
154 #endif /* evaldebug 23 */
155 );
156 /**< set the evaluation for table (mainly for debugging) */
157
158 #else /* evaldebug */
159 extern void SetEvaluationContextF(CONST struct Instance *i);
160 /**< set the evaluation context (mainly for debugging) */
161 extern void SetEvaluationForTableF(struct for_table_t *ft);
162 /**< set the evaluation for table (mainly for debugging) */
163 #endif /* evaldebug*/
164
165 extern struct value_t InstanceEvaluateName(CONST struct Name *nptr);
166 /**<
167 * This evaluates the name in the context given by EvaluationContext.
168 * This must be set before the InstanceEvaluateName call. Note since
169 * this is a global variable you cannot evaluate names in more than
170 * one context simultaneously.
171 *
172 * If EvaluationForTable is non-NULL, the for table will be checked before
173 * the instance tree.
174 */
175
176 extern struct value_t InstanceEvaluateSatisfiedName(CONST struct Name *nptr,
177 double tol);
178 /**<
179 * This function is specially to evaluate name of relations or logical
180 * relations included in SATISFIED expressions.
181 * This evaluates the name in the context given by EvaluationContext.
182 * This must be set before the InstanceEvaluateName call. Note since
183 * this is a global variable you cannot evaluate names in more than
184 * one context simultaneously.
185 * If EvaluationForTable is non-NULL, the for table will be checked before
186 * the instance tree.
187 */
188
189 extern struct gl_list_t *FindInstances(CONST struct Instance *i,
190 CONST struct Name *n,
191 enum find_errors *err);
192 /**<
193 * Return the list of instances specified by n. If this returns NULL,
194 * it indicates that it couldn't find the name. Check err to discover why.
195 */
196
197 #endif /* ASC_FIND_H */
198

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