/[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 33 - (hide annotations) (download) (as text)
Sun Dec 26 20:06:01 2004 UTC (19 years, 9 months ago) by ben.allan
File MIME type: text/x-chdr
File size: 7370 byte(s)
First pass at doxygenation -- mechanically putting in ** and where
most likely needed **< using sed. Lots of cleanup needed to
be really useful, including grouping data types and their
member methods into class-like documentation.
1 ben.allan 33 /**<
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     #ifndef __INSTMACRO_H_SEEN__
33     #define __INSTMACRO_H_SEEN__
34    
35 ben.allan 33 /**<
36 aw0a 1 *---------------------------------------------------------------------------
37     * This header for instance and instantiator consumption only.
38     * Clients keep your hands off!
39     *---------------------------------------------------------------------------
40     */
41    
42 ben.allan 33 /**< temporary global variables used for debugging only */
43 aw0a 1 #ifndef NDEBUG
44 ben.allan 33 /**< fundies */
45 aw0a 1 extern struct RealInstance *g_r_inst;
46     extern struct IntegerInstance *g_i_inst;
47     extern struct BooleanInstance *g_b_inst;
48     extern struct SetInstance *g_s_inst;
49     extern struct SymbolInstance *g_sym_inst;
50 ben.allan 33 /**< constants */
51 aw0a 1 extern struct RealConstantInstance *g_rc_inst;
52     extern struct IntegerConstantInstance *g_ic_inst;
53     extern struct BooleanConstantInstance *g_bc_inst;
54     extern struct SetConstantInstance *g_sc_inst;
55     extern struct SymbolConstantInstance *g_symc_inst;
56 ben.allan 33 /**< atoms */
57 aw0a 1 extern struct RealAtomInstance *g_ra_inst;
58     extern struct IntegerAtomInstance *g_ia_inst;
59     extern struct BooleanAtomInstance *g_ba_inst;
60     extern struct SetAtomInstance *g_sa_inst;
61     extern struct SymbolAtomInstance *g_syma_inst;
62 ben.allan 33 /**< other */
63 aw0a 1 extern struct ModelInstance *g_mod_inst;
64     extern struct RelationInstance *g_rel_inst;
65     extern struct LogRelInstance *g_lrel_inst;
66     extern struct WhenInstance *g_when_inst;
67     #endif
68    
69 ben.allan 33 /**< init parent list size */
70     #define AVG_CONSTANT_PARENTS 2L /**< size to which all parent lists are */
71     /**< initialized for real constants */
72     #define AVG_ICONSTANT_PARENTS 20L /**< size to which all parent lists are */
73     /**< initialized for int constants */
74     #define AVG_PARENTS 2L /**< size to which all parent lists are */
75     /**< initialized */
76     #define AVG_CASES 2L /**< size to which all cases lists are */
77     /**< initialized (WHEN instance) */
78     #define AVG_WHEN 2L /**< size to which all when lists are */
79     /**< initialized (models, relations) */
80     #define AVG_RELATIONS 7L /**< size to which all relation lists are */
81     /**< initialized */
82     #define AVG_LOGRELS 7L /**< size to which all logical relation */
83     /**< lists are initialized */
84     #define AVG_ARY_CHILDREN 7L /**< size to which all array children lists */
85     /**< are initialized */
86 aw0a 1 #define UNDEFAULTEDREAL 0.0
87    
88 ben.allan 33 #define MAX_EXTRELATIONS 20 /**< maximum number of different ext relations */
89     /**< for a given simulation */
90 aw0a 1
91 ben.allan 33 /**< type coercion definitions */
92     /**< any */
93 aw0a 1 #define INST(i) ((struct Instance *)(i))
94 ben.allan 33 /**< other */
95 aw0a 1 #define SIM_INST(i) ((struct SimulationInstance *)(i))
96     #define RELN_INST(i) ((struct RelationInstance *)(i))
97     #define LRELN_INST(i) ((struct LogRelInstance *)(i))
98     #define ARY_INST(i) ((struct ArrayInstance *)(i))
99     #define MOD_INST(i) ((struct ModelInstance *)(i))
100     #define W_INST(i) ((struct WhenInstance *)(i))
101 ben.allan 33 /**< fundies */
102 aw0a 1 #define R_INST(i) ((struct RealInstance *)(i))
103     #define I_INST(i) ((struct IntegerInstance *)(i))
104     #define B_INST(i) ((struct BooleanInstance *)(i))
105     #define S_INST(i) ((struct SetInstance *)(i))
106     #define SYM_INST(i) ((struct SymbolInstance *)(i))
107 ben.allan 33 /**< constants */
108 aw0a 1 #define CI_INST(i) ((struct CommonConstantInstance *)(i))
109     #define RC_INST(i) ((struct RealConstantInstance *)(i))
110     #define IC_INST(i) ((struct IntegerConstantInstance *)(i))
111     #define BC_INST(i) ((struct BooleanConstantInstance *)(i))
112     #define SYMC_INST(i) ((struct SymbolConstantInstance *)(i))
113 ben.allan 33 /**< atoms */
114 aw0a 1 #define CA_INST(i) ((struct CommonAtomInstance *)(i))
115     #define RA_INST(i) ((struct RealAtomInstance *)(i))
116     #define BA_INST(i) ((struct BooleanAtomInstance *)(i))
117     #define IA_INST(i) ((struct IntegerAtomInstance *)(i))
118     #define SA_INST(i) ((struct SetAtomInstance *)(i))
119     #define SYMA_INST(i) ((struct SymbolAtomInstance *)(i))
120     #define SOL_INST(i) ((struct SolverAtomInstance *)(i))
121    
122     #define D_INST(i) ((struct GlobalDummyInstance *)(i))
123 ben.allan 33 /**< constant inst assigned? */
124 aw0a 1 #define CIASS(i) (CI_INST(i)->vflag & ci_ASSIGNED)
125 ben.allan 33 /**< boolean constant value */
126 aw0a 1 #define BCV(i) ((BC_INST(i)->vflag & ci_BVAL) == ci_BVAL)
127    
128 ben.allan 33 /**< parent macros for fundamental atoms real, integer, boolean, and set */
129 aw0a 1 #define R_PARENT(i) \
130     INST((unsigned long)i-(unsigned long)R_INST(i)->parent_offset)
131     #define I_PARENT(i) \
132     INST((unsigned long)i-(unsigned long)I_INST(i)->parent_offset)
133     #define B_PARENT(i) \
134     INST((unsigned long)i-(unsigned long)B_INST(i)->parent_offset)
135     #define S_PARENT(i) \
136     INST((unsigned long)i-(unsigned long)S_INST(i)->parent_offset)
137     #define SYM_PARENT(i) \
138     INST((unsigned long)i-(unsigned long)SYM_INST(i)->parent_offset)
139    
140 ben.allan 33 /**< this should probably be conditionally defined by LONGCHILDREN
141 aw0a 1 * so that if LONGCHILDREN, just returns ivalue.
142     */
143     #define NextHighestEven(ivalue) (((ivalue) & 1) ? ((ivalue)+1) : (ivalue))
144    
145 ben.allan 33 /**< child array macros */
146 aw0a 1 #define CHILD_ADR(iptr,type,c)\
147     ((struct Instance **)((unsigned long)iptr+(unsigned long)sizeof(type))+c)
148     #define SIM_CHILD(i,c) CHILD_ADR(i,struct SimulationInstance,c)
149     #define MOD_CHILD(i,c) CHILD_ADR(i,struct ModelInstance,c)
150     #define RA_CHILD(i,c) CHILD_ADR(i,struct RealAtomInstance,c)
151     #define BA_CHILD(i,c) CHILD_ADR(i,struct BooleanAtomInstance,c)
152     #define IA_CHILD(i,c) CHILD_ADR(i,struct IntegerAtomInstance,c)
153     #define SA_CHILD(i,c) CHILD_ADR(i,struct SetAtomInstance,c)
154     #define SYMA_CHILD(i,c) CHILD_ADR(i,struct SymbolAtomInstance,c)
155     #define REL_CHILD(i,c) CHILD_ADR(i,struct RelationInstance,c)
156     #define LREL_CHILD(i,c) CHILD_ADR(i,struct LogRelInstance,c)
157    
158     #define CLIST(in,type) (struct Instance **)((unsigned long)(in)+sizeof(type))
159     #define BASE_ADDR(in,num,type) INST((CLIST(in,type)) + NextHighestEven(num))
160    
161 ben.allan 33 /**< the whole use of BASE_ADDR needs to be reinvestigated. in particular
162 aw0a 1 * we need RealInstance children to be aligned to 8 bytes, not 2 bytes
163     * which is all NextHighestEven gives us.
164     */
165    
166     #ifdef NDEBUG
167     #define NotAtom(i) IsCompoundInstance(i)
168     #else
169     #define NotAtom(i) NotAtomF(i)
170     #endif
171     extern int NotAtomF(struct Instance *);
172 ben.allan 33 /**<
173 aw0a 1 * macro NotAtom(i)
174     * NotAtomF(i)
175     * Returns 1 if instance is compound (i.e. not relation, ATOM, constant,
176     * when. that means array or MODEL.) else returns 0.
177     */
178    
179     #endif
180 ben.allan 33 /**< __INSTMACRO_H_SEEN__ */

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