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

Contents of /trunk/base/generic/compiler/logical_relation.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, 8 months ago) by johnpye
File MIME type: text/x-chdr
File size: 5423 byte(s)
Adding doxygen 'addtogroup' for Solver, Compiler, Integrator.
1 /*
2 * Logical Relation Data
3 * by Vicente Rico-Ramirez
4 * Version: $Revision: 1.8 $
5 * Version control file: $RCSfile: logical_relation.h,v $
6 * Date last modified: $Date: 1997/07/29 15:52:42 $
7 * Last modified by: $Author: rv2a $
8 *
9 * This file is part of the Ascend Language Interpreter.
10 *
11 * Copyright (C) 1997 Carnegie Mellon University
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 * Logical Relation Data.
30 *
31 * The logical relation term types defined herein should only be
32 * accessed through the operators in logrelation.h.
33 * <pre>
34 * When including logical_relation.h, make sure these files are included:
35 * #include "fractions.h"
36 * #include "compiler.h"
37 * #include "dimen.h"
38 * #include "expr_types.h"
39 * </pre>
40 */
41
42 #ifndef ASC_LOGICAL_RELATION_H
43 #define ASC_LOGICAL_RELATION_H
44
45 /** addtogroup compiler Compiler
46 @{
47 */
48
49 struct LogRelBVar {
50 enum Expr_enum t; /**< type of term */
51 unsigned int flags; /**< flags for future use */
52 unsigned long varnum;
53 };
54
55
56 struct LogRelBoolean {
57 enum Expr_enum t; /**< type of term */
58 unsigned int flags; /**< flags for future use */
59 int bvalue;
60 };
61
62 struct LogRelInteger {
63 enum Expr_enum t; /**< type of term */
64 unsigned int flags; /**< flags for future use */
65 int ivalue;
66 };
67
68 /* operators */
69 struct LogRelSatisfied {
70 enum Expr_enum t; /**< type of term */
71 CONST struct Name *ncond; /**< Name of relation inside CONDITIONAL */
72 unsigned long relnum; /**< number of relation in rel list */
73 double rtol; /**< tolerance */
74 CONST dim_type *dim; /**< units of the relation */
75 unsigned int flags; /**< flags for future use */
76 };
77
78
79 /** unary NOT */
80 struct LogRelUnary {
81 enum Expr_enum t; /**< type of term */
82 unsigned int flags; /**< flags for future use */
83 struct logrel_term *left;
84 };
85
86 /** binary AND, OR */
87 struct LogRelBinary {
88 enum Expr_enum t; /**< type of term */
89 unsigned int flags; /**< flags for future use */
90 struct logrel_term *left;
91 struct logrel_term *right;
92 };
93
94 /** token type designed just as struct Instance */
95 struct logrel_term {
96 enum Expr_enum t; /**< type of term */
97 unsigned int flags; /**< flags for future use. only valid for operator and bvar terms */
98 };
99
100 /**
101 * A union type for sizeof and other sorts.
102 * Not really intended for actual use except in sizeof and array declarations.
103 */
104 union LogRelTermUnion {
105 struct logrel_term anon; /**< anonymous logical relation term type */
106 struct LogRelBVar bvar; /**< boolean vars */
107 struct LogRelBoolean bol; /**< boolean constants */
108 struct LogRelInteger intt; /**< integer for index in set */
109 struct LogRelSatisfied sat; /**< satisfied operator */
110 struct LogRelUnary uni; /**< unary operator NOT */
111 struct LogRelBinary bin; /**< binary operators OR AND */
112 };
113
114 /**
115 * The different types of relation structures that need to
116 * be supported by the relation module.
117 */
118 struct TokenLogRel {
119 unsigned long lhs_len, rhs_len;
120 union LogRelTermUnion *lhs, *rhs; /**< postfix arrays */
121 struct logrel_term *lhs_term, *rhs_term; /**< infix trees */
122 };
123 /*
124 * Under NO CIRCUMSTANCES should you attempt to free any element
125 * of the trees. They share memory with the postfix arrays.
126 * Also you should not dereference the pointers in a logical
127 * relation except by appropriate operators from the header.
128 */
129 /**
130 * The struct relation may be shared by multiple LogRelInstances.
131 */
132 struct logrelation {
133 struct TokenLogRel token; /**< pointer ?? */
134 int logresidual;
135 int lognominal;
136 int logiscond;
137 struct gl_list_t *bvars;
138 struct gl_list_t *satrels;
139 REFCOUNT_T ref_count;
140 enum Expr_enum relop; /**< type of boolean constraint */
141 };
142
143 /* casts to fix things up, should they really be needed. */
144 #define LOGA_TERM(i) ((struct logrel_term *)(i))
145 /* anonymous term */
146 #define LOGBV_TERM(i) ((struct LogRelBVar *)(i))
147 #define LOGBC_TERM(i) ((struct LogRelBoolean *)(i))
148 #define LOGI_TERM(i) ((struct LogRelInteger *)(i))
149 #define LOGS_TERM(i) ((struct LogRelSatisfied *)(i))
150 #define LOGB_TERM(i) ((struct LogRelBinary *)(i))
151 #define LOGU_TERM(i) ((struct LogRelUnary *)(i))
152 #define LOGUNION_TERM(i) ((union LogRelTermUnion *)(i))
153
154 /**
155 * The following define is for people who expect each term
156 * allocated to be individually deallocated and interchangable
157 * to all types of term. It returns a struct relation_term *.
158 * Cast as needed if you must.
159 * Use of individually allocated terms is a really bad idea!
160 */
161 #define LOGTERM_ALLOC LOGA_TERM(ascmalloc(sizeof(union LogRelTermUnion)))
162
163 /* @} */
164
165 #endif /* ASC_LOGICAL_RELATION_H */
166

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