|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectJSHOP2.CompileTimeObject
JSHOP2.Term
JSHOP2.TermConstant
public class TermConstant
Each constant symbol, both at compile time and at run time, is an instance of this class.
Field Summary | |
---|---|
private static TermConstant[] |
constants
To represent the constant symbols that we already know exist, so that there will be no duplicate copies of those symbols. |
private int |
index
Constant symbols are mapped to integers at compile time, and these integers are used thereafter to represent the constant symbols. |
Fields inherited from class JSHOP2.CompileTimeObject |
---|
endl |
Constructor Summary | |
---|---|
TermConstant(int indexIn)
To initialize this constant symbol. |
Method Summary | |
---|---|
Term |
bind(Term[] binding)
Since this term is a constant symbol, binding will not change it, therefore, simply this constant symbol itself is returned. |
boolean |
equals(Term t)
Whether or not another term is equivalent to this constant symbol. |
boolean |
findUnifier(Term t,
Term[] binding)
Find a unifier between this constant symbol and another given term. |
static TermConstant |
getConstant(int index)
To return the correponding existing constant symbol. |
int |
getIndex()
To get the index for this constant symbol. |
static void |
initialize(int size)
To initialize an array of constant symbols that we already know exist, so that there will be no duplicate copies of those symbols. |
boolean |
isGround()
This function always returns true because a constant symbol
is always ground by definition. |
java.lang.String |
toCode()
This function produces Java code to create this constant symbol as a term. |
java.lang.String |
toString()
Constant symbols are mapped at compile time to integers, this function, for printing purposes, maps them back to the strings they were before. |
Methods inherited from class JSHOP2.Term |
---|
isNil, merge, merge, print |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static TermConstant[] constants
private int index
Constructor Detail |
---|
public TermConstant(int indexIn)
indexIn
- the integer associated with this constant symbol.Method Detail |
---|
public Term bind(Term[] binding)
bind
in class Term
binding
- an array of terms, indexed by the integers associated with
variable symbols.
public boolean equals(Term t)
equals
in class Term
t
- the term being compared to this term.
true
if the two terms are equal, false
otherwise.public boolean findUnifier(Term t, Term[] binding)
findUnifier
in class Term
t
- the term with which we are finding a unifier.binding
- the unifier to be returned.
false
if the two terms can not be unified,
true
otherwise.public static TermConstant getConstant(int index)
index
- the index of the constant symbol to be returned.
public int getIndex()
public static void initialize(int size)
size
- the number of existing constant symbols.public boolean isGround()
true
because a constant symbol
is always ground by definition.
isGround
in class Term
true
if this term is ground, false
otherwise.public java.lang.String toCode()
toCode
in class CompileTimeObject
String
.public java.lang.String toString()
toString
in class Term
String
that shows the value of this
term.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |