Definition at line 97 of file wmlsdasm.c.
References WsBcFunctionRec::code, WsBcFunctionRec::code_size, WsBcRec::constants, WsBcRec::function_names, WsBcRec::functions, getopt(), WsBcFunctionNameRec::index, lookup_function(), WsBcFunctionNameRec::name, name, WsBcRec::num_constants, WsBcRec::num_function_names, WsBcRec::num_functions, WsBcRec::num_pragmas, optind, program, WsBcConstantRec::type, WsBcConstantRec::u, usage(), WsBcConstantRec::v_float, WsBcConstantRec::v_int, WsBcConstantRec::v_string, ws_asm_dasm(), WS_BC_CONST_TYPE_EMPTY_STRING, WS_BC_CONST_TYPE_FLOAT32, WS_BC_CONST_TYPE_FLOAT32_NAN, WS_BC_CONST_TYPE_FLOAT32_NEGATIVE_INF, WS_BC_CONST_TYPE_FLOAT32_POSITIVE_INF, WS_BC_CONST_TYPE_INT, WS_BC_CONST_TYPE_UTF8_STRING, ws_bc_decode(), ws_bc_free(), ws_create(), ws_destroy(), WS_FALSE, ws_malloc(), WS_TRUE, and ws_utf8_get_char().
107 program = strrchr(argv[0],
'/');
114 while ((opt =
getopt(argc, argv,
"cfnh")) != EOF) {
125 print_function_names =
WS_TRUE;
134 printf(
"Try `%s -h' for a complete list of options.\n",
140 for (i =
optind; i < argc; i++) {
147 if (stat(argv[i], &stat_st) < 0) {
148 fprintf(stderr,
"%s: could not access `%s': %s\n",
149 program, argv[i], strerror(errno));
152 data_len = stat_st.st_size;
156 fprintf(stderr,
"%s: out of memory: %s\n",
161 fp = fopen(argv[i],
"rb");
163 fprintf(stderr,
"%s: could not open input file `%s': %s\n",
164 program, argv[i], strerror(errno));
168 if (fread(data, 1, data_len, fp) != data_len) {
169 fprintf(stderr,
"%s: could not read file `%s': %s\n",
170 program, argv[i], strerror(errno));
178 fprintf(stderr,
"%s: invalid byte-code file `%s'\n",
184 printf(
"\n%s:\t%lu bytes\n\n", argv[i], (
unsigned long) data_len);
186 if (print_constants) {
187 printf(
"Disassembly of section Constants:\n\n");
204 printf(
"+infinity\n");
208 printf(
"-infinity\n");
222 printf(
"\\%02lx", ch);
224 }
else if (ch <= 0xff) {
225 printf(
"%c", (
unsigned char) ch);
228 printf(
"\\u%04lx", ch);
247 if (print_function_names) {
248 printf(
"Disassembly of section Function names:\n\n");
250 printf(
" %-40.40s%8d\n",
255 if (print_functions) {
258 printf(
"Disassembly of section Functions:\n");
263 printf(
"\nFunction %u", (
unsigned int) k);
266 printf(
" <%s>",
name);
277 if (!print_constants && !print_function_names && !print_functions) {
282 Function names\t%8d\n\
WsCompilerPtr ws_create(WsCompilerParams *params)
WsBcFunctionName * function_names
int getopt(int argc, char **argv, char *opts)
WsUInt8 num_function_names
void ws_destroy(WsCompilerPtr compiler)
void ws_bc_free(WsBc *bc)
void ws_asm_dasm(WsCompilerPtr compiler, const unsigned char *code, size_t len)
int ws_utf8_get_char(const WsUtf8String *string, unsigned long *ch_return, size_t *posp)
union WsBcConstantRec::@116 u
const char * lookup_function(WsBc *bc, WsUInt8 index)
void * ws_malloc(size_t size)
WsBc * ws_bc_decode(const unsigned char *data, size_t data_len)