From 73aa020eeb8fb77f09bd774a216b313de894acd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=F8=EDk?= Date: Sat, 22 Dec 2012 12:18:13 +0100 Subject: [PATCH] AS3: Detecting local register types --- .../com/jpexs/asdec/abc/avm2/AVM2Code.java | 24 ++++++++++++++++++- .../avm2/instructions/types/CoerceAIns.java | 8 +++++++ .../avm2/instructions/types/CoerceIns.java | 5 ++++ .../types/CoerceOrConvertTypeIns.java | 5 +++- .../avm2/instructions/types/CoerceSIns.java | 4 ++++ .../avm2/instructions/types/ConvertBIns.java | 4 ++++ .../avm2/instructions/types/ConvertDIns.java | 4 ++++ .../avm2/instructions/types/ConvertIIns.java | 4 ++++ .../avm2/instructions/types/ConvertOIns.java | 4 ++++ .../avm2/instructions/types/ConvertSIns.java | 4 ++++ .../avm2/instructions/types/ConvertUIns.java | 4 ++++ 11 files changed, 68 insertions(+), 2 deletions(-) diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/AVM2Code.java b/trunk/src/com/jpexs/asdec/abc/avm2/AVM2Code.java index c0f02cd46..62804eeca 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/AVM2Code.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/AVM2Code.java @@ -1832,6 +1832,23 @@ public HashMap getLocalRegNamesFromDebug(ABC abc){ return maxRegister+1; } + public HashMap getLocalRegTypes(ConstantPool constants){ + HashMap ret=new HashMap(); + AVM2Instruction prev=null; + for(AVM2Instruction ins:code){ + if(ins.definition instanceof SetLocalTypeIns){ + if(prev!=null){ + if(prev.definition instanceof CoerceOrConvertTypeIns) + { + ret.put(((SetLocalTypeIns)ins.definition).getRegisterId(ins),((CoerceOrConvertTypeIns)prev.definition).getTargetType(constants, prev)); + } + } + } + prev=ins; + } + return ret; + } + public String toSource(boolean isStatic, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[], MethodBody body, boolean hilighted,HashMap localRegNames) { toSourceCount = 0; loopList = new ArrayList(); @@ -1866,10 +1883,15 @@ public HashMap getLocalRegNamesFromDebug(ABC abc){ paramCount++; } } + HashMap localRegTypes=getLocalRegTypes(constants); for(int i=paramCount+1;i