00001
00002
00003 #ifndef expr_annotator_h
00004 #define expr_annotator_h
00005
00006 #include "paranoid_visitor.h"
00007 #include "expr_result.h"
00008
00009
00010
00011
00012
00013
00014 class Source;
00015 class Symbol_table;
00016 class Function_symbol;
00017 class Abstract_scope;
00018 class Overload_resolver;
00029 class Expr_annotator : public Paranoid_visitor<Expr_result> {
00030 Abstract_scope* current_scope;
00031 public:
00032 static const int PTR_DELEGATION_LIMIT = 100;
00033
00034 public:
00035
00036 Expr_annotator(Abstract_scope* scope, Source* source);
00037
00040 Expr_result visit_infix(PtreeInfixExpr *p);
00041
00042
00043
00045 Expr_result visit_leaf(Leaf* l);
00046
00049 Expr_result visit_name(Ptree* p);
00050
00052 Expr_result visit_this(LeafThis* p);
00053
00054
00055
00058 Expr_result visit_paren(PtreeParenExpr* e);
00059
00060
00061
00066 Expr_result visit_postfix(PtreePostfixExpr* e);
00067
00069 Expr_result visit_unary(PtreeUnaryExpr* e);
00070
00072 Expr_result visit_delete(PtreeDeleteExpr* pde);
00073
00074
00075
00077 Expr_result visit_new(PtreeNewExpr* p_);
00078
00080 Expr_result visit_sizeof(PtreeSizeofExpr* e);
00081
00083 Expr_result visit_throw(PtreeThrowExpr* p);
00084
00086 Expr_result visit_dotmember(PtreeDotMemberExpr* e);
00087
00090 Expr_result visit_arrowmember(PtreeArrowMemberExpr* e);
00091
00093 Expr_result visit_pm(PtreePmExpr* e);
00094
00096 Expr_result visit_cond(PtreeCondExpr* p);
00097
00101 Expr_result do_fstyle_cast(Type target, Ptree* arglist);
00102
00103 void add_parms_from_arglist(Overload_resolver* resolver, Ptree* p);
00104
00106 Expr_result visit_fstylecastexpr(PtreeFstyleCastExpr* e);
00107
00109 Expr_result visit_funcall(PtreeFuncallExpr* e);
00110
00112 Expr_result visit_cast(PtreeCastExpr* p);
00113
00114
00115 Expr_result visit_brace(PtreeBrace* b);
00116
00118 Expr_result visit_assign(PtreeAssignExpr* p);
00119
00120 Expr_result visit_array(PtreeArrayExpr* p);
00121
00122 private:
00126 Expr_result visit_comma(PtreeCommaExpr* e);
00127
00129 Expr_result process_binary_operator(Ptree* oper, Expr_result l, Expr_result r);
00130
00131
00132
00133
00134
00135
00136
00137
00138
00142 Expr_result process_unary_operator(Ptree* oper, Expr_result arg);
00143
00144
00145
00147 Expr_result process_member_access(Expr_result lhs, Ptree* rhs_tree);
00148
00150 Expr_result process_pm_expr(Expr_result lhs, const Expr_result& rhs);
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00185 Type get_cast_type(Ptree* type_args);
00186
00188 Expr_result get_cast_expr(Ptree* tree);
00189
00191 bool try_static_cast(Type target, bool enforce_const, Expr_result* res);
00192
00193
00194 Expr_result do_dynamic_cast(Ptree* type_args, Ptree* cast_args);
00195
00196 Expr_result do_reinterpret_cast(Ptree* type_args, Ptree* cast_args);
00197
00198 Expr_result do_static_cast(Ptree* type_args, Ptree* cast_args);
00199
00200 Expr_result do_const_cast(Ptree* type_args, Ptree* cast_args);
00201
00205 Expr_result do_ccast(Type t, Ptree* arg);
00206
00211 Expr_result do_funcall(Expr_result lhs, Ptree* arglist);
00212 };
00213
00215 bool try_reinterpret_cast(Type t, bool enforce_const, Expr_result* res);
00216
00217
00218
00221 Type binary_multeq_predicate(Type l, Type r);
00222
00226 Type binary_addeq_predicate(Type l, Type r);
00227
00230 Type binary_inteq_predicate(Type l, Type r);
00231
00232 #endif // expr_annotator_h