123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
- <html>
- <!-- Created on November 8, 2012 by texi2html 1.82
- texi2html was written by:
- Lionel Cons <[email protected]> (original author)
- Karl Berry <[email protected]>
- Olaf Bachmann <[email protected]>
- and many others.
- Maintained by: Many creative people.
- Send bugs and suggestions to <[email protected]>
- -->
- <head>
- <title>avram - a virtual machine code interpreter: 3.1.4.1 Primitive types</title>
- <meta name="description" content="avram - a virtual machine code interpreter: 3.1.4.1 Primitive types">
- <meta name="keywords" content="avram - a virtual machine code interpreter: 3.1.4.1 Primitive types">
- <meta name="resource-type" content="document">
- <meta name="distribution" content="global">
- <meta name="Generator" content="texi2html 1.82">
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <style type="text/css">
- <!--
- a.summary-letter {text-decoration: none}
- blockquote.smallquotation {font-size: smaller}
- pre.display {font-family: serif}
- pre.format {font-family: serif}
- pre.menu-comment {font-family: serif}
- pre.menu-preformatted {font-family: serif}
- pre.smalldisplay {font-family: serif; font-size: smaller}
- pre.smallexample {font-size: smaller}
- pre.smallformat {font-family: serif; font-size: smaller}
- pre.smalllisp {font-size: smaller}
- span.roman {font-family:serif; font-weight:normal;}
- span.sansserif {font-family:sans-serif; font-weight:normal;}
- ul.toc {list-style: none}
- -->
- </style>
- </head>
- <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
- <a name="Primitive-types"></a>
- <table cellpadding="1" cellspacing="1" border="0">
- <tr><td valign="middle" align="left">[<a href="Type-Conversions.html#Type-Conversions" title="Previous section in reading order"> < </a>]</td>
- <td valign="middle" align="left">[<a href="One-dimensional-arrays.html#One-dimensional-arrays" title="Next section in reading order"> > </a>]</td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left">[<a href="Library-Reference.html#Library-Reference" title="Beginning of this chapter or previous chapter"> << </a>]</td>
- <td valign="middle" align="left">[<a href="Type-Conversions.html#Type-Conversions" title="Up section"> Up </a>]</td>
- <td valign="middle" align="left">[<a href="Character-Table.html#Character-Table" title="Next chapter"> >> </a>]</td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left">[<a href="avram.html#Top" title="Cover (top) of document">Top</a>]</td>
- <td valign="middle" align="left">[<a href="avram_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
- <td valign="middle" align="left">[<a href="Function-Index.html#Function-Index" title="Index">Index</a>]</td>
- <td valign="middle" align="left">[<a href="avram_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
- </tr></table>
- <hr size="1">
- <a name="Primitive-types-1"></a>
- <h4 class="subsubsection">3.1.4.1 Primitive types</h4>
- <p>A pair of functions in support of this abstraction is prototyped in
- ‘<tt>listfuns.h</tt>’. These functions will be of interest mainly to
- developers wishing to implement an interface to a new library module
- and make it accessible on the virtual side by way of the
- <code>library</code> combinator (<a href="Library-combinator.html#Library-combinator">Library combinator</a>).
- </p>
- <dl>
- <dt><a name="index-_002aavm_005fvalue_005fof_005flist"></a><u>Function:</u> void <b>*avm_value_of_list</b><i> (list <var>operand</var>, list *<var>message</var>, int *<var>fault</var>)</i></dt>
- <dd><p>This function takes an <var>operand</var> representing a value used by a
- library function in the format described above (<a href="Type-Conversions.html#Type-Conversions">Type Conversions</a>) and returns a pointer to the value.
- </p>
- <p>The <code>value</code> field in the <var>operand</var> normally will point to the
- block of memory holding the value, and the <var>operand</var> itself will
- be a list of character representations whose binary encodings spell
- out the value as explained above.
- </p>
- <p>The <code>value</code> field need not be initialized on entry but it will be
- initialized as a side effect of being computed by this function. If it
- has been initialized due to a previous call with the same
- <var>operand</var>, this function is a fast constant time operation.
- </p>
- <p>The caller should not free the pointer returned by this function
- because a reference to its value will remain in the
- <var>operand</var>. When the <var>operand</var> itself is freed by
- <code>avm_dispose</code> (<a href="Simple-Operations.html#Simple-Operations">Simple Operations</a>), the value will go with it.
- </p>
- <p>If an error occurs during the evaluation of this function, the integer
- referenced by <var>fault</var> will be set to a non-zero value, and the
- list referenced by <var>message</var> will be assigned a representation of
- a list of strings describing the error. The <var>message</var> is freshly
- created and should be freed by the caller with <code>avm_dispose</code>
- when no longer needed.
- </p>
- <p>Possible error messages are <code><'missing value'></code>, in the case of
- <a name="index-missing-value"></a>
- an empty <var>operand</var>, <code><'invalid value'></code> in the case of an
- <a name="index-invalid-value"></a>
- <var>operand</var> that is not a list of character representations, and
- <code><'memory overflow'></code> if there was insufficient space to allocate
- the result.
- </p></dd></dl>
- <dl>
- <dt><a name="index-avm_005flist_005fof_005fvalue"></a><u>Function:</u> list <b>avm_list_of_value</b><i> (void *<var>contents</var>, size_t <var>size</var>, int *<var>fault</var>)</i></dt>
- <dd><p>This function performs the inverse operation of
- <code>avm_value_of_list</code>, taking the address of an area of
- contiguously stored data and its <var>size</var> in bytes to a list
- representation. The length of the list returned is equal to the number
- of bytes of data, <var>size</var>, and each item of the list is a character
- representation for the corresponding byte as given by <a href="Character-Table.html#Character-Table">Character Table</a>.
- </p>
- <p>A copy of the memory area is made so that the original is no longer
- needed and may be freed by the caller. A pointer to this copy is
- returned by subsequent calls to <code>avm_value_of_list</code> when the
- result returned by this function is used as the <var>operand</var>
- parameter.
- </p>
- <p>If there is insufficient memory to allocate the result, the integer
- referenced by <var>fault</var> is set to a non-zero value, and a copy of
- the message <code><'memory overflow'></code> represented as a list is
- returned. This function could also cause a segmentation fault if it is
- <a name="index-segmentation-fault-2"></a>
- passed an invalid pointer or a <var>size</var> that overruns the storage
- area. However, it is acceptable to specify a <var>size</var> that is less
- than the actual size of the given memory area to construct a list
- representing only the first part of it. The <var>size</var> must always be
- greater than zero.
- </p></dd></dl>
- <hr size="1">
- <table cellpadding="1" cellspacing="1" border="0">
- <tr><td valign="middle" align="left">[<a href="Type-Conversions.html#Type-Conversions" title="Previous section in reading order"> < </a>]</td>
- <td valign="middle" align="left">[<a href="One-dimensional-arrays.html#One-dimensional-arrays" title="Next section in reading order"> > </a>]</td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left">[<a href="Library-Reference.html#Library-Reference" title="Beginning of this chapter or previous chapter"> << </a>]</td>
- <td valign="middle" align="left">[<a href="Type-Conversions.html#Type-Conversions" title="Up section"> Up </a>]</td>
- <td valign="middle" align="left">[<a href="Character-Table.html#Character-Table" title="Next chapter"> >> </a>]</td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left">[<a href="avram.html#Top" title="Cover (top) of document">Top</a>]</td>
- <td valign="middle" align="left">[<a href="avram_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
- <td valign="middle" align="left">[<a href="Function-Index.html#Function-Index" title="Index">Index</a>]</td>
- <td valign="middle" align="left">[<a href="avram_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
- </tr></table>
- <p>
- <font size="-1">
- This document was generated on <i>November 8, 2012</i> using <a href="http://www.nongnu.org/texi2html/"><i>texi2html 1.82</i></a>.
- </font>
- <br>
- </p>
- </body>
- </html>
|