Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

analy_java.cc

Go to the documentation of this file.
00001 /* 
00002  *      HT Editor
00003  *      analy_java.cc
00004  *
00005  *      Copyright (C) 1999-2002 Sebastian Biallas (sb@web-productions.de)
00006  *
00007  *      This program is free software; you can redistribute it and/or modify
00008  *      it under the terms of the GNU General Public License version 2 as
00009  *      published by the Free Software Foundation.
00010  *
00011  *      This program is distributed in the hope that it will be useful,
00012  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *      GNU General Public License for more details.
00015  *
00016  *      You should have received a copy of the GNU General Public License
00017  *      along with this program; if not, write to the Free Software
00018  *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  */
00020 
00021 #include "analy_register.h"
00022 #include "analy_java.h"
00023 #include "htdebug.h"
00024 #include "javadis.h"
00025 
00026 #include <string.h>
00027 
00028 /*
00029  *
00030  */
00031 void AnalyJavaDisassembler::init(Analyser *A, java_token_func token_func, void *context)
00032 {
00033         disasm = new javadis(token_func, context);
00034         AnalyDisassembler::init(A);
00035 }
00036 
00037 /*
00038  *
00039  */
00040 int  AnalyJavaDisassembler::load(ht_object_stream *f)
00041 {
00042         return AnalyDisassembler::load(f);
00043 }
00044 
00045 /*
00046  *
00047  */
00048 void AnalyJavaDisassembler::done()
00049 {
00050         AnalyDisassembler::done();
00051 }
00052 
00053 /*
00054  *
00055  */
00056 OBJECT_ID       AnalyJavaDisassembler::object_id() const
00057 {
00058         return ATOM_ANALY_JAVA;
00059 }
00060 
00061 /*
00062  *
00063  */
00064 
00065 Address *AnalyJavaDisassembler::branchAddr(OPCODE *opcode, branch_enum_t branchtype, bool examine)
00066 {
00067         javadis_insn *o = (javadis_insn*)opcode;
00068         switch (o->op[0].type) {
00069                 case JAVA_OPTYPE_LABEL:
00070                         return new AddressFlat32(o->op[0].label);
00071         }
00072         return new InvalidAddress();
00073 }
00074 
00075 /*
00076  *
00077  */
00078 void AnalyJavaDisassembler::examineOpcode(OPCODE *opcode)
00079 {
00080 /*      javadis_insn *o = (javadis_insn*)opcode;
00081         for (int i=0; i<JAVAINSN_MAX_PARAM_COUNT; i++) {
00082                 java_insn_op *op = &o->op[i];
00083                 ADDR Addr = INVALID_ADDR;
00084                 taccess access;
00085                 xref_type_t xref = xrefoffset;
00086                 switch (op->type) {
00087                         case JAVA_OPTYPE_LABEL:
00088                                 Addr = op->label;
00089                                 access.type = acoffset;
00090                                 access.indexed = false;
00091                                 break;
00092                 }
00093                 if (Addr != INVALID_ADDR) {
00094                         if (analy->valid_addr(Addr, scvalid)) {
00095                                 analy->data_access(Addr, access);
00096                                 analy->add_xref(Addr, analy->addr, xref);
00097                         }
00098                 }
00099         }*/
00100 }
00101 
00102 /*
00103  *
00104  */
00105 branch_enum_t AnalyJavaDisassembler::isBranch(OPCODE *opcode)
00106 {
00107         javadis_insn *o = (javadis_insn*)opcode;
00108         char *opcode_str = o->name;
00109         if ((opcode_str[0]=='i') && (opcode_str[1]=='f')) {
00110                 return br_jXX;
00111         } else if ((strcmp("tableswitch", opcode_str)==0)
00112         || (strcmp("lookupswitch", opcode_str)==0)) {
00113                 return br_jXX;
00114         } else if (strncmp("ret", opcode_str, 3)==0
00115         || strncmp("ret", opcode_str+1, 3)==0
00116         || strncmp("athrow", opcode_str, 6)==0) {
00117                 return br_return;
00118         } else if (strncmp("goto", opcode_str, 4)==0) {
00119                 return br_jump;
00120         } else if (strncmp("jsr", opcode_str, 3)==0) {
00121                 return br_call;
00122         } else return br_nobranch;
00123 }
00124 
00125 /*
00126  *
00127  */
00128 void AnalyJavaDisassembler::store(ht_object_stream *f)
00129 {
00130         AnalyDisassembler::store(f);
00131 }
00132 
00133 

Generated on Fri May 7 21:15:28 2004 by doxygen 1.3.5