unsw.cse.framescript
Class Compound

java.lang.Object
  extended by unsw.cse.framescript.Term
      extended by unsw.cse.framescript.Compound

public class Compound
extends Term

The class represents all function/subroutine references and calls.

Author:
mmcgill

Constructor Summary
Compound(Atom functor)
          Creates a Compound with 0 arguements.
Compound(Atom functor, Term arg1)
          Creates a Compound with 1 argument.
Compound(Atom functor, Term arg1, Term arg2)
          Creates a Compound with 2 arguements.
Compound(Atom functor, java.util.Vector args)
          Creates a Compound with a list of arguements.
 
Method Summary
 Term assign(Instance currentObject, Term arg, StackFrame frame)
          Assigns a value to a Term.
 java.lang.String asString(int indentLevel, boolean inPattern)
          Turns the Term into a string.
 boolean equals(Term t)
          Compares two Terms for equality.
 Term eval(Instance currentObject, StackFrame frame)
          Evalutes the function call.
 boolean fullMatch(unsw.cse.framescript.InputPattern input, Instance current, StackFrame frame)
          Matches the Term to the current position in an input pattern.
 Term mapVars(FSList vars)
          Maps atoms to variables from the list of variables.
 boolean match(unsw.cse.framescript.InputPattern input, Instance current, StackFrame frame)
          Matches the Term to the current position in an input pattern.
 java.lang.String toString()
          Turns the Term into a string.
 
Methods inherited from class unsw.cse.framescript.Term
indents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Compound

public Compound(Atom functor)
Creates a Compound with 0 arguements.

Parameters:
functor - name of the function

Compound

public Compound(Atom functor,
                Term arg1)
Creates a Compound with 1 argument.

Parameters:
functor - name of the function
arg1 - the argument

Compound

public Compound(Atom functor,
                Term arg1,
                Term arg2)
Creates a Compound with 2 arguements.

Parameters:
functor - name of the function
arg1 - the first arguement
arg2 - the second arguement

Compound

public Compound(Atom functor,
                java.util.Vector args)
Creates a Compound with a list of arguements.

Parameters:
functor - the name of the function
args - the arguements to the function
Method Detail

eval

public Term eval(Instance currentObject,
                 StackFrame frame)
          throws FSException
Evalutes the function call.

Specified by:
eval in class Term
Parameters:
currentObject - the enclosing instance frame for the code being evaluated
frame - StackFrame that holds the values for any variables
Returns:
the result of the evaluation
Throws:
FSException - if any errors occur in performing the evaluation

equals

public boolean equals(Term t)
Description copied from class: Term
Compares two Terms for equality.

Specified by:
equals in class Term
Parameters:
t - Term to be compared to
Returns:
true if the Terms are equal, false otherwise

match

public boolean match(unsw.cse.framescript.InputPattern input,
                     Instance current,
                     StackFrame frame)
              throws FSException
Description copied from class: Term
Matches the Term to the current position in an input pattern.

Overrides:
match in class Term
Parameters:
input - the input the Term is being matched against
current - the enclosing instance frame for the code being evaluated
frame - StackFrame that holds the values for any variables
Returns:
true if it matches else false
Throws:
FSException - if any errors occur during the match process

fullMatch

public boolean fullMatch(unsw.cse.framescript.InputPattern input,
                         Instance current,
                         StackFrame frame)
                  throws FSException
Description copied from class: Term
Matches the Term to the current position in an input pattern.

Overrides:
fullMatch in class Term
Parameters:
input - the input the Term is being matched against
current - the enclosing instance frame for the code being evaluated
frame - StackFrame that holds the values for any variables
Returns:
true if it matches else false
Throws:
FSException - if any errors occur during the match process

assign

public Term assign(Instance currentObject,
                   Term arg,
                   StackFrame frame)
            throws FSException
Description copied from class: Term
Assigns a value to a Term. Most Terms cannot be assigned values so the default is to throw an error.

Overrides:
assign in class Term
Parameters:
currentObject - the enclosing instance frame for the code being evaluated that is performing the assignment
arg - the unevaluated value to be assigned to the Term
frame - StackFrame that holds the values for any variables
Returns:
the valuse assigned to the Term
Throws:
FSException - if assignment cannot be performed

mapVars

public Term mapVars(FSList vars)
             throws SyntaxError
Description copied from class: Term
Maps atoms to variables from the list of variables.

Overrides:
mapVars in class Term
Parameters:
vars - a list of variables to be mapped
Returns:
a clone of the Term where all the variables have been mapped
Throws:
SyntaxError - if in performing the mapping it finds an invalid variable name

toString

public java.lang.String toString()
Description copied from class: Term
Turns the Term into a string.

Specified by:
toString in class Term

asString

public java.lang.String asString(int indentLevel,
                                 boolean inPattern)
Description copied from class: Term
Turns the Term into a string.

Overrides:
asString in class Term
Parameters:
indentLevel - indentation level to uses for any subsequent lines in the string
inPattern - whether or not to format the string as though it is inside a pattern
Returns:
a string representing the Term