EventDecl Class Next: IODecl Class Up: Event Declarations Previous: Event Declarations

EventDecl Class

EventDecl  extends UnaryInstruction and defines an event which is local to its body and has no connection with the outside. The internal event is stored in the internal field.

 
public class EventDecl extends UnaryInstruction
{
  private String internalName;
  private Event internal;

  public EventDecl(String internalName,Instruction body) 
  { 
    this.internalName = internalName; 
    internal = new Event(internalName);
    this.body = body;
  }

  public void reset(){ 
    super.reset(); 
    internal = new Event(internalName);
  }

  public Object clone()
  {
    EventDecl copy = (EventDecl)super.clone();
    copy.internal = (Event)internal.clone();
    return copy;
  }

  final public boolean equals(Instruction inst){
    return  super.equals(inst) && 
      internalName.equals(((EventDecl)inst).internalName);
  }

  final public String toString(){ 
    return "event " +  internalName + " in " + body + " end";
  }

  final protected byte activation(Machine machine) 
  { 
    Event save = machine.getEvent(internalName);
    machine.putEvent(internalName,internal);
    byte res = body.activ(machine);
    machine.putEvent(internalName,save);
    return res;
  }
}