Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

IITreeNode.java

00001 package edu.ksu.cis.bandera.prog;
00002 
00003 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00004  * Bandera, a Java(TM) analysis and transformation toolkit           *
00005  * Copyright (C) 1998-2001 SAnToS Laboratories (santos@cis.ksu.edu)  *
00006 
00007  * All rights reserved.                                              *
00008  *                                                                   *
00009  * This work was done as a project in the SAnToS Laboratory,         *
00010  * Department of Computing and Information Sciences, Kansas State    *
00011  * University, USA (http://www.cis.ksu.edu/santos).                  *
00012  * It is understood that any modification not identified as such is  *
00013  * not covered by the preceding statement.                           *
00014  *                                                                   *
00015  * This work is free software; you can redistribute it and/or        *
00016  * modify it under the terms of the GNU Library General Public       *
00017  * License as published by the Free Software Foundation; either      *
00018  * version 2 of the License, or (at your option) any later version.  *
00019  *                                                                   *
00020  * This work is distributed in the hope that it will be useful,      *
00021  * but WITHOUT ANY WARRANTY; without even the implied warranty of    *
00022  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU *
00023  * Library General Public License for more details.                  *
00024  *                                                                   *
00025  * You should have received a copy of the GNU Library General Public *
00026  * License along with this toolkit; if not, write to the             *
00027  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,      *
00028  * Boston, MA  02111-1307, USA.                                      *
00029  *                                                                   *
00030  * Java is a trademark of Sun Microsystems, Inc.                     *
00031  *                                                                   *
00032  * To submit a bug report, send a comment, or get the latest news on *
00033  * this project and other SAnToS projects, please visit the web-site *
00034  *                http://www.cis.ksu.edu/santos                      *
00035  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00036 import java.util.Hashtable;
00037 import java.util.Vector;
00038 import java.util.Enumeration;
00039 import java.io.*;
00040 
00041 import ca.mcgill.sable.soot.*;
00042 import ca.mcgill.sable.soot.jimple.*;
00043 import ca.mcgill.sable.util.*;
00044 
00045 import edu.ksu.cis.bandera.jjjc.*;
00046 
00047 class IITreeNode
00048 {
00049     private SootClass element;
00050     private int depth;
00051     private int maxNodes; //used as a max array size
00052     private IITreeNode[] children;   
00053     private int childrenCount; //can be used as index where to insert next
00054 
00055     public IITreeNode(SootClass sc, int num)  
00056     {
00057         depth = 0;
00058         element = sc;
00059     maxNodes = num;
00060         children = new IITreeNode[maxNodes];
00061     childrenCount = 0;
00062     }
00063     public void addChild(SootClass sc)
00064     {
00065     IITreeNode child = new IITreeNode(sc, maxNodes);
00066     children[childrenCount] = child;
00067     childrenCount++;
00068     }
00069     public void addChild(IITreeNode child)
00070     {
00071         children[childrenCount] = child;
00072         childrenCount++;
00073     }
00074     public IITreeNode[] getChildren()
00075     {
00076     return children;
00077     }
00078     public int getChildrenCount()
00079     {
00080     return childrenCount;
00081     }
00082     public int getDepth()
00083     {
00084     return depth;
00085     }
00086     public SootClass getElement()
00087     {
00088     return element;
00089     }
00090     public int number(int d)
00091     {
00092         int tmp;
00093         int maxd = d;
00094 
00095         depth = d; 
00096         for (int i=0; i<childrenCount; i++) {
00097           tmp = children[i].number(d+1);
00098           if (tmp > maxd) maxd = tmp;
00099         }
00100         return maxd;
00101     }
00102     public void print()
00103     { 
00104     System.out.println();
00105     System.out.println("Children of "+this.element.getName()+":");
00106     for(int i=0; i<childrenCount; i++)
00107     {
00108         System.out.print(((children[i]).element).getName()+"\t");
00109         
00110     }
00111     System.out.println();
00112         for(int i=0; i<childrenCount; i++)
00113         (children[i]).print();
00114     }
00115 }

Generated at Thu Feb 7 06:46:33 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001