3 <!-- This HTML file has been created by texi2html 1.54
4 from suif1.texi on 28 April 1999 -->
6 <TITLE>The SUIF Version
1 Library - Function Types
</TITLE>
7 <link href=
"suif1_65.html" rel=Next
>
8 <link href=
"suif1_63.html" rel=Previous
>
9 <link href=
"suif1_toc.html" rel=ToC
>
13 <p>Go to the
<A HREF=
"suif1_1.html">first
</A>,
<A HREF=
"suif1_63.html">previous
</A>,
<A HREF=
"suif1_65.html">next
</A>,
<A HREF=
"suif1_113.html">last
</A> section,
<A HREF=
"suif1_toc.html">table of contents
</A>.
17 <H2><A NAME=
"SEC64" HREF=
"suif1_toc.html#TOC64">Function Types
</A></H2>
27 The
<CODE>TYPE_FUNC
</CODE> operator is used with the
<CODE>func_type
</CODE> derived
28 type class to describe the types of SUIF procedures. A function type
29 includes the type of the return value and optionally the types of the
30 arguments as well. The
<CODE>return_type
</CODE> and
<CODE>set_return_type
</CODE>
31 methods access the return type field. The type system itself places no
32 restrictions on the return types, but the SUIF call and return
33 instructions do. See section
<A HREF=
"suif1_35.html#SEC35">Call Instructions
</A>
41 Most of the complexity of function types involves the arguments.
42 Pointers to the argument types are stored in a dynamically-allocated
43 array. The number of arguments, and thus the size of the array, is
44 stored in a field that can be accessed with the
<CODE>num_args
</CODE> and
45 <CODE>set_num_args
</CODE> methods. The number of arguments can be changed at
46 any time; if necessary the argument array will be reallocated. The type
47 of a particular argument can be retrieved with the
<CODE>arg_type
</CODE>
48 method and set with the
<CODE>set_arg_type
</CODE> method. The arguments are
49 numbered beginning with zero.
53 Argument types are under the same restrictions as result types of
54 instructions (see section
<A HREF=
"suif1_26.html#SEC26">Result Types
</A>) -- they must be object types with
62 Since functions can be declared in C without complete prototypes, a
63 function type may not be able to include any information about the
64 arguments. This is indicated in a SUIF function type by the result of
65 the
<CODE>args_known
</CODE> method. This flag can be set with the
66 <CODE>set_args_known
</CODE> and
<CODE>set_args_unknown
</CODE> methods. Setting
67 <CODE>args_known
</CODE> FALSE sets the argument count to zero and the
68 <CODE>has_varargs
</CODE> flag to FALSE. Conversely, setting the argument
69 count to a non-zero value or the
<CODE>has_varargs
</CODE> flag to TRUE sets
70 the
<CODE>args_known
</CODE> flag to TRUE.
76 Some functions in C and other languages have a variable number of
77 arguments. The SUIF function types support this by keeping a flag to
78 indicate if there may be additional arguments besides the ones that are
79 explicitly listed. The
<CODE>has_varargs
</CODE> and
<CODE>set_varargs
</CODE>
80 methods access this flag. Note that the
<CODE>has_varargs
</CODE> flag should
81 not be used if nothing else is known about the arguments.
86 <p>Go to the
<A HREF=
"suif1_1.html">first
</A>,
<A HREF=
"suif1_63.html">previous
</A>,
<A HREF=
"suif1_65.html">next
</A>,
<A HREF=
"suif1_113.html">last
</A> section,
<A HREF=
"suif1_toc.html">table of contents
</A>.