00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include "c_breeze.h"
00039
00040
00041
00042
00043
00044 commaNode::commaNode(expr_list * exprs, const Coord coord)
00045 : exprNode(Comma, 0, coord),
00046 _exprs()
00047 {
00048 if (exprs) {
00049 _exprs.swap(* exprs);
00050
00051 }
00052 }
00053
00054 commaNode::commaNode(const Coord coord)
00055 : exprNode(Comma, 0, coord),
00056 _exprs()
00057 {}
00058
00059
00060
00061
00062
00063 typeNode * commaNode::base_type(bool TdefIndir) const
00064 {
00065 const expr_list & the_exprs = exprs();
00066
00067
00068
00069
00070 if (! the_exprs.empty())
00071 return the_exprs.back()->base_type(TdefIndir);
00072 else
00073 return (typeNode *)0;
00074 }
00075
00076
00077
00078
00079
00080 int commaNode::precedence(Assoc & assoc)
00081 {
00082 assoc = Left;
00083 return 1;
00084 }
00085
00086
00087
00088
00089
00090 void commaNode::eval()
00091 {
00092
00093
00094 for (expr_list_p p = exprs().begin();
00095 p != exprs().end();
00096 ++p)
00097 {
00098 (*p)->eval();
00099 }
00100
00101
00102
00103 value(exprs().back()->value());
00104 }
00105
00106
00107
00108
00109
00110 void commaNode::visit(Visitor * the_visitor)
00111 {
00112 the_visitor->at_comma(this);
00113 }
00114
00115 void commaNode::walk(Walker & the_walker)
00116 {
00117 Walker::Order ord = the_walker.order();
00118
00119 if (ord == Walker::Preorder || ord == Walker::Both)
00120 the_walker.at_comma(this, Walker::Preorder);
00121
00122 if (the_walker.depth() == Walker::Subtree) {
00123
00124
00125 list_walker(exprs(), the_walker);
00126
00127 if (type())
00128 type()->walk(the_walker);
00129 }
00130
00131 if (ord == Walker::Postorder || ord == Walker::Both)
00132 the_walker.at_comma(this, Walker::Postorder);
00133 }
00134
00135
00136
00137
00138
00139 void commaNode::dataflow(FlowVal * v, FlowProblem & fp)
00140 {
00141 if (fp.forward()) {
00142 fp.flow_comma(v, this, FlowProblem::Entry);
00143
00144 dataflow_forward_list(exprs(), v, fp);
00145
00146 fp.flow_comma(v, this, FlowProblem::Exit);
00147 }
00148 else {
00149 fp.flow_comma(v, this, FlowProblem::Exit);
00150
00151 dataflow_reverse_list(exprs(), v, fp);
00152
00153 fp.flow_comma(v, this, FlowProblem::Entry);
00154 }
00155 }
00156
00157
00158
00159
00160
00161 void commaNode::output_expr(output_context & ct, Node * parent, int prec, Assoc assoc)
00162 {
00163 bool par = parens(prec, assoc);
00164 int myprec;
00165 Assoc myassoc;
00166
00167 myprec = precedence(myassoc);
00168
00169 if (par)
00170 ct << '(';
00171
00172 output_delim_list(exprs(), ct, this, ',');
00173
00174 if (par)
00175 ct << ')';
00176 }
00177
00178
00179
00180
00181
00182 Node * commaNode::change(Changer & the_changer, bool redispatch)
00183 {
00184 Changer::Order ord = the_changer.order();
00185 commaNode * the_comma = this;
00186
00187 if ((ord == Changer::Preorder || ord == Changer::Both) && ! redispatch)
00188 the_comma = (commaNode *) the_changer.at_comma(the_comma, Changer::Preorder);
00189
00190 if (the_comma) {
00191
00192 if (the_comma != this)
00193 return the_comma->change(the_changer, true);
00194
00195 change_list(the_comma->exprs(), the_changer);
00196
00197 typeNode * old_type = the_comma->type();
00198 if (old_type) {
00199 typeNode * new_type = (typeNode *) old_type->change(the_changer);
00200 if (old_type != new_type) {
00201
00202
00203 the_comma->type(new_type);
00204 }
00205 }
00206
00207 }
00208
00209 if ((ord == Changer::Postorder || ord == Changer::Both) && ! redispatch)
00210 the_comma = (commaNode *) the_changer.at_comma(the_comma, Changer::Postorder);
00211
00212 return the_comma;
00213 }
00214
00215
00216
00217
00218
00219
00220 commaNode::~commaNode()
00221 {
00222
00223 }