| 152 | } |
| 153 | |
| 154 | static void output_object_code(JSContext *ctx, |
| 155 | FILE *fo, JSValue obj, const char *c_name, |
| 156 | bool load_only) |
| 157 | { |
| 158 | uint8_t *out_buf; |
| 159 | size_t out_buf_len; |
| 160 | int flags = JS_WRITE_OBJ_BYTECODE; |
| 161 | |
| 162 | if (strip) { |
| 163 | flags |= JS_WRITE_OBJ_STRIP_SOURCE; |
| 164 | if (strip > 1) |
| 165 | flags |= JS_WRITE_OBJ_STRIP_DEBUG; |
| 166 | } |
| 167 | |
| 168 | out_buf = JS_WriteObject(ctx, &out_buf_len, obj, flags); |
| 169 | if (!out_buf) { |
| 170 | js_std_dump_error(ctx); |
| 171 | exit(1); |
| 172 | } |
| 173 | |
| 174 | namelist_add(&cname_list, c_name, NULL, load_only); |
| 175 | |
| 176 | if (output_type == OUTPUT_RAW) { |
| 177 | fwrite(out_buf, 1, out_buf_len, fo); |
| 178 | } else { |
| 179 | fprintf(fo, "const uint32_t %s_size = %u;\n\n", |
| 180 | c_name, (unsigned int)out_buf_len); |
| 181 | fprintf(fo, "const uint8_t %s[%u] = {\n", |
| 182 | c_name, (unsigned int)out_buf_len); |
| 183 | dump_hex(fo, out_buf, out_buf_len); |
| 184 | fprintf(fo, "};\n\n"); |
| 185 | } |
| 186 | |
| 187 | js_free(ctx, out_buf); |
| 188 | } |
| 189 | |
| 190 | static int js_module_dummy_init(JSContext *ctx, JSModuleDef *m) |
| 191 | { |
no test coverage detected