-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathcpp_expr_code_gen.h
More file actions
64 lines (52 loc) · 2.71 KB
/
Copy pathcpp_expr_code_gen.h
File metadata and controls
64 lines (52 loc) · 2.71 KB
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
64
#ifndef B1262C86_DF1F_4A47_8920_3675EB33EF3A
#define B1262C86_DF1F_4A47_8920_3675EB33EF3A
#include "cppast/cpp_expression.h"
void CodeGenMonomialExpr(std::ostream& stm, const cppast::CppMonomialExpr& monomialExpr)
{
// clang-format off
switch(monomialExpr.oper()){
case cppast::CppUnaryOperator::UNARY_PLUS : stm << '+' << monomialExpr.term(); break;
case cppast::CppUnaryOperator::UNARY_MINUS : stm << '-' << monomialExpr.term(); break;
case cppast::CppUnaryOperator::PREFIX_INCREMENT : stm << '++' << monomialExpr.term(); break;
case cppast::CppUnaryOperator::PREFIX_DECREMENT : stm << '--' << monomialExpr.term(); break;
case cppast::CppUnaryOperator::BIT_TOGGLE : stm << '~' << monomialExpr.term(); break;
case cppast::CppUnaryOperator::LOGICAL_NOT : stm << '!' << monomialExpr.term(); break;
case cppast::CppUnaryOperator::DEREFER : stm << '*' << monomialExpr.term(); break;
case cppast::CppUnaryOperator::REFER : stm << '&' << monomialExpr.term(); break;
case cppast::CppUnaryOperator::POSTFIX_INCREMENT : stm << monomialExpr.term() << '++'; break;
case cppast::CppUnaryOperator::POSTFIX_DECREMENT : stm << monomialExpr.term() << '--'; break;
case cppast::CppUnaryOperator::VARIADIC : stm << monomialExpr.term() << "..."; break;
case cppast::CppUnaryOperator::NEW : stm << "new " << monomialExpr.term(); break;
case cppast::CppUnaryOperator::DELETE : stm << "delete " << monomialExpr.term(); break;
case cppast::CppUnaryOperator::DELETE_AARAY : stm << "delete[] " << monomialExpr.term(); break;
case cppast::CppUnaryOperator::PARENTHESIZE : stm << '(' << monomialExpr.term() << ')'; break;
case cppast::CppUnaryOperator::SIZE_OF : stm << "siezeof(" << monomialExpr.term() << ')'; break;
case cppast::CppUnaryOperator::VARIADIC_SIZE_OF : stm << "sizeof...(" << monomialExpr.term() << ')'; break;
}
// clang-format on
}
void CodeGenStringLiteralExpr(std::ostream& stm, const cppast::CppStringLiteralExpr& expr)
{
stm << expr.value();
};
void CodeGenCharLiteralExpr(std::ostream& stm, const cppast::CppCharLiteralExpr& expr)
{
stm << expr.value();
};
void CodeGenNumberLiteralExpr(std::ostream& stm, const cppast::CppNumberLiteralExpr& expr)
{
stm << expr.value();
};
void CodeGenNameExpr(std::ostream& stm, const cppast::CppNameExpr& expr)
{
stm << expr.value();
};
void CodeGenVartypeExpr(std::ostream& stm, const cppast::CppVartypeExpr& expr)
{
stm << expr.value();
};
void CodeGenLambdaExpr(std::ostream& stm, const cppast::CppLambdaExpr& expr)
{
stm << expr.value();
}
#endif /* B1262C86_DF1F_4A47_8920_3675EB33EF3A */