Ignore:
Timestamp:
Nov 30, 2023, 6:14:20 PM (23 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
2f8d351
Parents:
7f2bfb7 (diff), c4570af3 (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 branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 moved

Legend:

Unmodified
Added
Removed
  • src/Tuples/TupleExpansion.cpp

    r7f2bfb7 r4dc3b8c  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // TupleExpansionNew.cpp --
     7// TupleExpansion.cpp --
    88//
    99// Author           : Henry Xue
     
    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
Note: See TracChangeset for help on using the changeset viewer.