1 /** 2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef _PANDA_TYPE_INDEX_HPP 17 #define _PANDA_TYPE_INDEX_HPP 18 19 #include "type_tags.h" 20 21 #include "verification/util/lazy.h" 22 #include "verification/util/relation.h" 23 #include "verification/util/tagged_index.h" 24 25 #include "runtime/include/mem/panda_containers.h" 26 27 namespace panda::verifier { 28 class TypeParamIdx : public TaggedIndex<TypeVarianceTag, TypeNum> { 29 using Base = TaggedIndex<TypeVarianceTag, TypeNum>; 30 31 public: TypeParamIdx(TypeVariance variance,TypeNum num)32 TypeParamIdx(TypeVariance variance, TypeNum num) 33 { 34 Base::SetTag<0>(variance); 35 Base::SetInt(num); 36 } 37 ~TypeParamIdx() = default; 38 TypeParamIdx &operator+() 39 { 40 Base::SetTag<0>(TypeVariance::COVARIANT); 41 return *this; 42 } 43 TypeParamIdx &operator-() 44 { 45 Base::SetTag<0>(TypeVariance::CONTRVARIANT); 46 return *this; 47 } 48 TypeParamIdx &operator~() 49 { 50 Base::SetTag<0>(TypeVariance::INVARIANT); 51 return *this; 52 } Variance()53 TypeVariance Variance() const 54 { 55 return Base::GetTag<0>(); 56 } 57 }; 58 59 using TypeParamsIdx = PandaVector<TypeParamIdx>; 60 } // namespace panda::verifier 61 62 #endif // !_PANDA_TYPE_INDEX_HPP 63