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 #include "semcheck.h"
00040
00041
00042
00043
00044
00045 arrayNode::arrayNode(Type_qualifiers tq, typeNode * the_type, exprNode * the_dim,
00046 const Coord coord)
00047 : typeNode(Array, tq, the_type, coord),
00048 _dim(the_dim),
00049 _size(0) { }
00050
00051
00052
00053
00054
00055 bool arrayNode::is_string() const
00056 {
00057 return type()->is_char();
00058 }
00059
00060
00061
00062
00063
00064 bool arrayNode::qualified_equal_to(typeNode * node2,
00065 bool strict_toplevel, bool strict_recursive)
00066 {
00067
00068
00069 if (! equal_to(type(), node2->type(),
00070 strict_recursive, strict_recursive))
00071 return false;
00072
00073
00074
00075
00076 if (node2->typ() == Ptr)
00077 return true;
00078
00079
00080 arrayNode * n2 = (arrayNode *) node2;
00081 if (dim())
00082 if (n2->dim()) {
00083
00084
00085
00086
00087
00088 exprNode * dim1 = dim();
00089 exprNode * dim2 = n2->dim();
00090
00091
00092
00093
00094
00095 semcheck_expr_visitor::check(dim1);
00096 dim1->eval();
00097
00098 semcheck_expr_visitor::check(dim2);
00099 dim2->eval();
00100
00101 if ( ! dim1->value().no_val() &&
00102 ! dim2->value().no_val() ) {
00103
00104 unsigned long val1 = dim1->value().Integer();
00105 unsigned long val2 = dim2->value().Integer();
00106
00107
00108
00109 if (val1 && val2)
00110 return val1 == val2;
00111 else
00112 return false;
00113
00114 } else
00115 return true;
00116
00117 } else
00118
00119
00120 return true;
00121
00122 else {
00123
00124 dim(n2->dim());
00125 type(n2->type());
00126 }
00127
00128 return true;
00129 }
00130
00131
00132
00133
00134
00135 void arrayNode::visit(Visitor * the_visitor)
00136 {
00137 the_visitor->at_array(this);
00138 }
00139
00140 void arrayNode::walk(Walker & the_walker)
00141 {
00142 Walker::Order ord = the_walker.order();
00143
00144 if (ord == Walker::Preorder || ord == Walker::Both)
00145 the_walker.at_array(this, Walker::Preorder);
00146
00147 if (the_walker.depth() == Walker::Subtree) {
00148
00149
00150 if (type())
00151 type()->walk(the_walker);
00152
00153 if (dim())
00154 dim()->walk(the_walker);
00155 }
00156
00157 if (ord == Walker::Postorder || ord == Walker::Both)
00158 the_walker.at_array(this, Walker::Postorder);
00159 }
00160
00161
00162
00163
00164
00165 void arrayNode::output_type(output_context & ct, Node * parent, Assoc context, Type_qualifiers q)
00166 {
00167 if (context == Left)
00168 type()->output_type(ct, this, Left, q);
00169 else {
00170 ct << '[';
00171
00172
00173
00174
00175 if (dim()) dim()->output(ct, this);
00176 ct << ']';
00177
00178 type()->output_type(ct, this, Right, q);
00179 }
00180 }
00181
00182
00183
00184
00185
00186 Node * arrayNode::change(Changer & the_changer, bool redispatch)
00187 {
00188 Changer::Order ord = the_changer.order();
00189 arrayNode * the_array = this;
00190
00191 if ((ord == Changer::Preorder || ord == Changer::Both) && ! redispatch)
00192 the_array = (arrayNode *) the_changer.at_array(the_array, Changer::Preorder);
00193
00194 if (the_array) {
00195
00196 if (the_array != this)
00197 return the_array->change(the_changer, true);
00198
00199 typeNode * old_type = the_array->type();
00200 if (old_type) {
00201 typeNode * new_type = (typeNode *) old_type->change(the_changer);
00202 if (old_type != new_type) {
00203
00204
00205 the_array->type(new_type);
00206 }
00207 }
00208
00209 exprNode * old_dim = the_array->dim();
00210 if (old_dim) {
00211 exprNode * new_dim = (exprNode *) old_dim->change(the_changer);
00212 if (old_dim != new_dim) {
00213
00214
00215 the_array->dim(new_dim);
00216 }
00217 }
00218
00219 }
00220
00221 if ((ord == Changer::Postorder || ord == Changer::Both) && ! redispatch)
00222 the_array = (arrayNode *) the_changer.at_array(the_array, Changer::Postorder);
00223
00224 return the_array;
00225 }
00226
00227
00228
00229
00230
00231
00232 arrayNode::~arrayNode()
00233 {
00234
00235 }