Changeset 848ce71 for src/ResolvExpr
- Timestamp:
- Oct 13, 2016, 2:46:36 PM (8 years ago)
- 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:
- bf32bb8
- Parents:
- 7756647
- Location:
- src/ResolvExpr
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/AlternativeFinder.cc
r7756647 r848ce71 229 229 assertf( false, "reached unexpected case of addAggMembers" ); 230 230 } 231 } 232 233 void AlternativeFinder::addTupleMembers( TupleType * tupleType, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member ) { 234 if ( ConstantExpr * constantExpr = dynamic_cast< ConstantExpr * >( member ) ) { 235 // get the value of the constant expression as an int, must be between 0 and the length of the tuple type to have meaning 236 // xxx - this should be improved by memoizing the value of constant exprs 237 // during parsing and reusing that information here. 238 std::stringstream ss( constantExpr->get_constant()->get_value() ); 239 int val; 240 std::string tmp; 241 if ( ss >> val && ! (ss >> tmp) ) { 242 if ( val >= 0 && (unsigned int)val < tupleType->size() ) { 243 alternatives.push_back( Alternative( new TupleIndexExpr( expr->clone(), val ), env, newCost ) ); 244 } // if 245 } // if 246 } // if 231 247 } 232 248 … … 785 801 } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( agg->expr->get_result() ) ) { 786 802 addAggMembers( unionInst, agg->expr, agg->cost, agg->env, memberExpr->get_member() ); 803 } else if ( TupleType * tupleType = dynamic_cast< TupleType * >( agg->expr->get_result() ) ) { 804 addTupleMembers( tupleType, agg->expr, agg->cost, agg->env, memberExpr->get_member() ); 787 805 } // if 788 806 } // for -
src/ResolvExpr/AlternativeFinder.h
r7756647 r848ce71 76 76 /// Adds alternatives for member expressions, given the aggregate, conversion cost for that aggregate, and name of the member 77 77 template< typename StructOrUnionType > void addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member ); 78 /// Adds alternatives for member expressions where the left side has tuple type 79 void addTupleMembers( TupleType * tupleType, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member ); 78 80 /// Adds alternatives for offsetof expressions, given the base type and name of the member 79 81 template< typename StructOrUnionType > void addOffsetof( StructOrUnionType *aggInst, const std::string &name );
Note: See TracChangeset
for help on using the changeset viewer.