Compiling from GT.M

In Direct Mode, GT.M provides access to the compiler explicitly through the ZLINK and ZCOMPILE commands, and implicitly through automatic invocation of ZLINK functionality (auto-ZLINK) to add required routines to the image. ZCOMPILE is a GT.M routine compilation command, it compiles the routine and creates a new object module. The primary task of ZLINK is to place the object code in memory and "connect" it with other routines. However, under certain circumstances, ZLINK may first use the GT.M compiler to create a new object module.

The difference between ZCOMPILE and ZLINK is that ZCOMPILE creates a new object module on compiling, whereas the ZLINK command links the object module with other routines and places the object code in memory.

ZLINK compiles under these circumstances:

Auto-ZLINK compiles under the first two circumstances, but can never encounter the last one.

When a command refers to an M routine that is not part of the current image, GT.M automatically attempts to ZLINK and, if necessary, compile that routine. In Direct Mode, the most common method to invoke the compiler through an auto-ZLINK is to enter DO ^routinename at the GTM> prompt. When the current image does not contain the routine, GT.M does the following:

By using the DO command, you implicitly instruct GT.M to compile, link, and execute the program. With this method, you can test your routine interactively.

For complete descriptions of ZCOMPILE, ZLINK and auto-ZLINK, refer to the "Commands" chapter in this manual .

Example:

        GTM>DO ^PAYROLL
        GTM>DO ^TAXES
        

This uses the M DO command to invoke the GT.M compiler implicitly from the GTM> prompt if the routine requires new object code. When the compiler runs, it produces two object module files, PAYROLL.OBJ and TAXES.OBJ.

If you receive error messages from the compilation, you may fix them immediately by returning to the editor and correcting the source. By default, the GT.M compiler operates in "compile-as-written" mode, and produces object code even when a routine contains syntax errors. This code includes all lines that are correct and all commands on a line with an error, up to the error. Therefore, you may decide to tailor the debugging cycle by running the program without removing the syntax errors.

[Caution]

The DO command does not add an edited routine to the current image if the image already includes a routine matching the DO argument routine name. When the image contains a routine, GT.M simply executes the routine without examining whether a more recent version of the module exists. If you have a routine in your image, and you wish to change it, you must explicitly ZLINK that routine.

Example:

        GTM>ZLINK "PAYROLL"
        GTM>ZLINK "TAXES.M"
        

The first ZLINK compiles PAYROLL .M if it cannot locate PAYROLL or if it finds that PAYROLL.M has a more recent date/time stamp than PAYROLL.OBJ. The second ZLINK always compiles TAXES producing a new TAXES.OBJ.

For more information on debugging in GT.M Direct Mode, refer to the "Operating and Debugging in Direct Mode" chapter in this manual.

A ZLINK argument may contain qualifiers that affect the compiler.

Example:

          GTM>ZLINK "TAXES.M":"/NOOBJECT/LIST"
        

In this example ZLINK compiles the routine "TAXES", producing a listing and no object. Because the ZLINK does not produce an object, it does not change the current image.

During auto-ZLINK and when the ZLINK argument does not contain any compiler qualifiers, GT.M uses any qualifiers specified in $ZCOMPILE. For more information on $ZCOMPILE, refer to the "Intrinsic Special Variables" chapter in this manual. This chapter gives detailed descriptions of the MUMPS command qualifiers in the section on "Compiling from DCL", which follows.