Changeset 6009a5a


Ignore:
Timestamp:
Nov 30, 2023, 12:10:06 PM (5 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
83fd57d
Parents:
ab9c1b3
Message:

Combined the new and old TupleExpansion? files.

Location:
src/Tuples
Files:
1 deleted
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • src/Tuples/TupleExpansion.cpp

    rab9c1b3 r6009a5a  
    294294}
    295295
     296const ast::Type * makeTupleType( const std::vector<ast::ptr<ast::Expr>> & exprs ) {
     297        // If there are no expressions, the answer is set, otherwise go through a loop.
     298        if ( exprs.empty() ) return new ast::TupleType( {} );
     299
     300        std::vector<ast::ptr<ast::Type>> types;
     301        ast::CV::Qualifiers quals(
     302                ast::CV::Const | ast::CV::Volatile | ast::CV::Restrict |
     303                ast::CV::Atomic | ast::CV::Mutex );
     304
     305        for ( const ast::Expr * expr : exprs ) {
     306                assert( expr->result );
     307                // If the type of any expr is void, the type of the entire tuple is void.
     308                if ( expr->result->isVoid() ) return new ast::VoidType();
     309
     310                // Qualifiers on the tuple type are the qualifiers that exist on all components.
     311                quals &= expr->result->qualifiers;
     312
     313                types.emplace_back( expr->result );
     314        }
     315
     316        return new ast::TupleType( std::move( types ), quals );
     317}
     318
     319const ast::TypeInstType * isTtype( const ast::Type * type ) {
     320        if ( const ast::TypeInstType * inst = dynamic_cast< const ast::TypeInstType * >( type ) ) {
     321                if ( inst->base && inst->base->kind == ast::TypeDecl::Ttype ) {
     322                        return inst;
     323                }
     324        }
     325        return nullptr;
     326}
     327
    296328} // namespace Tuples
     329
  • src/Tuples/module.mk

    rab9c1b3 r6009a5a  
    1919        Tuples/Explode.h \
    2020        Tuples/TupleAssignment.cc \
    21         Tuples/TupleExpansion.cc \
    22         Tuples/TupleExpansionNew.cpp \
     21        Tuples/TupleExpansion.cpp \
    2322        Tuples/Tuples.cc \
    2423        Tuples/Tuples.h
Note: See TracChangeset for help on using the changeset viewer.