Translation elements

 

     

Structure of a C program

Parameter passing

Temporary variables     

Implementation of abstract types             

Files

Operation nomination

Translation parameters

Optimisations

Structure of a C program
 

#include <stdio.h>
#include <stdlib.h>
...
typedef ...

#define ...
#define ...

Implementation (Types and operations)

Declaration of static variables

Standard functions
Macro operations

Function prototypes

Function 1
{

Dynamic allocation ( malloc )
Variable declaration
Body
}


Function 2
{

Dynamic allocation ( malloc )
Variable declaration
Body
}

...
int main(int argc, char *argv[])
{
Dynamic allocation (malloc)
system("PAUSE");
return 0;
}

 


 Parameter passing

All the parameters are passed by addresses : use of symbol * in formal parameters  and symbol & in effective parameters.
when calling 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

The first file block is the header block.


Special management of opened 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

he 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 C 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 translator.