зеркало из https://github.com/mozilla/pjs.git
Propagate formatting changes from the mozilla-org CVS repository
This commit is contained in:
Родитель
f3d004a532
Коммит
7c2281b34b
|
@ -1,75 +0,0 @@
|
|||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!DOCTYPE doctype PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="generator" content=
|
||||
"HTML Tidy for Cygwin (vers 1st September 2004), see www.w3.org">
|
||||
<meta http-equiv="Content-Type" content=
|
||||
"text/html; charset=us-ascii">
|
||||
<meta name="Author" content="Igor Bukanov">
|
||||
<meta name="KeyWords" content="Rhino, JavaScript, Java">
|
||||
<title>Change Log</title>
|
||||
|
||||
<style type="text/css">
|
||||
P { text-align: justify; }
|
||||
</style>
|
||||
</head>
|
||||
<body bgcolor="#FFFFFF">
|
||||
<h1 align="center">Change Log for Rhino</h1>
|
||||
<h2>Change logs for previous Rhino releases</h2>
|
||||
<ul>
|
||||
<li><a href="rhino16R2.html">Rhino 1.6R2</a>, released
|
||||
2005-09-19</li>
|
||||
<li><a href="rhino16R1.html">Rhino 1.6R1</a>, released
|
||||
2004-11-29</li>
|
||||
<li><a href="rhino15R5.html">Rhino 1.5R5</a>, released
|
||||
2004-03-25</li>
|
||||
<li><a href="rhino15R41.html">Rhino 1.5R4.1</a>, released
|
||||
2003-04-21</li>
|
||||
<li><a href="rhino15R4.html">Rhino 1.5R4</a>, released
|
||||
2003-02-10</li>
|
||||
<li><a href="rhino15R3.html">Rhino 1.5R3</a>, released
|
||||
2002-01-27</li>
|
||||
<li><a href="rhino15R2.html">Rhino 1.5R2</a>, released
|
||||
2001-07-27</li>
|
||||
<li><a href="rhino15R1.html">Rhino 1.5R1</a>, released
|
||||
2000-09-10</li>
|
||||
</ul>
|
||||
<hr width="100%">
|
||||
<br>
|
||||
<a href="index.html">back to top</a>
|
||||
</body>
|
||||
</html>
|
|
@ -1,165 +0,0 @@
|
|||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="Author" content="Norris Boyd">
|
||||
<meta name="KeyWords" content="Rhino, JavaScript, Java">
|
||||
<title>Rhino Documentation</title>
|
||||
</head>
|
||||
<style>
|
||||
h1 { text-align: center }
|
||||
th { text-align: left; font-weight: normal; width: 220px }
|
||||
hr { width: 100% }
|
||||
</style>
|
||||
<body>
|
||||
|
||||
<h1> Rhino Documentation</h1>
|
||||
|
||||
<h3>General</h3>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th><a href="overview.html">Overview</a></th>
|
||||
<td>An overview of the JavaScript language and of Rhino.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><a href="limits.html">Requirements and Limitations</a></th>
|
||||
<td>What you must have to run Rhino; what Rhino cannot do.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><a href="changes.html">Change log</a></th>
|
||||
<td>Recent Rhino Changes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><a href="opt.html">Optimization</a></th>
|
||||
<td>Details on the various optimization levels.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><a href="faq.html">FAQ</a></th>
|
||||
<td>Answers to frequently asked questions about Rhino.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><a href="http://www.ociweb.com/jnb/archive/jnbMar2001.html">Scripting Languages for Java</a></th>
|
||||
<td>An article comparing and contrasting Rhino and Jython.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h3>Writing Scripts</h3>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th><a href="ScriptingJava.html">Scripting Java</a></th>
|
||||
<td>How to use Rhino to script Java classes.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><a href="scriptjava.html">Scripting Java</a></th>
|
||||
<td>How to use Rhino to script Java classes (an older treatment).</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><a href="perf.html">Performance Hints</a></th>
|
||||
<td>Some tips on writing faster JavaScript code.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h3>JavaScript Tools</h3>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th><a href="shell.html">JavaScript Shell</a></th>
|
||||
<td>Interactive or batch execution of scripts.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><a href="debugger.html">JavaScript Debugger</a></th>
|
||||
<td>Debugging scripts running in Rhino.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><a href="jsc.html">JavaScript Compiler</a></th>
|
||||
<td>Compiling scripts into Java class files.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><a href="http://www.mozilla.org/js/tests/library.html">Testing</a></th>
|
||||
<td>Running the JavaScript test suite.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h3>Embedding Rhino</h3>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th><a href="tutorial.html">Embedding tutorial</a></th>
|
||||
<td>A short tutorial on how to embed Rhino into your application.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><a href="apidocs/index.html">API javadoc Reference</a></th>
|
||||
<td>An annotated outline of the programming interface to Rhino (tip only).</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><a href="scopes.html">Scopes and Contexts</a></th>
|
||||
<td>Describes how to use scopes and contexts for the best performance
|
||||
and flexibility, with an eye toward multithreaded environments.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><a href="serialization.html">Serialization</a></th>
|
||||
<td>How to serialize JavaScript objects and functions in Rhino.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><a href="runtime.html">Runtime</a></th>
|
||||
<td>A brief description of the JavaScript runtime.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><a href="footprint.html">Small Footprint</a></th>
|
||||
<td>Hints for those interested in small-footprint embeddings.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><a href="examples.html">Examples</a></th>
|
||||
<td>A set of examples showing how to control the JavaScript engine and
|
||||
build JavaScript host objects.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><a href="bsf.html">Using Rhino with BSF</a></th>
|
||||
<td>How to use Rhino with apps that support BSF (Bean Scripting Framework) from the Apache Jakarta project.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h3><hr><a href="index.html">back to top</a></h3>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -32,41 +32,58 @@
|
|||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta http-equiv="Content-Language" content="en">
|
||||
<meta http-equiv="Content-Style-Type" content="text/css">
|
||||
<meta name="Author" content="Igor Bukanov">
|
||||
<meta name="KeyWords" content="Rhino, JavaScript, Java">
|
||||
<title>Rhino Downloads</title>
|
||||
|
||||
<link rel="up" href="./" title="Rhino project page">
|
||||
<link rel="section" href="#binaries" title="Rhino Binaries">
|
||||
<link rel="section" href="#source" title="Getting source code for Rhino">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<center><b><font size="+3">Rhino Downloads</font></b></center>
|
||||
|
||||
<p class="crumbs"><em>You are here:</em> <a href="./">Rhino project page</a> > <strong>Rhino Downloads</strong></p>
|
||||
|
||||
<h1>Rhino Downloads</h1>
|
||||
<p>Rhino is available for download both in source and compiled form. </p>
|
||||
<h3> Binaries</h3>
|
||||
|
||||
<h2><a name="binaries" id="binaries">Binaries</a></h2>
|
||||
<p>
|
||||
You can download binary distributions of Rhino from <a
|
||||
href="ftp://ftp.mozilla.org/pub/mozilla.org/js/"> ftp://ftp.mozilla.org/pub/mozilla.org/js/</a>
|
||||
. These zip files includes precompiled <tt>js.jar</tt> with all Rhino classes, documentation, examples and sources.
|
||||
href="ftp://ftp.mozilla.org/pub/mozilla.org/js/">ftp://ftp.mozilla.org/pub/mozilla.org/js/</a>
|
||||
. These zip files includes precompiled <code class="filename">js.jar</code>
|
||||
with all Rhino classes, documentation, examples and sources.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Rhino 1.6R4 is the last qualified release. It includes support for <a
|
||||
href="http://www.ecma-international.org/publications/standards/Ecma-357.htm">ECMAScript for XML</a> (E4X). To implement E4X runtime Rhino uses <a
|
||||
href="http://xmlbeans.apache.org/">XMLBeans</a> library and if you would like to use E4X you need to add <tt>xbean.jar</tt> from XMLBeans distribution to your class path.</p>
|
||||
Rhino 1.6R4 is the last qualified release. It includes support for
|
||||
<a class="ex-ref"
|
||||
href="http://www.ecma-international.org/publications/standards/Ecma-357.htm">ECMAScript for XML</a> (E4X). To implement E4X runtime Rhino uses <a class="ex-ref"
|
||||
href="http://xmlbeans.apache.org/">XMLBeans</a> library and if you
|
||||
would like to use E4X you need to add <code class="filename">xbean.jar</code>
|
||||
from XMLBeans distribution to your class path.</p>
|
||||
|
||||
|
||||
<table border=1 cellpadding=2 cellspacing=0>
|
||||
<table class="data">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Release</th>
|
||||
<th>Release Date</th>
|
||||
<th>Change log</th>
|
||||
<th>Download link</th>
|
||||
<th scope="col">Release</th>
|
||||
<th scope="col">Release Date</th>
|
||||
<th scope="col">Change log</th>
|
||||
<th scope="col">Download link</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Rhino 1.6R4</td>
|
||||
<td>2006-09-10</td>
|
||||
|
@ -144,30 +161,35 @@ href="http://xmlbeans.apache.org/">XMLBeans</a> library and if you would like to
|
|||
<td><a href="ftp://ftp.mozilla.org/pub/mozilla.org/js/older-packages/rhino14R3.zip">rhino14R3.zip</a></td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p>If you are looking for <tt>js.jar</tt> for XSLT or for IBM's Bean
|
||||
Scripting Framework (BSF), please read the following <a href="bsf.html#bsf-issue">note</a> and then download one of the zip files above and unzip it. </p>
|
||||
<p>If you are looking for <code class="filename">js.jar</code> for XSLT
|
||||
or for IBM's <dfn>Bean Scripting Framework (BSF)</dfn>, please read the
|
||||
following <a href="bsf.html#bsf-issue">note</a> and then download one of
|
||||
the zip files above and unzip it.</p>
|
||||
|
||||
<h3> Source</h3>
|
||||
The source code for Rhino is available under a dual <a
|
||||
href="http://www.mozilla.org/MPL/MPL-1.1.html">MPL 1.1</a>/GPL 2.0 license. In addition to getting the
|
||||
source from the zip files above, the source code for Rhino can be found in the
|
||||
CVS tree at mozilla/js/rhino. See <a
|
||||
href="http://www.mozilla.org/cvs.html">source code via cvs</a> for details on
|
||||
how to set up CVS, define your CVSROOT, and login. Once you've done that, just
|
||||
execute the command
|
||||
<pre> cvs co mozilla/js/rhino</pre>
|
||||
to get the tip source.
|
||||
<h2><a name="source" id="source">Source</a></h2>
|
||||
<p>The source code for Rhino is available under <a
|
||||
href="http://www.mozilla.org/MPL/MPL-1.1.html">MPL 1.1</a>/GPL 2.0 license. In addition to
|
||||
getting the source from the zip files above, the source code for
|
||||
Rhino can be found in the CVS tree at mozilla/js/rhino. See <a
|
||||
href="http://developer.mozilla.org/en/docs/Mozilla_Source_Code_Via_CVS">source code via cvs</a> for details on how to set up CVS, define your CVSROOT, and login. Once
|
||||
you've done that, just execute the command</p>
|
||||
|
||||
<pre class="code"> cvs co mozilla/js/rhino
|
||||
</pre>
|
||||
|
||||
<p>to get the tip source.</p>
|
||||
<p>The current tip can also be viewed using LXR at <a
|
||||
href="http://lxr.mozilla.org/mozilla/source/js/rhino/">
|
||||
http://lxr.mozilla.org/mozilla/source/js/rhino/</a> . See also <a href="changes.html">change log</a> for the current tip.</p>
|
||||
http://lxr.mozilla.org/mozilla/source/js/rhino/</a> . See also
|
||||
<a href="changes.html">change log</a> for the current tip.</p>
|
||||
<p>
|
||||
Rhino uses <a href="http://ant.apache.org/">Ant</a> as its build system and running <tt>ant</tt> command at the top directory of Rhino distribution should print the list of available build targets.
|
||||
</p>
|
||||
<hr width="100%"><a href="index.html">back to top</a> <br>
|
||||
<br>
|
||||
Rhino uses <a class="ex-ref" href="http://ant.apache.org/">Ant</a> as its
|
||||
build system and running <tt>ant</tt> command at the top
|
||||
directory of Rhino distribution should print the list of
|
||||
available build targets.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,86 +0,0 @@
|
|||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="Author" content="Norris Boyd">
|
||||
<meta name="GENERATOR" content="Mozilla/4.75 [en] (Windows NT 5.0; U) [Netscape]">
|
||||
<meta name="KeyWords" content="Rhino, JavaScript, Java">
|
||||
<title>Rhino FAQ</title>
|
||||
</head>
|
||||
<body bgcolor="#FFFFFF">
|
||||
<script src="owner.js"></script>
|
||||
|
||||
<center>
|
||||
<h1>
|
||||
Frequently Asked Questions about Rhino</h1></center>
|
||||
<script>document.write(owner());</script>
|
||||
|
||||
<br><script>
|
||||
var d = new Date(document.lastModified);
|
||||
document.write((d.getMonth()+1)+"/"+d.getDate()+"/"+d.getFullYear());
|
||||
document.write('<br>');
|
||||
</script>
|
||||
|
||||
<center>
|
||||
<hr WIDTH="100%"></center>
|
||||
|
||||
<p><b><font size=+2>Q</font>.</b> <i>How do I create a Java array from
|
||||
JavaScript?</i>
|
||||
<p><b><font size=+2>A.</font></b> You must use Java reflection. For instance,
|
||||
to create an array of java.lang.String of length five, do
|
||||
<blockquote><tt>var stringArray = java.lang.reflect.Array.newInstance(java.lang.String,
|
||||
5);</tt></blockquote>
|
||||
Then if you wish to assign the string "hi" to the first element, simply
|
||||
execute <tt>stringArray[0] = "hi"</tt>.
|
||||
<p>Creating arrays of primitive types is slightly different: you must use
|
||||
the TYPE field. For example, creating an array of seven ints can be done
|
||||
with the code
|
||||
<blockquote><tt>var intArray = java.lang.reflect.Array.newInstance(java.lang.Integer.TYPE,
|
||||
7);</tt></blockquote>
|
||||
|
||||
<p><br><b><font size=+2>Q</font>.</b> <i>When I try to execute a script
|
||||
I get the exception </i><tt>Required security context missing</tt><i>.
|
||||
What's going on?</i>
|
||||
<p><b><font size=+2>A.</font></b> You've likely missed placing the <tt>Security.properties</tt>
|
||||
file in your class path at <tt>org.mozilla.javascript.resources</tt>.
|
||||
<h3>
|
||||
|
||||
<hr WIDTH="100%"><br>
|
||||
<a href="index.html">back to top</a></h3>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -32,25 +32,37 @@
|
|||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta http-equiv="Content-Language" content="en">
|
||||
<meta http-equiv="Content-Style-Type" content="text/css">
|
||||
<meta http-equiv="Content-Script-Type" content="text/javascript">
|
||||
<title>Help with Rhino</title>
|
||||
<script src="owner.js"></script>
|
||||
<style>
|
||||
h1 { text-align: center }
|
||||
<script type="text/javascript" src="owner.js"></script>
|
||||
<style type="text/css">
|
||||
h1 { text-align: center; }
|
||||
</style>
|
||||
|
||||
<link rel="up" href="./" title="Rhino project page">
|
||||
<link rel="section" href="#newsgroups" title="Newsgroup and Mail Gateway">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p class="crumbs"><em>You are here:</em> <a href="./">Rhino project page</a> > <strong>Help with Rhino</strong></p>
|
||||
|
||||
<h1>Help with Rhino</h1>
|
||||
|
||||
<p>Have a question that you can't find answer to in the <a href="doc.html">documentation</a>?
|
||||
Here are some additional resources for help:
|
||||
</p>
|
||||
|
||||
<h3>Newsgroup and Mail Gateway</h3>
|
||||
<h2><a name="newsgroups" id="newsgroups">Newsgroup and Mail Gateway</a></h2>
|
||||
<p>
|
||||
The <a href="news:netscape.public.mozilla.jseng">netscape.public.mozilla.jseng</a>
|
||||
newsgroup answers questions about both Rhino and the C implementation of
|
||||
|
@ -60,26 +72,22 @@ To post messages, send mail to <a href="mailto:mozilla-jseng@mozilla.org">mozill
|
|||
To unsubscribe, mail with "unsubscribe" in the subject to <a href="mailto:mozilla-jseng-request@mozilla.org?subject=unsubscribe">mozilla-jseng-request@mozilla.org</a>.
|
||||
</p>
|
||||
<p>
|
||||
To view archived messages, try <a href="http://groups.google.com/groups?q=netscape.public.mozilla.jseng&hl=en&lr=&safe=off&site=groups">Google groups</a> or
|
||||
To view archived messages, try <a href="http://groups.google.com/groups?q=netscape.public.mozilla.jseng&hl=en&lr=&safe=off&site=groups">Google groups</a> or
|
||||
other newsgroup services.
|
||||
</p>
|
||||
|
||||
<h3>Bug System</h3>
|
||||
<h2>Bug System</h2>
|
||||
<p>
|
||||
Use <a href="http://bugzilla.mozilla.org/enter_bug.cgi?product=Rhino">Bugzilla</a>
|
||||
Use <a href="https://bugzilla.mozilla.org/enter_bug.cgi?product=Rhino">Bugzilla</a>
|
||||
to enter bugs against Rhino. Note that Rhino has its own product category.
|
||||
</p>
|
||||
|
||||
<h3>Module Owner</h3>
|
||||
<h2>Module Owner</h2>
|
||||
<p>
|
||||
The module owner, <script>document.write(owner());</script>, can
|
||||
The module owner, <script type="text/javascript">document.write(owner());</script>, can
|
||||
be mailed for help as well, although he may copy his response to the newsgroup
|
||||
to help others.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<hr WIDTH="100%"><a href="index.html">back to top</a>
|
||||
<br>
|
||||
<br>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,120 +0,0 @@
|
|||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="Author" content="Norris Boyd">
|
||||
<meta name="GENERATOR" content="Mozilla/4.72 [en]C-NSCP (WinNT; U) [Netscape]">
|
||||
<title>JavaScript Requirements and Limitations</title>
|
||||
</head>
|
||||
<body bgcolor="#FFFFFF">
|
||||
|
||||
<center>
|
||||
<h1>
|
||||
Requirements and Limitations</h1></center>
|
||||
|
||||
<h2>
|
||||
<b>Requirements</b></h2>
|
||||
Rhino requires version 1.1 or greater of Java.
|
||||
<p>To use the JavaAdapter feature or an optimization level of 0 or greater,
|
||||
Rhino must be running under a security manager that allows the definition
|
||||
of class loaders.
|
||||
<p>
|
||||
<hr WIDTH="100%">
|
||||
<h2>
|
||||
<b>Limitations</b></h2>
|
||||
|
||||
<h3>
|
||||
<b>Platforms and </b>JITs</h3>
|
||||
Many platforms and JREs have problems converting decimal numbers to and
|
||||
from strings. These errors are usually boundary case errors and will show
|
||||
up as test failures in section 7.7.3.
|
||||
<p>Windows versions of the Symantec JIT prior to 3.00.029(i) will report
|
||||
internal errors for some generated class files.
|
||||
<p>On the Symantec JIT and the AIX JVM, accessing a static field of a class
|
||||
that has not yet loaded may not give the correct value of the field. For
|
||||
example, accessing
|
||||
<tt>java.io.File.separatorChar</tt> before <tt>java.io.File</tt>
|
||||
has been loaded will return a value of 0. (This is a bug in the JIT; accessing
|
||||
the field should cause the class to be loaded.)
|
||||
<p>The AIX Java version "JDK 1.1.6 IBM build a116-19980924 (JIT enabled:
|
||||
jitc)" core dumps running several classes generated by Rhino. It also has
|
||||
errors in java.lang.Math.pow that are reflected as failures in the JavaScript
|
||||
Math object's pow method.
|
||||
<p>IBM Java for Linux version "JDK 1.1.8 IBM build l118-19991013 (JIT enabled:
|
||||
jitc)" has errors in java.lang.Math.pow that are reflected as test failures
|
||||
in the JavaScript Math object's pow method.
|
||||
<p>Solaris JDK 1.1.6 has errors in java.lang.Math.atan2 that are reflected
|
||||
as test failures in the JavaScript Math object's atan2 method.
|
||||
<br>
|
||||
<h3>
|
||||
<b>LiveConnect</b></h3>
|
||||
If a JavaObject's field's name collides with that of a method, the value
|
||||
of that field is retrieved lazily, and can be counter-intuitively affected
|
||||
by later assignments:
|
||||
<blockquote><tt>javaObj.fieldAndMethod = 5;</tt>
|
||||
<br><tt>var field = javaObj.fieldAndMethod;</tt>
|
||||
<br><tt>javaObj.fieldAndMethod = 7;</tt>
|
||||
<br><tt>// now, field == 7</tt></blockquote>
|
||||
You can work around this by forcing the field value to be converted to
|
||||
a JavaScript type when you take its value:
|
||||
<blockquote><tt>javaObj.fieldAndMethod = 5;</tt>
|
||||
<br><tt>var field = javaObj.fieldAndMethod + 0; // force conversion now</tt>
|
||||
<br><tt>javaObj.fieldAndMethod = 7;</tt>
|
||||
<br><tt>// now, field == 5</tt></blockquote>
|
||||
|
||||
<h3>
|
||||
<b>JSObject</b></h3>
|
||||
Rhino does NOT support the <tt>netscape.javascript.JSObject</tt> class.
|
||||
<br>
|
||||
<h3>
|
||||
<b>Date object</b></h3>
|
||||
The JavaScript Date object depends on time facilities of the underlying
|
||||
Java runtime to determine daylight savings time dates. Earlier JRE versions
|
||||
may report a date for the daylight savings changeover that is a week off.
|
||||
JRE 1.1.6 reports the correct date.
|
||||
<p>Under the 1.1.6 JRE, evaluating <tt>(new Date(1998, 9, 25, 2)).toString()</tt>
|
||||
returns:
|
||||
<pre> Sun Oct 25 02:00:00 GMT-0800 (PST) 1998</pre>
|
||||
Earlier versions may return:
|
||||
<pre> Sun Oct 25 02:00:00 GMT-0700 (PDT) 1998</pre>
|
||||
(the JRE doesn't report the changeover until Nov. 1.)
|
||||
<p>The Microsoft SDK 3.1 for Java also exhibits this problem.
|
||||
<p>
|
||||
<hr WIDTH="100%">
|
||||
<br><a href="#">back to top</a>
|
||||
</body>
|
||||
</html>
|
|
@ -1,104 +0,0 @@
|
|||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
|
||||
<META NAME="Author" CONTENT="Norris Boyd">
|
||||
<META NAME="GENERATOR" CONTENT="Mozilla/4.05 [en] (WinNT; U) [Netscape]">
|
||||
<TITLE>Optimization</TITLE>
|
||||
</HEAD>
|
||||
<BODY BGCOLOR="#FFFFFF">
|
||||
|
||||
<CENTER>
|
||||
<H1>
|
||||
Optimization</H1></CENTER>
|
||||
|
||||
<H2>
|
||||
Optimization settings</H2>
|
||||
<P>The currently supported optimization settings are:</P>
|
||||
|
||||
<P><B>-1</B></P>
|
||||
|
||||
<p>Interpretive mode is always used. The compilation time is minimized at the
|
||||
expense of runtime performance. No class files are generated, which may improve
|
||||
memory usage depending on your system. Another benefit of the interpreted mode
|
||||
is that the interpreter performs tail-call elimination of recursive functions.
|
||||
Also, you must use this optimization level if your code uses Continuation
|
||||
objects.
|
||||
<p>
|
||||
If the optimization package is not available, then optimization acts as if it is always -1.
|
||||
</p>
|
||||
|
||||
<P><B>0</B>
|
||||
|
||||
<P>No optimizations are
|
||||
performed. The bytecode compiler runs fastest in this mode, but the generated byte code
|
||||
is less efficient.</P>
|
||||
|
||||
<P><B>1-9</B>
|
||||
|
||||
<P>All optimizations are performed. Simple data & type
|
||||
flow analysis is performed to determine which JavaScript variables can be
|
||||
allocated to Java VM registers, and which variables are used only as Numbers.
|
||||
Local common sub-expressions are collapsed (currently this only happens for
|
||||
property lookup, but in the future more expressions may be optimized). All local
|
||||
variables and parameters are allocated to Java VM registers. Function call
|
||||
targets are speculatively pre-cached (based on the name used in the source) so
|
||||
that dispatching can be direct, pending runtime confirmation of the actual
|
||||
target. Arguments are passed as Object/Number pairs to reduce conversion
|
||||
overhead.</P>
|
||||
|
||||
<P>Note:
|
||||
<OL>
|
||||
<LI>
|
||||
Some language features (indirect calls to eval, use
|
||||
of the arguments property of function objects) were previously not supported
|
||||
in higher optimization levels. These features have been removed from the
|
||||
language in ECMA, so higher optimization levels are now conformant.
|
||||
|
||||
<LI>
|
||||
Future versions may allocate more aggressive
|
||||
optimizations to higher optimization levels. For compatibility with future
|
||||
versions, use level 1. For maximal optimization, use level 9, but retest
|
||||
your application when upgrading to new versions.</LI>
|
||||
</OL>
|
||||
|
||||
|
||||
<P>
|
||||
<HR WIDTH="100%">
|
||||
<BR><A HREF="index.html">back to top</A>
|
||||
<br>
|
||||
</BODY>
|
||||
</HTML>
|
|
@ -1,184 +0,0 @@
|
|||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="Author" content="Norris Boyd">
|
||||
<meta name="GENERATOR" content="Mozilla/4.72 [en]C-NSCP (WinNT; U) [Netscape]">
|
||||
<title>JavaScript Overview</title>
|
||||
</head>
|
||||
<body bgcolor="#FFFFFF">
|
||||
|
||||
<center>
|
||||
<h1>
|
||||
Rhino Overview</h1></center>
|
||||
|
||||
<h3>
|
||||
Overview of Rhino</h3>
|
||||
Most people who have used JavaScript before have done so by adding scripts
|
||||
to their HTML web pages. However, Rhino is an implementation of the core
|
||||
language only and doesn't contain objects or methods for manipulating HTML
|
||||
documents.
|
||||
<p>Rhino contains
|
||||
<ul>
|
||||
<li>
|
||||
All the features of JavaScript 1.5</li>
|
||||
|
||||
<li>
|
||||
Allows direct scripting of Java</li>
|
||||
|
||||
<li>
|
||||
A JavaScript shell for executing JavaScript scripts</li>
|
||||
|
||||
<li>
|
||||
A JavaScript compiler to transform JavaScript source files into Java class
|
||||
files</li>
|
||||
</ul>
|
||||
|
||||
<h3>
|
||||
Language</h3>
|
||||
The JavaScript language itself is standardized by Standard ECMA-262 <i>ECMAScript:
|
||||
A general purpose, cross-platform programming language</i>. Rhino 1.5 implements
|
||||
JavaScript 1.5, which conforms to Edition 3 of the Standard. The Standard
|
||||
may be <a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">downloaded</a> or
|
||||
obtained by mail from ECMA, 114 Rue du Rhône, CH1204 Geneva, Switzerland.
|
||||
<p>Rhino 1.6 also implements ECMA-357 <i>ECMAScript for XML (E4X)</i>. See the <a href="http://www.ecma-international.org/publications/standards/Ecma-357.htm">specification</a> for more information on the standard, and <a href="rhino16R1.html#E4X">Rhino version 1.6R1</a> for details on the implementation in Rhino.
|
||||
|
||||
<p>In addition, Rhino has implemented JavaAdapters, which allows JavaScript
|
||||
to implement any Java interface or extend any Java class with a JavaScript
|
||||
object. See the <tt>enum.js</tt> example for more information.
|
||||
<p>Numerous books and tutorials on JavaScript are available.
|
||||
<br>
|
||||
<br>
|
||||
<h3>
|
||||
Deprecated Language Features</h3>
|
||||
Several language features introduced in JavaScript 1.2 are now deprecated.
|
||||
These features allow "computational reflection": that is, the ability for
|
||||
a script to determine and influence aspects of the way it is evaluated.
|
||||
These features are generally not broadly useful, yet they impose significant
|
||||
constraints on implementations that hamper or prevent optimization. The
|
||||
deprecated features are the <tt>__proto__</tt> and <tt>__parent__</tt>
|
||||
properties, and the constructors <tt>With</tt>, <tt>Closure</tt>, and <tt>Call</tt>.
|
||||
Attempts to invoke these constructors with the language version 1.4 will
|
||||
result in an error. For other versions, a warning will be generated.
|
||||
<br>
|
||||
<br>
|
||||
<h3>
|
||||
Internationalization</h3>
|
||||
The messages reported by the JavaScript engine are by default retrieved
|
||||
from the property file <tt>org/mozilla/javascript/resources/Messages.properties</tt>.
|
||||
If other properties files with extensions corresponding to the current
|
||||
locale exist, they will be used instead.
|
||||
<br>
|
||||
<br>
|
||||
<h3>
|
||||
<a NAME="versions"></a>JavaScript Language Versions</h3>
|
||||
Some behavior in the JavaScript engine is dependent on the language version.
|
||||
In browser embeddings, this language version is selected using the LANGUAGE
|
||||
attribute of the SCRIPT tag with values such as "JavaScript1.2".
|
||||
<p>Version 1.3 and greater are ECMA conformant.
|
||||
<p><b>Operators <tt>==</tt> and <tt>!=</tt></b>
|
||||
<p>Version 1.2 only uses strict equality for the == and != operators. In
|
||||
version 1.3 and greater, == and != have the same meanings as ECMA. The
|
||||
operators === and !== use strict equality in all versions.
|
||||
<p><b>ToBoolean</b>
|
||||
<p><tt>Boolean(new Boolean(false))</tt> is false for all versions before
|
||||
1.3. It is true (and thus ECMA conformant) for version 1.3 and greater.
|
||||
<p><b>Array.prototype.toString and Object.prototype.toString</b>
|
||||
<p>Version 1.2 only returns array or object literal notation ("[1,2,3]"
|
||||
or "{a:1, b:2}" for example). In version 1.3 and greater these functions
|
||||
are ECMA conformant.
|
||||
<p><b>Array constructor</b>
|
||||
<p><tt>Array(i)</tt> for a number argument <tt>i</tt> constructs an array
|
||||
with a single element equal to <tt>i</tt> for version 1.2 only. Otherwise
|
||||
the ECMA conformant version is used (an array is constructed with no elements
|
||||
but with length property equal to <tt>i</tt>).
|
||||
<p><b>String.prototype.substring</b>
|
||||
<p>For version 1.2 only, the two arguments are not swapped if the first
|
||||
argument is less than the second one. All other versions are ECMA compliant.
|
||||
<p><b>String.prototype.split</b>
|
||||
<p>For version 1.2 only, split performs the Perl4 special case when given
|
||||
a single space character as an argument (skips leading whitespace, and
|
||||
splits on whitespace). All other versions split on the space character
|
||||
proper as specified by ECMA.
|
||||
<br>
|
||||
<br>
|
||||
<h3>
|
||||
Security</h3>
|
||||
The security features in Rhino provide the ability to track the origin
|
||||
of a piece of code (and any pieces of code that it may in turn generate).
|
||||
These features allow for the implementation of a traditional URL-based
|
||||
security policy for JavaScript as in Netscape Navigator. Embeddings that
|
||||
trust the JavaScript code they execute may ignore the security features.
|
||||
<p>Embeddings that run untrusted JavaScript code must do two things to
|
||||
enable the security features. First, every <tt>Context</tt> that is created
|
||||
must be supplied an instance of an object that implements the <tt>SecuritySupport</tt>
|
||||
interface. This will provide Rhino the support functionality it needs to
|
||||
perform security-related tasks.
|
||||
<p>Second, the value of the property <tt>security.requireSecurityDomain</tt>
|
||||
should be changed to <tt>true</tt> in the resource bundle <tt>org.mozilla.javascript.resources.Security</tt>.
|
||||
The value of this property can be determined at runtime by calling the
|
||||
<tt>isSecurityDomainRequired</tt>
|
||||
method of <tt>Context</tt>. Setting this property to true requires that
|
||||
any calls that compile or evaluate JavaScript must supply a security domain
|
||||
object of any object type that will be used to identify JavaScript code.
|
||||
In a typical client embedding, this object might be a string with the URL
|
||||
of the server that supplied the script, or an object that contains a representation
|
||||
of the signers of a piece of code for certificate-based security policies.
|
||||
<p>When JavaScript code attempts a restricted action, the security domain
|
||||
can be retrieved in the following manner. The class context should be obtained
|
||||
from the security manager (see <tt>java.lang.SecurityManager.getClassContext()</tt>).
|
||||
Then, the class of the code that called to request the restricted action
|
||||
can be obtained by looking an appropriate index into the class context
|
||||
array. If the caller is JavaScript the class obtained may be one of two
|
||||
types. First, it may be the class of the interpreter if interpretive mode
|
||||
is in effect. Second, it may be a generated class if classfile generation
|
||||
is supported. An embedding can distinguish the two cases by calling <tt>isInterpreterClass()</tt>
|
||||
in the <tt>Context</tt> class. If it is the interpreter class, call the
|
||||
getInterpreterSecurityDomain() method of Context to obtain the security
|
||||
domain of the currently executing interpreted script or function. Otherwise,
|
||||
it must be a generated class, and an embedding can call <tt>getSecurityDomain()</tt>
|
||||
in the class implementing
|
||||
<tt>SecuritySupport</tt>. When the class was
|
||||
defined and loaded, the appropriate security domain was associated with
|
||||
it, and can be retrieved by calling this method. Once the security domain
|
||||
has been determined, an embedding can perform whatever checks are appropriate
|
||||
to determine whether access should be allowed.
|
||||
<p>
|
||||
<hr WIDTH="100%">
|
||||
<br><a href="index.html">back to top</a>
|
||||
</body>
|
||||
</html>
|
|
@ -1,117 +0,0 @@
|
|||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="Author" content="Norris Boyd">
|
||||
<meta name="GENERATOR" content="Mozilla/4.5 [en]C-NSCP (WinNT; I) [Netscape]">
|
||||
<title>Performance Hints</title>
|
||||
</head>
|
||||
<body bgcolor="#FFFFFF">
|
||||
|
||||
<center>
|
||||
<h1>
|
||||
Performance Hints</h1></center>
|
||||
<h3>
|
||||
<tt>var</tt> Statements</h3>Use <tt>var</tt> statements when possible. Not only is it good
|
||||
programming practice, it can speed up your code by allowing the compiler to
|
||||
generate special code to access the variables. For example, you could rewrite
|
||||
<p><tt>function sum(a) {</tt>
|
||||
<br><tt> result = 0;</tt>
|
||||
<br><tt> for (i=0; i <
|
||||
a.length; i++)</tt>
|
||||
<br><tt> result += a[i];</tt>
|
||||
<br><tt> return result;</tt>
|
||||
<br><tt>}</tt>
|
||||
<p>as
|
||||
<p><tt>function sum(a) {</tt>
|
||||
<br><tt> var result = 0;</tt>
|
||||
<br><tt> for (var i=0; i
|
||||
< a.length; i++)</tt>
|
||||
<br><tt> result += a[i];</tt>
|
||||
<br><tt> return result;</tt>
|
||||
<br><tt>}</tt>
|
||||
<p>This is not equivalent code because the second version does
|
||||
not modify global variables <tt>result</tt> and <tt>i</tt>. However, if you don't intend for any other function to
|
||||
access these variables, then storing them globally is probably wrong anyway
|
||||
(what if you called another function that had a loop like the one in <tt>sum</tt>!).
|
||||
<br>
|
||||
<h3>
|
||||
Arrays</h3>Use the forms of the Array constructor that
|
||||
specify a size or take a list of initial elements. For example, the code
|
||||
<p><tt>var a = new Array();</tt>
|
||||
<br><tt>for (var i=0; i < n; i++)</tt>
|
||||
<br><tt> a[i] = i;</tt>
|
||||
<p>could be sped up by changing the constructor call to <tt>new Array(n)</tt>. A constructor call like that indicates to
|
||||
the runtime that a Java array should be used for the first <i>n</i> entries of the array. Similarly,
|
||||
<tt>new
|
||||
Array("a", "b", "c")</tt> or <tt>["a", "b", "c"]</tt> will cause a 3-element
|
||||
Java array to be allocated to hold the contents of the JavaScript array.
|
||||
<br>
|
||||
<br>
|
||||
<h3>
|
||||
<tt>eval</tt> and <tt>new Function</tt></h3>Avoid calling <tt>eval</tt> when
|
||||
possible. Calls to <tt>eval</tt> are slow because the script
|
||||
being executed must be compiled. Constructing a new function object can be slow
|
||||
for the same reason, while function expressions are more efficient because the
|
||||
function can be compiled. For example, the code
|
||||
<p><tt>function MyObject(a) {</tt>
|
||||
<br><tt> this.s = a;</tt>
|
||||
<br><tt> this.toString = new
|
||||
Function("return this.s");</tt>
|
||||
<br><tt>}</tt>
|
||||
<p>could be written more efficiently as
|
||||
<p><tt>function MyObject(a) {</tt>
|
||||
<br><tt> this.s = a;</tt>
|
||||
<br><tt> this.toString =
|
||||
function () { return this.s }</tt>
|
||||
<br><tt>}</tt>
|
||||
<p>Beginning with Rhino 1.4 Release 2, code
|
||||
passed to eval and new Function will be interpreted rather than compiled to
|
||||
class files.
|
||||
<br> </p>
|
||||
<h3>
|
||||
with</h3>Using the <tt>with</tt>
|
||||
statement prevents the compiler from generating code for fast access to local
|
||||
variables. You're probably better off explicitly accessing any properties of the
|
||||
object.
|
||||
<br>
|
||||
<p>
|
||||
<hr WIDTH="100%">
|
||||
<br><a href="index.html">back to top</a>
|
||||
<br>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче