private Argument ParseArgument() { LLVMType type = ParseType(); Value val = null; var attrs = ParseParameterAttributes(); if (Value_FIRST.Contains(Peek().Type)) { val = ParseValue(); } var arg = new Argument { Type = type, Value = val, Attributes = attrs }; return(arg); }
private GlobalDefinition ParseGlobalDefinition() { var name = Expect(TokenType.GlobalId); Expect(TokenType.EQ); bool unnamed_addr = false; string visibility = null; int align = 0; // 0 = no aligmnent specified. if (PeekAndDiscard(TokenType.@private)) { visibility = "private"; } else if (PeekAndDiscard(TokenType.external)) { visibility = "external"; } if (PeekAndDiscard(TokenType.unnamed_addr)) { unnamed_addr = true; } if (PeekAndDiscard(TokenType.common) || PeekAndDiscard(TokenType.@internal)) { // Not used yet. } if (PeekAndDiscard(TokenType.global)) { var type = ParseType(); Value value = null; if (Value_FIRST.Contains(Peek().Type)) { value = ParseValue(); } if (PeekAndDiscard(TokenType.COMMA)) { Expect(TokenType.align); align = int.Parse(Expect(TokenType.Integer)); } ; return(new GlobalDefinition { Name = name, Type = type, Initializer = value, unnamed_addr = unnamed_addr, Visibility = visibility, Alignment = align, }); } else if (PeekAndDiscard(TokenType.constant)) { var type = ParseType(); var value = ParseValue(); if (PeekAndDiscard(TokenType.COMMA)) { Expect(TokenType.align); align = int.Parse(Expect(TokenType.Integer)); } return(new GlobalDefinition { Name = name, Type = type, constant = true, unnamed_addr = unnamed_addr, Visibility = visibility, Initializer = value, Alignment = align, }); } Unexpected(Peek()); return(null); }