* docs/pmc.pod:
[parrot.git] / src / disassemble.c
blob36e66fb27844865828fdf0ab1f0802ab4942f561
1 /*
2 Copyright (C) 2001-2003, The Perl Foundation.
3 $Id$
5 =head1 NAME
7 disassemble - Parrot disassembler
9 =head1 SYNOPSIS
11 disassemble file.pbc
13 =head1 DESCRIPTION
15 This uses the C<Parrot_disassemble()> function from F<src/embed.c>,
16 which in turn uses the C<PDB_disassemble()> function from
17 F<src/debug.c>.
19 =cut
23 #include <parrot/parrot.h>
24 #include "parrot/embed.h"
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <ctype.h>
29 static void do_dis(Parrot_Interp);
33 int main(int argc, char *argv[])
35 The run-loop. Starts up an interpreter, loads the bytecode from the
36 command-line and disassembles it.
40 int
41 main(int argc, char *argv[])
43 Parrot_Interp interpreter;
44 char *filename;
45 Parrot_PackFile pf;
47 interpreter = Parrot_new(NULL);
49 if (!interpreter) {
50 return 1;
53 interpreter->lo_var_ptr = &interpreter;
55 if (argc != 2) {
56 fprintf(stderr, "Usage: disassemble programfile \n");
57 Parrot_exit(interpreter, 1);
60 filename = argv[1];
62 pf = Parrot_readbc(interpreter, filename);
64 if (!pf) {
65 return 1;
68 Parrot_loadbc(interpreter, pf);
70 do_dis(interpreter);
72 Parrot_exit(interpreter, 0);
74 return 0;
79 static void do_dis(Parrot_Interp interpreter)
81 Do the disassembling.
85 static void
86 do_dis(Parrot_Interp interpreter)
88 Parrot_disassemble(interpreter);
93 =head1 SEE ALSO
95 F<src/embed.c> and F<src/debug.c>.
97 =head1 HISTORY
99 Initial version by Daniel Grunblatt on 2002.5.26.
101 Florian Ragwitz: Moved POD documentation that's not necessary to know how to
102 actually run the disassembler to normal C comments (Wed, 16 Nov 2005).
104 =cut
110 * Local variables:
111 * c-file-style: "parrot"
112 * End:
113 * vim: expandtab shiftwidth=4: