82 lines · cpp
1//===-- lib/Support/default-kinds.cpp ---------------------------*- C++ -*-===//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-exception6//7//===----------------------------------------------------------------------===//8 9#include "flang/Support/default-kinds.h"10#include "flang/Common/idioms.h"11 12namespace Fortran::common {13 14IntrinsicTypeDefaultKinds::IntrinsicTypeDefaultKinds() {}15 16IntrinsicTypeDefaultKinds &IntrinsicTypeDefaultKinds::set_defaultIntegerKind(17 int k) {18 defaultIntegerKind_ = k;19 return *this;20}21 22IntrinsicTypeDefaultKinds &IntrinsicTypeDefaultKinds::set_subscriptIntegerKind(23 int k) {24 subscriptIntegerKind_ = k;25 return *this;26}27 28IntrinsicTypeDefaultKinds &IntrinsicTypeDefaultKinds::set_sizeIntegerKind(29 int k) {30 sizeIntegerKind_ = k;31 return *this;32}33 34IntrinsicTypeDefaultKinds &IntrinsicTypeDefaultKinds::set_defaultRealKind(35 int k) {36 defaultRealKind_ = k;37 return *this;38}39 40IntrinsicTypeDefaultKinds &IntrinsicTypeDefaultKinds::set_doublePrecisionKind(41 int k) {42 doublePrecisionKind_ = k;43 return *this;44}45 46IntrinsicTypeDefaultKinds &IntrinsicTypeDefaultKinds::set_quadPrecisionKind(47 int k) {48 quadPrecisionKind_ = k;49 return *this;50}51 52IntrinsicTypeDefaultKinds &IntrinsicTypeDefaultKinds::set_defaultCharacterKind(53 int k) {54 defaultCharacterKind_ = k;55 return *this;56}57 58IntrinsicTypeDefaultKinds &IntrinsicTypeDefaultKinds::set_defaultLogicalKind(59 int k) {60 defaultLogicalKind_ = k;61 return *this;62}63 64int IntrinsicTypeDefaultKinds::GetDefaultKind(TypeCategory category) const {65 switch (category) {66 case TypeCategory::Integer:67 case TypeCategory::Unsigned:68 return defaultIntegerKind_;69 case TypeCategory::Real:70 case TypeCategory::Complex:71 return defaultRealKind_;72 case TypeCategory::Character:73 return defaultCharacterKind_;74 case TypeCategory::Logical:75 return defaultLogicalKind_;76 default:77 CRASH_NO_CASE;78 return 0;79 }80}81} // namespace Fortran::common82