public static object RefIncrDecr(Ref @ref, Context cx, int incrDecrMask) { object value = @ref.Get(cx); bool post = ((incrDecrMask & Node.POST_FLAG) != 0); double number; if (value is Number) { number = System.Convert.ToDouble(((Number)value)); } else { number = ToNumber(value); if (post) { // convert result to number value = WrapNumber(number); } } if ((incrDecrMask & Node.DECR_FLAG) == 0) { ++number; } else { --number; } Number result = WrapNumber(number); @ref.Set(cx, result); if (post) { return value; } else { return result; } }
public static object RefSet(Ref @ref, object value, Context cx) { return @ref.Set(cx, value); }