Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Tuples/TupleExpansion.cc

    r77bfc80 r3ca912a  
    320320        }
    321321        const ast::Type * makeTupleType( const std::vector<ast::ptr<ast::Expr>> & exprs ) {
    322                 (void) exprs;
    323                 #warning Not implemented; needs Type.cpp in build
    324                 assertf(false, "Not implemented; needs Type.cpp in build");
    325                 // // produce the TupleType which aggregates the types of the exprs
    326                 // std::vector<ast::ptr<ast::Type>> types;
    327                 // ast::CV::Qualifiers quals{
    328                 //      ast::CV::Const | ast::CV::Volatile | ast::CV::Restrict | ast::CV::Lvalue |
    329                 //      ast::CV::Atomic | ast::CV::Mutex };
    330 
    331                 // for ( const ast::Expr * expr : exprs ) {
    332                 //      assert( expr->result );
    333                 //      // if the type of any expr is void, the type of the entire tuple is void
    334                 //      if ( expr->result->isVoid() ) return new ast::VoidType{};
    335 
    336                 //      // qualifiers on the tuple type are the qualifiers that exist on all components
    337                 //      quals &= expr->result->qualifiers;
    338 
    339                 //      types.emplace_back( expr->result );
    340                 // }
    341 
    342                 // if ( exprs.empty() ) { quals = ast::CV::Qualifiers{}; }
    343                 // return new ast::TupleType{ std::move(types), quals };
     322                // produce the TupleType which aggregates the types of the exprs
     323                std::vector<ast::ptr<ast::Type>> types;
     324                ast::CV::Qualifiers quals{
     325                        ast::CV::Const | ast::CV::Volatile | ast::CV::Restrict | ast::CV::Lvalue |
     326                        ast::CV::Atomic | ast::CV::Mutex };
     327
     328                for ( const ast::Expr * expr : exprs ) {
     329                        assert( expr->result );
     330                        // if the type of any expr is void, the type of the entire tuple is void
     331                        if ( expr->result->isVoid() ) return new ast::VoidType{};
     332
     333                        // qualifiers on the tuple type are the qualifiers that exist on all components
     334                        quals &= expr->result->qualifiers;
     335
     336                        types.emplace_back( expr->result );
     337                }
     338
     339                if ( exprs.empty() ) { quals = ast::CV::Qualifiers{}; }
     340                return new ast::TupleType{ std::move(types), quals };
    344341        }
    345342
     
    347344                if ( TypeInstType * inst = dynamic_cast< TypeInstType * >( type ) ) {
    348345                        if ( inst->get_baseType() && inst->get_baseType()->get_kind() == TypeDecl::Ttype ) {
     346                                return inst;
     347                        }
     348                }
     349                return nullptr;
     350        }
     351
     352        const ast::TypeInstType * isTtype( const ast::Type * type ) {
     353                if ( const ast::TypeInstType * inst = dynamic_cast< const ast::TypeInstType * >( type ) ) {
     354                        if ( inst->base && inst->base->kind == ast::TypeVar::Ttype ) {
    349355                                return inst;
    350356                        }
Note: See TracChangeset for help on using the changeset viewer.