ubc.cs.JLog.Builtins
Class jUnaryArithmetic

java.lang.Object
  extended by ubc.cs.JLog.Foundation.jType
      extended by ubc.cs.JLog.Terms.jTerm
          extended by ubc.cs.JLog.Terms.iPredicate
              extended by ubc.cs.JLog.Terms.jBuiltinPredicate
                  extended by ubc.cs.JLog.Terms.jUnaryBuiltinPredicate
                      extended by ubc.cs.JLog.Builtins.jUnaryArithmetic
All Implemented Interfaces:
iArithmetic, iType, iUnifiable, iConsultable, iName, iNameArity, iTerm, iValue
Direct Known Subclasses:
jAbs, jBitwiseNegation, jIsInteger, jIsReal, jMinus, jPlus, jRandom, jRealUnaryArithmetic, jRound, jTruncate

public abstract class jUnaryArithmetic
extends jUnaryBuiltinPredicate
implements iArithmetic

The abstract class for unary arithmetic operators.

Author:
Glendon Holst

Field Summary
 
Fields inherited from class ubc.cs.JLog.Terms.jUnaryBuiltinPredicate
rhs
 
Fields inherited from class ubc.cs.JLog.Foundation.jType
type
 
Fields inherited from interface ubc.cs.JLog.Builtins.iArithmetic
MAX
 
Fields inherited from interface ubc.cs.JLog.Terms.iTerm
EQUAL, GREATER_THAN, LESS_THAN
 
Fields inherited from interface ubc.cs.JLog.Foundation.iType
TYPE_ARITHMETIC, TYPE_ATOM, TYPE_BUILTINPREDICATE, TYPE_COMMAND, TYPE_COMPARE, TYPE_COMPOUND, TYPE_CONS, TYPE_IF, TYPE_INTEGER, TYPE_LIST, TYPE_NULLLIST, TYPE_NUMERICCOMPARE, TYPE_OBJECT, TYPE_OPERATOR, TYPE_OR, TYPE_ORPREDICATE, TYPE_PREDICATE, TYPE_PREDICATETERMS, TYPE_REAL, TYPE_TYPE, TYPE_UNARYARITHMETIC, TYPE_UNARYOPERATOR, TYPE_UNDEFINED, TYPE_VARIABLE
 
Constructor Summary
jUnaryArithmetic(jTerm r)
           
 
Method Summary
 void addGoals(jGoal g, iGoalStack goals)
          Arithmetics are intended as expressions for is, if used a predicate they fail.
 void addGoals(jGoal g, jVariable[] vars, iGoalStack goals)
          Arithmetics are intended as expressions for is, if used a predicate they fail.
 int getPriority()
          Return priority value 0..MAX for operator precedence.
 jTerm getValue()
          Return the value of this object after.
protected abstract  int operatorInt(int r)
          Perform the integer operations specified by this instance on the given integer, and returns the integer result.
protected abstract  float operatorReal(float r)
          Perform the float operations specified by this instance on the given float, and returns the float result.
 boolean prove(jUnaryArithmeticGoal ag)
          Some arithmetics may need to do double duty as istype predicates, so they can override this.
 java.lang.String toString(boolean usename)
          Produces a string identifying this term, suitable for display to the console.
 
Methods inherited from class ubc.cs.JLog.Terms.jUnaryBuiltinPredicate
compareArguments, consult, consultReset, copy, duplicate, duplicate, enumerateVariables, equivalenceArguments, getArguments, getArity, getRHS, isConsultNeeded, prove, registerUnboundVariables, registerVariables, unifyArguments
 
Methods inherited from class ubc.cs.JLog.Terms.jBuiltinPredicate
equivalence, unify
 
Methods inherited from class ubc.cs.JLog.Terms.iPredicate
compare
 
Methods inherited from class ubc.cs.JLog.Terms.jTerm
compare, copy, getName, getTerm, requiresCompleteVariableState, toString
 
Methods inherited from class ubc.cs.JLog.Foundation.jType
getType, objectToString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ubc.cs.JLog.Terms.iName
getName
 

Constructor Detail

jUnaryArithmetic

public jUnaryArithmetic(jTerm r)
Method Detail

getValue

public jTerm getValue()
Description copied from interface: iValue
Return the value of this object after.

Specified by:
getValue in interface iTerm
Specified by:
getValue in interface iValue
Overrides:
getValue in class jTerm
Returns:
jTerm which represents the evaluated value of this instance, or the value bound to this instance, in the case of a variable.

operatorInt

protected abstract int operatorInt(int r)
Perform the integer operations specified by this instance on the given integer, and returns the integer result.

Parameters:
r - The operand.
Returns:
The result of op r where op is specified by this instance.

operatorReal

protected abstract float operatorReal(float r)
Perform the float operations specified by this instance on the given float, and returns the float result.

Parameters:
r - The operand.
Returns:
The result of op r where op is specified by this instance.

prove

public boolean prove(jUnaryArithmeticGoal ag)
Some arithmetics may need to do double duty as istype predicates, so they can override this.


addGoals

public void addGoals(jGoal g,
                     jVariable[] vars,
                     iGoalStack goals)
Arithmetics are intended as expressions for is, if used a predicate they fail.

Overrides:
addGoals in class jUnaryBuiltinPredicate
Parameters:
g - The super-goal jGoal for the sub-goal that this function will add.
vars - The vector of duplicate variables produced from the previous call to registerVariables. Needed for call to duplicate.
goals - The iGoalStack to add the goal to.

addGoals

public void addGoals(jGoal g,
                     iGoalStack goals)
Arithmetics are intended as expressions for is, if used a predicate they fail.

Overrides:
addGoals in class jUnaryBuiltinPredicate
Parameters:
g - The super-goal jGoal for the sub-goal that this function will add.
goals - The iGoalStack to add the goal to.

getPriority

public int getPriority()
Description copied from interface: iArithmetic
Return priority value 0..MAX for operator precedence. Non-operator terms have max priority.

Specified by:
getPriority in interface iArithmetic
Returns:
the priority of this operator (lower priority number is higher precedence).

toString

public java.lang.String toString(boolean usename)
Description copied from class: jTerm
Produces a string identifying this term, suitable for display to the console. param usename determines whether to display variables by name or identity. false is the default for displaying the term, true for displaying this term in a user query.

Specified by:
toString in interface iTerm
Overrides:
toString in class jUnaryBuiltinPredicate
Returns:
String which is a textual representation of this term.