unsw.cse.framescript
Class Variable

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

public class Variable
extends Term

This class implements local variable in FrameScript.

Author:
mmcgill

Field Summary
static Variable current_object
           
static Variable current_slot
           
static Variable newValue
           
static Variable oldValue
           
 
Method Summary
 Term assign(Instance currentObject, Term arg, StackFrame stackframe)
          Assigns a value to a Term.
 boolean equals(Term t)
          Compares two Terms for equality.
 Term eval(Instance currentObject, StackFrame stackframe)
          Evaluates a Term.
 Term mapVars(FSList vars)
          Maps atoms to variables from the list of variables.
static Variable newCommonVariable(Atom name)
          Adds a new variable to the list of common variables.
 java.lang.String toString()
          Turns the Term into a string.
 
Methods inherited from class unsw.cse.framescript.Term
asString, fullMatch, indents, match
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

current_object

public static Variable current_object

current_slot

public static Variable current_slot

newValue

public static Variable newValue

oldValue

public static Variable oldValue
Method Detail

newCommonVariable

public static Variable newCommonVariable(Atom name)
Adds a new variable to the list of common variables.

Parameters:
name - the name of the new variable
Returns:
the new variable

eval

public Term eval(Instance currentObject,
                 StackFrame stackframe)
          throws FSException
Description copied from class: Term
Evaluates a Term. For many Terms the result is to return itself.

Specified by:
eval in class Term
Parameters:
currentObject - the enclosing instance frame for the code being evaluated
stackframe - 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

assign

public Term assign(Instance currentObject,
                   Term arg,
                   StackFrame stackframe)
            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
stackframe - 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)
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

toString

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

Specified by:
toString in class Term