示例#1
0
        public virtual bool IsStrictSuperset(VarType val)
        {
            int valType = val.type;

            if (valType == ICodeConstants.Type_Unknown && type != ICodeConstants.Type_Unknown)
            {
                return(true);
            }
            if (val.arrayDim > 0)
            {
                return(this.Equals(Vartype_Object));
            }
            else if (arrayDim > 0)
            {
                return(valType == ICodeConstants.Type_Null);
            }
            bool res = false;

            switch (type)
            {
            case ICodeConstants.Type_Int:
            {
                res = (valType == ICodeConstants.Type_Short || valType == ICodeConstants.Type_Char
                       );
                goto case ICodeConstants.Type_Short;
            }

            case ICodeConstants.Type_Short:
            {
                res |= (valType == ICodeConstants.Type_Byte);
                goto case ICodeConstants.Type_Char;
            }

            case ICodeConstants.Type_Char:
            {
                res |= (valType == ICodeConstants.Type_Shortchar);
                goto case ICodeConstants.Type_Byte;
            }

            case ICodeConstants.Type_Byte:
            case ICodeConstants.Type_Shortchar:
            {
                res |= (valType == ICodeConstants.Type_Bytechar);
                goto case ICodeConstants.Type_Bytechar;
            }

            case ICodeConstants.Type_Bytechar:
            {
                res |= (valType == ICodeConstants.Type_Boolean);
                break;
            }

            case ICodeConstants.Type_Object:
            {
                if (valType == ICodeConstants.Type_Null)
                {
                    return(true);
                }
                else if (this.Equals(Vartype_Object))
                {
                    return(valType == ICodeConstants.Type_Object && !val.Equals(Vartype_Object));
                }
                break;
            }
            }
            return(res);
        }
示例#2
0
 public virtual bool IsSuperset(VarType val)
 {
     return(this.Equals(val) || this.IsStrictSuperset(val));
 }
示例#3
0
 private MethodDescriptor(VarType[] @params, VarType ret)
 {
     this.@params = @params;
     this.ret     = ret;
 }
示例#4
0
        public static MethodDescriptor ParseDescriptor(string descriptor)
        {
            int parenth = descriptor.LastIndexOf(')');

            if (descriptor.Length < 2 || parenth < 0 || descriptor[0] != '(')
            {
                throw new ArgumentException("Invalid descriptor: " + descriptor);
            }
            VarType[] @params;
            if (parenth > 1)
            {
                string        parameters = Sharpen.Runtime.Substring(descriptor, 1, parenth);
                List <string> lst        = new List <string>();
                int           indexFrom  = -1;
                int           ind;
                int           len   = parameters.Length;
                int           index = 0;
                while (index < len)
                {
                    switch (parameters[index])
                    {
                    case '[':
                    {
                        if (indexFrom < 0)
                        {
                            indexFrom = index;
                        }
                        break;
                    }

                    case 'L':
                    {
                        ind = parameters.IndexOf(";", index);
                        lst.Add(Sharpen.Runtime.Substring(parameters, indexFrom < 0 ? index : indexFrom,
                                                          ind + 1));
                        index     = ind;
                        indexFrom = -1;
                        break;
                    }

                    default:
                    {
                        lst.Add(Sharpen.Runtime.Substring(parameters, indexFrom < 0 ? index : indexFrom,
                                                          index + 1));
                        indexFrom = -1;
                        break;
                    }
                    }
                    index++;
                }
                @params = new VarType[lst.Count];
                for (int i = 0; i < lst.Count; i++)
                {
                    @params[i] = new VarType(lst[i]);
                }
            }
            else
            {
                @params = VarType.Empty_Array;
            }
            VarType ret = new VarType(Sharpen.Runtime.Substring(descriptor, parenth + 1));

            return(new MethodDescriptor(@params, ret));
        }
示例#5
0
 private FieldDescriptor(string descriptor)
 {
     type             = new VarType(descriptor);
     descriptorString = descriptor;
 }