// collect.beh -- Behavior collection // $Id: collect.beh,v 1.1 1998/03/11 22:27:48 dougo Exp $ ProgramBehavior { /** Attach each behavior method to its class definition. */ void collectBehavior(String behfile) via ClassBehavior bypassing ClassMethods to { ClassName, AnyClass } { (@ ClassMethods methods; @) before ClassBehavior (@ methods = host.get_methods(); @) before ClassName (@ ClassDef def = Program.prog.findClassDef(host); if (def == null) { System.err.println(behfile + ": Error: No such class " + "\"" + host + "\"."); } else { def.addBehavior(methods); } @) before AnyClass (@ Program.prog.attachBehaviorToAllClasses(methods); @) } } Program { void attachBehaviorToAllClasses(ClassMethods methods) = allClassDefs { before ClassDef (@ host.addBehavior(methods); @) } } ClassDef { void addBehavior(ClassMethods methods) (@ if (classmethods == null) classmethods = new ClassMethods(); classmethods.concat(methods.deepCopy()); @) } ClassMethods { void concat(ClassMethods added) (@ if (added == null || added.methods == null) return; if (methods == null) methods = new Method_SList(); Enumeration e = added.methods.elements(); while (e.hasMoreElements()) methods.addElement((Method) e.nextElement()); @) }