/home/doxygen/libascend/compiler/expr_types.h

00001 /*  ASCEND modelling environment
00002     Copyright (C) 2006, 2007 Carnegie Mellon University
00003     Copyright (C) 1990, 1993, 1994 Thomas Guthrie Epperly
00004 
00005     This program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation; either version 2, or (at your option)
00008     any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program; if not, write to the Free Software
00017     Foundation, Inc., 59 Temple Place - Suite 330,
00018     Boston, MA 02111-1307, USA.
00019 *//*
00020     @file
00021     Name, set and expr type definitions
00022 
00023     @todo Complete documentation of types.h.
00024 
00025     Renamed from 'types.h' -- JP, 21 Jun 2006.
00026 *//*
00027     by Tom Epperly
00028     July 31, 1989
00029     Last in CVS $Revision: 1.17 $ $Date: 1998/03/25 00:32:31 $ $Author: ballan $
00030 */
00031 
00032 #ifndef ASC_TYPES_H
00033 #define ASC_TYPES_H
00034 
00039 #include <limits.h>
00040 #include "compiler.h"
00041 #include "dimen.h"
00042 #include <general/list.h>
00043 #include "functype.h"
00044 
00045 /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
00046  * Please see usage notes at top of Expr_enum before modifying it.
00047  * In particular, if you mess with it, make sure the defines still work.
00048  */
00049 #define NUM_EXPR_ENUMS 44
00050 
00062 enum Expr_enum {
00063   /* shouldn't be seen, but just in case */
00064   e_nop     = 0,     
00067   e_undefined   = 1, 
00068   e_glassbox    = 2, 
00069   e_blackbox    = 3, 
00070   e_opcode  = 4,   
00071   e_token   = 5,     
00073   e_zero    = 6,     
00074   e_real    = 7,     
00075   e_int     = 8,     
00076 /* two types only to be seen in fully compiled token relations, and not
00077   yet seen at all. These are the types for RelationRealConst terms and
00078   RelationIntegerConst terms.
00079   e_realconst  = 7a,
00080   e_intconst  = 8a,
00081 */
00082   e_var     = 9,     
00084   e_uminus  = 10,  
00085   e_func    = 11,    
00087   e_plus    = 12,    
00088   e_minus   = 13,    
00089   e_times   = 14,    
00090   e_divide  = 15,  
00091   e_power   = 16,    
00092   e_ipower  = 17,  
00093   /* Don't mess with the ordering of the above items */
00094 
00095   /* Boolean Relations  */
00096   e_bol_token,
00097 
00098   /* relational operators, at present somewhat overloaded. may be in any kind*/
00099   e_notequal,     
00100   e_equal,        
00101   e_less,         
00102   e_greater,      
00103   e_lesseq,       
00104   e_greatereq,    
00105   e_maximize,     
00106   e_minimize,     
00107   e_boolean_eq,   
00108   e_boolean_neq,  
00110   /* ALL following are never encountered in compiled real relations */
00111   e_boolean,      
00112 /*e_var_bool,      unimplemented boolean variable */
00113   e_or,           
00114   e_and,          
00115   e_not,          
00116   e_satisfied,    
00118   /* ALL following are never encountered in compiled bool relations */
00119   e_subexpr,      
00120   e_const,        
00121   e_par,          
00122   e_sum,          
00123   e_prod,         
00125   e_symbol,       
00126 /*e_var_sym unimplemented symbol variable */
00127   e_set,          
00128   e_in,           
00129   e_st,           
00130   e_card,         
00131   e_choice,       
00132   e_union,        
00133   e_inter,        
00135   /* miscellany */
00136   e_qstring       
00137 };
00138 
00139 #define TOK_SCALAR_LOW    e_zero
00140 #define TOK_SCALAR_HIGH   e_var
00141 #define TOK_CONSTANT_LOW  e_zero
00142 #define TOK_CONSTANT_HIGH e_int
00143 #define TOK_XARY_LOW      e_uminus
00144 #define TOK_XARY_HIGH     e_ipower
00145 #define TOK_BINARY_LOW    e_plus
00146 #define TOK_BINARY_HIGH   e_ipower
00147 #define TOK_UNARY_LOW     e_uminus
00148 #define TOK_UNARY_HIGH    e_func
00149 #define TOK_REAL_REL_LOW  e_zero
00150 #define TOK_REAL_REL_HIGH e_ipower
00151 #define TOK_REL_TYPE_LOW  e_glassbox
00152 #define TOK_REL_TYPE_HIGH e_token
00153 
00154 struct ExprReal {
00155   double rvalue;
00156   CONST dim_type *dimensions;
00157 };
00158 
00159 struct SatisfiedExpr {
00160   struct ExprReal ser;
00161   struct Name *sen;
00162 };
00163 
00164 union ExprUnion {
00165   struct Name *nptr;
00166   long ivalue;
00167   symchar *sym_ptr;   
00168   struct Set *s;
00169   struct ExprReal r;
00170   CONST struct Func *fptr;
00171   unsigned bvalue;    
00172   struct SatisfiedExpr se;
00173 };
00174 
00175 struct Expr {
00176   struct Expr *next;
00177   enum Expr_enum t;
00178   union ExprUnion v;
00179 };
00180 
00181 struct Range {
00182   struct Expr *lower,*upper;
00183 };
00184 
00185 union SetUnion {
00186   struct Expr *e;   
00187   struct Range r;   
00188 };
00189 
00190 struct Set {
00191   struct Set *next;
00192   unsigned range;   
00193   union SetUnion val;
00194   unsigned long ref_count;
00195 };
00196 
00197 union NameUnion {
00198   symchar *id;      
00199   struct Set *s;
00200   int attribute;    
00201 };
00202 
00203 struct Name {
00204   /* this element info */
00205   unsigned int bits;
00221 #define NAMEBIT_IDTY    0x1
00222 #define NAMEBIT_ATTR    0x2
00223 #define NAMEBIT_CHAT    0x4
00224 #define NAMEBIT_AUTO    0x8
00225   struct Name *next;
00226   union NameUnion val;
00227 };
00228 
00238 #define MAXINTREAL 100000
00239 
00240 /* @} */
00241 
00242 #endif /* ASC_TYPES_H */
00243 

Generated on Thu Jul 17 04:00:10 2008 for libascend by  doxygen 1.5.1