BARfly Help - BAR Implementation File Reference - Expressions

  Special Load Considerations

Some expressions can be interpreted in more than one way.

Zero

The constant value of zero can mean two things:  a scalar value of zero, or a pointer value of zero (null pointer).  The actual interpretation depends on how the expression is ultimately handled with associated operators:  scalar or pointer value is chosen depending on the expectation.

If there is an ambiguous context (either scalar or pointer type is expected), directly casting the value of zero will remove the ambiguity:

(void*)0;
(unsigned long)0;

The “this” pointer

The “this” pointer is always valid for member functions, and loads as a non-L-value pointer.  The pointer’s type is to void for member functions of blocks; the type is to the member scope for member functions of structures.

The “this” pointer causes an error if used in a global function.

For organized blocks, the “this” pointer always points to a node handle.  The pointer cannot be used to address memory, but it can be used to look up siblings, parents, children, and information of the node with operators such as getnext or getuid.

For unorganized blocks, the “this” pointer points to either a node handle or to memory.  A node handle is chosen when the unorganized block is empty; a memory location is chosen when the unorganized block is not empty.

Regardless of whether the “this” pointer is implemented as a node handle or memory pointer, you can use operators like getnext and getuid on the pointer.  BAR is always capable of figuring out the nodes to which you are are trying to refer.

Short Strings

Short strings, which are delimited by single quotes, can have more than one meaning in an expression:  a scalar value representation of the characters, or a pointer value to constant data (what would be expected for an ordinary null-terminated string).

The actual interpretation depends on how the expression is ultimately handled with associated operators:  scalar or pointer value is chosen depending on the expectation.

If there is an ambiguous context (either scalar or pointer type is expected), directly casting the string will remove the ambiguity:

(char*)'ab';
(unsigned long)'BAR1';

Structures derived from Simple Type

Structures derived from simple type are treated synonymously with the simple type of derivation (not as a structured type with its own members).


  See also:  [Expression characteristics] [Identifier interpretations] [Built-in functions] [Special load considerations]
[Additional rules for expressions] [Final expression type result] [L-value status gain and loss]
[Overly complex expressions] [Limitations on pointer usage] [Structure member dereference:  bit scan blocks]


BARfly Help Copyright © 2009 Christopher Allen