/
disassemble.c
69 lines (54 loc) · 1.08 KB
/
disassemble.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
* disassemble.c
*
* CVS Info
* $Id$
* Overview:
* Parrot disassembler
* History:
* Initial version by Daniel Grunblatt on 2002.5.26
* Notes:
* References:
*/
#include "parrot/embed.h"
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#define na(c) { \
while(*c && !isspace(*c)) \
c++; }
int
main(int argc, char *argv[])
{
Parrot_Interp interpreter;
char *filename, *disassemble;
Parrot_PackFile pf;
interpreter = Parrot_new();
if (!interpreter) {
return 1;
}
Parrot_init(interpreter, (void*) &interpreter);
if (argc != 2) {
fprintf(stderr, "Usage: disassemble programfile \n");
exit(1);
}
na(argv[0]);
filename = &(*argv)[1];
pf = Parrot_readbc(interpreter, filename);
if (!pf) {
return 1;
}
Parrot_loadbc(interpreter, pf);
Parrot_disassemble(interpreter);
Parrot_destroy(interpreter);
return 0;
}
/*
* Local variables:
* c-indentation-style: bsd
* c-basic-offset: 4
* indent-tabs-mode: nil
* End:
*
* vim: expandtab shiftwidth=4:
*/