Package com.strobel.reflection.emit
Class CodeStream
java.lang.Object
com.strobel.reflection.emit.CodeStream
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate byte[]
The content of this stream.private int
Actual number of bytes in this stream.private static final int
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newCodeStream
with a default initial size.CodeStream
(int initialSize) Constructs a newCodeStream
with the given initial size. -
Method Summary
Modifier and TypeMethodDescription(package private) void
ensureCapacity
(int size) Enlarge this byte stream so that it can receive n more bytes.byte[]
getData()
int
(package private) CodeStream
put11
(int b1, int b2) Puts two bytes into this byte stream.(package private) CodeStream
put12
(int b, int s) Puts a byte and a short into this byte stream.putByte
(int b) Puts a byte into this byte stream.putByteArray
(byte[] b, int offset, int length) Puts an array of bytes into this byte stream.putDouble
(double d) Puts a double into this byte stream.putFloat
(float f) Puts a float into this byte stream.putInt
(int i) Puts an int into this byte stream.putLong
(long l) Puts a long into this byte stream.putShort
(int s) Puts a short into this byte stream.Puts an UTF8 string into this byte stream.void
reset()
void
reset
(int initialSize)
-
Field Details
-
DEFAULT_SIZE
private static final int DEFAULT_SIZE- See Also:
-
_data
private byte[] _dataThe content of this stream. -
_length
private int _lengthActual number of bytes in this stream.
-
-
Constructor Details
-
CodeStream
public CodeStream()Constructs a newCodeStream
with a default initial size. -
CodeStream
public CodeStream(int initialSize) Constructs a newCodeStream
with the given initial size.- Parameters:
initialSize
- the initial size of the byte stream to be constructed.
-
-
Method Details
-
reset
public void reset() -
reset
public void reset(int initialSize) -
getData
public byte[] getData() -
getLength
public int getLength() -
putByte
Puts a byte into this byte stream. The byte stream is automatically enlarged if necessary.- Parameters:
b
- a byte.- Returns:
- this byte stream.
-
put11
Puts two bytes into this byte stream. The byte stream is automatically enlarged if necessary.- Parameters:
b1
- a byte.b2
- another byte.- Returns:
- this byte stream.
-
putShort
Puts a short into this byte stream. The byte stream is automatically enlarged if necessary.- Parameters:
s
- a short.- Returns:
- this byte stream.
-
put12
Puts a byte and a short into this byte stream. The byte stream is automatically enlarged if necessary.- Parameters:
b
- a byte.s
- a short.- Returns:
- this byte stream.
-
putInt
Puts an int into this byte stream. The byte stream is automatically enlarged if necessary.- Parameters:
i
- an int.- Returns:
- this byte stream.
-
putLong
Puts a long into this byte stream. The byte stream is automatically enlarged if necessary.- Parameters:
l
- a long.- Returns:
- this byte stream.
-
putFloat
Puts a float into this byte stream. The byte stream is automatically enlarged if necessary.- Parameters:
f
- a float.- Returns:
- this byte stream.
-
putDouble
Puts a double into this byte stream. The byte stream is automatically enlarged if necessary.- Parameters:
d
- a double.- Returns:
- this byte stream.
-
putUtf8
Puts an UTF8 string into this byte stream. The byte stream is automatically enlarged if necessary.- Parameters:
s
- a String.- Returns:
- this byte stream.
-
putByteArray
Puts an array of bytes into this byte stream. The byte stream is automatically enlarged if necessary.- Parameters:
b
- an array of bytes. May be null to put length null bytes into this byte stream.offset
- index of the fist byte of b that must be copied.length
- number of bytes of b that must be copied.- Returns:
- this byte stream.
-
ensureCapacity
void ensureCapacity(int size) Enlarge this byte stream so that it can receive n more bytes.- Parameters:
size
- number of additional bytes that this byte stream should be able to receive.
-