|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--uk.co.badgersinfoil.jactionscript.analysis.SimpleStackSimulator
Builds a picture of the actionscript stack layout as each instruction is
executed, driving an implementation of StackListener
.
For example, when a NOT action is encountered, we pop an Operand off
our emulated stack, create a new Operand to hold the result, and then
pass these values to StackListener.visitNOT(Action,Operand,Operand)
.
The result-Operand's value isn't calculated, though the StackListener
implementation may fill this in. When visitNot() returns, the
SimpleStackSimulator pushes the result Operand onto the stack.
The only time that this class fills in the value for Operands is where constant values are pushed onto the stack. Without this, we wouldn't be able to resonably emulate things like function-calls, where the number of values to pop off the stack is determined by the (usually constant) value on the top of the stack.
Since no attempt is made to follow the branches in the flow of control
produced by BranchAction
subclasses, encountering any Action that is
a branch, or that is the target of a branch invalidates all our guesses
about the stack layout. Later attempts to read from this invalid part
of the stack will always produce Operands with unknown values.
Field Summary | |
protected LookupTable |
currentLookupTable
|
protected StackInfo |
stack
|
Constructor Summary | |
SimpleStackSimulator(StackListener listener)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected StackInfo stack
protected LookupTable currentLookupTable
Constructor Detail |
public SimpleStackSimulator(StackListener listener)
Method Detail |
protected void push(Operand entry)
protected Operand pop()
protected void invalidateState()
protected java.util.List popArgs()
public void visitHandle(ActionHandle handle) throws JASVisitorException
Visitor
visitHandle
in interface Visitor
JASVisitorException
public void visitEnd(ActionList list) throws JASVisitorException
Visitor
visitEnd
in interface Visitor
JASVisitorException
public void visitADD(Action action) throws JASVisitorException
visitADD
in interface Visitor
JASVisitorException
public void visitAND(Action action) throws JASVisitorException
visitAND
in interface Visitor
JASVisitorException
public void visitASCII_TO_CHAR(Action action) throws JASVisitorException
visitASCII_TO_CHAR
in interface Visitor
JASVisitorException
public void visitASCII_TO_CHAR_MB(Action action) throws JASVisitorException
visitASCII_TO_CHAR_MB
in interface Visitor
JASVisitorException
public void visitBIT_AND(Action action) throws JASVisitorException
visitBIT_AND
in interface Visitor
JASVisitorException
public void visitBIT_OR(Action action) throws JASVisitorException
visitBIT_OR
in interface Visitor
JASVisitorException
public void visitBIT_XOR(Action action) throws JASVisitorException
visitBIT_XOR
in interface Visitor
JASVisitorException
public void visitCALL(Action action) throws JASVisitorException
visitCALL
in interface Visitor
JASVisitorException
public void visitCALL_FUNCTION(Action action) throws JASVisitorException
visitCALL_FUNCTION
in interface Visitor
JASVisitorException
public void visitCALL_METHOD(Action action) throws JASVisitorException
visitCALL_METHOD
in interface Visitor
JASVisitorException
public void visitCHAR_MB_TO_ASCII(Action action) throws JASVisitorException
visitCHAR_MB_TO_ASCII
in interface Visitor
JASVisitorException
public void visitCHAR_TO_ASCII(Action action) throws JASVisitorException
visitCHAR_TO_ASCII
in interface Visitor
JASVisitorException
public void visitCLONE_SPRITE(Action action) throws JASVisitorException
visitCLONE_SPRITE
in interface Visitor
JASVisitorException
public void visitCONCAT(Action action) throws JASVisitorException
visitCONCAT
in interface Visitor
JASVisitorException
public void visitCONVERT_TO_NUMBER(Action action) throws JASVisitorException
visitCONVERT_TO_NUMBER
in interface Visitor
JASVisitorException
public void visitCONVERT_TO_STRING(Action action) throws JASVisitorException
visitCONVERT_TO_STRING
in interface Visitor
JASVisitorException
public void visitDECREMENT(Action action) throws JASVisitorException
visitDECREMENT
in interface Visitor
JASVisitorException
public void visitDEFINE_LOCAL(Action action) throws JASVisitorException
visitDEFINE_LOCAL
in interface Visitor
JASVisitorException
public void visitDEFINE_LOCAL_VALUE(Action action) throws JASVisitorException
visitDEFINE_LOCAL_VALUE
in interface Visitor
JASVisitorException
public void visitDELETE_PROPERTY(Action action) throws JASVisitorException
visitDELETE_PROPERTY
in interface Visitor
JASVisitorException
public void visitDELETE_THREAD_VARS(Action action) throws JASVisitorException
visitDELETE_THREAD_VARS
in interface Visitor
JASVisitorException
public void visitDIVIDE(Action action) throws JASVisitorException
visitDIVIDE
in interface Visitor
JASVisitorException
public void visitDUPLICATE(Action action) throws JASVisitorException
visitDUPLICATE
in interface Visitor
JASVisitorException
public void visitEND_DRAG(Action action) throws JASVisitorException
visitEND_DRAG
in interface Visitor
JASVisitorException
public void visitENUMERATE(Action action) throws JASVisitorException
visitENUMERATE
in interface Visitor
JASVisitorException
public void visitENUMERATE_OBJECT(Action action) throws JASVisitorException
visitENUMERATE_OBJECT
in interface Visitor
JASVisitorException
public void visitEQUALS(Action action) throws JASVisitorException
visitEQUALS
in interface Visitor
JASVisitorException
public void visitGET_MEMBER(Action action) throws JASVisitorException
visitGET_MEMBER
in interface Visitor
JASVisitorException
public void visitGET_PROPERTY(Action action) throws JASVisitorException
visitGET_PROPERTY
in interface Visitor
JASVisitorException
public void visitGET_TARGET_PATH(Action action) throws JASVisitorException
visitGET_TARGET_PATH
in interface Visitor
JASVisitorException
public void visitGET_TIME(Action action) throws JASVisitorException
visitGET_TIME
in interface Visitor
JASVisitorException
public void visitGET_URL2(GetURL2Action action) throws JASVisitorException
visitGET_URL2
in interface Visitor
JASVisitorException
public void visitGET_URL(GetURLAction action) throws JASVisitorException
visitGET_URL
in interface Visitor
JASVisitorException
public void visitGET_VARIABLE(Action action) throws JASVisitorException
visitGET_VARIABLE
in interface Visitor
JASVisitorException
public void visitGOTO_FRAME2(GotoFrame2Action action) throws JASVisitorException
visitGOTO_FRAME2
in interface Visitor
JASVisitorException
public void visitGOTO_FRAME(GotoFrameAction action) throws JASVisitorException
visitGOTO_FRAME
in interface Visitor
JASVisitorException
public void visitGOTO_LABEL(GotoLabelAction action) throws JASVisitorException
visitGOTO_LABEL
in interface Visitor
JASVisitorException
public void visitGREATER_THAN(Action action) throws JASVisitorException
visitGREATER_THAN
in interface Visitor
JASVisitorException
public void visitIF_JUMP(IfJumpAction action) throws JASVisitorException
visitIF_JUMP
in interface Visitor
JASVisitorException
public void visitINCREMENT(Action action) throws JASVisitorException
visitINCREMENT
in interface Visitor
JASVisitorException
public void visitINIT_ARRAY(Action action) throws JASVisitorException
visitINIT_ARRAY
in interface Visitor
JASVisitorException
public void visitINIT_OBJECT(Action action) throws JASVisitorException
visitINIT_OBJECT
in interface Visitor
JASVisitorException
public void visitINSTANCE_OF(Action action) throws JASVisitorException
visitINSTANCE_OF
in interface Visitor
JASVisitorException
public void visitJUMP(JumpAction action) throws JASVisitorException
visitJUMP
in interface Visitor
JASVisitorException
public void visitLESS_THAN(Action action) throws JASVisitorException
visitLESS_THAN
in interface Visitor
JASVisitorException
public void visitLOOKUP(LookupAction action) throws JASVisitorException
visitLOOKUP
in interface Visitor
JASVisitorException
public void visitLOOKUP_TABLE(LookupTableAction action) throws JASVisitorException
visitLOOKUP_TABLE
in interface Visitor
JASVisitorException
public void visitMODULO(Action action) throws JASVisitorException
visitMODULO
in interface Visitor
JASVisitorException
public void visitMULTIPLY(Action action) throws JASVisitorException
visitMULTIPLY
in interface Visitor
JASVisitorException
public void visitNEW_METHOD(Action action) throws JASVisitorException
visitNEW_METHOD
in interface Visitor
JASVisitorException
public void visitNEW_OBJECT(Action action) throws JASVisitorException
visitNEW_OBJECT
in interface Visitor
JASVisitorException
public void visitNEXT_FRAME(Action action) throws JASVisitorException
visitNEXT_FRAME
in interface Visitor
JASVisitorException
public void visitNOT(Action action) throws JASVisitorException
visitNOT
in interface Visitor
JASVisitorException
public void visitOR(Action action) throws JASVisitorException
visitOR
in interface Visitor
JASVisitorException
public void visitPLAY(Action action) throws JASVisitorException
visitPLAY
in interface Visitor
JASVisitorException
public void visitPOP(Action action) throws JASVisitorException
visitPOP
in interface Visitor
JASVisitorException
public void visitPREV_FRAME(Action action) throws JASVisitorException
visitPREV_FRAME
in interface Visitor
JASVisitorException
public void visitPUSH(PushAction action) throws JASVisitorException
visitPUSH
in interface Visitor
JASVisitorException
public void visitRANDOM_NUMBER(Action action) throws JASVisitorException
visitRANDOM_NUMBER
in interface Visitor
JASVisitorException
public void visitREMOVE_SPRITE(Action action) throws JASVisitorException
visitREMOVE_SPRITE
in interface Visitor
JASVisitorException
public void visitRETURN_VALUE(Action action) throws JASVisitorException
visitRETURN_VALUE
in interface Visitor
JASVisitorException
public void visitSET_MEMBER(Action action) throws JASVisitorException
visitSET_MEMBER
in interface Visitor
JASVisitorException
public void visitSET_PROPERTY(Action action) throws JASVisitorException
visitSET_PROPERTY
in interface Visitor
JASVisitorException
public void visitSET_TARGET_2(Action action) throws JASVisitorException
visitSET_TARGET_2
in interface Visitor
JASVisitorException
public void visitSET_TARGET(SetTargetAction action) throws JASVisitorException
visitSET_TARGET
in interface Visitor
JASVisitorException
public void visitSET_VARIABLE(Action action) throws JASVisitorException
visitSET_VARIABLE
in interface Visitor
JASVisitorException
public void visitSHIFT_LEFT(Action action) throws JASVisitorException
visitSHIFT_LEFT
in interface Visitor
JASVisitorException
public void visitSHIFT_RIGHT(Action action) throws JASVisitorException
visitSHIFT_RIGHT
in interface Visitor
JASVisitorException
public void visitSHIFT_RIGHT_UNSIGNED(Action action) throws JASVisitorException
visitSHIFT_RIGHT_UNSIGNED
in interface Visitor
JASVisitorException
public void visitSTART_DRAG(Action action) throws JASVisitorException
visitSTART_DRAG
in interface Visitor
JASVisitorException
public void visitSTART_FUNCTION(StartFunctionAction action) throws JASVisitorException
visitSTART_FUNCTION
in interface Visitor
JASVisitorException
public void visitSTART_WITH(Action action) throws JASVisitorException
visitSTART_WITH
in interface Visitor
JASVisitorException
public void visitSTOP(Action action) throws JASVisitorException
visitSTOP
in interface Visitor
JASVisitorException
public void visitSTOP_SOUNDS(Action action) throws JASVisitorException
visitSTOP_SOUNDS
in interface Visitor
JASVisitorException
public void visitSTORE_IN_REGISTER(StoreInRegisterAction action) throws JASVisitorException
visitSTORE_IN_REGISTER
in interface Visitor
JASVisitorException
public void visitSTRICT_EQUALS(Action action) throws JASVisitorException
visitSTRICT_EQUALS
in interface Visitor
JASVisitorException
public void visitSTRING_EQUALS(Action action) throws JASVisitorException
visitSTRING_EQUALS
in interface Visitor
JASVisitorException
public void visitSTRING_GREATER_THAN(Action action) throws JASVisitorException
visitSTRING_GREATER_THAN
in interface Visitor
JASVisitorException
public void visitSTRING_LENGTH(Action action) throws JASVisitorException
visitSTRING_LENGTH
in interface Visitor
JASVisitorException
public void visitSTRING_LENGTH_MB(Action action) throws JASVisitorException
visitSTRING_LENGTH_MB
in interface Visitor
JASVisitorException
public void visitSTRING_LESS_THAN(Action action) throws JASVisitorException
visitSTRING_LESS_THAN
in interface Visitor
JASVisitorException
public void visitSUBSTRING(Action action) throws JASVisitorException
visitSUBSTRING
in interface Visitor
JASVisitorException
public void visitSUBSTRING_MB(Action action) throws JASVisitorException
visitSUBSTRING_MB
in interface Visitor
JASVisitorException
public void visitSUBTRACT(Action action) throws JASVisitorException
visitSUBTRACT
in interface Visitor
JASVisitorException
public void visitSWAP(Action action) throws JASVisitorException
visitSWAP
in interface Visitor
JASVisitorException
public void visitTOGGLE_QUALITY(Action action) throws JASVisitorException
visitTOGGLE_QUALITY
in interface Visitor
JASVisitorException
public void visitTO_INTEGER(Action action) throws JASVisitorException
visitTO_INTEGER
in interface Visitor
JASVisitorException
public void visitTRACE(Action action) throws JASVisitorException
visitTRACE
in interface Visitor
JASVisitorException
public void visitTYPED_ADD(Action action) throws JASVisitorException
visitTYPED_ADD
in interface Visitor
JASVisitorException
public void visitTYPED_EQUALS(Action action) throws JASVisitorException
visitTYPED_EQUALS
in interface Visitor
JASVisitorException
public void visitTYPED_LESS_THAN(Action action) throws JASVisitorException
visitTYPED_LESS_THAN
in interface Visitor
JASVisitorException
public void visitTYPE_OF(Action action) throws JASVisitorException
visitTYPE_OF
in interface Visitor
JASVisitorException
public void visitUNKNOWN(UnknownAction action) throws JASVisitorException
visitUNKNOWN
in interface Visitor
JASVisitorException
public void visitWAIT_FOR_FRAME(WaitForFrameAction action) throws JASVisitorException
visitWAIT_FOR_FRAME
in interface Visitor
JASVisitorException
public void visitWAIT_FOR_FRAME_2(WaitForFrame2Action action) throws JASVisitorException
visitWAIT_FOR_FRAME_2
in interface Visitor
JASVisitorException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |