struct point {
double x, y;
};
/* A vector is an array of points. N is the number of
points, and p points to the first point in the array. */
struct vector {
int n;
struct point *p;
};
/* A binary tree of vectors, ordered by KEY. */
struct tree {
struct tree *left, *right;
int key;
struct vector *vector;
};
/* Return the node in TREE whose key is KEY.
Return zero if there is no such node. */
struct tree *
find (struct tree *tree, int key)
{
if (!tree)
return 0;
if (key < tree->key)
return find (tree->left, key);
else if (key > tree->key)
return find (tree->right, key);
else
return tree;
}
The expression: tree->vector.p[tree->vector.n - 1]
Compiles to the bytecode:
reg 8 ; push value of "tree"
const8 8
add ; compute address of tree->vector
trace_quick 4 ; record its value in log
ref32 ; get value of tree->vector
const8 4
add
trace_quick 4
ref32 ; get value of tree->vector.p
reg 8
const8 8
add
trace_quick 4
ref32
trace_quick 4
ref32 ; get value of tree->vector.n
const8 1
sub ; compute tree->vector.n - 1
const8 16
mul
add ; do pointer arithmetic
const8 16
trace
end ; collect entire point structure