/home/doxygen/libascend/compiler/childinfo.h

Go to the documentation of this file.
00001 /*
00002  *  Atom Child Description List
00003  *  by Tom Epperly
00004  *  Version: $Revision: 1.10 $
00005  *  Version control file: $RCSfile: childinfo.h,v $
00006  *  Date last modified: $Date: 1998/02/05 16:35:41 $
00007  *  Last modified by: $Author: ballan $
00008  *
00009  *  This file is part of the Ascend Language Interpreter.
00010  *
00011  *  Copyright (C) 1990, 1993, 1994 Thomas Guthrie Epperly
00012  *
00013  *  The Ascend Language Interpreter is free software; you can redistribute
00014  *  it and/or modify it under the terms of the GNU General Public License as
00015  *  published by the Free Software Foundation; either version 2 of the
00016  *  License, or (at your option) any later version.
00017  *
00018  *  The Ascend Language Interpreter is distributed in hope that it will be
00019  *  useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00021  *  General Public License for more details.
00022  *
00023  *  You should have received a copy of the GNU General Public License
00024  *  along with the program; if not, write to the Free Software Foundation,
00025  *  Inc., 675 Mass Ave, Cambridge, MA 02139 USA.  Check the file named
00026  *  COPYING.
00027  *
00028  *  These routines provide a list for storing descriptions of children of
00029  *  atoms.
00030  */
00031 
00045 #ifndef ASC_CHILDINFO_H
00046 #define ASC_CHILDINFO_H
00047 
00048 #include "dimen.h"
00049 
00055 struct ChildDescR {
00056   double value;
00057   CONST dim_type *dims;
00058 };
00059 
00061 struct ChildDescI {
00062   long value;     
00063 };
00064 
00066 struct ChildDescS{
00067   struct set_t *slist;  
00068   unsigned is_int;      
00069 };
00070 
00072 union ChildDescUnion {
00073   int bvalue;               
00074   struct ChildDescS s;      
00075   struct ChildDescI ivalue; 
00076   struct ChildDescR rvalue; 
00077   symchar *svalue;          
00078 };
00079 
00081 enum ChildDescT {
00082   bad_child,       
00087   real_child,     
00088   integer_child,  
00089   boolean_child,  
00090   set_child,      
00091   symbol_child    
00092 };
00093 
00095 struct ChildDesc {
00096   enum ChildDescT t;      
00097   unsigned assigned;      
00098   union ChildDescUnion u; 
00099 };
00100 
00101 #ifdef NDEBUG
00102 
00103 #define ICDESC(x)
00104 
00105 #define ICDESCPTR(y)
00106 #else
00107 
00112 #define ICDESC(x) CDescInit(&(x))
00113 
00118 #define ICDESCPTR(y) CDescInit(y)
00119 #endif
00120 
00121 extern void CDescInit(struct ChildDesc *c);
00128 extern struct ChildDesc *CreateChildDescArray(unsigned long l);
00139 extern struct ChildDesc *CreateEmptyChildDescArray(void);
00149 extern void DestroyChildDescArray(struct ChildDesc *c,
00150                                   unsigned long l);
00160 #ifdef NDEBUG
00161 #define AssignChildArrayElement(a,n,e) (a)[(n)-1] = (e)
00162 #else
00163 #define AssignChildArrayElement(a,n,e) AssignChildArrayElementF((a),(n),(e))
00164 #endif
00165 
00174 extern void AssignChildArrayElementF(struct ChildDesc *a,
00175                                      unsigned long n,
00176                                      struct ChildDesc e);
00190 #ifdef NDEBUG
00191 #define GetChildArrayElement(a,n) ((a)[n-1])
00192 #else
00193 #define GetChildArrayElement(a,n) GetChildArrayElementF((a),(n))
00194 #endif
00195 
00203 extern struct ChildDesc GetChildArrayElementF(CONST struct ChildDesc *a,
00204                                               unsigned long n);
00216 #ifdef NDEBUG
00217 #define ChildDescType(e) ((e).t)
00218 #else
00219 #define ChildDescType(e) ChildDescTypeF(e)
00220 #endif
00221 
00227 extern enum ChildDescT ChildDescTypeF(struct ChildDesc e);
00237 #ifdef NDEBUG
00238 #define ValueAssigned(e) ((e).assigned)
00239 #else
00240 #define ValueAssigned(e) ValueAssignedF(e)
00241 #endif
00242 
00249 extern int ValueAssignedF(struct ChildDesc e);
00260 #ifdef NDEBUG
00261 #define IntegerDefault(e) ((e).u.ivalue.value)
00262 #else
00263 #define IntegerDefault(e) IntegerDefaultF(e)
00264 #endif
00265 
00273 extern long IntegerDefaultF(struct ChildDesc e);
00284 #ifdef NDEBUG
00285 #define BooleanDefault(e) ((e).u.bvalue)
00286 #else
00287 #define BooleanDefault(e) BooleanDefaultF(e)
00288 #endif
00289 
00297 extern int BooleanDefaultF(struct ChildDesc e);
00308 #ifdef NDEBUG
00309 #define SetDefault(e) ((e).u.s.slist)
00310 #else
00311 #define SetDefault(e) SetDefaultF(e)
00312 #endif
00313 
00321 extern CONST struct set_t *SetDefaultF(struct ChildDesc e);
00332 #ifdef NDEBUG
00333 #define SetIsIntegerSet(e) ((e).u.s.is_int)
00334 #else
00335 #define SetIsIntegerSet(e) SetIsIntegerSetF(e)
00336 #endif
00337 
00344 extern int SetIsIntegerSetF(struct ChildDesc e);
00354 #ifdef NDEBUG
00355 #define SymbolDefault(e) ((e).u.svalue)
00356 #else
00357 #define SymbolDefault(e) SymbolDefaultF(e)
00358 #endif
00359 
00367 extern symchar *SymbolDefaultF(struct ChildDesc e);
00378 #ifdef NDEBUG
00379 #define RealDefaultValue(e) ((e).u.rvalue.value)
00380 #else
00381 #define RealDefaultValue(e) RealDefaultValueF(e)
00382 #endif
00383 
00391 extern double RealDefaultValueF(struct ChildDesc e);
00401 #ifdef NDEBUG
00402 #define RealDimensions(e) ((e).u.rvalue.dims)
00403 #else
00404 #define RealDimensions(e) RealDimensionsF(e)
00405 #endif
00406 
00414 extern CONST dim_type *RealDimensionsF(struct ChildDesc e);
00424 extern struct ChildDesc MakeRealDesc(int assigned,
00425                                      double v,
00426                                      CONST dim_type *dims);
00436 extern struct ChildDesc MakeIntegerDesc(int assigned, long i);
00445 extern struct ChildDesc MakeBooleanDesc(int assigned, int b);
00453 extern struct ChildDesc MakeSetDesc(int assigned, int intset, struct set_t *s);
00463 extern struct ChildDesc MakeSymbolDesc(int assigned, symchar *str);
00472 /* @} */
00473 
00474 #endif  /* ASC_CHILDINFO_H */
00475 

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