public final class RMASNode
extends java.lang.Object
Encoding a tree of nodes to the binary Flash file format is performed in four stages:
1. First the nodes in the tree are re-ordered. This is used to move function definitions to the start of the block they are defined in - matching the behaviour performed by the Flash authoring application and making regression testing of the code generated against the code generated by Flash much easier.
2. then the node tree is searched for string literals, identifier and function names to construct a table of strings that is added to the start of the script, References to strings can then be made by specifying an index into the table rathe than pushing the string onto the Flash Player's stack - greatly reducing the size of the code.
3. The node tree is translated into an array of action objects. This intermediate step is required to calculate the relative branches and jumps performed when implementing if..else statements and construct such as for and while loops.
4. The array of actions generated by the translation step is then encoded to the binary data format support by Flash.
Modifier and Type | Field and Description |
---|---|
static int |
Add |
static int |
And |
static int |
ASR |
static int |
Assign |
static int |
AssignAdd |
static int |
AssignASR |
static int |
AssignBitAnd |
static int |
AssignBitOr |
static int |
AssignBitXOr |
static int |
AssignDiv |
static int |
AssignLSL |
static int |
AssignLSR |
static int |
AssignMod |
static int |
AssignMul |
static int |
AssignSub |
static int |
Attribute |
static int |
BitAnd |
static int |
BitNot |
static int |
BitOr |
static int |
BitXOr |
static int |
Break |
static int |
Button |
static java.util.HashMap |
buttonEvents |
static java.util.HashMap |
clipEvents |
static int |
Continue |
static int |
DefineArray |
static int |
DefineAttribute |
static int |
DefineFunction |
static int |
DefineMethod |
static int |
DefineObject |
static int |
DefineVariable |
static int |
Div |
static int |
Do |
static int |
Equal |
static int |
For |
static int |
ForIn |
static int |
Frame |
static int |
Function |
static int |
GreaterThan |
static int |
GreaterThanEqual |
static int |
Identifier |
static int |
If |
static int |
LessThan |
static int |
LessThanEqual |
static int |
List |
static int |
Literal |
static int |
LSL |
static int |
LSR |
static int |
Method |
static int |
Minus |
static int |
Mod |
static int |
MovieClip |
static int |
Mul |
static int |
NewObject |
static int |
NoOp |
static int |
Not |
static int |
NotEqual |
static int |
On |
static int |
OnClipEvent |
static int |
Or |
static int |
Plus |
static int |
PostDec |
static int |
PostInc |
static int |
PreDec |
static int |
PreInc |
static int |
Return |
static int |
Select |
static int |
Sub |
static int |
Subscript |
static int |
Value |
static int |
While |
static int |
With |
Constructor and Description |
---|
RMASNode(int nodeType)
Constructs an RMASNode with the specified type.
|
RMASNode(int nodeType,
int value)
Constructs an RMASNode with the specified type and integer value.
|
RMASNode(int nodeType,
RMASNode node)
Constructs an RMASNode with the specified type and adds the child node.
|
RMASNode(int nodeType,
RMASNode node1,
RMASNode node2)
Constructs an RMASNode with the specified type and adds the child nodes.
|
RMASNode(int nodeType,
java.lang.String value)
Constructs an RMASNode with the specified type and string value.
|
Modifier and Type | Method and Description |
---|---|
void |
add(RMASNode aNode)
Adds a node to the array of children.
|
int |
count()
Return the number of child nodes contained by this node.
|
void |
displayTree(java.lang.String prefix)
displayTree is used to display the structure of the node tree, with the
root starting at the current node.
|
byte[] |
encode(int version)
The encode method 'compiles' the node and all child nodes into an array
of action objects which represents the sequence of actions performed by the
Flash Player.
|
RMASNode |
get(int index)
Returns the node at the specified index from the array of child nodes.
|
int |
getIntValue()
Get the integer value assigned to a node.
|
int |
getNumber()
Get the number assigned to a node.
|
RMASNode |
getParent()
Gets the parent node of this one.
|
java.lang.String |
getStringValue()
Get the string value assigned to a node.
|
int |
getType()
Gets the type of the node.
|
int |
indexOf(RMASNode aNode)
Returns the index position of a node in the array of child nodes.
|
void |
insert(int index,
RMASNode aNode)
Inserts a node at position i in the array of children.
|
void |
remove(int index)
Removes the node at position i in the array of children.
|
void |
set(int i,
RMASNode aNode)
Replaces the node at position i in the array of children.
|
void |
setIntValue(int value)
Set the integer value assigned to a node.
|
void |
setNumber(int value)
Set the number assigned to a node.
|
void |
setStringValue(java.lang.String value)
Set the string value assigned to a node.
|
void |
setType(int type)
Sets the type of the node.
|
java.lang.String |
toString()
Returns a string containing the type of node, any associated
value and the number of children.
|
void |
validate()
validate is used to provide additional error checking not covered in the parser
grammar.
|
public static final int Frame
public static final int Button
public static final int MovieClip
public static final int List
public static final int NoOp
public static final int If
public static final int For
public static final int ForIn
public static final int While
public static final int Do
public static final int With
public static final int OnClipEvent
public static final int On
public static final int Break
public static final int Return
public static final int Continue
public static final int Value
public static final int Literal
public static final int Identifier
public static final int Attribute
public static final int Method
public static final int Function
public static final int NewObject
public static final int Subscript
public static final int DefineFunction
public static final int DefineArray
public static final int DefineObject
public static final int DefineMethod
public static final int DefineAttribute
public static final int DefineVariable
public static final int Add
public static final int Sub
public static final int Mul
public static final int Div
public static final int Mod
public static final int LSL
public static final int ASR
public static final int LSR
public static final int BitAnd
public static final int BitOr
public static final int BitXOr
public static final int And
public static final int Or
public static final int Equal
public static final int NotEqual
public static final int GreaterThan
public static final int LessThan
public static final int GreaterThanEqual
public static final int LessThanEqual
public static final int Select
public static final int Not
public static final int BitNot
public static final int Plus
public static final int Minus
public static final int PreInc
public static final int PreDec
public static final int PostInc
public static final int PostDec
public static final int Assign
public static final int AssignAdd
public static final int AssignSub
public static final int AssignMul
public static final int AssignDiv
public static final int AssignMod
public static final int AssignLSL
public static final int AssignASR
public static final int AssignLSR
public static final int AssignBitAnd
public static final int AssignBitOr
public static final int AssignBitXOr
public static java.util.HashMap buttonEvents
public static java.util.HashMap clipEvents
public RMASNode(int nodeType)
nodeType
- the type of node being constructed.public RMASNode(int nodeType, int value)
nodeType
- the type of node being constructed.value
- the integer value assigned to the node.public RMASNode(int nodeType, java.lang.String value)
nodeType
- the type of node being constructed.value
- the string assigned to the node.public RMASNode(int nodeType, RMASNode node)
nodeType
- the type of node being constructed.node
- a child node which will be added to the new node.public RMASNode(int nodeType, RMASNode node1, RMASNode node2)
nodeType
- the type of node being constructed.node1
- a child node which will be added to the new node.node2
- a child node which will be added to the new node.public int getType()
public void setType(int type)
type
- the type assigned to the node.public int getIntValue()
public void setIntValue(int value)
value
- a value that will be assigned to the node.public java.lang.String getStringValue()
public void setNumber(int value)
value
- a unique number that will be assigned to the node.public int getNumber()
public void setStringValue(java.lang.String value)
value
- a string that will be assigned to the node.public RMASNode get(int index)
index
- the index of the child node to return.java.lang.ArrayIndexOutOfBoundsException
- if (index < 0 || index >= length).public void set(int i, RMASNode aNode)
i
- the index of the child node to replace.aNode
- the node to replace the ith node.java.lang.ArrayIndexOutOfBoundsException
- if (index < 0 || index >= length).public void add(RMASNode aNode)
aNode
- the node to be added.public void insert(int index, RMASNode aNode)
If the position is outside the range of the array (i< 0 || i >= length) then an ArrayIndexOutOfBoundsException is thrown.
index
- the index of the child node to replace.aNode
- the node to replace the ith node.java.lang.ArrayIndexOutOfBoundsException
- if (index < 0 || index >= length).public void remove(int index)
If the position is outside the range of the array (i< 0 || i >= length) then an ArrayIndexOutOfBoundsException is thrown.
index
- the index of the child node to remove.java.lang.ArrayIndexOutOfBoundsException
- if (index < 0 || index >= length).public int indexOf(RMASNode aNode)
aNode
- the node to search the array of children for.public RMASNode getParent()
public int count()
public java.lang.String toString()
toString
in class java.lang.Object
public void displayTree(java.lang.String prefix)
prefix
- the string prepended to the text representation for this
node.public byte[] encode(int version)
The version of Flash for which the actions are generated is specified to ensure compatibility with future release of Flash.
IMPORTANT: The programming model changed with Flash version 5 to support stack-based actions. Earlier versions of Flash are not support. An IllegalArgumentexception will be thrown if the version is earlier than 5.
version
- the version of Flash that control the actions that are
generated.version
- the version of Flash that the script should be encoded for.IllegalArgumentexception
- is the version is less than 5.public void validate() throws ParseException
ParseException