예제 #1
0
 private TypeParser.Type[] ParseGenericArguments(int arity)
 {
     TypeParser.Type[] result = null;
     if (this.position == this.length || this.fullname[this.position] != '[')
     {
         return(result);
     }
     this.TryParse('[');
     for (int i = 0; i < arity; i++)
     {
         bool flag = this.TryParse('[');
         TypeParser.Add <TypeParser.Type>(ref result, this.ParseType(flag));
         if (flag)
         {
             this.TryParse(']');
         }
         this.TryParse(',');
         this.TryParseWhiteSpace();
     }
     this.TryParse(']');
     return(result);
 }
예제 #2
0
        private static TypeReference CreateSpecs(TypeReference type, TypeParser.Type type_info)
        {
            type = TypeParser.TryCreateGenericInstanceType(type, type_info);
            int[] specs = type_info.specs;
            if (specs.IsNullOrEmpty <int>())
            {
                return(type);
            }
            for (int i = 0; i < specs.Length; i++)
            {
                switch (specs[i])
                {
                case -3:
                    type = new ArrayType(type);
                    break;

                case -2:
                    type = new ByReferenceType(type);
                    break;

                case -1:
                    type = new PointerType(type);
                    break;

                default:
                {
                    ArrayType arrayType = new ArrayType(type);
                    arrayType.Dimensions.Clear();
                    for (int j = 0; j < specs[i]; j++)
                    {
                        arrayType.Dimensions.Add(default(ArrayDimension));
                    }
                    type = arrayType;
                    break;
                }
                }
            }
            return(type);
        }
예제 #3
0
 private void WriteTypeReference(TypeReference type)
 {
     this.WriteUTF8String(TypeParser.ToParseable(type));
 }
예제 #4
0
        private static void AppendTypeSpecification(TypeSpecification type, StringBuilder name)
        {
            if (type.ElementType.IsTypeSpecification())
            {
                TypeParser.AppendTypeSpecification((TypeSpecification)type.ElementType, name);
            }
            ElementType etype = type.etype;

            switch (etype)
            {
            case ElementType.Ptr:
                name.Append('*');
                return;

            case ElementType.ByRef:
                name.Append('&');
                return;

            case ElementType.ValueType:
            case ElementType.Class:
            case ElementType.Var:
                return;

            case ElementType.Array:
                break;

            case ElementType.GenericInst:
            {
                GenericInstanceType        genericInstanceType = (GenericInstanceType)type;
                Collection <TypeReference> genericArguments    = genericInstanceType.GenericArguments;
                name.Append('[');
                for (int i = 0; i < genericArguments.Count; i++)
                {
                    if (i > 0)
                    {
                        name.Append(',');
                    }
                    TypeReference typeReference = genericArguments[i];
                    bool          flag          = typeReference.Scope != typeReference.Module;
                    if (flag)
                    {
                        name.Append('[');
                    }
                    TypeParser.AppendType(typeReference, name, true, false);
                    if (flag)
                    {
                        name.Append(']');
                    }
                }
                name.Append(']');
                return;
            }

            default:
                if (etype != ElementType.SzArray)
                {
                    return;
                }
                break;
            }
            ArrayType arrayType = (ArrayType)type;

            if (arrayType.IsVector)
            {
                name.Append("[]");
                return;
            }
            name.Append('[');
            for (int j = 1; j < arrayType.Rank; j++)
            {
                name.Append(',');
            }
            name.Append(']');
        }
예제 #5
0
 public TypeReference ReadTypeReference()
 {
     return(TypeParser.ParseType(this.reader.module, this.ReadUTF8String()));
 }