FAUST compiler  0.9.9.6b8
Functions
privatise.cpp File Reference
#include "sigtype.hh"
#include "compatibility.hh"
#include <stdio.h>
#include "sigprint.hh"
#include "sigtyperules.hh"
#include "privatise.hh"
Include dependency graph for privatise.cpp:

Go to the source code of this file.

Functions

static Tree makePrivatisationKey (const Tree &t)
static Tree makePrivatisationLabel (const Tree &exp)
static Tree privatisation (const Tree &k, const Tree &t)
static Tree computePrivatisation (const Tree &k, const Tree &t)
static Tree labelize (const Tree &label, const Tree &exp)
Tree privatise (const Tree &t)

Function Documentation

static Tree computePrivatisation ( const Tree k,
const Tree t 
) [static]

Definition at line 102 of file privatise.cpp.

References CTree::arity(), CTree::branch(), isRec(), isSigGen(), isSigTable(), isSigWRTbl(), labelize(), makePrivatisationLabel(), nil, CTree::node(), privatisation(), rec(), setProperty(), sigWRTbl(), and tree().

Referenced by privatisation().

{
    Tree    tbl, size, idx, wrt, content, id, var, body;

    if ( isSigWRTbl(exp, id, tbl, idx, wrt) )   {
        /*  Ce qui ne peut pas être partagé, ce sont les
            tables dans lesquelles on ecrit. Pour cela
            on leur donne un label unique
        */
        return sigWRTbl(
                    id,
                    labelize( makePrivatisationLabel(exp), privatisation(k, tbl) ),
                    privatisation(k, idx),
                    privatisation(k, wrt) );

    } else if ( isSigTable(exp, id, size, content) ) {
        /*  Rien à privatiser dans une table (car size est
            censée etre une expression entiere)
        */
        return exp;

    } else if ( isSigGen(exp, content) ) {
        /*  On ne visite pas les contenus des tables
        */
        printf("erreur 1 dans computePrivatisation\n");
        exit(1);

    } else if ( isRec(exp, var, body) ) {
        /*  On ne visite pas les contenus des tables
        */
        setProperty(exp, k, nil);
        return rec(var, privatisation(k,body));

    } else {
        /*  On parcours les autres arbres en privatisant les branches
        */
        int n = exp->arity();

        switch (n) {

            case 1 :
                return tree(
                        exp->node(),
                        privatisation(k, exp->branch(0)) );
            case 2 :
                return tree(
                        exp->node(),
                        privatisation(k, exp->branch(0)),
                        privatisation(k, exp->branch(1)) );
            case 3 :
                return tree (
                        exp->node(),
                        privatisation(k, exp->branch(0)),
                        privatisation(k, exp->branch(1)),
                        privatisation(k, exp->branch(2)) );
            case 4 :
                return tree (
                        exp->node(),
                        privatisation(k, exp->branch(0)),
                        privatisation(k, exp->branch(1)),
                        privatisation(k, exp->branch(2)),
                        privatisation(k, exp->branch(3)) );
        }
        printf("erreur 2 dans computePrivatisation\n");
        exit(1);
    }
    printf("situation anormale dans computePrivatisation\n");
    return exp;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static Tree labelize ( const Tree label,
const Tree exp 
) [static]

Definition at line 172 of file privatise.cpp.

References isSigTable(), isSigWRTbl(), sigTable(), and sigWRTbl().

Referenced by computePrivatisation().

{
    Tree    tbl, size, idx, wrt, content, oldid;

    if ( isSigWRTbl(exp, oldid, tbl, idx, wrt) )    {
        /*  Ce qui ne peut pas être partagé, ce sont les
            tables dans lesquelles on ecrit. Pour cela
            on leur donne un label unique
        */
        return sigWRTbl(newid, tbl, idx, wrt);

    } else  if ( isSigTable(exp, oldid, size, content) ) {
        /*  Rien à privatiser dans une table (car size est
            censée etre une expression entiere)
        */
        return sigTable(newid, size, content);

    } else {

        printf("erreur labelize\n");
        exit(1);
    }

    return exp;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static Tree makePrivatisationKey ( const Tree t) [static]

Definition at line 54 of file privatise.cpp.

References name(), tree(), and unique().

Referenced by privatise().

{
    char    name[256];
    snprintf(name, 256, "PRIVATISE %p : ", (CTree*)t);
    return tree(unique(name));
}

Here is the call graph for this function:

Here is the caller graph for this function:

static Tree makePrivatisationLabel ( const Tree exp) [static]

Definition at line 61 of file privatise.cpp.

References name(), tree(), and unique().

Referenced by computePrivatisation().

{
    char    name[256];
    snprintf(name, 256, "OWNER IS %p : ", (CTree*)t);
    return tree(unique(name));
}

Here is the call graph for this function:

Here is the caller graph for this function:

static Tree privatisation ( const Tree k,
const Tree t 
) [static]

Definition at line 71 of file privatise.cpp.

References CTree::arity(), computePrivatisation(), getProperty(), isNil(), nil, and setProperty().

Referenced by computePrivatisation(), and privatise().

{
    Tree v;

    if (t->arity() == 0) {
        return t;

    } else if (getProperty(t, k, v)) {
        /*  Terme deja visité. La propriété nous indique
            la version privatisée ou nil si elle est identique
            au terme initial.
        */
        return isNil(v) ? t : v;

    } else {
        /*  Calcul du terme privatisé et mis à jour
            de la propriété. Nil indique que le terme
            privatisé est identique à celui de depart
            (pour eviter les boucles avec les compteurs
            de references)
        */
        v = computePrivatisation(k,t);
        if (v != t) {
            setProperty(t, k, v );
        } else {
            setProperty(t, k, nil);
        }
        return v;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Tree privatise ( const Tree t)

Definition at line 45 of file privatise.cpp.

References makePrivatisationKey(), and privatisation().

Referenced by ScalarCompiler::prepare().

Here is the call graph for this function:

Here is the caller graph for this function: