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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2011 - (show annotations) (download) (as text)
Tue Apr 28 08:58:48 2009 UTC (16 years, 8 months ago) by jpye
File MIME type: text/x-csrc
File size: 4418 byte(s)
Moving libascend components from #/base/generic into #/ascend
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
39 #include "symtab.h"
40
41
42 #include "functype.h"
43 #include "expr_types.h"
44 #include "childinfo.h"
45 #include "instance_name.h"
46 #include "instance_io.h"
47 #include "instance_types.h"
48 #include "instmacro.h"
49 #include "atomsize.h"
50
51 #ifndef lint
52 static CONST char AtomSizeModuleID[] = "$Id: atomsize.c,v 1.6 1997/07/18 12:28:01 mthomas Exp $";
53 #endif
54
55 static unsigned long ChildMemory(unsigned long int count,
56 CONST struct ChildDesc *cdesc)
57 {
58 register unsigned long result;
59 result = NextHighestEven(count)*sizeof(struct Instance *);
60 while(count) {
61 switch(ChildDescType(GetChildArrayElement(cdesc,count))) {
62 case real_child:
63 result += sizeof(struct RealInstance);
64 break;
65 case integer_child:
66 result += sizeof(struct IntegerInstance);
67 break;
68 case boolean_child:
69 result += sizeof(struct BooleanInstance);
70 break;
71 case set_child:
72 result += sizeof(struct SetInstance);
73 break;
74 case symbol_child:
75 result += sizeof(struct SymbolInstance);
76 break;
77 default:
78 /* the bad_child type should never! have count > 0 */
79 Asc_Panic(2, "ChildMemory",
80 "Bad ChildDesc struct passed to ChildMemory.\n");
81 /*NOTREACHED*/
82 }
83 count--;
84 }
85 return result;
86 }
87
88 unsigned long ConstantByteLength(enum inst_t it)
89 {
90 switch (it) {
91 case REAL_CONSTANT_INST:
92 return sizeof(struct RealConstantInstance);
93 case BOOLEAN_CONSTANT_INST:
94 return sizeof(struct BooleanConstantInstance);
95 case INTEGER_CONSTANT_INST:
96 return sizeof(struct IntegerConstantInstance);
97 case SYMBOL_CONSTANT_INST:
98 return sizeof(struct SymbolConstantInstance);
99 default:
100 ASC_PANIC("Bytelength of unknown constant type requested.");
101
102 break;
103 }
104 /* not reached */
105 }
106
107 unsigned long RealAtomByteLength(unsigned long int num_children,
108 CONST struct ChildDesc *c)
109 {
110 return sizeof(struct RealAtomInstance)+ChildMemory(num_children,c);
111 }
112
113 unsigned long IntegerAtomByteLength(unsigned long int num_children,
114 CONST struct ChildDesc *c)
115 {
116 return sizeof(struct IntegerAtomInstance)+ChildMemory(num_children,c);
117 }
118
119 unsigned long BooleanAtomByteLength(unsigned long int num_children,
120 CONST struct ChildDesc *c)
121 {
122 return sizeof(struct BooleanAtomInstance)+ChildMemory(num_children,c);
123 }
124
125 unsigned long SetAtomByteLength(unsigned long int num_children,
126 CONST struct ChildDesc *c)
127 {
128 return sizeof(struct SetAtomInstance)+ChildMemory(num_children,c);
129 }
130
131 unsigned long SymbolAtomByteLength(unsigned long int num_children,
132 CONST struct ChildDesc *c)
133 {
134 return sizeof(struct SymbolAtomInstance)+ChildMemory(num_children,c);
135 }
136
137 unsigned long RelationAtomByteLength(unsigned long int num_children,
138 CONST struct ChildDesc *c)
139 {
140 return sizeof(struct RelationInstance)+ChildMemory(num_children,c);
141 }
142
143
144 unsigned long LogRelAtomByteLength(unsigned long int num_children,
145 CONST struct ChildDesc *c)
146 {
147 return sizeof(struct LogRelInstance)+ChildMemory(num_children,c);
148 }
149

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