Changeset 4520b77e for src/ResolvExpr
- Timestamp:
- Sep 20, 2022, 8:37:05 PM (3 years ago)
- 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. - Location:
- src/ResolvExpr
- Files:
-
- 4 edited
-
CandidateFinder.cpp (modified) (2 diffs)
-
ConversionCost.cc (modified) (3 diffs)
-
Resolver.cc (modified) (2 diffs)
-
Unify.cc (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/CandidateFinder.cpp
rd489da8 r4520b77e 864 864 } 865 865 866 void postvisit( const ast::QualifiedNameExpr * qualifiedNameExpr ) { 867 auto mangleName = Mangle::mangle(qualifiedNameExpr->var); 868 addCandidate( qualifiedNameExpr, tenv ); 869 } 870 866 871 void postvisit( const ast::UntypedExpr * untypedExpr ) { 867 872 std::vector< CandidateFinder > argCandidates = … … 897 902 } 898 903 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 int907 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 // } 910 915 else funcFinder.otypeKeys.insert(Mangle::mangle(argType, Mangle::NoGenericParams | Mangle::Type)); 911 916 } -
src/ResolvExpr/ConversionCost.cc
rd489da8 r4520b77e 338 338 } else if ( const EnumInstType * enumInst = dynamic_cast< const EnumInstType * >( dest ) ) { 339 339 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 ) { 341 341 if ( const BasicType * enumBaseAstBasic = dynamic_cast< const BasicType *> (base) ) { 342 342 conversionCostFromBasicToBasic(basicType, enumBaseAstBasic); … … 632 632 } else if ( const ast::EnumInstType * enumInst = dynamic_cast< const ast::EnumInstType * >( dst ) ) { 633 633 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() ) { 635 637 if ( const ast::BasicType * enumTypeAsBasic = dynamic_cast<const ast::BasicType *>(enumType) ) { 636 638 conversionCostFromBasicToBasic( basicType, enumTypeAsBasic ); … … 694 696 const ast::EnumDecl * baseEnum = enumInstType->base; 695 697 if ( const ast::Type * baseType = baseEnum->base ) { 696 cost = costCalc( baseType, dst, srcIsLvalue, symtab, env );698 costCalc( baseType, dst, srcIsLvalue, symtab, env ); 697 699 } else { 698 700 (void)enumInstType; -
src/ResolvExpr/Resolver.cc
rd489da8 r4520b77e 1478 1478 // enum type is still incomplete at this point. Use `int` instead. 1479 1479 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 ) { 1481 1482 objectDecl = fixObjectType( objectDecl, context ); 1482 const ast::Type * enumBase = (dynamic_cast< const ast::EnumInstType * >( objectDecl->get_type() )->base->base.get());1483 1483 currentObject = ast::CurrentObject{ 1484 1484 objectDecl->location, … … 1493 1493 } 1494 1494 else { 1495 if ( !objectDecl->isTypeFixed) {1495 if ( !objectDecl->isTypeFixed ) { 1496 1496 auto newDecl = fixObjectType(objectDecl, context); 1497 1497 auto mutDecl = mutate(newDecl); -
src/ResolvExpr/Unify.cc
rd489da8 r4520b77e 165 165 ast::Type * newFirst = shallowCopy( first ); 166 166 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 167 181 newFirst ->qualifiers = {}; 168 182 newSecond->qualifiers = {}; … … 988 1002 if ( isTuple && isTuple2 ) { 989 1003 ++it; ++jt; // skip ttype parameters before break 990 } else if ( isTuple ) { 1004 } else if ( isTuple ) { 991 1005 // bundle remaining params into tuple 992 1006 pty2 = tupleFromExprs( param2, jt, params2.end(), pty->qualifiers );
Note:
See TracChangeset
for help on using the changeset viewer.