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);
            }
Example #2
0
        public virtual InsType VisitPointer(InsPointerType 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 InsPointerType(inner));
        }
 public InsAssembly?VisitPointer(InsPointerType type, object argument) => type.ElementType.Apply(this, argument);
 public StringBuilder VisitPointer(InsPointerType type, StringBuilder builder)
 => type.ElementType.Apply(this, builder).Append('*');