Changes in / [c8ad5d9:da7fe39]
- Location:
- src
- Files:
-
- 3 edited
-
GenPoly/Lvalue.cc (modified) (6 diffs)
-
InitTweak/InitTweak.cc (modified) (2 diffs)
-
ResolvExpr/CommonType.cc (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Lvalue.cc
rc8ad5d9 rda7fe39 17 17 #include <string> // for string 18 18 19 #include "Common/Debug.h" 19 20 #include "Common/PassVisitor.h" 20 21 #include "GenPoly.h" // for isPolyType … … 128 129 PassVisitor<AddrRef> addrRef; 129 130 PassVisitor<FixIntrinsicResult> intrinsicResults; 131 Debug::codeGen( translationUnit, "begin" ); 130 132 mutateAll( translationUnit, intrinsicResults ); 133 Debug::codeGen( translationUnit, "intrinsicResults" ); 131 134 mutateAll( translationUnit, addrRef ); 135 Debug::codeGen( translationUnit, "addrRef" ); 132 136 mutateAll( translationUnit, refCvt ); 137 Debug::codeGen( translationUnit, "refCvt" ); 133 138 mutateAll( translationUnit, fixer ); 139 Debug::codeGen( translationUnit, "fixer" ); 134 140 mutateAll( translationUnit, collapser ); 141 Debug::codeGen( translationUnit, "collapser" ); 135 142 mutateAll( translationUnit, genLval ); 143 Debug::codeGen( translationUnit, "genLval" ); 136 144 mutateAll( translationUnit, elim ); // last because other passes need reference types to work 145 Debug::codeGen( translationUnit, "elim" ); 137 146 138 147 // from this point forward, no other pass should create reference types. … … 211 220 ) 212 221 // TODO: it's likely that the second condition should be ... && ! isIntrinsicReference( arg ), but this requires investigation. 222 213 223 if ( function->get_linkage() != LinkageSpec::Intrinsic && isIntrinsicReference( arg ) ) { 224 // needed for definition of prelude functions, etc. 214 225 // if argument is dereference or array subscript, the result isn't REALLY a reference, but non-intrinsic functions expect a reference: take address 215 226 … … 225 236 ) 226 237 arg = new AddressExpr( arg ); 238 // } else if ( function->get_linkage() == LinkageSpec::Intrinsic && InitTweak::getPointerBase( arg->result ) ) { 227 239 } else if ( function->get_linkage() == LinkageSpec::Intrinsic && arg->result->referenceDepth() != 0 ) { 228 240 // argument is a 'real' reference, but function expects a C lvalue: add a dereference to the reference-typed argument … … 234 246 PointerType * ptrType = new PointerType( Type::Qualifiers(), baseType->clone() ); 235 247 delete arg->result; 236 arg-> set_result( ptrType );248 arg->result = ptrType; 237 249 arg = mkDeref( arg ); 238 assertf( arg->result->referenceDepth() == 0, "Reference types should have been eliminated from intrinsic function calls, but weren't: %s", toCString( arg->result ) );250 // assertf( arg->result->referenceDepth() == 0, "Reference types should have been eliminated from intrinsic function calls, but weren't: %s", toCString( arg->result ) ); 239 251 } 240 252 } … … 413 425 for ( int i = 0; i < diff; ++i ) { 414 426 ret = mkDeref( ret ); 427 // xxx - try removing one reference here? actually, looks like mkDeref already does this, so more closely look at the types generated. 415 428 } 416 429 if ( ! ResolvExpr::typesCompatibleIgnoreQualifiers( destType->stripReferences(), srcType->stripReferences(), SymTab::Indexer() ) ) { -
src/InitTweak/InitTweak.cc
rc8ad5d9 rda7fe39 520 520 521 521 ApplicationExpr * createBitwiseAssignment( Expression * dst, Expression * src ) { 522 std::cerr << "=== createBitwiseAssignment ===" << std::endl; 523 std::cerr << "== dst: " << dst << std::endl; 524 std::cerr << "== src: " << src << std::endl; 525 522 526 static FunctionDecl * assign = nullptr; 523 527 if ( ! assign ) { … … 528 532 } 529 533 if ( dynamic_cast< ReferenceType * >( dst->result ) ) { 530 dst = new AddressExpr( dst ); 534 for (int depth = dst->result->referenceDepth(); depth > 0; depth--) { 535 dst = new AddressExpr( dst ); 536 } 531 537 } else { 532 538 dst = new CastExpr( dst, new ReferenceType( noQualifiers, dst->result->clone() ) ); 533 539 } 534 540 if ( dynamic_cast< ReferenceType * >( src->result ) ) { 535 src = new CastExpr( src, new ReferenceType( noQualifiers, src->result->stripReferences()->clone() ) ); 536 } 541 for (int depth = src->result->referenceDepth(); depth > 0; depth--) { 542 src = new AddressExpr( src ); 543 } 544 // src = new CastExpr( src, new ReferenceType( noQualifiers, src->result->stripReferences()->clone() ) ); 545 } 546 std::cerr << "============= endl : " << std::endl; 547 std::cerr << "-- dst: " << dst << std::endl; 548 std::cerr << "-- src: " << src << std::endl; 537 549 return new ApplicationExpr( VariableExpr::functionPointer( assign ), { dst, src } ); 538 550 } -
src/ResolvExpr/CommonType.cc
rc8ad5d9 rda7fe39 101 101 int diff = depth1-depth2; 102 102 // TODO: should it be possible for commonType to generate complicated conversions? I would argue no, only conversions that involve types of the same reference level or a difference of 1 should be allowed. 103 if ( diff > 1 || diff < -1 ) return nullptr;103 // if ( diff > 1 || diff < -1 ) return nullptr; 104 104 105 105 // special case where one type has a reference depth of 1 larger than the other
Note:
See TracChangeset
for help on using the changeset viewer.