uk.co.badgersinfoil.jactionscript
Class ActionList

java.lang.Object
  |
  +--uk.co.badgersinfoil.jactionscript.ActionList

public class ActionList
extends java.lang.Object

An ActionList declares a list of actionscript bytecodes, in execution order. The list doesn't store Action objects directly, they are referred to indirectly via an ActionHandle object. This extra level of indirection allows the list to manage the targets of branch operations in the face of insertions or deletions (branch operations keep a reference to the ActionHandle of their target, rather then the target Action itself, or an integer offset into the list). ActionHandle objects form a doubly-linked list that should be managed though calls to the ActionList that owns them.

Insertion of actions into the middle of the list isn't implemented yet. Sorry.


Constructor Summary
ActionList()
           
 
Method Summary
 void accept(Visitor v)
           
 ActionHandle append(Action op)
           
 ActionHandle first()
          Returns the handle on the first Action in the list
 ActionHandle get(int pos)
           
 ActionHandle last()
          Returns the handle on the last Action in the list
 int length()
           
 ActionHandle peekNext()
          Returns a reference to the object that will be returned by the next call to append(Action).
 void pokeNext(ActionHandle handle)
          Set the ActionHandle for the next Action appended.
 void remove(ActionHandle handle)
          Removes the Action referenced by the given handle from this list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ActionList

public ActionList()
Method Detail

append

public ActionHandle append(Action op)

peekNext

public ActionHandle peekNext()
Returns a reference to the object that will be returned by the next call to append(Action).


pokeNext

public void pokeNext(ActionHandle handle)
Set the ActionHandle for the next Action appended. This can be used when you want to create a forward branch like so:
   ActionHandle target = new ActionHandle();
   list.append(new IfJumpAction(target));
   ..more appends..
   list.pokeNext(target);
   list.append(..the target Action..);
 


accept

public void accept(Visitor v)
            throws JASVisitorException
JASVisitorException

length

public int length()

first

public ActionHandle first()
Returns the handle on the first Action in the list


last

public ActionHandle last()
Returns the handle on the last Action in the list


get

public ActionHandle get(int pos)
Throws:
java.lang.IllegalArgumentException - if pos if less than 0, or beond the end of the list

remove

public void remove(ActionHandle handle)
Removes the Action referenced by the given handle from this list. If this handle was the target of any BranchAction objects, those branches will be re-targeted at the next ActionHandle in the list (or the handle given by peekNext() if you are removing the last item in the list).

Trying to remove a handle not in this list will result in undefined behaviour.