Class AbstractSymbol

java.lang.Object
  extended byAbstractSymbol
Direct Known Subclasses:
IdSymbol, IntSymbol, StringSymbol

abstract class AbstractSymbol
extends java.lang.Object

String table entry There are three kinds of string table entries:

Having separate tables is convenient for code generation. Different data definitions are generated for string constants (StringSymbol) and integer constants (IntSymbol). Identifiers (IdSymbol) don't produce static data definitions.

codeDef and codeRef (defined by subclasses) are used by the code to produce definitions and references (respectively) to constants.

See Also:
AbstractTable

Field Summary
protected  int index
          The index of this entry in the string table
protected  java.lang.String str
          The stored string
 
Constructor Summary
AbstractSymbol(java.lang.String str, int len, int index)
          Constructs a new table entry.
 
Method Summary
abstract  java.lang.Object clone()
          Returns a copy of this symbol
 boolean equals(java.lang.Object another)
          Tests if two symbols are equal.
 boolean equalsIndex(int index)
          Tests if the index argument is equal to the index of this symbol.
 boolean equalString(java.lang.String str, int len)
          Tests if the string argument is equal to the string in this symbol.
 java.lang.String getString()
          Returns the string representation of this symbol.
 java.lang.String toString()
          Returns a printable representation of this symbol.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

str

protected java.lang.String str
The stored string


index

protected int index
The index of this entry in the string table

Constructor Detail

AbstractSymbol

public AbstractSymbol(java.lang.String str,
                      int len,
                      int index)
Constructs a new table entry.

Parameters:
str - the entry string
len - the length of the str prefix that is acually used
index - the table index
Method Detail

equalString

public boolean equalString(java.lang.String str,
                           int len)
Tests if the string argument is equal to the string in this symbol.

Parameters:
str - the string to compare
Returns:
true if the strings are equal

equalsIndex

public boolean equalsIndex(int index)
Tests if the index argument is equal to the index of this symbol. It is only meaningful to compare indecies of symbols from the same string table.

Parameters:
index - the index to compare
Returns:
true if the indecies are equal

equals

public boolean equals(java.lang.Object another)
Tests if two symbols are equal. Symbol equality is equivalent to equality of their indecies, so it is only meaningful to compare symbols that came from the same string table.

Parameters:
another - the other symbol
Returns:
true if the symbols are equal

getString

public java.lang.String getString()
Returns the string representation of this symbol.


toString

public java.lang.String toString()
Returns a printable representation of this symbol.


clone

public abstract java.lang.Object clone()
Returns a copy of this symbol