Primitive-types.html 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
  2. <html>
  3. <!-- Created on November 8, 2012 by texi2html 1.82
  4. texi2html was written by:
  5. Lionel Cons <[email protected]> (original author)
  6. Karl Berry <[email protected]>
  7. Olaf Bachmann <[email protected]>
  8. and many others.
  9. Maintained by: Many creative people.
  10. Send bugs and suggestions to <[email protected]>
  11. -->
  12. <head>
  13. <title>avram - a virtual machine code interpreter: 3.1.4.1 Primitive types</title>
  14. <meta name="description" content="avram - a virtual machine code interpreter: 3.1.4.1 Primitive types">
  15. <meta name="keywords" content="avram - a virtual machine code interpreter: 3.1.4.1 Primitive types">
  16. <meta name="resource-type" content="document">
  17. <meta name="distribution" content="global">
  18. <meta name="Generator" content="texi2html 1.82">
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  20. <style type="text/css">
  21. <!--
  22. a.summary-letter {text-decoration: none}
  23. blockquote.smallquotation {font-size: smaller}
  24. pre.display {font-family: serif}
  25. pre.format {font-family: serif}
  26. pre.menu-comment {font-family: serif}
  27. pre.menu-preformatted {font-family: serif}
  28. pre.smalldisplay {font-family: serif; font-size: smaller}
  29. pre.smallexample {font-size: smaller}
  30. pre.smallformat {font-family: serif; font-size: smaller}
  31. pre.smalllisp {font-size: smaller}
  32. span.roman {font-family:serif; font-weight:normal;}
  33. span.sansserif {font-family:sans-serif; font-weight:normal;}
  34. ul.toc {list-style: none}
  35. -->
  36. </style>
  37. </head>
  38. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  39. <a name="Primitive-types"></a>
  40. <table cellpadding="1" cellspacing="1" border="0">
  41. <tr><td valign="middle" align="left">[<a href="Type-Conversions.html#Type-Conversions" title="Previous section in reading order"> &lt; </a>]</td>
  42. <td valign="middle" align="left">[<a href="One-dimensional-arrays.html#One-dimensional-arrays" title="Next section in reading order"> &gt; </a>]</td>
  43. <td valign="middle" align="left"> &nbsp; </td>
  44. <td valign="middle" align="left">[<a href="Library-Reference.html#Library-Reference" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
  45. <td valign="middle" align="left">[<a href="Type-Conversions.html#Type-Conversions" title="Up section"> Up </a>]</td>
  46. <td valign="middle" align="left">[<a href="Character-Table.html#Character-Table" title="Next chapter"> &gt;&gt; </a>]</td>
  47. <td valign="middle" align="left"> &nbsp; </td>
  48. <td valign="middle" align="left"> &nbsp; </td>
  49. <td valign="middle" align="left"> &nbsp; </td>
  50. <td valign="middle" align="left"> &nbsp; </td>
  51. <td valign="middle" align="left">[<a href="avram.html#Top" title="Cover (top) of document">Top</a>]</td>
  52. <td valign="middle" align="left">[<a href="avram_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
  53. <td valign="middle" align="left">[<a href="Function-Index.html#Function-Index" title="Index">Index</a>]</td>
  54. <td valign="middle" align="left">[<a href="avram_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
  55. </tr></table>
  56. <hr size="1">
  57. <a name="Primitive-types-1"></a>
  58. <h4 class="subsubsection">3.1.4.1 Primitive types</h4>
  59. <p>A pair of functions in support of this abstraction is prototyped in
  60. &lsquo;<tt>listfuns.h</tt>&rsquo;. These functions will be of interest mainly to
  61. developers wishing to implement an interface to a new library module
  62. and make it accessible on the virtual side by way of the
  63. <code>library</code> combinator (<a href="Library-combinator.html#Library-combinator">Library combinator</a>).
  64. </p>
  65. <dl>
  66. <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>
  67. <dd><p>This function takes an <var>operand</var> representing a value used by a
  68. library function in the format described above (<a href="Type-Conversions.html#Type-Conversions">Type Conversions</a>) and returns a pointer to the value.
  69. </p>
  70. <p>The <code>value</code> field in the <var>operand</var> normally will point to the
  71. block of memory holding the value, and the <var>operand</var> itself will
  72. be a list of character representations whose binary encodings spell
  73. out the value as explained above.
  74. </p>
  75. <p>The <code>value</code> field need not be initialized on entry but it will be
  76. initialized as a side effect of being computed by this function. If it
  77. has been initialized due to a previous call with the same
  78. <var>operand</var>, this function is a fast constant time operation.
  79. </p>
  80. <p>The caller should not free the pointer returned by this function
  81. because a reference to its value will remain in the
  82. <var>operand</var>. When the <var>operand</var> itself is freed by
  83. <code>avm_dispose</code> (<a href="Simple-Operations.html#Simple-Operations">Simple Operations</a>), the value will go with it.
  84. </p>
  85. <p>If an error occurs during the evaluation of this function, the integer
  86. referenced by <var>fault</var> will be set to a non-zero value, and the
  87. list referenced by <var>message</var> will be assigned a representation of
  88. a list of strings describing the error. The <var>message</var> is freshly
  89. created and should be freed by the caller with <code>avm_dispose</code>
  90. when no longer needed.
  91. </p>
  92. <p>Possible error messages are <code>&lt;'missing value'&gt;</code>, in the case of
  93. <a name="index-missing-value"></a>
  94. an empty <var>operand</var>, <code>&lt;'invalid value'&gt;</code> in the case of an
  95. <a name="index-invalid-value"></a>
  96. <var>operand</var> that is not a list of character representations, and
  97. <code>&lt;'memory overflow'&gt;</code> if there was insufficient space to allocate
  98. the result.
  99. </p></dd></dl>
  100. <dl>
  101. <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>
  102. <dd><p>This function performs the inverse operation of
  103. <code>avm_value_of_list</code>, taking the address of an area of
  104. contiguously stored data and its <var>size</var> in bytes to a list
  105. representation. The length of the list returned is equal to the number
  106. of bytes of data, <var>size</var>, and each item of the list is a character
  107. representation for the corresponding byte as given by <a href="Character-Table.html#Character-Table">Character Table</a>.
  108. </p>
  109. <p>A copy of the memory area is made so that the original is no longer
  110. needed and may be freed by the caller. A pointer to this copy is
  111. returned by subsequent calls to <code>avm_value_of_list</code> when the
  112. result returned by this function is used as the <var>operand</var>
  113. parameter.
  114. </p>
  115. <p>If there is insufficient memory to allocate the result, the integer
  116. referenced by <var>fault</var> is set to a non-zero value, and a copy of
  117. the message <code>&lt;'memory overflow'&gt;</code> represented as a list is
  118. returned. This function could also cause a segmentation fault if it is
  119. <a name="index-segmentation-fault-2"></a>
  120. passed an invalid pointer or a <var>size</var> that overruns the storage
  121. area. However, it is acceptable to specify a <var>size</var> that is less
  122. than the actual size of the given memory area to construct a list
  123. representing only the first part of it. The <var>size</var> must always be
  124. greater than zero.
  125. </p></dd></dl>
  126. <hr size="1">
  127. <table cellpadding="1" cellspacing="1" border="0">
  128. <tr><td valign="middle" align="left">[<a href="Type-Conversions.html#Type-Conversions" title="Previous section in reading order"> &lt; </a>]</td>
  129. <td valign="middle" align="left">[<a href="One-dimensional-arrays.html#One-dimensional-arrays" title="Next section in reading order"> &gt; </a>]</td>
  130. <td valign="middle" align="left"> &nbsp; </td>
  131. <td valign="middle" align="left">[<a href="Library-Reference.html#Library-Reference" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
  132. <td valign="middle" align="left">[<a href="Type-Conversions.html#Type-Conversions" title="Up section"> Up </a>]</td>
  133. <td valign="middle" align="left">[<a href="Character-Table.html#Character-Table" title="Next chapter"> &gt;&gt; </a>]</td>
  134. <td valign="middle" align="left"> &nbsp; </td>
  135. <td valign="middle" align="left"> &nbsp; </td>
  136. <td valign="middle" align="left"> &nbsp; </td>
  137. <td valign="middle" align="left"> &nbsp; </td>
  138. <td valign="middle" align="left">[<a href="avram.html#Top" title="Cover (top) of document">Top</a>]</td>
  139. <td valign="middle" align="left">[<a href="avram_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
  140. <td valign="middle" align="left">[<a href="Function-Index.html#Function-Index" title="Index">Index</a>]</td>
  141. <td valign="middle" align="left">[<a href="avram_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
  142. </tr></table>
  143. <p>
  144. <font size="-1">
  145. This document was generated on <i>November 8, 2012</i> using <a href="http://www.nongnu.org/texi2html/"><i>texi2html 1.82</i></a>.
  146. </font>
  147. <br>
  148. </p>
  149. </body>
  150. </html>