LLDB mainline
FortranTypes.cpp
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "FortranTypes.h"
10
11using namespace lldb_private;
12using namespace lldb_private::plugin::fortran;
13
16
18
19static ConstString
21 const llvm::SmallVectorImpl<CompilerType> &param_types,
23 CompilerType return_type) {
24 std::string buf;
25 llvm::raw_string_ostream ss(buf);
26
27 if (return_type.IsValid())
28 ss << return_type.GetTypeName().AsCString("") << " ";
29
30 ss << func_name.AsCString("<unnamed function>") << "(";
31
32 for (size_t i = 0; i < param_types.size(); i++) {
33 if (i)
34 ss << ", ";
35 ss << param_types[i].GetTypeName().AsCString("") << " ";
36 ss << param_names[i];
37 }
38 ss << ")";
39 ss.flush();
40 return ConstString(buf);
41}
42
44 ConstString func_name,
45 const llvm::SmallVectorImpl<CompilerType> &param_types,
47 CompilerType return_type)
48 : FortranType(FortranType::KIND_FUNCTION, 0, func_name),
49 m_param_types(param_types.begin(), param_types.end()),
50 m_return_type(return_type),
51 m_func_signature(CreateFuncSignature(func_name, param_types, param_names,
52 return_type)) {}
53
55 if (!type)
56 return nullptr;
57
58 FortranType *base_type = static_cast<FortranType *>(type);
59 if (base_type->GetKind() != FortranType::KIND_FUNCTION)
60 return nullptr;
61
62 return llvm::cast<FortranFunction>(base_type);
63}
static ConstString CreateFuncSignature(ConstString func_name, const llvm::SmallVectorImpl< CompilerType > &param_types, const llvm::SmallVectorImpl< llvm::StringRef > &param_names, CompilerType return_type)
This file defines the classes that describe the Fortran types.
Generic representation of a type in a programming language.
ConstString GetTypeName(bool BaseOnly=false) const
A uniqued constant string class.
Definition ConstString.h:40
const char * AsCString(const char *value_if_empty) const
Get the string value as a C string.
static FortranFunction * GetFunctionType(void *type)
FortranFunction(ConstString func_name, const llvm::SmallVectorImpl< CompilerType > &param_types, const llvm::SmallVectorImpl< llvm::StringRef > &param_names, CompilerType return_type)
llvm::SmallVector< CompilerType, 4 > m_param_types
FortranType(int32_t kind, uint64_t bitsize, const ConstString &name)
A class that represents a running process on the host machine.