Changes in src/CodeGen/CodeGenerator.cc [c2ce2350:03e5d14]
- File:
-
- 1 edited
-
src/CodeGen/CodeGenerator.cc (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
rc2ce2350 r03e5d14 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Apr 27 11:59:36201613 // Update Count : 2 5512 // Last Modified On : Fri May 06 15:40:35 2016 13 // Update Count : 243 14 14 // 15 15 … … 67 67 string mangleName( DeclarationWithType *decl ) { 68 68 if ( decl->get_mangleName() != "" ) { 69 // need to incorporate scope level in order to differentiate names for destructors 70 return decl->get_scopedMangleName(); 69 return decl->get_mangleName(); 71 70 } else { 72 71 return decl->get_name(); … … 76 75 //*** Declarations 77 76 void CodeGenerator::visit( FunctionDecl *functionDecl ) { 77 // generalize this 78 FunctionDecl::Attribute attr = functionDecl->get_attribute(); 79 switch ( attr.type ) { 80 case FunctionDecl::Attribute::Constructor: 81 output << "__attribute__ ((constructor"; 82 if ( attr.priority != FunctionDecl::Attribute::Default ) { 83 output << "(" << attr.priority << ")"; 84 } 85 output << ")) "; 86 break; 87 case FunctionDecl::Attribute::Destructor: 88 output << "__attribute__ ((destructor"; 89 if ( attr.priority != FunctionDecl::Attribute::Default ) { 90 output << "(" << attr.priority << ")"; 91 } 92 output << ")) "; 93 break; 94 default: 95 break; 96 } 78 97 handleStorageClass( functionDecl ); 79 98 if ( functionDecl->get_isInline() ) { … … 214 233 printDesignators( init->get_designators() ); 215 234 output << "{ "; 216 if ( init->begin_initializers() == init->end_initializers() ) { 217 // illegal to leave initializer list empty for scalar initializers, 218 // but always legal to have 0 219 output << "0"; 220 } else { 221 genCommaList( init->begin_initializers(), init->end_initializers() ); 222 } 235 genCommaList( init->begin_initializers(), init->end_initializers() ); 223 236 output << " }"; 224 237 } … … 238 251 case OT_POSTFIXASSIGN: 239 252 case OT_INFIXASSIGN: 240 case OT_CTOR:241 case OT_DTOR:242 253 { 243 254 assert( arg != applicationExpr->get_args().end() ); 244 255 if ( AddressExpr *addrExpr = dynamic_cast< AddressExpr * >( *arg ) ) { 245 // remove & from first assignment/ctor argument 256 246 257 *arg = addrExpr->get_arg(); 247 258 } else { 248 // no address-of operator, so must be a pointer - add dereference249 259 UntypedExpr *newExpr = new UntypedExpr( new NameExpr( "*?" ) ); 250 260 newExpr->get_args().push_back( *arg ); … … 273 283 break; 274 284 275 case OT_CTOR:276 case OT_DTOR:277 if ( applicationExpr->get_args().size() == 1 ) {278 // the expression fed into a single parameter constructor or destructor279 // may contain side effects - output as a void expression280 output << "((void)(";281 (*arg++)->accept( *this );282 output << ")) /* " << opInfo.inputName << " */";283 } else if ( applicationExpr->get_args().size() == 2 ) {284 // intrinsic two parameter constructors are essentially bitwise assignment285 output << "(";286 (*arg++)->accept( *this );287 output << opInfo.symbol;288 (*arg)->accept( *this );289 output << ") /* " << opInfo.inputName << " */";290 } else {291 // no constructors with 0 or more than 2 parameters292 assert( false );293 }294 break;295 296 285 case OT_PREFIX: 297 286 case OT_PREFIXASSIGN: … … 309 298 output << opInfo.symbol; 310 299 break; 311 312 300 313 301 case OT_INFIX: … … 356 344 case OT_CALL: 357 345 assert( false ); 358 359 360 case OT_CTOR:361 case OT_DTOR:362 if ( untypedExpr->get_args().size() == 1 ) {363 // the expression fed into a single parameter constructor or destructor364 // may contain side effects - output as a void expression365 output << "((void)(";366 (*arg++)->accept( *this );367 output << ")) /* " << opInfo.inputName << " */";368 } else if ( untypedExpr->get_args().size() == 2 ) {369 // intrinsic two parameter constructors are essentially bitwise assignment370 output << "(";371 (*arg++)->accept( *this );372 output << opInfo.symbol;373 (*arg)->accept( *this );374 output << ") /* " << opInfo.inputName << " */";375 } else {376 // no constructors with 0 or more than 2 parameters377 assert( false );378 }379 346 break; 380 347
Note:
See TracChangeset
for help on using the changeset viewer.