/[ascend]/trunk/ascend/compiler/childinfo.c
ViewVC logotype

Contents of /trunk/ascend/compiler/childinfo.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2781 - (show annotations) (download) (as text)
Fri Jun 20 05:12:07 2014 UTC (4 years, 2 months ago) by jpye
File MIME type: text/x-csrc
File size: 4543 byte(s)
remove RCS comments per warnings from clang 3.4
1 /*
2 * Atom Child Description Implementation
3 * by Tom Epperly
4 * part of Ascend
5 * Version: $Revision: 1.10 $
6 * Version control file: $RCSfile: childinfo.c,v $
7 * Date last modified: $Date: 1998/02/05 16:35:39 $
8 * Last modified by: $Author: ballan $
9 *
10 * This file is part of the Ascend Language Interpreter.
11 *
12 * Copyright (C) 1990, 1993, 1994 Thomas Guthrie Epperly
13 *
14 * The Ascend Language Interpreter is free software; you can redistribute
15 * it and/or modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of the
17 * License, or (at your option) any later version.
18 *
19 * The Ascend Language Interpreter is distributed in hope that it will be
20 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program. If not, see <http://www.gnu.org/licenses/>.
26 */
27 #include <ascend/general/platform.h>
28
29 #include <ascend/general/panic.h>
30 #include <ascend/general/ascMalloc.h>
31
32
33 #include "setinstval.h"
34 #include "childinfo.h"
35 #include <ascend/general/mathmacros.h>
36
37 void CDescInit(struct ChildDesc *v)
38 {
39 memset((char *)v,0,sizeof(struct ChildDesc));
40 }
41 /*
42 * ICDESC(stackvar) should be called on locally allocated
43 * value_t before any other action using them is taken.
44 * When NDEBUG is not defined, it causes the stack memory to be
45 * initialized to 0. Normally it is a do nothing macro.
46 * Proper initialization helps us separate signal from noise in
47 * gdb and purify.
48 */
49
50 struct ChildDesc *CreateChildDescArray(unsigned long int l){
51 #ifndef NDEBUG
52 return ASC_NEW_ARRAY_CLEAR(struct ChildDesc,l);
53 #else
54 return ASC_NEW_ARRAY(struct ChildDesc,l);
55 #endif
56 }
57
58 struct ChildDesc *CreateEmptyChildDescArray(void)
59 {
60 register struct ChildDesc *cda = NULL;
61 cda = ASC_NEW_CLEAR(struct ChildDesc);
62 assert(cda != NULL);
63 cda->t = bad_child;
64 return cda;
65 }
66
67 void DestroyChildDescArray(struct ChildDesc *c, unsigned long int l)
68 {
69 struct ChildDesc *ptr = c;
70 AssertAllocatedMemory(c,sizeof(struct ChildDesc)*MAX(l,1));
71 while(l--){
72 if ((ptr->t == set_child) && (ptr->u.s.slist))
73 DestroySet(ptr->u.s.slist);
74 ptr++;
75 }
76 ascfree(c);
77 }
78
79 struct ChildDesc MakeRealDesc(int assigned, double v, CONST dim_type *dims)
80 {
81 struct ChildDesc result;
82 ICDESC(result);
83 result.t = real_child;
84 result.assigned = (assigned)?1:0;
85 result.u.rvalue.value = v;
86 result.u.rvalue.dims = dims;
87 return result;
88 }
89
90 struct ChildDesc MakeIntegerDesc(int assigned, long int i)
91 {
92 struct ChildDesc result;
93 ICDESC(result);
94 result.t = integer_child;
95 result.assigned = (assigned)?1:0;
96 result.u.ivalue.value = i;
97 return result;
98 }
99
100 struct ChildDesc MakeBooleanDesc(int assigned, int b)
101 {
102 struct ChildDesc result;
103 ICDESC(result);
104 result.t = boolean_child;
105 result.assigned = (assigned)?1:0;
106 result.u.bvalue = b;
107 return result;
108 }
109
110 struct ChildDesc MakeSetDesc(int assigned, int intset, struct set_t *s)
111 {
112 struct ChildDesc result;
113 ICDESC(result);
114 result.t = set_child;
115 result.assigned = (assigned)?1:0;
116 result.u.s.slist = s;
117 result.u.s.is_int = intset ? 1 :0;
118 return result;
119 }
120
121 struct ChildDesc MakeSymbolDesc(int assigned, symchar *str)
122 {
123 struct ChildDesc result;
124 ICDESC(result);
125 result.t = symbol_child;
126 result.assigned = (assigned)?1:0;
127 result.u.svalue = str;
128 return result;
129 }
130
131 void AssignChildArrayElementF(struct ChildDesc *a, unsigned long int n,
132 struct ChildDesc e)
133 {
134 AssertMemory(a);
135 AssertMemory(&a[n-1]);
136 a[n-1] = e;
137 }
138
139 struct ChildDesc GetChildArrayElementF(CONST struct ChildDesc *a,
140 unsigned long int n)
141 {
142 AssertMemory(a);
143 AssertMemory(&a[n-1]);
144 return a[n-1];
145 }
146
147 enum ChildDescT ChildDescTypeF(struct ChildDesc e)
148 {
149 return e.t;
150 }
151
152 int ValueAssignedF(struct ChildDesc e)
153 {
154 return e.assigned;
155 }
156
157 long IntegerDefaultF(struct ChildDesc e)
158 {
159 return e.u.ivalue.value;
160 }
161
162 symchar *SymbolDefaultF(struct ChildDesc e)
163 {
164 return e.u.svalue;
165 }
166
167 int BooleanDefaultF(struct ChildDesc e)
168 {
169 return e.u.bvalue;
170 }
171
172 CONST struct set_t *SetDefaultF(struct ChildDesc e)
173 {
174 return e.u.s.slist;
175 }
176
177 int SetIsIntegerSetF(struct ChildDesc e)
178 {
179 return e.u.s.is_int;
180 }
181
182 double RealDefaultValueF(struct ChildDesc e)
183 {
184 return e.u.rvalue.value;
185 }
186
187 CONST dim_type *RealDimensionsF(struct ChildDesc e)
188 {
189 return e.u.rvalue.dims;
190 }

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