// CTGsubgraph.beh -- use the TG package to compute the subgraph. // $Id: CTGsubgraph.beh,v 1.4 2000/09/19 21:08:24 dougo Exp $ UGraph { (@ edu.neu.ccs.demeter.common.tg.ClassGraph ccg; @) /** computes the subgraph input - StrategyGraph object output - true/false if success/failure Marks the UGraph object with tags corresponding to the subgraph */ boolean computeSubgraph(StrategyGraph sg) (@ initialize(); //create new hashtables hashinit(get_idToVertexTable(),get_idToEdgeTable()); //fill 'em buildCyclicClassGraph(); // Assume no name map for now... TraversalGraph tg = ccg.computeTraversalGraph(sg, null); // TBD: check compatibility // For now, just sanity check... if (tg.get_vertices().isEmpty()) { System.err.println("Error: No path found."); return false; } updateUGraph(tg); return true; @) void buildCyclicClassGraph() = toVertEdge(TGCreateVisitor); void updateUGraph(TraversalGraph tg) = toVertEdge(TGUpdateVisitor); } TGCreateVisitor { (@ edu.neu.ccs.demeter.common.tg.ClassGraph ccg; @) before UGraph (@ vtable = host.get_idToVertexTable(); host.ccg = ccg = new edu.neu.ccs.demeter.common.tg.ClassGraph(); @) before UConstEdge (@ UEdgeName edgename = host.get_edgename(); if (edgename == null) { // Not sure how this could happen... edgename = UEdgeName.parse("_"); } ccg.addConstructionEdge(host.get_sourcename(vtable).toClassName(), edgename.toPartName(), host.get_destname(vtable).toClassName()); @) before UAltEdge (@ ccg.addAlternationEdge(host.get_sourcename(vtable).toClassName(), host.get_destname(vtable).toClassName()); @) before UExtendEdge (@ ccg.addInheritanceEdge(host.get_sourcename(vtable).toClassName(), host.get_destname(vtable).toClassName()); @) } TGUpdateVisitor { before UGraph (@ vtable = host.get_idToVertexTable(); @) before UVertex (@ if (host.get_vdeco() == null) host.set_vdeco(new Decorator()); if (tg.hasVertex(host.get_vertexname())) host.get_vdeco().setMarked(3); else host.get_vdeco().setMarked(0); @) before UEdge (@ if (host.get_edeco() == null) host.set_edeco(new Decorator()); @) before UConstEdge (@ if (tg.hasConstructionEdge(host.get_sourcename(vtable).toClassName(), host.get_edgename().toPartName(), host.get_destname(vtable).toClassName())) host.get_edeco().setMarked(3); else host.get_edeco().setMarked(0); @) before UAltEdge (@ if (tg.hasAlternationEdge(host.get_sourcename(vtable).toClassName(), host.get_destname(vtable).toClassName())) host.get_edeco().setMarked(3); else host.get_edeco().setMarked(0); @) before UExtendEdge (@ if (tg.hasInheritanceEdge(host.get_sourcename(vtable).toClassName(), host.get_destname(vtable).toClassName())) host.get_edeco().setMarked(3); else host.get_edeco().setMarked(0); @) }