| [0dd3a2f] | 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 | 
|---|
| [d58ebf3] | 11 | // Last Modified By : Rob Schluntz | 
|---|
| [baf7fee] | 12 | // Last Modified On : Wed Dec 09 14:10:29 2015 | 
|---|
|  | 13 | // Update Count     : 34 | 
|---|
| [0dd3a2f] | 14 | // | 
|---|
|  | 15 |  | 
|---|
| [51b73452] | 16 | #include <iostream> | 
|---|
|  | 17 | #include <cassert> | 
|---|
|  | 18 | #include <list> | 
|---|
|  | 19 | #include <algorithm> | 
|---|
|  | 20 |  | 
|---|
|  | 21 | #include <iterator> | 
|---|
|  | 22 |  | 
|---|
|  | 23 | #include "Type.h" | 
|---|
|  | 24 | #include "Expression.h" | 
|---|
|  | 25 | #include "Declaration.h" | 
|---|
|  | 26 | #include "Statement.h" | 
|---|
|  | 27 | #include "TypeSubstitution.h" | 
|---|
|  | 28 | #include "utility.h" | 
|---|
|  | 29 |  | 
|---|
|  | 30 |  | 
|---|
|  | 31 | Expression::Expression( Expression *_aname ) : env( 0 ), argName( _aname ) {} | 
|---|
| [0dd3a2f] | 32 |  | 
|---|
| [d0d9610] | 33 | Expression::Expression( const Expression &other ) : env( maybeClone( other.env ) ), argName( maybeClone( other.get_argName() ) ) { | 
|---|
| [0dd3a2f] | 34 | cloneAll( other.results, results ); | 
|---|
|  | 35 | } | 
|---|
|  | 36 |  | 
|---|
|  | 37 | Expression::~Expression() { | 
|---|
|  | 38 | delete env; | 
|---|
| [7f5566b] | 39 | delete argName; // xxx -- there's a problem in cloning ConstantExpr I still don't know how to fix | 
|---|
| [0dd3a2f] | 40 | deleteAll( results ); | 
|---|
|  | 41 | } | 
|---|
|  | 42 |  | 
|---|
|  | 43 | void Expression::add_result( Type *t ) { | 
|---|
|  | 44 | if ( TupleType *tuple = dynamic_cast< TupleType* >( t ) ) { | 
|---|
|  | 45 | std::copy( tuple->get_types().begin(), tuple->get_types().end(), back_inserter( results ) ); | 
|---|
|  | 46 | } else { | 
|---|
|  | 47 | results.push_back(t); | 
|---|
|  | 48 | } // if | 
|---|
| [51b73452] | 49 | } | 
|---|
|  | 50 |  | 
|---|
| [59db689] | 51 | void Expression::print( std::ostream &os, int indent ) const { | 
|---|
| [0dd3a2f] | 52 | if ( env ) { | 
|---|
| [cf0941d] | 53 | os << std::string( indent, ' ' ) << "with environment:" << std::endl; | 
|---|
| [0dd3a2f] | 54 | env->print( os, indent+2 ); | 
|---|
|  | 55 | } // if | 
|---|
| [51b73452] | 56 |  | 
|---|
| [0dd3a2f] | 57 | if ( argName ) { | 
|---|
| [cf0941d] | 58 | os << std::string( indent, ' ' ) << "with designator:"; | 
|---|
| [0dd3a2f] | 59 | argName->print( os, indent+2 ); | 
|---|
|  | 60 | } // if | 
|---|
| [51b73452] | 61 | } | 
|---|
|  | 62 |  | 
|---|
| [0dd3a2f] | 63 | ConstantExpr::ConstantExpr( Constant _c, Expression *_aname ) : Expression( _aname ), constant( _c ) { | 
|---|
|  | 64 | add_result( constant.get_type()->clone() ); | 
|---|
| [51b73452] | 65 | } | 
|---|
|  | 66 |  | 
|---|
| [0dd3a2f] | 67 | ConstantExpr::ConstantExpr( const ConstantExpr &other) : Expression( other ), constant( other.constant ) { | 
|---|
|  | 68 | } | 
|---|
| [51b73452] | 69 |  | 
|---|
|  | 70 | ConstantExpr::~ConstantExpr() {} | 
|---|
|  | 71 |  | 
|---|
| [0dd3a2f] | 72 | void ConstantExpr::print( std::ostream &os, int indent ) const { | 
|---|
| [d58ebf3] | 73 | os << std::string( indent, ' ' ) << "constant expression " ; | 
|---|
| [cf0941d] | 74 | constant.print( os ); | 
|---|
| [0dd3a2f] | 75 | Expression::print( os, indent ); | 
|---|
| [d58ebf3] | 76 | os << std::endl; | 
|---|
| [51b73452] | 77 | } | 
|---|
|  | 78 |  | 
|---|
| [0dd3a2f] | 79 | VariableExpr::VariableExpr( DeclarationWithType *_var, Expression *_aname ) : Expression( _aname ), var( _var ) { | 
|---|
|  | 80 | add_result( var->get_type()->clone() ); | 
|---|
|  | 81 | for ( std::list< Type* >::iterator i = get_results().begin(); i != get_results().end(); ++i ) { | 
|---|
|  | 82 | (*i)->set_isLvalue( true ); | 
|---|
|  | 83 | } // for | 
|---|
| [51b73452] | 84 | } | 
|---|
|  | 85 |  | 
|---|
| [0dd3a2f] | 86 | VariableExpr::VariableExpr( const VariableExpr &other ) : Expression( other ), var( other.var ) { | 
|---|
| [51b73452] | 87 | } | 
|---|
|  | 88 |  | 
|---|
| [0dd3a2f] | 89 | VariableExpr::~VariableExpr() { | 
|---|
|  | 90 | // don't delete the declaration, since it points somewhere else in the tree | 
|---|
| [51b73452] | 91 | } | 
|---|
|  | 92 |  | 
|---|
| [0dd3a2f] | 93 | void VariableExpr::print( std::ostream &os, int indent ) const { | 
|---|
| [44b5ca0] | 94 | os << std::string( indent, ' ' ) << "Variable Expression: "; | 
|---|
| [51b73452] | 95 |  | 
|---|
| [0dd3a2f] | 96 | Declaration *decl = get_var(); | 
|---|
|  | 97 | // if ( decl != 0) decl->print(os, indent + 2); | 
|---|
|  | 98 | if ( decl != 0) decl->printShort(os, indent + 2); | 
|---|
|  | 99 | os << std::endl; | 
|---|
|  | 100 | Expression::print( os, indent ); | 
|---|
| [51b73452] | 101 | } | 
|---|
|  | 102 |  | 
|---|
|  | 103 | SizeofExpr::SizeofExpr( Expression *expr_, Expression *_aname ) : | 
|---|
| [0dd3a2f] | 104 | Expression( _aname ), expr(expr_), type(0), isType(false) { | 
|---|
|  | 105 | add_result( new BasicType( Type::Qualifiers(), BasicType::UnsignedInt ) ); | 
|---|
| [51b73452] | 106 | } | 
|---|
|  | 107 |  | 
|---|
|  | 108 | SizeofExpr::SizeofExpr( Type *type_, Expression *_aname ) : | 
|---|
| [0dd3a2f] | 109 | Expression( _aname ), expr(0), type(type_), isType(true) { | 
|---|
|  | 110 | add_result( new BasicType( Type::Qualifiers(), BasicType::UnsignedInt ) ); | 
|---|
| [51b73452] | 111 | } | 
|---|
|  | 112 |  | 
|---|
| [0dd3a2f] | 113 | SizeofExpr::SizeofExpr( const SizeofExpr &other ) : | 
|---|
|  | 114 | Expression( other ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType ) { | 
|---|
| [51b73452] | 115 | } | 
|---|
|  | 116 |  | 
|---|
| [0dd3a2f] | 117 | SizeofExpr::~SizeofExpr() { | 
|---|
|  | 118 | delete expr; | 
|---|
|  | 119 | delete type; | 
|---|
| [51b73452] | 120 | } | 
|---|
|  | 121 |  | 
|---|
|  | 122 | void SizeofExpr::print( std::ostream &os, int indent) const { | 
|---|
| [44b5ca0] | 123 | os << std::string( indent, ' ' ) << "Sizeof Expression on: "; | 
|---|
| [51b73452] | 124 |  | 
|---|
| [47534159] | 125 | if (isType) | 
|---|
|  | 126 | type->print(os, indent + 2); | 
|---|
|  | 127 | else | 
|---|
|  | 128 | expr->print(os, indent + 2); | 
|---|
|  | 129 |  | 
|---|
|  | 130 | os << std::endl; | 
|---|
|  | 131 | Expression::print( os, indent ); | 
|---|
|  | 132 | } | 
|---|
|  | 133 |  | 
|---|
|  | 134 | AlignofExpr::AlignofExpr( Expression *expr_, Expression *_aname ) : | 
|---|
|  | 135 | Expression( _aname ), expr(expr_), type(0), isType(false) { | 
|---|
|  | 136 | add_result( new BasicType( Type::Qualifiers(), BasicType::UnsignedInt ) ); | 
|---|
|  | 137 | } | 
|---|
|  | 138 |  | 
|---|
|  | 139 | AlignofExpr::AlignofExpr( Type *type_, Expression *_aname ) : | 
|---|
|  | 140 | Expression( _aname ), expr(0), type(type_), isType(true) { | 
|---|
|  | 141 | add_result( new BasicType( Type::Qualifiers(), BasicType::UnsignedInt ) ); | 
|---|
|  | 142 | } | 
|---|
|  | 143 |  | 
|---|
|  | 144 | AlignofExpr::AlignofExpr( const AlignofExpr &other ) : | 
|---|
|  | 145 | Expression( other ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType ) { | 
|---|
|  | 146 | } | 
|---|
|  | 147 |  | 
|---|
|  | 148 | AlignofExpr::~AlignofExpr() { | 
|---|
|  | 149 | delete expr; | 
|---|
|  | 150 | delete type; | 
|---|
|  | 151 | } | 
|---|
|  | 152 |  | 
|---|
|  | 153 | void AlignofExpr::print( std::ostream &os, int indent) const { | 
|---|
|  | 154 | os << std::string( indent, ' ' ) << "Alignof Expression on: "; | 
|---|
|  | 155 |  | 
|---|
| [0dd3a2f] | 156 | if (isType) | 
|---|
|  | 157 | type->print(os, indent + 2); | 
|---|
|  | 158 | else | 
|---|
|  | 159 | expr->print(os, indent + 2); | 
|---|
| [51b73452] | 160 |  | 
|---|
| [0dd3a2f] | 161 | os << std::endl; | 
|---|
|  | 162 | Expression::print( os, indent ); | 
|---|
| [51b73452] | 163 | } | 
|---|
|  | 164 |  | 
|---|
|  | 165 | AttrExpr::AttrExpr( Expression *attr, Expression *expr_, Expression *_aname ) : | 
|---|
| [0dd3a2f] | 166 | Expression( _aname ), attr( attr ), expr(expr_), type(0), isType(false) { | 
|---|
| [51b73452] | 167 | } | 
|---|
|  | 168 |  | 
|---|
|  | 169 | AttrExpr::AttrExpr( Expression *attr, Type *type_, Expression *_aname ) : | 
|---|
| [0dd3a2f] | 170 | Expression( _aname ), attr( attr ), expr(0), type(type_), isType(true) { | 
|---|
| [51b73452] | 171 | } | 
|---|
|  | 172 |  | 
|---|
| [0dd3a2f] | 173 | AttrExpr::AttrExpr( const AttrExpr &other ) : | 
|---|
|  | 174 | Expression( other ), attr( maybeClone( other.attr ) ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType ) { | 
|---|
| [51b73452] | 175 | } | 
|---|
|  | 176 |  | 
|---|
| [0dd3a2f] | 177 | AttrExpr::~AttrExpr() { | 
|---|
|  | 178 | delete attr; | 
|---|
|  | 179 | delete expr; | 
|---|
|  | 180 | delete type; | 
|---|
| [51b73452] | 181 | } | 
|---|
|  | 182 |  | 
|---|
|  | 183 | void AttrExpr::print( std::ostream &os, int indent) const { | 
|---|
| [44b5ca0] | 184 | os << std::string( indent, ' ' ) << "Attr "; | 
|---|
| [0dd3a2f] | 185 | attr->print( os, indent + 2 ); | 
|---|
|  | 186 | if ( isType || expr ) { | 
|---|
|  | 187 | os << "applied to: "; | 
|---|
| [51b73452] | 188 |  | 
|---|
| [0dd3a2f] | 189 | if (isType) | 
|---|
|  | 190 | type->print(os, indent + 2); | 
|---|
|  | 191 | else | 
|---|
|  | 192 | expr->print(os, indent + 2); | 
|---|
|  | 193 | } // if | 
|---|
| [51b73452] | 194 |  | 
|---|
| [0dd3a2f] | 195 | os << std::endl; | 
|---|
|  | 196 | Expression::print( os, indent ); | 
|---|
| [51b73452] | 197 | } | 
|---|
|  | 198 |  | 
|---|
| [0dd3a2f] | 199 | CastExpr::CastExpr( Expression *arg_, Type *toType, Expression *_aname ) : Expression( _aname ), arg(arg_) { | 
|---|
|  | 200 | add_result(toType); | 
|---|
| [51b73452] | 201 | } | 
|---|
|  | 202 |  | 
|---|
|  | 203 | CastExpr::CastExpr( Expression *arg_, Expression *_aname ) : Expression( _aname ), arg(arg_) { | 
|---|
|  | 204 | } | 
|---|
|  | 205 |  | 
|---|
| [0dd3a2f] | 206 | CastExpr::CastExpr( const CastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ) { | 
|---|
| [51b73452] | 207 | } | 
|---|
|  | 208 |  | 
|---|
|  | 209 | CastExpr::~CastExpr() { | 
|---|
| [0dd3a2f] | 210 | delete arg; | 
|---|
| [51b73452] | 211 | } | 
|---|
|  | 212 |  | 
|---|
|  | 213 | // CastExpr *CastExpr::clone() const { return 0; } | 
|---|
|  | 214 |  | 
|---|
|  | 215 | void CastExpr::print( std::ostream &os, int indent ) const { | 
|---|
| [44b5ca0] | 216 | os << std::string( indent, ' ' ) << "Cast of:" << std::endl; | 
|---|
| [0dd3a2f] | 217 | arg->print(os, indent+2); | 
|---|
| [44b5ca0] | 218 | os << std::endl << std::string( indent, ' ' ) << "to:" << std::endl; | 
|---|
| [0dd3a2f] | 219 | if ( results.empty() ) { | 
|---|
| [44b5ca0] | 220 | os << std::string( indent+2, ' ' ) << "nothing" << std::endl; | 
|---|
| [0dd3a2f] | 221 | } else { | 
|---|
|  | 222 | printAll(results, os, indent+2); | 
|---|
|  | 223 | } // if | 
|---|
|  | 224 | Expression::print( os, indent ); | 
|---|
|  | 225 | } | 
|---|
|  | 226 |  | 
|---|
| [51b73452] | 227 | UntypedMemberExpr::UntypedMemberExpr( std::string _member, Expression *_aggregate, Expression *_aname ) : | 
|---|
| [0dd3a2f] | 228 | Expression( _aname ), member(_member), aggregate(_aggregate) {} | 
|---|
| [51b73452] | 229 |  | 
|---|
| [0dd3a2f] | 230 | UntypedMemberExpr::UntypedMemberExpr( const UntypedMemberExpr &other ) : | 
|---|
|  | 231 | Expression( other ), member( other.member ), aggregate( maybeClone( other.aggregate ) ) { | 
|---|
| [51b73452] | 232 | } | 
|---|
|  | 233 |  | 
|---|
|  | 234 | UntypedMemberExpr::~UntypedMemberExpr() { | 
|---|
| [0dd3a2f] | 235 | delete aggregate; | 
|---|
| [51b73452] | 236 | } | 
|---|
|  | 237 |  | 
|---|
|  | 238 | void UntypedMemberExpr::print( std::ostream &os, int indent ) const { | 
|---|
| [44b5ca0] | 239 | os << std::string( indent, ' ' ) << "Member Expression, with field: " << get_member(); | 
|---|
| [51b73452] | 240 |  | 
|---|
| [0dd3a2f] | 241 | Expression *agg = get_aggregate(); | 
|---|
| [44b5ca0] | 242 | os << std::string( indent, ' ' ) << "from aggregate: "; | 
|---|
| [0dd3a2f] | 243 | if (agg != 0) agg->print(os, indent + 2); | 
|---|
|  | 244 | Expression::print( os, indent ); | 
|---|
| [51b73452] | 245 | } | 
|---|
|  | 246 |  | 
|---|
|  | 247 |  | 
|---|
|  | 248 | MemberExpr::MemberExpr( DeclarationWithType *_member, Expression *_aggregate, Expression *_aname ) : | 
|---|
| [0dd3a2f] | 249 | Expression( _aname ), member(_member), aggregate(_aggregate) { | 
|---|
|  | 250 | add_result( member->get_type()->clone() ); | 
|---|
|  | 251 | for ( std::list< Type* >::iterator i = get_results().begin(); i != get_results().end(); ++i ) { | 
|---|
|  | 252 | (*i)->set_isLvalue( true ); | 
|---|
|  | 253 | } // for | 
|---|
| [51b73452] | 254 | } | 
|---|
|  | 255 |  | 
|---|
| [0dd3a2f] | 256 | MemberExpr::MemberExpr( const MemberExpr &other ) : | 
|---|
|  | 257 | Expression( other ), member( maybeClone( other.member ) ), aggregate( maybeClone( other.aggregate ) ) { | 
|---|
| [51b73452] | 258 | } | 
|---|
|  | 259 |  | 
|---|
|  | 260 | MemberExpr::~MemberExpr() { | 
|---|
| [0dd3a2f] | 261 | delete member; | 
|---|
|  | 262 | delete aggregate; | 
|---|
| [51b73452] | 263 | } | 
|---|
|  | 264 |  | 
|---|
|  | 265 | void MemberExpr::print( std::ostream &os, int indent ) const { | 
|---|
| [44b5ca0] | 266 | os << std::string( indent, ' ' ) << "Member Expression, with field: " << std::endl; | 
|---|
| [51b73452] | 267 |  | 
|---|
| [0dd3a2f] | 268 | assert( member ); | 
|---|
| [44b5ca0] | 269 | os << std::string( indent + 2, ' ' ); | 
|---|
| [0dd3a2f] | 270 | member->print( os, indent + 2 ); | 
|---|
|  | 271 | os << std::endl; | 
|---|
| [51b73452] | 272 |  | 
|---|
| [0dd3a2f] | 273 | Expression *agg = get_aggregate(); | 
|---|
| [44b5ca0] | 274 | os << std::string( indent, ' ' ) << "from aggregate: " << std::endl; | 
|---|
| [0dd3a2f] | 275 | if (agg != 0) agg->print(os, indent + 2); | 
|---|
|  | 276 | Expression::print( os, indent ); | 
|---|
| [51b73452] | 277 | } | 
|---|
|  | 278 |  | 
|---|
|  | 279 |  | 
|---|
|  | 280 | UntypedExpr::UntypedExpr( Expression *_function, Expression *_aname ) : Expression( _aname ), function( _function ) {} | 
|---|
|  | 281 |  | 
|---|
| [0dd3a2f] | 282 | UntypedExpr::UntypedExpr( const UntypedExpr &other ) : | 
|---|
|  | 283 | Expression( other ), function( maybeClone( other.function ) ) { | 
|---|
|  | 284 | cloneAll( other.args, args ); | 
|---|
| [51b73452] | 285 | } | 
|---|
|  | 286 |  | 
|---|
|  | 287 | UntypedExpr::UntypedExpr( Expression *_function, std::list<Expression *> &_args, Expression *_aname ) : | 
|---|
| [0dd3a2f] | 288 | Expression( _aname ), function(_function), args(_args) {} | 
|---|
| [51b73452] | 289 |  | 
|---|
|  | 290 | UntypedExpr::~UntypedExpr() {} | 
|---|
|  | 291 |  | 
|---|
|  | 292 | void UntypedExpr::print( std::ostream &os, int indent ) const { | 
|---|
| [44b5ca0] | 293 | os << std::string( indent, ' ' ) << "Applying untyped: " << std::endl; | 
|---|
| [0dd3a2f] | 294 | function->print(os, indent + 4); | 
|---|
| [44b5ca0] | 295 | os << std::string( indent, ' ' ) << "...to: " << std::endl; | 
|---|
| [0dd3a2f] | 296 | printArgs(os, indent + 4); | 
|---|
|  | 297 | Expression::print( os, indent ); | 
|---|
| [51b73452] | 298 | } | 
|---|
|  | 299 |  | 
|---|
| [0dd3a2f] | 300 | void UntypedExpr::printArgs( std::ostream &os, int indent ) const { | 
|---|
|  | 301 | std::list<Expression *>::const_iterator i; | 
|---|
|  | 302 | for (i = args.begin(); i != args.end(); i++) | 
|---|
|  | 303 | (*i)->print(os, indent); | 
|---|
| [51b73452] | 304 | } | 
|---|
|  | 305 |  | 
|---|
|  | 306 | NameExpr::NameExpr( std::string _name, Expression *_aname ) : Expression( _aname ), name(_name) {} | 
|---|
|  | 307 |  | 
|---|
| [0dd3a2f] | 308 | NameExpr::NameExpr( const NameExpr &other ) : Expression( other ), name( other.name ) { | 
|---|
| [51b73452] | 309 | } | 
|---|
|  | 310 |  | 
|---|
|  | 311 | NameExpr::~NameExpr() {} | 
|---|
|  | 312 |  | 
|---|
|  | 313 | void NameExpr::print( std::ostream &os, int indent ) const { | 
|---|
| [44b5ca0] | 314 | os << std::string( indent, ' ' ) << "Name: " << get_name() << std::endl; | 
|---|
| [0dd3a2f] | 315 | Expression::print( os, indent ); | 
|---|
| [51b73452] | 316 | } | 
|---|
|  | 317 |  | 
|---|
|  | 318 | LogicalExpr::LogicalExpr( Expression *arg1_, Expression *arg2_, bool andp, Expression *_aname ) : | 
|---|
| [0dd3a2f] | 319 | Expression( _aname ), arg1(arg1_), arg2(arg2_), isAnd(andp) { | 
|---|
|  | 320 | add_result( new BasicType( Type::Qualifiers(), BasicType::SignedInt ) ); | 
|---|
| [51b73452] | 321 | } | 
|---|
|  | 322 |  | 
|---|
| [0dd3a2f] | 323 | LogicalExpr::LogicalExpr( const LogicalExpr &other ) : | 
|---|
|  | 324 | Expression( other ), arg1( maybeClone( other.arg1 ) ), arg2( maybeClone( other.arg2 ) ), isAnd( other.isAnd ) { | 
|---|
| [51b73452] | 325 | } | 
|---|
|  | 326 |  | 
|---|
| [a08ba92] | 327 | LogicalExpr::~LogicalExpr() { | 
|---|
| [0dd3a2f] | 328 | delete arg1; | 
|---|
|  | 329 | delete arg2; | 
|---|
| [51b73452] | 330 | } | 
|---|
|  | 331 |  | 
|---|
|  | 332 | void LogicalExpr::print( std::ostream &os, int indent )const { | 
|---|
| [44b5ca0] | 333 | os << std::string( indent, ' ' ) << "Short-circuited operation (" << (isAnd?"and":"or") << ") on: "; | 
|---|
| [0dd3a2f] | 334 | arg1->print(os); | 
|---|
|  | 335 | os << " and "; | 
|---|
|  | 336 | arg2->print(os); | 
|---|
|  | 337 | os << std::endl; | 
|---|
|  | 338 | Expression::print( os, indent ); | 
|---|
| [51b73452] | 339 | } | 
|---|
|  | 340 |  | 
|---|
|  | 341 | ConditionalExpr::ConditionalExpr( Expression *arg1_, Expression *arg2_, Expression *arg3_, Expression *_aname ) : | 
|---|
| [0dd3a2f] | 342 | Expression( _aname ), arg1(arg1_), arg2(arg2_), arg3(arg3_) {} | 
|---|
| [51b73452] | 343 |  | 
|---|
| [0dd3a2f] | 344 | ConditionalExpr::ConditionalExpr( const ConditionalExpr &other ) : | 
|---|
|  | 345 | Expression( other ), arg1( maybeClone( other.arg1 ) ), arg2( maybeClone( other.arg2 ) ), arg3( maybeClone( other.arg3 ) ) { | 
|---|
|  | 346 | } | 
|---|
| [51b73452] | 347 |  | 
|---|
|  | 348 | ConditionalExpr::~ConditionalExpr() { | 
|---|
| [0dd3a2f] | 349 | delete arg1; | 
|---|
|  | 350 | delete arg2; | 
|---|
|  | 351 | delete arg3; | 
|---|
| [51b73452] | 352 | } | 
|---|
|  | 353 |  | 
|---|
|  | 354 | void ConditionalExpr::print( std::ostream &os, int indent ) const { | 
|---|
| [44b5ca0] | 355 | os << std::string( indent, ' ' ) << "Conditional expression on: " << std::endl; | 
|---|
| [0dd3a2f] | 356 | arg1->print( os, indent+2 ); | 
|---|
| [44b5ca0] | 357 | os << std::string( indent, ' ' ) << "First alternative:" << std::endl; | 
|---|
| [0dd3a2f] | 358 | arg2->print( os, indent+2 ); | 
|---|
| [44b5ca0] | 359 | os << std::string( indent, ' ' ) << "Second alternative:" << std::endl; | 
|---|
| [0dd3a2f] | 360 | arg3->print( os, indent+2 ); | 
|---|
|  | 361 | os << std::endl; | 
|---|
|  | 362 | Expression::print( os, indent ); | 
|---|
|  | 363 | } | 
|---|
|  | 364 |  | 
|---|
| [7f5566b] | 365 | void AsmExpr::print( std::ostream &os, int indent ) const { | 
|---|
|  | 366 | os << "Asm Expression: " << std::endl; | 
|---|
|  | 367 | if ( inout ) inout->print( os, indent + 2 ); | 
|---|
|  | 368 | if ( constraint ) constraint->print( os, indent + 2 ); | 
|---|
|  | 369 | if ( operand ) operand->print( os, indent + 2 ); | 
|---|
|  | 370 | } | 
|---|
|  | 371 |  | 
|---|
| [0dd3a2f] | 372 | void UntypedValofExpr::print( std::ostream &os, int indent ) const { | 
|---|
| [44b5ca0] | 373 | os << std::string( indent, ' ' ) << "Valof Expression: " << std::endl; | 
|---|
| [0dd3a2f] | 374 | if ( get_body() != 0 ) | 
|---|
|  | 375 | get_body()->print( os, indent + 2 ); | 
|---|
|  | 376 | } | 
|---|
|  | 377 |  | 
|---|
| [baf7fee] | 378 | std::ostream & operator<<( std::ostream & out, Expression * expr ) { | 
|---|
|  | 379 | expr->print( out ); | 
|---|
|  | 380 | return out; | 
|---|
|  | 381 | } | 
|---|
|  | 382 |  | 
|---|
| [0dd3a2f] | 383 | // Local Variables: // | 
|---|
|  | 384 | // tab-width: 4 // | 
|---|
|  | 385 | // mode: c++ // | 
|---|
|  | 386 | // compile-command: "make install" // | 
|---|
|  | 387 | // End: // | 
|---|