Changeset 356189a for src/CodeGen
- Timestamp:
- Apr 14, 2016, 5:11:26 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- b617e4b
- Parents:
- 70a06f6
- git-author:
- Rob Schluntz <rschlunt@…> (04/14/16 17:10:08)
- git-committer:
- Rob Schluntz <rschlunt@…> (04/14/16 17:11:26)
- Location:
- src/CodeGen
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r70a06f6 r356189a 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Thu Apr 14 1 5:40:00201612 // Last Modified On : Thu Apr 14 17:10:21 2016 13 13 // Update Count : 255 14 14 // … … 238 238 case OT_POSTFIXASSIGN: 239 239 case OT_INFIXASSIGN: 240 case OT_CTOR: 240 241 { 241 242 assert( arg != applicationExpr->get_args().end() ); 242 243 if ( AddressExpr *addrExpr = dynamic_cast< AddressExpr * >( *arg ) ) { 243 244 // remove & from first assignment/ctor argument 244 245 *arg = addrExpr->get_arg(); 245 246 } else { 247 // no address-of operator, so must be a pointer - add dereference 246 248 UntypedExpr *newExpr = new UntypedExpr( new NameExpr( "*?" ) ); 247 249 newExpr->get_args().push_back( *arg ); … … 266 268 267 269 case OT_CALL: 268 // there are no intrinsic definitions of the function call operator or constructors or destructors270 // there are no intrinsic definitions of the function call operator 269 271 assert( false ); 270 272 break; 271 273 272 274 case OT_CTOR: 273 // it's just an optimization to disallow this, so for now let it through 274 // since it makes autogenerating constructors a lot easier 275 varExpr->accept( *this ); 276 output << "("; 277 genCommaList( applicationExpr->get_args().begin(), applicationExpr->get_args().end() ); 278 output << ")"; 279 280 // intrinsic constructors should never be called directly - they should be transformed back into Initializer nodes 281 // assert(false); 282 break; 275 if ( applicationExpr->get_args().size() == 1 ) { 276 // the expression fed into a single parameter constructor may contain 277 // side effects - output as a void expression 278 output << "((void)("; 279 (*arg++)->accept( *this ); 280 output << ")) /* ?{} */"; 281 } else if ( applicationExpr->get_args().size() == 2 ) { 282 // intrinsic constructors are essentially bitwise assignment 283 output << "("; 284 (*arg++)->accept( *this ); 285 output << opInfo.symbol; 286 (*arg)->accept( *this ); 287 output << ") /* ?{} */"; 288 } else { 289 // not constructors with 0 or more than 2 parameters 290 assert( false ); 291 } 292 break; 283 293 284 294 case OT_DTOR: -
src/CodeGen/OperatorTable.cc
r70a06f6 r356189a 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : T ue Oct 06 15:26:34 201512 // Last Modified On : Thu Apr 14 16:48:27 2016 13 13 // Update Count : 9 14 14 // … … 21 21 const OperatorInfo tableValues[] = { 22 22 { "?[?]", "", "_operator_index", OT_INDEX }, 23 { "?{}", " ", "_constructor", OT_CTOR },23 { "?{}", "=", "_constructor", OT_CTOR }, 24 24 { "^?{}", "", "_destructor", OT_DTOR }, 25 25 { "?()", "", "_operator_call", OT_CALL },
Note:
See TracChangeset
for help on using the changeset viewer.