|
| Previous: 4.17.1 Generated Hints | TOC | Index | Back | Next: 4.19 Resolving Interface References |
The Tcode language provides a set of instructions for binding modules which were compiled separately. External references are limited to procedure calls. This means that a module can call procedures defined in an external module, but it cannot access an external module's data.
To call an external procedure, the label which tags the entry point of the routine must be declared public (using a PUB instruction) in the module containing the called routine. In the module of the caller, it must be declared extern (using EXT).
The PUB instruction provides a symbolic name for a procedure. This symbolic name may be referenced by EXT in a different module. CALX instructions are used to reference an EXT instruction defined in the same module. An external reference is resolved in four steps:
The following figure illustrates the principle of external references.
+----------------------------+ +----------------------------+
| | | |
| ,--> EXT E 4 name >================> PUB L 4 name |
| | | | CLAB L HDR ... END |
| '-------.-.-----------, | | |
| | | | | | |
| CALX E >--' | CALX E >-' | | |
| | | | |
| CALX E >-' | | |
| | | |
+----------------------------+ +----------------------------+
Caller's Module Callee's Module
|
| Fig.8 External References |
Since labels are represented by integers in Tcode, label collisions will occur when binding two (or more) Tcode modules. Therefore, labels must be renamed: When a module A already has been loaded and a module B is to be loaded, the highest label ID used in A should be added to each (non-external) label in B.
Two or more EXT records with the same name may exist, because the same symbol may be associated with different external labels in different modules.
The existance of two PUB records with the same name is considered an error (redefinition error).
There must be a matching PUB record for each EXT record. Otherwise, an error is signalled (unresolved external).
| Previous: 4.17.1 Generated Hints | TOC | Index | Back | Next: 4.19 Resolving Interface References |