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

Contents of /trunk/base/generic/compiler/extcall.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 708 - (show annotations) (download) (as text)
Tue Jun 27 07:34:31 2006 UTC (17 years, 11 months ago) by johnpye
File MIME type: text/x-chdr
File size: 6666 byte(s)
Replaced some references to ascmalloc with ASC_NEW_ARRAY
1 /* ASCEND modelling environment
2 Copyright (C) 2006 Carnegie Mellon University
3 Copyright (C) 1990, 1993, 1994 Thomas Guthrie Epperly, Kirk Andre Abbott
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19 *//**
20 @file
21 Hold-all structure for external relations and method calls as declared in an
22 ASCEND model file.
23
24 The ExtCallNode structure points to an ExternalFunc structure and holds a
25 list of instances which are tied to the arguments in the calling ASCEND
26 statement.
27
28 @TODO Complete documentation of compiler/extcall.h.
29
30 @TODO Documentation: what is a 'subject' in the context of an ExtCallNode?
31
32 Requires:
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include "utilities/ascConfig.h"
36 #include "compiler.h"
37 #include "ascmalloc.h"
38 #include "list.h"
39 #include "extfunc.h"
40 #include "instance_enum.h"
41 *//*
42 by Kirk Andre Abbott
43 Created: Jun 1, 1995.
44 Last in CVS: $Revision: 1.6 $ $Date: 1997/07/18 12:29:27 $ $Author: mthomas $
45 */
46
47
48 #ifndef ASC_EXTCALL_H
49 #define ASC_EXTCALL_H
50
51 /** External call data structure. */
52 struct ExtCallNode{
53 struct ExternalFunc *efunc; /**< Pointer to external function. */
54 struct gl_list_t *arglist; /**< List of Instance pointers. */
55 struct Instance **data; /**< A handle to additional user data. */
56 unsigned long subject; /**< Index into the arglist. */
57 int nodestamp; /**< A unique id for each call node. */
58 };
59
60 extern struct ExtCallNode *CreateExtCall(struct ExternalFunc *efunc,
61 struct gl_list_t *args,
62 struct Instance *subject,
63 struct Instance *data);
64 /**<
65 Create ExtCall structure and return.
66 */
67
68 extern void DestroyExtCall(struct ExtCallNode *ext,
69 struct Instance *relinst);
70 /**<
71 Destroy ExtCall structure.
72 */
73
74 extern struct Instance *GetSubjectInstance(struct gl_list_t *arglist,
75 unsigned long varndx);
76
77 extern unsigned long GetSubjectIndex(struct gl_list_t *arglist,
78 struct Instance *subject);
79 /**<
80 @TODO what is this?
81 */
82
83 extern unsigned long CountNumberOfArgs(struct gl_list_t *arglist,
84 unsigned long start, unsigned long end);
85 /**<
86 @TODO what is the purpose of the 'start' and 'end' parameters?
87 */
88
89 extern struct gl_list_t *LinearizeArgList(struct gl_list_t *arglist,
90 unsigned long start, unsigned long end);
91 /**<
92 Given a list of gl_list_t's this function will create a new list which
93 is a linearized representation,i.e, each of the lists is spliced into
94 the original list, to create one long list. The user now owns the
95 new list structure, although the data in the original list is shared
96 with the new list.
97 */
98
99 extern struct gl_list_t *CopySpecialList(struct gl_list_t *list);
100
101 extern void DestroySpecialList(struct gl_list_t *list);
102 /**<
103 Given a list of gl_list_t's, this function will destroy the lists
104 structures associated with this complex list. It *will* not destroy
105 the *leaf* data, but it will destroy all the list structures.
106 */
107
108
109
110 #ifdef NDEBUG
111 #define ExternalCallExtFunc(ext) ((ext)->efunc)
112 #else
113 #define ExternalCallExtFunc(ext) ExternalCallExtFuncF(ext)
114 #endif
115 /**<
116 Return the external function pointer of an external call.
117 @param ext <code>struct ExtCallNode*</code>, node to query.
118 @return Returns the external function as a <code>struct ExternalFunc*</code>.
119 @see ExternalCallExtFuncF()
120 */
121 extern struct ExternalFunc *ExternalCallExtFuncF(struct ExtCallNode *ext);
122 /**<
123 Implementation function for ExternalCallExtFunc(). Do not call this
124 function directly - call ExternalCallExtFunc() instead.
125 */
126
127
128
129 #ifdef NDEBUG
130 #define ExternalCallArgList(ext) ((ext)->arglist)
131 #else
132 #define ExternalCallArgList(ext) ExternalCallArgListF(ext)
133 #endif
134 /**<
135 Return the argument list. This is a List of Lists of struct
136 Instances, for an external call.
137 @param ext <code>struct ExtCallNode*</code>, node to query.
138 @return Returns the arguments as a <code>struct gl_list_t*</code>.
139 @see ExternalCallArgListF()
140 */
141 extern struct gl_list_t *ExternalCallArgListF(struct ExtCallNode *ext);
142 /**<
143 Implementation function for ExternalCallArgList(). Do not call this
144 function directly - call ExternalCallArgList() instead.
145 */
146
147
148
149 extern struct Instance *ExternalCallDataInstance(struct ExtCallNode *ext);
150 /**<
151 Return the 'data' instance for an external call. This 'data'
152 instance can has to be a MODEL_INST. It is used to convey additional
153 information to a client who may need it. A NULL result means that no
154 additional information was requested and is a valid result.
155 */
156
157
158
159 #ifdef NDEBUG
160 #define ExternalCallVarIndex(ext) ((ext)->subject)
161 #else
162 #define ExternalCallVarIndex(ext) ExternalCallVarIndexF(ext)
163 #endif
164 /**<
165 Return the index in the argument list of the subject variable.
166 @param ext <code>struct ExtCallNode*</code>, node to query.
167 @return Returns the index as an <code>unsigned long</code>.
168 @see ExternalCallVarIndexF()
169 */
170 extern unsigned long ExternalCallVarIndexF(struct ExtCallNode *ext);
171 /**<
172 Implementation function for ExternalCallVarIndex(). Do not call this
173 function directly - call ExternalCallVarIndex() instead.
174
175 This function uses the primitives GetWhichVar etc.
176 */
177
178
179
180 extern struct Instance *ExternalCallVarInstance(struct ExtCallNode *ext);
181 /**<
182 Return the "subject" variable instance of the external call. This is
183 the variable that relation was constructed wrt. If NULL, then a user
184 should consider this as an error.
185 */
186
187
188
189 #ifdef NDEBUG
190 #define ExternalCallNodeStamp(ext) ((ext)->nodestamp)
191 #else
192 #define ExternalCallNodeStamp(ext) ExternalCallNodeStampF(ext)
193 #endif
194 /**<
195 Return the nodestamp for the given external node.
196 Valid results are >= 0.
197
198 @param ext <code>struct ExtCallNode*</code>, node to query.
199 @return Returns the node stamp as an <code>int</code>.
200 @see ExternalCallNodeStampF()
201 */
202
203 extern int ExternalCallNodeStampF(struct ExtCallNode *ext);
204 /**<
205 Implementation function for ExternalCallNodeStamp(). Do not call this
206 function directly - call ExternalCallNodeStamp() instead.
207 */
208
209
210
211 extern void SetExternalCallNodeStamp(struct ExtCallNode *ext, int nodestamp);
212 /**<
213 Set the nodestamp for the given external node.
214 */
215
216 #endif /* ASC_EXTCALL_H */
217

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