Class RobotType
java.lang.Object
|
+----Symbol
|
+----RobotType
- class RobotType
- extends Symbol
Represents a new robot type defined by the RoBOTL programmer.
- Author:
- Peter Sagerson, petersag@wpi.edu
-
functions
- The custom functions defined by the robot type.
-
initialBeepers
- Defined by the DefineInitialBeepers statement.
-
parent
- Defined by the IsLikeA statement.
-
variables
- The variables defined by the robot type.
-
RobotType(String, RobotType)
-
-
addFunction(Function)
- Adds the given function to this RobotType, first ensuring that
the name is unique.
-
addVariable(Variable)
- Adds the given variable to this RobotType, first ensuring that
the name is unique.
-
buildVariableString(String)
- Called by a
Robot or a RobotType derived
from this one.
-
define(Node, RobotWorld)
- Defines a new robot type from a branch of the abstract syntax
tree.
-
EnsureUniqueFunc(String)
- Ensures that a name is not already associated with a function defined
in this RobotType or an ancestor.
-
EnsureUniqueVar(String)
- Ensures that a name is not already associated with a variable defined
in this RobotType or an ancestor.
-
getFunction(String)
- Returns the function with the given name, if it exists in
this RobotType or any ancestor.
-
getVariable(String)
- Returns the variable with the given name, if it exists in
this RobotType or any ancestor.
initialBeepers
public int initialBeepers
- Defined by the DefineInitialBeepers statement.
parent
private RobotType parent
- Defined by the IsLikeA statement.
functions
private SymbolTable functions
- The custom functions defined by the robot type.
variables
private SymbolTable variables
- The variables defined by the robot type.
RobotType
public RobotType(String inName,
RobotType inParent) throws NameLengthException
define
public void define(Node root,
RobotWorld world)
- Defines a new robot type from a branch of the abstract syntax
tree. The root node should be the node for the NewRobotType
statement.
- Parameters:
- root - should be an ASTNRT_State
EnsureUniqueFunc
private void EnsureUniqueFunc(String name) throws DuplicateNameException
- Ensures that a name is not already associated with a function defined
in this RobotType or an ancestor.
- Throws: DuplicateNameException
- if the function is already defined.
addFunction
private void addFunction(Function f) throws DuplicateNameException
- Adds the given function to this RobotType, first ensuring that
the name is unique.
- Throws: DuplicateNameException
- if the function already exists
getFunction
public Function getFunction(String name) throws NameNotFoundException
- Returns the function with the given name, if it exists in
this RobotType or any ancestor.
- Throws: NameNotFoundException
- if the function does not exist.
EnsureUniqueVar
private void EnsureUniqueVar(String name) throws DuplicateNameException
- Ensures that a name is not already associated with a variable defined
in this RobotType or an ancestor.
- Throws: DuplicateNameException
- if the variable is already defined.
addVariable
private void addVariable(Variable v) throws DuplicateNameException
- Adds the given variable to this RobotType, first ensuring that
the name is unique.
- Throws: DuplicateNameException
- if the variable is already defined.
getVariable
public Variable getVariable(String name) throws NameNotFoundException
- Returns the variable with the given name, if it exists in
this RobotType or any ancestor. Note that the Variable object returned
is a new copy of the variable, not a reference to the object
maintained by the RobotType. This is part of the "lazy variable"
scheme.
- Throws: NameNotFoundException
- if the variable does not exist.
- See Also:
- getVariable
buildVariableString
public String buildVariableString(String used)
- Called by a
Robot or a RobotType derived
from this one.
- Returns:
- An empty string if this
RobotType has no variables
(including inherited ones).
- See Also:
- Robot