3.2.4.12 Working with pointers, structs and unions

C++ Function: gccjit::lvalue gccjit::rvalue::dereference (gccjit::location loc)

Given an rvalue of pointer type T *, dereferencing the pointer, getting an lvalue of type T. Analogous to:

*(EXPR)

in C.

Parameter “loc” is optional.

If you don’t need to specify the location, this can also be expressed using an overloaded operator:

C++ Function: gccjit::lvalue gccjit::rvalue::operator* ()
gccjit::lvalue content = *ptr;

Field access is provided separately for both lvalues and rvalues:

C++ Function: gccjit::lvalue gccjit::lvalue::access_field (gccjit::field field, gccjit::location loc)

Given an lvalue of struct or union type, access the given field, getting an lvalue of the field’s type. Analogous to:

(EXPR).field = ...;

in C.

C++ Function: gccjit::rvalue gccjit::rvalue::access_field (gccjit::field field, gccjit::location loc)

Given an rvalue of struct or union type, access the given field as an rvalue. Analogous to:

(EXPR).field

in C.

C++ Function: gccjit::lvalue gccjit::rvalue::dereference_field (gccjit::field field, gccjit::location loc)

Given an rvalue of pointer type T * where T is of struct or union type, access the given field as an lvalue. Analogous to:

(EXPR)->field

in C, itself equivalent to (*EXPR).FIELD.

C++ Function: gccjit::lvalue gccjit::context::new_array_access (gccjit::rvalue ptr, gccjit::rvalue index, gccjit::location loc)

Given an rvalue of pointer type T *, get at the element T at the given index, using standard C array indexing rules i.e. each increment of index corresponds to sizeof(T) bytes. Analogous to:

PTR[INDEX]

in C (or, indeed, to PTR + INDEX).

Parameter “loc” is optional.

For array accesses where you don’t need to specify a gccjit;;location, two overloaded operators are available:

gccjit::lvalue gccjit::rvalue::operator[] (gccjit::rvalue index)

gccjit::lvalue element = array[idx];

gccjit::lvalue gccjit::rvalue::operator[] (int index)

gccjit::lvalue element = array[0];