man ngs-js (Commandes) - interpret, execute, and compile JavaScript files
NAME
js - interpret, execute, and compile JavaScript files
SYNOPSIS
js [-acfghlNStvV] [-d type] [-e code] [-O[level]] [-r option] [-s size] [-W option] file [argument]...
DESCRIPTION
The js program is the JavaScript interpreter command. It can be used to execute JavaScript and JavaScript byte-code files. The progam can also be used to compile JavaScript files into the byte-code files.
OPTIONS
- -a, --annotate-assembler
- Annotate the created assembler listing with the original JavaScript source code. The option can be used only with the --assembler option.
- -c, --compile
- Compile JavaScript files to byte-code. The generated byte-code is saved to file which name is created from the name of the input file by replacing the suffix .js with the suffix .jsc. The compilation can be controlled with options --debug, --optimize, and --compiler-option.
- -d type, --dispatch=type
- Use the byte-code instruction dispatch method type. The current implementation supports the following dispatch methods:
- switch-basic
- The basic switch-method using a big switch-case table to dispatch the instruction. This method is available only if the interpreter has been configured with the option --with-all-dispatchers.
- switch
- An optimized version of the switch-method. This method is supported on all environments.
- jumps
- The fastest dispatch method that uses the `computed goto' statement of the GNU C-compiler. This method is available if the interpreter has been compiled with the GNU C-compiler. The default dispatch method, for environments that has the GNU C-compiler, is jumps. For all other environments, the default method is switch.
- -e code, --eval=code
- Evaluate JavaScript code code.
- -f, --file
- Stop processing options and use the next argument as the name of the JavaScript (or byte-code) file. All the remaining arguments are passed to the interpreter through the ARGS array. The first item of the array will be the name of the script, i.e. the argument that follows the option --file.
- -g, --debug
- Make the compiler to generate debugging information to the generated byte-code files. This option can be used with the option --compile.
- -h, --help
- Print a short help message that describes the options that can be given to the js program.
- -l, --load
- Load multiple JavaScript and JavaScript byte-code files to the interpreter. Normally, the first non-option argument is evaluated and all remaining arguments are passed to the script as arguments. With the option --load, multiple files can be loaded the to the interpreter. The loading can be stopped with option --file that specifies the last file to load.
- -N, --no-compiler
- Do not define the compiler to the virtual machine. This option makes the interpreter smaller, but the interpreter can only execute pre-compiled byte-code files. The option disables the eval global method.
- -O [level], --optimize[=level]
- Set the compiler optimization level to level. The compiler has three different optimization levels:
- 0
- Do not optimize.
- 1
- Perform all cheap optimizations which do not required heavy assembler instruction analyzing.
- 2
- Perform all optimizations, supported by the compiler. The default optimization level is 1.
- -r option, --secure=option
- Turn on virtual machine security option option. The following security options are available:
- file
- Disable insecure methods from the buit-in File object.
- system
- Disable insecure methods from the buit-in System object.
- -s size, --stack-size=size
- Set the size of the virtual machine operand stack to size. The size of the virtual machine operand stack is set at the startup-time and it can't be enlarged dynamically at the runtime.
- -S, --assembler
- Compile JavaScript files to JavaScript assembler. The generated assembler listing is saved to file which name is created from the name of the input file by replacing the suffix .js with the suffix .jas. The compilation can be controlled with options --optimize, and --compiler-option.
- -t, --stacktrace
- Print a stack trace on error. When an error occurs during the evaluation of a script, the virtual machine will halt and the js program terminates. If the option --stacktrace was given to the interpreter, the virtual machine will print a stack trace that shows the call stack at the point of the error.
- -v, --verbose
- Increase the verbosity of the interpreter. The option can be given multiple times to increase the amount of messages the interpreter prints.
- -V, --version
- Print the version number of the js program.
- -W option, --compiler-option=option
- Set JavaScript compiler options according to the option specification option. The specification option can be given in two forms. In the normal form, the option specifies a compiler option that should be set on. If the specification @var{option} starts with the prefix `no-', the specified option will be turn off. The following option specifications are currently implemented:
- all
- match most of the compile time options
- pedantic
- match all compile time options. This option generates as much warnings as possible. It will also complain about some things that are allowed by the ECMAScript standard, but which are consired to show bad programming style, for example, missing semicolons.
- runtime
- match all runtime options
- shadow
- warn if a variable declaration shadows a parameter
- undefined
- runtime check for undefined global variables
- unused-argument
- warn about unused arguments
- unused-variable
- warn about unused local variables
- with-clobber
- warn if the with-lookup of a symbol is clobbered because the symbol is defined to be a local variable or a function argument
- missing-semicolon
- warn about missing semicolons that are fixed by the missing semicolon inserting during the compilation
- strict-ecma
- warn about things that are supported by this implementation, but are not allowed by the ECMAScript standard. These features are:
- - line terminators in string and regular expression constant
- deprecated
- warn if deprecated features has been used in the source code
- -x, --executable
- Add execute permissions to the generated byte-code files. This option is useful on Linux environments where JavaScript byte-code files can be executed natively with the `binfmt_js' module.
AUTHOR
Markku Rossi <mtr@ngs.fi>
NGS JavaScript WWW home page: <http://www.ngs.fi/js/>