Esempio n. 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);
        }
Esempio n. 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;
        }
Esempio n. 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);
        }
Esempio n. 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;
		}
Esempio n. 5
0
		internal GenericTypeReference(string simpleName, TypeReference[] genericArguments)
			: base(simpleName)
		{
			_genericArguments = genericArguments;
		}
Esempio n. 6
0
		internal ArrayTypeReference(TypeReference elementType, int rank) : base(elementType)
		{
			_rank = rank;
		}
Esempio n. 7
0
		public PointerTypeReference(TypeReference elementType)
			: base(elementType)
		{
		}
Esempio n. 8
0
		protected QualifiedTypeReference(TypeReference elementType)
		{
			_elementType = elementType;
		}