scope.java

来自「检查Java程序漏洞」· Java 代码 · 共 80 行

JAVA
80
字号
package net.sourceforge.pmd.cpd.cppast;import java.util.Hashtable;public class Scope{   /**    * Name of the scope (set only for class/function scopes).    */   String scopeName;   /**    * Indicates whether this is a class scope or not.    */   boolean type;     // Indicates if this is a type.   /**    * (partial) table of type symbols introduced in this scope.    */   Hashtable typeTable = new Hashtable();   /**    * Parent scope. (null if it is the global scope).    */   Scope parent;   /**    * Creates a scope object with a given name.    */   public Scope(String name, boolean isType, Scope p)   {      scopeName = name;      type = isType;      parent = p;   }   /**    * Creates an unnamed scope (like for compound statements).    */   public Scope(Scope p)   {      type = false;      parent = p;   }   /**    * Inserts a name into the table to say that it is the name of a type.    */   public void PutTypeName(String name)   {      typeTable.put(name, name);   }   /**    * A type with a scope (class/struct/union).    */   public void PutTypeName(String name, Scope sc)   {      typeTable.put(name, sc);   }   /**     * Checks if a given name is the name of a type in this scope.    */   public boolean IsTypeName(String name)   {      return typeTable.get(name) != null;   }   public Scope GetScope(String name)   {      Object sc = typeTable.get(name);      if (sc instanceof Scope || sc instanceof ClassScope)         return (Scope)sc;      return null;   }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?