source: src/SynTree/Expression.cc@ f229fc2

new-env with_gc
Last change on this file since f229fc2 was 68f9c43, checked in by Aaron Moss <a3moss@…>, 8 years ago

First pass at delete removal

  • Property mode set to 100644
File size: 21.9 KB
Line 
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 : Tue Jul 25 14:15:47 2017
13// Update Count : 54
14//
15
16#include "SynTree/Expression.h"
17
18#include <cassert> // for assert, assertf
19#include <iostream> // for ostream, operator<<, basic_ostream
20#include <list> // for list, _List_iterator, list<>::co...
21
22#include "Common/utility.h" // for maybeClone, cloneAll, deleteAll
23#include "Declaration.h" // for ObjectDecl, DeclarationWithType
24#include "Expression.h" // for Expression, ImplicitCopyCtorExpr
25#include "InitTweak/InitTweak.h" // for getCallArg, getPointerBase
26#include "Initializer.h" // for Designation, Initializer
27#include "Statement.h" // for CompoundStmt, ExprStmt, Statement
28#include "SynTree/BaseSyntaxNode.h" // for BaseSyntaxNode
29#include "SynTree/Constant.h" // for Constant
30#include "Type.h" // for Type, BasicType, Type::Qualifiers
31#include "TypeSubstitution.h" // for TypeSubstitution
32
33#include "GenPoly/Lvalue.h"
34
35void printInferParams( const InferredParams & inferParams, std::ostream &os, Indenter indent, int level ) {
36 if ( ! inferParams.empty() ) {
37 os << indent << "with inferred parameters " << level << ":" << std::endl;
38 for ( InferredParams::const_iterator i = inferParams.begin(); i != inferParams.end(); ++i ) {
39 os << indent+1;
40 Declaration::declFromId( i->second.decl )->printShort( os, indent+1 );
41 os << std::endl;
42 printInferParams( *i->second.inferParams, os, indent+1, level+1 );
43 } // for
44 } // if
45}
46
47Expression::Expression() : result( 0 ), env( 0 ) {}
48
49Expression::Expression( const Expression &other ) : BaseSyntaxNode( other ), result( maybeClone( other.result ) ), env( maybeClone( other.env ) ), extension( other.extension ), inferParams( other.inferParams ) {
50}
51
52Expression::~Expression() {
53 delete env;
54}
55
56void Expression::print( std::ostream &os, Indenter indent ) const {
57 printInferParams( inferParams, os, indent+1, 0 );
58
59 if ( env ) {
60 os << std::endl << indent << "... with environment:" << std::endl;
61 env->print( os, indent+1 );
62 } // if
63
64 if ( extension ) {
65 os << std::endl << indent << "... with extension:";
66 } // if
67}
68
69ConstantExpr::ConstantExpr( Constant _c ) : Expression(), constant( _c ) {
70 set_result( constant.get_type()->clone() );
71}
72
73ConstantExpr::ConstantExpr( const ConstantExpr &other) : Expression( other ), constant( other.constant ) {
74}
75
76void ConstantExpr::print( std::ostream &os, Indenter indent ) const {
77 os << "constant expression " ;
78 constant.print( os );
79 Expression::print( os, indent );
80}
81
82long long int ConstantExpr::intValue() const {
83 if ( BasicType * basicType = dynamic_cast< BasicType * >( result ) ) {
84 if ( basicType->isInteger() ) {
85 return get_constant()->get_ival();
86 }
87 } else if ( dynamic_cast< OneType * >( result ) ) {
88 return 1;
89 } else if ( dynamic_cast< ZeroType * >( result ) ) {
90 return 0;
91 }
92 SemanticError( this, "Constant expression of non-integral type " );
93}
94
95VariableExpr::VariableExpr( DeclarationWithType *_var ) : Expression(), var( _var ) {
96 assert( var );
97 assert( var->get_type() );
98 Type * type = var->get_type()->clone();
99 type->set_lvalue( true );
100
101 // xxx - doesn't quite work yet - get different alternatives with the same cost
102
103 // // enumerators are not lvalues
104 // if ( EnumInstType * inst = dynamic_cast< EnumInstType * >( var->get_type() ) ) {
105 // assert( inst->baseEnum );
106 // EnumDecl * decl = inst->baseEnum;
107 // long long int value;
108 // if ( decl->valueOf( var, value ) ) {
109 // type->set_lvalue( false );
110 // }
111 // }
112
113 set_result( type );
114}
115
116VariableExpr::VariableExpr( const VariableExpr &other ) : Expression( other ), var( other.var ) {
117}
118
119VariableExpr * VariableExpr::functionPointer( FunctionDecl * func ) {
120 VariableExpr * funcExpr = new VariableExpr( func );
121 funcExpr->set_result( new PointerType( Type::Qualifiers(), funcExpr->get_result() ) );
122 return funcExpr;
123}
124
125void VariableExpr::print( std::ostream &os, Indenter indent ) const {
126 os << "Variable Expression: ";
127 var->printShort(os, indent);
128 Expression::print( os, indent );
129}
130
131SizeofExpr::SizeofExpr( Expression *expr_ ) :
132 Expression(), expr(expr_), type(0), isType(false) {
133 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
134}
135
136SizeofExpr::SizeofExpr( Type *type_ ) :
137 Expression(), expr(0), type(type_), isType(true) {
138 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
139}
140
141SizeofExpr::SizeofExpr( const SizeofExpr &other ) :
142 Expression( other ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType ) {
143}
144
145void SizeofExpr::print( std::ostream &os, Indenter indent) const {
146 os << "Sizeof Expression on: ";
147 if (isType) type->print(os, indent+1);
148 else expr->print(os, indent+1);
149 Expression::print( os, indent );
150}
151
152AlignofExpr::AlignofExpr( Expression *expr_ ) :
153 Expression(), expr(expr_), type(0), isType(false) {
154 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
155}
156
157AlignofExpr::AlignofExpr( Type *type_ ) :
158 Expression(), expr(0), type(type_), isType(true) {
159 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
160}
161
162AlignofExpr::AlignofExpr( const AlignofExpr &other ) :
163 Expression( other ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType ) {
164}
165
166void AlignofExpr::print( std::ostream &os, Indenter indent) const {
167 os << "Alignof Expression on: ";
168 if (isType) type->print(os, indent+1);
169 else expr->print(os, indent+1);
170 Expression::print( os, indent );
171}
172
173UntypedOffsetofExpr::UntypedOffsetofExpr( Type *type, const std::string &member ) :
174 Expression(), type(type), member(member) {
175 assert( type );
176 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
177}
178
179UntypedOffsetofExpr::UntypedOffsetofExpr( const UntypedOffsetofExpr &other ) :
180 Expression( other ), type( maybeClone( other.type ) ), member( other.member ) {}
181
182void UntypedOffsetofExpr::print( std::ostream &os, Indenter indent) const {
183 os << "Untyped Offsetof Expression on member " << member << " of ";
184 type->print(os, indent+1);
185 Expression::print( os, indent );
186}
187
188OffsetofExpr::OffsetofExpr( Type *type, DeclarationWithType *member ) :
189 Expression(), type(type), member(member) {
190 assert( member );
191 assert( type );
192 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
193}
194
195OffsetofExpr::OffsetofExpr( const OffsetofExpr &other ) :
196 Expression( other ), type( maybeClone( other.type ) ), member( other.member ) {}
197
198void OffsetofExpr::print( std::ostream &os, Indenter indent) const {
199 os << "Offsetof Expression on member " << member->name << " of ";
200 type->print(os, indent+1);
201 Expression::print( os, indent );
202}
203
204OffsetPackExpr::OffsetPackExpr( StructInstType *type ) : Expression(), type( type ) {
205 assert( type );
206 set_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) );
207}
208
209OffsetPackExpr::OffsetPackExpr( const OffsetPackExpr &other ) : Expression( other ), type( maybeClone( other.type ) ) {}
210
211void OffsetPackExpr::print( std::ostream &os, Indenter indent ) const {
212 os << "Offset pack expression on ";
213 type->print(os, indent+1);
214 Expression::print( os, indent );
215}
216
217AttrExpr::AttrExpr( Expression *attr, Expression *expr_ ) :
218 Expression(), attr( attr ), expr(expr_), type(0), isType(false) {
219}
220
221AttrExpr::AttrExpr( Expression *attr, Type *type_ ) :
222 Expression(), attr( attr ), expr(0), type(type_), isType(true) {
223}
224
225AttrExpr::AttrExpr( const AttrExpr &other ) :
226 Expression( other ), attr( maybeClone( other.attr ) ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType ) {
227}
228
229void AttrExpr::print( std::ostream &os, Indenter indent) const {
230 os << "Attr ";
231 attr->print( os, indent+1);
232 if ( isType || expr ) {
233 os << "applied to: ";
234 if (isType) type->print(os, indent+1);
235 else expr->print(os, indent+1);
236 } // if
237 Expression::print( os, indent );
238}
239
240CastExpr::CastExpr( Expression *arg_, Type *toType ) : Expression(), arg(arg_) {
241 set_result(toType);
242}
243
244CastExpr::CastExpr( Expression *arg_ ) : Expression(), arg(arg_) {
245 set_result( new VoidType( Type::Qualifiers() ) );
246}
247
248CastExpr::CastExpr( const CastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ) {
249}
250
251void CastExpr::print( std::ostream &os, Indenter indent ) const {
252 os << "Cast of:" << std::endl << indent+1;
253 arg->print(os, indent+1);
254 os << std::endl << indent << "... to:";
255 if ( result->isVoid() ) {
256 os << " nothing";
257 } else {
258 os << std::endl << indent+1;
259 result->print( os, indent+1 );
260 } // if
261 Expression::print( os, indent );
262}
263
264VirtualCastExpr::VirtualCastExpr( Expression *arg_, Type *toType ) : Expression(), arg(arg_) {
265 set_result(toType);
266}
267
268VirtualCastExpr::VirtualCastExpr( const VirtualCastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ) {
269}
270
271void VirtualCastExpr::print( std::ostream &os, Indenter indent ) const {
272 os << "Virtual Cast of:" << std::endl << indent+1;
273 arg->print(os, indent+1);
274 os << std::endl << indent << "... to:";
275 if ( ! result ) {
276 os << " unknown";
277 } else {
278 os << std::endl << indent+1;
279 result->print( os, indent+1 );
280 } // if
281 Expression::print( os, indent );
282}
283
284UntypedMemberExpr::UntypedMemberExpr( Expression * member, Expression *aggregate ) :
285 Expression(), member(member), aggregate(aggregate) {
286 assert( aggregate );
287}
288
289UntypedMemberExpr::UntypedMemberExpr( const UntypedMemberExpr &other ) :
290 Expression( other ), member( maybeClone( other.member ) ), aggregate( maybeClone( other.aggregate ) ) {
291}
292
293void UntypedMemberExpr::print( std::ostream &os, Indenter indent ) const {
294 os << "Untyped Member Expression, with field: " << std::endl << indent+1;
295 member->print(os, indent+1 );
296 os << indent << "... from aggregate: " << std::endl << indent+1;
297 aggregate->print(os, indent+1);
298 Expression::print( os, indent );
299}
300
301MemberExpr::MemberExpr( DeclarationWithType *member, Expression *aggregate ) :
302 Expression(), member(member), aggregate(aggregate) {
303 assert( member );
304 assert( aggregate );
305 assert( aggregate->result );
306
307 TypeSubstitution sub = aggregate->result->genericSubstitution();
308 Type * res = member->get_type()->clone();
309 sub.apply( res );
310 result = res;
311 result->set_lvalue( true );
312 result->get_qualifiers() |= aggregate->result->get_qualifiers();
313}
314
315MemberExpr::MemberExpr( const MemberExpr &other ) :
316 Expression( other ), member( other.member ), aggregate( maybeClone( other.aggregate ) ) {
317}
318
319void MemberExpr::print( std::ostream &os, Indenter indent ) const {
320 os << "Member Expression, with field: " << std::endl;
321 os << indent+1;
322 member->print( os, indent+1 );
323 os << std::endl << indent << "... from aggregate: " << std::endl << indent+1;
324 aggregate->print(os, indent + 1);
325 Expression::print( os, indent );
326}
327
328UntypedExpr::UntypedExpr( Expression *function, const std::list<Expression *> &args ) :
329 Expression(), function(function), args(args) {}
330
331UntypedExpr::UntypedExpr( const UntypedExpr &other ) :
332 Expression( other ), function( maybeClone( other.function ) ) {
333 cloneAll( other.args, args );
334}
335
336UntypedExpr * UntypedExpr::createDeref( Expression * expr ) {
337 UntypedExpr * ret = new UntypedExpr( new NameExpr("*?"), std::list< Expression * >{ expr } );
338 if ( Type * type = expr->get_result() ) {
339 Type * base = InitTweak::getPointerBase( type );
340 assertf( base, "expected pointer type in dereference (type was %s)", toString( type ).c_str() );
341 ret->set_result( base->clone() );
342 if ( GenPoly::referencesPermissable() ) {
343 // if references are still allowed in the AST, dereference returns a reference
344 ret->set_result( new ReferenceType( Type::Qualifiers(), ret->get_result() ) );
345 } else {
346 // references have been removed, in which case dereference returns an lvalue of the base type.
347 ret->result->set_lvalue( true );
348 }
349 }
350 return ret;
351}
352
353UntypedExpr * UntypedExpr::createAssign( Expression * arg1, Expression * arg2 ) {
354 assert( arg1 && arg2 );
355 UntypedExpr * ret = new UntypedExpr( new NameExpr( "?=?" ), std::list< Expression * >{ arg1, arg2 } );
356 if ( arg1->get_result() && arg2->get_result() ) {
357 // if both expressions are typed, assumes that this assignment is a C bitwise assignment,
358 // so the result is the type of the RHS
359 ret->set_result( arg2->get_result()->clone() );
360 }
361 return ret;
362}
363
364
365void UntypedExpr::print( std::ostream &os, Indenter indent ) const {
366 os << "Applying untyped: " << std::endl;
367 os << indent+1;
368 function->print(os, indent+1);
369 os << std::endl << indent << "...to: " << std::endl;
370 printAll(args, os, indent+1);
371 Expression::print( os, indent );
372}
373
374NameExpr::NameExpr( std::string name ) : Expression(), name(name) {
375 assertf(name != "0", "Zero is not a valid name");
376 assertf(name != "1", "One is not a valid name");
377}
378
379NameExpr::NameExpr( const NameExpr &other ) : Expression( other ), name( other.name ) {
380}
381
382void NameExpr::print( std::ostream &os, Indenter indent ) const {
383 os << "Name: " << get_name();
384 Expression::print( os, indent );
385}
386
387LogicalExpr::LogicalExpr( Expression *arg1_, Expression *arg2_, bool andp ) :
388 Expression(), arg1(arg1_), arg2(arg2_), isAnd(andp) {
389 set_result( new BasicType( Type::Qualifiers(), BasicType::SignedInt ) );
390}
391
392LogicalExpr::LogicalExpr( const LogicalExpr &other ) :
393 Expression( other ), arg1( maybeClone( other.arg1 ) ), arg2( maybeClone( other.arg2 ) ), isAnd( other.isAnd ) {
394}
395
396void LogicalExpr::print( std::ostream &os, Indenter indent )const {
397 os << "Short-circuited operation (" << (isAnd ? "and" : "or") << ") on: ";
398 arg1->print(os);
399 os << " and ";
400 arg2->print(os);
401 Expression::print( os, indent );
402}
403
404ConditionalExpr::ConditionalExpr( Expression * arg1, Expression * arg2, Expression * arg3 ) :
405 Expression(), arg1(arg1), arg2(arg2), arg3(arg3) {}
406
407ConditionalExpr::ConditionalExpr( const ConditionalExpr &other ) :
408 Expression( other ), arg1( maybeClone( other.arg1 ) ), arg2( maybeClone( other.arg2 ) ), arg3( maybeClone( other.arg3 ) ) {
409}
410
411void ConditionalExpr::print( std::ostream &os, Indenter indent ) const {
412 os << "Conditional expression on: " << std::endl << indent+1;
413 arg1->print( os, indent+1 );
414 os << indent << "First alternative:" << std::endl << indent+1;
415 arg2->print( os, indent+1 );
416 os << indent << "Second alternative:" << std::endl << indent+1;
417 arg3->print( os, indent+1 );
418 Expression::print( os, indent );
419}
420
421AsmExpr::AsmExpr( const AsmExpr & other ) : Expression( other ), inout( maybeClone( other.inout ) ), constraint( maybeClone( other.constraint ) ), operand( maybeClone( other.operand ) ) {}
422
423
424void AsmExpr::print( std::ostream &os, Indenter indent ) const {
425 os << "Asm Expression: " << std::endl;
426 if ( inout ) inout->print( os, indent+1 );
427 if ( constraint ) constraint->print( os, indent+1 );
428 if ( operand ) operand->print( os, indent+1 );
429}
430
431
432ImplicitCopyCtorExpr::ImplicitCopyCtorExpr( ApplicationExpr * callExpr ) : callExpr( callExpr ) {
433 assert( callExpr );
434 assert( callExpr->result );
435 set_result( callExpr->get_result()->clone() );
436}
437
438ImplicitCopyCtorExpr::ImplicitCopyCtorExpr( const ImplicitCopyCtorExpr & other ) : Expression( other ), callExpr( maybeClone( other.callExpr ) ) {
439 cloneAll( other.tempDecls, tempDecls );
440 cloneAll( other.returnDecls, returnDecls );
441 cloneAll( other.dtors, dtors );
442}
443
444ImplicitCopyCtorExpr::~ImplicitCopyCtorExpr() {
445 set_env( nullptr ); // ImplicitCopyCtorExpr does not take ownership of an environment
446}
447
448void ImplicitCopyCtorExpr::print( std::ostream &os, Indenter indent ) const {
449 os << "Implicit Copy Constructor Expression: " << std::endl << indent+1;
450 callExpr->print( os, indent+1 );
451 os << std::endl << indent << "... with temporaries:" << std::endl;
452 printAll( tempDecls, os, indent+1 );
453 os << std::endl << indent << "... with return temporaries:" << std::endl;
454 printAll( returnDecls, os, indent+1 );
455 Expression::print( os, indent );
456}
457
458
459ConstructorExpr::ConstructorExpr( Expression * callExpr ) : callExpr( callExpr ) {
460 // allow resolver to type a constructor used as an expression as if it has the same type as its first argument
461 assert( callExpr );
462 Expression * arg = InitTweak::getCallArg( callExpr, 0 );
463 assert( arg );
464 set_result( maybeClone( arg->result ) );
465}
466
467ConstructorExpr::ConstructorExpr( const ConstructorExpr & other ) : Expression( other ), callExpr( maybeClone( other.callExpr ) ) {
468}
469
470void ConstructorExpr::print( std::ostream &os, Indenter indent ) const {
471 os << "Constructor Expression: " << std::endl << indent+1;
472 callExpr->print( os, indent + 2 );
473 Expression::print( os, indent );
474}
475
476
477CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : initializer( initializer ) {
478 assert( type && initializer );
479 type->set_lvalue( true );
480 set_result( type );
481}
482
483CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), initializer( other.initializer->clone() ) {}
484
485void CompoundLiteralExpr::print( std::ostream &os, Indenter indent ) const {
486 os << "Compound Literal Expression: " << std::endl << indent+1;
487 result->print( os, indent+1 );
488 os << indent+1;
489 initializer->print( os, indent+1 );
490 Expression::print( os, indent );
491}
492
493RangeExpr::RangeExpr( Expression *low, Expression *high ) : low( low ), high( high ) {}
494RangeExpr::RangeExpr( const RangeExpr &other ) : Expression( other ), low( other.low->clone() ), high( other.high->clone() ) {}
495void RangeExpr::print( std::ostream &os, Indenter indent ) const {
496 os << "Range Expression: ";
497 low->print( os, indent );
498 os << " ... ";
499 high->print( os, indent );
500 Expression::print( os, indent );
501}
502
503StmtExpr::StmtExpr( CompoundStmt *statements ) : statements( statements ) {
504 computeResult();
505}
506StmtExpr::StmtExpr( const StmtExpr &other ) : Expression( other ), statements( other.statements->clone() ) {
507 cloneAll( other.returnDecls, returnDecls );
508 cloneAll( other.dtors, dtors );
509}
510void StmtExpr::computeResult() {
511 assert( statements );
512 std::list< Statement * > & body = statements->kids;
513 result = nullptr;
514 if ( ! returnDecls.empty() ) {
515 // prioritize return decl for result type, since if a return decl exists, then
516 // the StmtExpr is currently in an intermediate state where the body will always
517 // give a void result type.
518 result = returnDecls.front()->get_type()->clone();
519 } else if ( ! body.empty() ) {
520 if ( ExprStmt * exprStmt = dynamic_cast< ExprStmt * >( body.back() ) ) {
521 result = maybeClone( exprStmt->expr->result );
522 }
523 }
524 // ensure that StmtExpr has a result type
525 if ( ! result ) {
526 result = new VoidType( Type::Qualifiers() );
527 }
528}
529void StmtExpr::print( std::ostream &os, Indenter indent ) const {
530 os << "Statement Expression: " << std::endl << indent+1;
531 statements->print( os, indent+1 );
532 if ( ! returnDecls.empty() ) {
533 os << indent+1 << "... with returnDecls: ";
534 printAll( returnDecls, os, indent+1 );
535 }
536 if ( ! dtors.empty() ) {
537 os << indent+1 << "... with dtors: ";
538 printAll( dtors, os, indent+1 );
539 }
540 Expression::print( os, indent );
541}
542
543
544long long UniqueExpr::count = 0;
545UniqueExpr::UniqueExpr( Expression *expr, long long idVal ) : expr( expr ), object( nullptr ), var( nullptr ), id( idVal ) {
546 assert( expr );
547 assert( count != -1 );
548 if ( id == -1 ) id = count++;
549 if ( expr->get_result() ) {
550 set_result( expr->get_result()->clone() );
551 }
552}
553UniqueExpr::UniqueExpr( const UniqueExpr &other ) : Expression( other ), expr( maybeClone( other.expr ) ), object( maybeClone( other.object ) ), var( maybeClone( other.var ) ), id( other.id ) {
554}
555
556void UniqueExpr::print( std::ostream &os, Indenter indent ) const {
557 os << "Unique Expression with id:" << id << std::endl << indent+1;
558 expr->print( os, indent+1 );
559 if ( object ) {
560 os << indent << "... with decl: ";
561 get_object()->printShort( os, indent+1 );
562 }
563 Expression::print( os, indent );
564}
565
566InitAlternative::InitAlternative( Type * type, Designation * designation ) : type( type ), designation( designation ) {}
567InitAlternative::InitAlternative( const InitAlternative & other ) : type( maybeClone( other.type ) ), designation( maybeClone( other.designation ) ) {}
568
569UntypedInitExpr::UntypedInitExpr( Expression * expr, const std::list<InitAlternative> & initAlts ) : expr( expr ), initAlts( initAlts ) {}
570UntypedInitExpr::UntypedInitExpr( const UntypedInitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), initAlts( other.initAlts ) {}
571
572void UntypedInitExpr::print( std::ostream & os, Indenter indent ) const {
573 os << "Untyped Init Expression" << std::endl << indent+1;
574 expr->print( os, indent+1 );
575 if ( ! initAlts.empty() ) {
576 for ( const InitAlternative & alt : initAlts ) {
577 os << indent+1 << "InitAlternative: ";
578 alt.type->print( os, indent+1 );
579 alt.designation->print( os, indent+1 );
580 }
581 }
582}
583
584InitExpr::InitExpr( Expression * expr, Designation * designation ) : expr( expr ), designation( designation ) {
585 set_result( expr->get_result()->clone() );
586}
587InitExpr::InitExpr( const InitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), designation( maybeClone( other.designation) ) {}
588
589void InitExpr::print( std::ostream & os, Indenter indent ) const {
590 os << "Init Expression" << std::endl << indent+1;
591 expr->print( os, indent+1 );
592 os << indent+1 << "... with designation: ";
593 designation->print( os, indent+1 );
594}
595
596DeletedExpr::DeletedExpr( Expression * expr, BaseSyntaxNode * deleteStmt ) : expr( expr ), deleteStmt( deleteStmt ) {
597 assert( expr->result );
598 result = expr->result->clone();
599}
600DeletedExpr::DeletedExpr( const DeletedExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), deleteStmt( other.deleteStmt ) {}
601
602void DeletedExpr::print( std::ostream & os, Indenter indent ) const {
603 os << "Deleted Expression" << std::endl << indent+1;
604 expr->print( os, indent+1 );
605 os << std::endl << indent+1 << "... deleted by: ";
606 deleteStmt->print( os, indent+1 );
607}
608
609
610// Local Variables: //
611// tab-width: 4 //
612// mode: c++ //
613// compile-command: "make install" //
614// End: //
Note: See TracBrowser for help on using the repository browser.