Inferno  0.2
render.hpp
Go to the documentation of this file.
00001 #ifndef RENDER_HPP
00002 #define RENDER_HPP
00003 
00004 #include "tree/cpptree.hpp"
00005 #include "helpers/transformation.hpp"
00006 #include "uniquify_identifiers.hpp"
00007 
00008 
00009 class Render : public OutOfPlaceTransformation
00010 {
00011 public:
00012   using Transformation::operator();
00013     Render( string of = string() );
00014     TreePtr<Node> operator()( TreePtr<Node> context, TreePtr<Node> root );
00015 private:
00016     TreePtr<CPPTree::Program> program;
00017     string deferred_decls;
00018     stack< TreePtr<CPPTree::Scope> > scope_stack;
00019     UniquifyIdentifiers unique;
00020     // Remember the orders of collections when we sort them. Mirrors the same
00021     // map in the parser.
00022     Map< TreePtr<CPPTree::Scope>, Sequence<CPPTree::Declaration> > backing_ordering;
00023 
00024     bool IsSystemC( TreePtr<Node> root );
00025     string RenderLiteral( TreePtr<CPPTree::Literal> sp );
00026     string RenderIdentifier( TreePtr<CPPTree::Identifier> id );
00027     string RenderScopePrefix( TreePtr<CPPTree::Identifier> id );
00028     string RenderScopedIdentifier( TreePtr<CPPTree::Identifier> id );
00029     string RenderIntegralType( TreePtr<CPPTree::Integral> type, string object=string() );
00030     string RenderFloatingType( TreePtr<CPPTree::Floating> type );
00031     string RenderType( TreePtr<CPPTree::Type> type, string object=string(), bool constant=false );
00032     string Sanitise( string s );
00033     string RenderOperator( TreePtr<CPPTree::Operator> op, Sequence<CPPTree::Expression> &operands );
00034     string RenderCall( TreePtr<CPPTree::Call> call );
00035     string RenderExpression( TreePtr<CPPTree::Initialiser> expression, bool bracketize_operator=false );
00036     string RenderMakeRecord( TreePtr<CPPTree::MakeRecord> ro );
00037     string RenderMapInOrder( TreePtr<CPPTree::MapOperator> ro,
00038                          TreePtr<CPPTree::Scope> r,
00039                              string separator,
00040                              bool separate_last );
00041     string RenderAccess( TreePtr<CPPTree::AccessSpec> current_access );
00042     string RenderStorage( TreePtr<CPPTree::Instance> st );
00043     void ExtractInits( Sequence<CPPTree::Statement> &body, Sequence<CPPTree::Statement> &inits, Sequence<CPPTree::Statement> &remainder );
00044     string RenderInstance( TreePtr<CPPTree::Instance> o, string sep, bool showtype = true,
00045                            bool showstorage = true, bool showinit = true, bool showscope = false );
00046     bool ShouldSplitInstance( TreePtr<CPPTree::Instance> o );
00047     string RenderDeclaration( TreePtr<CPPTree::Declaration> declaration, string sep, TreePtr<CPPTree::AccessSpec> *current_access = NULL,
00048                               bool showtype = true, bool force_incomplete = false );
00049     string RenderStatement( TreePtr<CPPTree::Statement> statement, string sep );
00050     template< class ELEMENT >
00051     string RenderSequence( Sequence<ELEMENT> spe, 
00052                            string separator, 
00053                            bool separate_last,
00054                            TreePtr<CPPTree::AccessSpec> init_access = TreePtr<CPPTree::AccessSpec>(),
00055                            bool showtype=true );
00056     string RenderOperandSequence( Sequence<CPPTree::Expression> spe, 
00057                                   string separator, 
00058                                   bool separate_last );
00059     string RenderModuleCtor( TreePtr<SCTree::Module> m,
00060                              TreePtr<CPPTree::AccessSpec> *access );    
00061     string RenderDeclarationCollection( TreePtr<CPPTree::Scope> sd,
00062                                   string separator, 
00063                                   bool separate_last,
00064                                   TreePtr<CPPTree::AccessSpec> init_access = TreePtr<CPPTree::AccessSpec>(),
00065                                   bool showtype=true );
00066     const string outfile;                                 
00067 };
00068 
00069 #endif
00070