Class RMASNode
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.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic HashMapstatic HashMapstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final int
- 
Constructor SummaryConstructorsConstructorDescriptionRMASNode(int nodeType) Constructs an RMASNode with the specified type.RMASNode(int nodeType, int value) Constructs an RMASNode with the specified type and integer value.Constructs an RMASNode with the specified type and adds the child node.Constructs an RMASNode with the specified type and adds the child nodes.Constructs an RMASNode with the specified type and string value.
- 
Method SummaryModifier and TypeMethodDescriptionvoidAdds a node to the array of children.intcount()Return the number of child nodes contained by this node.voiddisplayTree(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.get(int index) Returns the node at the specified index from the array of child nodes.intGet the integer value assigned to a node.intGet the number assigned to a node.Gets the parent node of this one.Get the string value assigned to a node.intgetType()Gets the type of the node.intReturns the index position of a node in the array of child nodes.voidInserts a node at position i in the array of children.voidremove(int index) Removes the node at position i in the array of children.voidReplaces the node at position i in the array of children.voidsetIntValue(int value) Set the integer value assigned to a node.voidsetNumber(int value) Set the number assigned to a node.voidsetStringValue(String value) Set the string value assigned to a node.voidsetType(int type) Sets the type of the node.toString()Returns a string containing the type of node, any associated value and the number of children.voidvalidate()validate is used to provide additional error checking not covered in the parser grammar.
- 
Field Details- 
Framepublic static final int Frame- See Also:
 
- 
Buttonpublic static final int Button- See Also:
 
- 
MovieClippublic static final int MovieClip- See Also:
 
- 
Listpublic static final int List- See Also:
 
- 
NoOppublic static final int NoOp- See Also:
 
- 
Ifpublic static final int If- See Also:
 
- 
Forpublic static final int For- See Also:
 
- 
ForInpublic static final int ForIn- See Also:
 
- 
Whilepublic static final int While- See Also:
 
- 
Dopublic static final int Do- See Also:
 
- 
Withpublic static final int With- See Also:
 
- 
OnClipEventpublic static final int OnClipEvent- See Also:
 
- 
Onpublic static final int On- See Also:
 
- 
Breakpublic static final int Break- See Also:
 
- 
Returnpublic static final int Return- See Also:
 
- 
Continuepublic static final int Continue- See Also:
 
- 
Valuepublic static final int Value- See Also:
 
- 
Literalpublic static final int Literal- See Also:
 
- 
Identifierpublic static final int Identifier- See Also:
 
- 
Attributepublic static final int Attribute- See Also:
 
- 
Methodpublic static final int Method- See Also:
 
- 
Functionpublic static final int Function- See Also:
 
- 
NewObjectpublic static final int NewObject- See Also:
 
- 
Subscriptpublic static final int Subscript- See Also:
 
- 
DefineFunctionpublic static final int DefineFunction- See Also:
 
- 
DefineArraypublic static final int DefineArray- See Also:
 
- 
DefineObjectpublic static final int DefineObject- See Also:
 
- 
DefineMethodpublic static final int DefineMethod- See Also:
 
- 
DefineAttributepublic static final int DefineAttribute- See Also:
 
- 
DefineVariablepublic static final int DefineVariable- See Also:
 
- 
Addpublic static final int Add- See Also:
 
- 
Subpublic static final int Sub- See Also:
 
- 
Mulpublic static final int Mul- See Also:
 
- 
Divpublic static final int Div- See Also:
 
- 
Modpublic static final int Mod- See Also:
 
- 
LSLpublic static final int LSL- See Also:
 
- 
ASRpublic static final int ASR- See Also:
 
- 
LSRpublic static final int LSR- See Also:
 
- 
BitAndpublic static final int BitAnd- See Also:
 
- 
BitOrpublic static final int BitOr- See Also:
 
- 
BitXOrpublic static final int BitXOr- See Also:
 
- 
Andpublic static final int And- See Also:
 
- 
Orpublic static final int Or- See Also:
 
- 
Equalpublic static final int Equal- See Also:
 
- 
NotEqualpublic static final int NotEqual- See Also:
 
- 
GreaterThanpublic static final int GreaterThan- See Also:
 
- 
LessThanpublic static final int LessThan- See Also:
 
- 
GreaterThanEqualpublic static final int GreaterThanEqual- See Also:
 
- 
LessThanEqualpublic static final int LessThanEqual- See Also:
 
- 
Selectpublic static final int Select- See Also:
 
- 
Notpublic static final int Not- See Also:
 
- 
BitNotpublic static final int BitNot- See Also:
 
- 
Pluspublic static final int Plus- See Also:
 
- 
Minuspublic static final int Minus- See Also:
 
- 
PreIncpublic static final int PreInc- See Also:
 
- 
PreDecpublic static final int PreDec- See Also:
 
- 
PostIncpublic static final int PostInc- See Also:
 
- 
PostDecpublic static final int PostDec- See Also:
 
- 
Assignpublic static final int Assign- See Also:
 
- 
AssignAddpublic static final int AssignAdd- See Also:
 
- 
AssignSubpublic static final int AssignSub- See Also:
 
- 
AssignMulpublic static final int AssignMul- See Also:
 
- 
AssignDivpublic static final int AssignDiv- See Also:
 
- 
AssignModpublic static final int AssignMod- See Also:
 
- 
AssignLSLpublic static final int AssignLSL- See Also:
 
- 
AssignASRpublic static final int AssignASR- See Also:
 
- 
AssignLSRpublic static final int AssignLSR- See Also:
 
- 
AssignBitAndpublic static final int AssignBitAnd- See Also:
 
- 
AssignBitOrpublic static final int AssignBitOr- See Also:
 
- 
AssignBitXOrpublic static final int AssignBitXOr- See Also:
 
- 
buttonEvents
- 
clipEvents
 
- 
- 
Constructor Details- 
RMASNodepublic RMASNode(int nodeType) Constructs an RMASNode with the specified type.- Parameters:
- nodeType- the type of node being constructed.
 
- 
RMASNodepublic RMASNode(int nodeType, int value) Constructs an RMASNode with the specified type and integer value. This constructor is primarily used to create nodes representing integer literals.- Parameters:
- nodeType- the type of node being constructed.
- value- the integer value assigned to the node.
 
- 
RMASNodeConstructs an RMASNode with the specified type and string value. This constructor is primarily used to create string literals and identifiers.- Parameters:
- nodeType- the type of node being constructed.
- value- the string assigned to the node.
 
- 
RMASNodeConstructs an RMASNode with the specified type and adds the child node.- Parameters:
- nodeType- the type of node being constructed.
- node- a child node which will be added to the new node.
 
- 
RMASNodeConstructs an RMASNode with the specified type and adds the child nodes.- Parameters:
- 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.
 
 
- 
- 
Method Details- 
getTypepublic int getType()Gets the type of the node.- Returns:
- the type assigned to the node.
 
- 
setTypepublic void setType(int type) Sets the type of the node.- Parameters:
- type- the type assigned to the node.
 
- 
getIntValuepublic int getIntValue()Get the integer value assigned to a node.- Returns:
- the integer value assigned to a node.
 
- 
setIntValuepublic void setIntValue(int value) Set the integer value assigned to a node.- Parameters:
- value- a value that will be assigned to the node.
 
- 
getStringValueGet the string value assigned to a node.- Returns:
- the string value assigned to a node.
 
- 
setNumberpublic void setNumber(int value) Set the number assigned to a node.- Parameters:
- value- a unique number that will be assigned to the node.
 
- 
getNumberpublic int getNumber()Get the number assigned to a node.- Returns:
- the number assigned to a node.
 
- 
setStringValueSet the string value assigned to a node.- Parameters:
- value- a string that will be assigned to the node.
 
- 
getReturns the node at the specified index from the array of child nodes. If the index is outside the range of the array then an ArrayIndexOutOfBounds exception is thrown.- Parameters:
- index- the index of the child node to return.
- Returns:
- the ith node in the array of children.
- Throws:
- ArrayIndexOutOfBoundsException- if (index < 0 || index >= length).
 
- 
setReplaces the node at position i in the array of children. If the position is outside the range of the array (i< 0 || i >= length) then an ArrayIndexOutOfBoundsException is thrown.- Parameters:
- i- the index of the child node to replace.
- aNode- the node to replace the ith node.
- Throws:
- ArrayIndexOutOfBoundsException- if (index < 0 || index >= length).
 
- 
addAdds a node to the array of children. If the node is null then it is ignored.- Parameters:
- aNode- the node to be added.
 
- 
insertInserts a node at position i in the array of children. The size of the array is increased by one and the nodes from the insertion point onwards are moved to the right.If the position is outside the range of the array (i< 0 || i >= length) then an ArrayIndexOutOfBoundsException is thrown. - Parameters:
- index- the index of the child node to replace.
- aNode- the node to replace the ith node.
- Throws:
- ArrayIndexOutOfBoundsException- if (index < 0 || index >= length).
 
- 
removepublic void remove(int index) Removes the node at position i in the array of children. The size of the array is decreased by one and the nodes from the insertion point onwards are moved to the left.If the position is outside the range of the array (i< 0 || i >= length) then an ArrayIndexOutOfBoundsException is thrown. - Parameters:
- index- the index of the child node to remove.
- Throws:
- ArrayIndexOutOfBoundsException- if (index < 0 || index >= length).
 
- 
indexOfReturns the index position of a node in the array of child nodes. If the node is not one of the current nodes children then -1 is returned.- Parameters:
- aNode- the node to search the array of children for.
- Returns:
- the index of the node in the array of children, -1 if the node is not a child of this node.
 
- 
getParentGets the parent node of this one. If no parent is define then null is returned.- Returns:
- the parent node of this one.
 
- 
countpublic int count()Return the number of child nodes contained by this node.- Returns:
- the number of child nodes.
 
- 
toStringReturns a string containing the type of node, any associated value and the number of children.
- 
displayTreedisplayTree is used to display the structure of the node tree, with the root starting at the current node. The prefix argument is used to ident the text displayed. The level of indent is increased by appending the string " " before calling the displayTree method on each child node. This illustrates the tree structure with nodes at the same level in the tree displayed with the same level of indent.- Parameters:
- prefix- the string prepended to the text representation for this node.
 
- 
encodepublic 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. The actions are then encoded to generate the binary data that can be added to an encoded Flash file.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. - Parameters:
- version- the version of Flash that control the actions that are generated.
- version- the version of Flash that the script should be encoded for.
- Returns:
- an array of bytes containing encoded action objects.
- Throws:
- IllegalArgumentexception- is the version is less than 5.
 
- 
validatevalidate is used to provide additional error checking not covered in the parser grammar.- Throws:
- ParseException
 
 
-