Interface IStoredProgram
- Namespace
- BOOSE
- Assembly
- BOOSE.dll
public interface IStoredProgram
Properties
PC
property for int pc the program counter
int PC { get; set; }
Property Value
Methods
Add(Command)
adds Command to program, calls Command.compile() Any new command needs to implement a compile() method which will be called here when the command is compiled and added.
int Add(Command C)
Parameters
C
Command
Returns
- int
index at which member was added
AddVariable(Evaluation)
Add a Var object to the StoredProgram.
void AddVariable(Evaluation Variable)
Parameters
Variable
Evaluation
Commandsleft()
Are there any commands left to execute in the program? i.e. pc (Program Counter) has not yet reached the end of the program
bool Commandsleft()
Returns
- bool
true if commands left to execute, false if the end has been reached
EvaluateExpression(string)
Evaluate the given expression by finding the values of any variables and passing the result as a String
string EvaluateExpression(string Exp)
Parameters
Exp
string
Returns
Exceptions
- StoredProgramException
Throws StoredProgramException is it cannot be evaluated. Use IsExpression() before calling to prevent this exception being thrown.
GetVarValue(string)
Return the String value of a variable. It should throw a StoredProgramException if attampt is made to retrieve a non-existant variable. i.e. don't try, check first.
string GetVarValue(string varName)
Parameters
varName
string
Returns
IsExpression(string)
Determine if the passed in string is an evaluatable expression.
bool IsExpression(string expression)
Parameters
expression
stringExpression to be tested.
Returns
- bool
true is it is an expression.
ResetProgram()
Once a program has finished executing it needs to be reset (Program Counter set to zero)
void ResetProgram()
Run()
Attempt to execute the program, throws a StoredProgram if it cannot run. The parser object should have generated a runnable program before running.
void Run()
Exceptions
VariableExists(string)
Returns true if variable has been defined in this program, false if not.
bool VariableExists(string varName)
Parameters
varName
string
Returns
- bool
True if variable exists.