1 | //
|
---|
2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
|
---|
3 | //
|
---|
4 | // The contents of this file are covered under the licence agreement in the
|
---|
5 | // file "LICENCE" distributed with Cforall.
|
---|
6 | //
|
---|
7 | // Expression.cc --
|
---|
8 | //
|
---|
9 | // Author : Richard C. Bilson
|
---|
10 | // Created On : Mon May 18 07:44:20 2015
|
---|
11 | // Last Modified By : Peter A. Buhr
|
---|
12 | // Last Modified On : Fri Apr 8 17:16:23 2016
|
---|
13 | // Update Count : 40
|
---|
14 | //
|
---|
15 |
|
---|
16 | #include <iostream>
|
---|
17 | #include <cassert>
|
---|
18 | #include <list>
|
---|
19 | #include <algorithm>
|
---|
20 |
|
---|
21 | #include <iterator>
|
---|
22 |
|
---|
23 | #include "Type.h"
|
---|
24 | #include "Initializer.h"
|
---|
25 | #include "Expression.h"
|
---|
26 | #include "Declaration.h"
|
---|
27 | #include "Statement.h"
|
---|
28 | #include "TypeSubstitution.h"
|
---|
29 | #include "Common/utility.h"
|
---|
30 |
|
---|
31 |
|
---|
32 | Expression::Expression( Expression *_aname ) : env( 0 ), argName( _aname ) {}
|
---|
33 |
|
---|
34 | Expression::Expression( const Expression &other ) : env( maybeClone( other.env ) ), argName( maybeClone( other.get_argName() ) ) {
|
---|
35 | cloneAll( other.results, results );
|
---|
36 | }
|
---|
37 |
|
---|
38 | Expression::~Expression() {
|
---|
39 | delete env;
|
---|
40 | delete argName; // xxx -- there's a problem in cloning ConstantExpr I still don't know how to fix
|
---|
41 | deleteAll( results );
|
---|
42 | }
|
---|
43 |
|
---|
44 | void Expression::add_result( Type *t ) {
|
---|
45 | if ( TupleType *tuple = dynamic_cast< TupleType* >( t ) ) {
|
---|
46 | std::copy( tuple->get_types().begin(), tuple->get_types().end(), back_inserter( results ) );
|
---|
47 | } else {
|
---|
48 | results.push_back(t);
|
---|
49 | } // if
|
---|
50 | }
|
---|
51 |
|
---|
52 | void Expression::print( std::ostream &os, int indent ) const {
|
---|
53 | if ( env ) {
|
---|
54 | os << std::string( indent, ' ' ) << "with environment:" << std::endl;
|
---|
55 | env->print( os, indent+2 );
|
---|
56 | } // if
|
---|
57 |
|
---|
58 | if ( argName ) {
|
---|
59 | os << std::string( indent, ' ' ) << "with designator:";
|
---|
60 | argName->print( os, indent+2 );
|
---|
61 | } // if
|
---|
62 | }
|
---|
63 |
|
---|
64 | ConstantExpr::ConstantExpr( Constant _c, Expression *_aname ) : Expression( _aname ), constant( _c ) {
|
---|
65 | add_result( constant.get_type()->clone() );
|
---|
66 | }
|
---|
67 |
|
---|
68 | ConstantExpr::ConstantExpr( const ConstantExpr &other) : Expression( other ), constant( other.constant ) {
|
---|
69 | }
|
---|
70 |
|
---|
71 | ConstantExpr::~ConstantExpr() {}
|
---|
72 |
|
---|
73 | void ConstantExpr::print( std::ostream &os, int indent ) const {
|
---|
74 | os << std::string( indent, ' ' ) << "constant expression " ;
|
---|
75 | constant.print( os );
|
---|
76 | Expression::print( os, indent );
|
---|
77 | os << std::endl;
|
---|
78 | }
|
---|
79 |
|
---|
80 | VariableExpr::VariableExpr( DeclarationWithType *_var, Expression *_aname ) : Expression( _aname ), var( _var ) {
|
---|
81 | add_result( var->get_type()->clone() );
|
---|
82 | for ( std::list< Type* >::iterator i = get_results().begin(); i != get_results().end(); ++i ) {
|
---|
83 | (*i)->set_isLvalue( true );
|
---|
84 | } // for
|
---|
85 | }
|
---|
86 |
|
---|
87 | VariableExpr::VariableExpr( const VariableExpr &other ) : Expression( other ), var( other.var ) {
|
---|
88 | }
|
---|
89 |
|
---|
90 | VariableExpr::~VariableExpr() {
|
---|
91 | // don't delete the declaration, since it points somewhere else in the tree
|
---|
92 | }
|
---|
93 |
|
---|
94 | void VariableExpr::print( std::ostream &os, int indent ) const {
|
---|
95 | os << std::string( indent, ' ' ) << "Variable Expression: ";
|
---|
96 |
|
---|
97 | Declaration *decl = get_var();
|
---|
98 | // if ( decl != 0) decl->print(os, indent + 2);
|
---|
99 | if ( decl != 0) decl->printShort(os, indent + 2);
|
---|
100 | os << std::endl;
|
---|
101 | Expression::print( os, indent );
|
---|
102 | }
|
---|
103 |
|
---|
104 | SizeofExpr::SizeofExpr( Expression *expr_, Expression *_aname ) :
|
---|
105 | Expression( _aname ), expr(expr_), type(0), isType(false) {
|
---|
106 | add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
|
---|
107 | }
|
---|
108 |
|
---|
109 | SizeofExpr::SizeofExpr( Type *type_, Expression *_aname ) :
|
---|
110 | Expression( _aname ), expr(0), type(type_), isType(true) {
|
---|
111 | add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
|
---|
112 | }
|
---|
113 |
|
---|
114 | SizeofExpr::SizeofExpr( const SizeofExpr &other ) :
|
---|
115 | Expression( other ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType ) {
|
---|
116 | }
|
---|
117 |
|
---|
118 | SizeofExpr::~SizeofExpr() {
|
---|
119 | delete expr;
|
---|
120 | delete type;
|
---|
121 | }
|
---|
122 |
|
---|
123 | void SizeofExpr::print( std::ostream &os, int indent) const {
|
---|
124 | os << std::string( indent, ' ' ) << "Sizeof Expression on: ";
|
---|
125 |
|
---|
126 | if (isType)
|
---|
127 | type->print(os, indent + 2);
|
---|
128 | else
|
---|
129 | expr->print(os, indent + 2);
|
---|
130 |
|
---|
131 | os << std::endl;
|
---|
132 | Expression::print( os, indent );
|
---|
133 | }
|
---|
134 |
|
---|
135 | AlignofExpr::AlignofExpr( Expression *expr_, Expression *_aname ) :
|
---|
136 | Expression( _aname ), expr(expr_), type(0), isType(false) {
|
---|
137 | add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
|
---|
138 | }
|
---|
139 |
|
---|
140 | AlignofExpr::AlignofExpr( Type *type_, Expression *_aname ) :
|
---|
141 | Expression( _aname ), expr(0), type(type_), isType(true) {
|
---|
142 | add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
|
---|
143 | }
|
---|
144 |
|
---|
145 | AlignofExpr::AlignofExpr( const AlignofExpr &other ) :
|
---|
146 | Expression( other ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType ) {
|
---|
147 | }
|
---|
148 |
|
---|
149 | AlignofExpr::~AlignofExpr() {
|
---|
150 | delete expr;
|
---|
151 | delete type;
|
---|
152 | }
|
---|
153 |
|
---|
154 | void AlignofExpr::print( std::ostream &os, int indent) const {
|
---|
155 | os << std::string( indent, ' ' ) << "Alignof Expression on: ";
|
---|
156 |
|
---|
157 | if (isType)
|
---|
158 | type->print(os, indent + 2);
|
---|
159 | else
|
---|
160 | expr->print(os, indent + 2);
|
---|
161 |
|
---|
162 | os << std::endl;
|
---|
163 | Expression::print( os, indent );
|
---|
164 | }
|
---|
165 |
|
---|
166 | UntypedOffsetofExpr::UntypedOffsetofExpr( Type *type_, const std::string &member_, Expression *_aname ) :
|
---|
167 | Expression( _aname ), type(type_), member(member_) {
|
---|
168 | add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
|
---|
169 | }
|
---|
170 |
|
---|
171 | UntypedOffsetofExpr::UntypedOffsetofExpr( const UntypedOffsetofExpr &other ) :
|
---|
172 | Expression( other ), type( maybeClone( other.type ) ), member( other.member ) {}
|
---|
173 |
|
---|
174 | UntypedOffsetofExpr::~UntypedOffsetofExpr() {
|
---|
175 | delete type;
|
---|
176 | }
|
---|
177 |
|
---|
178 | void UntypedOffsetofExpr::print( std::ostream &os, int indent) const {
|
---|
179 | os << std::string( indent, ' ' ) << "Untyped Offsetof Expression on member " << member << " of ";
|
---|
180 |
|
---|
181 | if ( type ) {
|
---|
182 | type->print(os, indent + 2);
|
---|
183 | } else {
|
---|
184 | os << "<NULL>";
|
---|
185 | }
|
---|
186 |
|
---|
187 | os << std::endl;
|
---|
188 | Expression::print( os, indent );
|
---|
189 | }
|
---|
190 |
|
---|
191 | OffsetofExpr::OffsetofExpr( Type *type_, DeclarationWithType *member_, Expression *_aname ) :
|
---|
192 | Expression( _aname ), type(type_), member(member_) {
|
---|
193 | add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
|
---|
194 | }
|
---|
195 |
|
---|
196 | OffsetofExpr::OffsetofExpr( const OffsetofExpr &other ) :
|
---|
197 | Expression( other ), type( maybeClone( other.type ) ), member( maybeClone( other.member ) ) {}
|
---|
198 |
|
---|
199 | OffsetofExpr::~OffsetofExpr() {
|
---|
200 | delete type;
|
---|
201 | delete member;
|
---|
202 | }
|
---|
203 |
|
---|
204 | void OffsetofExpr::print( std::ostream &os, int indent) const {
|
---|
205 | os << std::string( indent, ' ' ) << "Offsetof Expression on member ";
|
---|
206 |
|
---|
207 | if ( member ) {
|
---|
208 | os << member->get_name();
|
---|
209 | } else {
|
---|
210 | os << "<NULL>";
|
---|
211 | }
|
---|
212 |
|
---|
213 | os << " of ";
|
---|
214 |
|
---|
215 | if ( type ) {
|
---|
216 | type->print(os, indent + 2);
|
---|
217 | } else {
|
---|
218 | os << "<NULL>";
|
---|
219 | }
|
---|
220 |
|
---|
221 | os << std::endl;
|
---|
222 | Expression::print( os, indent );
|
---|
223 | }
|
---|
224 |
|
---|
225 | OffsetPackExpr::OffsetPackExpr( StructInstType *type_, Expression *aname_ ) : Expression( aname_ ), type( type_ ) {
|
---|
226 | add_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) );
|
---|
227 | }
|
---|
228 |
|
---|
229 | OffsetPackExpr::OffsetPackExpr( const OffsetPackExpr &other ) : Expression( other ), type( maybeClone( other.type ) ) {}
|
---|
230 |
|
---|
231 | OffsetPackExpr::~OffsetPackExpr() { delete type; }
|
---|
232 |
|
---|
233 | void OffsetPackExpr::print( std::ostream &os, int indent ) const {
|
---|
234 | os << std::string( indent, ' ' ) << "Offset pack expression on ";
|
---|
235 |
|
---|
236 | if ( type ) {
|
---|
237 | type->print(os, indent + 2);
|
---|
238 | } else {
|
---|
239 | os << "<NULL>";
|
---|
240 | }
|
---|
241 |
|
---|
242 | os << std::endl;
|
---|
243 | Expression::print( os, indent );
|
---|
244 | }
|
---|
245 |
|
---|
246 | AttrExpr::AttrExpr( Expression *attr, Expression *expr_, Expression *_aname ) :
|
---|
247 | Expression( _aname ), attr( attr ), expr(expr_), type(0), isType(false) {
|
---|
248 | }
|
---|
249 |
|
---|
250 | AttrExpr::AttrExpr( Expression *attr, Type *type_, Expression *_aname ) :
|
---|
251 | Expression( _aname ), attr( attr ), expr(0), type(type_), isType(true) {
|
---|
252 | }
|
---|
253 |
|
---|
254 | AttrExpr::AttrExpr( const AttrExpr &other ) :
|
---|
255 | Expression( other ), attr( maybeClone( other.attr ) ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType ) {
|
---|
256 | }
|
---|
257 |
|
---|
258 | AttrExpr::~AttrExpr() {
|
---|
259 | delete attr;
|
---|
260 | delete expr;
|
---|
261 | delete type;
|
---|
262 | }
|
---|
263 |
|
---|
264 | void AttrExpr::print( std::ostream &os, int indent) const {
|
---|
265 | os << std::string( indent, ' ' ) << "Attr ";
|
---|
266 | attr->print( os, indent + 2 );
|
---|
267 | if ( isType || expr ) {
|
---|
268 | os << "applied to: ";
|
---|
269 |
|
---|
270 | if (isType)
|
---|
271 | type->print(os, indent + 2);
|
---|
272 | else
|
---|
273 | expr->print(os, indent + 2);
|
---|
274 | } // if
|
---|
275 |
|
---|
276 | os << std::endl;
|
---|
277 | Expression::print( os, indent );
|
---|
278 | }
|
---|
279 |
|
---|
280 | CastExpr::CastExpr( Expression *arg_, Type *toType, Expression *_aname ) : Expression( _aname ), arg(arg_) {
|
---|
281 | add_result(toType);
|
---|
282 | }
|
---|
283 |
|
---|
284 | CastExpr::CastExpr( Expression *arg_, Expression *_aname ) : Expression( _aname ), arg(arg_) {
|
---|
285 | }
|
---|
286 |
|
---|
287 | CastExpr::CastExpr( const CastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ) {
|
---|
288 | }
|
---|
289 |
|
---|
290 | CastExpr::~CastExpr() {
|
---|
291 | delete arg;
|
---|
292 | }
|
---|
293 |
|
---|
294 | // CastExpr *CastExpr::clone() const { return 0; }
|
---|
295 |
|
---|
296 | void CastExpr::print( std::ostream &os, int indent ) const {
|
---|
297 | os << std::string( indent, ' ' ) << "Cast of:" << std::endl;
|
---|
298 | arg->print(os, indent+2);
|
---|
299 | os << std::endl << std::string( indent, ' ' ) << "to:" << std::endl;
|
---|
300 | if ( results.empty() ) {
|
---|
301 | os << std::string( indent+2, ' ' ) << "nothing" << std::endl;
|
---|
302 | } else {
|
---|
303 | printAll(results, os, indent+2);
|
---|
304 | } // if
|
---|
305 | Expression::print( os, indent );
|
---|
306 | }
|
---|
307 |
|
---|
308 | UntypedMemberExpr::UntypedMemberExpr( std::string _member, Expression *_aggregate, Expression *_aname ) :
|
---|
309 | Expression( _aname ), member(_member), aggregate(_aggregate) {}
|
---|
310 |
|
---|
311 | UntypedMemberExpr::UntypedMemberExpr( const UntypedMemberExpr &other ) :
|
---|
312 | Expression( other ), member( other.member ), aggregate( maybeClone( other.aggregate ) ) {
|
---|
313 | }
|
---|
314 |
|
---|
315 | UntypedMemberExpr::~UntypedMemberExpr() {
|
---|
316 | delete aggregate;
|
---|
317 | }
|
---|
318 |
|
---|
319 | void UntypedMemberExpr::print( std::ostream &os, int indent ) const {
|
---|
320 | os << std::string( indent, ' ' ) << "Member Expression, with field: " << get_member();
|
---|
321 |
|
---|
322 | Expression *agg = get_aggregate();
|
---|
323 | os << std::string( indent, ' ' ) << "from aggregate: ";
|
---|
324 | if (agg != 0) agg->print(os, indent + 2);
|
---|
325 | Expression::print( os, indent );
|
---|
326 | }
|
---|
327 |
|
---|
328 |
|
---|
329 | MemberExpr::MemberExpr( DeclarationWithType *_member, Expression *_aggregate, Expression *_aname ) :
|
---|
330 | Expression( _aname ), member(_member), aggregate(_aggregate) {
|
---|
331 | add_result( member->get_type()->clone() );
|
---|
332 | for ( std::list< Type* >::iterator i = get_results().begin(); i != get_results().end(); ++i ) {
|
---|
333 | (*i)->set_isLvalue( true );
|
---|
334 | } // for
|
---|
335 | }
|
---|
336 |
|
---|
337 | MemberExpr::MemberExpr( const MemberExpr &other ) :
|
---|
338 | Expression( other ), member( maybeClone( other.member ) ), aggregate( maybeClone( other.aggregate ) ) {
|
---|
339 | }
|
---|
340 |
|
---|
341 | MemberExpr::~MemberExpr() {
|
---|
342 | delete member;
|
---|
343 | delete aggregate;
|
---|
344 | }
|
---|
345 |
|
---|
346 | void MemberExpr::print( std::ostream &os, int indent ) const {
|
---|
347 | os << std::string( indent, ' ' ) << "Member Expression, with field: " << std::endl;
|
---|
348 |
|
---|
349 | assert( member );
|
---|
350 | os << std::string( indent + 2, ' ' );
|
---|
351 | member->print( os, indent + 2 );
|
---|
352 | os << std::endl;
|
---|
353 |
|
---|
354 | Expression *agg = get_aggregate();
|
---|
355 | os << std::string( indent, ' ' ) << "from aggregate: " << std::endl;
|
---|
356 | if (agg != 0) agg->print(os, indent + 2);
|
---|
357 | Expression::print( os, indent );
|
---|
358 | }
|
---|
359 |
|
---|
360 |
|
---|
361 | UntypedExpr::UntypedExpr( Expression *_function, Expression *_aname ) : Expression( _aname ), function( _function ) {}
|
---|
362 |
|
---|
363 | UntypedExpr::UntypedExpr( const UntypedExpr &other ) :
|
---|
364 | Expression( other ), function( maybeClone( other.function ) ) {
|
---|
365 | cloneAll( other.args, args );
|
---|
366 | }
|
---|
367 |
|
---|
368 | UntypedExpr::UntypedExpr( Expression *_function, std::list<Expression *> &_args, Expression *_aname ) :
|
---|
369 | Expression( _aname ), function(_function), args(_args) {}
|
---|
370 |
|
---|
371 | UntypedExpr::~UntypedExpr() {}
|
---|
372 |
|
---|
373 | void UntypedExpr::print( std::ostream &os, int indent ) const {
|
---|
374 | os << std::string( indent, ' ' ) << "Applying untyped: " << std::endl;
|
---|
375 | function->print(os, indent + 4);
|
---|
376 | os << std::string( indent, ' ' ) << "...to: " << std::endl;
|
---|
377 | printArgs(os, indent + 4);
|
---|
378 | Expression::print( os, indent );
|
---|
379 | }
|
---|
380 |
|
---|
381 | void UntypedExpr::printArgs( std::ostream &os, int indent ) const {
|
---|
382 | std::list<Expression *>::const_iterator i;
|
---|
383 | for (i = args.begin(); i != args.end(); i++)
|
---|
384 | (*i)->print(os, indent);
|
---|
385 | }
|
---|
386 |
|
---|
387 | NameExpr::NameExpr( std::string _name, Expression *_aname ) : Expression( _aname ), name(_name) {}
|
---|
388 |
|
---|
389 | NameExpr::NameExpr( const NameExpr &other ) : Expression( other ), name( other.name ) {
|
---|
390 | }
|
---|
391 |
|
---|
392 | NameExpr::~NameExpr() {}
|
---|
393 |
|
---|
394 | void NameExpr::print( std::ostream &os, int indent ) const {
|
---|
395 | os << std::string( indent, ' ' ) << "Name: " << get_name() << std::endl;
|
---|
396 | Expression::print( os, indent );
|
---|
397 | }
|
---|
398 |
|
---|
399 | LogicalExpr::LogicalExpr( Expression *arg1_, Expression *arg2_, bool andp, Expression *_aname ) :
|
---|
400 | Expression( _aname ), arg1(arg1_), arg2(arg2_), isAnd(andp) {
|
---|
401 | add_result( new BasicType( Type::Qualifiers(), BasicType::SignedInt ) );
|
---|
402 | }
|
---|
403 |
|
---|
404 | LogicalExpr::LogicalExpr( const LogicalExpr &other ) :
|
---|
405 | Expression( other ), arg1( maybeClone( other.arg1 ) ), arg2( maybeClone( other.arg2 ) ), isAnd( other.isAnd ) {
|
---|
406 | }
|
---|
407 |
|
---|
408 | LogicalExpr::~LogicalExpr() {
|
---|
409 | delete arg1;
|
---|
410 | delete arg2;
|
---|
411 | }
|
---|
412 |
|
---|
413 | void LogicalExpr::print( std::ostream &os, int indent )const {
|
---|
414 | os << std::string( indent, ' ' ) << "Short-circuited operation (" << (isAnd?"and":"or") << ") on: ";
|
---|
415 | arg1->print(os);
|
---|
416 | os << " and ";
|
---|
417 | arg2->print(os);
|
---|
418 | os << std::endl;
|
---|
419 | Expression::print( os, indent );
|
---|
420 | }
|
---|
421 |
|
---|
422 | ConditionalExpr::ConditionalExpr( Expression *arg1_, Expression *arg2_, Expression *arg3_, Expression *_aname ) :
|
---|
423 | Expression( _aname ), arg1(arg1_), arg2(arg2_), arg3(arg3_) {}
|
---|
424 |
|
---|
425 | ConditionalExpr::ConditionalExpr( const ConditionalExpr &other ) :
|
---|
426 | Expression( other ), arg1( maybeClone( other.arg1 ) ), arg2( maybeClone( other.arg2 ) ), arg3( maybeClone( other.arg3 ) ) {
|
---|
427 | }
|
---|
428 |
|
---|
429 | ConditionalExpr::~ConditionalExpr() {
|
---|
430 | delete arg1;
|
---|
431 | delete arg2;
|
---|
432 | delete arg3;
|
---|
433 | }
|
---|
434 |
|
---|
435 | void ConditionalExpr::print( std::ostream &os, int indent ) const {
|
---|
436 | os << std::string( indent, ' ' ) << "Conditional expression on: " << std::endl;
|
---|
437 | arg1->print( os, indent+2 );
|
---|
438 | os << std::string( indent, ' ' ) << "First alternative:" << std::endl;
|
---|
439 | arg2->print( os, indent+2 );
|
---|
440 | os << std::string( indent, ' ' ) << "Second alternative:" << std::endl;
|
---|
441 | arg3->print( os, indent+2 );
|
---|
442 | os << std::endl;
|
---|
443 | Expression::print( os, indent );
|
---|
444 | }
|
---|
445 |
|
---|
446 | AsmExpr::AsmExpr( const AsmExpr & other ) : inout( maybeClone( other.inout ) ), constraint( maybeClone( other.constraint ) ), operand( maybeClone( other.operand ) ) {}
|
---|
447 |
|
---|
448 |
|
---|
449 | void AsmExpr::print( std::ostream &os, int indent ) const {
|
---|
450 | os << "Asm Expression: " << std::endl;
|
---|
451 | if ( inout ) inout->print( os, indent + 2 );
|
---|
452 | if ( constraint ) constraint->print( os, indent + 2 );
|
---|
453 | if ( operand ) operand->print( os, indent + 2 );
|
---|
454 | }
|
---|
455 |
|
---|
456 | UntypedValofExpr::UntypedValofExpr( const UntypedValofExpr & other ) : Expression( other ), body ( maybeClone( other.body ) ) {}
|
---|
457 |
|
---|
458 | UntypedValofExpr::~UntypedValofExpr() { delete body; }
|
---|
459 |
|
---|
460 | void UntypedValofExpr::print( std::ostream &os, int indent ) const {
|
---|
461 | os << std::string( indent, ' ' ) << "Valof Expression: " << std::endl;
|
---|
462 | if ( get_body() != 0 )
|
---|
463 | get_body()->print( os, indent + 2 );
|
---|
464 | }
|
---|
465 |
|
---|
466 |
|
---|
467 | CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : type( type ), initializer( initializer ) {
|
---|
468 | add_result( type->clone() );
|
---|
469 | }
|
---|
470 |
|
---|
471 | CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), type( maybeClone( other.type ) ), initializer( maybeClone( other.initializer ) ) {}
|
---|
472 |
|
---|
473 | CompoundLiteralExpr::~CompoundLiteralExpr() {
|
---|
474 | delete initializer;
|
---|
475 | delete type;
|
---|
476 | }
|
---|
477 |
|
---|
478 | void CompoundLiteralExpr::print( std::ostream &os, int indent ) const {
|
---|
479 | os << "Compound Literal Expression: " << std::endl;
|
---|
480 | if ( type ) type->print( os, indent + 2 );
|
---|
481 | if ( initializer ) initializer->print( os, indent + 2 );
|
---|
482 | }
|
---|
483 |
|
---|
484 |
|
---|
485 | std::ostream & operator<<( std::ostream & out, Expression * expr ) {
|
---|
486 | expr->print( out );
|
---|
487 | return out;
|
---|
488 | }
|
---|
489 |
|
---|
490 | // Local Variables: //
|
---|
491 | // tab-width: 4 //
|
---|
492 | // mode: c++ //
|
---|
493 | // compile-command: "make install" //
|
---|
494 | // End: //
|
---|