Пример #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);
                }
            }
        }
Пример #2
0
 public DataType VisitFunction(LLVMFunctionType fn)
 {
     return(TranslateFn(fn.ReturnType, fn.Parameters, new StorageBinder()));
 }