2 * Assembler for JavaScript assembler.
3 * Copyright (c) 1998 New Generation Software (NGS) Oy
5 * Author: Markku Rossi <mtr@ngs.fi>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
19 * You should have received a copy of the GNU Library General Public
20 * License along with this library; if not, write to the Free
21 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
26 * $Source: /cygdrive/c/RCVS/CVS/ReactOS/reactos/lib/kjs/jsas/main.js,v $
31 * Variables and definitions.
34 version_number
= "0.0.1";
43 * Generate debugging information.
51 * Print short help and exit successfully.
57 * Optimize the assembler.
65 * Tell what we are doing.
73 * Print version information and exit successfully.
82 var idx
= ARGS
[0].lastIndexOf ("/");
84 program
= ARGS
[0].substr (idx
+ 1);
88 /* Handle arguments. */
90 for (i
= 1; i
< ARGS
.length
; i
++)
92 if (ARGS
[i
][0] == #'-')
94 if (ARGS
[i
] == "-g" || ARGS
[i
] == "--debug")
96 else if (ARGS
[i
] == "-h" || ARGS
[i
] == "--help")
101 else if (ARGS
[i
] == "-O" || ARGS
[i
] == "--optimize")
103 else if (ARGS
[i
] == "-v" || ARGS
[i
] == "--verbose")
105 else if (ARGS
[i
] == "-V" || ARGS
[i
] == "--version")
112 /* Unrecognized option. */
113 System
.error (program
, ": unrecognized option `",
115 System
.error ("Try `", program
,
116 " --help' for more information.\n");
122 /* End of arguments. */
127 if (i
>= ARGS
.length
)
129 System
.error (program
, ": no files specified\n");
135 JSC
$verbose
= opt_verbose
;
136 JSC
$generate_debug_info
= opt_debug
;
139 for (; i
< ARGS
.length
; i
++)
141 /* Reset the JSC's assembler package. */
144 /* Process the input file. */
145 JSC
$filename
= ARGS
[i
];
146 process_file (JSC
$filename
);
149 JSC
$asm_optimize (JSC
$FLAG_OPTIMIZE_MASK
);
153 var result
= JSC
$asm_bytecode ();
155 /* Create the output file name. */
156 var oname
= ARGS
[i
].replace (/\.jas$/, ".jsc");
157 if (oname
== ARGS
[i
])
160 var ostream
= new File (oname
);
161 if (ostream
.open ("w"))
163 ostream
.write (result
);
168 System
.stderr
.writeln ("jsas: couldn't create bc file `"
170 + System
.strerror (System
.errno
));
179 Usage: ", program
, " [OPTION]... FILE...\n\
180 Mandatory arguments to long options are mandatory for short options too.\n");
183 -g, --debug generate debugging information\n\
184 -h, --help print this help and exit\n\
185 -O, --optimize optimize the assembler code\n\
186 -v, --verbose tell what the assembler is doing\n\
187 -V, --version print version number\n\
190 System
.print ("\nReport bugs to mtr@ngs.fi.\n");
195 System
.print ("NGS JavaScript assembler ", version_number
, "\n");
197 Copyright (C) 1998 New Generation Software (NGS) Oy.\n\
198 NGS JavaScript Interpreter comes with NO WARRANTY, to the extent\n\
199 permitted by law. You may redistribute copies of NGS JavaScript\n\
200 Interpreter under the terms of the GNU Library General Public License.\n\
201 For more information about these matters, see the files named COPYING.\n\