MaxPrim Class Reference

Inherits xtended.

Collaboration diagram for MaxPrim:
[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.

00013 : 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().

00015 { 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().

00037     {
00038         double f,g; int i,j;
00039         
00040         assert (args.size() == arity());
00041         
00042         if (isDouble(args[0]->node(),&f)) {
00043         
00044             if (isDouble(args[1]->node(), &g)) {
00045                 return tree(max(f, g));
00046             } else if (isInt(args[1]->node(),&j)) {
00047                 return tree(max(f, double(j)));
00048             } else {
00049                 return tree(symbol(), args[0], args[1]);
00050             }
00051                 
00052         } else if (isInt(args[0]->node(),&i)) {
00053         
00054             if (isDouble(args[1]->node(), &g)) {
00055                 return tree(max(double(i), g));
00056             } else if (isInt(args[1]->node(),&j)) {
00057                 return tree(max(i, j));
00058             } else {
00059                 return tree(symbol(), args[0], args[1]);
00060             }
00061                 
00062         } else {
00063         
00064             return tree(symbol(), args[0], args[1]);
00065         }
00066     }

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().

00069     {
00070         assert (args.size() == arity());
00071         assert (types.size() == arity());
00072         
00073         Type t = infereSigType(types);
00074         if (t->nature() == kReal) {
00075             return subst("max($0, $1)", args[0], args[1]);
00076         } else {
00077             return subst("max($0, $1)", args[0], args[1]);
00078         }           
00079     }

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().

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

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().

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

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().

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

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.

00017 { return true; }

virtual void MaxPrim::sigVisit ( Tree  sig,
sigvisitor visitor 
) [inline, virtual]

Definition at line 27 of file maxprim.cpp.

00027 {}  


The documentation for this class was generated from the following file:
Generated on Tue Aug 10 08:04:21 2010 for FAUST compiler by  doxygen 1.6.3