Contents Up << >>

Access types

An access type is used to define a type for declaring what is usually called a pointer. A pointer is an object that points to another object and can point to different objects during execution. The access type defines the type of the pointer object. The access type definition follows the grammar rule:

incomplete-type-definition : TYPE simple-name ";"
access-type-definition : ACCESS subtype
For every access type, there is a predefined value null that indicates the pointer does not point to anything. When defining access types it is useful to be able to reference a certain type before that type is fully defined. The incomplete type definition specifies a type name that may be used in this manner. It must have a corresponding full definition.

The most common use of pointers is for a linked list. The following is an example of how a linked list can be declared.

type node;
type node_ptr is access node;
type node is record
    value : integer;
    next : node_ptr;
  end record;

variable list1,list2 : node_ptr;
The node_ptr type defines a pointer that can be used to build a list of integer values. An object of an access type must be a variable. The variable list1 can be used in two different ways. It can be used as a pointer value or as the object it points to. If the variable name appears in an expression or target by itself, then it represents the pointer value. If it appears in a selected, indexed, or slice name then it represents the object that it points to. For example,
list1:=list2;
makes list1 point to the same object as list2,
list1.all:=list2.all;
assigns the value of the object pointed to by list2 to the object pointed to by list1, and
list1.value:=list2.value;
assigns the value of the value field of the object pointed to by list2 to the value field of the object pointed to by list1.

The new operator allocates a new object of the specified type and returns a pointer value to that object. For example,

list1:=new node;
would create a new object of the type node and set list1 to point to that new object.<P> There is also a predefined procedure, free, for every access type that deallocates space that was created with the new operator. For example,
free(list1);
would deallocate the space referred to by the list1 variable in the above assignment statement.

New file capabilities.
New operators.
File parameters.
Expression port actuals.
Direct instantiations.
New attributes.
PURE and IMPURE functions.
Report statement.
Uniform syntax.
Shared variables.
Generate declarations.
Extended identifiers.
Extended character set
UNAFFECTED waveform.