Changeset 2a6c115 for src


Ignore:
Timestamp:
Jun 6, 2018, 4:54:59 PM (6 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, with_gc
Children:
0f79853
Parents:
630bcb5
Message:

Simplify tuple index resolution

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AlternativeFinder.cc

    r630bcb5 r2a6c115  
    345345                if ( ConstantExpr * constantExpr = dynamic_cast< ConstantExpr * >( member ) ) {
    346346                        // get the value of the constant expression as an int, must be between 0 and the length of the tuple type to have meaning
    347                         // xxx - this should be improved by memoizing the value of constant exprs
    348                         // during parsing and reusing that information here.
    349                         std::stringstream ss( constantExpr->get_constant()->get_value() );
    350                         int val = 0;
     347                        auto val = constantExpr->intValue();
    351348                        std::string tmp;
    352                         if ( ss >> val && ! (ss >> tmp) ) {
    353                                 if ( val >= 0 && (unsigned int)val < tupleType->size() ) {
    354                                         alternatives.push_back( Alternative( new TupleIndexExpr( expr->clone(), val ), env, newCost ) );
    355                                 } // if
     349                        if ( val >= 0 && (unsigned long long)val < tupleType->size() ) {
     350                                alternatives.push_back( Alternative( new TupleIndexExpr( expr->clone(), val ), env, newCost ) );
    356351                        } // if
    357                 } else if ( NameExpr * nameExpr = dynamic_cast< NameExpr * >( member ) ) {
    358                         // xxx - temporary hack until 0/1 are int constants
    359                         if ( nameExpr->get_name() == "0" || nameExpr->get_name() == "1" ) {
    360                                 std::stringstream ss( nameExpr->get_name() );
    361                                 int val;
    362                                 ss >> val;
    363                                 alternatives.push_back( Alternative( new TupleIndexExpr( expr->clone(), val ), env, newCost ) );
    364                         }
    365352                } // if
    366353        }
Note: See TracChangeset for help on using the changeset viewer.