summaryrefslogtreecommitdiff
path: root/include/printer/cfamily.h
blob: f6e22848a541a8ed41454be22c9b84de9bd3075d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//
// Created by ztuowen on 9/24/16.
//

#ifndef CHILL_CFAMILY_H
#define CHILL_CFAMILY_H

#include "printer/generic.h"

/*!
 * \file
 */

namespace chill {
  namespace printer{
    /*!
     * \brief Print the AST for C like syntax, This replace the old print function
     * Custom multiplexer should not be needed. This version should calculate the correct precedence for expressions.
     * Expression should be encapsulated in {} or () or ended with ; with heuristics at the parent node
     */
    class CFamily : public GenericPrinter {
    public:
      CFamily() {}
      virtual int getPrec(chillAST_Node *n);
      virtual void printS(std::string ident, chillAST_ArraySubscriptExpr *n, std::ostream &o);
      virtual void printS(std::string ident, chillAST_BinaryOperator *n, std::ostream &o);
      virtual void printS(std::string ident, chillAST_CallExpr *n, std::ostream &o);
      virtual void printS(std::string ident, chillAST_CompoundStmt *n, std::ostream &o);
      virtual void printS(std::string ident, chillAST_CStyleAddressOf *n, std::ostream &o);
      virtual void printS(std::string ident, chillAST_CStyleCastExpr *n, std::ostream &o);
      virtual void printS(std::string ident, chillAST_CudaFree *n, std::ostream &o);
      virtual void printS(std::string ident, chillAST_CudaKernelCall *n, std::ostream &o);
      virtual void printS(std::string ident, chillAST_CudaMalloc *n, std::ostream &o);
      virtual void printS(std::string ident, chillAST_CudaMemcpy *n, std::ostream &o);
      virtual void printS(std::string ident, chillAST_CudaSyncthreads *n, std::ostream &o);
      virtual void printS(std::string ident, chillAST_DeclRefExpr *n, std::ostream &o);
      virtual void printS(std::string ident, chillAST_FloatingLiteral *n, std::ostream &o);
      virtual void printS(std::string ident, chillAST_ForStmt *n, std::ostream &o);
      virtual void printS(std::string ident, chillAST_Free *n, std::ostream &o);
      virtual void printS(std::string ident, chillAST_FunctionDecl *n, std::ostream &o);
      virtual void printS(std::string ident, chillAST_IfStmt *n, std::ostream &o);
      virtual void printS(std::string ident, chillAST_IntegerLiteral *n, std::ostream &o);
      virtual void printS(std::string ident, chillAST_ImplicitCastExpr *n, std::ostream &o);
      virtual void printS(std::string ident, chillAST_MacroDefinition *n, std::ostream &o);
      virtual void printS(std::string ident, chillAST_Malloc *n, std::ostream &o);
      virtual void printS(std::string ident, chillAST_MemberExpr *n, std::ostream &o);
      virtual void printS(std::string ident, chillAST_NULL *n, std::ostream &o);
      virtual void printS(std::string ident, chillAST_NoOp *n, std::ostream &o);
      virtual void printS(std::string ident, chillAST_ParenExpr *n, std::ostream &o);
      virtual void printS(std::string ident, chillAST_Preprocessing *n, std::ostream &o);
      virtual void printS(std::string ident, chillAST_RecordDecl *n, std::ostream &o);
      virtual void printS(std::string ident, chillAST_ReturnStmt *n, std::ostream &o);
      virtual void printS(std::string ident, chillAST_Sizeof *n, std::ostream &o);
      virtual void printS(std::string ident, chillAST_SourceFile *n, std::ostream &o);
      virtual void printS(std::string ident, chillAST_TypedefDecl *n, std::ostream &o);
      virtual void printS(std::string ident, chillAST_TernaryOperator *n, std::ostream &o);
      virtual void printS(std::string ident, chillAST_UnaryOperator *n, std::ostream &o);
      virtual void printS(std::string ident, chillAST_VarDecl *n, std::ostream &o);
    };
  }
}

#endif //CHILL_CFAMILY_H