1 30 31 package jbet.cmd; 32 import jbet.*; 33 import java.io.*; 34 38 39 public class disassemble implements Command 40 { 41 public int helplevel() { return 1; } 42 public String shorthelp() { return "disassemble a class or method"; } 43 public String longhelp() { return 44 "jbet disassemble <class>\t\tDisassemble <class>\n" + 45 "jbet disassemble <class>.<method>\tDisassemble <method>\n" + 46 "The output is suitable for input to jbet assemble."; } 47 48 public void run (Lexer lexer) throws Exception { 49 LineWriter output = Jbet.output; 50 loop: 51 while(true) { 52 switch(lexer.read().type) { 53 case 'o': 54 lexer.push(Lexer.ST_STRING); 55 String filename = lexer.parse_string(); 56 lexer.pop(); 57 throw new IllegalStateException ("-o option not implemented"); 58 59 case Token.END_OF_OPTS: break loop; 60 default: lexer.unexpected(lexer.justread()); 61 } 62 } 63 64 66 67 Object thing = lexer.getThing (Jbet.default_class); 68 69 if ( thing instanceof ClassInfo ) 70 ((ClassInfo) thing).disassemble(output, ""); 71 else if ( thing instanceof MethodInfo ) 72 ((MethodInfo) thing).disassemble(output, ""); 73 else if ( thing instanceof FieldInfo ) 74 ((FieldInfo) thing).disassemble(output, ""); 75 } 76 } 77 | Popular Tags |