1 Reply Latest reply on Nov 5, 2003 9:37 PM by chiba

    Array FieldAccess

    georgewinters

      I would like to intercept accesses to a class's data members and alter the result of the read or write. I've been able to get it to work OK for native types but have been less successful with arrays of native types.

      I have extended ExprEditor and in the edit method that takes a FieldAccess as a parameter I call its replace method to alter the field access. For example, when a field (say called numItems) of type int is read I can replace it with "$_ = numItems + 1;". This works just fine. Instead of the code getting the value of numItems it gets numItems+1.

      I have a problem, however, when attempting a similar alteration to a read of an array of ints. So, for example, if the class being altered is accessing an array of ints called items I would like to replace that access with something like "$_ = items[4] + 1;". Unfortunately this doesn't work *and* it doesn't generate a CannotCompileException.

      Is there a way to accomplish this?

      Michael