// utils.beh -- Utility traversals and functions // $Id: utils.beh,v 1.2 1999/06/23 05:50:28 dougo Exp $ ClassDef { traversal toClassName(ClassNameAccessor v) { bypassing { ClassParts, ClassMethods, -> *,parameters,* } to ClassName; } } { Subclass, Superclass, Part, RepeatedPart } { traversal toClassName(ClassNameAccessor v) { bypassing { -> *,actual_parameters,* } to ClassName; } } { ClassDef, Subclass, Superclass, Part, RepeatedPart } { ClassName get_classname() = toClassName { before ClassName (@ return_val = host; @) } } HostSet { void add(Glob host) (@ if (host.isExact()) addExactHost(host); else if (host.isPartNameGlob()) addPartName(host.get_partname()); else addGlob(host); @) void addExactHost(Glob host) (@ if (exactHosts == null) exactHosts = new Hashtable(); exactHosts.put(host, host); @) void addPartName(PartName name) (@ if (partnames == null) partnames = new Hashtable(); partnames.put(name, name); @) void addGlob(Glob glob) (@ if (globs == null) globs = new GlobSet(); globs.addElement(glob); @) boolean contains(Glob glob) (@ if (exactHosts != null && exactHosts.get(glob) != null) return true; if (partnames != null && glob instanceof PartGlob && partnames.get(glob.get_partname()) != null) return true; if (globs != null && globs.match(glob)) return true; return false; @) } GlobSpec { GlobSpec deepCopy() (@ CopyVisitor c = new CopyVisitor(getClass()); universal_trv0(c); return (GlobSpec) c.get_copy(); @) } //to get the first ClassName in a StrategyGraph StrategyGraph { ClassName getFirst() through SGEdge to ClassName{ (@ boolean flag;@) init (@ flag = true; @) around ClassName (@ if(flag){ return_val = host; flag = false; } @) } } UEdge { UVertexName get_sourcename(Hashtable vtable) (@ return get_fromVertex().get_vertexname(vtable); @) UVertexName get_destname(Hashtable vtable) (@ return get_toVertex().get_vertexname(vtable); @) } UID { UVertexName get_vertexname(Hashtable vtable) (@ UVertex v = (UVertex) vtable.get(this); return v.get_vertexname(); @) } UEdgeName { PartName toPartName() {{ return PartName.parse(name.toString()); }} } UVertexName { ClassName toClassName() {{ return ClassName.parse(name.toString()); }} }