示例#1
0
        public static Type[] GetSiteTypes(IList <Expression> arguments, Type returnType)
        {
            int count = arguments.Count;

            Type[] ret = new Type[count + 1];

            for (int i = 0; i < count; i++)
            {
                ret[i] = arguments[i].Type;
            }

            ret[count] = returnType;

            NonNullType.AssertInitialized(ret);
            return(ret);
        }
示例#2
0
        private static InputType ParseInputType(ref Token token, ListIterator <Token> iterator)
        {
            if (token is PunctuatorToken && token.Value.Equals("["))
            {
                token = AssertNotEof(iterator.FirstOrDefault());

                var inputType = ParseInputType(ref token, iterator);

                // token is currently ']'
                token = AssertNotEof(iterator.FirstOrDefault());

                var       listType = new ListType(inputType);
                InputType result   = listType;

                if (token is PunctuatorToken && token.Value.Equals("!"))
                {
                    token = AssertNotEof(iterator.FirstOrDefault());

                    result = new NonNullType(listType);
                }

                return(result);
            }

            if (!(token is NameToken))
            {
                throw new ParserException();
            }

            var namedType = new NamedType(token.Value);

            token = AssertNotEof(iterator.FirstOrDefault());

            if (token is PunctuatorToken && token.Value.Equals("!"))
            {
                token = AssertNotEof(iterator.FirstOrDefault());

                return(new NonNullType(namedType));
            }

            return(namedType);
        }
示例#3
0
        private static bool TryCreateBluePrint(
            List <Type> components,
            int index,
            out IType bluePrint)
        {
            if (index < components.Count)
            {
                Type component = components[index];

                if (index == components.Count - 1)
                {
                    if (IsNamedType(component))
                    {
                        bluePrint = TypeFactoryHelper.PlaceHolder;
                        return(true);
                    }
                }
                else if (IsNonNullType(component))
                {
                    if (TryCreateBluePrint(components, index + 1, out IType innerType) &&
                        innerType.Kind != TypeKind.NonNull)
                    {
                        bluePrint = new NonNullType(innerType);
                        return(true);
                    }
                }
                else if (IsListType(component))
                {
                    if (TryCreateBluePrint(components, index + 1, out IType innerType))
                    {
                        bluePrint = new ListType(innerType);
                        return(true);
                    }
                }
            }

            bluePrint = null;
            return(false);
        }
示例#4
0
 private TypeNameField()
 {
     Name      = WellKnownNames.TypeName;
     Type      = new NonNullType(new StringType());
     Arguments = FieldCollection <IInputField> .Empty;
 }
 private void VisitNonNullType(NonNullType node)
 {
     EnterNode(node);
     Visit(node.OfType);
     ExitNode(node);
 }
示例#6
0
 protected override void ExitNonNullType(PrinterContext context, NonNullType nonNullType)
 {
     context.Append("!");
 }
示例#7
0
        private string PrintNonNullType(NonNullType node)
        {
            var type = Print(node.OfType);

            return($"{type}!");
        }
 protected virtual void ExitNonNullType(TContext context, NonNullType nonNullType)
 {
 }