/[ascend]/trunk/base/generic/compiler/atomsize.c
ViewVC logotype

Contents of /trunk/base/generic/compiler/atomsize.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 709 - (show annotations) (download) (as text)
Wed Jun 28 16:28:57 2006 UTC (13 years, 5 months ago) by johnpye
File MIME type: text/x-csrc
File size: 4515 byte(s)
Monster commit!
Lots of recommenting and reorganising of external relations-related stuff.
Replaced a lot of ascmalloc and asccalloc calls with the new ASC_NEW* macros.
Fixed (?) the problem Art is having with icons in PyGTK.
Turned on -Wall in SConstruct and fixed up a stack of warnings.
Removed the redundant exit(2) from after Asc_Panic calls and added __attribute__((noreturn)).
Set doxygen to create callgraphs to level 2, updated doxyfile to version 1.4.7.
Fixed up building of extfntest.c.
1 /*
2 * Ascend Instance Atom Size Functions
3 * by Tom Epperly & Ben Allan
4 * 9/3/89
5 * Version: $Revision: 1.6 $
6 * Version control file: $RCSfile: atomsize.c,v $
7 * Date last modified: $Date: 1997/07/18 12:28:01 $
8 * Last modified by: $Author: mthomas $
9 *
10 * This file is part of the Ascend Language Interpreter.
11 *
12 * Copyright (C) 1996 Ben 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 #include <stdarg.h>
33 #include <utilities/ascConfig.h>
34 #include <utilities/ascPanic.h>
35 #include <utilities/ascMalloc.h>
36 #include <general/list.h>
37 #include <general/dstring.h>
38 #include "compiler.h"
39 #include "symtab.h"
40 #include "fractions.h"
41 #include "dimen.h"
42 #include "functype.h"
43 #include "expr_types.h"
44 #include "childinfo.h"
45 #include "instance_enum.h"
46 #include "instance_name.h"
47 #include "instance_io.h"
48 #include "instance_types.h"
49 #include "instmacro.h"
50 #include "atomsize.h"
51
52 #ifndef lint
53 static CONST char AtomSizeModuleID[] = "$Id: atomsize.c,v 1.6 1997/07/18 12:28:01 mthomas Exp $";
54 #endif
55
56 static unsigned long ChildMemory(unsigned long int count,
57 CONST struct ChildDesc *cdesc)
58 {
59 register unsigned long result;
60 result = NextHighestEven(count)*sizeof(struct Instance *);
61 while(count) {
62 switch(ChildDescType(GetChildArrayElement(cdesc,count))) {
63 case real_child:
64 result += sizeof(struct RealInstance);
65 break;
66 case integer_child:
67 result += sizeof(struct IntegerInstance);
68 break;
69 case boolean_child:
70 result += sizeof(struct BooleanInstance);
71 break;
72 case set_child:
73 result += sizeof(struct SetInstance);
74 break;
75 case symbol_child:
76 result += sizeof(struct SymbolInstance);
77 break;
78 default:
79 /* the bad_child type should never! have count > 0 */
80 Asc_Panic(2, "ChildMemory",
81 "Bad ChildDesc struct passed to ChildMemory.\n");
82 /*NOTREACHED*/
83 }
84 count--;
85 }
86 return result;
87 }
88
89 unsigned long ConstantByteLength(enum inst_t it)
90 {
91 switch (it) {
92 case REAL_CONSTANT_INST:
93 return sizeof(struct RealConstantInstance);
94 case BOOLEAN_CONSTANT_INST:
95 return sizeof(struct BooleanConstantInstance);
96 case INTEGER_CONSTANT_INST:
97 return sizeof(struct IntegerConstantInstance);
98 case SYMBOL_CONSTANT_INST:
99 return sizeof(struct SymbolConstantInstance);
100 default:
101 Asc_Panic(2, NULL, "Bytelength of unknown constant type requested.");
102
103 break;
104 }
105 /* not reached */
106 }
107
108 unsigned long RealAtomByteLength(unsigned long int num_children,
109 CONST struct ChildDesc *c)
110 {
111 return sizeof(struct RealAtomInstance)+ChildMemory(num_children,c);
112 }
113
114 unsigned long IntegerAtomByteLength(unsigned long int num_children,
115 CONST struct ChildDesc *c)
116 {
117 return sizeof(struct IntegerAtomInstance)+ChildMemory(num_children,c);
118 }
119
120 unsigned long BooleanAtomByteLength(unsigned long int num_children,
121 CONST struct ChildDesc *c)
122 {
123 return sizeof(struct BooleanAtomInstance)+ChildMemory(num_children,c);
124 }
125
126 unsigned long SetAtomByteLength(unsigned long int num_children,
127 CONST struct ChildDesc *c)
128 {
129 return sizeof(struct SetAtomInstance)+ChildMemory(num_children,c);
130 }
131
132 unsigned long SymbolAtomByteLength(unsigned long int num_children,
133 CONST struct ChildDesc *c)
134 {
135 return sizeof(struct SymbolAtomInstance)+ChildMemory(num_children,c);
136 }
137
138 unsigned long RelationAtomByteLength(unsigned long int num_children,
139 CONST struct ChildDesc *c)
140 {
141 return sizeof(struct RelationInstance)+ChildMemory(num_children,c);
142 }
143
144
145 unsigned long LogRelAtomByteLength(unsigned long int num_children,
146 CONST struct ChildDesc *c)
147 {
148 return sizeof(struct LogRelInstance)+ChildMemory(num_children,c);
149 }
150

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