t3x.org / t3x / t3x-manual / 4J.html
 
T3X - A Minimum Procedural Language
Version 8.1.5, Online Edition
Copyright(C) 1996-2004
Nils M Holm
 
Previous:
4.18 Loading Tcode
TOC | Index | Back Next:
5. Formal Definitions

4.19 Resolving Interface References

Interface references are references to procedures which are not located in the code area of the Tcode machine. Modules can provide interfaces by exporting IPROC records and request interfaces using IREF records. ICALX instructions are used to call unresolved interfaces and ICALL instructions are used to call resolved interfaces. Resolving an interface means to assign a unique slot number to the name of an interface procedure.

Since multiple modules may export IPROC records and each module starts numbering interfaces at one, the Tcode loader must relocate IPROCs by assigning unique slot numbers to them.

IPROC records and corresponding IREF records may be located in the same module. In any case, though, the IPROC record must precede the IREF record and the IREF record must precede any ICALX instructions referenecing the IREF record. In this section, IPROC and IREF are assumed to be in a different modules.

IPROC records provide a symbolic name for an interface procedure. This symbolic name may be referenced by IREF records. ICALX instructions are used to reference an IREF records defined in the same module. An external reference is resolved in four steps:

  1. The label, which is the operand of a ICALX instruction, is looked up in a table holding the IREF records read so far.
  2. The name contained in the matching IREF record is looked up in another table which holds the IPROC records read so far.
  3. The label contained in the matching IPROC record replaces the external label in the ICALX instruction.
  4. ICALX is replaced with ICALL.

The following figure illustrates the principle of interface references.

       Caller's Module                     Callee's Module
+----------------------------+      +----------------------------+
|                            |      |                            |
|    ,--> IREF I 4 name >===============> IPROC L 4 name         |
|    |                       |      |          \/                |
|    '-------.-.-----------, |      |          ||                |
|            | |           | |      |          ||                |
| ICALX I >--' | ICALX I >-' |      |          ||                |
|              |             |      |          ||                |
|    ICALX I >-'             |      |          ||                |
|                            |      |          ||                |
+----------------------------+      +----------||----------------+
                                               ||
       Tcode Machine or external object               ||
+----------------------------------------------||----------------+
|                                              ||                |
|      Interface procdedure slot #0            ||                |
|      ...                                     ||                |
|      Interface procdedure slot #L <==========='                |
|      ...                                                       |
|                                                                |
+----------------------------------------------------------------+
Fig.9 Interface References

The existance of two IPROC records with the same name is considered an error (redefinition error).

There must be a matching IPROC record for each IREF record at link time. Otherwise, an error is signalled (unresolved interface).

There must be a matching interface procedure for each IPROC record at run time. Otherwise, an error is signalled (unresolved interface).

Previous:
4.18 Loading Tcode
TOC | Index | Back Next:
5. Formal Definitions