📄 jsdas.js
字号:
DASM$op_names = new Array ();
DASM$op_data = new Array ();
DASM$op_flags = new Array ();
DASM$op_names[0] = "halt";
DASM$op_data[0] = 0;
DASM$op_flags[0] = 0x0;
DASM$op_names[1] = "done";
DASM$op_data[1] = 0;
DASM$op_flags[1] = 0x0;
DASM$op_names[2] = "nop";
DASM$op_data[2] = 0;
DASM$op_flags[2] = 0x0;
DASM$op_names[3] = "dup";
DASM$op_data[3] = 0;
DASM$op_flags[3] = 0x0;
DASM$op_names[4] = "pop";
DASM$op_data[4] = 0;
DASM$op_flags[4] = 0x0;
DASM$op_names[5] = "pop_n";
DASM$op_data[5] = 1;
DASM$op_flags[5] = 0x0;
DASM$op_names[6] = "apop";
DASM$op_data[6] = 1;
DASM$op_flags[6] = 0x0;
DASM$op_names[7] = "swap";
DASM$op_data[7] = 0;
DASM$op_flags[7] = 0x0;
DASM$op_names[8] = "roll";
DASM$op_data[8] = 1;
DASM$op_flags[8] = 0x0;
DASM$op_names[9] = "const";
DASM$op_data[9] = 4;
DASM$op_flags[9] = 0x0;
DASM$op_names[10] = "const_null";
DASM$op_data[10] = 0;
DASM$op_flags[10] = 0x0;
DASM$op_names[11] = "const_true";
DASM$op_data[11] = 0;
DASM$op_flags[11] = 0x0;
DASM$op_names[12] = "const_false";
DASM$op_data[12] = 0;
DASM$op_flags[12] = 0x0;
DASM$op_names[13] = "const_undefined";
DASM$op_data[13] = 0;
DASM$op_flags[13] = 0x0;
DASM$op_names[14] = "const_i0";
DASM$op_data[14] = 0;
DASM$op_flags[14] = 0x0;
DASM$op_names[15] = "const_i1";
DASM$op_data[15] = 0;
DASM$op_flags[15] = 0x0;
DASM$op_names[16] = "const_i2";
DASM$op_data[16] = 0;
DASM$op_flags[16] = 0x0;
DASM$op_names[17] = "const_i3";
DASM$op_data[17] = 0;
DASM$op_flags[17] = 0x0;
DASM$op_names[18] = "const_i";
DASM$op_data[18] = 4;
DASM$op_flags[18] = 0x0;
DASM$op_names[19] = "load_global";
DASM$op_data[19] = 4;
DASM$op_flags[19] = 0x1;
DASM$op_names[20] = "store_global";
DASM$op_data[20] = 4;
DASM$op_flags[20] = 0x1;
DASM$op_names[21] = "load_arg";
DASM$op_data[21] = 1;
DASM$op_flags[21] = 0x0;
DASM$op_names[22] = "store_arg";
DASM$op_data[22] = 1;
DASM$op_flags[22] = 0x0;
DASM$op_names[23] = "load_local";
DASM$op_data[23] = 2;
DASM$op_flags[23] = 0x0;
DASM$op_names[24] = "store_local";
DASM$op_data[24] = 2;
DASM$op_flags[24] = 0x0;
DASM$op_names[25] = "load_property";
DASM$op_data[25] = 4;
DASM$op_flags[25] = 0x1;
DASM$op_names[26] = "store_property";
DASM$op_data[26] = 4;
DASM$op_flags[26] = 0x1;
DASM$op_names[27] = "load_array";
DASM$op_data[27] = 0;
DASM$op_flags[27] = 0x0;
DASM$op_names[28] = "store_array";
DASM$op_data[28] = 0;
DASM$op_flags[28] = 0x0;
DASM$op_names[29] = "nth";
DASM$op_data[29] = 0;
DASM$op_flags[29] = 0x0;
DASM$op_names[30] = "cmp_eq";
DASM$op_data[30] = 0;
DASM$op_flags[30] = 0x0;
DASM$op_names[31] = "cmp_ne";
DASM$op_data[31] = 0;
DASM$op_flags[31] = 0x0;
DASM$op_names[32] = "cmp_lt";
DASM$op_data[32] = 0;
DASM$op_flags[32] = 0x0;
DASM$op_names[33] = "cmp_gt";
DASM$op_data[33] = 0;
DASM$op_flags[33] = 0x0;
DASM$op_names[34] = "cmp_le";
DASM$op_data[34] = 0;
DASM$op_flags[34] = 0x0;
DASM$op_names[35] = "cmp_ge";
DASM$op_data[35] = 0;
DASM$op_flags[35] = 0x0;
DASM$op_names[36] = "cmp_seq";
DASM$op_data[36] = 0;
DASM$op_flags[36] = 0x0;
DASM$op_names[37] = "cmp_sne";
DASM$op_data[37] = 0;
DASM$op_flags[37] = 0x0;
DASM$op_names[38] = "sub";
DASM$op_data[38] = 0;
DASM$op_flags[38] = 0x0;
DASM$op_names[39] = "add";
DASM$op_data[39] = 0;
DASM$op_flags[39] = 0x0;
DASM$op_names[40] = "mul";
DASM$op_data[40] = 0;
DASM$op_flags[40] = 0x0;
DASM$op_names[41] = "div";
DASM$op_data[41] = 0;
DASM$op_flags[41] = 0x0;
DASM$op_names[42] = "mod";
DASM$op_data[42] = 0;
DASM$op_flags[42] = 0x0;
DASM$op_names[43] = "neg";
DASM$op_data[43] = 0;
DASM$op_flags[43] = 0x0;
DASM$op_names[44] = "and";
DASM$op_data[44] = 0;
DASM$op_flags[44] = 0x0;
DASM$op_names[45] = "not";
DASM$op_data[45] = 0;
DASM$op_flags[45] = 0x0;
DASM$op_names[46] = "or";
DASM$op_data[46] = 0;
DASM$op_flags[46] = 0x0;
DASM$op_names[47] = "xor";
DASM$op_data[47] = 0;
DASM$op_flags[47] = 0x0;
DASM$op_names[48] = "shift_left";
DASM$op_data[48] = 0;
DASM$op_flags[48] = 0x0;
DASM$op_names[49] = "shift_right";
DASM$op_data[49] = 0;
DASM$op_flags[49] = 0x0;
DASM$op_names[50] = "shift_rright";
DASM$op_data[50] = 0;
DASM$op_flags[50] = 0x0;
DASM$op_names[51] = "iffalse";
DASM$op_data[51] = 4;
DASM$op_flags[51] = 0x2;
DASM$op_names[52] = "iftrue";
DASM$op_data[52] = 4;
DASM$op_flags[52] = 0x2;
DASM$op_names[53] = "call_method";
DASM$op_data[53] = 4;
DASM$op_flags[53] = 0x1;
DASM$op_names[54] = "jmp";
DASM$op_data[54] = 4;
DASM$op_flags[54] = 0x2;
DASM$op_names[55] = "jsr";
DASM$op_data[55] = 0;
DASM$op_flags[55] = 0x0;
DASM$op_names[56] = "return";
DASM$op_data[56] = 0;
DASM$op_flags[56] = 0x0;
DASM$op_names[57] = "typeof";
DASM$op_data[57] = 0;
DASM$op_flags[57] = 0x0;
DASM$op_names[58] = "new";
DASM$op_data[58] = 0;
DASM$op_flags[58] = 0x0;
DASM$op_names[59] = "delete_property";
DASM$op_data[59] = 4;
DASM$op_flags[59] = 0x1;
DASM$op_names[60] = "delete_array";
DASM$op_data[60] = 0;
DASM$op_flags[60] = 0x0;
DASM$op_names[61] = "locals";
DASM$op_data[61] = 2;
DASM$op_flags[61] = 0x0;
DASM$op_names[62] = "min_args";
DASM$op_data[62] = 1;
DASM$op_flags[62] = 0x0;
DASM$op_names[63] = "load_nth_arg";
DASM$op_data[63] = 0;
DASM$op_flags[63] = 0x0;
DASM$op_names[64] = "with_push";
DASM$op_data[64] = 0;
DASM$op_flags[64] = 0x0;
DASM$op_names[65] = "with_pop";
DASM$op_data[65] = 1;
DASM$op_flags[65] = 0x0;
DASM$op_names[66] = "try_push";
DASM$op_data[66] = 4;
DASM$op_flags[66] = 0x2;
DASM$op_names[67] = "try_pop";
DASM$op_data[67] = 1;
DASM$op_flags[67] = 0x0;
DASM$op_names[68] = "throw";
DASM$op_data[68] = 0;
DASM$op_flags[68] = 0x0;
DASM$op_names[69] = "iffalse_b";
DASM$op_data[69] = 4;
DASM$op_flags[69] = 0x2;
DASM$op_names[70] = "iftrue_b";
DASM$op_data[70] = 4;
DASM$op_flags[70] = 0x2;
DASM$op_names[71] = "add_1_i";
DASM$op_data[71] = 0;
DASM$op_flags[71] = 0x0;
DASM$op_names[72] = "add_2_i";
DASM$op_data[72] = 0;
DASM$op_flags[72] = 0x0;
DASM$op_names[73] = "load_global_w";
DASM$op_data[73] = 4;
DASM$op_flags[73] = 0x1;
DASM$op_names[74] = "jsr_w";
DASM$op_data[74] = 4;
DASM$op_flags[74] = 0x1;
/*
* Disassembler for JavaScript byte-code files.
* Copyright (c) 1998 New Generation Software (NGS) Oy
*
* Author: Markku Rossi <mtr@ngs.fi>
*/
/*
* 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, Boston,
* MA 02111-1307, USA
*/
/*
* $Source: /cygdrive/c/RCVS/CVS/ReactOS/reactos/lib/kjs/jsdas/jsdas.js,v $
* $Id: jsdas.js 21681 2006-04-21 15:00:24Z peterw $
*/
/*
* Variables and definitions.
*/
version_number = "0.0.1";
/*
* Options.
*/
/*
* -c, --code
*
* Print code section.
*/
opt_code = false;
/*
* -C, --constants
*
* Print constants section.
*/
opt_constants = false;
/*
* -d, --debug
*
* Print the debug section.
*/
opt_debug = false;
/*
* -h, --help
*
* Print short help and exit successfully.
*/
/*
* -i, --info
*
* Show general information about the file.
*/
opt_info = false;
/*
* -l TYPE DATA, --link TYPE DATA
*
* Link a new section to the byte-code file. The new section's type is
* TYPE and its data is in file DATA.
*/
opt_link = false;
opt_link_type = 0;
opt_link_data = "";
/*
* -r TYPE, --remove TYPE
*
* Remove section TYPE.
*/
opt_remove = false;
opt_remove_type = 0;
/*
* -s, --symtab
*
* Print symtab section.
*/
opt_symtab = false;
/*
* -S, --strip
*
* Remove the debug section from byte-code files.
*/
/*
* -V, --version
*
* Print version information and exit successfully.
*/
/*
* Functions.
*/
function main ()
{
var opt_default = true;
var idx = ARGS[0].lastIndexOf ("/");
if (idx >= 0)
program = ARGS[0].substr (idx + 1);
else
program = ARGS[0];
/* Handle arguments. */
var i;
for (i = 1; i < ARGS.length; i++)
{
if (ARGS[i][0] == #'-')
{
if (ARGS[i] == "-c" || ARGS[i] == "--code")
{
opt_code = true;
opt_default = false;
}
else if (ARGS[i] == "-C" || ARGS[i] == "--constants")
{
opt_constants = true;
opt_default = false;
}
else if (ARGS[i] == "-d" || ARGS[i] == "--debug")
{
opt_debug = true;
opt_default = false;
}
else if (ARGS[i] == "-i" || ARGS[i] == "--info")
{
opt_info = true;
opt_default = false;
}
else if (ARGS[i] == "-l" || ARGS[i] == "--link")
{
opt_link = true;
opt_default = false;
if (i + 2 >= ARGS.length)
{
System.error (program, ": no arguments for option --link\n");
System.exit (1);
}
opt_link_type = parseInt (ARGS[++i]);
if (isNaN (opt_link_type))
{
System.error (program, ": illegal section type `",
ARGS[i], "'\n");
System.exit (1);
}
opt_link_data = (ARGS[++i]);
}
else if (ARGS[i] == "-r" || ARGS[i] == "--remove")
{
opt_remove = true;
opt_default = false;
if (i + 1 >= ARGS.length)
{
System.error (program,
": no arguments for option --remove\n");
System.exit (1);
}
opt_remove_type = parseInt (ARGS[++i]);
if (isNaN (opt_remove_type))
{
System.error (program, ": illegal section type `",
ARGS[i], "'\n");
System.exit (1);
}
}
else if (ARGS[i] == "-s" || ARGS[i] == "--symtab")
{
opt_symtab = true;
opt_default = false;
}
else if (ARGS[i] == "-S" || ARGS[i] == "--strip")
{
opt_remove = true;
opt_default = false;
opt_remove_type = JSC$BC_SECT_DEBUG;
}
else if (ARGS[i] == "-h" || ARGS[i] == "--help")
{
usage ();
System.exit (0);
}
else if (ARGS[i] == "-V" || ARGS[i] == "--version")
{
version ();
System.exit (0);
}
else
{
/* Unrecognized option. */
System.error (program, ": unrecognized option `",
ARGS[i], "'\n");
System.error ("Try `", program,
" --help' for more information.\n");
System.exit (1);
}
}
else
{
/* End of arguments. */
break;
}
}
if (i >= ARGS.length)
{
System.error (program, ": no files specified\n");
System.exit (1);
}
/* Process files. */
var first = true;
for (; i < ARGS.length; i++)
{
if (first)
first = false;
else
System.print ("\n");
System.print (ARGS[i], ":\n");
var is = new File (ARGS[i]);
if (is.open ("r"))
{
var bc = new ByteCode ();
var result = bc.parse (is);
is.close ();
if (!result)
System.print (program, ": couldn't parse byte-code file `",
ARGS[i], "'\n");
else
{
var write_back = false;
if (opt_info)
{
System.print ("\n* byte-code file information\n\n");
bc.printInfo ();
}
if (opt_constants)
{
System.print ("\n* section `Constants'\n\n");
bc.printConstants ();
}
if (opt_default || opt_code)
{
System.print ("\n* section `Code'\n\n");
bc.printCode ();
}
if (opt_symtab)
{
System.print ("\n* section `Symtab'\n\n");
bc.printSymtab ();
}
if (opt_debug)
{
System.print ("\n* section `Debug'\n\n");
bc.printDebug ();
}
if (opt_link)
{
var df = new File (opt_link_data);
if (df.open ("r"))
{
var len = df.getLength ();
var data = df.read (len);
df.close ();
if (data.length < len)
System.error (program,
": couldn't read data from file `",
opt_link_data, "': ",
System.strerror (System.errno), "\n");
else
{
System.print (program, ": linking ", data.length,
" bytes of data to section ",
opt_link_type.toString (), "\n");
bc.linkSection (opt_link_type, data);
write_back = true;
}
}
else
System.error (program, ": couldn't open data file `",
opt_link_data, "': ",
System.strerror (System.errno), "\n");
}
if (opt_remove)
{
System.print (program, ": removing section ",
opt_remove_type, "\n");
if (bc.removeSection (opt_remove_type))
write_back = true;
}
if (write_back)
{
/* Write the byte-code file back to its original file. */
if (!bc.write (ARGS[i]))
{
System.error (program, ": write failed: ",
System.strerror (System.errno),
"\n");
System.exit (1);
}
}
}
}
else
System.error (program, ": couldn't open bc file `", ARGS[i], "': ",
System.strerror (System.errno), "\n");
}
}
function usage ()
{
System.print ("\
Usage: ", program, " [OPTION]... FILE...\n\
Mandatory arguments to long options are mandatory for short options too.\n");
System.print ("\
-c, --code print code section (default)\n\
-C, --constants print constants section\n\
-d, --debug print debug section\n\
-h, --help print this help and exit\n\
-i, --info print the byte-code file header and general\n\
information about the sections\n\
-l, --link TYPE DATA link data from file DATA to section TYPE\n\
-r, --remove TYPE remove section TYPE\n\
-s, --symtab print symtab section\n\
-S, --strip remove debug section\n\
-V, --version print version number\n\
");
System.print ("\nReport bugs to mtr@ngs.fi.\n");
}
function version ()
{
System.print ("NGS JavaScript disassembler ", version_number, "\n");
System.print ("\
Copyright (C) 1998 New Generation Software (NGS) Oy.\n\
NGS JavaScript Interpreter comes with NO WARRANTY, to the extent\n\
permitted by law. You may redistribute copies of NGS JavaScript\n\
Interpreter under the terms of the GNU Library General Public License.\n\
For more information about these matters, see the files named COPYING.\n\
");
}
main ();
/*
Local variables:
mode: c
End:
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -