compiler/resolution/lowerIterators.cpp
// fix GET_MEMBER primitives that access fields of an iterator class
// via a number
fix GET_MEMBER primitives that access fields of an iterator class
via a number
fix GET_MEMBER primitives that access fields of an iterator class via a number
forv_Vec(CallExpr, call, gCallExprs) {
    if (call->inTree() && call->isPrimitive(PRIM_GET_MEMBER)) {
      AggregateType* ct = toAggregateType(call->get(1)->getValType());
      int64_t num;
      if (get_int(call->get(2), &num)) {
        Symbol* field = ct->getField(num+1); 
        SET_LINENO(call);
        call->get(2)->replace(new SymExpr(field));
        CallExpr* parent = toCallExpr(call->parentExpr);
        INT_ASSERT(parent->isPrimitive(PRIM_MOVE));
        Symbol* local = toSymExpr(parent->get(1))->symbol();
        if (local->type == field->type)
          call->primitive = primitives[PRIM_GET_MEMBER_VALUE];
        else if (local->type != field->type->refType)
          INT_FATAL(call, "unexpected case");
      }
    }
  }
forv_Vec ( CallExpr , call , gCallExprs ) { if ( call -> inTree ( ) && call -> isPrimitive ( PRIM_GET_MEMBER ) ) { AggregateType * ct = toAggregateType ( call -> get ( 1 ) -> getValType ( ) ) ; int64_t num ; if ( get_int ( call -> get ( 2 ) , & num ) ) { Symbol * field = ct -> getField ( num + 1 ) ; SET_LINENO ( call ) ; call -> get ( 2 ) -> replace ( new SymExpr ( field ) ) ; CallExpr * parent = toCallExpr ( call -> parentExpr ) ; INT_ASSERT ( parent -> isPrimitive ( PRIM_MOVE ) ) ; Symbol * local = toSymExpr ( parent -> get ( 1 ) ) -> symbol ( ) ; if ( local -> type == field -> type ) call -> primitive = primitives [ PRIM_GET_MEMBER_VALUE ] ; else if ( local -> type != field -> type -> refType ) INT_FATAL ( call , " " ) ; } } }
fix GET_MEMBER primitives that access fields of an iterator class
via a number
fix GET_MEMBER primitives that access fields of an iterator class via a number
// add 1 for super