KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > soot > Kind


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2003 Ondrej Lhotak
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */

19
20 package soot;
21 import soot.util.*;
22
23 /** Enumeration type representing the kind of a call graph edge.
24  * @author Ondrej Lhotak
25  */

26 public final class Kind implements Numberable
27 {
28     public static final Kind INVALID = new Kind( "INVALID" );
29     /** Due to explicit invokestatic instruction. */
30     public static final Kind STATIC = new Kind( "STATIC" );
31     /** Due to explicit invokevirtual instruction. */
32     public static final Kind VIRTUAL = new Kind( "VIRTUAL" );
33     /** Due to explicit invokeinterface instruction. */
34     public static final Kind INTERFACE = new Kind( "INTERFACE" );
35     /** Due to explicit invokespecial instruction. */
36     public static final Kind SPECIAL = new Kind( "SPECIAL" );
37     /** Implicit call to static initializer. */
38     public static final Kind CLINIT = new Kind( "CLINIT" );
39     /** Implicit call to Thread.run() due to Thread.start() call. */
40     public static final Kind THREAD = new Kind( "THREAD" );
41     /** Implicit call to java.lang.ref.Finalizer.register from new bytecode. */
42     public static final Kind FINALIZE = new Kind( "FINALIZE" );
43     /** Implicit call to finalize() from java.lang.ref.Finalizer.invokeFinalizeMethod(). */
44     public static final Kind INVOKE_FINALIZE = new Kind( "INVOKE_FINALIZE" );
45     /** Implicit call to run() through AccessController.doPrivileged(). */
46     public static final Kind PRIVILEGED = new Kind( "PRIVILEGED" );
47     /** Implicit call to constructor from java.lang.Class.newInstance(). */
48     public static final Kind NEWINSTANCE = new Kind( "NEWINSTANCE" );
49
50     private Kind( String JavaDoc name ) {
51         this.name = name;
52     }
53     private final String JavaDoc name;
54     private int num;
55
56     public String JavaDoc name() { return name; }
57     public int getNumber() { return num; }
58     public void setNumber( int num ) { this.num = num; }
59
60     public String JavaDoc toString() { return name(); }
61
62     public boolean passesParameters() {
63         return isExplicit() || this == THREAD || this == FINALIZE ||
64             this == PRIVILEGED || this == NEWINSTANCE || this == INVOKE_FINALIZE;
65     }
66
67     /** Returns true if the call is due to an explicit invoke statement. */
68     public boolean isExplicit() {
69         return isInstance() || isStatic();
70     }
71     
72     /** Returns true if the call is due to an explicit instance invoke
73      * statement. */

74     public boolean isInstance() {
75         return this == VIRTUAL || this == INTERFACE || this == SPECIAL;
76     }
77
78     /** Returns true if the call is to static initializer. */
79     public boolean isClinit() {
80         return this == CLINIT;
81     }
82     /** Returns true if the call is due to an explicit static invoke
83      * statement. */

84     public boolean isStatic() {
85         return this == STATIC;
86     }
87
88 }
89
90
Popular Tags