|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectunsw.cse.framescript.Term
unsw.cse.framescript.Subr
public abstract class Subr
Abstract class that provides the common code for all subroutines and FrameScript written functions.
Field Summary | |
---|---|
protected Atom |
functor
The name of the function. |
Constructor Summary | |
---|---|
Subr(java.lang.String str)
Creates a subroutine for any any number of arguments. |
|
Subr(java.lang.String str,
int nArgs)
Creates a subroutine for a specific number of arguments. |
Method Summary | |
---|---|
abstract Term |
apply(Instance currentObject,
Term[] args,
StackFrame frame)
This is the method that needs to be implemented for each subroutine. |
protected Alternatives |
check_alternatives(Instance currentObject,
Term[] args,
int n,
StackFrame frame)
Convenience routine to check alternatives arguments for built-in functions. |
protected Atom |
check_atom(Instance currentObject,
Term[] args,
int n,
StackFrame frame)
Convenience routine to check atom arguments for built-in functions. |
protected Atom |
check_boolean(Instance currentObject,
Term[] args,
int n,
StackFrame frame)
Convenience routine to check boolean arguments for built-in functions. |
protected Compound |
check_compound(Instance currentObject,
Term[] args,
int n,
StackFrame frame)
Convenience routine to check compound arguments for built-in functions. |
protected Domain |
check_domain(Instance currentObject,
Term[] args,
int n,
StackFrame frame)
Convenience routine to check domain arguments for built-in functions. |
protected ExprList |
check_exprlist(Instance currentObject,
Term[] args,
int n,
StackFrame frame)
Convenience routine to check expression list arguments for built-in functions. |
protected Frame |
check_frame(Instance currentObject,
Term[] args,
int n,
StackFrame frame)
Convenience routine to check frame arguments for built-in functions. |
protected Generic |
check_generic(Instance currentObject,
Term[] args,
int n,
StackFrame frame)
Convenience routine to check generic frame arguments for built-in functions. |
protected Instance |
check_instance(Instance currentObject,
Term[] args,
int n,
StackFrame frame)
Convenience routine to check instance frame arguments for built-in functions. |
protected FSInteger |
check_integer(Instance currentObject,
Term[] args,
int n,
StackFrame frame)
Convenience routine to check integer arguments for built-in functions. |
protected FSList |
check_list(Instance currentObject,
Term[] args,
int n,
StackFrame frame)
Convenience routine to check list arguments for built-in functions. |
protected FSNumber |
check_number(Instance currentObject,
Term[] args,
int n,
StackFrame frame)
Convenience routine to check numerical arguments for built-in functions. |
protected Pattern |
check_pattern(Instance currentObject,
Term[] args,
int n,
StackFrame frame)
Convenience routine to check pattern arguments for built-in functions. |
protected RDR |
check_rdr(Instance currentObject,
Term[] args,
int n,
StackFrame frame)
Convenience routine to check RDR arguments for built-in functions. |
protected Script |
check_script(Instance currentObject,
Term[] args,
int n,
StackFrame frame)
Convenience routine to check script arguments for built-in functions. |
protected Sequence |
check_sequence(Instance currentObject,
Term[] args,
int n,
StackFrame frame)
Convenience routine to check sequence arguments for built-in functions. |
protected FSString |
check_string(Instance currentObject,
Term[] args,
int n,
StackFrame frame)
Convenience routine to check string arguments for built-in functions. |
boolean |
equals(Term t)
Compares two Terms for equality. |
Term |
eval(Instance currentObject,
StackFrame stackframe)
Evaluates a Term. |
protected Domain |
getCurrentDomain(StackFrame frame)
Method for subroutines to get the current domain. |
Atom |
getSlotName(Term arg,
StackFrame frame)
Helper function for getting the hard coded name of a slot from an argument. |
FSException |
hardCodeSlotNames(Term found,
StackFrame frame)
Throws an error with standard message if a function expects a slot name to be hard coded in FrameScript but it isn't. |
FSException |
noEnclosingInstance(StackFrame frame)
Throws an error with standard message if a function expects an enclosing instance frame |
static FSException |
notDefined(Atom functor,
StackFrame frame)
Method for throwing errors with a standard error message if a function has not been defined. |
FSException |
notForNArgs(int nArgs,
StackFrame frame)
Method for throwing an error with standard error message if a subroutine is not defined to handle a given number of arguments. |
FSException |
notImplemented(StackFrame frame)
Throws an error if a subroutine is defined but not actually implemented. |
java.lang.String |
toString()
Turns the Term into a string. |
Methods inherited from class unsw.cse.framescript.Term |
---|
assign, asString, fullMatch, indents, mapVars, match |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected Atom functor
Constructor Detail |
---|
public Subr(java.lang.String str)
str
- the name of the functionpublic Subr(java.lang.String str, int nArgs) throws FSException
str
- the name of the functionnArgs
- the number of arguments for the function
FSException
- if the function is already defined for any number of argumentsMethod Detail |
---|
public abstract Term apply(Instance currentObject, Term[] args, StackFrame frame) throws FSException
currentObject
- the enclosing instance frameargs
- the arguments to the subroutineframe
- the StackFrame with the variable values
FSException
- if there are problems running the subroutinepublic static FSException notDefined(Atom functor, StackFrame frame) throws FSException
functor
- the name of the functionframe
- the current StackFrame
FSException
- a standardised errorpublic FSException notForNArgs(int nArgs, StackFrame frame) throws FSException
nArgs
- the number of arguments not expectedframe
- the current StackFrame
FSException
- a standardised errorpublic FSException notImplemented(StackFrame frame) throws FSException
frame
- the current StackFrame
FSException
- a standardised errorpublic Atom getSlotName(Term arg, StackFrame frame) throws FSException
arg
- the argument from which to get the slot nameframe
- the current state of the stack
FSException
- if the argument is not a hard coded namepublic FSException hardCodeSlotNames(Term found, StackFrame frame) throws FSException
found
- the found termframe
- the current StackFrame
FSException
- a standardised errorpublic FSException noEnclosingInstance(StackFrame frame) throws FSException
frame
- the current StackFrame
FSException
- a standardised errorpublic Term eval(Instance currentObject, StackFrame stackframe) throws FSException
Term
eval
in class Term
currentObject
- the enclosing instance frame for the code being evaluatedstackframe
- StackFrame that holds the values for any variables
FSException
- if any errors occur in performing the evaluationpublic boolean equals(Term t)
Term
equals
in class Term
t
- Term to be compared to
public java.lang.String toString()
Term
toString
in class Term
protected Alternatives check_alternatives(Instance currentObject, Term[] args, int n, StackFrame frame) throws FSException
currentObject
- the current enclosing instance framearg
- the arguments to the functionn
- the index of the argument being checkedframe
- a StackFrame containing contextual information
FRSerror
- if the alternatives isn't an atom
FSException
protected Atom check_atom(Instance currentObject, Term[] args, int n, StackFrame frame) throws FSException
currentObject
- the current enclosing instance framearg
- the arguments to the functionn
- the index of the argument being checkedframe
- a StackFrame containing contextual information
FRSerror
- if the argument isn't an atom
FSException
protected Atom check_boolean(Instance currentObject, Term[] args, int n, StackFrame frame) throws FSException
currentObject
- the current enclosing instance framearg
- the arguments to the functionn
- the index of the argument being checkedframe
- a StackFrame containing contextual information
FRSerror
- if the argument isn't a boolean
FSException
protected Compound check_compound(Instance currentObject, Term[] args, int n, StackFrame frame) throws FSException
currentObject
- the current enclosing instance framearg
- the arguments to the functionn
- the index of the argument being checkedframe
- a StackFrame containing contextual information
FRSerror
- if the argument isn't a compound
FSException
protected Domain check_domain(Instance currentObject, Term[] args, int n, StackFrame frame) throws FSException
currentObject
- the current enclosing instance framearg
- the arguments to the functionn
- the index of the argument being checkedframe
- a StackFrame containing contextual information
FRSerror
- if the argument isn't a domain
FSException
protected ExprList check_exprlist(Instance currentObject, Term[] args, int n, StackFrame frame) throws FSException
currentObject
- the current enclosing instance framearg
- the arguments to the functionn
- the index of the argument being checkedframe
- a StackFrame containing contextual information
FRSerror
- if the argument isn't a FrameScript expression list
FSException
protected Frame check_frame(Instance currentObject, Term[] args, int n, StackFrame frame) throws FSException
currentObject
- the current enclosing instance framearg
- the arguments to the functionn
- the index of the argument being checkedframe
- a StackFrame containing contextual information
FRSerror
- if the argument isn't a frame
FSException
protected Generic check_generic(Instance currentObject, Term[] args, int n, StackFrame frame) throws FSException
currentObject
- the current enclosing instance framearg
- the arguments to the functionn
- the index of the argument being checkedframe
- a StackFrame containing contextual information
FRSerror
- if the argument isn't a generic frame
FSException
protected Instance check_instance(Instance currentObject, Term[] args, int n, StackFrame frame) throws FSException
currentObject
- the current enclosing instance framearg
- the arguments to the functionn
- the index of the argument being checkedframe
- a StackFrame containing contextual information
FRSerror
- if the argument isn't an instance frame
FSException
protected FSInteger check_integer(Instance currentObject, Term[] args, int n, StackFrame frame) throws FSException
currentObject
- the current enclosing instance framearg
- the arguments to the functionn
- the index of the argument being checkedframe
- a StackFrame containing contextual information
FRSerror
- if the argument isn't an integer
FSException
protected FSList check_list(Instance currentObject, Term[] args, int n, StackFrame frame) throws FSException
currentObject
- the current enclosing instance framearg
- the arguments to the functionn
- the index of the argument being checkedframe
- a StackFrame containing contextual information
FRSerror
- if the argument isn't a list
FSException
protected FSNumber check_number(Instance currentObject, Term[] args, int n, StackFrame frame) throws FSException
currentObject
- the current enclosing instance framearg
- the arguments to the functionn
- the index of the argument being checkedframe
- a StackFrame containing contextual information
FRSerror
- if the argument isn't a number
FSException
protected Pattern check_pattern(Instance currentObject, Term[] args, int n, StackFrame frame) throws FSException
currentObject
- the current enclosing instance framearg
- the arguments to the functionn
- the index of the argument being checkedframe
- a StackFrame containing contextual information
FRSerror
- if the argument isn't a pattern
FSException
protected RDR check_rdr(Instance currentObject, Term[] args, int n, StackFrame frame) throws FSException
currentObject
- the current enclosing instance framearg
- the arguments to the functionn
- the index of the argument being checkedframe
- a StackFrame containing contextual information
FRSerror
- if the argument isn't an RDR
FSException
protected Script check_script(Instance currentObject, Term[] args, int n, StackFrame frame) throws FSException
currentObject
- the current enclosing instance framearg
- the arguments to the functionn
- the index of the argument being checkedframe
- a StackFrame containing contextual information
FRSerror
- if the argument isn't a script
FSException
protected Sequence check_sequence(Instance currentObject, Term[] args, int n, StackFrame frame) throws FSException
currentObject
- the current enclosing instance framearg
- the arguments to the functionn
- the index of the argument being checkedframe
- a StackFrame containing contextual information
FRSerror
- if the argument isn't a sequence
FSException
protected FSString check_string(Instance currentObject, Term[] args, int n, StackFrame frame) throws FSException
currentObject
- the current enclosing instance framearg
- the arguments to the functionn
- the index of the argument being checkedframe
- a StackFrame containing contextual information
FRSerror
- if the argument isn't a string
FSException
protected Domain getCurrentDomain(StackFrame frame) throws FSException
frame
- a StackFrame containing contextual information
FSException
- if the input pattern is corrupted or there is no domain
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |