Changeset 4520b77e for src/ResolvExpr


Ignore:
Timestamp:
Sep 20, 2022, 8:37:05 PM (3 years ago)
Author:
JiadaL <j82liang@…>
Branches:
ADT, ast-experimental, master, pthread-emulation
Children:
a065f1f
Parents:
d489da8 (diff), 12df6fe (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 to Master Sept 19

Location:
src/ResolvExpr
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/CandidateFinder.cpp

    rd489da8 r4520b77e  
    864864                }
    865865
     866                void postvisit( const ast::QualifiedNameExpr * qualifiedNameExpr ) {
     867                        auto mangleName = Mangle::mangle(qualifiedNameExpr->var);
     868                        addCandidate( qualifiedNameExpr, tenv );
     869                }
     870
    866871                void postvisit( const ast::UntypedExpr * untypedExpr ) {
    867872                        std::vector< CandidateFinder > argCandidates =
     
    897902                                                }
    898903
    899                                                 if (argType.as<ast::PointerType>()) funcFinder.otypeKeys.insert(Mangle::Encoding::pointer);
    900                                                 else if (const ast::EnumInstType * enumInst = argType.as<ast::EnumInstType>()) {
    901                                                         const ast::EnumDecl * enumDecl = enumInst->base;
    902                                                         if ( const ast::Type* enumType = enumDecl->base ) {
    903                                                                 // instance of enum (T) is a instance of type (T)
    904                                                                 funcFinder.otypeKeys.insert(Mangle::mangle(enumType, Mangle::NoGenericParams | Mangle::Type));
    905                                                         } else {
    906                                                                 // instance of an untyped enum is techically int
    907                                                                 funcFinder.otypeKeys.insert(Mangle::mangle(enumDecl, Mangle::NoGenericParams | Mangle::Type));
    908                                                         }
    909                                                 }
     904                                                if (argType.as<ast::PointerType>()) funcFinder.otypeKeys.insert(Mangle::Encoding::pointer);                                             
     905                                                // else if (const ast::EnumInstType * enumInst = argType.as<ast::EnumInstType>()) {
     906                                                //      const ast::EnumDecl * enumDecl = enumInst->base; // Here
     907                                                //      if ( const ast::Type* enumType = enumDecl->base ) {
     908                                                //              // instance of enum (T) is a instance of type (T)
     909                                                //              funcFinder.otypeKeys.insert(Mangle::mangle(enumType, Mangle::NoGenericParams | Mangle::Type));
     910                                                //      } else {
     911                                                //              // instance of an untyped enum is techically int
     912                                                //              funcFinder.otypeKeys.insert(Mangle::mangle(enumDecl, Mangle::NoGenericParams | Mangle::Type));
     913                                                //      }
     914                                                // }
    910915                                                else funcFinder.otypeKeys.insert(Mangle::mangle(argType, Mangle::NoGenericParams | Mangle::Type));
    911916                                        }
  • src/ResolvExpr/ConversionCost.cc

    rd489da8 r4520b77e  
    338338                } else if ( const EnumInstType * enumInst = dynamic_cast< const EnumInstType * >( dest ) ) {
    339339                        const EnumDecl * base_enum = enumInst->baseEnum;
    340                         if ( const Type * base = base_enum->base ) { // if the base enum has a base (if it is typed)
     340                        if ( const Type * base = base_enum->base ) {
    341341                                if ( const BasicType * enumBaseAstBasic = dynamic_cast< const BasicType *> (base) ) {
    342342                                        conversionCostFromBasicToBasic(basicType, enumBaseAstBasic);
     
    632632        } else if ( const ast::EnumInstType * enumInst = dynamic_cast< const ast::EnumInstType * >( dst ) ) {
    633633                const ast::EnumDecl * enumDecl = enumInst->base.get();
    634                 if ( const ast::Type * enumType = enumDecl->base.get() ) {
     634                if ( enumDecl->isTyped && !enumDecl->base.get() ) {
     635                        cost = Cost::infinity;
     636                } else if ( const ast::Type * enumType = enumDecl->base.get() ) {
    635637                        if ( const ast::BasicType * enumTypeAsBasic = dynamic_cast<const ast::BasicType *>(enumType) ) {
    636638                                conversionCostFromBasicToBasic( basicType, enumTypeAsBasic );
     
    694696        const ast::EnumDecl * baseEnum = enumInstType->base;
    695697        if ( const ast::Type * baseType = baseEnum->base ) {
    696                 cost = costCalc( baseType, dst, srcIsLvalue, symtab, env );
     698                costCalc( baseType, dst, srcIsLvalue, symtab, env );
    697699        } else {
    698700                (void)enumInstType;
  • src/ResolvExpr/Resolver.cc

    rd489da8 r4520b77e  
    14781478                        // enum type is still incomplete at this point. Use `int` instead.
    14791479
    1480                         if (dynamic_cast< const ast::EnumInstType * >( objectDecl->get_type() )->base->base) {
     1480                        if ( auto enumBase = dynamic_cast< const ast::EnumInstType * >
     1481                                ( objectDecl->get_type() )->base->base ) {
    14811482                                objectDecl = fixObjectType( objectDecl, context );
    1482                                 const ast::Type * enumBase =  (dynamic_cast< const ast::EnumInstType * >( objectDecl->get_type() )->base->base.get());
    14831483                                currentObject = ast::CurrentObject{
    14841484                                        objectDecl->location,
     
    14931493                }
    14941494                else {
    1495                         if (!objectDecl->isTypeFixed) {
     1495                        if ( !objectDecl->isTypeFixed ) {
    14961496                                auto newDecl = fixObjectType(objectDecl, context);
    14971497                                auto mutDecl = mutate(newDecl);
  • src/ResolvExpr/Unify.cc

    rd489da8 r4520b77e  
    165165                ast::Type * newFirst  = shallowCopy( first  );
    166166                ast::Type * newSecond = shallowCopy( second );
     167                if ( auto temp = dynamic_cast<const ast::EnumInstType *>(first) ) {
     168                        if ( !dynamic_cast< const ast::EnumInstType * >( second ) ) {
     169                                const ast::EnumDecl * baseEnum = dynamic_cast<const ast::EnumDecl *>(temp->base.get());
     170                                if ( auto t = baseEnum->base.get() ) {
     171                                        newFirst = ast::shallowCopy( t );
     172                                }
     173                        }
     174                } else if ( auto temp = dynamic_cast<const ast::EnumInstType *>(second) ) {
     175                        const ast::EnumDecl * baseEnum = dynamic_cast<const ast::EnumDecl *>(temp->base.get());
     176                        if ( auto t = baseEnum->base.get() ) {
     177                                newSecond = ast::shallowCopy( t );
     178                        }
     179                }
     180
    167181                newFirst ->qualifiers = {};
    168182                newSecond->qualifiers = {};
     
    9881002                                if ( isTuple && isTuple2 ) {
    9891003                                        ++it; ++jt;  // skip ttype parameters before break
    990                                 } else if ( isTuple ) {
     1004                                } else if ( isTuple ) { 
    9911005                                        // bundle remaining params into tuple
    9921006                                        pty2 = tupleFromExprs( param2, jt, params2.end(), pty->qualifiers );
Note: See TracChangeset for help on using the changeset viewer.