Ticket #266: tt266+258-todo-read_pbc.patch
File tt266+258-todo-read_pbc.patch, 42.2 KB (added by rurban, 13 years ago) |
---|
-
src/embed.c
374 374 375 375 /* 376 376 377 =item C<PackFile * Parrot_ readbc>377 =item C<PackFile * Parrot_pbc_read> 378 378 379 379 Read in a bytecode, unpack it into a C<PackFile> structure, and do fixups. 380 380 … … 385 385 PARROT_EXPORT 386 386 PARROT_CAN_RETURN_NULL 387 387 PackFile * 388 Parrot_ readbc(PARROT_INTERP, ARGIN_NULLOK(const char *fullname))388 Parrot_pbc_read(PARROT_INTERP, ARGIN_NULLOK(const char *fullname), int options) 389 389 { 390 390 FILE *io = NULL; 391 391 INTVAL is_mapped = 0; … … 527 527 528 528 pf = PackFile_new(interp, is_mapped); 529 529 530 /* Make the cmdline option available to the unpackers */ 531 pf->options = options; 532 530 533 if (!PackFile_unpack(interp, pf, (opcode_t *)program_code, 531 534 (size_t)program_size)) { 532 535 Parrot_io_eprintf(interp, "Parrot VM: Can't unpack packfile %s.\n", … … 555 558 556 559 /* 557 560 558 =item C<void Parrot_ loadbc>561 =item C<void Parrot_pbc_load> 559 562 560 Loads the C<PackFile> returned by C<Parrot_ readbc()>.563 Loads the C<PackFile> returned by C<Parrot_pbc_read()>. 561 564 562 565 =cut 563 566 … … 565 568 566 569 PARROT_EXPORT 567 570 void 568 Parrot_ loadbc(PARROT_INTERP, NOTNULL(PackFile *pf))571 Parrot_pbc_load(PARROT_INTERP, NOTNULL(PackFile *pf)) 569 572 { 570 573 if (pf == NULL) { 571 574 Parrot_io_eprintf(interp, "Invalid packfile\n"); … … 1040 1043 INTVAL i; 1041 1044 1042 1045 /* TODO: would be nice to print the name of the file as well */ 1043 Parrot_io_printf(interp, " Constant-table\n");1046 Parrot_io_printf(interp, "=head1 Constant-table\n\n"); 1044 1047 1045 1048 for (i = 0; i < numconstants; ++i) { 1046 1049 PackFile_Constant *c = interp->code->const_table->constants[i]; … … 1110 1113 } 1111 1114 } 1112 1115 1113 Parrot_io_printf(interp, "\n ");1116 Parrot_io_printf(interp, "\n=cut\n\n"); 1114 1117 } 1115 1118 1116 1119 … … 1128 1131 1129 1132 PARROT_EXPORT 1130 1133 void 1131 Parrot_disassemble(PARROT_INTERP )1134 Parrot_disassemble(PARROT_INTERP, char *outfile, Parrot_disassemble_options options) 1132 1135 { 1133 1136 PDB_line_t *line; 1134 1137 PDB_t *pdb = mem_allocate_zeroed_typed(PDB_t); … … 1146 1149 debugs = (interp->code->debugs != NULL); 1147 1150 1148 1151 print_constant_table(interp); 1152 if (options & enum_DIS_HEADER) 1153 return; 1149 1154 1150 Parrot_io_printf(interp, "%12s-%12s", "Seq_Op_Num", "Relative-PC"); 1155 if (!(options & enum_DIS_BARE)) 1156 Parrot_io_printf(interp, "# %12s-%12s", "Seq_Op_Num", "Relative-PC"); 1151 1157 1152 1158 if (debugs) { 1153 Parrot_io_printf(interp, " %6s:\n", "SrcLn#"); 1159 if (!(options & enum_DIS_BARE)) 1160 Parrot_io_printf(interp, " %6s:\n", "SrcLn#"); 1154 1161 num_mappings = interp->code->debugs->num_mappings; 1155 1162 } 1156 1163 else { … … 1168 1175 if (op_code_seq_num == interp->code->debugs->mappings[curr_mapping]->offset) { 1169 1176 const int filename_const_offset = 1170 1177 interp->code->debugs->mappings[curr_mapping]->filename; 1171 Parrot_io_printf(interp, " Current Source Filename %Ss\n",1178 Parrot_io_printf(interp, "# Current Source Filename '%Ss'\n", 1172 1179 interp->code->const_table->constants[filename_const_offset]->u.string); 1173 1180 curr_mapping++; 1174 1181 } 1175 1182 } 1176 1183 1177 Parrot_io_printf(interp, "%012i-%012i", 1178 op_code_seq_num, line->opcode - interp->code->base.data); 1184 if (!(options & enum_DIS_BARE)) 1185 Parrot_io_printf(interp, "%012i-%012i", 1186 op_code_seq_num, line->opcode - interp->code->base.data); 1179 1187 1180 if (debugs )1188 if (debugs && !(options & enum_DIS_BARE)) 1181 1189 Parrot_io_printf(interp, " %06i: ", 1182 1190 interp->code->debugs->base.data[op_code_seq_num]); 1183 1191 … … 1231 1239 pf->cur_cs->base.data = program_code; 1232 1240 pf->cur_cs->base.size = 2; 1233 1241 1234 Parrot_ loadbc(interp, pf);1242 Parrot_pbc_load(interp, pf); 1235 1243 1236 1244 run_native = func; 1237 1245 -
src/pbc_info.c
70 70 71 71 interp = Parrot_new(NULL); 72 72 73 pf = Parrot_ readbc(interp, argv[1]);73 pf = Parrot_pbc_read(interp, argv[1], 0); 74 74 75 75 /* 76 76 * add some more segments -
src/pbc_merge.c
228 228 =item C<static PackFile* pbc_merge_loadpbc> 229 229 230 230 This function loads a PBC file and unpacks it. We can't 231 use Parrot_ readbcbecause that is specified to also231 use Parrot_pbc_read because that is specified to also 232 232 fixup the segments, which we don't want. 233 233 234 234 =cut -
src/exec_start.c
81 81 printf("Can't unpack.\n"); 82 82 return 1; 83 83 } 84 Parrot_ loadbc(interp, pf);84 Parrot_pbc_load(interp, pf); 85 85 PackFile_fixup_subs(interp, PBC_PBC, NULL); 86 86 87 87 /* opcode_map has the offset of each opcode in the compiled code -
src/parrot_debugger.c
181 181 ext = strrchr(filename, '.'); 182 182 183 183 if (ext && STREQ(ext, ".pbc")) { 184 Parrot_PackFile pf = Parrot_ readbc(interp, filename);184 Parrot_PackFile pf = Parrot_pbc_read(interp, filename, 0); 185 185 186 186 if (!pf) 187 187 return 1; 188 188 189 Parrot_ loadbc(interp, pf);189 Parrot_pbc_load(interp, pf); 190 190 PackFile_fixup_subs(interp, PBC_MAIN, NULL); 191 191 } 192 192 else { 193 193 Parrot_PackFile pf = PackFile_new(interp, 0); 194 194 int pasm_file = 0; 195 195 196 Parrot_ loadbc(interp, pf);196 Parrot_pbc_load(interp, pf); 197 197 198 198 IMCC_push_parser_state(interp); 199 199 IMCC_INFO(interp)->state->file = filename; -
src/pbc_disassemble.c
8 8 9 9 =head1 SYNOPSIS 10 10 11 pbc_disassemble file.pbc11 pbc_disassemble [-bh?] [-o outfile] [file.pbc] 12 12 13 13 =head1 DESCRIPTION 14 14 … … 16 16 which in turn uses the C<PDB_disassemble()> function from 17 17 F<src/debug.c>. 18 18 19 Without non-option arguments it reads the pbc from STDIN. 20 19 21 =head2 Functions 20 22 21 23 =over 4 … … 30 32 #include <stdlib.h> 31 33 #include <ctype.h> 32 34 33 static void do_dis(Parrot_Interp );35 static void do_dis(Parrot_Interp, char *, Parrot_disassemble_options); 34 36 35 37 /* 36 38 39 =item C<static void help(void)> 40 41 Print out the user help info. 42 43 =cut 44 45 */ 46 47 static void help(void) 48 { 49 printf("pbc_disassemble - dump or convert parrot bytecode (PBC) files\n"); 50 printf("usage:\n"); 51 printf("pbc_disassemble [-bh] [--bare|--header-only] [file.pbc]\n"); 52 printf("pbc_disassemble -o converted.pasm file.pbc\n\n"); 53 printf(" -b\t\t bare .pasm without header and left column\n"); 54 printf(" -h\t\t dump Constant-table header only\n"); 55 printf(" -d\t\t debug output for the pbc reader\n"); 56 printf(" -o filename\t ... output to filename\n"); 57 exit(EXIT_SUCCESS); 58 } 59 60 static struct longopt_opt_decl options[] = { 61 { 'h', 'h', OPTION_optional_FLAG, { "--header-only" } }, 62 { '?', '?', OPTION_optional_FLAG, { "--help" } }, 63 { 'b', 'b', OPTION_optional_FLAG, { "--bare" } }, 64 { 'd', 'd', OPTION_optional_FLAG, { "--debug" } }, 65 { 'o', 'o', OPTION_required_FLAG, { "--output" } } 66 }; 67 68 /* 69 37 70 =item C<int main(int argc, char *argv[])> 38 71 39 72 The run-loop. Starts up an interpreter, loads the bytecode from the … … 46 79 int 47 80 main(int argc, char *argv[]) 48 81 { 82 Parrot_PackFile pf; 49 83 Parrot_Interp interp; 50 char *filename; 51 Parrot_PackFile pf; 84 char *outfile = NULL; 85 int option = 0; 86 int debug = 0; 87 struct longopt_opt_info opt = LONGOPT_OPT_INFO_INIT; 88 int status; 52 89 53 90 interp = Parrot_new(NULL); 54 55 91 if (!interp) { 56 92 return 1; 57 93 } 58 59 /* set the top of the stack so GC can trace it for GC-able pointers 60 * see trace_system_areas() in src/cpu_dep.c */ 61 interp->lo_var_ptr = &interp; 62 63 if (argc != 2) { 64 fprintf(stderr, "Usage: pbc_disassemble programfile \n"); 65 Parrot_exit(interp, 1); 94 /* init and set top of stack */ 95 Parrot_init_stacktop(interp, &status); 96 while ((status = longopt_get(interp, 97 argc, argv, options, &opt)) > 0) { 98 switch (opt.opt_id) { 99 case 'h': 100 option += enum_DIS_HEADER; 101 break; 102 case 'b': 103 option += enum_DIS_BARE; 104 break; 105 case 'd': 106 debug = 1; 107 break; 108 case 'o': 109 outfile = opt.opt_arg; 110 break; 111 case '?': 112 default: 113 help(); 114 break; 115 } 66 116 } 117 if (status == -1) { 118 help(); 119 } 120 argc -= opt.opt_index; 121 argv += opt.opt_index; 67 122 68 filename = argv[1];123 pf = Parrot_pbc_read(interp, argc ? *argv : "-", debug); 69 124 70 pf = Parrot_readbc(interp, filename);71 72 125 if (!pf) { 126 printf("Can't read PBC\n"); 73 127 return 1; 74 128 } 75 129 76 Parrot_ loadbc(interp, pf);130 Parrot_pbc_load(interp, pf); 77 131 78 do_dis(interp );132 do_dis(interp, outfile, option); 79 133 80 134 Parrot_exit(interp, 0); 81 135 } 82 136 83 137 /* 84 138 85 =item C<static void do_dis(PARROT_INTERP )>139 =item C<static void do_dis(PARROT_INTERP, outfile, options)> 86 140 87 141 Do the disassembling. 88 142 … … 91 145 */ 92 146 93 147 static void 94 do_dis(PARROT_INTERP )148 do_dis(PARROT_INTERP, char *outfile, Parrot_disassemble_options options) 95 149 { 96 Parrot_disassemble(interp );150 Parrot_disassemble(interp, outfile, options); 97 151 } 98 152 99 153 /* … … 112 166 actually run the disassembler to normal C comments (Wed, 16 Nov 2005). 113 167 114 168 Reini Urban: Renamed from disassemble to pbc_disassemble (2008-07-03). 169 add options: help, -h, -o, bare (2009-01-29) 115 170 116 171 =cut 117 172 -
src/pdump.c
177 177 printf("usage:\n"); 178 178 printf("pdump [-tdh] [--terse|--disassemble|--header-only] file.pbc\n"); 179 179 printf("pdump -o converted.pbc file.pbc\n\n"); 180 printf("\t-d ... disassemble bytecode segments\n"); 181 printf("\t-h ... dump header only\n"); 182 printf("\t-t ... terse output\n"); 180 printf("\t-d disassemble bytecode segments\n"); 181 printf("\t-h dump header only\n"); 182 printf("\t-t terse output\n"); 183 printf("\t--debug debug output\n"); 183 184 printf("\n\t-o converted.pbc repacks a PBC file into " 184 185 "the platform's native\n"); 185 186 printf("\t binary format for better efficiency on reading " … … 192 193 { '?', '?', OPTION_optional_FLAG, { "--help" } }, 193 194 { 't', 't', OPTION_optional_FLAG, { "--terse" } }, 194 195 { 'd', 'd', OPTION_optional_FLAG, { "--disassemble" } }, 196 { 'e', 'e', OPTION_optional_FLAG, { "--debug" } }, 195 197 { 'o', 'o', OPTION_required_FLAG, { "--output" } } 196 198 }; 197 199 … … 215 217 int disas = 0; 216 218 int convert = 0; 217 219 int header = 0; 220 int debug = 0; 218 221 const char *file = NULL; 219 222 struct longopt_opt_info opt = LONGOPT_OPT_INFO_INIT; 220 223 int status; … … 237 240 case 'd': 238 241 disas = 1; 239 242 break; 243 case 'e': 244 debug = 1; 245 break; 240 246 case 'o': 241 247 file = opt.opt_arg; 242 248 convert = 1; … … 254 260 argv += opt.opt_index; 255 261 256 262 257 pf = Parrot_ readbc(interp, *argv);263 pf = Parrot_pbc_read(interp, *argv, debug); 258 264 259 265 if (!pf) { 260 266 printf("Can't read PBC\n"); 261 267 return 1; 262 268 } 263 Parrot_ loadbc(interp, pf);269 Parrot_pbc_load(interp, pf); 264 270 if (convert) { 265 271 size_t size; 266 272 opcode_t *pack; -
src/packfile/pf_items.c
107 107 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */ 108 108 /* HEADERIZER END: static */ 109 109 110 #define TRACE_PACKFILE 0 110 #if TRACE_PACKFILE 111 void Parrot_trace_eprintf(ARGIN(const char *s), ...); 112 #endif 111 113 112 114 /* 113 115 * round val up to whole size, return result in bytes … … 470 472 return *(*stream)++; 471 473 o = (pf->fetch_op)(*((const unsigned char **)stream)); 472 474 *((const unsigned char **) (stream)) += pf->header->wordsize; 473 #if TRACE_PACKFILE 474 Parrot_io_eprintf(NULL, " PF_fetch_opcode: 0x%lx (%ld)\n", o, o); 475 #endif 475 TRACE_PRINTF_VAL((" PF_fetch_opcode: 0x%lx (%ld)\n", o, o)); 476 476 return o; 477 477 } 478 478 … … 606 606 FLOATVAL f; 607 607 double d; 608 608 if (!pf || !pf->fetch_nv) { 609 #if TRACE_PACKFILE 610 Parrot_io_eprintf(NULL, "PF_fetch_number: Native [%d bytes]\n", 611 sizeof (FLOATVAL)); 612 #endif 609 TRACE_PRINTF(("PF_fetch_number: Native [%d bytes]\n", 610 sizeof (FLOATVAL))); 613 611 memcpy(&f, (const char*)*stream, sizeof (FLOATVAL)); 612 TRACE_PRINTF_VAL(("PF_fetch_number: %f\n", f)); 614 613 (*stream) += (sizeof (FLOATVAL) + sizeof (opcode_t) - 1)/ 615 614 sizeof (opcode_t); 616 615 return f; 617 616 } 618 617 f = (FLOATVAL) 0; 619 #if TRACE_PACKFILE 620 Parrot_io_eprintf(NULL, "PF_fetch_number: Byteordering..\n"); 621 #endif 618 TRACE_PRINTF(("PF_fetch_number: Byteordering..\n")); 622 619 /* Here is where the size transforms get messy. 623 620 Floattype 0 = IEEE-754 8 byte double 624 621 Floattype 1 = x86 little endian 12 byte long double … … 626 623 if (NUMVAL_SIZE == 8 && pf->header->floattype) { 627 624 (pf->fetch_nv)((unsigned char *)&d, (const unsigned char *) *stream); 628 625 f = d; 626 TRACE_PRINTF_VAL(("PF_fetch_number: 12->8 byte %f\n", f)); 629 627 } 630 628 else { 631 629 (pf->fetch_nv)((unsigned char *)&f, (const unsigned char *) *stream); 630 TRACE_PRINTF_VAL(("PF_fetch_number: %f\n", f)); 632 631 } 633 632 if (pf->header->floattype) { 634 633 *((const unsigned char **) (stream)) += 12; … … 718 717 719 718 /* These may need to be separate */ 720 719 size = (size_t)PF_fetch_opcode(pf, cursor); 720 TRACE_PRINTF(("PF_fetch_string(): flags are 0x%04x...\n", flags)); 721 TRACE_PRINTF(("PF_fetch_string(): charset_nr is %ld...\n", 722 charset_nr)); 723 TRACE_PRINTF(("PF_fetch_string(): size is %ld...\n", size)); 721 724 722 #if TRACE_PACKFILE723 Parrot_io_eprintf(NULL, "PF_fetch_string(): flags are 0x%04x...\n", flags);724 Parrot_io_eprintf(NULL, "PF_fetch_string(): charset_nr is %ld...\n",725 charset_nr);726 Parrot_io_eprintf(NULL, "PF_fetch_string(): size is %ld...\n", size);727 #endif728 729 725 charset_name = Parrot_charset_c_name(interp, charset_nr); 730 726 s = string_make(interp, (const char *)*cursor, size, charset_name, flags); 731 727 732 #if TRACE_PACKFILE == 3 733 Parrot_io_eprintf(NULL, "PF_fetch_string(): string is: "); 734 Parrot_io_putps(interp, Parrot_io_STDERR(interp), s); 735 Parrot_io_eprintf(NULL, "\n"); 728 #if TRACE_PACKFILE == 2 729 if (pf->options & 3) { 730 /* print only printable characters */ 731 Parrot_io_eprintf(NULL, "PF_fetch_string(): string is '%s'\n", s->strstart); 732 } 736 733 #endif 737 734 738 735 /* s = string_make(interp, *cursor, size, … … 740 737 flags); */ 741 738 742 739 size = ROUND_UP_B(size, wordsize); 743 #if TRACE_PACKFILE == 2 744 Parrot_io_eprintf(NULL, "PF_fetch_string(): round size up to %ld.\n", size); 745 #endif 740 TRACE_PRINTF(("PF_fetch_string(): round size up to %ld.\n", size)); 746 741 *((const unsigned char **) (cursor)) += size; 747 742 return s; 748 743 } … … 766 761 opcode_t padded_size = s->bufused; 767 762 char *charcursor; 768 763 769 #if TRACE_PACKFILE == 2764 #if TRACE_PACKFILE == 3 770 765 Parrot_io_eprintf(NULL, "PF_store_string(): size is %ld...\n", s->bufused); 771 766 #endif 772 767 -
src/pmc/packfile.pmc
82 82 83 83 =cut 84 84 85 Implementation note: taken from the bottom end of Parrot_ readbc().85 Implementation note: taken from the bottom end of Parrot_pbc_read(). 86 86 */ 87 87 VTABLE void set_string_native(STRING *str) { 88 88 PackFile *pf = PMC_data_typed(SELF, PackFile *); -
src/packfile.c
15 15 This file contains all the functions required for the processing of the 16 16 structure of a PackFile. It is not intended to understand the byte code 17 17 stream itself, but merely to dissect and reconstruct data from the 18 various segments. See F<docs/p arrotbyte.pod> for information about the18 various segments. See F<docs/pdds/pdd13_bytecode.pod> for information about the 19 19 structure of the frozen bytecode. 20 20 21 21 =over 4 … … 451 451 extern int Parrot_exec_run; 452 452 #endif 453 453 454 #define TRACE_PACKFILE 0455 456 454 /* TODO: This is broken on 64-bit. See TT #254 */ 457 455 #if OPCODE_T_SIZE == 4 458 456 # define ROUND_16(val) (((val) & 0xf) ? 16 - ((val) & 0xf) : 0) … … 462 460 # define ALIGN_16(xx, ptr) ptr = (const opcode_t *)(((unsigned long)ptr + 15) & (~15)) 463 461 #endif 464 462 463 #if TRACE_PACKFILE 464 void Parrot_trace_eprintf(ARGIN(const char *s), ...); 465 void Parrot_trace_eprintf(ARGIN(const char *s), ...) { 466 va_list args; 467 va_start(args, s); 468 vfprintf(stderr, s, args); 469 va_end(args); 470 } 471 #endif 472 465 473 /* 466 474 467 475 =item C<void PackFile_destroy> … … 843 851 opcode_t i; 844 852 PackFile_FixupTable * const ft = self->fixups; 845 853 PackFile_ConstTable * const ct = self->const_table; 846 847 854 #if TRACE_PACKFILE 848 Pa rrot_io_eprintf(NULL, "PackFile: do_sub_pragmas (action=%d)\n", action);855 PackFile * const pf = self->base.pf; 849 856 #endif 850 857 858 TRACE_PRINTF(("PackFile: do_sub_pragmas (action=%d)\n", action)); 859 851 860 for (i = 0; i < ft->fixup_count; i++) { 852 861 switch (ft->fixups[i]->type) { 853 862 case enum_fixup_sub: … … 915 924 const opcode_t *cursor; 916 925 int header_read_length; 917 926 opcode_t padding; 927 #if TRACE_PACKFILE 928 PackFile * const pf = self; 929 #endif 918 930 919 931 self->src = packed; 920 932 self->size = packed_size; … … 958 970 } 959 971 960 972 /* Describe what was read for debugging. */ 961 #if TRACE_PACKFILE 962 Parrot_io_eprintf(NULL, "PackFile_unpack: Wordsize %d.\n", header->wordsize); 963 Parrot_io_eprintf(NULL, "PackFile_unpack: Floattype %d (%s).\n", 964 header->floattype, 965 header->floattype ? 973 TRACE_PRINTF(("PackFile_unpack: Wordsize %d.\n", header->wordsize)); 974 TRACE_PRINTF(("PackFile_unpack: Floattype %d (%s).\n", 975 header->floattype, 976 header->floattype ? 966 977 "x86 little endian 12 byte long double" : 967 "IEEE-754 8 byte double"); 968 Parrot_io_eprintf(NULL, "PackFile_unpack: Byteorder %d (%sendian).\n", 969 header->byteorder, header->byteorder ? "big " : "little-"); 970 #endif 978 "IEEE-754 8 byte double")); 979 TRACE_PRINTF(("PackFile_unpack: Byteorder %d (%sendian).\n", 980 header->byteorder, header->byteorder ? "big " : "little-")); 971 981 972 982 /* Check the UUID type is valid and, if needed, read a UUID. */ 973 983 if (header->uuid_type == 0) { … … 1011 1021 } 1012 1022 1013 1023 /* Padding. */ 1014 #if TRACE_PACKFILE 1015 Parrot_io_eprintf(NULL, "PackFile_unpack: 3 words padding.\n"); 1016 #endif 1024 TRACE_PRINTF(("PackFile_unpack: 3 words padding.\n")); 1017 1025 padding = PF_fetch_opcode(self, &cursor); 1018 1026 padding = PF_fetch_opcode(self, &cursor); 1019 1027 padding = PF_fetch_opcode(self, &cursor); 1020 1028 UNUSED(padding); 1021 1029 1022 #if TRACE_PACKFILE 1023 Parrot_io_eprintf(NULL, "PackFile_unpack: Directory read, offset %d.\n", 1024 (INTVAL)cursor - (INTVAL)packed); 1025 #endif 1030 TRACE_PRINTF(("PackFile_unpack: Directory read, offset %d.\n", 1031 (INTVAL)cursor - (INTVAL)packed)); 1026 1032 1027 1033 self->directory.base.file_offset = (INTVAL)cursor - (INTVAL)self->src; 1028 1034 … … 1044 1050 } 1045 1051 #endif 1046 1052 1047 #if TRACE_PACKFILE 1048 Parrot_io_eprintf(NULL, "PackFile_unpack: Unpack done.\n"); 1049 #endif 1053 TRACE_PRINTF(("PackFile_unpack: Unpack done.\n")); 1050 1054 1051 1055 return cursor - packed; 1052 1056 } … … 1225 1229 header->bc_minor = PARROT_PBC_MINOR; 1226 1230 #if NUMVAL_SIZE == 8 1227 1231 header->floattype = 0; 1228 #else /* if XXX */ 1232 #else 1233 # if (NUMVAL_SIZE == 12) && PARROT_BIGENDIAN 1229 1234 header->floattype = 1; 1235 # else 1236 Parrot_io_eprintf 1237 (NULL, 1238 "PackFile_set_header: Unsupported floattype NUMVAL_SIZE=%d, PARROT_BIGENDIAN=%d\n", 1239 NUMVAL_SIZE, PARROT_BIGENDIAN); 1240 return 0; 1241 # endif 1230 1242 #endif 1231 1243 } 1232 1244 … … 1289 1301 PackFile * const pf = mem_allocate_zeroed_typed(PackFile); 1290 1302 pf->header = mem_allocate_zeroed_typed(PackFile_Header); 1291 1303 pf->is_mmap_ped = is_mapped; 1304 pf->options = 0; 1292 1305 1293 1306 /* fill header with system specific data */ 1294 1307 PackFile_set_header(pf->header); … … 1379 1392 { 1380 1393 ASSERT_ARGS(default_unpack) 1381 1394 DECL_CONST_CAST_OF(opcode_t); 1395 #if TRACE_PACKFILE 1396 PackFile * const pf = self->pf; 1397 #endif 1382 1398 1383 1399 self->op_count = PF_fetch_opcode(self->pf, &cursor); 1384 1400 self->itype = PF_fetch_opcode(self->pf, &cursor); 1385 1401 self->id = PF_fetch_opcode(self->pf, &cursor); 1386 1402 self->size = PF_fetch_opcode(self->pf, &cursor); 1387 #if TRACE_PACKFILE == 2 1388 Parrot_io_eprintf(NULL, "default_unpack: op_count=%d, itype=%d, id=%d, size=%d.\n", 1389 self->op_count, self->itype, self->id, self->size); 1390 #endif 1403 TRACE_PRINTF_VAL(("default_unpack: op_count=%d, itype=%d, id=%d, size=%d.\n", 1404 self->op_count, self->itype, self->id, self->size)); 1391 1405 1392 1406 if (self->size == 0) 1393 1407 return cursor; … … 1419 1433 int i; 1420 1434 for (i = 0; i < (int)self->size; i++) { 1421 1435 self->data[i] = PF_fetch_opcode(self->pf, &cursor); 1422 #if TRACE_PACKFILE 1423 Parrot_io_eprintf(NULL, "default_unpack: transformed op[#%d]/%d %u\n", 1424 i, self->size, self->data[i]); 1425 #endif 1436 TRACE_PRINTF(("default_unpack: transformed op[#%d]/%d %u\n", 1437 i, self->size, self->data[i])); 1426 1438 } 1427 1439 } 1428 1440 … … 1792 1804 { 1793 1805 ASSERT_ARGS(PackFile_Segment_unpack) 1794 1806 PackFile_Segment_unpack_func_t f = self->pf->PackFuncs[self->type].unpack; 1807 #if TRACE_PACKFILE 1808 PackFile * const pf = self->pf; 1809 #endif 1795 1810 1796 1811 cursor = default_unpack(self, cursor); 1797 1812 … … 1799 1814 return NULL; 1800 1815 1801 1816 if (f) { 1802 #if TRACE_PACKFILE 1803 Parrot_io_eprintf(NULL, "PackFile_Segment_unpack: special\n"); 1804 #endif 1817 TRACE_PRINTF(("PackFile_Segment_unpack: special\n")); 1818 1805 1819 cursor = (f)(interp, self, cursor); 1806 #if TRACE_PACKFILE == 2 1807 Parrot_io_eprintf(NULL, " PackFile_Segment_unpack: cursor=0x%x\n", cursor); 1808 #endif 1820 TRACE_PRINTF_VAL((" PackFile_Segment_unpack: offset=0x%x\n", pf->src - cursor)); 1821 1809 1822 if (!cursor) 1810 1823 return NULL; 1811 1824 } 1812 1825 1813 1826 ALIGN_16(self->pf->src, cursor); 1814 #if TRACE_PACKFILE == 2 1815 Parrot_io_eprintf(NULL, " ALIGN_16: src=0x%x cursor=0x%x\n", self->pf->src, cursor); 1816 #endif 1827 TRACE_PRINTF_VAL(("ALIGN_16: offset=0x%x src=0x%x cursor=0x%x\n", pf->src - cursor, pf->src, cursor)); 1817 1828 return cursor; 1818 1829 } 1819 1830 … … 1927 1938 size_t i; 1928 1939 1929 1940 dir->num_segments = PF_fetch_opcode(pf, &cursor); 1930 #if TRACE_PACKFILE 1931 Parrot_io_eprintf(interp, "directory_unpack: %ld num_segments\n", dir->num_segments); 1932 #endif 1941 TRACE_PRINTF(("directory_unpack: %ld num_segments\n", dir->num_segments)); 1933 1942 mem_realloc_n_typed(dir->segments, dir->num_segments, PackFile_Segment *); 1934 1943 1935 1944 for (i = 0; i < dir->num_segments; i++) { … … 1942 1951 if (type >= PF_MAX_SEG) 1943 1952 type = PF_UNKNOWN_SEG; 1944 1953 1945 #if TRACE_PACKFILE == 2 1946 Parrot_io_eprintf(NULL, "Segment type %d.\n", type); 1947 #endif 1954 TRACE_PRINTF_VAL(("Segment type %d.\n", type)); 1948 1955 /* get name */ 1949 1956 name = PF_fetch_cstring(pf, &cursor); 1957 TRACE_PRINTF_VAL(("Segment name \"%s\".\n", name)); 1950 1958 1951 #if TRACE_PACKFILE == 21952 Parrot_io_eprintf(NULL, "Segment name \"%s\".\n", name);1953 #endif1954 1955 1959 /* create it */ 1956 1960 seg = PackFile_Segment_new_seg(interp, dir, type, name, 0); 1957 1961 mem_sys_free(name); 1958 1962 1959 1963 seg->file_offset = PF_fetch_opcode(pf, &cursor); 1960 #if TRACE_PACKFILE == 2 1961 Parrot_io_eprintf(NULL, "Segment file_offset %ld.\n", seg->file_offset); 1962 #endif 1964 TRACE_PRINTF_VAL(("Segment file_offset %ld.\n", seg->file_offset)); 1963 1965 seg->op_count = PF_fetch_opcode(pf, &cursor); 1964 #if TRACE_PACKFILE == 2 1965 Parrot_io_eprintf(NULL, "Segment op_count %ld.\n", seg->op_count); 1966 #endif 1966 TRACE_PRINTF_VAL(("Segment op_count %ld.\n", seg->op_count)); 1967 1967 1968 1968 if (pf->need_wordsize) { 1969 1969 #if OPCODE_T_SIZE == 8 … … 1979 1979 pf->header->wordsize); 1980 1980 return 0; 1981 1981 } 1982 #if TRACE_PACKFILE == 2 1983 Parrot_io_eprintf(NULL, "Segment offset: new pos 0x%x (src=0x%x cursor=0x%x).\n", 1984 pos - pf->src, pf->src, cursor); 1985 #endif 1982 TRACE_PRINTF_VAL(("Segment offset: new pos 0x%x (src=0x%x cursor=0x%x).\n", 1983 pos - pf->src, pf->src, cursor)); 1984 1986 1985 } 1987 1986 else 1988 1987 pos = pf->src + seg->file_offset; … … 2011 2010 seg->dir = dir; 2012 2011 } 2013 2012 2014 #if TRACE_PACKFILE == 2 2015 Parrot_io_eprintf(NULL, "pre-ALIGN_16: cursor=0x%x\n", cursor); 2013 TRACE_PRINTF_VAL(("pre-ALIGN_16: offset=0x%x\n", pf->src - cursor)); 2016 2014 /* FIXME on 64bit reading 32bit */ 2017 #endif2018 2015 ALIGN_16(pf->src, cursor); 2019 #if TRACE_PACKFILE == 2 2020 Parrot_io_eprintf(NULL, "ALIGN_16: src=0x%x cursor=0x%x\n", pf->src, cursor); 2021 #endif 2016 TRACE_PRINTF_VAL(("ALIGN_16: offset=0x%x src=0x%x cursor=0x%x\n", pf->src - cursor, pf->src, cursor)); 2022 2017 2023 2018 /* and now unpack contents of dir */ 2024 2019 for (i = 0; cursor && i < dir->num_segments; i++) { … … 2031 2026 size_t delta = 0; 2032 2027 2033 2028 cursor = csave; 2034 #if TRACE_PACKFILE == 2 2035 Parrot_io_eprintf(NULL, "PackFile_Segment_unpack [%d] tmp len=%d.\n", i, tmp); 2036 #endif 2029 TRACE_PRINTF_VAL(("PackFile_Segment_unpack [%d] tmp len=%d.\n", i, tmp)); 2037 2030 pos = PackFile_Segment_unpack(interp, dir->segments[i], cursor); 2038 2031 2039 2032 if (!pos) { … … 2041 2034 dir->segments[i]->name); 2042 2035 return 0; 2043 2036 } 2044 #if TRACE_PACKFILE == 22045 2037 else 2046 Parrot_io_eprintf(NULL, "PackFile_Segment_unpack ok. pos=0x%x\n", pos); 2047 #endif 2038 TRACE_PRINTF_VAL((NULL, "PackFile_Segment_unpack ok. pos=0x%x\n", pos)); 2048 2039 2049 2040 /* BUG: on 64bit reading 32bit lurking here! */ 2050 2041 if (pf->need_wordsize) { … … 2058 2049 } 2059 2050 else 2060 2051 delta = pos - cursor; 2061 #if TRACE_PACKFILE == 2 2062 Parrot_io_eprintf(NULL, " delta=%d pos=0x%x cursor=0x%x\n", 2063 delta, pos, cursor); 2064 #endif 2052 TRACE_PRINTF_VAL((" delta=%d pos=0x%x cursor=0x%x\n", 2053 delta, pos, cursor)); 2065 2054 2066 2055 if ((size_t)delta != tmp || dir->segments[i]->op_count != tmp) 2067 2056 fprintf(stderr, "PackFile_unpack segment '%s' directory length %d " … … 3250 3239 3251 3240 pf = self->base.pf; 3252 3241 self->fixup_count = PF_fetch_opcode(pf, &cursor); 3253 #if TRACE_PACKFILE 3254 Parrot_io_eprintf(interp, 3255 "PackFile_FixupTable_unpack(): %ld entries\n", self->fixup_count); 3256 #endif 3242 TRACE_PRINTF(("PackFile_FixupTable_unpack(): %ld entries\n", self->fixup_count)); 3257 3243 3258 3244 if (self->fixup_count) { 3259 3245 self->fixups = (PackFile_FixupEntry **)mem_sys_allocate_zeroed( … … 3278 3264 case enum_fixup_sub: 3279 3265 entry->name = PF_fetch_cstring(pf, &cursor); 3280 3266 entry->offset = PF_fetch_opcode(pf, &cursor); 3281 #if TRACE_PACKFILE == 2 3282 Parrot_io_eprintf(interp, 3283 "PackFile_FixupTable_unpack(): type %d, name %s, offset %ld\n", 3284 entry->type, entry->name, entry->offset); 3285 #endif 3267 TRACE_PRINTF_VAL(("PackFile_FixupTable_unpack(): type %d, name %s, offset %ld\n", 3268 entry->type, entry->name, entry->offset)); 3286 3269 break; 3287 3270 case enum_fixup_none: 3288 3271 break; … … 3301 3284 3302 3285 =item C<void PackFile_FixupTable_new_entry> 3303 3286 3304 I<What does this do?> 3287 Adds a new fix-up entry with label and type. 3288 Creates a new PackFile FixupTable if none is present. 3305 3289 3306 RT #48260: Not yet documented!!!3307 3308 3290 =cut 3309 3291 3310 3292 */ … … 3340 3322 3341 3323 =item C<static PackFile_FixupEntry * find_fixup> 3342 3324 3343 Finds the fix-up entry forC<name> and returns it.3325 Finds the fix-up entry in a given FixupTable C<ft> for C<type> and C<name> and returns it. 3344 3326 3327 This ignores directories, for a recursive version see C<PackFile_find_fixup_entry>. 3328 3345 3329 =cut 3346 3330 3347 3331 */ … … 3367 3351 3368 3352 =item C<static INTVAL find_fixup_iter> 3369 3353 3370 I <What does this do?>3354 Iterator for C<PackFile_find_fixup_entry> to recurse into directories. 3371 3355 3372 RT #48260: Not yet documented!!!3373 3374 3356 =cut 3375 3357 3376 3358 */ … … 3400 3382 3401 3383 =item C<PackFile_FixupEntry * PackFile_find_fixup_entry> 3402 3384 3403 I<What does this do?> 3385 Searches the whole PackFile recursively for a fix-up entry 3386 with the given C<type> and C<name>, and returns the found entry or NULL. 3404 3387 3405 RT #48260: Not yet documented!!! 3388 This recurses into directories, compared to the simplier 3389 C<find_fixup> which just searches one PackFile_FixupTable. 3406 3390 3407 3391 =cut 3408 3392 … … 3499 3483 3500 3484 self->const_count = PF_fetch_opcode(pf, &cursor); 3501 3485 3502 #if TRACE_PACKFILE 3503 Parrot_io_eprintf(interp, 3504 "PackFile_ConstTable_unpack: Unpacking %ld constants\n", 3505 self->const_count); 3506 #endif 3486 TRACE_PRINTF(("PackFile_ConstTable_unpack: Unpacking %ld constants\n", 3487 self->const_count)); 3507 3488 3508 3489 if (self->const_count == 0) { 3509 3490 return cursor; … … 3521 3502 } 3522 3503 3523 3504 for (i = 0; i < self->const_count; i++) { 3524 #if TRACE_PACKFILE 3525 Parrot_io_eprintf(interp, 3526 "PackFile_ConstTable_unpack(): Unpacking constant %ld/%ld\n", 3527 i, self->const_count); 3528 #endif 3505 TRACE_PRINTF(("PackFile_ConstTable_unpack(): Unpacking constant %ld/%ld\n", 3506 i, self->const_count)); 3529 3507 3530 3508 #if EXEC_CAPABLE 3531 3509 if (Parrot_exec_run) … … 3721 3699 PackFile * const pf = constt->base.pf; 3722 3700 const opcode_t type = PF_fetch_opcode(pf, &cursor); 3723 3701 3724 #if TRACE_PACKFILE 3725 Parrot_io_eprintf(NULL, "PackFile_Constant_unpack(): Type is %ld ('%c')...\n", 3726 type, (char)type); 3727 #endif 3702 TRACE_PRINTF(("PackFile_Constant_unpack(): Type is %ld ('%c')...\n", 3703 type, (char)type)); 3728 3704 3729 3705 switch (type) { 3730 3706 case PFC_NUMBER: … … 4058 4034 INTVAL i, str_len; 4059 4035 PackFile_ByteCode *code; 4060 4036 char *code_name; 4037 #if TRACE_PACKFILE 4038 PackFile * const pf = seg->pf; 4039 #endif 4061 4040 4062 4041 /* Unpack keys. */ 4063 4042 self->num_keys = PF_fetch_opcode(seg->pf, &cursor); 4064 #if TRACE_PACKFILE 4065 Parrot_io_eprintf(interp, 4066 "PackFile_Annotations_unpack: Unpacking %ld keys\n", 4067 self->num_keys); 4068 #endif 4043 TRACE_PRINTF(("PackFile_Annotations_unpack: Unpacking %ld keys\n", 4044 self->num_keys)); 4069 4045 self->keys = mem_allocate_n_typed(self->num_keys, PackFile_Annotations_Key *); 4070 4046 for (i = 0; i < self->num_keys; i++) { 4071 4047 self->keys[i] = mem_allocate_typed(PackFile_Annotations_Key); 4072 4048 self->keys[i]->name = PF_fetch_opcode(seg->pf, &cursor); 4073 4049 self->keys[i]->type = PF_fetch_opcode(seg->pf, &cursor); 4074 #if TRACE_PACKFILE == 2 4075 Parrot_io_eprintf(interp, 4076 "PackFile_Annotations_unpack: key[%d]/%d name=%s type=%d\n", 4077 i, self->num_keys, self->keys[i]->name, self->keys[i]->type); 4078 #endif 4050 TRACE_PRINTF_VAL(("PackFile_Annotations_unpack: key[%d]/%d name=%s type=%d\n", 4051 i, self->num_keys, self->keys[i]->name, self->keys[i]->type)); 4079 4052 } 4080 4053 4081 4054 /* Unpack groups. */ … … 4085 4058 self->groups[i] = mem_allocate_typed(PackFile_Annotations_Group); 4086 4059 self->groups[i]->bytecode_offset = PF_fetch_opcode(seg->pf, &cursor); 4087 4060 self->groups[i]->entries_offset = PF_fetch_opcode(seg->pf, &cursor); 4088 #if TRACE_PACKFILE == 2 4089 Parrot_io_eprintf(interp, 4090 "PackFile_Annotations_unpack: group[%d]/%d bytecode_offset=%d entries_offset=%d\n", 4091 i, self->num_groups, self->groups[i]->bytecode_offset, self->groups[i]->entries_offset); 4092 #endif 4061 TRACE_PRINTF_VAL(("PackFile_Annotations_unpack: group[%d]/%d bytecode_offset=%d entries_offset=%d\n", 4062 i, self->num_groups, self->groups[i]->bytecode_offset, self->groups[i]->entries_offset)); 4093 4063 } 4094 4064 4095 4065 /* Unpack entries. */ … … 4449 4419 PackFile_append_pbc(PARROT_INTERP, ARGIN_NULLOK(const char *filename)) 4450 4420 { 4451 4421 ASSERT_ARGS(PackFile_append_pbc) 4452 PackFile * const pf = Parrot_readbc(interp, filename);4422 PackFile * const pf = Parrot_pbc_read(interp, filename, 0); 4453 4423 if (!pf) 4454 4424 return NULL; 4455 4425 PackFile_add_segment(interp, &interp->initial_pf->directory, … … 4558 4528 4559 4529 =head1 HISTORY 4560 4530 4531 Trace macros and 64-bit fixes by Reini Urban, 2009-02-03 4532 4561 4533 Rework by Melvin; new bytecode format, make bytecode portable. (Do 4562 4534 endian conversion and wordsize transforms on the fly.) 4563 4535 -
docs/embed.pod
21 21 return 1; 22 22 } 23 23 24 pf = Parrot_ readbc(interp, "foo.pbc");25 Parrot_ loadbc(interp, pf);24 pf = Parrot_pbc_read(interp, "foo.pbc", 0); 25 Parrot_pbc_load(interp, pf); 26 26 Parrot_runcode(interp, argc, argv); 27 27 28 28 Parrot_destroy(interp); … … 245 245 246 246 =over 4 247 247 248 =item C<Parrot_PackFile Parrot_ readbc(PARROT_INTERP, const char *path)>248 =item C<Parrot_PackFile Parrot_pbc_read(PARROT_INTERP, const char *path, int debug)> 249 249 250 250 Reads Parrot bytecode or PIR from the file referenced by C<path>. Returns 251 a packfile structure for use by C<Parrot_ loadbc()>.251 a packfile structure for use by C<Parrot_pbc_load()>. 252 252 253 =item C<void Parrot_ loadbc(PARROT_INTERP, Parrot_PackFile pf)>253 =item C<void Parrot_pbc_load(PARROT_INTERP, Parrot_PackFile pf)> 254 254 255 255 Loads a packfile into the interpreter. After this operation the interpreter 256 256 is ready to run the bytecode in the packfile. -
tools/util/dump_pbc.pl
70 70 my %cache; 71 71 72 72 foreach (@dis) { 73 if (/^Current Source Filename (.*)/) { 74 if ($cur_file ne $1) { 75 $cur_file = $1; 73 if (/^(?:# )?Current Source Filename (.*)/) { 74 my $found = $1; 75 $found =~ s/^'//; 76 $found =~ s/'$//; 77 if ($cur_file ne $found) { 78 $cur_file = $found; 76 79 $cache{$cur_file} ||= slurp_file($cur_file); 77 80 $cur_line = -1; 78 81 -
tools/dev/pbc_to_exe_gen.pl
267 267 268 268 do_sub_pragmas(interp, pf->cur_cs, PBC_PBC, NULL); 269 269 270 Parrot_ loadbc(interp, pf);270 Parrot_pbc_load(interp, pf); 271 271 272 272 PackFile_fixup_subs(interp, PBC_MAIN, NULL); 273 273 Parrot_runcode(interp, argc, argv); -
include/parrot/embed.h
22 22 23 23 typedef int Parrot_warnclass; 24 24 25 typedef enum { 26 enum_DIS_BARE = 1, 27 enum_DIS_HEADER = 2 28 } Parrot_disassemble_options; 29 25 30 PARROT_EXPORT Parrot_Interp Parrot_new(Parrot_Interp parent); 26 31 27 32 PARROT_EXPORT void Parrot_init_stacktop(Parrot_Interp, void *); … … 44 49 45 50 PARROT_EXPORT void Parrot_setwarnings(Parrot_Interp, Parrot_warnclass); 46 51 47 PARROT_EXPORT Parrot_PackFile Parrot_ readbc(Parrot_Interp, const char *);52 PARROT_EXPORT Parrot_PackFile Parrot_pbc_read(Parrot_Interp, const char *, int); 48 53 49 PARROT_EXPORT void Parrot_ loadbc(Parrot_Interp, Parrot_PackFile);54 PARROT_EXPORT void Parrot_pbc_load(Parrot_Interp, Parrot_PackFile); 50 55 51 56 PARROT_EXPORT void Parrot_setup_argv(Parrot_Interp, int argc, const char **argv); 52 57 … … 58 63 59 64 PARROT_EXPORT Parrot_Opcode * Parrot_debug(Parrot_Interp, Parrot_Interp, Parrot_Opcode *pc); 60 65 61 PARROT_EXPORT void Parrot_disassemble(Parrot_Interp );66 PARROT_EXPORT void Parrot_disassemble(Parrot_Interp, char *outfile, Parrot_disassemble_options options); 62 67 63 68 PARROT_EXPORT 64 69 PARROT_DOES_NOT_RETURN -
include/parrot/packfile.h
24 24 #define CONSTANT_SEGMENT_NAME "CONSTANT" 25 25 #define BYTE_CODE_SEGMENT_NAME "BYTECODE" 26 26 27 #define TRACE_PACKFILE 0 28 #if TRACE_PACKFILE 29 # define TRACE_PRINTF(args) if (pf->options) Parrot_trace_eprintf args 30 # if TRACE_PACKFILE == 2 31 # define TRACE_PRINTF_VAL(args) if (pf->options & 2) Parrot_trace_eprintf args 32 # else 33 # define TRACE_PRINTF_VAL(args) 34 # endif 35 #else 36 # define TRACE_PRINTF(args) 37 # define TRACE_PRINTF_VAL(args) 38 #endif 39 27 40 /* 28 41 ** Structure Definitions: 29 42 */ … … 271 284 272 285 PackFile_ByteCode * cur_cs; /* used during PF loading */ 273 286 287 INTVAL options; 274 288 INTVAL need_wordsize; 275 289 INTVAL need_endianize; 276 290 -
compilers/imcc/main.c
972 972 opt_desc, opt_level); 973 973 974 974 pf = PackFile_new(interp, 0); 975 Parrot_ loadbc(interp, pf);975 Parrot_pbc_load(interp, pf); 976 976 977 977 IMCC_push_parser_state(interp); 978 978 IMCC_INFO(interp)->state->file = sourcefile; … … 1076 1076 /* If the input file is Parrot bytecode, then we simply read it 1077 1077 into a packfile, which Parrot then loads */ 1078 1078 if (STATE_LOAD_PBC(interp)) { 1079 PackFile * const pf = Parrot_ readbc(interp, sourcefile);1079 PackFile * const pf = Parrot_pbc_read(interp, sourcefile, 0); 1080 1080 1081 1081 if (!pf) 1082 1082 IMCC_fatal_standalone(interp, 1, "main: Packfile loading failed\n"); 1083 Parrot_ loadbc(interp, pf);1083 Parrot_pbc_load(interp, pf); 1084 1084 } 1085 1085 else 1086 1086 compile_to_bytecode(interp, sourcefile, output_file); … … 1098 1098 PackFile *pf; 1099 1099 1100 1100 IMCC_info(interp, 1, "Loading %s\n", output_file); 1101 pf = Parrot_ readbc(interp, output_file);1101 pf = Parrot_pbc_read(interp, output_file, 0); 1102 1102 if (!pf) 1103 1103 IMCC_fatal_standalone(interp, 1, "Packfile loading failed\n"); 1104 Parrot_ loadbc(interp, pf);1104 Parrot_pbc_load(interp, pf); 1105 1105 SET_STATE_LOAD_PBC(interp); 1106 1106 } 1107 1107 } -
compilers/pirc/src/bcgen.c
380 380 381 381 /* Create a new packfile and load it into the parrot interpreter */ 382 382 bc->packfile = PackFile_new(interp, 0); 383 Parrot_ loadbc(interp, bc->packfile);383 Parrot_pbc_load(interp, bc->packfile); 384 384 385 385 /* store a pointer to the parrot interpreter, which saves passing around 386 386 * the interp as an extra argument. -
t/src/extend.t
440 440 static opcode_t* 441 441 the_test(PARROT_INTERP, opcode_t *cur_op, opcode_t *start) 442 442 { 443 PackFile *pf = Parrot_ readbc(interp, "$temp_pbc");443 PackFile *pf = Parrot_pbc_read(interp, "$temp_pbc", 0); 444 444 STRING *name = Parrot_str_new_constant(interp, "_sub1"); 445 445 PMC *sub, *arg; 446 446 447 Parrot_ loadbc(interp, pf);447 Parrot_pbc_load(interp, pf); 448 448 sub = Parrot_find_global_cur(interp, name); 449 449 Parrot_call_sub(interp, sub, "v"); 450 450 Parrot_eprintf(interp, "back\\n"); … … 514 514 static opcode_t* 515 515 the_test(PARROT_INTERP, opcode_t *cur_op, opcode_t *start) 516 516 { 517 PackFile *pf = Parrot_ readbc(interp, "$temp_pbc");517 PackFile *pf = Parrot_pbc_read(interp, "$temp_pbc", 0); 518 518 STRING *name = Parrot_str_new_constant(interp, "_sub1"); 519 519 PMC *sub; 520 520 Parrot_runloop jump_point; 521 521 522 Parrot_ loadbc(interp, pf);522 Parrot_pbc_load(interp, pf); 523 523 sub = Parrot_find_global_cur(interp, name); 524 524 525 525 if (setjmp(jump_point.resume)) { … … 602 602 return 1; 603 603 } 604 604 605 packfile = Parrot_ readbc( interp, "$temp_pbc");605 packfile = Parrot_pbc_read( interp, "$temp_pbc", 0 ); 606 606 607 607 if (!packfile) { 608 608 printf( "Boo\\n" ); 609 609 return 1; 610 610 } 611 611 612 Parrot_ loadbc( interp, packfile );612 Parrot_pbc_load( interp, packfile ); 613 613 Parrot_runcode( interp, 1, code ); 614 614 615 615 Parrot_destroy( interp ); … … 684 684 return 1; 685 685 } 686 686 687 pf = Parrot_ readbc( interp, "$temp_pbc");688 Parrot_ loadbc( interp, pf );687 pf = Parrot_pbc_read( interp, "$temp_pbc", 0 ); 688 Parrot_pbc_load( interp, pf ); 689 689 690 690 sub = Parrot_find_global_cur( interp, Parrot_str_new_constant( interp, "add" ) ); 691 691 result = Parrot_call_sub( interp, sub, "III", 100, 200 ); -
examples/c/test_main.c
80 80 81 81 filename = parseflags(interp, &argc, &argv); 82 82 83 pf = Parrot_ readbc(interp, filename);83 pf = Parrot_pbc_read(interp, filename, 0); 84 84 85 85 if (!pf) { 86 86 return 1; 87 87 } 88 88 89 Parrot_ loadbc(interp, pf);89 Parrot_pbc_load(interp, pf); 90 90 Parrot_runcode(interp, argc, argv); 91 91 Parrot_destroy(interp); 92 92