unsw.cse.framescript
Class Generic

java.lang.Object
  extended by unsw.cse.framescript.Term
      extended by unsw.cse.framescript.Frame
          extended by unsw.cse.framescript.Generic
Direct Known Subclasses:
MobGeneric

public class Generic
extends Frame

The class that implements generic frames in FrameScript.

Author:
mmcgill

Constructor Summary
Generic(Atom name)
          Creates a generic frame with a given name.
 
Method Summary
protected  void addInstance(Instance i)
          Adds a new instance of the generic frame.
 void addParent(Generic parent)
          Adds a parent to the frame.
 java.lang.String asText()
          Writes the frame as FrameScript.
 boolean fullMatch(unsw.cse.framescript.InputPattern input, Instance current, StackFrame frame)
          Matches the Term to the current position in an input pattern.
 FSList getInstances()
          Gets all instances of the generic frame.
 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.Frame
equals, eval, initFrame
 
Methods inherited from class unsw.cse.framescript.Term
assign, asString, indents, mapVars
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Generic

public Generic(Atom name)
Creates a generic frame with a given name.

Parameters:
name - the name of the frame
Method Detail

addParent

public void addParent(Generic parent)
               throws FSException
Adds a parent to the frame.

Parameters:
parent - the parent being added, this should either be a frame or the name of a frame
Throws:
FSException - if adding t as a parent would create an inheritance cycle

addInstance

protected void addInstance(Instance i)
Adds a new instance of the generic frame.

Parameters:
i - the new instance

getInstances

public FSList getInstances()
Gets all instances of the generic frame.

Returns:
a list of all instance frames that inherit this frame

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

toString

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

Overrides:
toString in class Frame

asText

public java.lang.String asText()
Description copied from class: Frame
Writes the frame as FrameScript.

Specified by:
asText in class Frame
Returns:
a string that can hopefully be parsed to recreate the frame