Пример #1
0
        private TypeReference ParseArrayTypeReference(TypeReference str)
        {
            var rank = 1;
            var token = NextToken();
            while (null != token && token.Kind == TokenKind.Comma)
            {
                ++rank;
                token = NextToken();
            }
            AssertTokenKind(TokenKind.RBrack, token);

            return new ArrayTypeReference(str, rank);
        }
Пример #2
0
        private TypeReference ParseQualifiedTypeReference(TypeReference elementType)
        {
            var returnValue = elementType;

            Token token;
            while (null != (token = NextToken()))
            {
                switch (token.Kind)
                {
                    case TokenKind.LBrack:
                        returnValue = ParseArrayTypeReference(returnValue);
                        break;
                    case TokenKind.PointerQualifier:
                        returnValue = new PointerTypeReference(returnValue);
                        break;
                    default:
                        Push(token);
                        return returnValue;
                }
            }

            return returnValue;
        }
Пример #3
0
        private SimpleTypeReference InternalParseGenericTypeReference(Token id, int count)
        {
            var argcToken = Expect(TokenKind.Number);
            id.Value += "`" + argcToken.Value;

            var argc = int.Parse(argcToken.Value);

            var t = NextToken();
            while (TokenKind.NestedQualifier == t.Kind)
            {
                var nestedId = Expect(TokenKind.Id);
                id.Value += "+" + nestedId.Value;

                t = NextToken();
            }

            if (IsInnerGenericTypeReference(t))
            {
                return InternalParseGenericTypeReference(id, argc + count);
            }

            var args = new TypeReference[0];
            if (!IsOpenGenericTypeDefinition(t))
            {
                args = new TypeReference[argc + count];
                AssertTokenKind(TokenKind.LBrack, t);
                for (var i = 0; i < args.Length; ++i)
                {
                    if (i > 0) Expect(TokenKind.Comma);
                    Expect(TokenKind.LBrack);
                    args[i] = Parse();
                    Expect(TokenKind.RBrack);
                }
                Expect(TokenKind.RBrack);
            }
            else
            {
                Push(t);
            }

            return new GenericTypeReference(id.Value, args);
        }
Пример #4
0
		static Type[] Resolve(TypeReference[] typeRefs)
		{
			Type[] types = new Type[typeRefs.Length];
			for (int i = 0; i < types.Length; ++i)
			{
				types[i] = typeRefs[i].Resolve();
			}
			return types;
		}
Пример #5
0
		internal GenericTypeReference(string simpleName, TypeReference[] genericArguments)
			: base(simpleName)
		{
			_genericArguments = genericArguments;
		}
Пример #6
0
		internal ArrayTypeReference(TypeReference elementType, int rank) : base(elementType)
		{
			_rank = rank;
		}
Пример #7
0
		public PointerTypeReference(TypeReference elementType)
			: base(elementType)
		{
		}
Пример #8
0
		protected QualifiedTypeReference(TypeReference elementType)
		{
			_elementType = elementType;
		}