File: PolyMLCodetree.html

package info (click to toggle)
polyml 5.6-8
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 31,892 kB
  • ctags: 34,453
  • sloc: cpp: 44,983; ansic: 24,520; asm: 14,850; sh: 11,730; makefile: 551; exp: 484; python: 253; awk: 91; sed: 9
file content (157 lines) | stat: -rw-r--r-- 6,852 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>The PolyML.Codetree structure</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="docstyle.css" rel="stylesheet" type="text/css">
</head>

<body>
<ul class="nav">
	<li><a href="#">Previous</a></li>
	<li><a href="PolyMLStructure.html">Up</a></li>
	<li><a href="PolyMLCompiler.html">Next</a></li>
</ul>
<H2><STRONG><font face="Arial, Helvetica, sans-serif">The PolyML.Codetree structure</font></STRONG></H2>
<p> The <span class="identifier">CodeTree</span> sub-structure contains functions 
  that construct and operate on the intermediate code structure of the Poly/ML 
  compiler. It is intended for compilers for languages other than Standard ML 
  to target the back-end. </p>
<p>The intermediate code-tree is untyped and almost no checking is performed on 
  it. It is very easy to cause the compiler or garbage-collector to crash and 
  a failure could occur at some random point.</p>
<pre class="mainsig">
structure CodeTree :
  sig

    type codeBinding
    type codetree
    type machineWord


    val mkConstant: machineWord -> codetree
    val mkLoadArgument: int -> codetree
    val mkLoadClosure: int -> codetree
    val mkLoadLocal: int -> codetree

    val mkEnv: codeBinding list * codetree -> codetree

    val mkFunction: codetree * int * string * codetree list * int -> codetree
    val mkInlineFunction: codetree * int * string * codetree list * int -> codetree
    val mkCall: codetree * codetree list -> codetree

    val mkTuple: codetree list -> codetree
    val mkInd: int * codetree -> codetree

    val mkIf: codetree * codetree * codetree -> codetree

    val mkBeginLoop: codetree * (int * codetree) list -> codetree
    val mkLoop: codetree list -> codetree
    val mkWhile: codetree * codetree -> codetree

    val mkRaise: codetree -> codetree
    val mkHandle: codetree * codetree -> codetree
    val Ldexc: codetree

    val mkDec: int * codetree -> codeBinding
    val mkMutualDecs: (int * codetree) list -> codeBinding
    val mkNullDec: codetree -> codeBinding

    val rtsFunction: int -> codetree

    val <a href="#pretty">pretty</a>: codetree -> pretty

    val <a href="#genCode">genCode</a>: codetree * int -> unit -> codetree
    val <a href="#evalue">evalue</a>: codetree -> machineWord option

    val <a href="#encodeBinary">encodeBinary</a>: codetree -> Word8Vector.vector
    val <a href="#decodeBinary">decodeBinary</a>: Word8Vector.vector -> codetree

    val <a href="#unsafeMakeFunctor">unsafeMakeFunctor</a>:
       string * NameSpace.signatureVal * NameSpace.signatureVal * codetree -> NameSpace.functorVal
  end
</pre>
<div class="entryblock"> 
  <pre class="entrycode"><a name="encodeBinary" id="encodeBinary"></a>val encodeBinary : codetree -> Word8Vector.vector
</pre>
  <div class="entrytext"> 
    <p>This encodes the code-tree as a byte vector. It is intended to allow compiled 
      code to be exported and subsequently imported by <a href="#decodeBinary"><span class="identifier">decodeBinary</span></a>. 
      There are a number of restrictions on the code-tree to allow it to be exported, 
      primarily that it is fully self-contained. It is really only suitable for 
      use with the code of a functor.</p>
  </div>
</div>
<div class="entryblock"> 
  <pre class="entrycode"><a name="decodeBinary" id="decodeBinary"></a>val decodeBinary : Word8Vector.vector -> codetree</pre>
  <div class="entrytext"> 
    <p>This function imports a code-tree that has been encoded with <a href="#encodeBinary"><span class="identifier">encodeBinary</span></a>.</p>
  </div>
</div>
<div class="entryblock"> 
  <pre class="entrycode"><a name="unsafeMakeFunctor" id="unsafeMakeFunctor"></a>val unsafeMakeFunctor:
       string * NameSpace.signatureVal * NameSpace.signatureVal * codetree -> NameSpace.functorVal</pre>
  <div class="entrytext"> 
    <p>This function can be used to create a functor from code and signature information.</p>
  </div>
</div>
<div class="entryblock"> 
  <pre class="entrycode"><a name="genCode" id="genCode"></a>val genCode: codetree * int -> unit -> codetree</pre>
  <div class="entrytext"> 
    <p>The <span class="identifier">genCode</span> function compiles code and 
      returns a function that, when called, will execute the compiled code. <span class="identifier">genCode(c, 
      nBindings) </span>takes the <span class="identifier">codetree c</span> and 
      an integer <span class="identifier">nBindings</span> which is the number 
      of binding addresses used in the top-level tree, or more specifically at 
      least one more than the maximum binding address used. Binding addresses 
      used within functions are not included in this; they are counted within 
      their respective function. The result is a function of type <span class="identifier">unit 
      -> codetree</span> which when called executes the code. The result is a 
      codetree. Currently this will always be a <span class="identifier">Constant</span> 
      node whose value can be extracted by <span class="identifier"><a href="#evalue">evalue</a></span>.</p>
  </div>
</div>
<div class="entryblock"> 
  <pre class="entrycode"><a name="evalue" id="evalue"></a>val evalue : codetree -> machineWord option</pre>
  <div class="entrytext"> 
    <p>The <span class="identifier">evalue</span> function extracts the value 
      from a <span class="identifier">Constant</span> node. If the argument is 
      not a <span class="identifier">Constant</span> node the result will be <span class="identifier">NONE</span>.</p>
  </div>
</div>
<div class="entryblock"> 
  <pre class="entrycode"><a name="pretty" id="pretty"></a>val pretty: codetree -> pretty
</pre>
  <div class="entrytext"> 
    <p>This function formats the code-tree as a <span class="identifier"><a href="PolyMLStructure.html#pretty">pretty</a></span> 
      data structure. It can then be printed using <span class="identifier"><a href="PolyMLStructure.html#prettyPrint">PolyML.prettyPrint</a></span> 
      or incorporated into another <span class="identifier">pretty</span> structure.</p>
  </div>
</div>
<div class="entryblock"> 
  <pre class="entrycode"><a name="ZZZ"></a>val ZZZ: int ref</pre>
  <div class="entrytext"> 
    <p>This function does ZZZ</p>
  </div>
</div>
<div class="entryblock"> 
  <pre class="entrycode"><a name="ZZZ"></a>val ZZZ: int ref</pre>
  <div class="entrytext"> 
    <p>This function does ZZZ</p>
  </div>
</div>
<div class="entryblock"> 
  <pre class="entrycode"><a name="ZZZ"></a>val ZZZ: int ref</pre>
  <div class="entrytext"> 
    <p>This function does ZZZ</p>
  </div>
</div>

<ul class="nav">
	<li><a href="#">Previous</a></li>
	<li><a href="PolyMLStructure.html">Up</a></li>
	<li><a href="PolyMLCompiler.html">Next</a></li>
</ul>

</body>
</html>