|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.flagstone.translate.ASNode
public final class ASNode
ASNode is the class used by the parser to construct a tree representation of an ActionScript file based on the parser grammar. Node trees can also be constructed 'manually' and then encoded to give the binary representation of the byte-codes and actions that will be executed by the Flash Player. For example, the node tree for the ActionScript statement:
c = a + b;Can be represented using the following code to build the tree.
ASNode a = new ASNode(ASNode.Identifier, "a"); ASNode b = new ASNode(ASNode.Identifier, "b"); ASNode c = new ASNode(ASNode.Identifier, "c"); ASNode add = new ASNode(ASNode.Add, a, b); ASNode assign = new ASNode(a, add);The ASNode class defines a full range of node types ranging from specifying literals through to complex structures such as iterative and conditional constructs such as for loops and if/else blocks. The simplest method for determining the structure of the trees that represent different structure in ActionScript is to use the Interpreter class provided in the framework and dump out the structure of the parsed code.
Field Summary | |
---|---|
static int |
Add
Add operation |
static int |
And
|
static int |
Array
Array nodes are used to represent any list of ActionScript statements. |
static int |
ASR
Arithmetic Shift Right operation |
static int |
Assign
Assign, = |
static int |
AssignAdd
Assign add, += |
static int |
AssignASR
Assign arithmetic shift right, >>= |
static int |
AssignBitAnd
Assign bitwise-AND, &= |
static int |
AssignBitOr
Assign bitwise-OR, |= |
static int |
AssignBitXOr
Assign bitwise-exclusive-OR, ^= |
static int |
AssignDiv
Assign divide, /= |
static int |
AssignLSL
Assign logical shift left, <<= |
static int |
AssignLSR
Assign logical shift right, >>>= |
static int |
AssignMod
Assign modulo, %= |
static int |
AssignMul
Assign multiply, *= |
static int |
AssignSub
Assign subtract, -= |
static int |
Attribute
Use to represent an attribute of an object |
static int |
BitAnd
Bitwise AND operation |
static int |
BitNot
Unary bit-not |
static int |
BitOr
Bitwise OR operation |
static int |
BitXOr
Bitwise Exclusive-OR operation |
static int |
BooleanLiteral
Use to represent a boolean value |
static int |
Break
Use to represent break statements |
static int |
Button
Button nodes are used to represent the on() block statement in ActionScript. |
static int |
Catch
|
static int |
Continue
< Use to represent continue statements |
static int |
DefineArray
Use to represent an anonyomus array. |
static int |
DefineAttribute
Use to represent an attribute on a user defined object. |
static int |
DefineFunction
Use to represent a user defined function. |
static int |
DefineMethod
Use to represent a method on a user defined object. |
static int |
DefineObject
Use to represent a user defined object. |
static int |
DefineVariable
Use to represent a var statement |
static int |
Delete
Object reclamation |
static int |
Div
Divide operation |
static int |
Do
Use to represent do..while loops |
static int |
DoubleLiteral
Use to represent an double-precision floating point value |
static int |
EndInitClip
|
static int |
Equal
Equal comparison |
static int |
Exception
|
static int |
Finally
|
static int |
For
Use to represent for loops |
static int |
ForIn
Use to represent for..in statements |
static int |
Function
Use to represent the name of one of ActionScript's built-in functions. |
static int |
GreaterThan
Greater Than comparison |
static int |
GreaterThanEqual
Greater Than or Equal comparison |
static int |
Identifier
Use to represent a variable |
static int |
If
Use to represent if statements |
static int |
InitClip
|
static int |
InstanceOf
Object identity |
static int |
IntegerLiteral
Use to represent an integer value |
static int |
Label
|
static int |
LessThan
Less Than comparison |
static int |
LessThanEqual
Less Than or Equal comparison |
static int |
List
|
static int |
LogicalAnd
Logical AND operation |
static int |
LogicalOr
Logical OR operation |
static int |
LSL
Logical Shift Left operation |
static int |
LSR
Logical Shift Right operation |
static int |
Method
Use to represent the name of a method |
static int |
Minus
Unary minus |
static int |
Mod
Modulo operation |
static int |
MovieClip
MovieClip nodes are used to represent the onClipEvent() block statement in ActionScript. |
static int |
Mul
Multiply operation |
static int |
NewObject
Use to represent new statements for creating instances of objects. |
static int |
NoOp
NoOp is used as a place-holder for child nodes with resorting to using null. |
static int |
Not
Unary not |
static int |
NotEqual
Not Equal comparison |
static int |
NullLiteral
Use to represent a null literal |
static int |
On
Use to represent on statements |
static int |
OnClipEvent
Use to represent onClipEvent statements |
static int |
Or
|
static int |
Plus
Unary plus |
static int |
PostDec
Post-decrement |
static int |
PostInc
Post-increment |
static int |
PreDec
Pre-decorement |
static int |
PreInc
Pre-increment |
static int |
Return
Use to represent return statements |
static int |
Select
ternary operator. |
static int |
StatementList
List nodes are used to represent groups of one or more statements. |
static int |
StrictEqual
Strict Equal comparison |
static int |
StrictNotEqual
Strict Not Equal comparison |
static int |
StringAdd
Strict Not Equal comparison |
static int |
StringEqual
|
static int |
StringGreaterThan
|
static int |
StringGreaterThanEqual
|
static int |
StringLessThanEqual
|
static int |
StringLiteral
Use to represent a string value |
static int |
StringNotEqual
|
static int |
Sub
Subtract operation |
static int |
Subscript
Use to represent subscript operation when accessing the elements of an array. |
static int |
Switch
|
static int |
Throw
|
static int |
Try
|
static int |
Value
Value is an abstract node type used to group together nodes that will result in a value being generated such as subscripting an array variable or dereferencing an object's attribute. |
static int |
While
Use to represent while loops |
static int |
With
Use to represent with statements |
Constructor Summary | |
---|---|
ASNode(int nodeType)
Constructs an ASNode with the specified type. |
|
ASNode(int nodeType,
ASNode node)
Constructs an ASNode with the specified type and adds the child node. |
|
ASNode(int nodeType,
ASNode node1,
ASNode node2)
Constructs an ASNode with the specified type and adds the child nodes. |
|
ASNode(int nodeType,
double value)
Constructs an ASNode with the specified type and floating-point value. |
|
ASNode(int nodeType,
int value)
Constructs an ASNode with the specified type and integer value. |
|
ASNode(int nodeType,
java.lang.String value)
Constructs an ASNode with the specified type and string value. |
Method Summary | |
---|---|
void |
add(ASNode 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. |
ASNode |
get(int index)
Returns the node at the specified index from the array of child nodes. |
boolean |
getBoolValue()
Get the boolean value assigned to a node. |
double |
getDoubleValue()
Get the floating-point value assigned to a node. |
int |
getIntValue()
Get the integer value assigned to a node. |
int |
getNumber()
Get the number assigned to a node. |
ASNode |
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(ASNode aNode)
Returns the index position of a node in the array of child nodes. |
void |
insert(int index,
ASNode 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,
ASNode aNode)
Replaces the node at position i in the array of children. |
void |
setBoolValue(boolean value)
Set the boolean value assigned to a node. |
void |
setDoubleValue(double value)
Set the floating-point value assigned to a node. |
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int Array
public static final int Button
public static final int MovieClip
public static final int StatementList
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 BooleanLiteral
public static final int IntegerLiteral
public static final int DoubleLiteral
public static final int StringLiteral
public static final int NullLiteral
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 LogicalAnd
public static final int LogicalOr
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 final int InstanceOf
public static final int Delete
public static final int StrictEqual
public static final int StrictNotEqual
public static final int StringAdd
public static final int StringEqual
public static final int StringNotEqual
public static final int StringLessThanEqual
public static final int StringGreaterThan
public static final int StringGreaterThanEqual
public static final int Exception
public static final int Try
public static final int Catch
public static final int Finally
public static final int Switch
public static final int Throw
public static final int Label
public static final int InitClip
public static final int EndInitClip
public static final int And
public static final int Or
Constructor Detail |
---|
public ASNode(int nodeType)
nodeType
- the type of node being constructed.public ASNode(int nodeType, int value)
nodeType
- the type of node being constructed.value
- the integer value assigned to the node.public ASNode(int nodeType, double value)
nodeType
- the type of node being constructed.value
- the floating-point value assigned to the node.public ASNode(int nodeType, java.lang.String value)
nodeType
- the type of node being constructed.value
- the string assigned to the node.public ASNode(int nodeType, ASNode node)
nodeType
- the type of node being constructed.node
- a child node which will be added to the new node.public ASNode(int nodeType, ASNode node1, ASNode 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.Method Detail |
---|
public int getType()
public void setType(int type)
type
- the type assigned to the node.public boolean getBoolValue()
public void setBoolValue(boolean value)
value
- a value that will be assigned to the node.public int getIntValue()
public void setIntValue(int value)
value
- a value that will be assigned to the node.public double getDoubleValue()
public void setDoubleValue(double value)
value
- a floating-point 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 ASNode 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, ASNode 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(ASNode aNode)
aNode
- the node to be added.public void insert(int index, ASNode aNode)
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)
index
- the index of the child node to remove.
java.lang.ArrayIndexOutOfBoundsException
- if (index < 0 || index >= length).public int indexOf(ASNode aNode)
aNode
- the node to search the array of children for.
public ASNode 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)
version
- the version of Flash that control the actions that are
generated.
java.lang.IllegalArgumentException
- is the version is less than 5.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |