root/trunk/docs/minid.compiler.html

Revision 470, 14.3 kB (checked in by JarrettBillingsley, 1 week ago)

- Some documentation stuff.
- Added some semantic analysis for ranged case statements.

  • Property svn:mime-type set to text/html
Line 
1 <html><head>
2 <meta http-equiv="content-type" content="text/html; charset=utf-8">
3 <meta content="text/javascript" http-equiv="content-script-type">
4 <title>minid.compiler</title>
5 <link rel="stylesheet" type="text/css" href="candydoc/style.css">
6 <!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="candydoc/ie56hack.css"><![endif]-->
7 <script language="JavaScript" src="candydoc/util.js" type="text/javascript"></script>
8 <script language="JavaScript" src="candydoc/tree.js" type="text/javascript"></script>
9 <script language="JavaScript" src="candydoc/explorer.js" type="text/javascript"></script>
10 </head><body>
11 <div id="tabarea"></div><div id="explorerclient"></div>
12 <div id="content"><script>explorer.initialize("minid.compiler");</script>
13     <table class="content">
14         <tr><td id="docbody"><h1>minid.compiler</h1><!-- Generated by Ddoc from minid\compiler.d -->
15 This module contains the public interface to the MiniD
16 <span class="currsymbol">compiler</span>
17 <script>explorer.outline.addDecl('compiler');</script>
18
19 .
20 <br><br>
21 <b>License:</b><br><pre class="license">Copyright (c) 2008 Jarrett Billingsley
22 <br><br>
23
24 This software is provided 'as-is', without any express or implied warranty.
25 In no event will the authors be held liable for any damages arising from the
26 use of this software.
27 <br><br>
28
29 Permission is granted to anyone to use this software for any purpose,
30 including commercial applications, and to alter it and redistribute it freely,
31 subject to the following restrictions:
32 <br><br>
33
34     1. The origin of this software must not be misrepresented; you must not
35     claim that you wrote the original software. If you use this software in a
36     product, an acknowledgment in the product documentation would be
37     appreciated but is not required.
38 <br><br>
39
40     2. Altered source versions must be plainly marked as such, and must not
41     be misrepresented as being the original software.
42 <br><br>
43
44     3. This notice may not be removed or altered from any source distribution.
45 </pre><br>
46
47
48 <script>explorer.outline.incSymbolLevel();</script>
49 <dl>
50 <script>explorer.outline.writeEnabled = true;</script>
51 <dt><span class="decl">class
52 <span class="currsymbol">Compiler</span>
53 <script>explorer.outline.addDecl('Compiler');</script>
54
55 : minid.compilertypes.ICompiler;
56 </span></dt>
57 <script>explorer.outline.writeEnabled = false;</script>
58
59
60 <dd>This class encapsulates all the functionality needed for compiling MiniD code.
61 <br><br>
62
63
64 <script>explorer.outline.incSymbolLevel();</script>
65 <dl>
66 <script>explorer.outline.writeEnabled = true;</script>
67 <dt><span class="decl">
68 <span class="currsymbol">None</span>
69 <script>explorer.outline.addDecl('None');</script>
70
71 </span></dt>
72 <script>explorer.outline.writeEnabled = false;</script>
73
74
75 <dd>Do not generate code for any optional features.
76        
77 <br><br>
78
79 </dd>
80
81 <script>explorer.outline.writeEnabled = true;</script>
82 <dt><span class="decl">
83 <span class="currsymbol">TypeConstraints</span>
84 <script>explorer.outline.addDecl('TypeConstraints');</script>
85
86 </span></dt>
87 <script>explorer.outline.writeEnabled = false;</script>
88
89
90 <dd>Generate code to check parameter type constraints.
91        
92 <br><br>
93
94 </dd>
95
96 <script>explorer.outline.writeEnabled = true;</script>
97 <dt><span class="decl">
98 <span class="currsymbol">Asserts</span>
99 <script>explorer.outline.addDecl('Asserts');</script>
100
101 </span></dt>
102 <script>explorer.outline.writeEnabled = false;</script>
103
104
105 <dd>Generate code for assert statements.
106        
107 <br><br>
108
109 </dd>
110
111 <script>explorer.outline.writeEnabled = true;</script>
112 <dt><span class="decl">
113 <span class="currsymbol">Debug</span>
114 <script>explorer.outline.addDecl('Debug');</script>
115
116 </span></dt>
117 <script>explorer.outline.writeEnabled = false;</script>
118
119
120 <dd>Generate debug info.  Currently always on.
121        
122 <br><br>
123
124 </dd>
125
126 <script>explorer.outline.writeEnabled = true;</script>
127 <dt><span class="decl">
128 <span class="currsymbol">All</span>
129 <script>explorer.outline.addDecl('All');</script>
130
131 </span></dt>
132 <script>explorer.outline.writeEnabled = false;</script>
133
134
135 <dd>Generate code for all optional features.
136        
137 <br><br>
138
139 </dd>
140
141 <script>explorer.outline.writeEnabled = true;</script>
142 <dt><span class="decl">this(MDThread* <span class="funcparam">t</span>, uint <span class="funcparam">flags</span> = All);
143 </span></dt>
144 <script>explorer.outline.writeEnabled = false;</script>
145
146
147 <dd>Constructs a compiler.  The given thread will be used to hold temporary data structures,
148     to throw exceptions, and to return the functions that result from compilation.
149 <br><br>
150 <b>Params:</b><br><table class="params"><tr>
151 <td class = "paramname" nowrap valign="top" style="padding-right: 8px">MDThread* <span class="funcparam">t</span></td>
152
153                
154 <td>The thread with which this compiler will be associated.</td></tr>
155 <tr>
156 <td class = "paramname" nowrap valign="top" style="padding-right: 8px">uint <span class="funcparam">flags</span></td>
157
158                
159 <td>A bitwise or of any code-generation <span class="funcparam">flags</span> you want to use for this compiler.
160             Defaults to All.</td></tr>
161 </table><br>
162
163 </dd>
164
165 <script>explorer.outline.writeEnabled = true;</script>
166 <dt><span class="decl">void
167 <span class="currsymbol">setFlags</span>
168 <script>explorer.outline.addDecl('setFlags');</script>
169
170 (uint <span class="funcparam">flags</span>);
171 </span></dt>
172 <script>explorer.outline.writeEnabled = false;</script>
173
174
175 <dd>Set the compiler's code-generation <span class="funcparam">flags</span>.
176    
177 <br><br>
178
179 </dd>
180
181 <script>explorer.outline.writeEnabled = true;</script>
182 <dt><span class="decl">bool
183 <span class="currsymbol">asserts</span>
184 <script>explorer.outline.addDecl('asserts');</script>
185
186 ();
187 </span></dt>
188 <script>explorer.outline.writeEnabled = false;</script>
189
190
191 <dd>Returns whether or not code for
192 <span class="currsymbol">asserts</span>
193 <script>explorer.outline.addDecl('asserts');</script>
194
195  should be generated.
196    
197 <br><br>
198
199 </dd>
200
201 <script>explorer.outline.writeEnabled = true;</script>
202 <dt><span class="decl">bool
203 <span class="currsymbol">typeConstraints</span>
204 <script>explorer.outline.addDecl('typeConstraints');</script>
205
206 ();
207 </span></dt>
208 <script>explorer.outline.writeEnabled = false;</script>
209
210
211 <dd>Returns whether or not code for parameter type constraint checking should be generated.
212    
213 <br><br>
214
215 </dd>
216
217 <script>explorer.outline.writeEnabled = true;</script>
218 <dt><span class="decl">bool
219 <span class="currsymbol">isEof</span>
220 <script>explorer.outline.addDecl('isEof');</script>
221
222 ();
223 </span></dt>
224 <script>explorer.outline.writeEnabled = false;</script>
225
226
227 <dd>Returns whether or not the most recently-thrown exception was thrown due to an unexpected end-of-file.
228     As an example, this is used by MDCL (that is, minid.commandline) to detect when more code must be entered
229     to complete a code segment.  A simple example of use:
230 <br><br>
231 <pre class="d_code"><pre class="d_keyword">scope</pre> c = <pre class="d_keyword">new</pre> Compiler(t);
232
233 <pre class="d_keyword">try</pre>
234     c.compileExpression(someCode, <pre class="d_string">"test"</pre>);
235 <pre class="d_keyword">catch</pre>(MDException e)
236 {
237     <pre class="d_keyword">auto</pre> ex = catchException(t);
238
239     <pre class="d_keyword">if</pre>(c.<pre class="d_psymbol">isEof</pre>())
240     {
241         <pre class="d_comment">// error was caused by an unexpected end-of-file
242 </pre>  }
243 }
244 </pre>
245    
246 <br><br>
247
248 </dd>
249
250 <script>explorer.outline.writeEnabled = true;</script>
251 <dt><span class="decl">bool
252 <span class="currsymbol">isLoneStmt</span>
253 <script>explorer.outline.addDecl('isLoneStmt');</script>
254
255 ();
256 </span></dt>
257 <script>explorer.outline.writeEnabled = false;</script>
258
259
260 <dd>Returns whether or not the most recently-thrown exception was thrown due to a no-effect expression being used
261     as a statement (yes, this method has a horrible name).  Its use is identical to isEof().
262    
263 <br><br>
264
265 </dd>
266
267 <script>explorer.outline.writeEnabled = true;</script>
268 <dt><span class="decl">int
269 <span class="currsymbol">compileModule</span>
270 <script>explorer.outline.addDecl('compileModule');</script>
271
272 (char[] <span class="funcparam">filename</span>);
273 </span></dt>
274 <script>explorer.outline.writeEnabled = false;</script>
275
276
277 <dd>Compile a source code file into a function closure.  Takes the path to the source file, compiles
278     that file, and pushes the top-level closure onto the stack.  The environment of the closure is
279     just set to the global namespace of the compiler's thread; you must create and set a namespace
280     for the module function before calling it.
281 <br><br>
282 You shouldn't have to deal with this function that much.  Most of the time the compilation of
283     modules should be handled for you by the import system.
284
285 <br><br>
286 <b>Params:</b><br><table class="params"><tr>
287 <td class = "paramname" nowrap valign="top" style="padding-right: 8px">char[] <span class="funcparam">filename</span></td>
288
289                
290 <td>The <span class="funcparam">filename</span> of the source file to compile.</td></tr>
291 </table><br>
292 <b>Returns:</b><br>
293 The stack index of the newly-pushed function closure that represents the top-level function
294         of the module.
295    
296 <br><br>
297
298 </dd>
299
300 <script>explorer.outline.writeEnabled = true;</script>
301 <dt><span class="decl">int
302 <span class="currsymbol">compileModule</span>
303 <script>explorer.outline.addDecl('compileModule');</script>
304
305 (char[] <span class="funcparam">source</span>, char[] <span class="funcparam">name</span>);
306 </span></dt>
307 <script>explorer.outline.writeEnabled = false;</script>
308
309
310 <dd>Same as above, but compiles from a string holding the <span class="funcparam">source</span> rather than from a file.
311 <br><br>
312 <b>Params:</b><br><table class="params"><tr>
313 <td class = "paramname" nowrap valign="top" style="padding-right: 8px">char[] <span class="funcparam">source</span></td>
314
315                
316 <td>The <span class="funcparam">source</span> code as a string.</td></tr>
317 <tr>
318 <td class = "paramname" nowrap valign="top" style="padding-right: 8px">char[] <span class="funcparam">name</span></td>
319
320                
321 <td>The <span class="funcparam">name</span> which should be used as the <span class="funcparam">source</span> <span class="funcparam">name</span> in compiler error message.  Takes the
322             place of the filename when compiling from a <span class="funcparam">source</span> file.</td></tr>
323 </table><br>
324 <b>Returns:</b><br>
325 The stack index of the newly-pushed function closure that represents the top-level function
326         of the module.
327    
328 <br><br>
329
330 </dd>
331
332 <script>explorer.outline.writeEnabled = true;</script>
333 <dt><span class="decl">int
334 <span class="currsymbol">compileStatements</span>
335 <script>explorer.outline.addDecl('compileStatements');</script>
336
337 (char[] <span class="funcparam">source</span>, char[] <span class="funcparam">name</span>);
338 </span></dt>
339 <script>explorer.outline.writeEnabled = false;</script>
340
341
342 <dd>Compile a list of statements into a function which takes a variadic number of arguments.  The environment
343     of the compiled function closure is set to the globals of the compiler's thread.
344 <br><br>
345 <b>Params:</b><br><table class="params"><tr>
346 <td class = "paramname" nowrap valign="top" style="padding-right: 8px">char[] <span class="funcparam">source</span></td>
347
348                
349 <td>The <span class="funcparam">source</span> code as a string.</td></tr>
350 <tr>
351 <td class = "paramname" nowrap valign="top" style="padding-right: 8px">char[] <span class="funcparam">name</span></td>
352
353                
354 <td>The <span class="funcparam">name</span> to use as the <span class="funcparam">source</span> <span class="funcparam">name</span> for compilation errors.</td></tr>
355 </table><br>
356 <b>Returns:</b><br>
357 The stack index of the newly-pushed function closure.
358    
359 <br><br>
360
361 </dd>
362
363 <script>explorer.outline.writeEnabled = true;</script>
364 <dt><span class="decl">int
365 <span class="currsymbol">compileExpression</span>
366 <script>explorer.outline.addDecl('compileExpression');</script>
367
368 (char[] <span class="funcparam">source</span>, char[] <span class="funcparam">name</span>);
369 </span></dt>
370 <script>explorer.outline.writeEnabled = false;</script>
371
372
373 <dd>Compile a single expression into a function which returns the value of that expression when called.
374 <br><br>
375 <b>Params:</b><br><table class="params"><tr>
376 <td class = "paramname" nowrap valign="top" style="padding-right: 8px">char[] <span class="funcparam">source</span></td>
377
378                
379 <td>The <span class="funcparam">source</span> code as a string.</td></tr>
380 <tr>
381 <td class = "paramname" nowrap valign="top" style="padding-right: 8px">char[] <span class="funcparam">name</span></td>
382
383                
384 <td>The <span class="funcparam">name</span> to use as the <span class="funcparam">source</span> <span class="funcparam">name</span> for compilation errors.</td></tr>
385 </table><br>
386 <b>Returns:</b><br>
387 The stack index of the newly-pushed function closure.
388    
389 <br><br>
390
391 </dd>
392
393 <script>explorer.outline.writeEnabled = true;</script>
394 <dt><span class="decl">int
395 <span class="currsymbol">loadJSON</span>
396 <script>explorer.outline.addDecl('loadJSON');</script>
397
398 (char[] <span class="funcparam">source</span>);
399 </span></dt>
400 <script>explorer.outline.writeEnabled = false;</script>
401
402
403 <dd>Parses a JSON string into a MiniD value, pushes that value onto the stack, and returns the
404     index of the newly-pushed value.
405    
406 <br><br>
407
408 </dd>
409 </dl>
410 <script>explorer.outline.decSymbolLevel();</script>
411
412
413 </dd>
414 </dl>
415 <script>explorer.outline.decSymbolLevel();</script>
416
417
418 </td></tr>
419         <tr><td id="docfooter">
420             Page was generated with
421             <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px">
422             on Thu Jan  1 12:24:54 2009
423
424         </td></tr>
425     </table>
426 </div>
427 <script>
428     explorer.packageExplorer.addModuleFull("minid.alloc");
429     explorer.packageExplorer.addModuleFull("minid.api");
430     explorer.packageExplorer.addModuleFull("minid.ast");
431     explorer.packageExplorer.addModuleFull("minid.bind");
432     explorer.packageExplorer.addModuleFull("minid.commandline");
433     explorer.packageExplorer.addModuleFull("minid.compiler");
434     explorer.packageExplorer.addModuleFull("minid.ex");
435     explorer.packageExplorer.addModuleFull("minid.interpreter");
436     explorer.packageExplorer.addModuleFull("minid.serialization");
437     explorer.packageExplorer.addModuleFull("minid.types");
438     explorer.packageExplorer.addModuleFull("minid.utils");
439     explorer.packageExplorer.addModuleFull("minid.vm");</script>
440 </body></html>
Note: See TracBrowser for help on using the browser.