edu.arizona.cs.mbel.signature
Class Constraint

java.lang.Object
  extended byedu.arizona.cs.mbel.signature.Signature
      extended byedu.arizona.cs.mbel.signature.Constraint
All Implemented Interfaces:
SignatureConstants

public class Constraint
extends edu.arizona.cs.mbel.signature.Signature

This class decsribes a constraint on a local var. As of right now, the only possible constraint is ELEMENT_TYPE_PINNED, so this class is kinda useless.


Field Summary
 
Fields inherited from interface edu.arizona.cs.mbel.signature.SignatureConstants
ELEMENT_TYPE_ARRAY, ELEMENT_TYPE_BOOLEAN, ELEMENT_TYPE_BYREF, ELEMENT_TYPE_CHAR, ELEMENT_TYPE_CLASS, ELEMENT_TYPE_CMOD_OPT, ELEMENT_TYPE_CMOD_REQD, ELEMENT_TYPE_END, ELEMENT_TYPE_FNPTR, ELEMENT_TYPE_I, ELEMENT_TYPE_I1, ELEMENT_TYPE_I2, ELEMENT_TYPE_I4, ELEMENT_TYPE_I8, ELEMENT_TYPE_INTERNAL, ELEMENT_TYPE_MODIFIER, ELEMENT_TYPE_OBJECT, ELEMENT_TYPE_PINNED, ELEMENT_TYPE_PTR, ELEMENT_TYPE_R4, ELEMENT_TYPE_R8, ELEMENT_TYPE_SENTINEL, ELEMENT_TYPE_STRING, ELEMENT_TYPE_SZARRAY, ELEMENT_TYPE_TYPEDBYREF, ELEMENT_TYPE_TYPEONLY, ELEMENT_TYPE_U, ELEMENT_TYPE_U1, ELEMENT_TYPE_U2, ELEMENT_TYPE_U4, ELEMENT_TYPE_U8, ELEMENT_TYPE_VALUETYPE, ELEMENT_TYPE_VOID
 
Constructor Summary
Constraint()
          Makes a new Constraint (with type PINNED)
 
Method Summary
 void emit(ByteBuffer buffer, ClassEmitter emitter)
          Writes this signature out to a buffer in raw binary form
static byte[] encodeInteger(long value)
          Converts an unsigned integer to its PackedLen integer equivalent
 byte getElementType()
          Returns the type of constraint this is (as of now, always ELEMENT_TYPE_PINNED)
static byte[] makeTypeDefOrRefEncoded(int table, int row)
          Turns a {table num, row num} into a TypeDefOrRefEncoded integer value
static Constraint parse(ByteBuffer buffer)
          Factory method for parsing a constraint from a raw binary blob
static int[] parseTypeDefOrRefEncoded(ByteBuffer buffer)
          Reads a TypeDefOrRefEncoded blob from the given buffer, and returns an int array in the form of {table number, row number}
static int readCodedInteger(ByteBuffer buffer)
          Parses a PackedLen coded integer from the given buffer
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Constraint

public Constraint()
Makes a new Constraint (with type PINNED)

Method Detail

parse

public static Constraint parse(ByteBuffer buffer)
Factory method for parsing a constraint from a raw binary blob

Parameters:
buffer - the buffer to read from
Returns:
a Constraint representing the given blob, or null if there was a parse error

getElementType

public byte getElementType()
Returns the type of constraint this is (as of now, always ELEMENT_TYPE_PINNED)


emit

public void emit(ByteBuffer buffer,
                 ClassEmitter emitter)
Writes this signature out to a buffer in raw binary form

Parameters:
buffer - the buffer to write to

toString

public java.lang.String toString()

readCodedInteger

public static int readCodedInteger(ByteBuffer buffer)
Parses a PackedLen coded integer from the given buffer

Parameters:
buffer - the buffer
Returns:
the decoded integer value

parseTypeDefOrRefEncoded

public static int[] parseTypeDefOrRefEncoded(ByteBuffer buffer)
Reads a TypeDefOrRefEncoded blob from the given buffer, and returns an int array in the form of {table number, row number}

Parameters:
buffer - the buffer to read from
Returns:
an int array with {table num, row num}

makeTypeDefOrRefEncoded

public static byte[] makeTypeDefOrRefEncoded(int table,
                                             int row)
Turns a {table num, row num} into a TypeDefOrRefEncoded integer value

Parameters:
table - the table number (i.e. one of TypeDef, TypeRef, TypeSpec)
row - the row number within the given table (1-based index)
Returns:
the raw binary TypeDefOrRefEncoded blob

encodeInteger

public static byte[] encodeInteger(long value)
Converts an unsigned integer to its PackedLen integer equivalent

Parameters:
value - the value to convert to PackedLen form
Returns:
the raw binary PackedLen blob corresponding to value