/* Performs storing to array element * (corresponds to CILPE.CFG.StoreElement class) */ public void Perform_StoreElement(Type type, out Exception exc) { Value objVal = Pop(); int index = popArrayIndex(); Array array = popArray(out exc); Type elementType = array.GetType().GetElementType(); if (exc == null) { objVal = objVal.FromStack(elementType); object val = null; if (objVal is StructValue && (objVal as StructValue).IsPrimitive) { val = (objVal as StructValue).Obj; } else if (objVal is NullValue) { val = null; } else if (objVal is ObjectReferenceValue) { val = (objVal as ObjectReferenceValue).Obj; } else { throw new InvalidOperandException(); } if (type != typeof(object) && TypeFixer.WeakFixType(elementType) != TypeFixer.WeakFixType(type)) //Andrew! { exc = new ArrayTypeMismatchException(); } else if (type == typeof(object) && !elementType.IsAssignableFrom(val.GetType())) { exc = new InvalidCastException(); } else { try { array.SetValue(val, index); } catch (IndexOutOfRangeException e) { exc = e; } } } }
public override void SetReferencedValue(Value val) { Type t = obj.GetType(); StructValue structVal = val.FromStack(t) as StructValue; if (structVal.IsPrimitive) { DataModelUtils.StoreToBox(obj, (int)(StructValue.getTypeIndex(t)), structVal.Obj); } else { FieldInfo[] fields = obj.GetType().GetFields((BindingFlags) (BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) ); foreach (FieldInfo field in fields) { field.SetValue(obj, field.GetValue(structVal.Obj)); } } }
public override void SetReferencedValue(Value val) { val = val.FromStack(type); object valObj = null; if (val is StructValue) { valObj = (val as StructValue).Obj; } else if (val is ObjectReferenceValue) { valObj = (val as ObjectReferenceValue).Obj; } else if (val is NullValue) { valObj = null; } arr.SetValue(valObj, index); }
public override void SetReferencedValue(Value val) { val = val.FromStack(field.FieldType); object valObj = null; if (val is StructValue) { valObj = (val as StructValue).Obj; } else if (val is ObjectReferenceValue) { valObj = (val as ObjectReferenceValue).Obj; } else if (val is NullValue) { valObj = null; } field.SetValue(obj, valObj); }
public override void SetReferencedValue(Value val) { Type t = obj.GetType(); StructValue structVal = val.FromStack(t) as StructValue; if (structVal.IsPrimitive) DataModelUtils.StoreToBox(obj,(int)(StructValue.getTypeIndex(t)),structVal.Obj); else { FieldInfo[] fields = obj.GetType().GetFields((BindingFlags) (BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) ); foreach (FieldInfo field in fields) field.SetValue(obj,field.GetValue(structVal.Obj)); } }
public override void SetReferencedValue(Value val) { object obj = ptr.GetReferencedObject(); val = val.FromStack(field.FieldType); object valObj = null; if (val is StructValue) valObj = (val as StructValue).Obj; else if (val is ObjectReferenceValue) valObj = (val as ObjectReferenceValue).Obj; else if (val is NullValue) valObj = null; field.SetValue(obj,valObj); ptr.SetReferencedValue(new StructValue(obj as ValueType)); }
public override void SetReferencedValue(Value val) { val = val.FromStack(type); object valObj = null; if (val is StructValue) valObj = (val as StructValue).Obj; else if (val is ObjectReferenceValue) valObj = (val as ObjectReferenceValue).Obj; else if (val is NullValue) valObj = null; arr.SetValue(valObj,index); }