InsType ParseUnqualified(ref int index, InsAssembly?assembly)
            {
                var identifier = ParseIdentifier(ref index);
                var baseType   = new InsNamedType(identifier, assembly);

                while (TryReadChar(ref index, '+'))
                {
                    AssertNotEOF(index);
                    identifier = ParseIdentifier(ref index);
                    baseType   = new InsNamedType(identifier, baseType);
                }

                InsType type;

                if (index + 1 < _buffer.Length &&
                    _buffer[index] == '[' &&
                    _buffer[index + 1] != ']' &&
                    _buffer[index + 1] != ',' &&
                    _buffer[index + 1] != '*')
                {
                    var typeArguments = ParseTypeArguments(ref index);
                    type = new InsGenericType(baseType, typeArguments);
                }
                else
                {
                    type = baseType;
                }

                while (index < _buffer.Length)
                {
                    var c = _buffer[index];

                    if (c == '*')
                    {
                        type = new InsPointerType(type);
                        index++;
                    }
                    else if (c == '[')
                    {
                        type = ParseArrayDetails(ref index, type);
                    }
                    else
                    {
                        break;
                    }
                }

                if (TryReadChar(ref index, '&'))
                {
                    type = new InsByRefType(type);
                }

                return(type);
            }
Exemplo n.º 2
0
        public virtual InsType VisitByRef(InsByRefType type, TArgument argument)
        {
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }

            var inner = type.ElementType.Apply(this, argument);

            if (inner == type.ElementType)
            {
                return(type);
            }

            return(new InsByRefType(inner));
        }
 public StringBuilder VisitByRef(InsByRefType type, StringBuilder builder)
 => type.ElementType.Apply(this, builder).Append('&');
 public InsAssembly?VisitByRef(InsByRefType type, object argument) => type.ElementType.Apply(this, argument);