com.svincent.moksa
Class Variable

java.lang.Object
  |
  +--com.svincent.moksa.WamObject
        |
        +--com.svincent.moksa.PrologTerm
              |
              +--com.svincent.moksa.Variable
All Implemented Interfaces:
Trailable

public class Variable
extends PrologTerm

Represents a Variable: a WAM term that contains (possibly) a reference to another WAM term.


Fields inherited from class com.svincent.moksa.PrologTerm
EmptyArray
 
Constructor Summary
Variable(PrologEngine _engine, java.lang.String _name)
          Constructs a new Variable with the given name.
 
Method Summary
 java.lang.Object accept(PrologTermVisitor v, java.lang.Object parm)
          Allow PrologTermVisitor to access this PrologTerm.
 void bind(PrologTerm newValue)
          Binds this variable to the given new value.
 PrologTerm clonePrologTerm(java.util.Map objs)
           
 PrologTerm deref()
          Dereferences this PrologTerm, retrieving the PrologTerm that it represents.
 java.lang.String getName()
          Retrieves this Variable's name.
 PrologTerm getValue()
          Retrieves this Variable's value.
 boolean isVariable()
          Returns true iff this is a Variable.
protected  void tag(java.io.PrintWriter out)
          Writes a short human-readable representation of this object to the given Writer.
 boolean unify(PrologTerm that, boolean doBindings)
          Unification algorithm.
 void untrail()
          Unbinds the Variable
 
Methods inherited from class com.svincent.moksa.PrologTerm
clonePrologTerm, evaluateExpression, floatValue, getArity, getNameConstant, getPriority, intValue, isAtom, isCompoundTerm, isConstant, isEmptyList, isFloat, isInteger, isJavaObject, isList, isNonEmptyList, isStreamId, isStructure, printVariables, setPriority, unify, unifyWithoutBindings
 
Methods inherited from class com.svincent.moksa.WamObject
tag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Variable

public Variable(PrologEngine _engine,
                java.lang.String _name)
Constructs a new Variable with the given name. Note that by default, this Variable's value will not be null. Rather, it points to itself, by WAM convention.

(There are some good consequences that come out of this slightly odd convention)

Method Detail

getName

public java.lang.String getName()
Retrieves this Variable's name.
Overrides:
getName in class PrologTerm

getValue

public PrologTerm getValue()
Retrieves this Variable's value.

isVariable

public boolean isVariable()
Returns true iff this is a Variable.
Overrides:
isVariable in class PrologTerm

accept

public java.lang.Object accept(PrologTermVisitor v,
                               java.lang.Object parm)
Allow PrologTermVisitor to access this PrologTerm.
Overrides:
accept in class PrologTerm

deref

public PrologTerm deref()
Dereferences this PrologTerm, retrieving the PrologTerm that it represents. This has no effect except for Variables.

Unbound variables and all other PrologTerms return themselves.

Overrides:
deref in class PrologTerm

bind

public void bind(PrologTerm newValue)
Binds this variable to the given new value.

Returns:
true iff the binding was successful.

unify

public boolean unify(PrologTerm that,
                     boolean doBindings)
Unification algorithm. Can cause variables to become bound. (We will eventually have a rollback mechanism to undo these bindings.)

Overrides:
unify in class PrologTerm
Returns:
true iff the two PrologTerms successfully unify.

clonePrologTerm

public PrologTerm clonePrologTerm(java.util.Map objs)
Overrides:
clonePrologTerm in class PrologTerm

untrail

public void untrail()

Unbinds the Variable

Overrides:
untrail in class PrologTerm

tag

protected void tag(java.io.PrintWriter out)
Writes a short human-readable representation of this object to the given Writer.

Overrides:
tag in class WamObject



This is documentation for Moksa Prolog, which can be found at http://www.svincent.com/moksa/

Copyright © 1999 Shawn P. Vincent.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.