1/*
2 * Copyright (c) 2010 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1.  Redistributions of source code must retain the above copyright
11 *     notice, this list of conditions and the following disclaimer.
12 * 2.  Redistributions in binary form must reproduce the above copyright
13 *     notice, this list of conditions and the following disclaimer in the
14 *     documentation and/or other materials provided with the distribution.
15 * 3.  Neither the name of Apple Inc. ("Apple") nor the names of its
16 *     contributors may be used to endorse or promote products derived from
17 *     this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
20 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
30 * Portions of this software have been released under the following terms:
31 *
32 * (c) Copyright 1989-1993 OPEN SOFTWARE FOUNDATION, INC.
33 * (c) Copyright 1989-1993 HEWLETT-PACKARD COMPANY
34 * (c) Copyright 1989-1993 DIGITAL EQUIPMENT CORPORATION
35 *
36 * To anyone who acknowledges that this file is provided "AS IS"
37 * without any express or implied warranty:
38 * permission to use, copy, modify, and distribute this file for any
39 * purpose is hereby granted without fee, provided that the above
40 * copyright notices and this notice appears in all source code copies,
41 * and that none of the names of Open Software Foundation, Inc., Hewlett-
42 * Packard Company or Digital Equipment Corporation be used
43 * in advertising or publicity pertaining to distribution of the software
44 * without specific, written prior permission.  Neither Open Software
45 * Foundation, Inc., Hewlett-Packard Company nor Digital
46 * Equipment Corporation makes any representations about the suitability
47 * of this software for any purpose.
48 *
49 * Copyright (c) 2007, Novell, Inc. All rights reserved.
50 * Redistribution and use in source and binary forms, with or without
51 * modification, are permitted provided that the following conditions
52 * are met:
53 *
54 * 1.  Redistributions of source code must retain the above copyright
55 *     notice, this list of conditions and the following disclaimer.
56 * 2.  Redistributions in binary form must reproduce the above copyright
57 *     notice, this list of conditions and the following disclaimer in the
58 *     documentation and/or other materials provided with the distribution.
59 * 3.  Neither the name of Novell Inc. nor the names of its contributors
60 *     may be used to endorse or promote products derived from this
61 *     this software without specific prior written permission.
62 *
63 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
64 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
65 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
66 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY
67 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
68 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
69 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
70 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
71 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
72 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
73 *
74 * @APPLE_LICENSE_HEADER_END@
75 */
76
77/*
78**
79**  NAME:
80**
81**      ast.h
82**
83**  FACILITY:
84**
85**      Interface Definition Language (IDL) Compiler
86**
87**  ABSTRACT:
88**
89**  Definition of Abstract Syntax Tree (AST) data structures.
90**
91**  VERSION: DCE 1.1
92*/
93
94#ifndef AST_H
95#define AST_H
96
97 /*
98 *  a s t . h
99 *
100 *  This file contains the declarations for the abstract syntax tree
101 *  nodes used in the tree generated by the frontend and read by the
102 *  backend.
103 *
104 *  Naming conventions: _n_t suffix used for struct or union types used
105 *  for ast nodes; _k_t suffix used for enumerated types used to
106 *  discriminate among the variants of a node type represented as a union.
107 *
108 *
109 *  Notes on the representation of attributes
110 *  -----------------------------------------
111 *  The following table gives information on all of the attributes
112 *  used in the IDL language and in the intermediate rep of interface
113 *  definitions.
114 *
115 *  attribute         | type        |  where      |  kind  |  notes
116 *  name              | of          |  allowed    |  of    |
117 *                    | value       |  in         |  attr  |
118 *                    |             |  source     |        |
119 *  ------------------|-------------|-------------|--------|-------
120 *  auto_handle       | boolean     |    i        |  i     |
121 *  local             | boolean     |    i        |  i     |
122 *  implicit_handle   | <name,type> |    i        |  i     |
123 *  uuid              | idl_uuid_t      |    i        |  i     |
124 *  port              | int[]       |    i        |  i     |
125 *  version           | unsigned    |    i        |  i     |
126 *  npb               | boolean     |    i        |  i     | 5
127 *  implicit_handle_g | boolean     |  <inferred> |  i     | 10
128 *  double_used       | boolean     |  <inferred> |  i     |
129 *  has_encode_ops    | boolean     |  <inferred> |  i     |
130 *  ------------------|-------------|-------------|--------|-------
131 *  represent_as      | type_t *    |          t  |  t     |
132 *  transmit_as       | type_t *    |          t  |  t     |
133 *  handle            | boolean     |          t  |  t     |
134 *  context           | boolean     |          t  |  t     | 3
135 *  unalign           | boolean     |          t  |  t     | 7
136 *  align             | int         |          t  |  t     | 7
137 *  ref               | boolean     |  f     p t  |a,t,f,p | 6
138 *  unique            | boolean     |  f     p t  |a,t,f,p |
139 *  ptr               | boolean     |        p    |a,t,f,p |
140 *  self_pointing     | boolean     |  <inferred> |  t     | 1
141 *  def_as_tag        | boolean     |  <inferred> |  t     |
142 *  v1_enum           | boolean     |          t  |  t     |
143 *  in                | boolean     |  <inferred> |  t     |
144 *  out               | boolean     |  <inferred> |  t     |
145 *  out_pa_ref        | boolean     |  <inferred> |  t     |
146 *  in_fixed          | boolean     |  <inferred> |  t     |
147 *  out_fixed         | boolean     |  <inferred> |  t     |
148 *  in_varying        | boolean     |  <inferred> |  t     |
149 *  out_varying       | boolean     |  <inferred> |  t     |
150 *  in_pa_stub        | boolean     |  <inferred> |  t     |
151 *  out_pa_stub       | boolean     |  <inferred> |  t     |
152 *  ------------------|-------------|-------------|--------|-------
153 *  broadcast         | boolean     |      o      |  o     |
154 *  enable_allocate   | boolean     |      o      |  o     |
155 *  maybe             | boolean     |      o      |  o     |
156 *  idempotent        | boolean     |      o      |  o     |
157 *  reflect_deletions | boolean     |      o      |  o     |
158 *                    |             |             |        |
159 *  code              | boolean     |    i o      |  o     |
160 *  no_code           | boolean     |    i o      |  o     |
161 *  decode            | boolean     |    i o      |  o     |
162 *  encode            | boolean     |    i o      |  o     |
163 *  explicit_handle   | boolean     |    i o      |  o     |
164 *  no_cancel         | boolean     |    i o      |  o     |
165 *                    |             |             |        |
166 *  has_ins           | boolean     |  <inferred> |  o     |
167 *  has_in_pipes      | boolean     |  <inferred> |  o     |
168 *  has_outs          | boolean     |  <inferred> |  o     |
169 *  has_out_pipes     | boolean     |  <inferred> |  o     |
170 *  has_in_ptrs       | boolean     |  <inferred> |  o     |
171 *  has_out_ptrs      | boolean     |  <inferred> |  o     |
172 *  has_in_ools       | boolean     |  <inferred> |  o     |
173 *  has_out_ools      | boolean     |  <inferred> |  o     |
174 *  has_in_ctx        | boolean     |  <inferred> |  o     |
175 *  has_out_ctx       | boolean     |  <inferred> |  o     |
176 *  has_in_out_ctx    | boolean     |  <inferred> |  o     |
177 *  has_xmit_as       | boolean     |  <inferred> |  o     |
178 *  has_in_full_ptrs  | boolean     |  <inferred> |  o     |
179 *  ------------------|-------------|-------------|--------|-------
180 *  in                | boolean     |        p    |  p     | 8
181 *  out               | boolean     |        p    |  p     | 8
182 *  in_shape          | boolean     |        p    |  p     |
183 *  out_shape         | boolean     |        p    |  p     |
184 *  cs_stag           | boolean     |        p    |  p     |
185 *  cs_drtag          | boolean     |        p    |  p     |
186 *  cs_rtag           | boolean     |        p    |  p     |
187 *  hidden            | boolean     |        p    |  p     |
188 *                    |             |             |        |
189 *  comm_status       | boolean     |      o p    |  p     | 2
190 *  add_comm_status   | boolean     |      o p    |  p     | 9
191 *  fault_status      | boolean     |      o p    |  p     | 2
192 *  add_fault_status  | boolean     |      o p    |  p     | 9
193 *  ------------------|-------------|-------------|--------|-------
194 *  last_is           | ref         |  f     p    |  f     |
195 *  first_is          | ref         |  f     p    |  f     |
196 *  max_is            | ref         |  f     p    |  f     |
197 *  min_is            | ref         |  f     p    |  f     |
198 *  length_is         | ref         |  f     p    |  f     |
199 *  size_is           | ref         |  f     p    |  f     |
200 *  range             | tuple       |  f     p    |  f     |
201 *                    |             |             |        |
202 *  string            | boolean     |  f     p t  |  f     |
203 *  string0           | boolean     |  f     p t  |  f     |
204 *  ignore            | boolean     |  f       t  |  f     |
205 *  small             | boolean     |  f     p t  |  f     |
206 *                    |             |             |        |
207 *  heap              | boolean     |        p t  |  p     |
208 *  in_line           | boolean     |  f i   p t  |  f     |
209 *  out_of_line       | boolean     |  f i   p t  |  f     |
210 *                    |             |             |        |
211 *  context           | boolean     |  f     p    |  f     | 4
212 *  varying           | boolean     |  f     p    |  f,p,t | 11
213 *  ------------------|-------------|-------------|--------|-------
214 *  extern            | boolean     |    i        |  e     |
215 *                    |             |             |        |
216 *  ------------------|-------------|-------------|--------|-------
217 *  f - field or arm attribute
218 *  i - interface attribute
219 *  o - operation attribute
220 *  p - parameter attribute
221 *  t - type attribute
222 *  e - exception attribute
223 *
224 *  notes:
225 *
226 *  1. "Self_pointing" means that a type is or contains a pointer that could
227 *  directly or indirectly point to another instance of itself, i.e. T is
228 *  self_pointing iff (T,T) is in the transitive closure of the "contains
229 *  a pointer to" relation on types.
230 *
231 *  2. While [comm_status] or [fault_status] appears in operation attribute
232 *  position it is represented only as a parameter attribute in the implicit
233 *  parameter which models the function result.
234 *
235 *  3. This is the context with rundown which is denoted by applying the
236 *  [context_handle] attribute to a type.
237 *
238 *  4. This is the context withOUT rundown which is denoted by applying the
239 *  [context_handle] attribute to a field or parameter.
240 *
241 *  5. "npb" stands for "non-parametric binding" which means that either
242 *  auto_handle or implicit_handle also needs to be specified.
243 *
244 *  6. The ref flag is used on parameters to avoid pervasive changes just
245 *  for naming.  In the source this is specified via the lack of [ptr] and
246 *  [unique] on parameters, and by the presence of [ref] on types and fields.
247 *
248 *  7. [unalign] is set to indicate that the aligment_size is set to
249 *  the alignment of the first field in the struct.  [align] puts
250 *  the specified size in the alignment_size field of the type.
251 *
252 *  8. The [in] and [out] synthesized attributes on types indicate that
253 *  there are one or more occurences of that type as [in] or [out] params.
254 *
255 *  9. [add_comm_status] or [add_fault_status] indicates that the an additional
256 *  status_t parameter is added to the argument list.  If no errors occur it
257 *  should be set to the success value, otherwise it contains the error status.
258 *  This is different from the corresponding attribute in that it is used
259 *  only for status and is not an explicit parameter that may be set by the
260 *  programmer.
261 *
262 *  10. When set the [implicit_handle_g] sythesized attribute indicates that
263 *  the type used as the implicit handle is not a handle_t and thus must
264 *  have binding routines generated for it.
265 *
266 *  11. When [varying] is set on an instance location, this indicates the
267 *  usage site is varying.  When set on a type, this indicates that the
268 *  type may be used as varying at some point.
269 *
270 *  On the representation of boolean valued attributes
271 *  --------------------------------------------------
272 *
273 *  Boolean attributes are represented as bits in flag words.  The same
274 *  bit in the same field is used to represent a given attribute regardless
275 *  of the kind of node in which it occurs. In order to achieve this
276 *  regularity and to represent all flags as compactly as possible a
277 *  "bin-packing" algorithm should be used to assign boolean attributes
278 *  to bit positions.  The current assignment is represented by the
279 *  following table.  However, the flags should be manipulated through
280 *  the supplied macros in case the bit assignments need to be changed or
281 *  expanded to more than one 16-bit flag word.
282 *
283 *    bit    | node type in which flag occurs (i.e. field stands for field_n_t):
284 *           | field       | arm     | interface   | operation     | parameter   | type          | array_index
285 *    -------|-------------|---------|-------------|---------------|-------------|---------------|-------------
286 *   0x00001 | in_line     |         | in_line     | broadcast     | in_line     | in_line       | fixed_lower
287 *   0x00002 | out_of_line |         | out_of_line | maybe         | out_of_line | out_of_line   | fixed_upper
288 *   0x00004 | string      | string  | code        | code          | string      | string        |
289 *   0x00008 | string0     | string0 | no_code     | no_code       | string0     | string0       |
290 *   0x00010 | unique      | unique  | auto_handle | idempotent    | unique      | unique        |
291 *   0x00020 | ref         | ref     | local       | has_ins       | ref         | ref           |
292 *   0x00040 | ignore      |         | npb         | has_in_pipes  |             | ignore        |
293 *   0x00080 | small       | small   |impl_handle_g| has_outs      | small       | small         |
294 *   0x00100 | context     | context |double_used  | has_out_pipes | context     | handle        |
295 *   0x00200 | varying     | varying |has_encode_ops|has_in_ctx    | varying     | varying       |
296 *   0x00400 |             |         |             | has_in_ptrs   | in          | in            |
297 *   0x00800 |             |         |             | has_out_ptrs  | out         | out           |
298 *   0x01000 |             |         |             | has_out_ctx   | comm_status | self-pointing |
299 *   0x02000 |             |         |             | has_in_ools   | in_shape    | conformant    |
300 *   0x04000 |             |         |             | has_out_ools  | out_shape   | def_as_tag    |
301 *   0x08000 |             |         |             | has_in_out_ctx|add_com_statu| unalign       |
302 *   0x10000 | ptr         | ptr     | explicit_han| explicit_han  | ptr         | ptr           |
303 *   0x20000 |             |         |             | enable_alloc  | heap        | heap          |
304 *   0x40000 |             |         |             | has_xmit_as   | fault_status| v1_enum       |
305 *   0x80000 |             |         |             | has_full_ptrs |add_flt_statu| out_pa_ref    |
306 *  0x100000 |             |         | decode      | decode        | cs_stag     | in_fixed      |
307 *  0x200000 |             |         | encode      | encode        | cs_drtag    | in_varying    |
308 *  0x400000 |             |         |             |reflect_deletions| cs_rtag   | out_fixed     |
309 *  0x800000 |             |         |             |               | hidden      | out_varying   |
310 *  0x100000 |             |         |             |               |             | in_fixed      |
311 *  0x200000 |             |         |             |               |             | in_varying    |
312 *  0x400000 |             |         |             |               |             | out_fixed     |
313 *  0x800000 |             |         |             |               |             | out_varying   |
314 * 0x1000000 |             |         | no_cancel   | no_cancel     |             | context_rd    |
315 * 0x2000000 |             |         |             |               |             |               |
316 * 0x4000000 |             |         |             |               |             | in_pa_stub    |
317 * 0x8000000 |             |         |             |               |             | out_pa_stub   |
318  */
319
320#include <nidl.h>
321#include <be_pvt.h>
322#include <ir_pvt.h>
323#include <fe_pvt.h>
324#include <nametbl.h>
325
326/* flags used in interface, type, field, parameter attribute flag words */
327#define AST_IN_LINE       0x0001
328#define AST_OUT_OF_LINE   0x0002
329
330/* flags used in interface, operation attribute flag words */
331#define AST_CODE          0x0004
332#define AST_NO_CODE       0x0008
333#define AST_EXPLICIT_HANDLE 0x10000
334#define AST_DECODE        0x100000
335#define AST_ENCODE        0x200000
336#define AST_OBJECT		  0x00400
337#define AST_NO_CANCEL     0x1000000
338
339/* flags used in  operation attribute flag word */
340#define AST_BROADCAST     0x0001
341#define AST_MAYBE         0x0002
342#define AST_IDEMPOTENT    0x0010
343#define AST_HAS_INS       0x0020
344#define AST_HAS_IN_PIPES  0x0040
345#define AST_HAS_OUTS      0x0080
346#define AST_HAS_OUT_PIPES 0x0100
347#define AST_HAS_IN_CTX    0x0200
348#define AST_HAS_IN_PTRS   0x0400
349#define AST_HAS_OUT_PTRS  0x0800
350#define AST_HAS_OUT_CTX   0x1000
351#define AST_HAS_OUT_OOLS  0x2000
352#define AST_HAS_IN_OOLS   0x4000
353#define AST_HAS_IN_OUT_CTX 0x8000
354#define AST_ENABLE_ALLOCATE 0x20000
355#define AST_HAS_FULL_PTRS   0x40000
356#define AST_HAS_XMIT_AS     0x80000
357#define AST_REFLECT_DELETIONS 0x400000
358
359/* flags used in interface attribute flag word */
360#define AST_AUTO_HANDLE   0x0010
361#define AST_LOCAL         0x0020
362#define AST_NPB           0x0040
363#define AST_IMPLICIT_HANDLE_G  0x0080
364#define AST_DOUBLE_USED   0x00100
365#define AST_HAS_ENCODE_OPS 0x00200
366
367/* flags used in type, field, parameter attribute flag words */
368#define AST_STRING        0x0004
369#define AST_STRING0       0x0008
370#define AST_IGNORE        0x0040
371#define AST_SMALL         0x0080
372
373/* flags used in type, parameter attribute flag words */
374#define AST_HEAP         0x20000
375
376/* flags used in type flag word */
377#define AST_HANDLE        0x0100
378#define AST_SELF_POINTER  0x1000
379#define AST_CONFORMANT    0x2000
380#define AST_DEF_AS_TAG    0x4000
381#define AST_REF           0x0020
382#define AST_UNIQUE        0x0010
383#define AST_PTR          0x10000
384#define AST_UNALIGN       0x8000
385#define AST_V1_ENUM      0x40000
386#define AST_OUT_PA_REF   0x80000
387#define AST_IN_FIXED    0x100000
388#define AST_IN_VARYING  0x200000
389#define AST_OUT_FIXED   0x400000
390#define AST_OUT_VARYING 0x800000
391#define AST_CONTEXT_RD  0x1000000
392#define AST_IN_PA_STUB  0x4000000
393#define AST_OUT_PA_STUB 0x8000000
394
395/* flags used in parameter flag word */
396#define AST_IN                  0x0400
397#define AST_OUT                 0x0800
398#define AST_COMM_STATUS         0x1000
399#define AST_IN_SHAPE            0x2000
400#define AST_OUT_SHAPE           0x4000
401#define AST_ADD_COMM_STATUS     0x8000
402#define AST_FAULT_STATUS       0x40000
403#define AST_ADD_FAULT_STATUS   0x80000
404#define AST_CS_STAG           0x100000
405#define AST_CS_DRTAG          0x200000
406#define AST_CS_RTAG           0x400000
407#define AST_HIDDEN            0x800000
408
409/* flag used in parameter and field words */
410#define AST_CONTEXT       0x0100
411#define AST_VARYING       0x0200
412
413/* flag used in field words */
414
415/* flags used in AST_array_index_n_t's flag word */
416#define AST_FIXED_LOWER   0x0001
417#define AST_FIXED_UPPER   0x0002
418
419/* flags used in exception attribute flag words */
420#define AST_EXTERN        0x0001
421
422/*
423 *  Macros for set, clearing, and testing the flag bits in AST nodes.
424 *  To be used to achieve representation independence.
425 */
426
427#define AST_CLR_FLAGS(np)         (np)->flags = 0
428
429#define AST_DOUBLE_USED_SET(np)       (AST_DOUBLE_USED & (np)->flags)
430#define AST_CLR_DOUBLE_USED(np)       (np)->flags &= ~AST_DOUBLE_USED
431#define AST_SET_DOUBLE_USED(np)       (np)->flags |= AST_DOUBLE_USED
432
433#define AST_HAS_ENCODE_OPS_SET(np)    (AST_HAS_ENCODE_OPS & (np)->flags)
434#define AST_CLR_HAS_ENCODE_OPS(np)    (np)->flags &= ~AST_HAS_ENCODE_OPS
435#define AST_SET_HAS_ENCODE_OPS(np)    (np)->flags |= AST_HAS_ENCODE_OPS
436
437#define AST_UNALIGN_SET(np)       (AST_UNALIGN & (np)->flags)
438#define AST_CLR_UNALIGN(np)       (np)->flags &= ~AST_UNALIGN
439#define AST_SET_UNALIGN(np)       (np)->flags |= AST_UNALIGN
440
441#define AST_V1_ENUM_SET(np)       (AST_V1_ENUM & (np)->flags)
442#define AST_CLR_V1_ENUM(np)       (np)->flags &= ~AST_V1_ENUM
443#define AST_SET_V1_ENUM(np)       (np)->flags |= AST_V1_ENUM
444
445#define AST_HEAP_SET(np)          (AST_HEAP & (np)->flags)
446#define AST_CLR_HEAP(np)          (np)->flags &= ~AST_HEAP
447#define AST_SET_HEAP(np)          (np)->flags |= AST_HEAP
448
449#define AST_IN_LINE_SET(np)       (AST_IN_LINE & (np)->flags)
450#define AST_CLR_IN_LINE(np)       (np)->flags &= ~AST_IN_LINE
451#define AST_SET_IN_LINE(np)       (np)->flags |= AST_IN_LINE
452
453#define AST_OUT_OF_LINE_SET(np)   (AST_OUT_OF_LINE & (np)->flags)
454#define AST_CLR_OUT_OF_LINE(np)   (np)->flags &= ~AST_OUT_OF_LINE
455#define AST_SET_OUT_OF_LINE(np)   (np)->flags |= AST_OUT_OF_LINE
456
457#define AST_STRING_SET(np)        (AST_STRING & (np)->flags)
458#define AST_CLR_STRING(np)        (np)->flags &= ~(AST_STRING)
459#define AST_SET_STRING(np)        (np)->flags |= AST_STRING
460
461#define AST_STRING0_SET(np)       (AST_STRING0 & (np)->flags)
462#define AST_CLR_STRING0(np)       (np)->flags &= ~AST_STRING0
463#define AST_SET_STRING0(np)       (np)->flags |= AST_STRING0
464
465#define AST_UNIQUE_SET(np)        (AST_UNIQUE & (np)->flags)
466#define AST_CLR_UNIQUE(np)        (np)->flags &= ~AST_UNIQUE
467#define AST_SET_UNIQUE(np)        (np)->flags |= AST_UNIQUE
468
469#define AST_REF_SET(np)           (AST_REF & (np)->flags)
470#define AST_CLR_REF(np)           (np)->flags &= ~AST_REF
471#define AST_SET_REF(np)           (np)->flags |= AST_REF
472
473#define AST_PTR_SET(np)           (AST_PTR & (np)->flags)
474#define AST_CLR_PTR(np)           (np)->flags &= ~AST_PTR
475#define AST_SET_PTR(np)           (np)->flags |= AST_PTR
476
477#define AST_IGNORE_SET(np)        (AST_IGNORE & (np)->flags)
478#define AST_CLR_IGNORE(np)        (np)->flags &= ~AST_IGNORE
479#define AST_SET_IGNORE(np)        (np)->flags |= AST_IGNORE
480
481#define AST_SMALL_SET(np)         (AST_SMALL & (np)->flags)
482#define AST_CLR_SMALL(np)         (np)->flags &= ~AST_SMALL
483#define AST_SET_SMALL(np)         (np)->flags |= AST_SMALL
484
485#define AST_CODE_SET(np)          (AST_CODE & (np)->flags)
486#define AST_CLR_CODE(np)          (np)->flags &= ~AST_CODE
487#define AST_SET_CODE(np)          (np)->flags |= AST_CODE
488
489#define AST_NO_CODE_SET(np)       (AST_NO_CODE & (np)->flags)
490#define AST_CLR_NO_CODE(np)       (np)->flags &= ~AST_NO_CODE
491#define AST_SET_NO_CODE(np)       (np)->flags |= AST_NO_CODE
492
493#define AST_DECODE_SET(np)        (AST_DECODE & (np)->flags)
494#define AST_CLR_DECODE(np)        (np)->flags &= ~AST_DECODE
495#define AST_SET_DECODE(np)        (np)->flags |= AST_DECODE
496
497#define AST_ENCODE_SET(np)        (AST_ENCODE & (np)->flags)
498#define AST_CLR_ENCODE(np)        (np)->flags &= ~AST_ENCODE
499#define AST_SET_ENCODE(np)        (np)->flags |= AST_ENCODE
500
501#define AST_EXPLICIT_HANDLE_SET(np) (AST_EXPLICIT_HANDLE & (np)->flags)
502#define AST_CLR_EXPLICIT_HANDLE(np) (np)->flags &= ~AST_EXPLICIT_HANDLE
503#define AST_SET_EXPLICIT_HANDLE(np) (np)->flags |= AST_EXPLICIT_HANDLE
504
505#define AST_AUTO_HANDLE_SET(np)   (AST_AUTO_HANDLE & (np)->flags)
506#define AST_CLR_AUTO_HANDLE(np)   (np)->flags &= ~AST_AUTO_HANDLE
507#define AST_SET_AUTO_HANDLE(np)   (np)->flags |= AST_AUTO_HANDLE
508
509#define AST_LOCAL_SET(np)         (AST_LOCAL & (np)->flags)
510#define AST_CLR_LOCAL(np)         (np)->flags &= ~AST_LOCAL
511#define AST_SET_LOCAL(np)         (np)->flags |= AST_LOCAL
512
513#define AST_OBJECT_SET(np)			 (AST_OBJECT & (np)->flags)
514#define AST_CLR_OBJECT(np)			 ((np)->flags &= ~AST_OBJECT
515#define AST_SET_OBJECT(np)			 (np)->flags |= AST_OBJECT
516
517#define AST_NO_CANCEL_SET(np)     (AST_NO_CANCEL & (np)->flags)
518#define AST_CLR_NO_CANCEL(np)     (np)->flags &= ~AST_NO_CANCEL
519#define AST_SET_NO_CANCEL(np)     (np)->flags |= AST_NO_CANCEL
520
521#define AST_NPB_SET(np)           (AST_NPB & (np)->flags)
522#define AST_CLR_NPB(np)           (np)->flags &= ~AST_NPB
523#define AST_SET_NPB(np)           (np)->flags |= AST_NPB
524
525#define AST_IMPLICIT_HANDLE_G_SET(np)   (AST_IMPLICIT_HANDLE_G & (np)->flags)
526#define AST_CLR_IMPLICIT_HANDLE_G(np)   (np)->flags &= ~AST_IMPLICIT_HANDLE_G
527#define AST_SET_IMPLICIT_HANDLE_G(np)   (np)->flags |= AST_IMPLICIT_HANDLE_G
528
529#define AST_BROADCAST_SET(np)     (AST_BROADCAST & (np)->flags)
530#define AST_CLR_BROADCAST(np)     (np)->flags &= ~AST_BROADCAST
531#define AST_SET_BROADCAST(np)     (np)->flags |= AST_BROADCAST
532
533#define AST_ENABLE_ALLOCATE_SET(np) (AST_ENABLE_ALLOCATE & (np)->flags)
534#define AST_CLR_ENABLE_ALLOCATE(np) (np)->flags &= ~AST_ENABLE_ALLOCATE
535#define AST_SET_ENABLE_ALLOCATE(np) (np)->flags |= AST_ENABLE_ALLOCATE
536
537#define AST_HAS_FULL_PTRS_SET(np)  (AST_HAS_FULL_PTRS & (np)->flags)
538#define AST_CLR_HAS_FULL_PTRS(np)  (np)->flags &= ~AST_HAS_FULL_PTRS
539#define AST_SET_HAS_FULL_PTRS(np)  (np)->flags |= AST_HAS_FULL_PTRS
540
541#define AST_MAYBE_SET(np)         (AST_MAYBE & (np)->flags)
542#define AST_CLR_MAYBE(np)         (np)->flags &= ~AST_MAYBE
543#define AST_SET_MAYBE(np)         (np)->flags |= AST_MAYBE
544
545#define AST_IDEMPOTENT_SET(np)    (AST_IDEMPOTENT & (np)->flags)
546#define AST_CLR_IDEMPOTENT(np)    (np)->flags &= ~AST_IDEMPOTENT
547#define AST_SET_IDEMPOTENT(np)    (np)->flags |= AST_IDEMPOTENT
548
549#define AST_REFLECT_DELETIONS_SET(np)   (AST_REFLECT_DELETIONS & (np)->flags)
550#define AST_CLR_REFLECT_DELETIONS(np)   (np)->flags &= ~AST_REFLECT_DELETIONS
551#define AST_SET_REFLECT_DELETIONS(np)   (np)->flags |= AST_REFLECT_DELETIONS
552
553#define AST_HAS_INS_SET(np)       (AST_HAS_INS & (np)->flags)
554#define AST_CLR_HAS_INS(np)       (np)->flags &= ~AST_HAS_INS
555#define AST_SET_HAS_INS(np)       (np)->flags |= AST_HAS_INS
556
557#define AST_HAS_IN_PIPES_SET(np)  (AST_HAS_IN_PIPES & (np)->flags)
558#define AST_CLR_HAS_IN_PIPES(np)  (np)->flags &= ~AST_HAS_IN_PIPES
559#define AST_SET_HAS_IN_PIPES(np)  (np)->flags |= AST_HAS_IN_PIPES
560
561#define AST_HAS_IN_PTRS_SET(np)  (AST_HAS_IN_PTRS & (np)->flags)
562#define AST_CLR_HAS_IN_PTRS(np)  (np)->flags &= ~AST_HAS_IN_PTRS
563#define AST_SET_HAS_IN_PTRS(np)  (np)->flags |= AST_HAS_IN_PTRS
564
565#define AST_HAS_IN_CTX_SET(np)    (AST_HAS_IN_CTX & (np)->flags)
566#define AST_CLR_HAS_IN_CTX(np)    (np)->flags &= ~AST_HAS_IN_CTX
567#define AST_SET_HAS_IN_CTX(np)    (np)->flags |= AST_HAS_IN_CTX
568
569#define AST_HAS_OUT_CTX_SET(np)   (AST_HAS_OUT_CTX & (np)->flags)
570#define AST_CLR_HAS_OUT_CTX(np)   (np)->flags &= ~AST_HAS_OUT_CTX
571#define AST_SET_HAS_OUT_CTX(np)   (np)->flags |= AST_HAS_OUT_CTX
572
573#define AST_HAS_IN_OUT_CTX_SET(np)   (AST_HAS_IN_OUT_CTX & (np)->flags)
574#define AST_CLR_HAS_IN_OUT_CTX(np)   (np)->flags &= ~AST_HAS_IN_OUT_CTX
575#define AST_SET_HAS_IN_OUT_CTX(np)   (np)->flags |= AST_HAS_IN_OUT_CTX
576
577#define AST_HAS_OUTS_SET(np)      (AST_HAS_OUTS & (np)->flags)
578#define AST_CLR_HAS_OUTS(np)      (np)->flags &= ~AST_HAS_OUTS
579#define AST_SET_HAS_OUTS(np)      (np)->flags |= AST_HAS_OUTS
580
581#define AST_HAS_OUT_PIPES_SET(np) (AST_HAS_OUT_PIPES & (np)->flags)
582#define AST_CLR_HAS_OUT_PIPES(np) (np)->flags &= ~AST_HAS_OUT_PIPES
583#define AST_SET_HAS_OUT_PIPES(np) (np)->flags |= AST_HAS_OUT_PIPES
584
585#define AST_HAS_OUT_PTRS_SET(np) (AST_HAS_OUT_PTRS & (np)->flags)
586#define AST_CLR_HAS_OUT_PTRS(np) (np)->flags &= ~AST_HAS_OUT_PTRS
587#define AST_SET_HAS_OUT_PTRS(np) (np)->flags |= AST_HAS_OUT_PTRS
588
589#define AST_HAS_OUT_OOLS_SET(np) (AST_HAS_OUT_OOLS & (np)->flags)
590#define AST_CLR_HAS_OUT_OOLS(np) (np)->flags &= ~AST_HAS_OUT_OOLS
591#define AST_SET_HAS_OUT_OOLS(np) (np)->flags |= AST_HAS_OUT_OOLS
592
593#define AST_HAS_IN_OOLS_SET(np) (AST_HAS_IN_OOLS & (np)->flags)
594#define AST_CLR_HAS_IN_OOLS(np) (np)->flags &= ~AST_HAS_IN_OOLS
595#define AST_SET_HAS_IN_OOLS(np) (np)->flags |= AST_HAS_IN_OOLS
596
597#define AST_HAS_XMIT_AS_SET(np) (AST_HAS_XMIT_AS & (np)->flags)
598#define AST_CLR_HAS_XMIT_AS(np) (np)->flags &= ~AST_HAS_XMIT_AS
599#define AST_SET_HAS_XMIT_AS(np) (np)->flags |= AST_HAS_XMIT_AS
600
601#define AST_OUT_PA_REF_SET(np) (AST_OUT_PA_REF & (np)->flags)
602#define AST_CLR_OUT_PA_REF(np) (np)->flags &= ~AST_OUT_PA_REF
603#define AST_SET_OUT_PA_REF(np) (np)->flags |= AST_OUT_PA_REF
604
605#define AST_IN_SET(np)            (AST_IN & (np)->flags)
606#define AST_CLR_IN(np)            (np)->flags &= ~AST_IN
607#define AST_SET_IN(np)            (np)->flags |= AST_IN
608
609#define AST_OUT_SET(np)           (AST_OUT & (np)->flags)
610#define AST_CLR_OUT(np)           (np)->flags &= ~AST_OUT
611#define AST_SET_OUT(np)           (np)->flags |= AST_OUT
612
613#define AST_IN_SHAPE_SET(np)      (AST_IN_SHAPE & (np)->flags)
614#define AST_CLR_IN_SHAPE(np)      (np)->flags &= ~AST_IN_SHAPE
615#define AST_SET_IN_SHAPE(np)      (np)->flags |= AST_IN_SHAPE
616
617#define AST_OUT_SHAPE_SET(np)     (AST_OUT_SHAPE & (np)->flags)
618#define AST_CLR_OUT_SHAPE(np)     (np)->flags &= ~AST_OUT_SHAPE
619#define AST_SET_OUT_SHAPE(np)     (np)->flags |= AST_OUT_SHAPE
620
621#define AST_COMM_STATUS_SET(np)   (AST_COMM_STATUS & (np)->flags)
622#define AST_CLR_COMM_STATUS(np)   (np)->flags &= ~AST_COMM_STATUS
623#define AST_SET_COMM_STATUS(np)   (np)->flags |= AST_COMM_STATUS
624
625#define AST_ADD_COMM_STATUS_SET(np) (AST_ADD_COMM_STATUS & (np)->flags)
626#define AST_CLR_ADD_COMM_STATUS(np) (np)->flags &= ~AST_ADD_COMM_STATUS
627#define AST_SET_ADD_COMM_STATUS(np) (np)->flags |= AST_ADD_COMM_STATUS
628
629#define AST_FAULT_STATUS_SET(np)   (AST_FAULT_STATUS & (np)->flags)
630#define AST_CLR_FAULT_STATUS(np)   (np)->flags &= ~AST_FAULT_STATUS
631#define AST_SET_FAULT_STATUS(np)   (np)->flags |= AST_FAULT_STATUS
632
633#define AST_ADD_FAULT_STATUS_SET(np) (AST_ADD_FAULT_STATUS & (np)->flags)
634#define AST_CLR_ADD_FAULT_STATUS(np) (np)->flags &= ~AST_ADD_FAULT_STATUS
635#define AST_SET_ADD_FAULT_STATUS(np) (np)->flags |= AST_ADD_FAULT_STATUS
636
637#define AST_CS_STAG_SET(np)     (AST_CS_STAG & (np)->flags)
638#define AST_CLR_CS_STAG(np)     (np)->flags &= ~AST_CS_STAG
639#define AST_SET_CS_STAG(np)     (np)->flags |= AST_CS_STAG
640
641#define AST_CS_DRTAG_SET(np)    (AST_CS_DRTAG & (np)->flags)
642#define AST_CLR_CS_DRTAG(np)    (np)->flags &= ~AST_CS_DRTAG
643#define AST_SET_CS_DRTAG(np)    (np)->flags |= AST_CS_DRTAG
644
645#define AST_CS_RTAG_SET(np)     (AST_CS_RTAG & (np)->flags)
646#define AST_CLR_CS_RTAG(np)     (np)->flags &= ~AST_CS_RTAG
647#define AST_SET_CS_RTAG(np)     (np)->flags |= AST_CS_RTAG
648
649#define AST_HIDDEN_SET(np)      (AST_HIDDEN & (np)->flags)
650#define AST_CLR_HIDDEN(np)      (np)->flags &= ~AST_HIDDEN
651#define AST_SET_HIDDEN(np)      (np)->flags |= AST_HIDDEN
652
653#define AST_HANDLE_SET(np)        (AST_HANDLE & (np)->flags)
654#define AST_CLR_HANDLE(np)        (np)->flags &= ~AST_HANDLE
655#define AST_SET_HANDLE(np)        (np)->flags |= AST_HANDLE
656
657#define AST_CONTEXT_RD_SET(np)    (AST_CONTEXT_RD & (np)->flags)
658#define AST_CLR_CONTEXT_RD(np)    (np)->flags &= ~AST_CONTEXT_RD
659#define AST_SET_CONTEXT_RD(np)    (np)->flags |= AST_CONTEXT_RD
660
661#define AST_SELF_POINTER_SET(np)  (AST_SELF_POINTER & (np)->flags)
662#define AST_CLR_SELF_POINTER(np)  (np)->flags &= ~AST_SELF_POINTER
663#define AST_SET_SELF_POINTER(np)  (np)->flags |= AST_SELF_POINTER
664
665#define AST_CONTEXT_SET(np)       (AST_CONTEXT & (np)->flags)
666#define AST_CLR_CONTEXT(np)       (np)->flags &= ~AST_CONTEXT
667#define AST_SET_CONTEXT(np)       (np)->flags |= AST_CONTEXT
668
669#define AST_FIXED_LOWER_SET(np)   (AST_FIXED_LOWER & (np)->flags)
670#define AST_CLR_FIXED_LOWER(np)   (np)->flags &= ~AST_FIXED_LOWER
671#define AST_SET_FIXED_LOWER(np)   (np)->flags |= AST_FIXED_LOWER
672
673#define AST_FIXED_UPPER_SET(np)   (AST_FIXED_UPPER & (np)->flags)
674#define AST_CLR_FIXED_UPPER(np)   (np)->flags &= ~AST_FIXED_UPPER
675#define AST_SET_FIXED_UPPER(np)   (np)->flags |= AST_FIXED_UPPER
676
677#define AST_CONFORMANT_SET(np)    (AST_CONFORMANT & (np)->flags)
678#define AST_CLR_CONFORMANT(np)    (np)->flags &= ~AST_CONFORMANT
679#define AST_SET_CONFORMANT(np)    (np)->flags |= AST_CONFORMANT
680
681#define AST_VARYING_SET(np)       (AST_VARYING & (np)->flags)
682#define AST_CLR_VARYING(np)       (np)->flags &= ~AST_VARYING
683#define AST_SET_VARYING(np)       (np)->flags |= AST_VARYING
684
685#define AST_DEF_AS_TAG_SET(np)    (AST_DEF_AS_TAG & (np)->flags)
686#define AST_CLR_DEF_AS_TAG(np)    (np)->flags &= ~AST_DEF_AS_TAG
687#define AST_SET_DEF_AS_TAG(np)    (np)->flags |= AST_DEF_AS_TAG
688
689#define AST_IN_FIXED_SET(np)       (AST_IN_FIXED & (np)->flags)
690#define AST_CLR_IN_FIXED(np)       (np)->flags &= ~AST_IN_FIXED
691#define AST_SET_IN_FIXED(np)       (np)->flags |= AST_IN_FIXED
692
693#define AST_IN_VARYING_SET(np)       (AST_IN_VARYING & (np)->flags)
694#define AST_CLR_IN_VARYING(np)       (np)->flags &= ~AST_IN_VARYING
695#define AST_SET_IN_VARYING(np)       (np)->flags |= AST_IN_VARYING
696
697#define AST_OUT_FIXED_SET(np)       (AST_OUT_FIXED & (np)->flags)
698#define AST_CLR_OUT_FIXED(np)       (np)->flags &= ~AST_OUT_FIXED
699#define AST_SET_OUT_FIXED(np)       (np)->flags |= AST_OUT_FIXED
700
701#define AST_OUT_VARYING_SET(np)       (AST_OUT_VARYING & (np)->flags)
702#define AST_CLR_OUT_VARYING(np)       (np)->flags &= ~AST_OUT_VARYING
703#define AST_SET_OUT_VARYING(np)       (np)->flags |= AST_OUT_VARYING
704
705#define AST_IN_PA_STUB_SET(np)       (AST_IN_PA_STUB & (np)->flags)
706#define AST_CLR_IN_PA_STUB(np)       (np)->flags &= ~AST_IN_PA_STUB
707#define AST_SET_IN_PA_STUB(np)       (np)->flags |= AST_IN_PA_STUB
708
709#define AST_OUT_PA_STUB_SET(np)       (AST_OUT_PA_STUB & (np)->flags)
710#define AST_CLR_OUT_PA_STUB(np)       (np)->flags &= ~AST_OUT_PA_STUB
711#define AST_SET_OUT_PA_STUB(np)       (np)->flags |= AST_OUT_PA_STUB
712
713#define AST_EXTERN_SET(np)  (AST_EXTERN & (np)->flags)
714#define AST_CLR_EXTERN(np)  (np)->flags &= ~AST_EXTERN
715#define AST_SET_EXTERN(np)  (np)->flags |= AST_EXTERN
716
717/* Mutable pointers are represented by unique and ref bits clear */
718#define AST_MUTABLE_SET(np)       (((np)->flags & (AST_UNIQUE|AST_REF)) == 0)
719#define AST_SET_MUTABLE(np)       ((np) == (np))
720
721/*
722 *  A S T _ f l a g s _ t
723 *
724 *  32-bit flag word
725 */
726
727typedef unsigned long AST_flags_t;
728
729/*
730 *  A S T _ i n t e r f a c e _ n _ t
731 */
732
733typedef struct AST_interface_n_t {
734    fe_info_t            *fe_info;
735    be_info_t            be_info;
736
737    NAMETABLE_id_t       name;
738
739    /*
740     * interface attributes
741     */
742    nidl_uuid_t         uuid;
743    unsigned long int   version;
744    int                 number_of_ports;        /* Number of protocol/endpoints below */
745    STRTAB_str_t        *protocol;              /* Pointer to array of protocol strings */
746    STRTAB_str_t        *endpoints;             /* Pointer to array of endpoint strings */
747    NAMETABLE_id_t      implicit_handle_name;
748    NAMETABLE_id_t      implicit_handle_type_name;
749    struct AST_type_n_t *implicit_handle_type;
750    int                 op_count;               /* synthsized: */
751    AST_flags_t         flags;
752    /*
753     *  The following five fields head lists of type_p_n_t nodes that point
754     *  to exported types that, in one way or another, oblige the backend
755     *  to construct routines other than the basic stub routines for the
756     *  operations of the interface.
757     */
758    struct AST_type_p_n_t *pipe_types; /* synth: list of pipe types */
759    struct AST_type_p_n_t *ool_types;  /* synth: list of [out_of_line] types */
760    struct AST_type_p_n_t *ra_types;   /* synth: list of [represent_as] types */
761    struct AST_type_p_n_t *cs_types;   /* synth: list of [cs_char] types */
762    struct AST_type_p_n_t *sp_types;   /* synth: list of self_pointer types */
763    struct AST_type_p_n_t *pa_types;   /* synth: list of pointed-at types */
764    struct AST_type_p_n_t *up_types;   /* synth: list of unions containing pointers */
765    struct AST_include_n_t *includes;
766    struct AST_import_n_t  *imports;
767    struct AST_export_n_t  *exports;
768    struct AST_exception_n_t *exceptions;  /* list of user-defined exceptions */
769    NAMETABLE_id_t     cs_tag_rtn_name; /* [cs_tag_rtn] name if any */
770    struct AST_name_n_t   *cs_tag_rtns; /* synth: list of [cs_tag_rtn] names */
771    NAMETABLE_id_t  binding_callout_name;  /* [binding_callout] name if any */
772    NAMETABLE_id_t  inherited_interface_name;	/* base class interface name for ORPC */
773    int pointer_default;	/* for pointer_default() attribute: values are
774				0, ASTP_REF, ASTP_UNIQUE, or ASTP_PTR
775			 */
776    struct AST_type_n_t * orpc_intf_type; /* type for ORPC */
777    struct AST_interface_n_t *prev; /* Previous sibling interface */
778} AST_interface_n_t;
779
780/*
781 *  A S T _ t y p e _ p _ n _ t
782 */
783
784typedef struct AST_type_p_n_t {
785    fe_info_t             *fe_info;
786    be_info_t             be_info;
787    struct AST_type_p_n_t *next;
788    struct AST_type_p_n_t *last;
789    struct AST_type_n_t   *type;
790} AST_type_p_n_t;
791
792/*
793 *  A S T _ i n c l u d e  _ n _ t
794 */
795
796typedef struct AST_include_n_t {
797    fe_info_t              *fe_info;
798    be_info_t              be_info;
799    struct AST_include_n_t *next;
800    struct AST_include_n_t *last;
801    STRTAB_str_t           file_name;
802    STRTAB_str_t           simple_file_name;
803} AST_include_n_t;
804
805/*
806 *  A S T _ e x c e p t i o n _ n _ t
807 */
808
809typedef struct AST_exception_n_t {
810    fe_info_t                   *fe_info;
811    be_info_t                   be_info;
812    struct AST_exception_n_t    *next;
813    struct AST_exception_n_t    *last;
814    NAMETABLE_id_t              name;
815    AST_flags_t                 flags;
816} AST_exception_n_t;
817
818/*
819 *  A S T _ n a m e _ n _ t
820 */
821
822typedef struct AST_name_n_t {
823    fe_info_t               *fe_info;
824    be_info_t               be_info;
825    struct AST_name_n_t     *next;
826    struct AST_name_n_t     *last;
827    NAMETABLE_id_t          name;
828} AST_name_n_t;
829
830/*
831 *  A S T _ i m p o r t _ n _ t
832 */
833
834typedef struct AST_import_n_t {
835    fe_info_t             *fe_info;
836    be_info_t             be_info;
837    struct AST_import_n_t *next;
838    struct AST_import_n_t *last;
839    STRTAB_str_t          file_name;
840    AST_interface_n_t     *interface;
841} AST_import_n_t;
842
843/*
844 *  A S T _ e x p o r t _ k _ t
845 */
846
847typedef enum {
848    AST_constant_k,
849    AST_operation_k,
850    AST_type_k,
851    AST_cpp_quote_k
852} AST_export_k_t;
853
854/*
855 *  A S T _ e x p o r t _ n _ t
856 */
857
858typedef struct AST_export_n_t {
859    fe_info_t             *fe_info;
860    be_info_t             be_info;
861    struct AST_export_n_t *next;
862    struct AST_export_n_t *last;
863    AST_export_k_t        kind;
864    union {
865        struct AST_constant_n_t  *exported_constant;
866        struct AST_type_n_t      *exported_type;
867        struct AST_operation_n_t *exported_operation;
868        struct AST_cpp_quote_n_t *exported_cpp_quote;
869    } thing_p;
870} AST_export_n_t;
871
872//this is for CPP_quotes take place inside interface (from Brian originally, extended by wfu
873typedef struct AST_cpp_quote_n_t {
874    fe_info_t              *fe_info;
875    be_info_t              be_info;
876
877    struct AST_cpp_quotes_n_t *next;
878    struct AST_cpp_quotes_n_t *last;
879    STRTAB_str_t           text;
880} AST_cpp_quote_n_t;
881
882/*
883 *  A S T _ c o n s t a n t _ k _ t
884 */
885
886typedef enum {
887    AST_nil_const_k,
888    AST_int_const_k,
889    AST_hyper_int_const_k,
890    AST_char_const_k,
891    AST_string_const_k,
892    AST_boolean_const_k
893} AST_constant_k_t;
894
895#define AST_EXP_CONSTANT		0x000000000
896#define AST_EXP_SUB_EXP			0x000000001
897#define AST_EXP_UNARY_NOT		0x000000002
898#define AST_EXP_UNARY_TILDE		0x000000004
899#define AST_EXP_UNARY_PLUS		0x000000008
900#define AST_EXP_UNARY_MINUS		0x000000010
901#define AST_EXP_UNARY_STAR		0x000000020
902#define AST_EXP_1_OP_MASK		0x000000fff
903
904#define AST_EXP_BINARY_PERCENT		0x000001000
905#define AST_EXP_BINARY_SLASH		0x000002000
906#define AST_EXP_BINARY_STAR		0x000004000
907#define AST_EXP_BINARY_MINUS		0x000008000
908#define AST_EXP_BINARY_PLUS		0x000010000
909#define AST_EXP_BINARY_RSHIFT		0x000020000
910#define AST_EXP_BINARY_LSHIFT		0x000040000
911#define AST_EXP_BINARY_GE		0x000080000
912#define AST_EXP_BINARY_LE		0x000100000
913#define AST_EXP_BINARY_GT		0x000200000
914#define AST_EXP_BINARY_LT		0x000400000
915#define AST_EXP_BINARY_NE		0x000800000
916#define AST_EXP_BINARY_EQUAL		0x001000000
917#define AST_EXP_BINARY_AND		0x002000000
918#define AST_EXP_BINARY_OR		0x004000000
919#define AST_EXP_BINARY_XOR		0x008000000
920#define AST_EXP_BINARY_LOG_OR		0x010000000
921#define AST_EXP_BINARY_LOG_AND		0x020000000
922#define AST_EXP_TUPLE			0x040000000
923#define AST_EXP_2_OP_MASK		0x0fffff000
924
925#define AST_EXP_TERNARY_OP		0x000000001
926#define AST_EXP_3_OP_MASK		0x100000000ULL
927
928/*
929 *  A S T _ c o n s t a n t _ n _ t
930 */
931
932typedef struct AST_constant_n_t {
933    fe_info_t               *fe_info;
934    be_info_t               be_info;
935    struct AST_constant_n_t *next;
936    struct AST_constant_n_t *last;
937    NAMETABLE_id_t          name;
938    struct AST_constant_n_t *defined_as;
939    AST_constant_k_t        kind;
940    union {
941        STRTAB_str_t string_val;
942        char         char_val;
943        boolean      boolean_val;
944        long int     int_val;
945        struct {
946            long int high;
947            unsigned long int low;
948        }            hyper_int_val;
949    } value;
950    boolean int_signed;
951} AST_constant_n_t;
952
953/*
954 *  A S T _ t y p e _ k _ t
955 */
956
957typedef enum {
958    AST_handle_k,
959
960    AST_boolean_k, AST_byte_k, AST_character_k,
961
962    AST_small_integer_k, AST_short_integer_k, AST_long_integer_k,
963    AST_hyper_integer_k,
964
965    AST_small_unsigned_k, AST_short_unsigned_k, AST_long_unsigned_k,
966    AST_hyper_unsigned_k,
967
968    AST_short_float_k, AST_long_float_k,
969
970    AST_array_k, AST_structure_k, AST_pipe_k, AST_pointer_k, AST_void_k,
971    AST_function_k, AST_disc_union_k, AST_enum_k,
972
973    AST_null_k,	 AST_interface_k
974} AST_type_k_t;
975
976/*
977 *  A S T _ t y p e _ n _ t
978 */
979
980typedef struct AST_type_n_t {
981    fe_info_t           *fe_info;
982    be_info_t           be_info;
983    NAMETABLE_id_t      name;        /* NAMETABLE_NIL_ID iff anonymous type exp */
984    struct AST_type_n_t *defined_as;
985    AST_type_k_t        kind;
986    union {
987        struct AST_array_n_t       *array;        /* kind == array_k */
988        struct AST_disc_union_n_t  *disc_union;   /*  "   == disc_union_k */
989        struct AST_enumeration_n_t *enumeration;  /*  "   == enum_k */
990        struct AST_pipe_n_t        *pipe;         /*  "   == pipe_k */
991        struct AST_pointer_n_t     *pointer;      /*  "   == pointer_k */
992        struct AST_operation_n_t   *function;     /*  "   == function_k */
993        struct AST_structure_n_t   *structure;    /*  "   == structure_k */
994	struct AST_interface_n_t   *interface;	  /*  "   == interface_k */
995    } type_structure;
996
997    /* type attributes */
998    AST_flags_t           flags;
999    struct AST_type_n_t   *xmit_as_type;
1000    struct AST_rep_as_n_t *rep_as_type;
1001    struct AST_cs_char_n_t *cs_char_type;
1002
1003    int                 ndr_size;       /* size of type in bytes; 0 means unspecified */
1004    int                 alignment_size; /* 0 means [unaligned] was specified */
1005    struct AST_type_n_t   *array_rep_type;
1006    IR_info_t           ir_info;
1007    struct IR_tup_n_t   *data_tups;     /* Intermediate rep tuples */
1008    NAMETABLE_id_t      iid_is_name;    /* name of iis_is */
1009} AST_type_n_t;
1010
1011/*
1012 *  A S T _ r e p _ a s _ n _ t
1013 */
1014
1015typedef struct AST_rep_as_n_t {
1016    fe_info_t             *fe_info;
1017    be_info_t             be_info;
1018    NAMETABLE_id_t        type_name;
1019    STRTAB_str_t          file_name;
1020    IR_info_t           ir_info;
1021    struct IR_tup_n_t   *data_tups;     /* Intermediate rep tuples */
1022} AST_rep_as_n_t;
1023
1024/*
1025 *  A S T _ c s _ c h a r _ n _ t
1026 */
1027
1028typedef struct AST_cs_char_n_t {
1029    fe_info_t             *fe_info;
1030    be_info_t             be_info;
1031    NAMETABLE_id_t        type_name;
1032    IR_info_t           ir_info;
1033    struct IR_tup_n_t   *data_tups;     /* Intermediate rep tuples */
1034} AST_cs_char_n_t;
1035
1036/*
1037 *  A S T _ a r r a y _ n _ t
1038 */
1039
1040typedef struct AST_array_n_t {
1041    fe_info_t                  *fe_info;
1042    be_info_t                  be_info;
1043    struct AST_type_n_t        *element_type;
1044    unsigned short             index_count;
1045    struct AST_array_index_n_t *index_vec;  /* a vector of size index_count */
1046} AST_array_n_t;
1047
1048/*
1049 *  A S T _ a r r a y _ i n d e x _ n _ t
1050 */
1051
1052typedef struct AST_array_index_n_t {
1053    fe_info_t           *fe_info;
1054    be_info_t           be_info;
1055    AST_flags_t         flags;
1056    AST_constant_n_t    *lower_bound; /* defined iff (flags & FIXED_LOWER) */
1057    AST_constant_n_t    *upper_bound; /* defined iff (flags & FIXED_UPPER) */
1058} AST_array_index_n_t;
1059
1060/*
1061 *  A S T _ d i s c _ u n i o n _ n _ t
1062 */
1063
1064typedef struct AST_disc_union_n_t {
1065    fe_info_t           *fe_info;
1066    be_info_t           be_info;
1067    NAMETABLE_id_t      tag_name;   /* NAMETABLE_NIL_ID if no tag */
1068    NAMETABLE_id_t      union_name; /* id ("tagged_union" if no name supplied) */
1069    NAMETABLE_id_t      discrim_name;
1070    struct AST_type_n_t *discrim_type;
1071    struct AST_arm_n_t  *arms;
1072} AST_disc_union_n_t;
1073
1074/*
1075 *  A S T _ a r m _ n _ t
1076 */
1077
1078#if 0
1079typedef struct AST_arm_n_t {
1080    fe_info_t                 *fe_info;
1081    be_info_t                 be_info;
1082    struct AST_arm_n_t        *next;
1083    struct AST_arm_n_t        *last;
1084    AST_flags_t               flags;
1085    struct AST_case_label_n_t *labels;
1086    NAMETABLE_id_t            name;  /* NAMETABLE_NIL_ID iff rep of empty arm */
1087    AST_type_n_t              *type; /* NULL             iff rep of empty arm */
1088} AST_arm_n_t;
1089#endif
1090
1091/*
1092 * The fields up to and including 'ir_info' must be identical and in the same
1093 * order in arm, field, and parameter nodes.
1094 */
1095typedef struct AST_arm_n_t {
1096    fe_info_t                 *fe_info;
1097    be_info_t                 be_info;
1098    struct AST_arm_n_t        *next;
1099    struct AST_arm_n_t        *last;
1100    AST_type_n_t              *type;        /* NULL iff rep of empty arm */
1101    struct AST_field_attr_n_t *field_attrs; /* Always NULL for arms */
1102    NAMETABLE_id_t            name;  /* NAMETABLE_NIL_ID iff rep of empty arm */
1103    AST_flags_t               flags;
1104    IR_info_t                 ir_info;
1105    struct AST_case_label_n_t *labels;
1106} AST_arm_n_t;
1107
1108/*
1109 *  A S T _ c a s e _ l a b e l _ n _ t
1110 */
1111
1112typedef struct AST_case_label_n_t {
1113    fe_info_t                 *fe_info;
1114    be_info_t                 be_info;
1115    struct AST_case_label_n_t *next;
1116    struct AST_case_label_n_t *last;
1117    boolean                   default_label; /* iff represents default: */
1118    AST_constant_n_t          *value;
1119} AST_case_label_n_t;
1120
1121/*
1122 *  A S T _ e n u m e r a t i o n _ n _ t
1123 */
1124
1125typedef struct AST_enumeration_n_t {
1126    fe_info_t        *fe_info;
1127    be_info_t        be_info;
1128    AST_constant_n_t *enum_constants;
1129} AST_enumeration_n_t;
1130
1131/*
1132 *  A S T _ p i p e _ n _ t
1133 */
1134
1135typedef struct AST_pipe_n_t {
1136    fe_info_t    *fe_info;
1137    be_info_t    be_info;
1138    AST_type_n_t *base_type;
1139} AST_pipe_n_t;
1140
1141/*
1142 *  A S T _ p o i n t e r _ n _ t
1143 */
1144
1145typedef struct AST_pointer_n_t {
1146    fe_info_t    *fe_info;
1147    be_info_t    be_info;
1148    AST_type_n_t *pointee_type;
1149} AST_pointer_n_t;
1150
1151/*
1152 *  A S T _ s t r u c t u r e _ n _ t
1153 */
1154
1155typedef struct AST_structure_n_t {
1156    fe_info_t            *fe_info;
1157    be_info_t            be_info;
1158    struct AST_field_n_t *fields;
1159    NAMETABLE_id_t       tag_name;     /* NAMETABLE_NIL_ID if no tag */
1160} AST_structure_n_t;
1161
1162/*
1163 *  A S T _ f i e l d _ n _t
1164 */
1165
1166#if 0
1167typedef struct AST_field_n_t {
1168    fe_info_t                 *fe_info;
1169    be_info_t                 be_info;
1170    struct AST_field_n_t      *next;
1171    struct AST_field_n_t      *last;
1172    AST_flags_t               flags;
1173    NAMETABLE_id_t            name;
1174    struct AST_type_n_t       *type;
1175    struct AST_field_attr_n_t *field_attrs;
1176} AST_field_n_t;
1177#endif
1178
1179/*
1180 * The fields up to and including 'ir_info' must be identical and in the same
1181 * order in arm, field, and parameter nodes.
1182 */
1183typedef struct AST_field_n_t {
1184    fe_info_t                 *fe_info;
1185    be_info_t                 be_info;
1186    struct AST_field_n_t      *next;
1187    struct AST_field_n_t      *last;
1188    struct AST_type_n_t       *type;
1189    struct AST_field_attr_n_t *field_attrs;
1190    NAMETABLE_id_t            name;
1191    AST_flags_t               flags;
1192    IR_info_t                 ir_info;
1193    int                       field_num;
1194} AST_field_n_t;
1195
1196/*
1197 *  A S T _ t u p l e _ n _ t
1198 */
1199typedef struct AST_tuple_n_t {
1200    /* tuple for storing a fixed expression */
1201    long value[2];
1202} AST_tuple_n_t;
1203
1204/*
1205 *  A S T _ f i e l d _ a t t r _ n _ t
1206 */
1207typedef struct AST_field_attr_n_t {
1208    fe_info_t                *fe_info;
1209    be_info_t                be_info;
1210    /*
1211     * these six fields will be NULL iff corresponding attribute not used
1212     */
1213    struct AST_field_ref_n_t *first_is_vec;
1214    struct AST_field_ref_n_t *last_is_vec;
1215    struct AST_field_ref_n_t *length_is_vec;
1216    struct AST_field_ref_n_t *min_is_vec;
1217    struct AST_field_ref_n_t *max_is_vec;
1218    struct AST_field_ref_n_t *size_is_vec;
1219    struct AST_field_ref_n_t *switch_is;
1220    struct AST_field_ref_n_t *iid_is; /* MIDL extension */
1221    struct AST_tuple_n_t     *range;  /* MIDL extension */
1222} AST_field_attr_n_t;
1223
1224/*
1225 * Type used to evaluate expressions
1226 */
1227typedef struct AST_exp_n_t {
1228    unsigned long long exp_type;	/* AST_EXP_xxx flags */
1229    union	{
1230	struct	{
1231	    AST_constant_k_t    type;     /* datatype of the constant */
1232	    union {
1233		int              integer;         /* Integer value         */
1234		AST_constant_n_t *other;          /* Constant node         */
1235	    } val;
1236	    boolean int_signed;
1237	    NAMETABLE_id_t	name;	/* use when "other" is null to resolve binding */
1238	} constant;
1239	struct	{
1240	    struct AST_exp_n_t  * oper1;
1241	    struct AST_exp_n_t  * oper2;
1242	    struct AST_exp_n_t  * oper3;
1243	} expression;
1244    } exp;
1245} AST_exp_n_t;   /* const expression block */
1246
1247/*
1248 *  A S T _ f i e l d _ r e f _ n _ t
1249 *
1250 *  Used as elements of vector fields in field_attr_n_t.
1251 */
1252
1253typedef struct AST_field_ref_n_t {
1254    fe_info_t *fe_info;
1255    be_info_t be_info;
1256    boolean   valid;
1257    boolean   constant;
1258    union {
1259        struct AST_field_n_t     *f_ref;
1260        struct AST_parameter_n_t *p_ref;
1261        int                       integer;
1262    } ref;
1263    unsigned long xtra_opcode;
1264    unsigned long xtra_argument;
1265} AST_field_ref_n_t;
1266
1267/*
1268 *  A S T _ p a r a m e t e r _ n _ t
1269 */
1270
1271#if 0
1272typedef struct AST_parameter_n_t {
1273    fe_info_t                 *fe_info;
1274    be_info_t                 be_info;
1275    struct AST_parameter_n_t  *next;
1276    struct AST_parameter_n_t  *last;
1277    NAMETABLE_id_t            name;
1278    struct AST_type_n_t       *type;
1279    struct AST_field_attr_n_t *field_attrs;
1280    AST_flags_t               flags;
1281    struct AST_operation_n_t  *uplink; /* points to op. containing parameter */
1282} AST_parameter_n_t;
1283#endif
1284
1285/*
1286 * The fields up to and including 'ir_info' must be identical and in the same
1287 * order in arm, field, and parameter nodes.
1288 */
1289typedef struct AST_parameter_n_t {
1290    fe_info_t                 *fe_info;
1291    be_info_t                 be_info;
1292    struct AST_parameter_n_t  *next;
1293    struct AST_parameter_n_t  *last;
1294    struct AST_type_n_t       *type;
1295    struct AST_field_attr_n_t *field_attrs;
1296    NAMETABLE_id_t            name;
1297    AST_flags_t               flags;
1298    IR_info_t                 ir_info;
1299    struct IR_tup_n_t         *data_tups;   /* Intermediate rep tuples */
1300    int                       param_num;
1301    struct AST_operation_n_t  *uplink; /* points to op. containing parameter */
1302} AST_parameter_n_t;
1303
1304/*
1305 *  A S T _ o p e r a t i o n _ n _ t
1306 */
1307
1308typedef struct AST_operation_n_t {
1309    fe_info_t          *fe_info;
1310    be_info_t          be_info;
1311    AST_flags_t        flags;
1312    NAMETABLE_id_t     name;
1313    AST_parameter_n_t* parameters;
1314    AST_parameter_n_t* result;
1315    int                op_number;    /* inherited */
1316    IR_info_t          ir_info;
1317    struct IR_tup_n_t  *init_tups;   /* IREP tuples for stub initializations */
1318    struct IR_tup_n_t  *clean_tups;  /* IREP tuples for stub cleanups */
1319    NAMETABLE_id_t     cs_tag_rtn_name; /* [cs_tag_rtn] name if any */
1320} AST_operation_n_t;
1321
1322/*
1323 * This is the common layout of the first fields of the primary instance nodes,
1324 * i.e. arm, field, and parameter nodes.  Note that the first 4 of these fields
1325 * must also agree with an ASTP_node_t.
1326 */
1327typedef struct AST_instance_n_t {
1328    fe_info_t                 *fe_info;
1329    be_info_t                 be_info;
1330    struct AST_instance_n_t   *next;
1331    struct AST_instance_n_t   *last;
1332    struct AST_type_n_t       *type;
1333    struct AST_field_attr_n_t *field_attrs;
1334    NAMETABLE_id_t            name;
1335    AST_flags_t               flags;
1336    IR_info_t                 ir_info;
1337} AST_instance_n_t;
1338
1339#endif
1340