* Removed all Id tags.
[cacao.git] / src / vm / jit / intrp / disass.c
index 2687816854be18de893729ac12e79c41fbf23c40..5d5098990218ae758f65dbdb79711c42c418d90c 100644 (file)
@@ -1,9 +1,9 @@
-/* src/vm/jit/intrp/disass.c - primitive disassembler for alpha machine code
+/* src/vm/jit/intrp/disass.c - disassembler wrapper for interpreter
 
-   Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
-   R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
-   C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
-   Institut f. Computersprachen - TU Wien
+   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
 
    This file is part of CACAO.
 
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA.
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
 
-   Contact: cacao@complang.tuwien.ac.at
+   Contact: cacao@cacaojvm.org
 
    Authors: Andreas Krall
             Reinhard Grafl
 
-   $Id: disass.c 3138 2005-09-02 15:15:18Z twisti $
+   Changes: Christian Thalinger
+            Anton Ertl
+                       Edwin Steiner
 
 */
 
 
+#include "config.h"
+
 #include <stdio.h>
 
-#include "vm/jit/intrp/disass.h"
-#include "vm/jit/intrp/intrp.h"
+#include "vm/types.h"
 
-char *regs[] = {
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-};
+#include "vm/jit/intrp/intrp.h"
 
 
 /* function disassinstr ********************************************************
@@ -91,10 +50,17 @@ char *regs[] = {
 
 *******************************************************************************/
 
-s4 disassinstr(s4 *code)
+u1 *intrp_disassinstr(u1 *code)
 {
-       char *end = (char *)vm_disassemble_inst((Inst *)code, vm_prim);
-       return end - (char *)code;
+       FILE *savedout;
+       u1   *r;
+
+       savedout = vm_out;
+       vm_out = stdout;
+       r = (u1 *) vm_disassemble_inst((Inst *) code, vm_prim);
+       vm_out = savedout;
+
+       return r;
 }
 
 
@@ -106,13 +72,15 @@ s4 disassinstr(s4 *code)
 
 *******************************************************************************/
 
-void disassemble(s4 *code, s4 len)
+void intrp_disassemble(u1 *start, u1 *end)
 {
-       s4 i;
-       s4 seqlen;
+       FILE *savedout;
 
-       printf ("  --- disassembler listing ---\n");
-       vm_disassemble((Inst *)code, (Inst *)(((char *)code)+len), vm_prim);
+       printf("  --- disassembler listing ---\n");
+       savedout = vm_out;
+       vm_out = stdout;
+       vm_disassemble((Inst *) start, (Inst *) end, vm_prim);
+       vm_out = savedout;
 }
 
 
@@ -184,7 +152,7 @@ void printarg_aaTarget(Inst **            aaTarget)
 void printarg_aClass  (classinfo *        aClass  )
 {
        if (aClass)
-               utf_fprint_classname(vm_out, aClass->name);
+               utf_fprint_printable_ascii_classname(vm_out, aClass->name);
        else
                fprintf(vm_out, "NULL");
 }
@@ -204,13 +172,24 @@ void printarg_af      (functionptr        af      )
        fprintf(vm_out, "f: %p", (void *)af);
 }
 
+void printarg_afi     (fieldinfo *        afi      )
+{
+       if (afi) {
+               utf_fprint_printable_ascii_classname(vm_out, afi->class->name);
+               fprintf(vm_out, ".");
+               utf_fprint_printable_ascii(vm_out, afi->name);
+               utf_fprint_printable_ascii(vm_out, afi->descriptor);
+       } else
+               fprintf(vm_out, "fi=NULL");
+}
+
 void printarg_am      (methodinfo *       am      )
 {
        if (am) {
-               utf_fprint_classname(vm_out, am->class->name);
+               utf_fprint_printable_ascii_classname(vm_out, am->class->name);
                fprintf(vm_out, ".");
-               utf_fprint(vm_out, am->name);
-               utf_fprint(vm_out, am->descriptor);
+               utf_fprint_printable_ascii(vm_out, am->name);
+               utf_fprint_printable_ascii(vm_out, am->descriptor);
        } else
                fprintf(vm_out, "m=NULL");
 }
@@ -228,9 +207,9 @@ void printarg_ainst   (Inst *             ainst   )
 void printarg_auf     (unresolved_field * auf     )
 {
        if (auf) {
-               utf_fprint(vm_out, auf->fieldref->name);
+               utf_fprint_printable_ascii(vm_out, auf->fieldref->name);
                fprintf(vm_out, " (type ");
-               utf_fprint(vm_out, auf->fieldref->descriptor);
+               utf_fprint_printable_ascii(vm_out, auf->fieldref->descriptor);
                fprintf(vm_out, ")");
        } else
                fprintf(vm_out, "NULL");
@@ -239,10 +218,10 @@ void printarg_auf     (unresolved_field * auf     )
 void printarg_aum     (unresolved_method *aum     )
 {
        if (aum) {
-               utf_fprint_classname(vm_out, aum->methodref->classref->name);
+               utf_fprint_printable_ascii_classname(vm_out, METHODREF_CLASSNAME(aum->methodref));
                fprintf(vm_out, ".");
-               utf_fprint(vm_out, aum->methodref->name);
-               utf_fprint(vm_out, aum->methodref->descriptor);
+               utf_fprint_printable_ascii(vm_out, aum->methodref->name);
+               utf_fprint_printable_ascii(vm_out, aum->methodref->descriptor);
        } else
                fprintf(vm_out, "NULL");
 }
@@ -251,7 +230,7 @@ void printarg_avftbl  (vftbl_t *          avftbl  )
 {
        if (avftbl) {
                fprintf(vm_out, "vftbl: ");
-               utf_fprint_classname(vm_out, avftbl->class->name);
+               utf_fprint_printable_ascii_classname(vm_out, avftbl->class->name);
        } else
                fprintf(vm_out, "NULL");
 }
@@ -268,4 +247,5 @@ void printarg_avftbl  (vftbl_t *          avftbl  )
  * c-basic-offset: 4
  * tab-width: 4
  * End:
+ * vim:noexpandtab:sw=4:ts=4:
  */