📄 js.texi
字号:
\input texinfo @c -*-texinfo-*-
@c %**start of header
@setfilename js.info
@settitle js
@setchapternewpage on
@c %**end of header
@c (save-excursion (replace-regexp "^@\\(end \\)?cartouche" "@c \\&"))
@c (save-excursion (replace-regexp "^@c \\(@\\(end \\)?cartouche\\)" "\\1"))
@include version.texi
@set ECMA ECMA-262 Version 2 draft 22-Apr-98
@set JSREF Netscape JavaScript Reference 12-Dec-97
@set NGS NGS JavaScript Interpreter @value{VERSION}
@dircategory NGS JavaScript Interpreter
@direntry
* libjs: (js). The JavaScript interpreter library.
* js: (js)The js Program. JavaScript interpreter.
@end direntry
@c Combine function and variable indexes to the Concept index.
@synindex fn cp
@synindex vr cp
@ifinfo
This file documents NGS JavaScript interpreter @value{VERSION}
Copyright (C) 1998 New Generation Software (NGS) Oy
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
are preserved on all copies.
@ignore
Permission is granted to process this file through TeX and print the
results, provided the printed document carries copying permission
notice identical to this one except for the removal of this paragraph
@end ignore
Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided that the entire
resulting derived work is distributed under the terms of a permission
notice identical to this one.
Permission is granted to copy and distribute translations of this manual
into another language, under the above conditions for modified versions,
except that this permission notice may be stated in a translation approved
by the Foundation.
@end ifinfo
@titlepage
@title NGS JavaScript Interpreter
@subtitle For version @value{VERSION}, @value{UPDATED}
@author Markku Rossi
@page
@vskip 0pt plus 1filll
Copyright @copyright{} 1998 New Generation Software (NGS) Oy
@sp 2
This is the first edition of the NGS JavaScript documentation,@*
and is consistent with NGS JavaScript Interpreter @value{VERSION}.@*
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
are preserved on all copies.
Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided that the entire
resulting derived work is distributed under the terms of a permission
notice identical to this one.
Permission is granted to copy and distribute translations of this manual
into another language, under the above conditions for modified versions,
except that this permission notice may be stated in a translation
approved by the Free Software Foundation.
@end titlepage
@ifinfo
@node Top, Introduction, (dir), (dir)
@comment node-name, next, previous, up
@top NGS JavaScript Interpreter
This file documents the NGS JavaScript interpreter. This edition
documents version @value{VERSION}.
@menu
* Introduction::
* NGS JavaScript Language::
* The js Program::
* The jsas Program::
* The jsdas Program::
* The jswrap Program::
* JavaScript API::
* Virtual Machine::
* JavaScript Compiler::
* GNU Library General Public License::
* Index::
@end menu
@end ifinfo
@c ----------------------------------------------------------------------
@node Introduction, NGS JavaScript Language, Top, Top
@chapter Introduction
@itemize @bullet
@item overall
@item design goals
@item structure: virtual machine, JSC$, JS glue
@end itemize
@c ----------------------------------------------------------------------
@node NGS JavaScript Language, The js Program, Introduction, Top
@chapter NGS JavaScript Language
@menu
* Language::
* Global Methods and Properties::
* Native Objects::
* Extensions::
@end menu
@c ----------------------------------------------------------------------
@node Language, Global Methods and Properties, NGS JavaScript Language, NGS JavaScript Language
@section Language
@menu
* Lexical Conventions::
* Function Definition::
* Statements::
* Expressions::
@end menu
@node Lexical Conventions, Function Definition, Language, Language
@subsection Lexical Conventions
@menu
* White Space::
* Comments::
* Reserved Words::
* Identifiers::
* Punctuators::
* Literals::
* Automatic Semicolon Insertion::
@end menu
@node White Space, Comments, Lexical Conventions, Lexical Conventions
@subsubsection White Space
@node Comments, Reserved Words, White Space, Lexical Conventions
@subsubsection Comments
@node Reserved Words, Identifiers, Comments, Lexical Conventions
@subsubsection Reserved Words
@node Identifiers, Punctuators, Reserved Words, Lexical Conventions
@subsubsection Identifiers
@node Punctuators, Literals, Identifiers, Lexical Conventions
@subsubsection Punctuators
@node Literals, Automatic Semicolon Insertion, Punctuators, Lexical Conventions
@subsubsection Literals
@node Automatic Semicolon Insertion, , Literals, Lexical Conventions
@subsubsection Automatic Semicolon Insertion
Certain ECMAScript statements must be terminated with a semicolon. Such
a semicolon may always appear explicitly in the source text. For pain
of the compiler implementator, however, such semicolons may be omitted
from the source text in certain situations. These situations are
described in details in the @value{ECMA} standard. Here is
@email{mtr@@ngs.fi}'s interpretation of the rules:
Insert semicolons as you would do in the C language. Now, you can omit
them:
@enumerate
@item before '@code{@}}' character
@item from the end of the line
@item from the end of the file
@end enumerate
@noindent The automatic semicolon insertion sets some restrictions how
you can insert whitespace to you code. You can't insert line breaks:
@enumerate
@item between @var{LeftHandSideExpression} and @code{++} or @code{--}
operator
@item between @code{return} and the returned @var{Expression}
@end enumerate
@node Function Definition, Statements, Lexical Conventions, Language
@subsection Function Definition
@node Statements, Expressions, Function Definition, Language
@subsection Statements
@menu
* Block::
* Variable Statement::
* Empty Statement::
* The if Statement::
* The do...while Statement::
* The while Statement::
* The for Statement::
* The for...in Statement::
* The continue Statement::
* The break Statement::
* The return Statement::
* The with Statement::
* The switch Statement::
* Labeled Statements::
* The throw Statement::
* The try Statement::
@end menu
@node Block, Variable Statement, Statements, Statements
@subsubsection Block
@node Variable Statement, Empty Statement, Block, Statements
@subsubsection Variable Statement
@node Empty Statement, The if Statement, Variable Statement, Statements
@subsubsection Empty Statement
@node The if Statement, The do...while Statement, Empty Statement, Statements
@subsubsection The @code{if} Statement
@node The do...while Statement, The while Statement, The if Statement, Statements
@subsubsection The @code{do}@dots{}@code{while} Statement
@node The while Statement, The for Statement, The do...while Statement, Statements
@subsubsection The @code{while} Statement
@node The for Statement, The for...in Statement, The while Statement, Statements
@subsubsection The @code{for} Statement
@node The for...in Statement, The continue Statement, The for Statement, Statements
@subsubsection The @code{for}@dots{}@code{in} Statement
@node The continue Statement, The break Statement, The for...in Statement, Statements
@subsubsection The @code{continue} Statement
@node The break Statement, The return Statement, The continue Statement, Statements
@subsubsection The @code{break} Statement
@node The return Statement, The with Statement, The break Statement, Statements
@subsubsection The @code{return} Statement
@node The with Statement, The switch Statement, The return Statement, Statements
@subsubsection The @code{with} Statement
The syntax of the @code{with}-statement is:
@example
with (@var{expr}) @var{statement}
@end example
@c @cartouche
@example
with (Math)
@{
result = sin (PI);
result -= tan (45);
@}
@end example
@c @end cartouche
@node The switch Statement, Labeled Statements, The with Statement, Statements
@subsubsection The @code{switch} Statement
@node Labeled Statements, The throw Statement, The switch Statement, Statements
@subsubsection Labeled Statements
@node The throw Statement, The try Statement, Labeled Statements, Statements
@subsubsection The @code{throw} Statement
@node The try Statement, , The throw Statement, Statements
@subsubsection The @code{try} Statement
@node Expressions, , Statements, Language
@subsection Expressions
@menu
* Primary Expressions::
* Left-Hand-Side Expressions::
* Postfix Expressions::
* Unary Operators::
* Multiplicative Operators::
* Additive Operators::
* Bitwise Shift Operators::
* Relational Operators::
* Equality Operators::
* Binary Bitwise Operators::
* Binary Logical Operators::
* Conditional Operator::
* Assignment Operators::
* Comma Operator::
@end menu
@node Primary Expressions, Left-Hand-Side Expressions, Expressions, Expressions
@subsubsection Primary Expressions
@node Left-Hand-Side Expressions, Postfix Expressions, Primary Expressions, Expressions
@subsubsection Left-Hand-Side Expressions
@node Postfix Expressions, Unary Operators, Left-Hand-Side Expressions, Expressions
@subsubsection Postfix Expressions
@node Unary Operators, Multiplicative Operators, Postfix Expressions, Expressions
@subsubsection Unary Operators
@node Multiplicative Operators, Additive Operators, Unary Operators, Expressions
@subsubsection Multiplicative Operators
@node Additive Operators, Bitwise Shift Operators, Multiplicative Operators, Expressions
@subsubsection Additive Operators
@node Bitwise Shift Operators, Relational Operators, Additive Operators, Expressions
@subsubsection Bitwise Shift Operators
@node Relational Operators, Equality Operators, Bitwise Shift Operators, Expressions
@subsubsection Relational Operators
@node Equality Operators, Binary Bitwise Operators, Relational Operators, Expressions
@subsubsection Equality Operators
@node Binary Bitwise Operators, Binary Logical Operators, Equality Operators, Expressions
@subsubsection Binary Bitwise Operators
@node Binary Logical Operators, Conditional Operator, Binary Bitwise Operators, Expressions
@subsubsection Binary Logical Operators
@node Conditional Operator, Assignment Operators, Binary Logical Operators, Expressions
@subsubsection Conditional Operator
@node Assignment Operators, Comma Operator, Conditional Operator, Expressions
@subsubsection Assignment Operators
@node Comma Operator, , Assignment Operators, Expressions
@subsubsection Comma Operator
@c ----------------------------------------------------------------------
@node Global Methods and Properties, Native Objects, Language, NGS JavaScript Language
@section Global Methods and Properties
@table @strong
@item Standard
@value{ECMA}
@end table
@c --- Properties -------------------------------------------------------
@defcv Property Global NaN
The @emph{not a number} value.
@end defcv
@defcv Property Global Infinity
The @emph{positive infinity} value.
@end defcv
@c --- Methods ----------------------------------------------------------
@defun eval (any)
@end defun
@defun parseInt (string, radix)
@end defun
@defun parseFloat (string)
@end defun
@defun escape (string)
@end defun
@defun unescape (string)
@end defun
@defun isNaN (any)
@end defun
@defun isFinite (any)
@end defun
@defun debug (any)
@table @strong
@item Standard
@value{JSREF}
@end table
@end defun
@defun print (any[,@dots{}])
@table @strong
@item Standard
@value{JSREF} ???
@end table
@end defun
@defun error (message)
@table @strong
@item Standard
@value{JSREF} ???
@end table
@end defun
@defun float (any)
@table @strong
@item Standard
@value{NGS}
@end table
@end defun
@defun int (any)
@table @strong
@item Standard
@value{NGS}
@end table
@end defun
@defun isFloat (any)
@table @strong
@item Standard
@value{NGS}
@end table
@end defun
@defun isInt (any)
@table @strong
@item Standard
@value{NGS}
@end table
@end defun
@defun load (file@dots{})
@table @strong
@item Standard
@value{NGS}
@end table
@end defun
@defun loadClass (class_spec@dots{})
@table @strong
@item Standard
@value{NGS}
@end table
Extend interpreter by calling an initialization function from shared
library @var{class_spec}. The argument @var{class_spec} can be given in
the following formats:
@table @code
@item @var{library}:@var{function}
The argument @var{library} specifies the shared library from which
function @var{function} is called. The library specification can be
given in absolute or relative formats.
@item @var{library}
The argument @var{library} specifies both the shared library, and the
name of the entry function. The name of the entry function is the name
of the library, without the possible leading directory path and any
suffixes.
@end table
@c @cartouche
@example
loadClass ("libexts.so:init_all");
@result{} @var{call function @code{init_all} from library @file{libexts.so}}
loadClass ("/usr/local/lib/libexts.so:init_all");
@result{} @var{call function @code{init_all} from library @file{/usr/local/lib/libexts.so}}
loadClass ("/usr/local/lib/libdbexts.so");
@result{} @var{call function @code{dbexts} from library @file{/usr/local/lib/libexts.so}}
@end example
@c @end cartouche
The initialization function must be a void function that takes one
argument that is a pointer to the interpreter.
@c @cartouche
@example
void
entry (JSInterpPtr interp)
@{
@var{Initialize extensions using normal @file{js.h} and @file{jsint.h}}
@var{interfaces.}
@}
@end example
@c @end cartouche
@end defun
@defun callMethod (object, method, arguments)
@table @strong
@item Standard
@value{NGS}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -