This is js.info, produced by makeinfo version 4.8 from js.texi. INFO-DIR-SECTION NGS JavaScript Interpreter START-INFO-DIR-ENTRY * libjs: (js). The JavaScript interpreter library. * js: (js)The js Program. JavaScript interpreter. END-INFO-DIR-ENTRY This file documents NGS JavaScript interpreter 0.2.5 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. 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.  File: js.info, Node: Top, Next: Introduction, Prev: (dir), Up: (dir) NGS JavaScript Interpreter ************************** This file documents the NGS JavaScript interpreter. This edition documents version 0.2.5. * 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::  File: js.info, Node: Introduction, Next: NGS JavaScript Language, Prev: Top, Up: Top 1 Introduction ************** * overall * design goals * structure: virtual machine, JSC$, JS glue  File: js.info, Node: NGS JavaScript Language, Next: The js Program, Prev: Introduction, Up: Top 2 NGS JavaScript Language ************************* * Menu: * Language:: * Global Methods and Properties:: * Native Objects:: * Extensions::  File: js.info, Node: Language, Next: Global Methods and Properties, Prev: NGS JavaScript Language, Up: NGS JavaScript Language 2.1 Language ============ * Menu: * Lexical Conventions:: * Function Definition:: * Statements:: * Expressions::  File: js.info, Node: Lexical Conventions, Next: Function Definition, Prev: Language, Up: Language 2.1.1 Lexical Conventions ------------------------- * Menu: * White Space:: * Comments:: * Reserved Words:: * Identifiers:: * Punctuators:: * Literals:: * Automatic Semicolon Insertion::  File: js.info, Node: White Space, Next: Comments, Prev: Lexical Conventions, Up: Lexical Conventions 2.1.1.1 White Space ...................  File: js.info, Node: Comments, Next: Reserved Words, Prev: White Space, Up: Lexical Conventions 2.1.1.2 Comments ................  File: js.info, Node: Reserved Words, Next: Identifiers, Prev: Comments, Up: Lexical Conventions 2.1.1.3 Reserved Words ......................  File: js.info, Node: Identifiers, Next: Punctuators, Prev: Reserved Words, Up: Lexical Conventions 2.1.1.4 Identifiers ...................  File: js.info, Node: Punctuators, Next: Literals, Prev: Identifiers, Up: Lexical Conventions 2.1.1.5 Punctuators ...................  File: js.info, Node: Literals, Next: Automatic Semicolon Insertion, Prev: Punctuators, Up: Lexical Conventions 2.1.1.6 Literals ................  File: js.info, Node: Automatic Semicolon Insertion, Prev: Literals, Up: Lexical Conventions 2.1.1.7 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 ECMA-262 Version 2 draft 22-Apr-98 standard. Here is 's interpretation of the rules: Insert semicolons as you would do in the C language. Now, you can omit them: 1. before '`}'' character 2. from the end of the line 3. from the end of the file The automatic semicolon insertion sets some restrictions how you can insert whitespace to you code. You can't insert line breaks: 1. between LEFTHANDSIDEEXPRESSION and `++' or `--' operator 2. between `return' and the returned EXPRESSION  File: js.info, Node: Function Definition, Next: Statements, Prev: Lexical Conventions, Up: Language 2.1.2 Function Definition -------------------------  File: js.info, Node: Statements, Next: Expressions, Prev: Function Definition, Up: Language 2.1.3 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::  File: js.info, Node: Block, Next: Variable Statement, Prev: Statements, Up: Statements 2.1.3.1 Block .............  File: js.info, Node: Variable Statement, Next: Empty Statement, Prev: Block, Up: Statements 2.1.3.2 Variable Statement ..........................  File: js.info, Node: Empty Statement, Next: The if Statement, Prev: Variable Statement, Up: Statements 2.1.3.3 Empty Statement .......................  File: js.info, Node: The if Statement, Next: The do...while Statement, Prev: Empty Statement, Up: Statements 2.1.3.4 The `if' Statement ..........................  File: js.info, Node: The do...while Statement, Next: The while Statement, Prev: The if Statement, Up: Statements 2.1.3.5 The `do'...`while' Statement ....................................  File: js.info, Node: The while Statement, Next: The for Statement, Prev: The do...while Statement, Up: Statements 2.1.3.6 The `while' Statement .............................  File: js.info, Node: The for Statement, Next: The for...in Statement, Prev: The while Statement, Up: Statements 2.1.3.7 The `for' Statement ...........................  File: js.info, Node: The for...in Statement, Next: The continue Statement, Prev: The for Statement, Up: Statements 2.1.3.8 The `for'...`in' Statement ..................................  File: js.info, Node: The continue Statement, Next: The break Statement, Prev: The for...in Statement, Up: Statements 2.1.3.9 The `continue' Statement ................................  File: js.info, Node: The break Statement, Next: The return Statement, Prev: The continue Statement, Up: Statements 2.1.3.10 The `break' Statement ..............................  File: js.info, Node: The return Statement, Next: The with Statement, Prev: The break Statement, Up: Statements 2.1.3.11 The `return' Statement ...............................  File: js.info, Node: The with Statement, Next: The switch Statement, Prev: The return Statement, Up: Statements 2.1.3.12 The `with' Statement ............................. The syntax of the `with'-statement is: with (EXPR) STATEMENT with (Math) { result = sin (PI); result -= tan (45); }  File: js.info, Node: The switch Statement, Next: Labeled Statements, Prev: The with Statement, Up: Statements 2.1.3.13 The `switch' Statement ...............................  File: js.info, Node: Labeled Statements, Next: The throw Statement, Prev: The switch Statement, Up: Statements 2.1.3.14 Labeled Statements ...........................  File: js.info, Node: The throw Statement, Next: The try Statement, Prev: Labeled Statements, Up: Statements 2.1.3.15 The `throw' Statement ..............................  File: js.info, Node: The try Statement, Prev: The throw Statement, Up: Statements 2.1.3.16 The `try' Statement ............................  File: js.info, Node: Expressions, Prev: Statements, Up: Language 2.1.4 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::  File: js.info, Node: Primary Expressions, Next: Left-Hand-Side Expressions, Prev: Expressions, Up: Expressions 2.1.4.1 Primary Expressions ...........................  File: js.info, Node: Left-Hand-Side Expressions, Next: Postfix Expressions, Prev: Primary Expressions, Up: Expressions 2.1.4.2 Left-Hand-Side Expressions ..................................  File: js.info, Node: Postfix Expressions, Next: Unary Operators, Prev: Left-Hand-Side Expressions, Up: Expressions 2.1.4.3 Postfix Expressions ...........................  File: js.info, Node: Unary Operators, Next: Multiplicative Operators, Prev: Postfix Expressions, Up: Expressions 2.1.4.4 Unary Operators .......................  File: js.info, Node: Multiplicative Operators, Next: Additive Operators, Prev: Unary Operators, Up: Expressions 2.1.4.5 Multiplicative Operators ................................  File: js.info, Node: Additive Operators, Next: Bitwise Shift Operators, Prev: Multiplicative Operators, Up: Expressions 2.1.4.6 Additive Operators ..........................  File: js.info, Node: Bitwise Shift Operators, Next: Relational Operators, Prev: Additive Operators, Up: Expressions 2.1.4.7 Bitwise Shift Operators ...............................  File: js.info, Node: Relational Operators, Next: Equality Operators, Prev: Bitwise Shift Operators, Up: Expressions 2.1.4.8 Relational Operators ............................  File: js.info, Node: Equality Operators, Next: Binary Bitwise Operators, Prev: Relational Operators, Up: Expressions 2.1.4.9 Equality Operators ..........................  File: js.info, Node: Binary Bitwise Operators, Next: Binary Logical Operators, Prev: Equality Operators, Up: Expressions 2.1.4.10 Binary Bitwise Operators .................................  File: js.info, Node: Binary Logical Operators, Next: Conditional Operator, Prev: Binary Bitwise Operators, Up: Expressions 2.1.4.11 Binary Logical Operators .................................  File: js.info, Node: Conditional Operator, Next: Assignment Operators, Prev: Binary Logical Operators, Up: Expressions 2.1.4.12 Conditional Operator .............................  File: js.info, Node: Assignment Operators, Next: Comma Operator, Prev: Conditional Operator, Up: Expressions 2.1.4.13 Assignment Operators .............................  File: js.info, Node: Comma Operator, Prev: Assignment Operators, Up: Expressions 2.1.4.14 Comma Operator .......................  File: js.info, Node: Global Methods and Properties, Next: Native Objects, Prev: Language, Up: NGS JavaScript Language 2.2 Global Methods and Properties ================================= *Standard* ECMA-262 Version 2 draft 22-Apr-98 -- Property of Global: NaN The _not a number_ value. -- Property of Global: Infinity The _positive infinity_ value. -- Function: eval (any) -- Function: parseInt (string, radix) -- Function: parseFloat (string) -- Function: escape (string) -- Function: unescape (string) -- Function: isNaN (any) -- Function: isFinite (any) -- Function: debug (any) *Standard* Netscape JavaScript Reference 12-Dec-97 -- Function: print (any[,...]) *Standard* Netscape JavaScript Reference 12-Dec-97 ??? -- Function: error (message) *Standard* Netscape JavaScript Reference 12-Dec-97 ??? -- Function: float (any) *Standard* NGS JavaScript Interpreter 0.2.5 -- Function: int (any) *Standard* NGS JavaScript Interpreter 0.2.5 -- Function: isFloat (any) *Standard* NGS JavaScript Interpreter 0.2.5 -- Function: isInt (any) *Standard* NGS JavaScript Interpreter 0.2.5 -- Function: load (file...) *Standard* NGS JavaScript Interpreter 0.2.5 -- Function: loadClass (class_spec...) *Standard* NGS JavaScript Interpreter 0.2.5 Extend interpreter by calling an initialization function from shared library CLASS_SPEC. The argument CLASS_SPEC can be given in the following formats: `LIBRARY:FUNCTION' The argument LIBRARY specifies the shared library from which function FUNCTION is called. The library specification can be given in absolute or relative formats. `LIBRARY' The argument 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. loadClass ("libexts.so:init_all"); => CALL FUNCTION `INIT_ALL' FROM LIBRARY `LIBEXTS.SO' loadClass ("/usr/local/lib/libexts.so:init_all"); => CALL FUNCTION `INIT_ALL' FROM LIBRARY `/USR/LOCAL/LIB/LIBEXTS.SO' loadClass ("/usr/local/lib/libdbexts.so"); => CALL FUNCTION `DBEXTS' FROM LIBRARY `/USR/LOCAL/LIB/LIBEXTS.SO' The initialization function must be a void function that takes one argument that is a pointer to the interpreter. void entry (JSInterpPtr interp) { INITIALIZE EXTENSIONS USING NORMAL `JS.H' AND `JSINT.H' INTERFACES. } -- Function: callMethod (object, method, arguments) *Standard* NGS JavaScript Interpreter 0.2.5 Call method METHOD from object OBJECT with arguments ARGUMENTS. callMethod (System.stdout, "writeln", ["Hello, world!"]); -| Hello, world!  File: js.info, Node: Native Objects, Next: Extensions, Prev: Global Methods and Properties, Up: NGS JavaScript Language 2.3 Native Objects ================== * Menu: * Array:: * Boolean:: * Date:: * File:: * Directory:: * Function:: * Math:: * Number:: * Object:: * RegExp:: * String:: * System:: * VM::  File: js.info, Node: Array, Next: Boolean, Prev: Native Objects, Up: Native Objects 2.3.1 Array ----------- *Standard* ECMA-262 Version 2 draft 22-Apr-98 *Incompatibilities* * The `toSource()' method is missing. * The constructor doesn't set the [[Prototype]] and [[Class]] properties. -- Function: Array (count) -- Function: Array (item...) Do exactly the same as the expression `new Array()' called with the same arguments. -- Constructor: Array (count) -- Constructor: Array (item...) Create a new array object. The first form creates a new array which length is COUNT. All items are set to value `undefined'. The second form creates an array that contains the given items as its values. var a = new Array (5); a.length; => 5 a.toString (); => undefined,undefined,undefined,undefined,undefined a = new Array (1, 2, "hello"); a.length; => 3 a.toString (); => 1,2,hello -- Method on Array: concat (array[, ...]) Create a new array object from the items of the called array object and the argument arrays ARRAY, .... The contents of the argument arrays are not modified. var a = new Array (1, 2, 3); var b = a.concat (new Array (4, 5)); b.length; => 5; b.toString (); => 1,2,3,4,5 -- Method on Array: join ([glue]) Convert the array to a string. Individual items of the array are combined with the string GLUE. If the argument GLUE is omitted, string `","' is used. var a = new Array (1, 2, "three"); a.join (); => "1,2,three" a.join ("-"); => "1-2-three" -- Method on Array: pop () Remove the last item of the array. The method returns the item removed. If the array is empty, value `undefined' is returned. a = new Array (1, 2, 3); a.pop (); => 3 a.length; => 2 -- Method on Array: push (any...) Insert items to the end of the array. The method returns the last item pushed. a = new Array (1, 2); a.push (7); => 7 a.push (7, 8, 9); => 9 System.print (a.join (", "), "\n"); -| 1, 2, 7, 7, 8, 9 -- Method on Array: reverse () Reverse the array. a = new Array (1, 2, 3); a.reverse (); System.print (a.join (""), "\n"); -| 321 -- Method on Array: shift () Remove item from the beginning of the array. The method returns the item removed, or value `undefined' if the array was empty. a = new Array (1, 2, 3); a.shift (); => 1 -- Method on Array: slice (start[, end]) Return a new array containing items between START (inclusively) and END (exclusively) in the array. If the argument END is negative, it is counted from the end of the array. If the argument END is omitted, the method extract items from the position START to the end of the array. a = new Array (1, 2, 3, 4, 5); b = a.slice (1, 4); System.print (b.join (", "), "\n"); -| 2, 3, 4 b = a.slice (1, -2); System.print (b.join (", "), "\n"); -| 2, 3 b = a.slice (2); System.print (b.join (", "), "\n"); -| 3, 4, 5 -- Method on Array: splice (index, remove[, any...]) Modify array by removing old items and by inserting new ones. The argument INDEX specifies the index from which the array is modified. The argument REMOVE specifies how many old items are removed. If the argument REMOVE is 0, no old items are removed and at least one new item must have been given. After the items are removed, all remaining arguments are inserted after the position INDEX. var a = new Array (1, 2, 3); a.splice (1, 1); => 1, 3 a.splice (1, 0, "new item"); => 1, "new item", 2, 3 var a = new Array (1, 2, 3, 4); a.splice (1, 2, "new item"); => 1, "new item", 4 -- Method on Array: sort ([sort_function]) Sort the array to the order specified by the argument function SORT_FUNCTION. The comparison function SORT_FUNCTION takes two arguments and it must return one of the following codes: `-1' the first argument items is smaller than the second item (must come before the second item) `0' the items are equal `1' the first argument item is bigger than the second item (it must come after the second item) If the argument SORT_FUNCTION is omitted, the items are sorted to an alphabetical (lexicographical) order. a = new Array ("Jukka-Pekka", "Jukka", "Kari", "Markku"); a.sort (); System.print (a, "\n"); -| Jukka,Jukka-Pekka,Kari,Markku a = new Array (1, 2, 10, 20, 100, 200); a.sort (); System.stdout.writeln (a.toString ()); -| 1,10,100,2,20,200 The sort method is stable in that sense that, if the comparison function returns 0 for two items, their original order in the array is preserved. For example, if a list of person objects is sorted first by their names, and second by their ages, all persons with the same age will remain sorted in an alphabetical order. function by_age (a, b) { return a.age - b.age; } function by_name (a, b) { if (a.name < b.name) return -1; if (a.name > b.name) return 1; return 0; } function Person (name, age) { this.name = name; this.age = age; } a = new Array (new Person ("Smith", 30), new Person ("Jones", 31), new Person ("Bob", 30), new Person ("Chris", 29)); a.sort (by_name); a.sort (by_age); for (i in a) System.print (i.name, ", ", i.age, "\n"); -| Chris, 29 -| Bob, 30 -| Smith, 30 -| Jones, 31 -- Method on Array: toSource () -- Method on Array: toString () Convert the array to a string. The method converts each item of the array to string and combines them with the string `","'. var a = new Array (1, "foo", 2, new Array (7, 8)); a.toString (); => 1,foo,2,7,8 -- Method on Array: unshift (any...) Insert items ANY... to the beginning of the array. The method returns the new length of the array. a = new Array (1, 2, 3); System.print (a.unshift (7, 8, 9), "\n"); -| 6 -- Property of Array: length The length of the array. var a = new Array (1, 2); a.length; => 2 a.push (3, 4, 5); a.length; => 5  File: js.info, Node: Boolean, Next: Date, Prev: Array, Up: Native Objects 2.3.2 Boolean ------------- *Standard* ECMA-262 Version 2 draft 22-Apr-98 *Incompatibilities* * The constructor doesn't set the [[Prototype]] and [[Class]] properties. -- Function: Boolean () Return `false'. -- Function: Boolean (value) -- Constructor: Boolean () -- Constructor: Boolean (value) Create a new boolean object. If no arguments are given, the returned object will have value `false'. If the argument VALUE is given, the initial value of the object is determined by the type of the argument and its value. If the argument VALUE is `undefined', `null', `false', `""' (an empty string), or `0', the value of the object will be `false'. All other values for the argument VALUE will set the initial value of the object to `true'. -- Method on Boolean: toString () Return a string presentation of the boolean object. The method will return string `"true"' or `"false"' according to the value of the object. -- Method on Boolean: valueOf ()  File: js.info, Node: Date, Next: File, Prev: Boolean, Up: Native Objects 2.3.3 Date ---------- *Standard* ECMA-262 Version 2 draft 22-Apr-98 *Incompatibilities* XXX Check all methods and properties. -- Function: MakeTime (hour, min, sec, ms) -- Function: MakeDay (year, month, date) -- Function: MakeDate (day, time) -- Function: TimeClip (time) -- Function: Date ([a1[, a2[, a3[, a4[, a5[, a6[, a7]]]]]]]) When the `Date' constructor is called as a function, it ignores arguments A1...A7 and returns the result of expression: new Date ().toString() -- Constructor: Date () -- Constructor: Date ("MONTH DAY, YEAR HOURS:MINUTES:SECONDS") -- Constructor: Date (YR_NUM, MO_NUM, DAY_NUM) -- Constructor: Date (YR_NUM, MO_NUM, DAY_NUM, HR_NUM, MIN_NUM, SEC_NUM) -- Static Method on Date: UTC (YEAR, MONTH, DAY, HRS, MIN, SEC) -- Method on Date: format (format) -- Method on Date: formatGMT (format) -- Method on Date: getDate () -- Method on Date: getDay () -- Method on Date: getHours () -- Method on Date: getMinutes () -- Method on Date: getMonth () -- Method on Date: getSeconds () -- Method on Date: getTime () -- Method on Date: getTimezoneOffset () -- Method on Date: getYear () -- Method on Date: parse (string) -- Method on Date: setDate (day) -- Method on Date: setHours (hours) -- Method on Date: setMinutes (minutes) -- Method on Date: setMonths (months) -- Method on Date: setSeconds (seconds) -- Method on Date: setTime (time) -- Method on Date: setYear (year) -- Method on Date: toGMTString () -- Method on Date: toLocaleString ()  File: js.info, Node: File, Next: Directory, Prev: Date, Up: Native Objects 2.3.4 File ---------- *Standard* Netscape JavaScript Reference 12-Dec-97 *Incompatibilities* XXX Check all methods and properties. -- Constructor: File (path) -- Static Method on File: byteToString (byte) -- Static Method on File: chmod (path, mode) *Standard* NGS JavaScript Interpreter 0.2.5 Change permissions of file PATH to MODE. The modes are specifeid by or'ing the following values: `04000' set user ID on execution `02000' set group ID on execution `01000' sticky bit `00400' read by owner `00200' write by owner `00100' execute / search by owner `00040' read by group `00020' write by group `00010' execute / search by group `00004' read by others `00002' write by others `00001' execute / search by others -- Static Method on File: lstat (path) *Standard* NGS JavaScript Interpreter 0.2.5 -- Static Method on File: remove (path) *Standard* NGS JavaScript Interpreter 0.2.5 -- Static Method on File: rename (path) *Standard* NGS JavaScript Interpreter 0.2.5 -- Static Method on File: stat (path) *Standard* NGS JavaScript Interpreter 0.2.5 Return statistics about the file FILE. The method returns a 13 element array containing the statistics, or `false' if the file couldn't be inspected. The returned array contains the following items: `dev' Device that contains a directory entry for this file. `ino' Index of this file on its device. A file is uniquely identified by specifying its `dev' and `ino'. `mode' The mode of the file. `nlink' The number of hard links to the file. `uid' The ID of the file owner. `gid' The ID of the file group. `rdev' The ID of the device. `size' The size of the file. `atime' The time when the data was last accessed. `mtime' The time when the data was last modified. `ctime' The time when the file status was last changed. `blksize' Preferred blocksize for file system I/O. `blocks' The number of blocks the file actually uses. fields = new Array ("dev", "ino", "mode", "nlink", "uid", "gid", "rdev", "size", "atime", "mtime", "ctime", "blksize", "blocks"); var a = File.stat ("js"); if (a) { var i; for (i = 0; i < a.length; i++) System.print (fields[i], "=", a[i], " "); System.print ("\n"); } -| dev=655368 ino=370741 mode=33261 nlink=1 uid=201 gid=200 -| rdev=2979328 size=731370 atime=893159080 mtime=893158537 -| ctime=893158537 blksize=4096 blocks=1432 -- Static Method on File: stringToByte (string) -- Method on File: open (mode) The argument MODE must have one of the following values: `r'[`b'] `w'[`b'] `a'[`b'] `r+'[`b'] `w+'[`b'] `a+'[`b'] -- Method on File: close () -- Method on File: setPosition (position[, whence]) -- Method on File: getPosition () -- Method on File: eof () -- Method on File: read (size) -- Method on File: readln () -- Method on File: readByte () -- Method on File: toString () -- Method on File: write (string) -- Method on File: writeln (string) -- Method on File: writeByte (byte) -- Method on File: ungetByte (byte) *Standard* NGS JavaScript Interpreter 0.2.5 -- Method on File: flush () -- Method on File: getLength () -- Method on File: exists () -- Method on File: error () -- Method on File: clearError () -- Property of File: autoFlush *Standard* NGS JavaScript Interpreter 0.2.5 Flag that specifies whether the stream should automatically flush its buffers after a write. -- Property of File: bufferSize *Standard* NGS JavaScript Interpreter 0.2.5 The I/O buffer size of the stream. The buffer size can be changed at the runtime.  File: js.info, Node: Directory, Next: Function, Prev: File, Up: Native Objects 2.3.5 Directory --------------- *Standard* NGS JavaScript Interpreter 0.2.5 -- Constructor: Directory (path) -- Method on Directory: close () -- Method on Directory: open () -- Method on Directory: read () -- Method on Directory: rewind () -- Method on Directory: seek (pos) -- Method on Directory: tell ()  File: js.info, Node: Function, Next: Math, Prev: Directory, Up: Native Objects 2.3.6 Function --------------  File: js.info, Node: Math, Next: Number, Prev: Function, Up: Native Objects 2.3.7 Math ---------- *Standard* ECMA-262 Version 2 draft 22-Apr-98 -- Static Method on Math: abs (X) -- Static Method on Math: acos (X) -- Static Method on Math: asin (X) -- Static Method on Math: atan (X) -- Static Method on Math: atan2 (Y, X) -- Static Method on Math: ceil (X) -- Static Method on Math: cos (X) -- Static Method on Math: exp (X) -- Static Method on Math: floor (X) -- Static Method on Math: log (X) -- Static Method on Math: max (X, Y) -- Static Method on Math: min (X, Y) -- Static Method on Math: pow (X, Y) -- Static Method on Math: random () -- Static Method on Math: round (X) -- Static Method on Math: seed (X) *Standard* NGS JavaScript Interpreter 0.2.5 -- Static Method on Math: sin (X) -- Static Method on Math: sqrt (X) -- Static Method on Math: tan (X) -- Static Property of Math: E -- Static Property of Math: LN10 -- Static Property of Math: LN2 -- Static Property of Math: LOG10E -- Static Property of Math: LOG2E -- Static Property of Math: PI -- Static Property of Math: SQRT1_2 -- Static Property of Math: SQRT2  File: js.info, Node: Number, Next: Object, Prev: Math, Up: Native Objects 2.3.8 Number ------------ *Standard* ECMA-262 Version 2 draft 22-Apr-98 -- Function: Number() Return value `0'. -- Function: Number (value) -- Constructor: Number () -- Constructor: Number (VALUE) Create a new number object. If no argument is given, the constructor returns value `+0'. If the argument VALUE is given, the constructor returns `ToNumber(VALUE)'. new Number (); => 0 new Number (3.1415); => 3.1415 new Number (true); => 1 -- Method on Number: toString ([RADIX]) Convert the number to its textual presentation. If the argument RADIX is given, it specifies the radix to which the number is formatted. If the argument RADIX is not given, it defaults to `10'. System.stdout.writeln ((193).toString ()); -| 193 System.stdout.writeln ((193).toString (8)); -| 301 System.stdout.writeln ((193).toString (16)); -| c1 System.stdout.writeln ((193).toString (2)); -| 11000001 -- Method on Number: valueOf () Return the value of the number object. -- Static Property of Number: MAX_VALUE -- Static Property of Number: MIN_VALUE -- Static Property of Number: NaN -- Static Property of Number: NEGATIVE_INFINITY -- Static Property of Number: POSITIVE_INFINITY  File: js.info, Node: Object, Next: RegExp, Prev: Number, Up: Native Objects 2.3.9 Object ------------ *Standard* ECMA-262 Version 2 draft 22-Apr-98 *Incompatibilities* * The `toString()' and `toSource()' methods are missing. * The constructor doesn't set the [[Prototype]] and [[Class]] properties. -- Function: Object ([VALUE]) -- Constructor: Object ([VALUE]) Create a new object. var o = new Object (); -- Method on Object: toString () -- Method on Object: toSource () -- Method on Object: valueOf ()  File: js.info, Node: RegExp, Next: String, Prev: Object, Up: Native Objects 2.3.10 RegExp ------------- *Standard* ECMA-262 Version 2 draft 22-Apr-98 *Incompatibilities* * The regular expression engine - taken from the GNU Emacs - might not support all features that are required. * XXX Check all methods and properties. -- Constructor: RegExp (pattern[, flags]) Create a new regular expression from string PATTERN. The optional argument string FLAGS can contain the following options: `i' Ignore case; the matching is case-insensitive. `g' Global search. This allows you to iterate over all matches of the expression by executing the `exec' method multiple times against the string. -- Method on RegExp: compile (PATTERN[, FLAGS]) Create a new regular expression from string PATTERN using optional options FLAGS. The method can be used to change the regular expression pattern or its flags in the regular expression object. The method returns an error if the string PATTERN do not specify a well-formed regular expression. *Note!* All regular expressions are always compiled in this implementation. This holds also for the expressions, created with the `RegExp()' constructor. var re = new RegExp ("ab*"); re.compile ("ab*", "i"); -- Method on RegExp: exec ([string]) Match the expression against the string STRING. If the argument STRING is omitted, the regular expression is matched against the `RegExp.input' string. The method returns an array that holds the matched portions of the expression. var re = new RegExp ("d(b+)(d)", "ig"); var a = re.exec ("cdbBdbsbz"); a.toString (); => "dbBd,bB,d" In the previous example, the result array `a' has the following items: `dbBd' The substring that matched the regular expression. This string can also be retrieved as `RegExp.lastMatch'. `bB' The matched substring for the first parenthesized subexpression `(b+)'. This match can also be found as `RegExp.$1'. `d' The matched substring for the second parentsized subexpression `(d)'. This match can also be found as `RegExp.$2'. The option `g' of the regular expression can be used to iterate over multiple matches of the expression on at a time. For example, the following code fragment searches for the expression `a(b*)' from the string `str'. In the inial state - when the expression is create with the constructor - the object's `lastIndex' property is set to 0. When the expression is matched against the string, the `lastIndex' property is updated to point to the next index from which the matching should be continued. Therefore, the following example iterates over all matches in the string `str'. var re = new RegExp ("a(b*)", "g"); var str = "abbcdefabh"; while (a = re.exec (str)) System.print ("Found ", a, ". Next match starts at ", re.lastIndex, ".\n"); -| Found abb. Next match starts at 3. -| Found ab. Next match starts at 9. The property `REGEXP.lastIndex' can also be set explicitly to start the matching from a pre-defined position. -- Method on RegExp: test ([string]) Test whether the regular expression matches for the string STRING. If the argument STRING is omitted, the regular expression is tested against the `RegExp.input' string. var re = new RegExp ("fo*bar"); re.test ("fbar"); => true re.test ("fooBar"); => false re = new RegExp ("fo*bar", "i"); re.test ("FOObAR"); => true RegExp.input = "#include "; re = new RegExp ("^#"); re.test (); => true -- Static Property of RegExp: $1 -- Static Property of RegExp: $2 -- Static Property of RegExp: $3 -- Static Property of RegExp: $4 -- Static Property of RegExp: $5 -- Static Property of RegExp: $6 -- Static Property of RegExp: $7 -- Static Property of RegExp: $8 -- Static Property of RegExp: $9 The matching substring for the n:th parenthesized subexpression. If the latest regular expression didn't have that many parenthesized subexpressions, the property has value `undefined'. -- Static Property of RegExp: $_ -- Static Property of RegExp: input The string against which the expression was tested. The `input' property is also used, if no string argument was given for the `test()' or `exec()' methods. var str = file.readln (); re.test (str); RegExp.input; => THE STRING RETURNED BY THE `FILE.READLN()' METHOD. -- Static Property of RegExp: lastMatch The substring that matched the whole expression in the last regular expression matching. -- Static Property of RegExp: lastParen The last parenthesized subexpression of the last regular expression matching. -- Static Property of RegExp: leftContext The substring from the beginning of the input string to the beginning of the matching substring of the last regular expression. var re = new RegExp ("foo"); var str = "garbage foo tail garbage"; re.exec (str); RegExp.leftContext; => "garbage " -- Static Property of RegExp: multiline -- Static Property of RegExp: rightContext The substring from the end of the matching substring to the end the input string. var re = new RegExp ("foo"); var str = "garbage foo tail garbage"; re.exec (str); RegExp.rightContext; => " tail garbage" -- Property of RegExp: global Flag that tells if the option `g' was given for the constructor or for the `compile' method. -- Property of RegExp: ignoreCase Flat that tells if the option `i' was given for the construtor or for the `compile' method. -- Property of RegExp: lastIndex The index from which the matching is continued with the global (`g') expressions. -- Property of RegExp: source The source string from which the regular expression object was created.  File: js.info, Node: String, Next: System, Prev: RegExp, Up: Native Objects 2.3.11 String ------------- *Standard* ECMA-262 Version 2 draft 22-Apr-98 *Incompatibilities* * The constructor doesn't set the [[Prototype]] and [[Class]] properties. -- Constructor: String (string) Create a new string object and set its data to STRING. var str = new String ("Hello, world"); => "Hello, world!" -- Static Method on String: fromCharCode (code...) Create a new string object from the character codes CODE.... var str = String.fromCharCode (72, 101, 108, 108, 111, 33); => "Hello!" -- Static Method on String: pack (format, arg[, ...]) *Standard* NGS JavaScript Interpreter 0.2.5 Create a new string by packing values ARG... to a string according to the format string FORMAT. The format is a sequence of characters that specify the type of values as follows: `C' an unsigned char value `n' a short in "network" (big-endian) order `N' a long in "network" (big-endian) order `d' a double-precision float in the native format -- Method on String: append (string) *Standard* NGS JavaScript Interpreter 0.2.5 Append string STRING to the end of the string object. The string object must be a dynamic string, not a constant string literal. var str = new String (""); str.append ("foo"); str.append ("-"); str.append ("bar"); => "foo-bar" -- Method on String: charAt (position) Create a new string that constains the character from position POSITION of the the string object. "foobar".charAt (3); => "b" -- Method on String: charCodeAt (position) Return the code of the character at position POSITION in the string object. "foobar".charCodeAt (3); => 98 -- Method on String: concat (STRING[, ...]) Create a new string by appending the argument strings STRING, ... to the end of the string object. "foo".concat ("bar"); => "foobar" -- Method on String: crc32 () *Standard* NGS JavaScript Interpreter 0.2.5 Count a 32-bit CRC of the string. var str = "Hello, world!"; System.print ("CRC32 of \"", str, "\" is ", str.crc32 ().toString (16), ".\n"); -| CRC32 of "Hello, world!" is e4928064. -- Method on String: indexOf (string[, start_index]) Return the index of the first substring of STRING within the string object, or -1 if the string didn't contain the substring. The optional argument START_INDEX can be used to specify the index from which the searching is started. var str = "foobar foo bar foo"; str.indexOf ("foo"); => 0 str.indexOf (" foo"); => 6 str.indexOf ("foo", 1); => 7 str.indexOf ("Foo"); => -1 -- Method on String: lastIndexOf (string[, start_index]) Return the the index of the last substring of STRING within the string object, or -1 if the string didn't contain the substring. The optional argument START_INDEX can be used to specify the index from which the searching is started. var str = "foobar foo bar foo"; str.lastIndexOf ("foo"); => 15 str.lastIndexOf ("bar"); => 11 str.lastIndexOf ("foo", 14); => 7 str.lastIndexOf ("Foo"); => -1 -- Method on String: match (regexp) -- Method on String: replace (regexp, substitution) -- Method on String: search (regexp) -- Method on String: slice (start[, end]) -- Method on String: split (separtor[, limit]) -- Method on String: substr (start[, length]) -- Method on String: substring (start[, end]) -- Method on String: toLowerCase () Create a new string which contents is the data of the string object, converted to the lower case. "FoObAr".toLowerCase (); => "foobar" -- Method on String: toUpperCase () Create a new string which contents is the data of the string object, converted to the upper case. "FoObAr".toUpperCase (); => "FOOBAR" -- Method on String: unpack (format) *Standard* NGS JavaScript Interpreter 0.2.5 -- Property of String: length The length of the string. "foobar".length; => 6 var str = new String ("foo"); str.append ("bar"); str.length; => 6  File: js.info, Node: System, Next: VM, Prev: String, Up: Native Objects 2.3.12 System ------------- *Standard* NGS JavaScript Interpreter 0.2.5 -- Static Method on System: chdir (directory) Change the process' current working directory to DIRECTORY. The function returns a boolean success status. -- Static Method on System: error (any[, ...]) Convert arguments ANY... to string and print the resulting string to the standard error stream of the system. -- Static Method on System: exit (code) Terminate the program execution and return the value CODE to the operating system as the return value of the running program. Effectively the method performs C-code `exit (CODE)'. -- Static Method on System: getcwd () Get the current working directory of the process. The function returns a strings presenting the directory or `false' if errors were encountered. -- Static Method on System: getenv (variable) Return the value of the environment variable VARIABLE. The method returns the value as a string or `undefined' if the variable was not defined in the environment. -- Static Method on System: popen (command, mode) -- Static Method on System: print (any[, ...]) Convert arguments ANY... to string and print the resulting string to the standard output stream of the system. -- Static Method on System: sleep (seconds) Stop the interpreter for SECONDS seconds. -- Static Method on System: strerror (errno) Return a string that describes the system error code ERRNO. -- Static Method on System: system (command) -- Static Method on System: usleep (micro_seconds) Stop the interpreter for MICRO_SECONDS micro seconds. -- Static Property of System: bits Return a value that describes the "bitness" of the underlying system. Possible values might be `16', `32', `64', or even `128'. Normally this is the size of a host system pointer in bits. -- Static Property of System: canonicalHost The canonical host name of the system where the interpreter was compiled. System.stdout.writeln (System.canonicalHost); -| powerpc-ibm-aix4.2.1.0 -- Static Property of System: canonicalHostCPU The CPU part of the canonical host name. System.stdout.writeln (System.canonicalHostCPU); -| powerpc -- Static Property of System: canonicalHostVendor The Vendor part of the canonical host name. System.stdout.writeln (System.canonicalHostVendor); -| ibm -- Static Property of System: canonicalHostOS The OS part of the canonical host name. System.stdout.writeln (System.canonicalHostOS); -| aix4.2.1.0 -- Static Property of System: errno The system's error number. The error number can be converted to a string with the `strerror()' method of the System object. var fp = new File ("output.txt"); if (!fp.open ("w")) System.error ("couldn't create output file `", fp, "': ", System.strerror (System.errno), "\n"); -| couldn't create output file `output.txt': Permission denied -- Static Property of System: lineBreakSequence The line break sequence that is used in the underlying system. For example, the outputs from the following lines are identical: System.stdout.writeln ("Hello!"); -| Hello! System.stdout.write ("Hello!" + System.lineBreakSequence); -| Hello! -- Static Property of System: stderr The system's standard error stream. This is a normal JavaScript file and all methods of the File object can be called for it. System.stderr.writeln ("panic: must exit"); System.exit (1); -| panic: must exit -- Static Property of System: stdin The system's standard input stream. -- Static Property of System: stdout The system's standard output stream.  File: js.info, Node: VM, Prev: System, Up: Native Objects 2.3.13 VM --------- *Standard* NGS JavaScript Interpreter 0.2.5 -- Static Method on VM: garbageCollect () Perform a garbage collection for the virtual machine heap. Normally, the garbage collection is triggered automatically, but the `garbageCollect()' method can be used to trigger the collection explicitly. -- Static Method on VM: stackTrace ([LIMIT]) Print the contents of the virtual machine stack. Optional argument LIMIT specifies how many stack frames are printed. If no arguments are given, the whole virtual machine stack is printed. function recursive (n) { if (n > 5) VM.stackTrace (); else recursive (n + 1); } recursive (0); -|VM: stacktrace: stacksize=2048, used=78 -|#0 recursive(): builtin 0 -|#1 recursive(): null 1 6 -|#2 recursive(): null 1 5 -|#3 recursive(): null 1 4 -|#4 recursive(): null 1 3 -|#5 recursive(): null 1 2 -|#6 recursive(): null 1 1 -|#7 .global(): null 1 0 -- Static Property of VM: dispatchMethod The name of the dispatch method, currently used in the virtual machine. The method returns a string that describes the method. The possible return values are `switch-basic', `switch', and `jumps'. -- Static Property of VM: gcCount How many times the garbage collection has been performed for the heap. -- Static Property of VM: gcTrigger The garbage collection trigger. When the virtual machine heap has allocated more than `gcTrigger' number of bytes of memory, the virtual machine will perform a garbage collection. -- Static Property of VM: heapAllocated The number of bytes of memory the system has allocated from the heap. -- Static Property of VM: heapFree The number of bytes of memory the heap freelist contains. -- Static Property of VM: heapSize The size of the heap in bytes. -- Static Property of VM: numConstants The number of constants defined in the virtual machine. -- Static Property of VM: numGlobals The number of global symbols defined in the virtual machine. This value equals to the number of global variables and functions, defined in the system. -- Static Property of VM: stackSize The size of the virtual machine stack. -- Static Property of VM: stacktraceOnError A boolean flag that tells whether the virtual machine stack trace is printed if an error occurs in the program execution. -- Static Property of VM: verbose The verbosity level of the virtual machine. -- Static Property of VM: verboseStacktrace A boolean flag that tells whether the virtual machine prints the normal or verbose stacktrace. -- Static Property of VM: version The version string of the interpreter virtual machine. -- Static Property of VM: versionMajor The major version number of the virtual machine. -- Static Property of VM: versionMinor The minor version number of the virtual machine. -- Static Property of VM: versionPatch The patch level number of the virtual machine. -- Static Property of VM: warnUndef A boolean flag that tells whether the virtual machine should print a warning message if an undefined variable is used.  File: js.info, Node: Extensions, Prev: Native Objects, Up: NGS JavaScript Language 2.4 Extensions ============== * Menu: * Curses:: * JS:: * MD5::  File: js.info, Node: Curses, Next: JS, Prev: Extensions, Up: Extensions 2.4.1 Curses ------------  File: js.info, Node: JS, Next: MD5, Prev: Curses, Up: Extensions 2.4.2 JS -------- -- Constructor: JS () -- Method on JS: compile (file, asm_file, bc_file) -- Method on JS: eval (string) -- Method on JS: evalFile (filename) -- Method on JS: evalJavaScriptFile (filename) -- Method on JS: executeByteCodeFile (filename) -- Method on JS: getVar (name) -- Method on JS: setVar (name, value) -- Property of JS: errorMessage  File: js.info, Node: MD5, Prev: JS, Up: Extensions 2.4.3 MD5 --------- -- Constructor: MD5 () Create a new MD5 message digest object. var md5 = new MD5 (); -- Method on MD5: final () Return the MD5 value of the data, set to the object with the `update()' method. The method returns a 32 bytes long string that holds the MD5 value as a hexadecimal number. function print_md5 (str) { var md5 = new MD5 (); md5.update (str); System.print ("MD5 of \"", str, "\" is ", md5.final (), ".\n"); } print_md5 ("Hello, world!"); -| MD5 of "Hello, world!" is 6CD3556DEB0DA54BCA060B4C39479839. -- Method on MD5: finalBinary () Return the MD5 value of the data. The method returns a 128 bits long MD5 value. -- Method on MD5: init () Initalize the object to the initial state. The method can be used to reset the object after some data has been set to it with the `update()' method. -- Method on MD5: update (str) Append data to the object. The method can be called multiple times, so that the MD5 message digest can be counted one block at a time. function count_md5_for_file (stream) { var md5 = new MD5 (); while (!stream.eof ()) { var data = stream.read (1024); md5.update (data); } return md5.final (); }  File: js.info, Node: The js Program, Next: The jsas Program, Prev: NGS JavaScript Language, Up: Top 3 The `js' Program ****************** 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. * Menu: * Invoking The js Program:: * Evaluating and Executing Code:: * Compiling JavaScript Code::  File: js.info, Node: Invoking The js Program, Next: Evaluating and Executing Code, Prev: The js Program, Up: The js Program 3.1 Invoking The `js' Program ============================= The `js' program is invoked as: `js' OPTION... FILE [ARGUMENT...] The `js' program processes the command line options and when the first non-option argument, or the option `--file', is encountered, it is assumed to contain JavaScript or byte-code that should be evaluated. The interpreter will pass all remaining arguments to the script throught the `ARGS' array. The items in the array are strings containing the arguments ARGUMENT.... The first item of the array is always the name of the script FILE. The options can be one or more of the following command line 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 compiler 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. $ js --eval='System.print ("Hello, world!\n");' -| Hello, world! `-E' `--events' Print the interpreter events to the standard error. $ js -E -c test.js [js: garbage collect] [js: garbage collect] [js: garbage collect] [js: garbage collect] `-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'. $ cat hello.js -| var i; -| for (i = 0; i < ARGS.length; i++) -| System.print (i, ": ", ARGS[i], "\n"); $ js --file hello.js a b c d -| 0: hello.js -| 1: a -| 2: b -| 3: c -| 4: d The option can also be used with the option `--load' to indicate the last file to load. Also in that case, the remaining arguments will be passed to the script through the `ARGS' array. `-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. For example, if we have files `a.js': function do_a () { System.print ("do_a()\n"); } `b.js': function do_b () { System.print ("do_b()\n"); } and `main.js': do_a (); do_b (); the whole application can be run as: $ js --load a.js b.js --file main.js ARGUMENTS... -| do_a() -| do_b() `-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. The following listing showns an program that raises an error at the specified recursion level. function recursive (level) { if (level <= 0) error ("recursion limit exceeded"); else recursive (level - 1); } recursive (5); If the program is executed without the `--stacktrace' option, the following result is shown: $ js hello.js js: evaluation of file `hello.js' failed: hello.js:6: recursion limit exceeded With the `--stacktrace' option, the `js' program will print the following error message: $ js --stacktrace hello.js -| VM: error: hello.js:6: recursion limit exceeded -| VM: stacktrace: stacksize=2048, used=44 -| #0 recursive(): null 1 "recursion limit exceeded" -| #1 recursive(): null 1 0 -| #2 recursive(): null 1 1 -| #3 recursive(): null 1 2 -| #4 recursive(): null 1 3 -| #5 recursive(): null 1 4 -| #6 .global(): null 1 5 -| js: evaluation of file `hello.js' failed: -| hello.js:6: recursion limit exceeded `-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 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 constants `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. $ cat hello.js -| System.stdout.writeln ("Hello, world!"); $ js -cx hello.js $ ./hello.jsc -| Hello, world!  File: js.info, Node: Evaluating and Executing Code, Next: Compiling JavaScript Code, Prev: Invoking The js Program, Up: The js Program 3.2 Evaluating and Executing Code =================================  File: js.info, Node: Compiling JavaScript Code, Prev: Evaluating and Executing Code, Up: The js Program 3.3 Compiling JavaScript Code ============================= The compilation of JavaScript code is carried out with the following command: `js' [OPTIONS] `-c' FILE... where FILE is a JavaScript source file to compile and OPTIONS specify additional compiler options. In the simplest form, the compilation goes as follows: $ js -c hello.js This example compiles file `hello.js' to byte-code file `hello.jsc' with the default compiler options. * Menu: * Warning Messages:: * Optimization:: * Debugging Information:: * Assembler Listings::  File: js.info, Node: Warning Messages, Next: Optimization, Prev: Compiling JavaScript Code, Up: Compiling JavaScript Code 3.3.1 Warning Messages ---------------------- It is nice to get as many error messages as possible at the compilation time. However, sometimes some error messages are false and it is annoying to see them every time you compile your project. The option `--compiler-option' can be used to adjust the level of warning messages the compiler generates. Normally we want to get all possible compiler time warnings. They can be enable with the `-Wall' option. To set the warnings individually, the following options can be given for the `--compiler-option' option. The option names can be prefixed with string `no-' to turn them off instead of setting them. For example, let's assume that we want to get as much warnings as possible, but we do not care about unused function arguments: $ js -Wall -Wno-unused-arguments -c hello.js In this example, we turn on all warnings `-Wall', but we turn off warnings about unused arguments `-Wno-unused-arguments'. The `js' program knows the following warning options: `shadow' Warn if a variable declaration shadows a parameter. For example, when compiling file `test.js' containing code: function foo (a, b) { var a = 1; return a + b; } the following warning is generated: $ js -Wshadow -c test.js -| test.js:3: warning: declaration of `a' shadows a parameter `unused-argument' Warn if an argument is not used in the function body. For example, when compiling file `test.js' containing code: function foo (a, b) { return a + 5; } the following warning is generated: $ js -Wunused-argument -c test.js -| test.js:1: warning: unused argument `b' `unused-variable' Warn if a local variable is not used in the function body. For example, when compiling file `test.js' containing code: function foo (a, b) { var c; return a + b; } the following warning is generated: $ js -Wunused-variable -c test.js -| test.js:3: warning: unused variable `c' `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. For example, when compiling file `test.js' containing code: function foo (PI) { with (Math) System.print ("PI=", PI, "\n"); } the following warning is generated: $ js -Wwith-clobber -c test.js -| test.js:4: warning: the with-lookup of symbol `PI' is -| clobbered by the argument definition `missing-semicolon' Warn if a semicolon is missing from the input. The missing semicolons are inserted during the parsing by the automatic semicolon inserting. However, since the missing semicolons show bad programming style, this option will warn about them. For example, when compiling file `test.js' containing code: function foo () { return 1 } foo () the following warnings are generated: $ js -Wmissing-semicolon -c test.js test.js:3: warning: missing semicolon test.js:6: warning: missing semicolon `strict-ecma' warn about things that are supported by this implementation, but are not allowed by the ECMAScript standard. For example, when compiling file `test.js' containing code: function foo () { System.stdout.writeln ("Hello, world! "); } the following warning is generated: $ js -Wstrict-ecma -c test.js test.js:3: warning: ECMAScript don't allow line terminators in string constants `deprecated' warn if deprecated features has been used in the source code. For example, when compiling file `test.js' containing code: function foo () { for (var i in arguments) System.stdout.writeln (i); } the following warning is generated: $ js -Wdeprecated -c test.js test.js:1: warning: the `arguments' property of Function instance is deprecated Besides the compiler time checks, the virtual machine can also perform some checks at the runtime. These checks can be set and unset with the `-Wruntime' option. The following runtime warnings are supported: `undefined' Warn if the value of an undefined global variable is used. For example, when running file `test.js' containing code: foo = an_undefined_variable; the following warning is generated: $ js test.js -| VM: warning: using undefined global `an_undefined_variable'  File: js.info, Node: Optimization, Next: Debugging Information, Prev: Warning Messages, Up: Compiling JavaScript Code 3.3.2 Optimization ------------------  File: js.info, Node: Debugging Information, Next: Assembler Listings, Prev: Optimization, Up: Compiling JavaScript Code 3.3.3 Debugging Information --------------------------- As a default, the JavaScript compiler do not include symbolic debugging information to the generated byte-code files. The debugging information can be generated by giving the compiler `-g' option. The debugging information is also generated for the internal byte-code files that are created when the interpreter evaluates plain JavaScript source code. In the current implementation, the debugging information contains only the names of the source files, and mappings from the virtual machine program counter offsets to the source file locations. In the future, it will contain information about local variables and function arguments, so that the symbolic debugger can print their values. The presence of the debugging information shows in the error messages the interpreter shows. For example, let's consider the following JavaScript source code file `test.js': function foo (a) { a += 1; if (a > 50) error ("a overflow"); return 1; } foo (50); When this file is compiled to the byte-code without debugging information, the following error message is raised: $ js -c test.js $ js test.jsc -| js: evaluation of file `test.jsc' failed: -| a overflow If we recompile the file with the debugging information, we will get a more precise error message from the interpreter: $ js -g -c test.js $ js test.jsc -| js: evaluation of file `test.js' failed: -| test.js:5: a overflow Now we see the exact source code location where the error occurred. The debugging information can be removed from the byte-code files after the compilation with the `jsdas' program. $ jsdas --strip test.jsc test.jsc: jsdas: removing section 3 $ js test.jsc js: evaluation of file `test.jsc' failed: a overflow  File: js.info, Node: Assembler Listings, Prev: Debugging Information, Up: Compiling JavaScript Code 3.3.4 Assembler Listings ------------------------ The JavaScript compiler can generate assembler listings from the JavaScript source files. The assembler listings are generated just before the resulting byte-code data would be generated. So the resulting assembler listing is exactly the same that will be in the resulting byte-code data. The assembler listing is generated with the `--assembler' option. For example, if we have a source file `hello.js' with the following contents: function hello () { System.stdout.writeln ("Hello, world!"); return true; } hello (); it can be compiled to assembler with command $ js -S hello.js The command will save the assembler listing in file `hello.jas': hello: load_arg 1 add_2_i min_args 2 const "Hello, world!" const_i1 load_global System load_property stdout call_method writeln pop_n 4 const_true return .global: const_i0 const_null jsr hello apop 2 The option `--annotate-assembler' can be used with the `--assembler' option. It mixes the original source code to the generated assembler listing. In this format, it is easy to see how different JavaScript constructs are compiled in the assembler. Our example file can be compiled to the annotated assembler with the following command: $ js -a -S hello.js The result listing is saved to file `hello.jas': ; -*- asm -*- ; function hello () hello: ; { load_arg 1 add_2_i min_args 2 ; System.stdout.writeln ("Hello, world!"); const "Hello, world!" const_i1 load_global System load_property stdout call_method writeln pop_n 4 ; return true; const_true return ; } ; ; hello (); .global: const_i0 const_null jsr hello apop 2  File: js.info, Node: The jsas Program, Next: The jsdas Program, Prev: The js Program, Up: Top 4 The `jsas' Program ******************** The `jsas' program is a assembler for the JavaScript assembler. The program can be used to compile assembler files into byte-code. * Menu: * Invoking The jsas Program::  File: js.info, Node: Invoking The jsas Program, Prev: The jsas Program, Up: The jsas Program 4.1 Invoking The `jsas' Program =============================== The `jsas' program is invoked as: `jsas' OPTION... FILE... The program reads the options and processes the assembler files FILE... according to the options. The options can be one of more of the following command line options: `-g' `--debug' Make the assembler to generate debugging information to the generated byte-code files. `-h' `--help' Print a short help message that describes the options that can be given to the `jsas' program. `-O' `--optimize' Optimize the assembler instructions. `-v' `--verbose' Turn on verbose diagnostic messages. When this options is given, the `jsas' program tells what it is doing. `-V' `--version' Print the version number of the `jsas' program.  File: js.info, Node: The jsdas Program, Next: The jswrap Program, Prev: The jsas Program, Up: Top 5 The `jsdas' Program ********************* The `jsdas' program is a disassembler and a manipulator for the JavaScript byte-code files. The program can be used to view, disassemble and manipulate the byte-code files. * Menu: * Invoking The jsdas Program:: * Viewing Byte-Code Files:: * Manipulating Byte-Code Files::  File: js.info, Node: Invoking The jsdas Program, Next: Viewing Byte-Code Files, Prev: The jsdas Program, Up: The jsdas Program 5.1 Invoking The `jsdas' Program ================================ The `jsdas' program is invoked as: `jsdas' OPTION... FILE... The program reads the options and processes the byte-code files FILE... according to the options. The options can be one or more of the following command line options: `-c' `--code' Print the code section of the byte-code files. This is the default action that is preformed if no options are given for the `jsdas' program. `-C' `--constants' Print the constants section of the byte-code file. `-d' `--debug' Print the debug section of the byte-code file. `-h' `--help' Print a short help message that describes the options that can be given to the `jsdas' program. `-i' `--info' Print the byte-code file information. `-l TYPE DATA' `--link TYPE DATA' Link a new section to the byte-code file. The section's type is TYPE and its contents is read from file DATA. `-r TYPE' `--remove TYPE' Remove section of type TYPE from the byte-code files. `-s' `--symtab' Print the symbol table section of the byte-code file. `-S' `--strip' Remove the debug section from the byte-code files. `-V' `--version' Print the version number of the `jsdas' program.  File: js.info, Node: Viewing Byte-Code Files, Next: Manipulating Byte-Code Files, Prev: Invoking The jsdas Program, Up: The jsdas Program 5.2 Viewing Byte-Code Files =========================== In this section we assume that we have a source file `hello.js' with the following contents: function main () { System.print ("Hello, world!\n"); } main (); The file has been compiled to byte-code file `hello.jsc' with the following command: $ js -Wall -g -c hello.js The option `--info' is used to view the contents of the byte-code file. For example, our example file contains the following information: $ jsdas --info hello.jsc hello.jsc: * byte-code file information section 0: type=0 (code), length=34 section 1: type=1 (constants), length=40 section 2: type=2 (symtab), length=25 section 3: type=3 (debug), length=40 We see that the byte-code file has four sections: code, constants, symtab and debug. The listing shows also their lengths. The sections are: `code' the byte-code instructions of the file `constants' the constant values of the file `symtab' the symbol table `debug' the debugging information Next, we would like to see a assembler listing of the byte-code, defined in the `code' section of the file. This can be viewed with the option `--code' that is the `jsdas''s default option (so no options for the following example). $ jsdas hello.jsc hello.jsc: * section `Code' main: 0 load_arg 1 2 add_2_i 3 min_args 2 5 const "Hello, world!\n" 10 const_i1 11 load_global System 16 call_method print 21 pop_n 4 23 const_undefined 24 return .global: 25 const_i0 26 const_null 27 jsr main 32 apop 2 The constants section holds the constant data the byte-code instructions need. These constants are pushed to the stack with the `const' byte-code operand, or they are used to name a symbol in method invocation or in subroutine call. The constant section can be viewed with the `--constants' option. $ jsdas --constants hello.jsc hello.jsc: * section `Constants' 0: "Hello, world!\n" 1: System 2: print 3: main Our example file defines four constants. A string `Hello, world!\n' and three symbols `System', `print', and `main'. The debugging information holds line number information about the source file from which the file was compiled. The debugging section can be viewed with the option `--debug': $ jsdas --debug hello.jsc hello.jsc: * section `Debug' 2 hello.js:2 10 hello.js:3 26 hello.js:6 The symbol table hold the information about the global symbols the byte-code file defines. For each symbol, the symbol table has an offset that points to the appropriate location in the byte-code instruction stream. The symbol table information can be viewed with the `--symtab' option: $ jsdas --symtab hello.jsc hello.jsc: * section `Symtab' main 0 .global 25  File: js.info, Node: Manipulating Byte-Code Files, Prev: Viewing Byte-Code Files, Up: The jsdas Program 5.3 Manipulating Byte-Code Files ================================ $ jsdas --link 7001 hello.js hello.jsc hello.jsc: jsdas: linking 67 bytes of data to section 7001 $ jsdas --info hello.jsc hello.jsc: * byte-code file information section 0: type=0 (code), length=34 section 1: type=1 (constants), length=40 section 2: type=2 (symtab), length=25 section 3: type=3 (debug), length=40 section 4: type=7001, length=67 $ jsdas --remove 3 hello.jsc hello.jsc: jsdas: removing section 3 $ jsdas --remove 7001 hello.jsc hello.jsc: jsdas: removing section 7001 $ jsdas -i hello.jsc hello.jsc: * byte-code file information section 0: type=0 (code), length=34 section 1: type=1 (constants), length=40 section 2: type=2 (symtab), length=25  File: js.info, Node: The jswrap Program, Next: JavaScript API, Prev: The jsdas Program, Up: Top 6 The ``jswrap'' Program ************************ The `jswrap' program is a tool that helps implementing C functions in JavaScript. * Menu: * Invoking The jswrap Program:: * Definition File Format:: * Re-Entrant Functions:: * Calling the Functions from C:: * Sample Project::  File: js.info, Node: Invoking The jswrap Program, Next: Definition File Format, Prev: The jswrap Program, Up: The jswrap Program 6.1 Invoking The `jswrap' Program ================================= The `jswrap' program is invoked as: `jswrap' OPTIONS... FILE The `jswrap' program processes the command line options and according to them and the default values, it converts the input file FILE to the corresponding `.h' and `.c' files. The options can be one of more of the following command line options: `-g' `--debug' Generate debugging information to the generated JavaScript byte-code. `-h FILE' `--header FILE' Generate the C header file to file FILE. The default C header file name is constructed from the input file name by replacing the suffix `.jsw' with suffix `.h'. `-n' `--no-error-handler' Do not generate the default error handler to the generated C files. If this option is specified, then the error handler must be defined in your code. `-o' `--output FILE' Generate the C output to file FILE. The default output file name is constructed from the input file name by replacing the suffix `.jsw' with suffix `.c'. `-r' `--reentrant' Generate re-entrant C functions. The option adds a ``JSInterpPtr'' argument to all C functions it generates. `-V' `--version' Print the version number of the `jswrap' program. `--help' Print a short help message that describes the options that can be given to the `jswrap' program.  File: js.info, Node: Definition File Format, Next: Re-Entrant Functions, Prev: Invoking The jswrap Program, Up: The jswrap Program 6.2 Definition File Format ========================== The definition file contains the function definitions and their implementation in JavaScript. The function definitions are normal JavaScript function definitions but they are extended with the type information. The type information is used to generate the C header files and the glue code that is used in the function call. The definition file can also contain normal JavaScript comments. The comments are ignored and they are not copied to the generated C header and implementation files. The syntax of the function definition is: function [RETURN_TYPE] FUNCTION_NAME `('ARGUMENT_TYPE... ARGUMENT[, ...]`)' { JAVASCRIPT CODE IMPLEMENTING THE FUNCTION. } Where: RETURN_TYPE specifies the return type of the function. If the return type specification is omitted, the function is a `void' function returning no value. FUNCTION_NAME is the name of the function. The name must be a valid C identifier matching regular expression ``^[A-Za-z_][A-Za-z_0-9]*''. ARGUMENT_TYPE specifies the type of the argument, its passing type, and the life scope of the value of the argument. ARGUMENT is the name of the argument. The name must be a valid C identifier. * Menu: * The Type Specifiers:: * The Pass-Type Specifiers:: * The Life Scope Specifiers::  File: js.info, Node: The Type Specifiers, Next: The Pass-Type Specifiers, Prev: Definition File Format, Up: Definition File Format 6.2.1 The Type Specifiers ------------------------- The type specifiers specify the native C and JavaScript type that is used for the argument or for the return value. The following type are supported: `cstring' A `'\0'' terminated C-string. In the C, this is presented as ``char *''. In the JavaScript, this is a normal string. `double' A floating point number. In the C, this is a ``double'' floating point number. `int' An integer Number. In the C, this is a ``long'' integer. `string' An arbitrary data block. In the C, this is presented as ``unsigned char *', `unsigned int'' pair. In the JavaScript, this is a normal string. *Note!* Because the type's presentation in C is two types, this value can't be used as a return value of a function. The following example shows how the types are converted to the corresponding C header file. The input file `types.jsw' is as follows: function types (cstring vcstring, double vdouble, int vint, string vstring) { } The resulting C header file `types.h' contains the following definitions for the function `types': void types ( char *vcstring, double vdouble, long vint, unsigned char *vstring, unsigned int vstring_len );  File: js.info, Node: The Pass-Type Specifiers, Next: The Life Scope Specifiers, Prev: The Type Specifiers, Up: Definition File Format 6.2.2 The Pass-Type Specifiers ------------------------------ The passing type specifiers specify how the argument is passed to the function. The following specifies are supported: `in' An input argument. This is the default pass-type for arguments. `out' An output argument. In the JavaScript, the initial value of the argument is `undefined'. When the control returns from the implementation of the function, the argument's current value is returned to the calling C function. In the C, the output and input-output arguments are presented as pointers to the variables, containing the values. `inout' An input-output argument. The following example shows show the output and input-output arguments are presented in the C header file. The input file `pass.jsw' is as follows: function pass (out cstring vcstring, out double vdouble, inout int vint, inout string vstring) { } The resulting C header file `pass.h' contains the following definitions for the function `pass': void pass ( char **vcstring, double *vdouble, long *vint, unsigned char **vstring, unsigned int *vstring_len );  File: js.info, Node: The Life Scope Specifiers, Prev: The Pass-Type Specifiers, Up: Definition File Format 6.2.3 The Life Scope Specifiers ------------------------------- The life scope specifiers specify the liveness of the value, passed in an argument. The following specifiers are supported: `static' The argument points to static data that can't change while the execution is in the JavaScript code. This means that the JavaScript can use the same data that is given to it; it don't have to make a private copy of the data. The specifier can only be used with `cstring' and `string' types. The specifier don't have any affect for the generated C header file.  File: js.info, Node: Re-Entrant Functions, Next: Calling the Functions from C, Prev: Definition File Format, Up: The jswrap Program 6.3 Re-Entrant Functions ========================  File: js.info, Node: Calling the Functions from C, Next: Sample Project, Prev: Re-Entrant Functions, Up: The jswrap Program 6.4 Calling the Functions from C ================================  File: js.info, Node: Sample Project, Prev: Calling the Functions from C, Up: The jswrap Program 6.5 Sample Project ================== function hello (cstring user) { System.stdout.writeln ("Hello, " + user + "!"); } function int max_sum (int a, int b, int out sum) { sum = a + b; return a > b ? a : b; } $ jswrap sample.jsw /* This file is automatically generated from `hello.jsw' by jswrap. */ #ifndef HELLO_H #define HELLO_H void hello ( char *user ); int max_sum ( int a, int b, int *sum ); #endif /* not HELLO_H */ #include #include "hello.h" JSInterpPtr jswrap_interp; int main (int argc, char *argv[]) { int a, b, max, sum; jswrap_interp = js_create_interp (NULL); hello ("World"); a = 5; b = 7; max = max_sum (a, b, &sum); printf ("%d + %d = %d, max(%d, %d) = %d\n", a, b, sum, a, b, max); return 0; }  File: js.info, Node: JavaScript API, Next: Virtual Machine, Prev: The jswrap Program, Up: Top 7 JavaScript API **************** * Menu: * Interpreter Handling:: * Evaluation and Compilation:: * Type Handling:: * Defining Global Methods:: * Classes:: * Modules::  File: js.info, Node: Interpreter Handling, Next: Evaluation and Compilation, Prev: JavaScript API, Up: JavaScript API 7.1 Interpreter Handling ======================== -- Function: const char * js_version () Return a string that describes the JavaScript interpreter version number. The returned string is in format `"MAJOR.MINOR.PATCH"', where MAJOR, MINOR, and PATCH are integer numbers. -- Function: void js_init_default_options (JSInterpOptions *OPTIONS) Initialize the interpreter options OPTIONS to the default values. These are the same values that are used in the interpreter creation, if the argument OPTIONS of `js_create_interp()' is `NULL'. -- Function: JSInterpPtr js_create_interp (JSInterpOptions *OPTIONS) Create a new JavaScript interpreter. The function returns an interpreter handle that must be passed to all other interpreter API functions. The argument OPTIONS specify additional options for the interpreter. If the argument is NULL, the default values are used. If the interpreter creation fails - due insufficient memory resources - the function return value `NULL'. -- Function: void js_destroy_interp (JSInterpPtr INTERP) Destroy interpreter INTERP and free all resources the interpreter has allocated. The handle INTERP must not be used after this function. -- Function: const char * js_error_message (JSInterpPtr INTERP) Return an error message of the latest error in interpreter INTERP. -- Function: void js_result (JSInterpPtr INTERP, JSType *RESULT_RETURN) Get the result of the latest evaluation or execution in interpreter INTERP. The result is returned in RESULT_RETURN. All data, returned in RESULT_RETURN, belongs to the interpreter. The caller must not modify or changed it in any ways. -- Function: void js_set_var (JSInterpPtr INTERP, char *NAME, JSType *VALUE) -- Function: void js_get_var (JSInterpPtr INTERP, char *NAME, JSType *VALUE) -- Function: void js_get_options (JSInterpPtr INTERP, JSInterpOptions *OPTIONS) Get the options of interpreter INTERP to OPTIONS. -- Function: void js_set_options (JSInterpPtr INTERP, JSInterpOptions *OPTIONS) Modify the options of interpreter INTERP according to OPTIONS.  File: js.info, Node: Evaluation and Compilation, Next: Type Handling, Prev: Interpreter Handling, Up: JavaScript API 7.2 Evaluation and Compilation ============================== -- Function: int js_eval (JSInterpPtr INTERP, char *CODE) Evaluate JavaScript code CODE with interpreter INTERP. The argument CODE is NUL-terminated a C-string holding the JavaScript code. The function returns 1 if the operation was successful or 0 otherwise. If the evaluation failed, the error message can be retrieved with function `js_error_message()'. -- Function: int js_eval_data (JSInterpPtr INTERP, char *DATA, unsigned int DATALEN) Evaluate JavaScript code DATA, DATALEN with interpreter INTERP. -- Function: int js_eval_file (JSInterpPtr INTERP, char *FILENAME) Evaluate file FILENAME with interpreter INTERP. The file FILENAME can contain JavaScript or byte-code. -- Function: int js_eval_javascript_file (JSInterpPtr INTERP, char *FILENAME) Evaluate JavaScript code file FILENAME with interpreter INTERP. -- Function: int js_execute_byte_code_file (JSInterpPtr INTERP, char *FILENAME) Execute a byte-code file FILENAME with interpreter INTERP. -- Function: int js_apply (JSInterpPtr INTERP, char *NAME, unsigned int ARGC, JSType *ARGV) Call function NAME with arguments ARGC, ARGV. The return value of the function NAME can be retrieved with the `js_result()' function. -- Function: int js_compile (JSInterpPtr INTERP, char *INPUT_FILE, char *ASSEMBLER_FILE, char *BYTE_CODE_FILE) Compile JavaScript input file INPUT_FILE. If the argument ASSEMBLER_FILE is not `NULL', the generated assembler code is saved to the file, specified by the argument. If the argument BYTE_CODE_FILE is not `NULL', the generated byte-code data is svaed to the file, specified by the argument. -- Function: int js_compile_to_byte_code (JSInterpPtr INTERP, char *INPUT_FILE, unsigned char **BC_RETURN, unsigned int *BC_LEN_RETURN); Compile JavaScript file INPUT_FILE to byte-code and return the resulting byte-code data in BC_RETURN, BC_LEN_RETURN. The returned byte-code data BC_RETURN belongs to the interpreter and it must be saved by the caller *before* any other JS functions is called. If the data is not saved, its contents will be invalidated at the next garbage collection. -- Function: int js_compile_data_to_byte_code (JSInterpPtr INTERP, char *DATA, unsigned int DATALEN, unsigned char **BC_RETURN, unsigned int *BC_LEN_RETURN); Compile JavaScript code DATA, DATALEN to byte-code and return the resulting byte-code data in BC_RETURN, BC_LEN_RETURN. -- Function: int js_execute_byte_code (JSInterpPtr INTERP, unsigned char *BC, unsigned int BC_LEN); Execute byte-code data BC, BC_LEN. The byte-code data is the contents of a byte-code file, or a copy of the data returned by the `js_compile_to_byte_code()' or `js_compile_data_to_byte_code()' functions. *Note!* You can't use the data from the `js_compile_to_byte_code()', `js_compile_data_to_byte_code()' functions as an input for this function. You must take a private copy of the data and pass that copy to the function: if (js_compile_to_byte_code (interp, file, &bc, &bclen)) { char *bc_copy = xmalloc (bclen); memcpy (bc_copy, bc, bclen); js_execute_byte_code (interp, bc_copy, bclen); xfree (bc_copy); }  File: js.info, Node: Type Handling, Next: Defining Global Methods, Prev: Evaluation and Compilation, Up: JavaScript API 7.3 Type Handling ================= -- Function: void js_type_make_string (JSInterpPtr INTERP, JSType *TYPE, unsigned char *DATA, unsigned int LENGTH) Create a new string type from LENGTH bytes of data DATA. The result string is created to TYPE. -- Function: void js_type_make_array (JSInterpPtr INTERP, JSType *TYPE, unsigned int LENGTH) Create a new array type of length LENGTH. The result array is created to TYPE.  File: js.info, Node: Defining Global Methods, Next: Classes, Prev: Type Handling, Up: JavaScript API 7.4 Global Methods ================== -- Function: void js_create_global_method (JSInterpPtr INTERP, char *NAME, JSGlobalMethodProc PROC, void *CONTEXT, JSFreeProc CONTEXT_FREE_PROC)  File: js.info, Node: Classes, Next: Modules, Prev: Defining Global Methods, Up: JavaScript API 7.5 Classes =========== -- Function: JSClassPtr js_class_create (void *CLASS_CONTEXT, JSFreeProc CLASS_CONTEXT_DESTRUCTOR, int NO_AUTO_DESTROY, JSConstructor CONSTRUCTOR) Create a new class with class context data CLASS_CONTEXT. The context data is destroyed with CLASS_CONTEXT_DESTRUCTOR. If the argument NO_AUTO_DESTROY is not 0, the JavaScript interpreter will *not* destroy the class when the interpreter is destroyed. In that case, it is the caller's responsibility to call `js_class_destroy()' for the returned class handle, after the interpreter has been destroyed. If the argument CONSTRUCTOR is not `NULL', it is used to instantiate the class when a ``new 'CLASS` ('ARGS[...]`);'' expression is evaluated in the JavaScript code. -- Function: void js_class_destroy (JSClassPtr CLS) Destroy class handle CLS. The class handle must be created by the `js_class_create()' function, so that value `1' was given for the NO_AUTO_DESTROY argument. -- Function: JSVoidPtr js_class_context (JSClassPtr CLS) Return the class context of class CLS. The returned value is the same that was given for the CLASS_CONTEXT argument in call of function `js_class_create()'. -- Function: int js_class_define_method (JSClassPtr CLS, char *NAME, unsigned int FLAGS, JSMethodProc METHOD) Define a new method for the class CLS. The name of the new method is NAME and its implementation is METHOD. The argument FLAGS can have the following flags: `JS_CF_STATIC' The created method is a static method. -- Function: int js_class_define_property (JSClassPtr CLS, char *NAME, unsigned int FLAGS, JSPropertyProc PROPERTY) Define a new property for the class CLS. The name of the property is NAME and its setter and getter function is PROPERTY. The argument FLAGS can have the following flags: `JS_CF_STATIC' The property is a static property. `JS_CF_IMMUTABLE' The property is immutable. An error to try to set the property. -- Function: int js_define_class (JSInterpPtr INTERP, JSClassPtr CLS, char *NAME) Define the class CLS to the interpreter INTERP with name NAME. If the value `0' was given for the argument NO_AUTO_DESTROY of the function `js_class_create()', the handle CLS must not be used after this call. -- Function: int js_instantiate_class (JSInterpPtr INTERP, JSClassPtr CLS, void *INSTANCE_CTX, JSFreeProc INSTANCE_CTX_DESTRUCTOR, JSType *RESULT_RETURN) -- Function: const JSClassPtr js_lookup_class (JSInterpPtr INTERP, char *NAME) Lookup the class context by name from the interpreter INTERP. -- Function: int js_isa (JSInterpPtr INTERP, JSType *OBJECT, JSClassPtr CLS, void **INSTANCE_CONTEXT_RETURN) Check if object OBJECT is an instance of class CLS. The function returns a boolean success status. If the argument INSTANCE_CONTEXT_RETURN is not `NULL', it will be set to the instance context of object OBJECT.  File: js.info, Node: Modules, Prev: Classes, Up: JavaScript API 7.6 Modules =========== -- Function: int js_define_module (JSInterpPtr INTERP, JSModuleInitProc INIT_PROC)  File: js.info, Node: Virtual Machine, Next: JavaScript Compiler, Prev: JavaScript API, Up: Top 8 Virtual Machine ***************** * Menu: * Byte-Code File Format:: * Byte-Code Operands:: * Stack Frame::  File: js.info, Node: Byte-Code File Format, Next: Byte-Code Operands, Prev: Virtual Machine, Up: Virtual Machine 8.1 Byte-Code File Format ========================= * Menu: * File Header:: * Code Section:: * Constants Section:: * Symtab Section:: * Debug Section::  File: js.info, Node: File Header, Next: Code Section, Prev: Byte-Code File Format, Up: Byte-Code File Format 8.1.1 File Header ----------------- `magic' An `UInt32' number containing the JavaScript byte-code file magic. The value of the magic is `0xc0014a53'. `nsects' An `UInt32' number containing the number of sections in this byte-code file.  File: js.info, Node: Code Section, Next: Constants Section, Prev: File Header, Up: Byte-Code File Format 8.1.2 Code Section ------------------  File: js.info, Node: Constants Section, Next: Symtab Section, Prev: Code Section, Up: Byte-Code File Format 8.1.3 Constants Section ----------------------- The constants section contains the constant values of the byte-code. The different constant types are stored as follows: integer (UInt8)`3', (Int32)VALUE string (UInt8)`4', (UInt32)LENGTH, LENGTH BYTES OF DATA float (UInt8)`5', (double)VALUE symbol (UInt8)`10', SYMBOL NAME, (UInt8)`0' NaN (UInt8)`13' regular expression (UInt8)`100', (UInt8)FLAGS, (UInt32)LENGTH, LENGTH BYTES OF REGEXP SOURCE The item FLAGS holds the regular expression flags. It is a combination of the following flags: `0x01' global match `0x02' ignore case  File: js.info, Node: Symtab Section, Next: Debug Section, Prev: Constants Section, Up: Byte-Code File Format 8.1.4 Symtab Section --------------------  File: js.info, Node: Debug Section, Prev: Symtab Section, Up: Byte-Code File Format 8.1.5 Debug Section -------------------  File: js.info, Node: Byte-Code Operands, Next: Stack Frame, Prev: Byte-Code File Format, Up: Virtual Machine 8.2 Byte-Code Operands ====================== The virtual machine knows the following byte-code operands. Each operand is identified by a 8 bit long unsigned integer number. The first operand `halt' has code 0, the next operand `done' has code 1, and so on. Some operand take arguments that are shown after the operand name in the following listing. The meanings of the arguments are: `Int8' The code of the operand is followed by a 8 bit long integer number argument. `Int16' The code of the operand is followed by a 16 bit long integer number argument. `Int32' The code of the operand is followed by a 32 bit long integer number argument. `Symbol' The code of the operand is followed by a 32 bit long integer number argument. The number is an offset to the constant section and the specified constant is a symbol that is the argument of the operand. The notation BEFORE => AFTER desribes how the operand modifies the virtual machine stack. For example, the notation: -- => `undefined' means that the operand takes no items from the stack and it pushes value `undefined' to the stack. The notation: ANY ANY => `boolean' means that the operand takes two items from the stack and it pushes a boolean result to the stack. The virtual machine knows the following byte-code operands. -- Operand: halt -- => -- Halt the virtual machine. The program execution stops immediately and the virtual machine starts execute the following C-code: while (1) sleep (5); This "sleep forever" loop is implemented for debugging purposes. -- Operand: done -- => -- The execution of the byte-code is finished and the control returns to the calling C-function. -- Operand: nop -- => -- Do nothing; no operation. -- Operand: dup any => any any Duplicate the item at the top of the stack. -- Operand: pop any => -- Remove one item from the top of the stack. -- Operand: pop_n `Int8' any ... any => -- Remove INT8 items from the top of the stack. -- Operand: apop `Int8' any_n ... any_0 => any_0 Remove INT8 items from the top of the stack, leaving the topmost item on the top of the stack. This operand is used to remove arguments of a function call, leaving the function's return value to the top of the stack. -- Operand: swap any_1 any_2 => any_2 any_1 Swap the two topmost items in the stack. -- Operand: roll `Int8' any_n ... any_1 any_0 => any_0 any_n ... any_1 -- Operand: const `Int32' -- => const Push a constant from the constant section to the stack. The constant is specified by the value INT32. -- Operand: const_null -- => `null' Push value `null' to the stack. -- Operand: const_true -- => `true' Push value `true' to the stack. -- Operand: const_false -- => `false' Push value `false' to the stack. -- Operand: const_undefined -- => `undefined' Push value `undefined' to the stack. -- Operand: const_i0 -- => `0' Push integer number `0' to the stack. -- Operand: const_i1 -- => `1' Push integer number `1' to the stack. -- Operand: const_i2 -- => `2' Push integer number `2' to the stack. -- Operand: const_i3 -- => `3' Push integer number `3' to the stack. -- Operand: const_i `Int32' -- => `Int32' Push integer number `Int32' to the stack. -- Operand: load_global `Symbol' -- => value Push the value of the global variable SYMBOL to the stack. The operand will *not* lookup the variable SYMBOL from the with-chain. -- Operand: store_global `Symbol' value => -- Store the topmost item of the stack to the global variable SYMBOL. -- Operand: load_arg `Int8' -- => value Push the value of the argument INT8 to the stack. -- Operand: store_arg `Int8' value => -- Store the topmost item of the stack to the argument INT8. -- Operand: load_local `Int16' -- => value Push the value of the local variable INT16 to the stack. -- Operand: store_local `Int16' value => -- Store the topmost item of the stack to the local variable INT16. -- Operand: load_property `Symbol' object => value Push the value of the property SYMBOL of object OBJECT to the stack. -- Operand: store_property `Symbol' object value => -- Save the value VALUE to the property SYMBOL of object OBJECT. -- Operand: load_array object index => value Push the INDEX:th item of object OBJECT to the stack. -- Operand: store_array value object index => -- Store the value VALUE to the INDEX:th position of object OBJECT. -- Operand: nth any integer => item boolean Push the INTEGER:th item of object ANY to the stack. Push a boolean success status that tells whether the object ANY did contain INTEGER:th item. -- Operand: cmp_eq any1 any2 => boolean Compare the two objects ANY1, ANY2 for equality and push a boolean result code to the stack. -- Operand: cmp_ne any any => boolean Compare the two objects ANY1, ANY2 for inequality and push a boolean result code to the stack. -- Operand: cmp_lt any1 any2 => boolean Compare whether object ANY1 is smaller than object ANY2. Push a boolean result code to the stack. -- Operand: cmp_gt any1 any2 => boolean Compare whether object ANY1 is greater than object ANY2. Push a boolean result code to the stack. -- Operand: cmp_le any1 any2 => boolean Compare whether object ANY1 is smaller than, or equal to object ANY2. Push a boolean result code to the stack. -- Operand: cmp_ge any1 any2 => boolean Compare whether object ANY1 is greater than, or equal to object ANY2. Push a boolean result code to the stack. -- Operand: cmp_seq any1 any2 => boolean Compare the two objects ANY1, ANY2 for strict equality and push a boolean result code to the stack. -- Operand: cmp_sne any any => boolean Compare the two objects ANY1, ANY2 for strict inequality and push a boolean result code to the stack. -- Operand: sub any1 any2 => result Substract object ANY2 from object ANY1 and push the result to the stack. -- Operand: add any1 any2 => result Add object ANY2 to object ANY1 and push the result to the stack. -- Operand: mul any1 any2 => result Multiply object ANY1 with object ANY2 and push the result to the stack. -- Operand: div any1 any2 => result Divide object ANY1 with object ANY2 and push the result to the stack. -- Operand: mod integer1 integer2 => result Count object INTEGER1 modulo object INTEGER2 and push the result to the stack. -- Operand: neg any => result Negate object ANY and push the result to the stack. -- Operand: and any1 any2 => result Perform a bitwise and operation between objects ANY1 and ANY2 and push the result to the stack. -- Operand: not any1 any2 => result Perform a bitwise not operation between objects ANY1 and ANY2 and push the result to the stack. -- Operand: or any1 any2 => result Perform a bitwise or operation between objects ANY1 and ANY2 and push the result to the stack. -- Operand: xor any1 any2 => result Perform a bitwise xor operation between objects ANY1 and ANY2 and push the result to the stack. -- Operand: shift_left integer1 integer2 => integer Shift integer number INTEGER1 left INTEGER2 bits. Push the result value to the stack. -- Operand: shift_right integer1 integer2 => integer Shift integer number INTEGER1 right INTEGER2 bits. Push the result value to the stack. -- Operand: shift_rright integer1 integer2 => integer -- Operand: iffalse `Int32' any => -- If the topmost item in the stack has boolean value `false', adjust the program counter with relative offset INT32. -- Operand: iftrue `Int32' any => -- If the topmost item in the stack has boolean value `true', adjust the program counter with relative offset INT32. -- Operand: call_method `Symbol' object => result Call method SYMBOL in the object OBJECT. Push the result of the method call to the stack. -- Operand: jmp `Int32' -- => -- Adjust program counter with relative offset INT32, e.g. jump to relative position PC + INT32. -- Operand: jsr function => result Jump to subroutine FUNCTION and push the result of the subroutine call to the stack. The operand will *not* process the with-chain. -- Operand: return result => result Return from a subroutine with value RESULT. -- Operand: typeof any => string Push the type name of object ANY to the stack. -- Operand: new object => result object Create an instance of object OBJECT and call its constructor function. Push the result from the constructor and the new instance to the stack. The return value of the constructor is discarded. -- Operand: delete_property `Symbol' object => undefined Delete property SYMBOL from object OBJECT. Push value `undefined' to the stack. -- Operand: delete_array object index => undefined Delete the INDEX:th property of object OBJECT. Push value `undefined' to the stack. -- Operand: locals `Int16' -- => undefined ... undefined Allocate INT16 local variables from the stack frame. The operand `locals' must be called in the beginning of the function code. The operand will push INT16 `undefined' values to the stack. The values will be the place-holders for the local variables. -- Operand: min_args `Int8' integer => -- If the number of the arguments for the function INTEGER is smaller than `Int8', expand the stack frame so that the function gets `Int8' arguments. The created arguments will have value `undefined'. -- Operand: load_nth_arg integer => argument Push the INTEGER'th argument of function to the top of the stack. The index INTEGER must be an integer number. -- Operand: with_push object => -- Push object OBJECT to the function's with-lookup chain. -- Operand: with_pop `Int8' -- => -- Pop INT8 objects from the function's with-lookup chain. -- Operand: try_push `Int32' -- => -- Push a try-frame with a catch block offset INT32 to the virtual machine's try-chain. -- Operand: try_pop `Int8' -- => -- Pop INT8 frames from the virtual machine's try-chain. -- Operand: throw any => -- Throw an exception with value ANY. -- Operand: iffalse_b `Int32' boolean => -- If the topmost item in the stack is `false', adjust the program counter with relative offset INT32. The operand assumes that the topmost item is a boolean value. -- Operand: iftrue_b `Int32' boolean => -- If the topmost item in the stack is `true', adjust the program counter with relative offset INT32. The operand assumes that the topmost item is a boolean value. -- Operand: add_1_i integer => integer Add integer number one to the top most item in the stack. The operand assumes that the topmost item is an integer number. -- Operand: add_2_i integer => integer Add integer number two to the top most item in the stack. The operand assumes that the topmost item is an integer number. -- Operand: load_global_w `Symbol' -- => value Push the value of the global variable SYMBOL to the stack. The operand will lookup the property SYMBOL from the currently active with-chain. -- Operand: jsr_w `Symbol' function => result Jump to subroutine FUNCTION and push the result of the subroutine call to the stack. The operand will lookup the method SYMBOL from the currently active with-chain. If the method is not found, the argument FUNCTION is used.  File: js.info, Node: Stack Frame, Prev: Byte-Code Operands, Up: Virtual Machine 8.3 Stack Frame =============== JS_SP0 sp => JS_SP1 local_var_N JS_SP2 ... JS_SP(N) local_var_1 JS_LOCAL(0) local_var_0 return_addr JS_WITHPTR with_ptr JS_ARGS_FIXP args_fix fp => old_fp JS_ARG(0) this JS_ARG(1) arg_count JS_ARG(2) argument_1 argument_2 ... JS_ARG(N) argument_N local_var_N ... local_var_0 args_fix return_addr with_ptr old_fp this ...  File: js.info, Node: JavaScript Compiler, Next: GNU Library General Public License, Prev: Virtual Machine, Up: Top 9 JavaScript Compiler ********************* The JavaScript compiler is implemented in the JavaScript language. Because the JavaScript language does not have namespaces, the compiler has been coded to a fixed part of the global namespace. All global symbols the compiler uses, start with the prefix ``JSC$''. This prefix is reserved for the interpreter and users must not define any symbols or functions starting with that prefix. The compiler compiles JavaScript source code to byte-code and it returns a fixed byte-code file as the result. This result file (or data block) can be passed to the virtual machine for execution. The compiler has three stages. The first stage parse the input stream and create a syntax tree for the input. The second stage transforms the syntax tree to a list of assembler operations. The third stage converts the symbolic assembler instructions to byte-code operands. Depending on the compilation options, the compiler performs different optimizations during the compilation. The basic optimizations include constant folding, peephole optimization, and optimization of jumps to jump instructions. During the batch-compilation (when compiling a JavaScript source file `.js' to byte-code file `.jsc') the compiler performns heavier optimizations to minimize the size of the generated byte-code file, and to speed up some operations. * Menu: * Public Entry Points::  File: js.info, Node: Public Entry Points, Prev: JavaScript Compiler, Up: JavaScript Compiler 9.1 Public Entry Points ======================= -- Function: JSC$compile_file (NAME, FLAGS, ASM_FILE, BC_FILE) Compile JavaScript source file NAME according to FLAGS. If argument ASM_FILE is not `null', symbolic assembler output is saved to that file. If argument BC_FILE is not `null', the byte-code output is saved to that file. The function returns a string that holds the byte-code output for the source file. -- Function: JSC$compile_string (STRING, FLAGS, ASM_FILE, BC_FILE) Compile JavaScript source code STRING according to FLAGS. If argument ASM_FILE is not `null', symbolic assembler output is saved to that file. If argument BC_FILE is not `null', the byte-code output is saved to that file. The function returns a string that holds the byte-code output for the source code. In both functions, the argument FLAGS specify the verbosity, warning, and optimization levels of the compilation. The following values can be given to flags: `JSC$FLAG_VERBOSE' turns on diagnostic messages `JSC$FLAG_ANNOTATE_ASSEMBLER' add original JavaScript source lines to the generated assembler listing `JSC$FLAG_GENERATE_DEBUG_INFO' generate debugging information to the byte-code file `JSC$FLAG_GENERATE_EXECUTABLE_BC_FILES' add execute permissions to the generated byte-code files `JSC$FLAG_OPTIMIZE_PEEPHOLE' perform peephole optimization `JSC$FLAG_OPTIMIZE_JUMPS' perform optimization for jumps to jump instructions `JSC$FLAG_OPTIMIZE_BC_SIZE' optimize the size of the genated byte-code file `JSC$FLAG_OPTIMIZE_HEAVY' perform optimizations which require liveness analyzing of the variables `JSC$FLAG_OPTIMIZE_MASK' mask to turn on all optimizations `JSC$FLAG_WARN_UNUSED_ARGUMENT' warn if an argument of a function is unused in the function body `JSC$FLAG_WARN_UNUSED_VARIABLE' warn in a variable is defined but it is not used in the function body `JSC$FLAG_WARN_SHADOW' warn if a variable declaration shadows a parameter of a function `JSC$FLAG_WARN_WITH_CLOBBER' warn if a symbol with-lookup is clobbered because the symbol is defined to be a local variable or a function argument `JSC$FLAG_WARN_MISSING_SEMICOLON' warn if a semicolon is missing from the input. The missing semicolons are inserted during the parsing by the automatic semicolon inserting. However, since the missing semicolons show bad programming style, this option will warn about them. `JSC$FLAG_WARN_STRICT_ECMA' warn about things that are supported by this implementation, but are not allowed by the ECMAScript standard `JSC$FLAG_WARN_DEPRECATED' warn if deprecated features has been used in the source code `JSC$FLAG_WARN_MASK' mask to turn on all warnings The compiler entry points can be called from JavaScript and C programs. For example, they are used extensively to implement the JavaScript API, described in the `js.h' file. The following example shows how a C-string, containing JavaScript code, can be compiled and executed. Similar function can be found from the JavaScript API implementing the `js_eval()' function. int eval_code (JSInterpPtr interp, char *code); { JSNode argv[5]; int i = 0; int result; ByteCode *bc; /* Compile the code. */ /* Argument count. */ argv[i].type = JS_INTEGER; argv[i].u.vinteger = 4; i++; /* Source for the compiler. */ js_make_static_string (interp->vm, &argv[i], code, strlen (code)); i++; /* Flags. */ argv[i].type = JS_INTEGER; argv[i].u.vinteger = JSC_FLAG_VERBOSE; argv[i].u.vinteger |= JSC_FLAG_OPTIMIZE_MASK; argv[i].u.vinteger |= JSC_FLAG_WARN_MASK; i++; /* Assembler file. */ argv[i].type = JS_NULL; i++; /* Byte-code file. */ argv[i].type = JS_NULL; i++; /* Call the compiler entry point. */ result = js_vm_apply (interp->vm, "JSC$compile_string", i, argv); if (result == 0) return 0; bc = js_bc_read_data (interp->vm->exec_result.u.vstring->data, interp->vm->exec_result.u.vstring->len); /* And finally, execute it. */ result = js_vm_execute (interp->vm, bc); /* Free the byte-code. */ js_bc_free (bc); return result; } The following example shows how the compiler entry point can be called from JavaScript code. The example code compiles a JavaScript source code file `input.js' into byte-code and stores the result to file `ouput.jsc'. try { JSC$compile_file ("input.js", JSC$FLAG_OPTIMIZE_MASK | JSC$FLAG_WARN_MASK, null, "output.jsc"); } catch (e) { System.stdout.writeln ("compilation failed: " + e); }  File: js.info, Node: GNU Library General Public License, Next: Index, Prev: JavaScript Compiler, Up: Top Appendix A GNU Library General Public License ********************************************* Appendix B GNU LIBRARY GENERAL PUBLIC LICENSE ********************************************* Version 2, June 1991 Copyright (C) 1991 Free Software Foundation, Inc. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the library GPL. It is numbered 2 because it goes with version 2 of the ordinary GPL.] Preamble ======== The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Library General Public License, applies to some specially designated Free Software Foundation software, and to any other libraries whose authors decide to use it. You can use it for your libraries, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library, or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link a program with the library, you must provide complete object files to the recipients so that they can relink them with the library, after making changes to the library and recompiling it. And you must show them these terms so they know their rights. Our method of protecting your rights has two steps: (1) copyright the library, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the library. Also, for each distributor's protection, we want to make certain that everyone understands that there is no warranty for this free library. If the library is modified by someone else and passed on, we want its recipients to know that what they have is not the original version, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that companies distributing free software will individually obtain patent licenses, thus in effect transforming the program into proprietary software. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License, which was designed for utility programs. This license, the GNU Library General Public License, applies to certain designated libraries. This license is quite different from the ordinary one; be sure to read it in full, and don't assume that anything in it is the same as in the ordinary license. The reason we have a separate public license for some libraries is that they blur the distinction we usually make between modifying or adding to a program and simply using it. Linking a program with a library, without changing the library, is in some sense simply using the library, and is analogous to running a utility program or application program. However, in a textual and legal sense, the linked executable is a combined work, a derivative of the original library, and the ordinary General Public License treats it as such. Because of this blurred distinction, using the ordinary General Public License for libraries did not effectively promote software sharing, because most developers did not use the libraries. We concluded that weaker conditions might promote sharing better. However, unrestricted linking of non-free programs would deprive the users of those programs of all benefit from the free status of the libraries themselves. This Library General Public License is intended to permit developers of non-free programs to use free libraries, while preserving your freedom as a user of such programs to change the free libraries that are incorporated in them. (We have not seen how to achieve this as regards changes in header files, but we have achieved it as regards changes in the actual functions of the Library.) The hope is that this will lead to faster development of free libraries. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, while the latter only works together with the library. Note that it is possible for a library to be covered by the ordinary General Public License rather than by this special one. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Library General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a. The modified work must itself be a software library. b. You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c. You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d. If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also compile or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a. Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b. Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. c. If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. d. Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a. Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b. Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Library General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries ============================================== If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. ONE LINE TO GIVE THE LIBRARY'S NAME AND AN IDEA OF WHAT IT DOES. Copyright (C) YEAR NAME OF AUTHOR This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. SIGNATURE OF TY COON, 1 April 1990 Ty Coon, President of Vice That's all there is to it!  File: js.info, Node: Index, Prev: GNU Library General Public License, Up: Top Index ***** [index] * Menu: * $1: RegExp. (line 108) * $2: RegExp. (line 109) * $3: RegExp. (line 110) * $4: RegExp. (line 111) * $5: RegExp. (line 112) * $6: RegExp. (line 113) * $7: RegExp. (line 114) * $8: RegExp. (line 115) * $9: RegExp. (line 116) * $_: RegExp. (line 121) * abs on Math: Math. (line 10) * acos on Math: Math. (line 12) * add: Byte-Code Operands. (line 191) * add_1_i: Byte-Code Operands. (line 317) * add_2_i: Byte-Code Operands. (line 321) * and: Byte-Code Operands. (line 209) * apop: Byte-Code Operands. (line 75) * append on String: String. (line 48) * Array: Array. (line 21) * asin on Math: Math. (line 14) * atan on Math: Math. (line 16) * atan2 on Math: Math. (line 18) * autoFlush: File. (line 197) * bits: System. (line 50) * Boolean: Boolean. (line 20) * bufferSize: File. (line 204) * byteToString on File: File. (line 15) * call_method: Byte-Code Operands. (line 243) * callMethod: Global Methods and Properties. (line 108) * canonicalHost: System. (line 55) * canonicalHostCPU: System. (line 62) * canonicalHostOS: System. (line 74) * canonicalHostVendor: System. (line 68) * ceil on Math: Math. (line 20) * charAt on String: String. (line 61) * charCodeAt on String: String. (line 68) * chdir on System: System. (line 10) * chmod on File: File. (line 17) * clearError on File: File. (line 195) * close on Directory: Directory. (line 12) * close on File: File. (line 160) * cmp_eq: Byte-Code Operands. (line 155) * cmp_ge: Byte-Code Operands. (line 175) * cmp_gt: Byte-Code Operands. (line 167) * cmp_le: Byte-Code Operands. (line 171) * cmp_lt: Byte-Code Operands. (line 163) * cmp_ne: Byte-Code Operands. (line 159) * cmp_seq: Byte-Code Operands. (line 179) * cmp_sne: Byte-Code Operands. (line 183) * compile on JS: JS. (line 9) * compile on RegExp: RegExp. (line 28) * concat on Array: Array. (line 40) * concat on String: String. (line 75) * const: Byte-Code Operands. (line 87) * const_false: Byte-Code Operands. (line 97) * const_i: Byte-Code Operands. (line 115) * const_i0: Byte-Code Operands. (line 103) * const_i1: Byte-Code Operands. (line 106) * const_i2: Byte-Code Operands. (line 109) * const_i3: Byte-Code Operands. (line 112) * const_null: Byte-Code Operands. (line 91) * const_true: Byte-Code Operands. (line 94) * const_undefined: Byte-Code Operands. (line 100) * cos on Math: Math. (line 22) * crc32 on String: String. (line 82) * Date: Date. (line 21) * debug: Global Methods and Properties. (line 30) * delete_array: Byte-Code Operands. (line 271) * delete_property: Byte-Code Operands. (line 267) * Directory: Directory. (line 10) * dispatchMethod: VM. (line 40) * div: Byte-Code Operands. (line 198) * done: Byte-Code Operands. (line 59) * dup: Byte-Code Operands. (line 66) * E: Math. (line 51) * eof on File: File. (line 166) * errno: System. (line 80) * error: Global Methods and Properties. (line 40) * error on File: File. (line 193) * error on System: System. (line 14) * errorMessage: JS. (line 23) * escape: Global Methods and Properties. (line 22) * eval: Global Methods and Properties. (line 16) * eval on JS: JS. (line 11) * evalFile on JS: JS. (line 13) * evalJavaScriptFile on JS: JS. (line 15) * exec on RegExp: RegExp. (line 42) * executeByteCodeFile on JS: JS. (line 17) * exists on File: File. (line 191) * exit on System: System. (line 18) * exp on Math: Math. (line 24) * File: File. (line 13) * final on MD5: MD5. (line 12) * finalBinary on MD5: MD5. (line 27) * float: Global Methods and Properties. (line 45) * floor on Math: Math. (line 26) * flush on File: File. (line 187) * format on Date: Date. (line 35) * formatGMT on Date: Date. (line 37) * fromCharCode on String: String. (line 20) * garbageCollect on VM: VM. (line 10) * gcCount: VM. (line 46) * gcTrigger: VM. (line 50) * getcwd on System: System. (line 23) * getDate on Date: Date. (line 39) * getDay on Date: Date. (line 41) * getenv on System: System. (line 28) * getHours on Date: Date. (line 43) * getLength on File: File. (line 189) * getMinutes on Date: Date. (line 45) * getMonth on Date: Date. (line 47) * getPosition on File: File. (line 164) * getSeconds on Date: Date. (line 49) * getTime on Date: Date. (line 51) * getTimezoneOffset on Date: Date. (line 53) * getVar on JS: JS. (line 19) * getYear on Date: Date. (line 55) * global: RegExp. (line 162) * halt: Byte-Code Operands. (line 50) * heapAllocated: VM. (line 55) * heapFree: VM. (line 59) * heapSize: VM. (line 62) * iffalse: Byte-Code Operands. (line 235) * iffalse_b: Byte-Code Operands. (line 307) * iftrue: Byte-Code Operands. (line 239) * iftrue_b: Byte-Code Operands. (line 312) * ignoreCase: RegExp. (line 166) * indexOf on String: String. (line 93) * Infinity: Global Methods and Properties. (line 13) * init on MD5: MD5. (line 31) * input: RegExp. (line 122) * int: Global Methods and Properties. (line 50) * isFinite: Global Methods and Properties. (line 28) * isFloat: Global Methods and Properties. (line 55) * isInt: Global Methods and Properties. (line 60) * isNaN: Global Methods and Properties. (line 26) * jmp: Byte-Code Operands. (line 247) * join on Array: Array. (line 52) * JS: JS. (line 7) * js_apply: Evaluation and Compilation. (line 31) * js_class_context: Classes. (line 26) * js_class_create: Classes. (line 9) * js_class_define_method: Classes. (line 32) * js_class_define_property: Classes. (line 41) * js_class_destroy: Classes. (line 21) * js_compile: Evaluation and Compilation. (line 36) * js_compile_data_to_byte_code: Evaluation and Compilation. (line 55) * js_compile_to_byte_code: Evaluation and Compilation. (line 45) * js_create_global_method: Defining Global Methods. (line 9) * js_create_interp: Interpreter Handling. (line 18) * js_define_class: Classes. (line 54) * js_define_module: Modules. (line 8) * js_destroy_interp: Interpreter Handling. (line 26) * js_error_message: Interpreter Handling. (line 31) * js_eval: Evaluation and Compilation. (line 7) * js_eval_data: Evaluation and Compilation. (line 15) * js_eval_file: Evaluation and Compilation. (line 18) * js_eval_javascript_file: Evaluation and Compilation. (line 23) * js_execute_byte_code: Evaluation and Compilation. (line 60) * js_execute_byte_code_file: Evaluation and Compilation. (line 27) * js_get_options: Interpreter Handling. (line 47) * js_get_var: Interpreter Handling. (line 44) * js_init_default_options: Interpreter Handling. (line 12) * js_instantiate_class: Classes. (line 62) * js_isa: Classes. (line 69) * js_lookup_class: Classes. (line 65) * js_result: Interpreter Handling. (line 34) * js_set_options: Interpreter Handling. (line 51) * js_set_var: Interpreter Handling. (line 41) * js_type_make_array: Type Handling. (line 13) * js_type_make_string: Type Handling. (line 8) * js_version: Interpreter Handling. (line 7) * JSC$compile_file: Public Entry Points. (line 7) * JSC$compile_string: Public Entry Points. (line 16) * jsr: Byte-Code Operands. (line 251) * jsr_w: Byte-Code Operands. (line 330) * lastIndex: RegExp. (line 170) * lastIndexOf on String: String. (line 109) * lastMatch: RegExp. (line 132) * lastParen: RegExp. (line 136) * leftContext: RegExp. (line 140) * length <1>: String. (line 158) * length: Array. (line 226) * lineBreakSequence: System. (line 90) * LN10: Math. (line 53) * LN2: Math. (line 55) * load: Global Methods and Properties. (line 65) * load_arg: Byte-Code Operands. (line 125) * load_array: Byte-Code Operands. (line 144) * load_global: Byte-Code Operands. (line 118) * load_global_w: Byte-Code Operands. (line 325) * load_local: Byte-Code Operands. (line 131) * load_nth_arg: Byte-Code Operands. (line 287) * load_property: Byte-Code Operands. (line 137) * loadClass: Global Methods and Properties. (line 70) * locals: Byte-Code Operands. (line 275) * log on Math: Math. (line 28) * LOG10E: Math. (line 57) * LOG2E: Math. (line 59) * lstat on File: File. (line 60) * MakeDate: Date. (line 17) * MakeDay: Date. (line 15) * MakeTime: Date. (line 13) * match on String: String. (line 125) * max on Math: Math. (line 30) * MAX_VALUE: Number. (line 47) * MD5: MD5. (line 7) * min on Math: Math. (line 32) * min_args: Byte-Code Operands. (line 281) * MIN_VALUE: Number. (line 49) * mod: Byte-Code Operands. (line 202) * mul: Byte-Code Operands. (line 194) * multiline: RegExp. (line 150) * NaN <1>: Global Methods and Properties. (line 10) * NaN: Number. (line 51) * neg: Byte-Code Operands. (line 206) * NEGATIVE_INFINITY: Number. (line 53) * new: Byte-Code Operands. (line 261) * nop: Byte-Code Operands. (line 63) * not: Byte-Code Operands. (line 213) * nth: Byte-Code Operands. (line 150) * Number: Number. (line 10) * numConstants: VM. (line 65) * numGlobals: VM. (line 68) * Object: Object. (line 16) * open on Directory: Directory. (line 14) * open on File: File. (line 144) * or: Byte-Code Operands. (line 217) * pack on String: String. (line 26) * parse on Date: Date. (line 57) * parseFloat: Global Methods and Properties. (line 20) * parseInt: Global Methods and Properties. (line 18) * PI: Math. (line 61) * pop: Byte-Code Operands. (line 69) * pop on Array: Array. (line 64) * pop_n: Byte-Code Operands. (line 72) * popen on System: System. (line 33) * POSITIVE_INFINITY: Number. (line 55) * pow on Math: Math. (line 34) * print: Global Methods and Properties. (line 35) * print on System: System. (line 35) * push on Array: Array. (line 74) * random on Math: Math. (line 36) * read on Directory: Directory. (line 16) * read on File: File. (line 168) * readByte on File: File. (line 172) * readln on File: File. (line 170) * RegExp: RegExp. (line 16) * remove on File: File. (line 65) * rename on File: File. (line 70) * replace on String: String. (line 127) * return: Byte-Code Operands. (line 255) * reverse on Array: Array. (line 86) * rewind on Directory: Directory. (line 18) * rightContext: RegExp. (line 152) * roll: Byte-Code Operands. (line 85) * round on Math: Math. (line 38) * search on String: String. (line 129) * seed on Math: Math. (line 40) * seek on Directory: Directory. (line 20) * setDate on Date: Date. (line 59) * setHours on Date: Date. (line 61) * setMinutes on Date: Date. (line 63) * setMonths on Date: Date. (line 65) * setPosition on File: File. (line 162) * setSeconds on Date: Date. (line 67) * setTime on Date: Date. (line 69) * setVar on JS: JS. (line 21) * setYear on Date: Date. (line 71) * shift on Array: Array. (line 94) * shift_left: Byte-Code Operands. (line 225) * shift_right: Byte-Code Operands. (line 229) * shift_rright: Byte-Code Operands. (line 233) * sin on Math: Math. (line 45) * sleep on System: System. (line 39) * slice on Array: Array. (line 102) * slice on String: String. (line 131) * sort on Array: Array. (line 139) * source: RegExp. (line 174) * splice on Array: Array. (line 120) * split on String: String. (line 133) * sqrt on Math: Math. (line 47) * SQRT1_2: Math. (line 63) * SQRT2: Math. (line 65) * stackSize: VM. (line 73) * stackTrace on VM: VM. (line 16) * stacktraceOnError: VM. (line 76) * stat on File: File. (line 75) * stderr: System. (line 100) * stdin: System. (line 108) * stdout: System. (line 111) * store_arg: Byte-Code Operands. (line 128) * store_array: Byte-Code Operands. (line 147) * store_global: Byte-Code Operands. (line 122) * store_local: Byte-Code Operands. (line 134) * store_property: Byte-Code Operands. (line 141) * strerror on System: System. (line 42) * String: String. (line 14) * stringToByte on File: File. (line 142) * sub: Byte-Code Operands. (line 187) * substr on String: String. (line 135) * substring on String: String. (line 137) * swap: Byte-Code Operands. (line 81) * system on System: System. (line 45) * tan on Math: Math. (line 49) * tell on Directory: Directory. (line 22) * test on RegExp: RegExp. (line 88) * throw: Byte-Code Operands. (line 304) * TimeClip: Date. (line 19) * toGMTString on Date: Date. (line 73) * toLocaleString on Date: Date. (line 75) * toLowerCase on String: String. (line 139) * toSource on Array: Array. (line 208) * toSource on Object: Object. (line 25) * toString on Array: Array. (line 210) * toString on Boolean: Boolean. (line 29) * toString on File: File. (line 174) * toString on Number: Number. (line 29) * toString on Object: Object. (line 23) * toUpperCase on String: String. (line 146) * try_pop: Byte-Code Operands. (line 301) * try_push: Byte-Code Operands. (line 297) * typeof: Byte-Code Operands. (line 258) * unescape: Global Methods and Properties. (line 24) * ungetByte on File: File. (line 182) * unpack on String: String. (line 153) * unshift on Array: Array. (line 218) * update on MD5: MD5. (line 36) * usleep on System: System. (line 47) * UTC on Date: Date. (line 33) * valueOf on Boolean: Boolean. (line 34) * valueOf on Number: Number. (line 44) * valueOf on Object: Object. (line 27) * verbose: VM. (line 80) * verboseStacktrace: VM. (line 83) * version: VM. (line 87) * versionMajor: VM. (line 90) * versionMinor: VM. (line 93) * versionPatch: VM. (line 96) * warnUndef: VM. (line 99) * with_pop: Byte-Code Operands. (line 294) * with_push: Byte-Code Operands. (line 291) * write on File: File. (line 176) * writeByte on File: File. (line 180) * writeln on File: File. (line 178) * xor: Byte-Code Operands. (line 221)  Tag Table: Node: Top1026 Node: Introduction1501 Node: NGS JavaScript Language1705 Node: Language1952 Node: Lexical Conventions2202 Node: White Space2497 Node: Comments2646 Node: Reserved Words2784 Node: Identifiers2934 Node: Punctuators3081 Node: Literals3222 Node: Automatic Semicolon Insertion3375 Node: Function Definition4377 Node: Statements4537 Node: Block5050 Node: Variable Statement5173 Node: Empty Statement5327 Node: The if Statement5486 Node: The do...while Statement5657 Node: The while Statement5852 Node: The for Statement6034 Node: The for...in Statement6210 Node: The continue Statement6403 Node: The break Statement6594 Node: The return Statement6779 Node: The with Statement6962 Node: The switch Statement7303 Node: Labeled Statements7485 Node: The throw Statement7660 Node: The try Statement7838 Node: Expressions7985 Node: Primary Expressions8457 Node: Left-Hand-Side Expressions8632 Node: Postfix Expressions8829 Node: Unary Operators9008 Node: Multiplicative Operators9177 Node: Additive Operators9363 Node: Bitwise Shift Operators9545 Node: Relational Operators9733 Node: Equality Operators9915 Node: Binary Bitwise Operators10094 Node: Binary Logical Operators10291 Node: Conditional Operator10490 Node: Assignment Operators10677 Node: Comma Operator10854 Node: Global Methods and Properties10990 Node: Native Objects14025 Node: Array14339 Node: Boolean21477 Node: Date22602 Node: File24253 Node: Directory28626 Node: Function29040 Node: Math29157 Node: Number30365 Node: Object31825 Node: RegExp32397 Node: String38646 Node: System43296 Node: VM47285 Node: Extensions50750 Node: Curses50906 Node: JS51012 Node: MD551458 Node: The js Program52987 Node: Invoking The js Program53445 Node: Evaluating and Executing Code63583 Node: Compiling JavaScript Code63794 Node: Warning Messages64459 Node: Optimization69415 Node: Debugging Information69579 Node: Assembler Listings71596 Node: The jsas Program73973 Node: Invoking The jsas Program74290 Node: The jsdas Program75193 Node: Invoking The jsdas Program75620 Node: Viewing Byte-Code Files77017 Node: Manipulating Byte-Code Files80386 Node: The jswrap Program81361 Node: Invoking The jswrap Program81744 Node: Definition File Format83278 Node: The Type Specifiers84797 Node: The Pass-Type Specifiers86293 Node: The Life Scope Specifiers87697 Node: Re-Entrant Functions88408 Node: Calling the Functions from C88598 Node: Sample Project88796 Node: JavaScript API89890 Node: Interpreter Handling90162 Node: Evaluation and Compilation92504 Node: Type Handling96140 Node: Defining Global Methods96732 Node: Classes97046 Node: Modules100289 Node: Virtual Machine100479 Node: Byte-Code File Format100693 Node: File Header100968 Node: Code Section101344 Node: Constants Section101495 Node: Symtab Section102273 Node: Debug Section102432 Node: Byte-Code Operands102563 Node: Stack Frame114607 Node: JavaScript Compiler115432 Node: Public Entry Points116972 Node: GNU Library General Public License122019 Node: Index149031  End Tag Table