/[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 1699 - (show annotations) (download) (as text)
Sat Jan 5 02:49:48 2008 UTC (12 years, 6 months ago) by jpye
File MIME type: text/x-chdr
File size: 7348 byte(s)
Added operator< to SymChar class (C++).
Added toString method to Dimensions class (C++).
Fixed close-button behaviour in Solver Reporter dialog (Python).
Added Library::getUnits to get list of all units of measurement in use (C++).
Added Library::getRealAtomTypes to get list of all real atomic types (C++).
Removed duplicated class definition for Dimensions in ascpy.i (C++).
Added __str__ to Python wrapping of Dimensions type.
Started working on populating data fields in UnitsDialog (Python).
Default constructor for Dimensions object now creates 'wildcard' dimension.
Cleared contents of library.i (should delete it actually).
Added Type::isFundamental (C++).
Tidied find.h formatting, #includes.

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 by Tom Epperly
23 Created: 1/24/90
24 Last in CVS: $Revision: 1.12 $ $Date: 1998/03/26 20:39:45 $ $Author: ballan $
25 */
26
27 #ifndef ASC_FIND_H
28 #define ASC_FIND_H
29
30 #include "utilities/ascConfig.h"
31 #include "instance_enum.h"
32 #include "expr_types.h"
33
34 /** @addtogroup compiler Compiler
35 @{
36 */
37
38 /**
39 Search error codes.
40 At present, there is a GREAT DEAL of insanity between find_errors and
41 evaluation_error (value_type.h). In particular there is a lot of idiocy
42 mapping undefined_instance <--> undefined_value which is just plain wrong
43 in most cases.
44 */
45 enum find_errors {
46 unmade_instance, /**< Found an unmade instance (NULL child). */
47 undefined_instance, /**< Instance in an expression is unknown child. */
48 impossible_instance, /**< Name cannot possibily exist(real error),often sets. */
49 correct_instance /**< Return value when everything went okay. */
50 };
51
52 /* mmm, nasty global variables... */
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) */#include "expr_types.h"
142
143 #if EVALDEBUG /* version printing file/line when setting globals */
144 extern void SetEvaluationContextF(
145 CONST struct Instance *i
146 # if (EVALDEBUG == 1 || EVALDEBUG == 3)
147 ,char *file, int line
148 # endif
149 );
150 /**< set the evaluation context (mainly for debugging) */
151
152 extern void SetEvaluationForTableF(
153 struct for_table_t *ft
154 # if (EVALDEBUG == 2 || EVALDEBUG == 3)
155 ,char *file, int line
156 # endif
157 );
158 /**< set the evaluation for table (mainly for debugging) */
159
160 #else /* EVALDEBUG */
161
162 extern void SetEvaluationContextF(CONST struct Instance *i);
163 /**< set the evaluation context (mainly for debugging) */
164 extern void SetEvaluationForTableF(struct for_table_t *ft);
165 /**< set the evaluation for table (mainly for debugging) */
166
167 #endif /* EVALDEBUG*/
168
169 extern struct value_t InstanceEvaluateName(CONST struct Name *nptr);
170 /**<
171 This evaluates the name in the context given by EvaluationContext.
172 This must be set before the InstanceEvaluateName call. Note since
173 this is a global variable you cannot evaluate names in more than
174 one context simultaneously.
175
176 If EvaluationForTable is non-NULL, the for table will be checked before
177 the instance tree.
178 */
179
180 extern struct value_t InstanceEvaluateSatisfiedName(
181 CONST struct Name *nptr, double tol
182 );
183 /**<
184 This function is specially to evaluate name of relations or logical
185 relations included in SATISFIED expressions.
186 This evaluates the name in the context given by EvaluationContext.
187 This must be set before the InstanceEvaluateName call. Note since
188 this is a global variable you cannot evaluate names in more than
189 one context simultaneously.
190 If EvaluationForTable is non-NULL, the for table will be checked before
191 the instance tree.
192 */
193
194 extern struct gl_list_t *FindInstances(
195 CONST struct Instance *i,
196 CONST struct Name *n, enum find_errors *err
197 );
198 /**<
199 Return the list of instances specified by n. If this returns NULL,
200 it indicates that it couldn't find the name. Check err to discover why.
201 */
202
203
204 extern struct gl_list_t *FindInstancesFromNames(
205 CONST struct Instance *i,
206 CONST struct gl_list_t *names,
207 enum find_errors *err, unsigned long *errpos
208 );
209 /**<
210 Return the list of instances specified by names. If this returns NULL,
211 it indicates that it couldn't find a name. Check err to discover why
212 and errpos to discover which list element had the problem.
213 Each listed name on input must resolve to a single instance, or
214 the err will be impossible_instance.
215 */
216 /* @} */
217
218 #endif /* ASC_FIND_H */
219

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