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 initializerNode::initializerNode(expr_list * exprs, const Coord coord)
00045 : exprNode(Initializer, 0, coord),
00046 _exprs()
00047 {
00048 if (exprs) {
00049 _exprs.swap(* exprs);
00050
00051 }
00052 }
00053
00054
00055
00056
00057
00058 void initializerNode::eval()
00059 {
00060
00061
00062 for (expr_list_p p = exprs().begin();
00063 p != exprs().end();
00064 ++p)
00065 {
00066 (*p)->eval();
00067 }
00068
00069
00070
00071 value(constant());
00072 }
00073
00074
00075
00076
00077
00078 void initializerNode::visit(Visitor * the_visitor)
00079 {
00080 the_visitor->at_initializer(this);
00081 }
00082
00083 void initializerNode::walk(Walker & the_walker)
00084 {
00085 Walker::Order ord = the_walker.order();
00086
00087 if (ord == Walker::Preorder || ord == Walker::Both)
00088 the_walker.at_initializer(this, Walker::Preorder);
00089
00090 if (the_walker.depth() == Walker::Subtree) {
00091
00092
00093 list_walker(exprs(), the_walker);
00094
00095 if (type())
00096 type()->walk(the_walker);
00097 }
00098
00099 if (ord == Walker::Postorder || ord == Walker::Both)
00100 the_walker.at_initializer(this, Walker::Postorder);
00101 }
00102
00103
00104
00105
00106
00107 void initializerNode::dataflow(FlowVal * v, FlowProblem & fp)
00108 {
00109 if (fp.forward()) {
00110 fp.flow_initializer(v, this, FlowProblem::Entry);
00111
00112 dataflow_forward_list(exprs(), v, fp);
00113
00114 fp.flow_initializer(v, this, FlowProblem::Exit);
00115 }
00116 else {
00117 fp.flow_initializer(v, this, FlowProblem::Exit);
00118
00119 dataflow_reverse_list(exprs(), v, fp);
00120
00121 fp.flow_initializer(v, this, FlowProblem::Entry);
00122 }
00123 }
00124
00125
00126
00127
00128
00129 void initializerNode::output_expr(output_context & ct, Node * parent, int prec, Assoc assoc)
00130 {
00131 bool par = parens(prec, assoc);
00132
00133 if (par)
00134 ct << '(';
00135
00136 ct.indent_in();
00137 ct.new_line();
00138 ct << '{';
00139 ct.space();
00140
00141 output_delim_list(exprs(), ct, this, ',');
00142
00143 ct.indent_out();
00144 ct.space();
00145 ct << '}';
00146
00147 if (par)
00148 ct << ')';
00149 }
00150
00151
00152
00153
00154
00155 Node * initializerNode::change(Changer & the_changer, bool redispatch)
00156 {
00157 Changer::Order ord = the_changer.order();
00158 initializerNode * the_initializer = this;
00159
00160 if ((ord == Changer::Preorder || ord == Changer::Both) && ! redispatch)
00161 the_initializer = (initializerNode *) the_changer.at_initializer(the_initializer, Changer::Preorder);
00162
00163 if (the_initializer) {
00164
00165 if (the_initializer != this)
00166 return the_initializer->change(the_changer, true);
00167
00168 change_list(the_initializer->exprs(), the_changer);
00169
00170 typeNode * old_type = the_initializer->type();
00171 if (old_type) {
00172 typeNode * new_type = (typeNode *) old_type->change(the_changer);
00173 if (old_type != new_type) {
00174
00175
00176 the_initializer->type(new_type);
00177 }
00178 }
00179
00180 }
00181
00182 if ((ord == Changer::Postorder || ord == Changer::Both) && ! redispatch)
00183 the_initializer = (initializerNode *) the_changer.at_initializer(the_initializer, Changer::Postorder);
00184
00185 return the_initializer;
00186 }
00187
00188
00189
00190
00191
00192
00193 initializerNode::~initializerNode()
00194 {
00195
00196 }