public static void LoadVariable(mdr.DObject context, int fieldId, int ancestorDistance, ref Stack stack) { mdr.PropertyDescriptor pd = null; //TODO: If we do not create a prototype for GlobalContext, the following code would have been enough! //var pd = context.GetPropertyDescriptorByLineId(fieldId); //pd.Get(context, ref stack.Items[stack.Sp++]); if (ancestorDistance < 0) {//We are dealing with unknown symbol type while (context != mdr.Runtime.Instance.GlobalContext) { pd = context.Map.GetPropertyDescriptorByFieldId(fieldId); if (pd != null) { break; } context = context.Prototype; } } else {//we are dealing with known symbol type for (var i = 0; i < ancestorDistance && context != mdr.Runtime.Instance.GlobalContext; ++i) { context = context.Prototype; } } if (pd == null) { pd = context.GetPropertyDescriptorByFieldId(fieldId); } pd.Get(context, ref stack.Items[stack.Sp++]); }
public DForwardingProperty(DObject receiver, string field) { Receiver = receiver; ReceiverPD = Receiver.Map.GetPropertyDescriptor(field); Debug.Assert(ReceiverPD != null, "receiver field has null descriptor: " + field); OnGetDValue = (DObject This, ref DValue v) => { ReceiverPD.Get(Receiver, ref v); }; OnSetDValue = (DObject This, ref DValue v) => { ReceiverPD.Set(Receiver, ref v); }; }
public DForwardingProperty (DObject receiver, string field) { Receiver = receiver; ReceiverPD = Receiver.Map.GetPropertyDescriptor(field); Debug.Assert(ReceiverPD != null, "receiver field has null descriptor: " + field); OnGetDValue = (DObject This, ref DValue v) => { ReceiverPD.Get(Receiver, ref v); }; OnSetDValue = (DObject This, ref DValue v) => { ReceiverPD.Set(Receiver, ref v); }; }