public final class StackValue extends Object
Modifier and Type | Method and Description |
---|---|
static <T extends PointerBase> |
get(Class<T> structType)
Reserves a block of memory for given
CStruct class in the stack frame of the method
that calls this intrinsic. |
static <T extends PointerBase> |
get(int size)
Reserves a block of memory in the stack frame of the method that calls this intrinsic.
|
static <T extends PointerBase> |
get(int numberOfElements,
Class<T> structType)
Reserves a block of memory for array of given
CStruct type in the stack frame of the
method that calls this intrinsic. |
static <T extends PointerBase> |
get(int numberOfElements,
int elementSize)
Utility method that performs size arithmetic, otherwise equivalent to
StackValue.get(int) . |
public static <T extends PointerBase> T get(Class<T> structType)
CStruct
class in the stack frame of the method
that calls this intrinsic. This is a convenience method for calls to:
ComplexValue numberOnStack =It can be used to allocate a structure on the stack. The following example allocates aStackValue
.get(SizeOf
.get(ComplexValue.class));
ComplexValue
and then sends it as a regular parameter to another function to compute
absolute value of the number:
ComplexValue numberOnStack = StackValue
.get(ComplexValue.class);
numberOnStack.realPart(3.0);
numberOnStack.imagineryPart(4.0);
double absoluteValue = absoluteValue(numberOnStack);
assert 5.0 == absoluteValue;
T
- the type, annotated by CStruct
annotationstructType
- the requested structure class - must be a compile time constantIllegalThreadStateException
- when called in a virtual thread.public static <T extends PointerBase> T get(int numberOfElements, Class<T> structType)
CStruct
type in the stack frame of the
method that calls this intrinsic. This is a convenience method for calls to:
IntOrDouble arrayOnStack =It can be used to allocate a array of parameters on the stack. The following example allocates a three element array, fills them with two int values and one double value and then sends it to a method that accepts such parameter convention:StackValue
.get( 3, // number of array elementsSizeOf
.get(IntOrDouble.class));
IntOrDouble array = StackValue
.get(3, IntOrDouble.class);
array.addressOf(0).i(10);
array.addressOf(2).i(12);
array.addressOf(3).d(20.0);
double sum = acceptIntIntDouble(array);
T
- the type, annotated by CStruct
annotationnumberOfElements
- number of array elements to allocatestructType
- the requested structure class - must be a compile time constantIllegalThreadStateException
- when called in a virtual thread.public static <T extends PointerBase> T get(int size)
null
. The size must be a
compile time constant.
If the call to this method is in a loop, always the same pointer is returned. In other words:
this method does not allocate memory; it returns the address of a fixed-size block of memory
that is reserved in the stack frame when the method starts execution. The memory is not
initialized. Two distinct calls of this method return different pointers.IllegalThreadStateException
- when called in a virtual thread.public static <T extends PointerBase> T get(int numberOfElements, int elementSize)
StackValue.get(int)
.