internal unsafe void PushToStack(int fieldIdx, StackObject *esp, ILIntepreter intp, IList <object> managedStack) { if (fieldIdx < fields.Length && fieldIdx >= 0) { PushToStackSub(ref fields[fieldIdx], fieldIdx, esp, managedStack, intp); } else { if (Type.FirstCLRBaseType != null && Type.FirstCLRBaseType is Enviorment.CrossBindingAdaptor) { CLRType clrType = intp.AppDomain.GetType(((Enviorment.CrossBindingAdaptor)Type.FirstCLRBaseType).BaseCLRType) as CLRType; var obj = clrType.GetFieldValue(fieldIdx, clrInstance); if (obj is CrossBindingAdaptorType) { obj = ((CrossBindingAdaptorType)obj).ILInstance; } //if(!clrType.CopyFieldToStack(fieldIdx, clrInstance,)) ILIntepreter.PushObject(esp, managedStack, obj); } else { throw new TypeLoadException(); } } }
internal unsafe void CopyToRegister(int fieldIdx, ref RegisterFrameInfo info, short reg) { if (fieldIdx < fields.Length && fieldIdx >= 0) { fixed(StackObject *ptr = fields) { info.Intepreter.CopyToRegister(ref info, reg, &ptr[fieldIdx], managedObjs); } } else { if (Type.FirstCLRBaseType != null && Type.FirstCLRBaseType is Enviorment.CrossBindingAdaptor) { CLRType clrType = info.Intepreter.AppDomain.GetType(((Enviorment.CrossBindingAdaptor)Type.FirstCLRBaseType).BaseCLRType) as CLRType; var obj = clrType.GetFieldValue(fieldIdx, clrInstance); if (obj is CrossBindingAdaptorType) { obj = ((CrossBindingAdaptorType)obj).ILInstance; } ILIntepreter.AssignToRegister(ref info, reg, obj); } else { throw new TypeLoadException(); } } }
internal unsafe void PushToStack(int fieldIdx, StackObject *esp, Enviorment.AppDomain appdomain, IList <object> managedStack) { if (fieldIdx < fields.Length && fieldIdx >= 0) { PushToStackSub(ref fields[fieldIdx], fieldIdx, esp, managedStack); } else { if (Type.FirstCLRBaseType != null && Type.FirstCLRBaseType is Enviorment.CrossBindingAdaptor) { CLRType clrType = appdomain.GetType(((Enviorment.CrossBindingAdaptor)Type.FirstCLRBaseType).BaseCLRType) as CLRType; ILIntepreter.PushObject(esp, managedStack, clrType.GetFieldValue(fieldIdx, clrInstance)); } else { throw new TypeLoadException(); } } }
public unsafe object this[int index] { get { if (index < fields.Length && index >= 0) { fixed(StackObject *ptr = fields) { StackObject *esp = &ptr[index]; return(StackObject.ToObject(esp, null, managedObjs)); } } else { if (Type.FirstCLRBaseType != null && Type.FirstCLRBaseType is Enviorment.CrossBindingAdaptor) { CLRType clrType = type.AppDomain.GetType(((Enviorment.CrossBindingAdaptor)Type.FirstCLRBaseType).BaseCLRType) as CLRType; return(clrType.GetFieldValue(index, clrInstance)); } else { throw new TypeLoadException(); } } } set { value = ILIntepreter.CheckAndCloneValueType(value, type.AppDomain); if (index < fields.Length && index >= 0) { fixed(StackObject *ptr = fields) { StackObject *esp = &ptr[index]; if (value != null) { var vt = value.GetType(); if (vt.IsPrimitive) { ILIntepreter.UnboxObject(esp, value, managedObjs, type.AppDomain); } else if (vt.IsEnum) { esp->ObjectType = ObjectTypes.Integer; esp->Value = value.ToInt32(); esp->ValueLow = 0; } else { esp->ObjectType = ObjectTypes.Object; esp->Value = index; managedObjs[index] = value; } } else { *esp = StackObject.Null; } } } else { if (Type.FirstCLRBaseType != null && Type.FirstCLRBaseType is Enviorment.CrossBindingAdaptor) { CLRType clrType = type.AppDomain.GetType(((Enviorment.CrossBindingAdaptor)Type.FirstCLRBaseType).BaseCLRType) as CLRType; clrType.SetFieldValue(index, ref clrInstance, value); } else { throw new TypeLoadException(); } } } }