private static object doTrap(object self, string name, List args, Type type) { Slot slot = type.slot(name, true); if (slot is Method) { Method m = (Method)slot; return(m.m_func.callOn(self, args)); } else { Field f = (Field)slot; int argSize = (args == null) ? 0 : args.sz(); if (argSize == 0) { return(FanUtil.box(f.get(self))); } if (argSize == 1) { object val = args.get(0); f.set(self, val); return(FanUtil.box(val)); } throw ArgErr.make("Invalid number of args to get or set field '" + name + "'").val; } }
public override Object call(Object obj) { IDictionaryEnumerator en = m_map.pairsIterator(); while (en.MoveNext()) { Field field = (Field)en.Key; object val = en.Value; field.set(obj, val, obj != m_inCtor); } return(null); }
void complexSet(object obj, Field field, object val, int line) { try { if (field.isConst()) field.set(obj, OpUtil.toImmutable(val), false); else field.set(obj, val); } catch (System.Exception ex) { throw err("Cannot set field " + field.qname() + ": " + ex, line, ex); } }