/*
* Created on Oct 18, 2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package org.apache.bcel;
/**
* @author dorina
*
* TODO To change the template for this generated type comment go to Window -
* Preferences - Java - Code Style - Code Templates
*/
public abstract class SignatureConstants {
//public final static byte SIMPLE_CODIFICATION = 0x01;
public final static byte CODIF_4B = 0x01;
//public final static byte DOUBLE_CODIFICATION = 0x02;
public final static byte CODIF_8B = 0x02;
public final static byte CODIF_6B = 0x04;
public final static byte CODIF_14B = 0x08;
public final static byte ERROR_CODIFICATION = 0x05;
/**
* used to specified if a the codification it's a new signature, or it contains only the links missing from the previous signature
*
*/
public final static byte ACC_NEW_SIGNATURE = 0x10;
/** number of bytes used to specify
* the length of an multiobject,
*
*/
public final static int MULTIOBJECT_LENGTH_SIZE = 1;
/** number of bytes used to specify
* the length of the stack and local variables,
*
*/
public final static int STACK_LENGTH_SIZE = 1;
/**
*
*
*/
public final static int JVMTYPE_SIZE = 2;
public final static int CSTPOOL_SIZE = 2;
/** number of bytes used to specify
* the height of stack
* total size of a frame
* number of external methods
*/
public final static int TOTAL_LENGTH_SIZE = 2;
/**
* number of byte used to specify
* number of labels in a method
* the label (number of order) of a bytecode
*/
public final static int LABEL_BYTECODE_SIZE = 2;
public static byte[] toByteArray(int foo) {
return toByteArray(foo, 4);
}
public static byte[] toByteArray(int foo, int size) {
byte[] array = new byte[size];
for (int iInd = 0; iInd < array.length; ++iInd) {
array[iInd] = (byte) ((foo >> (iInd * 8)));
}
return array;
}
/*
* reads an int represented on size
bytes from array,
* starting at position index
*/
public static int readInt(byte[]array, int index, int size){
int a = 0;
for(int i = index; i < size+index; i++) {
int b = array[i];
if(b < 0) b += 256;
a = a + (b << 8*(i-index));
}
return a;
}
}