internal virtual void SetObject(TargetMemoryAccess target, TargetLocation location,
TargetObject obj)
{
if (obj == null) {
if (IsByRef) {
location.WriteAddress (target, TargetAddress.Null);
return;
}
throw new InvalidOperationException ();
}
if (IsByRef) {
if (obj.Type.IsByRef) {
location.WriteAddress (target, obj.Location.GetAddress (target));
return;
}
throw new InvalidOperationException ();
}
if (!HasFixedSize || !obj.Type.HasFixedSize)
throw new InvalidOperationException ();
if (Size != obj.Type.Size)
throw new InvalidOperationException ();
byte[] contents = obj.Location.ReadBuffer (target, obj.Type.Size);
location.WriteBuffer (target, contents);
}