Exemplo n.º 1
0
        internal DbgDotNetValue CreateDotNetValue_MonoDebug(DmdAppDomain reflectionAppDomain, Value value, DmdType realTypeOpt)
        {
            debuggerThread.VerifyAccess();
            if (value == null)
            {
                return(new SyntheticNullValue(realTypeOpt ?? reflectionAppDomain.System_Object));
            }
            DmdType type;

            if (value is PrimitiveValue pv)
            {
                type = MonoValueTypeCreator.CreateType(this, value, reflectionAppDomain.System_Object);
            }
            else if (value is StructMirror sm)
            {
                type = GetReflectionType(reflectionAppDomain, sm.Type, realTypeOpt);
            }
            else
            {
                Debug.Assert(value is ObjectMirror);
                type = GetReflectionType(reflectionAppDomain, ((ObjectMirror)value).Type, realTypeOpt);
            }
            var valueLocation = new NoValueLocation(type, value);

            return(CreateDotNetValue_MonoDebug(valueLocation));
        }
Exemplo n.º 2
0
        public override DbgDotNetValue?CreateInstance(DmdConstructorInfo ctor, object?[] arguments)
        {
            var           appDomain = ctor.AppDomain;
            var           ps        = ctor.GetMethodSignature().GetParameterTypes();
            ValueLocation valueLocation;

            switch (ps.Count)
            {
            case 1:
                // String(char* value)
                if (ps[0].IsPointer && ps[0].GetElementType() == appDomain.System_Char)
                {
                    //TODO:
                    break;
                }
                // String(sbyte* value)
                if (ps[0].IsPointer && ps[0].GetElementType() == appDomain.System_SByte)
                {
                    //TODO:
                    break;
                }
                // String(char[] value)
                if (ps[0].IsSZArray && ps[0].GetElementType() == appDomain.System_Char)
                {
                    var value = runtime.ValueConverter.ToCharArray(arguments[0]);
                    var s     = new string(value);
                    valueLocation = new NoValueLocation(appDomain.System_String, MonoValueFactory.TryCreateSyntheticValue(engine, GetMonoAppDomain(ctor), appDomain.System_String, s));
                    return(engine.CreateDotNetValue_MonoDebug(valueLocation));
                }
                break;

            case 2:
                // String(char c, int count)
                if (ps[0] == appDomain.System_Char && ps[1] == appDomain.System_Int32)
                {
                    char c     = runtime.ValueConverter.ToChar(arguments[0]);
                    int  count = runtime.ValueConverter.ToInt32(arguments[1]);
                    var  s     = new string(c, count);
                    valueLocation = new NoValueLocation(appDomain.System_String, MonoValueFactory.TryCreateSyntheticValue(engine, GetMonoAppDomain(ctor), appDomain.System_String, s));
                    return(engine.CreateDotNetValue_MonoDebug(valueLocation));
                }
                break;

            case 3:
                // String(char* value, int startIndex, int length)
                if (ps[0].IsPointer && ps[0].GetElementType() == appDomain.System_Char && ps[1] == appDomain.System_Int32 && ps[2] == appDomain.System_Int32)
                {
                    //TODO:
                    break;
                }
                // String(sbyte* value, int startIndex, int length)
                if (ps[0].IsPointer && ps[0].GetElementType() == appDomain.System_SByte && ps[1] == appDomain.System_Int32 && ps[2] == appDomain.System_Int32)
                {
                    //TODO:
                    break;
                }
                // String(char[] value, int startIndex, int length)
                if (ps[0].IsSZArray && ps[0].GetElementType() == appDomain.System_Char && ps[1] == appDomain.System_Int32 && ps[2] == appDomain.System_Int32)
                {
                    var value      = runtime.ValueConverter.ToCharArray(arguments[0]);
                    int startIndex = runtime.ValueConverter.ToInt32(arguments[1]);
                    int length     = runtime.ValueConverter.ToInt32(arguments[2]);
                    var s          = new string(value, startIndex, length);
                    valueLocation = new NoValueLocation(appDomain.System_String, MonoValueFactory.TryCreateSyntheticValue(engine, GetMonoAppDomain(ctor), appDomain.System_String, s));
                    return(engine.CreateDotNetValue_MonoDebug(valueLocation));
                }
                break;

            case 4:
                // String(sbyte* value, int startIndex, int length, Encoding enc)
                if (ps[0].IsPointer && ps[0].GetElementType() == appDomain.System_SByte && ps[1] == appDomain.System_Int32 &&
                    ps[2] == appDomain.System_Int32 && ps[3] == appDomain.GetWellKnownType(DmdWellKnownType.System_Text_Encoding, isOptional: true))
                {
                    //TODO:
                    break;
                }
                break;
            }

            return(null);
        }