Changes in / [c8ad5d9:da7fe39]


Ignore:
Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Lvalue.cc

    rc8ad5d9 rda7fe39  
    1717#include <string>                        // for string
    1818
     19#include "Common/Debug.h"
    1920#include "Common/PassVisitor.h"
    2021#include "GenPoly.h"                     // for isPolyType
     
    128129                PassVisitor<AddrRef> addrRef;
    129130                PassVisitor<FixIntrinsicResult> intrinsicResults;
     131                Debug::codeGen( translationUnit, "begin" );
    130132                mutateAll( translationUnit, intrinsicResults );
     133                Debug::codeGen( translationUnit, "intrinsicResults" );
    131134                mutateAll( translationUnit, addrRef );
     135                Debug::codeGen( translationUnit, "addrRef" );
    132136                mutateAll( translationUnit, refCvt );
     137                Debug::codeGen( translationUnit, "refCvt" );
    133138                mutateAll( translationUnit, fixer );
     139                Debug::codeGen( translationUnit, "fixer" );
    134140                mutateAll( translationUnit, collapser );
     141                Debug::codeGen( translationUnit, "collapser" );
    135142                mutateAll( translationUnit, genLval );
     143                Debug::codeGen( translationUnit, "genLval" );
    136144                mutateAll( translationUnit, elim );  // last because other passes need reference types to work
     145                Debug::codeGen( translationUnit, "elim" );
    137146
    138147                // from this point forward, no other pass should create reference types.
     
    211220                                                )
    212221                                                // TODO: it's likely that the second condition should be ... && ! isIntrinsicReference( arg ), but this requires investigation.
     222
    213223                                                if ( function->get_linkage() != LinkageSpec::Intrinsic && isIntrinsicReference( arg ) ) {
     224                                                        // needed for definition of prelude functions, etc.
    214225                                                        // if argument is dereference or array subscript, the result isn't REALLY a reference, but non-intrinsic functions expect a reference: take address
    215226
     
    225236                                                        )
    226237                                                        arg = new AddressExpr( arg );
     238                                                // } else if ( function->get_linkage() == LinkageSpec::Intrinsic && InitTweak::getPointerBase( arg->result ) ) {
    227239                                                } else if ( function->get_linkage() == LinkageSpec::Intrinsic && arg->result->referenceDepth() != 0 ) {
    228240                                                        // argument is a 'real' reference, but function expects a C lvalue: add a dereference to the reference-typed argument
     
    234246                                                        PointerType * ptrType = new PointerType( Type::Qualifiers(), baseType->clone() );
    235247                                                        delete arg->result;
    236                                                         arg->set_result( ptrType );
     248                                                        arg->result = ptrType;
    237249                                                        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 ) );
    239251                                                }
    240252                                        }
     
    413425                                for ( int i = 0; i < diff; ++i ) {
    414426                                        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.
    415428                                }
    416429                                if ( ! ResolvExpr::typesCompatibleIgnoreQualifiers( destType->stripReferences(), srcType->stripReferences(), SymTab::Indexer() ) ) {
  • src/InitTweak/InitTweak.cc

    rc8ad5d9 rda7fe39  
    520520
    521521        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
    522526                static FunctionDecl * assign = nullptr;
    523527                if ( ! assign ) {
     
    528532                }
    529533                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                        }
    531537                } else {
    532538                        dst = new CastExpr( dst, new ReferenceType( noQualifiers, dst->result->clone() ) );
    533539                }
    534540                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;
    537549                return new ApplicationExpr( VariableExpr::functionPointer( assign ), { dst, src } );
    538550        }
  • src/ResolvExpr/CommonType.cc

    rc8ad5d9 rda7fe39  
    101101                        int diff = depth1-depth2;
    102102                        // 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;
    104104
    105105                        // 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.