107e13b76SRoland McGrath# ====-- Function class for libc function headers -------------*- python -*--==# 207e13b76SRoland McGrath# 307e13b76SRoland McGrath# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 407e13b76SRoland McGrath# See https://llvm.org/LICENSE.txt for license information. 507e13b76SRoland McGrath# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 607e13b76SRoland McGrath# 707e13b76SRoland McGrath# ==-------------------------------------------------------------------------==# 807e13b76SRoland McGrath 907e13b76SRoland McGrath 1007e13b76SRoland McGrathclass Function: 1107e13b76SRoland McGrath def __init__( 1207e13b76SRoland McGrath self, return_type, name, arguments, standards, guard=None, attributes=[] 1307e13b76SRoland McGrath ): 1407e13b76SRoland McGrath self.return_type = return_type 1507e13b76SRoland McGrath self.name = name 1607e13b76SRoland McGrath self.arguments = [ 1707e13b76SRoland McGrath arg if isinstance(arg, str) else arg["type"] for arg in arguments 1807e13b76SRoland McGrath ] 1907e13b76SRoland McGrath self.standards = standards 2007e13b76SRoland McGrath self.guard = guard 2107e13b76SRoland McGrath self.attributes = attributes or "" 2207e13b76SRoland McGrath 2307e13b76SRoland McGrath def __str__(self): 2407e13b76SRoland McGrath attributes_str = " ".join(self.attributes) 25*906cbbbdSRoland McGrath arguments_str = ", ".join(self.arguments) if self.arguments else "void" 2607e13b76SRoland McGrath if attributes_str == "": 2707e13b76SRoland McGrath result = f"{self.return_type} {self.name}({arguments_str})" 2807e13b76SRoland McGrath else: 2907e13b76SRoland McGrath result = f"{attributes_str} {self.return_type} {self.name}({arguments_str})" 3007e13b76SRoland McGrath return result 31