Exemple #1
0
        public LLVMType ParseType()
        {
            LLVMType type = ParseTypeCore();

            for (;;)
            {
                if (PeekAndDiscard(TokenType.STAR))
                {
                    type = new LLVMPointer(type);
                }
                else if (PeekAndDiscard(TokenType.LPAREN))
                {
                    var args = new List <LLVMParameter>();
                    if (Peek().Type != TokenType.RPAREN)
                    {
                        var argType = ParseType();
                        args.Add(new LLVMParameter {
                            Type = argType
                        });
                        while (PeekAndDiscard(TokenType.COMMA))
                        {
                            if (PeekAndDiscard(TokenType.ELLIPSIS))
                            {
                                args.Add(new LLVMParameter {
                                    name = "..."
                                });
                                break;
                            }
                            argType = ParseType();
                            args.Add(new LLVMParameter {
                                Type = argType
                            });
                        }
                    }
                    Expect(TokenType.RPAREN);
                    var fnType = new LLVMFunctionType
                    {
                        ReturnType = type,
                        Parameters = args,
                    };
                    type = fnType;
                }
                else
                {
                    return(type);
                }
            }
        }
Exemple #2
0
        public DataType VisitPointer(LLVMPointer p)
        {
            var pointee = p.Pointee.Accept(this);

            return(new Pointer(pointee, ptrBitSize));
        }