View Javadoc
1 package net.sourceforge.pmd.cpd.cppast; 2 3 import java.util.Hashtable; 4 5 public class Scope 6 { 7 /*** 8 * Name of the scope (set only for class/function scopes). 9 */ 10 String scopeName; 11 12 /*** 13 * Indicates whether this is a class scope or not. 14 */ 15 boolean type; // Indicates if this is a type. 16 17 /*** 18 * (partial) table of type symbols introduced in this scope. 19 */ 20 Hashtable typeTable = new Hashtable(); 21 22 /*** 23 * Parent scope. (null if it is the global scope). 24 */ 25 Scope parent; 26 27 /*** 28 * Creates a scope object with a given name. 29 */ 30 public Scope(String name, boolean isType, Scope p) 31 { 32 scopeName = name; 33 type = isType; 34 parent = p; 35 } 36 37 /*** 38 * Creates an unnamed scope (like for compound statements). 39 */ 40 public Scope(Scope p) 41 { 42 type = false; 43 parent = p; 44 } 45 46 /*** 47 * Inserts a name into the table to say that it is the name of a type. 48 */ 49 public void PutTypeName(String name) 50 { 51 typeTable.put(name, name); 52 } 53 54 /*** 55 * A type with a scope (class/struct/union). 56 */ 57 public void PutTypeName(String name, Scope sc) 58 { 59 typeTable.put(name, sc); 60 } 61 62 /*** 63 * Checks if a given name is the name of a type in this scope. 64 */ 65 public boolean IsTypeName(String name) 66 { 67 return typeTable.get(name) != null; 68 } 69 70 public Scope GetScope(String name) 71 { 72 Object sc = typeTable.get(name); 73 74 if (sc instanceof Scope || sc instanceof ClassScope) 75 return (Scope)sc; 76 77 return null; 78 } 79 }

This page was automatically generated by Maven