Changeset 6d267ca


Ignore:
Timestamp:
Jul 25, 2017, 10:41:24 AM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
d335627
Parents:
9191a8e
Message:

Add unsafe_group_iterate

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Common/utility.h

    r9191a8e r6d267ca  
    310310template< typename T1, typename T2 >
    311311struct group_iterate_t {
    312         group_iterate_t( const T1 & v1, const T2 & v2 ) : args(v1, v2) {
    313                 assertf(v1.size() == v2.size(), "group iteration requires containers of the same size.");
     312        group_iterate_t( bool skipBoundsCheck, const T1 & v1, const T2 & v2 ) : args(v1, v2) {
     313                assertf(skipBoundsCheck || v1.size() == v2.size(), "group iteration requires containers of the same size: <%u, %u>.", v1.size(), v2.size());
    314314        };
    315315
     
    336336};
    337337
     338/// performs bounds check to ensure that all arguments are of the same length.
    338339template< typename... Args >
    339340group_iterate_t<Args...> group_iterate( Args &&... args ) {
    340         return group_iterate_t<Args...>(std::forward<Args>( args )...);
     341        return group_iterate_t<Args...>(false, std::forward<Args>( args )...);
     342}
     343
     344/// does not perform a bounds check - requires user to ensure that iteration terminates when appropriate.
     345template< typename... Args >
     346group_iterate_t<Args...> unsafe_group_iterate( Args &&... args ) {
     347        return group_iterate_t<Args...>(true, std::forward<Args>( args )...);
    341348}
    342349
  • src/Tuples/Explode.h

    r9191a8e r6d267ca  
    3030        template< typename OutputIterator >
    3131        void explodeUnique( Expression * expr, const ResolvExpr::Alternative & alt, const SymTab::Indexer & indexer, OutputIterator out, bool isTupleAssign ) {
    32                 Type * res = expr->get_result();
     32                Type * res = expr->get_result()->stripReferences();
    3333                if ( TupleType * tupleType = dynamic_cast< TupleType * > ( res ) ) {
    3434                        if ( TupleExpr * tupleExpr = dynamic_cast< TupleExpr * >( expr ) ) {
     
    3838                                }
    3939                        } else {
    40                                 // tuple type, but not tuple expr - recursively index into its components
     40                                // tuple type, but not tuple expr - recursively index into its components.
     41                                // if expr type is reference, convert to value type
    4142                                Expression * arg = expr->clone();
     43
     44                                if ( dynamic_cast<ReferenceType *>( arg->get_result() ) ) {
     45                                        // TODO: does this go here (inside uniqueexpr) or outside uniqueexpr? I'm guessing probably should go after...
     46                                        arg = new CastExpr( arg, tupleType->clone() );
     47                                }
    4248                                if ( Tuples::maybeImpure( arg ) && ! dynamic_cast< UniqueExpr * >( arg ) ) {
    4349                                        // expressions which may contain side effects require a single unique instance of the expression.
Note: See TracChangeset for help on using the changeset viewer.