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

Variable Index

 o functions
The custom functions defined by the robot type.
 o initialBeepers
Defined by the DefineInitialBeepers statement.
 o parent
Defined by the IsLikeA statement.
 o variables
The variables defined by the robot type.

Constructor Index

 o RobotType(String, RobotType)

Method Index

 o addFunction(Function)
Adds the given function to this RobotType, first ensuring that the name is unique.
 o addVariable(Variable)
Adds the given variable to this RobotType, first ensuring that the name is unique.
 o buildVariableString(String)
Called by a Robot or a RobotType derived from this one.
 o define(Node, RobotWorld)
Defines a new robot type from a branch of the abstract syntax tree.
 o EnsureUniqueFunc(String)
Ensures that a name is not already associated with a function defined in this RobotType or an ancestor.
 o EnsureUniqueVar(String)
Ensures that a name is not already associated with a variable defined in this RobotType or an ancestor.
 o getFunction(String)
Returns the function with the given name, if it exists in this RobotType or any ancestor.
 o getVariable(String)
Returns the variable with the given name, if it exists in this RobotType or any ancestor.

Variables

 o initialBeepers
 public int initialBeepers
Defined by the DefineInitialBeepers statement.

 o parent
 private RobotType parent
Defined by the IsLikeA statement.

 o functions
 private SymbolTable functions
The custom functions defined by the robot type.

 o variables
 private SymbolTable variables
The variables defined by the robot type.

Constructors

 o RobotType
 public RobotType(String inName,
                  RobotType inParent) throws NameLengthException

Methods

 o 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
 o 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.
 o 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
 o 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.
 o 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.
 o 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.
 o 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
 o 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