slogo.instruction
Class StrictInstructionList

java.lang.Object
  extended by slogo.language.GrammarElement
      extended by slogo.instruction.Instruction
          extended by slogo.instruction.StrictInstructionList

public class StrictInstructionList
extends Instruction

A list of instructions that doesn't include a function definition. This is the definition of Strict, an instruction list can include any instruction, including a function definition, whereas a strict instruction list doesn't include these.

Constructing a strict instruction list is usually accomplished by creating an object and repeatedly calling add to add new instructions. The order in which instructions are added is the order in which they'll be executed.

Author:
Owen Astrachan

Field Summary
protected  java.util.List<Instruction> instructionList
           
 
Fields inherited from class slogo.language.GrammarElement
gelementsToValue
 
Constructor Summary
StrictInstructionList()
          Construct an empty list.
 
Method Summary
 void add(Instruction i)
          Add an instruction to this list (FIFO order for execution).
 java.lang.Object evaluate(Context c)
          Evaluate this instruction in a Context, return the result of the evaluation (the result is the last instruction executed).
 java.util.Iterator<Instruction> iterator()
          Return an iterator for accessing all the instructions.
 java.lang.String toString()
          Return a string indicating the # of instructions in the list
 
Methods inherited from class slogo.instruction.Instruction
evaluateNumericExpression
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

instructionList

protected java.util.List<Instruction> instructionList
Constructor Detail

StrictInstructionList

public StrictInstructionList()
Construct an empty list.

Method Detail

add

public void add(Instruction i)
Add an instruction to this list (FIFO order for execution).

Parameters:
i - the instruction added.

evaluate

public java.lang.Object evaluate(Context c)
Evaluate this instruction in a Context, return the result of the evaluation (the result is the last instruction executed).

Overrides:
evaluate in class Instruction
Parameters:
c - the context for the evaluation
Returns:
the result of evaluating the last expression in the list

iterator

public java.util.Iterator<Instruction> iterator()
Return an iterator for accessing all the instructions.


toString

public java.lang.String toString()
Return a string indicating the # of instructions in the list

Overrides:
toString in class java.lang.Object
Returns:
"[list of size = # instructions]"