Inferno  0.2
typeof.hpp
Go to the documentation of this file.
00001 #ifndef TYPEOF_HPP
00002 #define TYPEOF_HPP
00003 
00004 #include "helpers/transformation.hpp"
00005 #include "cpptree.hpp"
00006 
00007 class TypeOf : public OutOfPlaceTransformation
00008 {
00009 public:
00010     virtual TreePtr<Node> operator()( TreePtr<Node> c, TreePtr<Node> root )
00011     {
00012       context = c;
00013       TreePtr<CPPTree::Expression> e = dynamic_pointer_cast<CPPTree::Expression>(root);
00014       TreePtr<Node> n;
00015       if( e ) // if the tree at root is not an expression, return NULL
00016         n = Get( e );
00017       context = TreePtr<Node>();
00018       return n;
00019     }
00020     // TODO make these private
00021     TreePtr<CPPTree::Type> Get( TreePtr<CPPTree::Expression> o );
00022     TreePtr<CPPTree::Type> Get( TreePtr<CPPTree::Operator> op, Sequence<CPPTree::Type> optypes );
00023     TreePtr<CPPTree::Type> GetStandard( Sequence<CPPTree::Type> &optypes );
00024     TreePtr<CPPTree::Type> GetStandard( Sequence<CPPTree::Numeric> &optypes );
00025     TreePtr<CPPTree::Type> GetSpecial( TreePtr<CPPTree::Operator> op, Sequence<CPPTree::Type> &optypes );
00026     TreePtr<CPPTree::Type> GetLiteral( TreePtr<CPPTree::Literal> l );
00027 
00028     // Is this call really a constructor call? If so return the object being
00029     // constructed. Otherwise, return NULL
00030     TreePtr<CPPTree::Expression> IsConstructorCall( TreePtr<Node> c, TreePtr<CPPTree::Call> call );
00031 
00032     static TypeOf instance; 
00033 private:
00034     TreePtr<Node> context;
00035 };
00036 
00037 #endif
00038