Translation elements

 

     

Structure of a PASCAL program

Parameter passing

Temporary variables     

Implementation of abstract types             

Files

Operation nomination

Translation parameters

Optimisations

Structure of  a PASCAL programme
 

PROGRAM My_program;
Implementation (types and operations)

Declaration of static variables ( My_program)
Standard functions
Macro operations

Function/Procedure prototypes (Forward)


Module 1 ( Procedure or Function)
BEGIN

Dynamic allocation ( New )
Local variables
Body

END;



Module 2 ( Procedure or Function)
BEGIN

Dynamic allocation ( New )
Local variables
Body

END;
...
BEGIN ( Main program )
Dynamic allocation ( New )
Body of  My_program
READLN;
END.

Parameter Passing

All the parameters are passed by addresses ( VAR Option).

when calling procedure or functions, temporary variables are generated for expressions (_Px1,_Px2, etc. )
 

Temporary variables  

Temporary variables, structures or arrays can be generated by the translator.

There are prefixed by symbol '_'.
 


Implementation of abstract types

All the machines are implemented using addresses.

Address to the structure
Address to the array
Address to the file block
 


Files
 

In PASCAL, the library Sysutils is used with the functions  : Filecreate, Fileopen, Fileclose, Fileseek, Filewrire et Fileread.

The first file block is the header block.
 

Special management of open files

        _Push_open: push an open file (Name and Handle)
        _Pop_open: pop the last open file (Name) of a given handle.
        _Open : test if a given file name exists or not.

When defining a file, two structures are considered.

- Definition of file structure block with addresses. If there is an array inside the block, its address is considered.

- Definition du file block (without address)
 


Operation nomination 

The names of machine operations are postfixed by the types.

Translation parameters

The Z language allows sharing files, i.e, a file can be opened several times. According to the PASCAL compiler used, charing a file cannot be allowed. In this case, a special mangement of open files is integrated in the translator.

Optimisations

Some optimisations remain to do such as recovery of temporary variables generated by the translateur.