code.term
Class Variable

java.lang.Object
  extended by code.term.Variable
All Implemented Interfaces:
TermImpl

public class Variable
extends java.lang.Object
implements TermImpl

Term representation for free variables.

Since:
June 17, 2003
Author:
Sergio Antoy

Field Summary
private static java.lang.IllegalStateException argException
          Exceptions thrown by Variable
static java.lang.String autoVarPrefix
          Prefix for program-generated variable names.
private static int counter
          Counter for program-generated variable names.
private static java.lang.IllegalStateException eqBool
           
private  java.lang.String name
           
private static java.lang.IllegalStateException replaceException
           
 
Constructor Summary
Variable()
          Constructor for the Variable object
Variable(java.lang.String name)
          Constructor for the Variable object
 
Method Summary
<R,T> R
accept(code.term.visitor.TermVisitor<R,T> v, T o)
          Accepts the visitor by passing this term as a parameter to the visit method of the visitor.
 Term[] getArgument()
          Returns an empty list of terms since free variables do not have arguments.
 Term getArgument(byte number)
          Throws an exception since free variables do not have arguments.
 Instruction[] getCode()
          Returns an empty list since free variables are not rewritten.
 byte getKind()
          Returns the kind for variables.
 java.lang.String getName()
          Returns the name of this variable.
 int getRoot()
          Returns the root id of this term.
 java.lang.String getRootSymbol()
          Returns the root symbol of this term.
 boolean isHNF()
          Returns true since free variables are in head normal form.
 boolean isNF()
          Returns true since variables are in normal form.
 java.lang.String toString()
          Returns the String representation of this variable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

counter

private static int counter
Counter for program-generated variable names.


autoVarPrefix

public static final java.lang.String autoVarPrefix
Prefix for program-generated variable names.

See Also:
Constant Field Values

argException

private static final java.lang.IllegalStateException argException
Exceptions thrown by Variable


replaceException

private static final java.lang.IllegalStateException replaceException

eqBool

private static final java.lang.IllegalStateException eqBool

name

private final java.lang.String name
Constructor Detail

Variable

public Variable(java.lang.String name)
Constructor for the Variable object

Parameters:
name - The name of this variable

Variable

public Variable()
Constructor for the Variable object

Method Detail

getRootSymbol

public java.lang.String getRootSymbol()
Returns the root symbol of this term.

Specified by:
getRootSymbol in interface TermImpl
Returns:
The rootSymbol value

getRoot

public int getRoot()
Returns the root id of this term.

Specified by:
getRoot in interface TermImpl
Returns:
The root value

getArgument

public Term[] getArgument()
Returns an empty list of terms since free variables do not have arguments.

Specified by:
getArgument in interface TermImpl
Returns:
The argument value

getArgument

public Term getArgument(byte number)
Throws an exception since free variables do not have arguments.

Specified by:
getArgument in interface TermImpl
Parameters:
number - Description of the Parameter
Returns:
The argument value

getKind

public byte getKind()
Returns the kind for variables.

Specified by:
getKind in interface TermImpl
Returns:
The kind value

getName

public java.lang.String getName()
Returns the name of this variable.

Returns:
String

getCode

public Instruction[] getCode()
Returns an empty list since free variables are not rewritten.

Specified by:
getCode in interface TermImpl
Returns:
The code value

isHNF

public boolean isHNF()
Returns true since free variables are in head normal form.

Specified by:
isHNF in interface TermImpl
Returns:
The hNF value

isNF

public boolean isNF()
Returns true since variables are in normal form.

Specified by:
isNF in interface TermImpl
Returns:
The nF value

toString

public java.lang.String toString()
Returns the String representation of this variable. To get the string representation you can use the ToStringTermVisitor. This method is just a wrapper for this. I included this wrapper since PrintAsTxtLoadable seems to be called in a number of places on a variable.

Overrides:
toString in class java.lang.Object

accept

public <R,T> R accept(code.term.visitor.TermVisitor<R,T> v,
                      T o)
Accepts the visitor by passing this term as a parameter to the visit method of the visitor.

Specified by:
accept in interface TermImpl
Returns:
Object