#!/bin/sh

#   usage
if [ $# -eq 0 ]; then
    echo "$0: USAGE: asmifier <jar-file> <class-name>" 1>&2
    echo "$0: USAGE: asmifier [<class-directory>] <class-name>" 1>&2
    exit 1
fi

#   determine dumping mode (ASM instructions or bytecode mnemonic)
class="org.objectweb.asm.util.ASMifierClassVisitor"
if [ ".$1" = "-m" ]; then
   class="org.objectweb.asm.util.TraceClassVisitor"
   shift
fi

#   allow to decode .class files from current directory
if [ $# -eq 1 ]; then
    set -- . "$1"
fi

#   late sanity check for usage
if [ $# -ne 2 ]; then
    echo "$0: ERROR: invalid number of arguments" 1>&2
    exit 1
fi

#   execute ASMifier
@l_prefix@/bin/java -cp "@l_prefix@/libexec/asmifier/asm-all.jar:$1" $class "$2"

