export const typeDimMap = new Map() export class PortModel { name: string type?: string constructor(name:string, type?:string){ this.name = name this.type = type } getTypeInfo(): {type: string; dim: number } { const result = PortModel.getTypeInfo(this.type || '') return result } static getTypeInfo(type: string): {type: string; dim: number } { if (!type) return {type: '', dim: 0 } const str = String(type).trim() if (typeDimMap.has(str)) return typeDimMap.get(str)! let dim = 0 let base = str let match: RegExpMatchArray | null const regex = /^(List|Array)\s*<(.+)>$/ while ((match = base.match(regex))) { dim++ base = match[2].trim() } const result = {type: base, dim } typeDimMap.set(str, result) return result } }