Changeset b21c77a for src/GenPoly


Ignore:
Timestamp:
Jun 29, 2018, 4:14:15 PM (6 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
new-env
Children:
184557e
Parents:
97397a26 (diff), 28f3a19 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge remote-tracking branch 'origin/with_gc' into new-env

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Lvalue.cc

    r97397a26 rb21c77a  
    145145
    146146        namespace {
    147                 // true for intrinsic function calls that return a reference
     147                // true for intrinsic function calls that return an lvalue in C
    148148                bool isIntrinsicReference( Expression * expr ) {
     149                        // known intrinsic-reference prelude functions
     150                        static std::set<std::string> lvalueFunctions = { "*?", "?[?]" };
    149151                        if ( UntypedExpr * untyped = dynamic_cast< UntypedExpr * >( expr ) ) {
    150152                                std::string fname = InitTweak::getFunctionName( untyped );
    151                                 // known intrinsic-reference prelude functions
    152                                 return fname == "*?" || fname == "?[?]";
     153                                return lvalueFunctions.count(fname);
    153154                        } else if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * > ( expr ) ) {
    154155                                if ( DeclarationWithType * func = InitTweak::getFunction( appExpr ) ) {
    155                                         // use type of return variable rather than expr result type, since it may have been changed to a pointer type
    156                                         FunctionType * ftype = GenPoly::getFunctionType( func->get_type() );
    157                                         Type * ret = ftype->returnVals.empty() ? nullptr : ftype->returnVals.front()->get_type();
    158                                         return func->linkage == LinkageSpec::Intrinsic && dynamic_cast<ReferenceType *>( ret );
     156                                        return func->linkage == LinkageSpec::Intrinsic && lvalueFunctions.count(func->name);
    159157                                }
    160158                        }
     
    210208                                                // TODO: it's likely that the second condition should be ... && ! isIntrinsicReference( arg ), but this requires investigation.
    211209
    212                                                 if ( function->get_linkage() != LinkageSpec::Intrinsic && isIntrinsicReference( arg ) ) {
     210                                                if ( function->linkage != LinkageSpec::Intrinsic && isIntrinsicReference( arg ) ) {
    213211                                                        // needed for definition of prelude functions, etc.
    214212                                                        // if argument is dereference or array subscript, the result isn't REALLY a reference, but non-intrinsic functions expect a reference: take address
     
    226224                                                        arg = new AddressExpr( arg );
    227225                                                // } else if ( function->get_linkage() == LinkageSpec::Intrinsic && InitTweak::getPointerBase( arg->result ) ) {
    228                                                 } else if ( function->get_linkage() == LinkageSpec::Intrinsic && arg->result->referenceDepth() != 0 ) {
     226                                                } else if ( function->linkage == LinkageSpec::Intrinsic && arg->result->referenceDepth() != 0 ) {
    229227                                                        // argument is a 'real' reference, but function expects a C lvalue: add a dereference to the reference-typed argument
    230228                                                        PRINT(
Note: See TracChangeset for help on using the changeset viewer.