1/* 2 * Copyright (c) 2021-2024 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 16package std.core; 17 18/** 19 * Represents parameter of function type 20 */ 21export final class Parameter { 22 private td: TypeDesc 23 private name: string 24 private attributes: int 25 26 private constructor () {} 27 28 public getType(): Type { 29 return Type.resolve(this.td)! 30 } 31 32 public getName(): string { 33 return this.name 34 } 35 36 public getAttributes(): int { 37 return this.attributes 38 } 39 40 public isRest(): boolean { 41 return (this.attributes & Attributes.REST) != 0 42 } 43 44 public isOptional(): boolean { 45 return (this.attributes & Attributes.OPTIONAL) != 0 46 } 47 48 public override toString(): string { 49 return this.getName() + ": " + this.getType().toString() 50 } 51 52 public equals(oth: NullishType): boolean { 53 return oth instanceof Parameter && 54 this.td == (oth as Parameter).td && 55 this.name == (oth as Parameter).name && 56 this.attributes == (oth as Parameter).attributes 57 } 58} 59