private EvaluatedExpression FindClass(string signature)
        {
            Contract.Requires <ArgumentNullException>(signature != null, "signature");
            Contract.Requires <ArgumentException>(!string.IsNullOrEmpty(signature));
            Contract.Ensures(Contract.Result <EvaluatedExpression>() != null);

            switch (signature[0])
            {
            case 'Z':
                return(GetField(GetReflectedType(FindClass("Ljava/lang/Boolean;")), "TYPE"));

            case 'B':
                return(GetField(GetReflectedType(FindClass("Ljava/lang/Byte;")), "TYPE"));

            case 'C':
                return(GetField(GetReflectedType(FindClass("Ljava/lang/Character;")), "TYPE"));

            case 'D':
                return(GetField(GetReflectedType(FindClass("Ljava/lang/Double;")), "TYPE"));

            case 'F':
                return(GetField(GetReflectedType(FindClass("Ljava/lang/Float;")), "TYPE"));

            case 'I':
                return(GetField(GetReflectedType(FindClass("Ljava/lang/Integer;")), "TYPE"));

            case 'J':
                return(GetField(GetReflectedType(FindClass("Ljava/lang/Long;")), "TYPE"));

            case 'S':
                return(GetField(GetReflectedType(FindClass("Ljava/lang/Short;")), "TYPE"));

            case 'V':
                return(GetField(GetReflectedType(FindClass("Ljava/lang/Void;")), "TYPE"));

            case '[':
            case 'L':
                if (_classForNameMethod == null)
                {
                    _javaLangClassClass = (IClassType)_stackFrame.GetVirtualMachine().GetClassesByName("java.lang.Class").Single();
                    _classForNameMethod = _javaLangClassClass.GetConcreteMethod("forName", "(Ljava/lang/String;)Ljava/lang/Class;");
                }

                if (signature[0] != '[')
                {
                    signature = SignatureHelper.DecodeTypeName(signature);
                }

                using (var signatureValue = _stackFrame.GetVirtualMachine().GetMirrorOf(signature))
                {
                    var result = _javaLangClassClass.InvokeMethod(null, _classForNameMethod, InvokeOptions.None, signatureValue.Value);
                    return(new EvaluatedExpression(signature, signature, result.Value, true));
                }

            default:
                throw new ArgumentException();
            }
        }
        internal UnloadedArrayType(VirtualMachine virtualMachine, string signature)
            : base(virtualMachine, signature)
        {
            Contract.Requires(virtualMachine != null);
            Contract.Requires(!string.IsNullOrEmpty(signature));

            _componentSignature = Signature.Substring(1);
            _componentTypeName  = SignatureHelper.DecodeTypeName(_componentSignature);
            _componentType      = new UnloadedReferenceType(VirtualMachine, _componentSignature);
        }
示例#3
0
        internal Method(VirtualMachine virtualMachine, ReferenceType declaringType, string name, string signature, string genericSignature, AccessModifiers modifiers, MethodId methodId)
            : base(virtualMachine, declaringType, name, signature, genericSignature, modifiers)
        {
            Contract.Requires(virtualMachine != null);
            _methodId = methodId;

            List <string> argumentTypeSignatures;
            string        returnTypeSignature;

            SignatureHelper.ParseMethodSignature(signature, out argumentTypeSignatures, out returnTypeSignature);

            _argumentTypeSignatures = argumentTypeSignatures.AsReadOnly();
            _argumentTypeNames      = argumentTypeSignatures.Select(SignatureHelper.DecodeTypeName).ToList().AsReadOnly();
            _returnTypeSignature    = returnTypeSignature;
            _returnTypeName         = SignatureHelper.DecodeTypeName(_returnTypeSignature);
        }
 public string GetLocalTypeName()
 {
     return(SignatureHelper.DecodeTypeName(GetSignature()));
 }