mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 23:58:20 +00:00
Update for version 0.3.0
This commit is contained in:
parent
0d8c8a6e5b
commit
761d7a5f73
1 changed files with 32 additions and 6 deletions
38
index.html
38
index.html
|
@ -27,7 +27,7 @@ h1 { background: #2080C0; color: white; padding:25px 5% 8px; margin: 4% 7% 0px;
|
|||
|
||||
<h2><a id="introduction"></a>Introduction</h2>
|
||||
|
||||
<p><b>LSL PyOptimizer</b> is a LSL2 script optimizer written in Python 2. Currently it only supports code memory optimization (no speed optimization), only for Mono (no LSO), and only for the Second Life flavour of LSL (no OpenSim etc.).</p>
|
||||
<p><b>LSL PyOptimizer</b> is a LSL2 script optimizer written in Python 2.7. Currently it only supports code memory optimization (no speed optimization), only for Mono (no LSO), and only for the Second Life flavour of LSL (no OpenSim etc.).</p>
|
||||
|
||||
<p>The original LSL compiler does not do any optimizations whatsoever. Either the programmer does the optimization, or the scripts take more memory than necessary when writing something as simple as <code>a = -1;</code> (yes, the sign takes code memory!).</p>
|
||||
|
||||
|
@ -58,8 +58,9 @@ h1 { background: #2080C0; color: white; padding:25px 5% 8px; margin: 4% 7% 0px;
|
|||
<li><a href="#extensions-switch-statements"><code>switch()</code> statements</a>, for compatibility with Firestorm.</li>
|
||||
<li><a href="#extensions-lazy-lists">Lazy list syntax</a> (<code>identifier[index]</code>), for compatibility with Firestorm.</li>
|
||||
<li><a href="#extensions-allow-dup-fn">Allow duplicate function definitions</a>, for compatibility with Firestorm.</li>
|
||||
<li>As of version 0.1.3alpha, it can invoke the preprocessor on its own, providing defaults for the GNU C preprocessor <code>cpp</code> and for <a href="http://mcpp.sourceforge.net/">mcpp</a>.</li>
|
||||
<li>As of version 0.2.1beta, it can interpret <a href="#extensions-preproc-cmds"><code>#pragma</code> and <code>#line</code> preprocessor directives</a></li>
|
||||
<li>Invoke the preprocessor on its own, providing defaults for the GNU C preprocessor <code>cpp</code> and for <a href="http://mcpp.sourceforge.net/">mcpp</a> (since 0.1.3alpha).</li>
|
||||
<li>Interpret <a href="#extensions-preproc-cmds"><code>#pragma</code> and <code>#line</code> preprocessor directives</a> (0.2.1beta).</li>
|
||||
<li><a href="#extensions-inlining">Manual inlining of functions</a> (0.3.0beta).
|
||||
</ul>
|
||||
|
||||
<p><a href="#optimizations">Optimizations supported:</a></p>
|
||||
|
@ -79,7 +80,7 @@ h1 { background: #2080C0; color: white; padding:25px 5% 8px; margin: 4% 7% 0px;
|
|||
|
||||
<p>The project is hosted on GitHub. The latest version is available at: <a href="https://github.com/Sei-Lisa/LSL-PyOptimizer">https://github.com/Sei-Lisa/LSL-PyOptimizer</a></p>
|
||||
|
||||
<p>In order to run the program, you need <a href="https://www.python.org/downloads/">Python 2</a> installed. <b>Python 3 will not work. Download and install Python 2</b> if you don't have it already.</p>
|
||||
<p>In order to run the program, you need <a href="https://www.python.org/downloads/">Python 2.7</a> installed. <b>Python 3.x will not work. Download and install Python 2.7</b> if you don't have it already.</p>
|
||||
|
||||
<h2><a id="also-on-this-page"></a>Also on this page</h2>
|
||||
|
||||
|
@ -263,6 +264,31 @@ h1 { background: #2080C0; color: white; padding:25px 5% 8px; margin: 4% 7% 0px;
|
|||
|
||||
<p>In versions 0.1.3alpha and below, there was a similar option called <code>skippreproc</code> that merely skipped any preprocessor directives. That option is now removed.</p>
|
||||
|
||||
<h3><a id="extensions-inlining"></a>Manual inlining of functions</h3>
|
||||
|
||||
<p>The option <code>inline</code> in the command line options enables a syntax extension that allows you to use functions as if they were macros. This option is active by default.</p>
|
||||
|
||||
<p><b>This feature is in an experimental stage. Use at your own risk. Currently, inlined functions in loop conditions don't work properly.</b></p>
|
||||
|
||||
<p>To declare a function as inline, add the word <code>inline</code> after the close parenthesis of the parameter list. For example, this definition:</p>
|
||||
|
||||
<pre><code><span>say(string s) inline</span>
|
||||
<span>{</span>
|
||||
<span> llOwnerSay(s);</span>
|
||||
<span>}</span>
|
||||
</code></pre>
|
||||
|
||||
<p>allows you to use <code>say</code> as if it were <code>llOwnerSay</code>, without actually defining a new function in the optimized output. Of course, the same can be done with a preprocessor macro.</p>
|
||||
|
||||
<p><b>Caveats:</b></p>
|
||||
|
||||
<ul>
|
||||
<li>Inlined functions in loop conditions do not yet work. The inlined function will be inserted before the loop.</li>
|
||||
<li>It's still possible that the resulting code ends up wasting more space than defining a function. Preprocessor macros may be preferable.</li>
|
||||
<li>The order of evaluation of functions may not be the same as without inlining. All inlined functions will be executed before the expression they are used in, in an unspecified order. This order may change in future, so don't depend on it.</li>
|
||||
<li>New labels and variables may be created. The names use the pattern <code>___letters__numbers</code>. If you use names like these, you risk causing a name collision.</li>
|
||||
</ul>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2><a id="compatibility-syntax-extensions"></a>Compatibility Syntax extensions</h2>
|
||||
|
@ -445,7 +471,7 @@ but this will cause an error:
|
|||
|
||||
<p>The input script must be encoded in UTF-8. If you're using an editor, make sure it saves UTF-8.</p>
|
||||
|
||||
<p>Running it by hand to optimize your scripts can be cumbersome. The intention is for it to act as a filter that is transparent to the user; however, as of this writing there's no support for any viewer or IDE, as it is still a young project. Run it without parameters to see the invocation help, for example with <code>python main.py</code>. Redirect the output to a file if you want to store the result, possibly to open it with an editor and copy it to the clipboard. Or under <em>X Window</em>, if you install the package <kbd><em>xclip</em></kbd>, you can pipe the output directly to <code>xclip -quiet -selection clipboard</code> to copy it to the clipboard, rather than using a file, so you can paste it into the viewer. It's a good idea to use the option <code>--bom</code> to include a UTF-8 byte order mark that other applications can use to recognize the encoding. Examples:</p>
|
||||
<p>Running it by hand to optimize your scripts can be cumbersome. The intention is for it to act as a filter that is transparent to the user; however, as of this writing there's no support for any viewer or IDE. Run it without parameters to see the invocation help, for example with <code>python main.py</code>. Redirect the output to a file if you want to store the result, possibly to open it with an editor and copy it to the clipboard. Or under <em>X Window</em>, if you install the package <kbd><em>xclip</em></kbd>, you can pipe the output directly to <code>xclip -quiet -selection clipboard</code> to copy it to the clipboard, rather than using a file, so you can paste it into the viewer. It's a good idea to use the option <code>--bom</code> to include a UTF-8 byte order mark that other applications can use to recognize the encoding. Examples:</p>
|
||||
|
||||
<pre><code><span>python main.py --bom myscript.lsl | xclip -quiet -selection clipboard</span>
|
||||
</code></pre>
|
||||
|
@ -463,7 +489,7 @@ but this will cause an error:
|
|||
|
||||
<p>to copy the optimized output to the clipboard. Under <em>OS X</em>, <code>pbcopy</code> does the same as <code>xclip</code> and <code>clip</code>.</p>
|
||||
|
||||
<p>The <code>clip</code> application does not recognize the byte order mark, therefore <em>Windows</em> users may need to execute <code>chcp 65001</code> before using the optimizer, to switch their console to UTF-8 and make the <code>clip</code> program work.</p>
|
||||
<p>The <code>clip</code> application does not recognize the byte order mark, therefore <em>Windows</em> users may need to execute <code>chcp 65001</code> before using the optimizer, to switch their console to UTF-8 and make the <code>clip</code> program work properly with non-ASCII characters.</p>
|
||||
|
||||
<p>An external preprocessor is supported. If your system has a GNU C Compiler suite already installed, then the <code>cpp</code> that comes with it (or <code>gcc</code> adding the <code>-E</code> option) should be enough. If you don't have it, the recommended preprocessor is <em>mcpp</em>, because it's a standalone executable, easy to install. Download it from <a href="http://mcpp.sourceforge.net/download.html">http://mcpp.sourceforge.net/download.html</a>, unpack the executable somewhere in the system path (or specify the path to the executable every time with the <code>--precmd</code> option of the program) and you're ready to go.</p>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue