FAUST compiler  0.9.9.6b8
Public Member Functions
MaxPrim Class Reference
Inheritance diagram for MaxPrim:
Inheritance graph
[legend]
Collaboration diagram for MaxPrim:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 MaxPrim ()
virtual unsigned int arity ()
virtual bool needCache ()
virtual Type infereSigType (const vector< Type > &types)
virtual void sigVisit (Tree sig, sigvisitor *visitor)
virtual int infereSigOrder (const vector< int > &args)
virtual Tree computeSigOutput (const vector< Tree > &args)
virtual string generateCode (Klass *klass, const vector< string > &args, const vector< Type > &types)
virtual string generateLateq (Lateq *lateq, const vector< string > &args, const vector< Type > &types)

Detailed Description

Definition at line 8 of file maxprim.cpp.


Constructor & Destructor Documentation

MaxPrim::MaxPrim ( ) [inline]

Definition at line 13 of file maxprim.cpp.

: xtended("max") {}

Member Function Documentation

virtual unsigned int MaxPrim::arity ( ) [inline, virtual]

Implements xtended.

Definition at line 15 of file maxprim.cpp.

Referenced by computeSigOutput(), generateCode(), generateLateq(), infereSigOrder(), and infereSigType().

{ return 2; }

Here is the caller graph for this function:

virtual Tree MaxPrim::computeSigOutput ( const vector< Tree > &  args) [inline, virtual]

Implements xtended.

Definition at line 36 of file maxprim.cpp.

References arity(), isDouble(), isInt(), max(), xtended::symbol(), and tree().

    {
        double f,g; int i,j;
        
        assert (args.size() == arity());
        
        if (isDouble(args[0]->node(),&f)) {
        
            if (isDouble(args[1]->node(), &g)) {
                return tree(max(f, g));
            } else if (isInt(args[1]->node(),&j)) {
                return tree(max(f, double(j)));
            } else {
                return tree(symbol(), args[0], args[1]);
            }
                
        } else if (isInt(args[0]->node(),&i)) {
        
            if (isDouble(args[1]->node(), &g)) {
                return tree(max(double(i), g));
            } else if (isInt(args[1]->node(),&j)) {
                return tree(max(i, j));
            } else {
                return tree(symbol(), args[0], args[1]);
            }
                
        } else {
        
            return tree(symbol(), args[0], args[1]);
        }
    }

Here is the call graph for this function:

virtual string MaxPrim::generateCode ( Klass klass,
const vector< string > &  args,
const vector< Type > &  types 
) [inline, virtual]

Implements xtended.

Definition at line 68 of file maxprim.cpp.

References arity(), infereSigType(), kReal, and subst().

    {
        assert (args.size() == arity());
        assert (types.size() == arity());
        
        Type t = infereSigType(types);
        if (t->nature() == kReal) {
            return subst("max($0, $1)", args[0], args[1]);
        } else {
            return subst("max($0, $1)", args[0], args[1]);
        }           
    }

Here is the call graph for this function:

virtual string MaxPrim::generateLateq ( Lateq lateq,
const vector< string > &  args,
const vector< Type > &  types 
) [inline, virtual]

Implements xtended.

Definition at line 81 of file maxprim.cpp.

References arity(), infereSigType(), and subst().

    {
        assert (args.size() == arity());
        assert (types.size() == arity());
        
        Type t = infereSigType(types);
        return subst("\\max\\left( $0, $1 \\right)", args[0], args[1]);
    }

Here is the call graph for this function:

virtual int MaxPrim::infereSigOrder ( const vector< int > &  args) [inline, virtual]

Implements xtended.

Definition at line 29 of file maxprim.cpp.

References arity(), and max().

    {
        assert (args.size() == arity());
        return max(args[0], args[1]);
    }

Here is the call graph for this function:

virtual Type MaxPrim::infereSigType ( const vector< Type > &  types) [inline, virtual]

Implements xtended.

Definition at line 19 of file maxprim.cpp.

References arity(), castInterval(), and max().

Referenced by generateCode(), and generateLateq().

    {
        assert (types.size() == arity());
        interval i = types[0]->getInterval();
        interval j = types[1]->getInterval();
        return castInterval(types[0]|types[1], max(i,j));
    }

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool MaxPrim::needCache ( ) [inline, virtual]

Implements xtended.

Definition at line 17 of file maxprim.cpp.

{ return true; }
virtual void MaxPrim::sigVisit ( Tree  sig,
sigvisitor visitor 
) [inline, virtual]

Definition at line 27 of file maxprim.cpp.

{}  

The documentation for this class was generated from the following file: