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

Annotation of /trunk/base/generic/compiler/instmacro.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1066 - (hide annotations) (download) (as text)
Sun Jan 7 10:02:41 2007 UTC (17 years, 9 months ago) by johnpye
File MIME type: text/x-chdr
File size: 7573 byte(s)
Adding doxygen 'addtogroup' for Solver, Compiler, Integrator.
1 jds 54 /*
2 aw0a 1 * Ascend Instance Tree Type Implementation Macros
3     * by Tom Epperly & Ben Allan
4     * 9/3/89
5     * Version: $Revision: 1.7 $
6     * Version control file: $RCSfile: instmacro.h,v $
7     * Date last modified: $Date: 1997/07/18 12:30:46 $
8     * Last modified by: $Author: mthomas $
9     *
10     * This file is part of the Ascend Language Interpreter.
11     *
12     * Copyright 1996 Bejamin Allan
13     * based on instance.c
14     * Copyright (C) 1990, 1993, 1994 Thomas Guthrie Epperly
15     *
16     * The Ascend Language Interpreter is free software; you can redistribute
17     * it and/or modify it under the terms of the GNU General Public License as
18     * published by the Free Software Foundation; either version 2 of the
19     * License, or (at your option) any later version.
20     *
21     * The Ascend Language Interpreter is distributed in hope that it will be
22     * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
23     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24     * General Public License for more details.
25     *
26     * You should have received a copy of the GNU General Public License
27     * along with the program; if not, write to the Free Software Foundation,
28     * Inc., 675 Mass Ave, Cambridge, MA 02139 USA. Check the file named
29     * COPYING.
30     */
31    
32 johnpye 1066 #ifndef ASC_INSTMACRO_H
33     #define ASC_INSTMACRO_H
34 aw0a 1
35 johnpye 1066 /** addtogroup compiler Compiler
36     @{
37     */
38    
39 jds 54 /** @file
40     * Ascend Instance Tree Type Implementation Macros.
41     * <pre>
42     * When #including instmacro.h, make sure these files are #included first:
43     * #include "utilities/ascConfig.h"
44     *
45 aw0a 1 *---------------------------------------------------------------------------
46     * This header for instance and instantiator consumption only.
47     * Clients keep your hands off!
48     *---------------------------------------------------------------------------
49 jds 54 * </pre>
50 aw0a 1 */
51    
52 jds 54 /* temporary global variables used for debugging only */
53 aw0a 1 #ifndef NDEBUG
54 jds 54 /* fundies */
55 aw0a 1 extern struct RealInstance *g_r_inst;
56     extern struct IntegerInstance *g_i_inst;
57     extern struct BooleanInstance *g_b_inst;
58     extern struct SetInstance *g_s_inst;
59     extern struct SymbolInstance *g_sym_inst;
60 jds 54 /* constants */
61 aw0a 1 extern struct RealConstantInstance *g_rc_inst;
62     extern struct IntegerConstantInstance *g_ic_inst;
63     extern struct BooleanConstantInstance *g_bc_inst;
64     extern struct SetConstantInstance *g_sc_inst;
65     extern struct SymbolConstantInstance *g_symc_inst;
66 jds 54 /* atoms */
67 aw0a 1 extern struct RealAtomInstance *g_ra_inst;
68     extern struct IntegerAtomInstance *g_ia_inst;
69     extern struct BooleanAtomInstance *g_ba_inst;
70     extern struct SetAtomInstance *g_sa_inst;
71     extern struct SymbolAtomInstance *g_syma_inst;
72 jds 54 /* other */
73 aw0a 1 extern struct ModelInstance *g_mod_inst;
74     extern struct RelationInstance *g_rel_inst;
75     extern struct LogRelInstance *g_lrel_inst;
76     extern struct WhenInstance *g_when_inst;
77     #endif
78    
79 jds 54 /* init parent list size */
80     #define AVG_CONSTANT_PARENTS 2L
81     /**< size to which all parent lists are initialized for real constants */
82     #define AVG_ICONSTANT_PARENTS 20L
83     /**< size to which all parent lists are initialized for int constants */
84     #define AVG_PARENTS 2L
85     /**< size to which all parent lists are initialized */
86     #define AVG_CASES 2L
87     /**< size to which all cases lists are initialized (WHEN instance) */
88     #define AVG_WHEN 2L
89     /**< size to which all when lists are initialized (models, relations) */
90     #define AVG_RELATIONS 7L
91     /**< size to which all relation lists are initialized */
92     #define AVG_LOGRELS 7L
93     /**< size to which all logical relation lists are initialized */
94     #define AVG_ARY_CHILDREN 7L
95     /**< size to which all array children lists are initialized */
96 aw0a 1 #define UNDEFAULTEDREAL 0.0
97    
98 johnpye 826 #define MAX_EXTRELATIONS 50
99 jds 54 /**< maximum number of different ext relations for a given simulation */
100 aw0a 1
101 jds 54 /* type coercion definitions */
102     /* any */
103 aw0a 1 #define INST(i) ((struct Instance *)(i))
104 jds 54 /* other */
105 aw0a 1 #define SIM_INST(i) ((struct SimulationInstance *)(i))
106     #define RELN_INST(i) ((struct RelationInstance *)(i))
107     #define LRELN_INST(i) ((struct LogRelInstance *)(i))
108     #define ARY_INST(i) ((struct ArrayInstance *)(i))
109     #define MOD_INST(i) ((struct ModelInstance *)(i))
110     #define W_INST(i) ((struct WhenInstance *)(i))
111 jds 54 /* fundies */
112 aw0a 1 #define R_INST(i) ((struct RealInstance *)(i))
113     #define I_INST(i) ((struct IntegerInstance *)(i))
114     #define B_INST(i) ((struct BooleanInstance *)(i))
115     #define S_INST(i) ((struct SetInstance *)(i))
116     #define SYM_INST(i) ((struct SymbolInstance *)(i))
117 jds 54 /* constants */
118 aw0a 1 #define CI_INST(i) ((struct CommonConstantInstance *)(i))
119     #define RC_INST(i) ((struct RealConstantInstance *)(i))
120     #define IC_INST(i) ((struct IntegerConstantInstance *)(i))
121     #define BC_INST(i) ((struct BooleanConstantInstance *)(i))
122     #define SYMC_INST(i) ((struct SymbolConstantInstance *)(i))
123 jds 54 /* atoms */
124 aw0a 1 #define CA_INST(i) ((struct CommonAtomInstance *)(i))
125     #define RA_INST(i) ((struct RealAtomInstance *)(i))
126     #define BA_INST(i) ((struct BooleanAtomInstance *)(i))
127     #define IA_INST(i) ((struct IntegerAtomInstance *)(i))
128     #define SA_INST(i) ((struct SetAtomInstance *)(i))
129     #define SYMA_INST(i) ((struct SymbolAtomInstance *)(i))
130     #define SOL_INST(i) ((struct SolverAtomInstance *)(i))
131    
132     #define D_INST(i) ((struct GlobalDummyInstance *)(i))
133 jds 54 /** constant inst assigned? */
134 aw0a 1 #define CIASS(i) (CI_INST(i)->vflag & ci_ASSIGNED)
135 jds 54 /** boolean constant value */
136 aw0a 1 #define BCV(i) ((BC_INST(i)->vflag & ci_BVAL) == ci_BVAL)
137    
138 jds 54 /* parent macros for fundamental atoms real, integer, boolean, and set */
139 aw0a 1 #define R_PARENT(i) \
140     INST((unsigned long)i-(unsigned long)R_INST(i)->parent_offset)
141     #define I_PARENT(i) \
142     INST((unsigned long)i-(unsigned long)I_INST(i)->parent_offset)
143     #define B_PARENT(i) \
144     INST((unsigned long)i-(unsigned long)B_INST(i)->parent_offset)
145     #define S_PARENT(i) \
146     INST((unsigned long)i-(unsigned long)S_INST(i)->parent_offset)
147     #define SYM_PARENT(i) \
148     INST((unsigned long)i-(unsigned long)SYM_INST(i)->parent_offset)
149    
150 jds 54 /** this should probably be conditionally defined by LONGCHILDREN
151 aw0a 1 * so that if LONGCHILDREN, just returns ivalue.
152     */
153     #define NextHighestEven(ivalue) (((ivalue) & 1) ? ((ivalue)+1) : (ivalue))
154    
155 jds 54 /* child array macros */
156 aw0a 1 #define CHILD_ADR(iptr,type,c)\
157     ((struct Instance **)((unsigned long)iptr+(unsigned long)sizeof(type))+c)
158     #define SIM_CHILD(i,c) CHILD_ADR(i,struct SimulationInstance,c)
159     #define MOD_CHILD(i,c) CHILD_ADR(i,struct ModelInstance,c)
160     #define RA_CHILD(i,c) CHILD_ADR(i,struct RealAtomInstance,c)
161     #define BA_CHILD(i,c) CHILD_ADR(i,struct BooleanAtomInstance,c)
162     #define IA_CHILD(i,c) CHILD_ADR(i,struct IntegerAtomInstance,c)
163     #define SA_CHILD(i,c) CHILD_ADR(i,struct SetAtomInstance,c)
164     #define SYMA_CHILD(i,c) CHILD_ADR(i,struct SymbolAtomInstance,c)
165     #define REL_CHILD(i,c) CHILD_ADR(i,struct RelationInstance,c)
166     #define LREL_CHILD(i,c) CHILD_ADR(i,struct LogRelInstance,c)
167    
168     #define CLIST(in,type) (struct Instance **)((unsigned long)(in)+sizeof(type))
169     #define BASE_ADDR(in,num,type) INST((CLIST(in,type)) + NextHighestEven(num))
170    
171 jds 54 /**<
172     * @todo The whole use of BASE_ADDR needs to be reinvestigated. in particular
173 aw0a 1 * we need RealInstance children to be aligned to 8 bytes, not 2 bytes
174     * which is all NextHighestEven gives us.
175     */
176    
177     #ifdef NDEBUG
178     #define NotAtom(i) IsCompoundInstance(i)
179     #else
180     #define NotAtom(i) NotAtomF(i)
181     #endif
182     extern int NotAtomF(struct Instance *);
183 ben.allan 33 /**<
184 jds 54 * <!-- macro NotAtom(i) -->
185     * <!-- NotAtomF(i) -->
186 aw0a 1 * Returns 1 if instance is compound (i.e. not relation, ATOM, constant,
187     * when. that means array or MODEL.) else returns 0.
188     */
189    
190 johnpye 1066 /* @} */
191 jds 54
192 johnpye 1066 #endif /* ASC_INSTMACRO_H */
193    

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