mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-12 05:54:51 +00:00
#1379 AS3 - better handling local registers postincrement/decrement
This commit is contained in:
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.AVM2LocalData;
|
||||
@@ -23,6 +24,8 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.DecLocalAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.PostDecrementAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.SubtractAVM2Item;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.flash.ecma.NotCompileTime;
|
||||
@@ -54,7 +57,20 @@ public class DecLocalIIns extends InstructionDefinition {
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
int regId = ins.operands[0];
|
||||
int regId = ins.operands[0];
|
||||
boolean isPostDec = false;
|
||||
if (!stack.isEmpty()) {
|
||||
GraphTargetItem stackTop = stack.peek();
|
||||
if (stackTop instanceof LocalRegAVM2Item) {
|
||||
if (regId == ((LocalRegAVM2Item) stackTop).regIndex) {
|
||||
stack.pop();
|
||||
stack.push(new PostDecrementAVM2Item(ins, localData.lineStartInstruction, stackTop));
|
||||
isPostDec = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isPostDec) {
|
||||
output.add(new DecLocalAVM2Item(ins, localData.lineStartInstruction, regId));
|
||||
}
|
||||
if (localData.localRegs.containsKey(regId)) {
|
||||
localData.localRegs.put(regId, new SubtractAVM2Item(ins, localData.lineStartInstruction, localData.localRegs.get(regId), new IntegerValueAVM2Item(ins, localData.lineStartInstruction, 1L)));
|
||||
} else {
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.AVM2LocalData;
|
||||
@@ -23,6 +24,8 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.DecLocalAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.PostDecrementAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.SubtractAVM2Item;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.flash.ecma.NotCompileTime;
|
||||
@@ -54,7 +57,20 @@ public class DecLocalIns extends InstructionDefinition {
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
int regId = ins.operands[0];
|
||||
int regId = ins.operands[0];
|
||||
boolean isPostDec = false;
|
||||
if (!stack.isEmpty()) {
|
||||
GraphTargetItem stackTop = stack.peek();
|
||||
if (stackTop instanceof LocalRegAVM2Item) {
|
||||
if (regId == ((LocalRegAVM2Item) stackTop).regIndex) {
|
||||
stack.pop();
|
||||
stack.push(new PostDecrementAVM2Item(ins, localData.lineStartInstruction, stackTop));
|
||||
isPostDec = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isPostDec) {
|
||||
output.add(new DecLocalAVM2Item(ins, localData.lineStartInstruction, regId));
|
||||
}
|
||||
if (localData.localRegs.containsKey(regId)) {
|
||||
localData.localRegs.put(regId, new SubtractAVM2Item(ins, localData.lineStartInstruction, localData.localRegs.get(regId), new IntegerValueAVM2Item(ins, localData.lineStartInstruction, 1L)));
|
||||
} else {
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.AVM2LocalData;
|
||||
@@ -23,6 +24,8 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.IncLocalAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.PostIncrementAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.AddAVM2Item;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.flash.ecma.NotCompileTime;
|
||||
@@ -54,11 +57,22 @@ public class IncLocalIIns extends InstructionDefinition {
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
int regId = ins.operands[0];
|
||||
int regId = ins.operands[0];
|
||||
boolean isPostInc = false;
|
||||
if (!stack.isEmpty()) {
|
||||
GraphTargetItem stackTop = stack.peek();
|
||||
if (stackTop instanceof LocalRegAVM2Item) {
|
||||
if (regId == ((LocalRegAVM2Item) stackTop).regIndex) {
|
||||
stack.pop();
|
||||
stack.push(new PostIncrementAVM2Item(ins, localData.lineStartInstruction, stackTop));
|
||||
isPostInc = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isPostInc) {
|
||||
output.add(new IncLocalAVM2Item(ins, localData.lineStartInstruction, regId));
|
||||
}
|
||||
if (localData.localRegs.containsKey(regId)) {
|
||||
localData.localRegs.put(regId, new AddAVM2Item(ins, localData.lineStartInstruction, localData.localRegs.get(regId), new IntegerValueAVM2Item(ins, localData.lineStartInstruction, 1L)));
|
||||
localData.localRegs.put(regId, new AddAVM2Item(ins, localData.lineStartInstruction, localData.localRegs.get(regId), new IntegerValueAVM2Item(ins, localData.lineStartInstruction, 1L)));
|
||||
} else {
|
||||
}
|
||||
if (!localData.localRegAssignmentIps.containsKey(regId)) {
|
||||
localData.localRegAssignmentIps.put(regId, 0);
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.AVM2LocalData;
|
||||
@@ -23,6 +24,8 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.IncLocalAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.PostIncrementAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.AddAVM2Item;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.flash.ecma.NotCompileTime;
|
||||
@@ -54,7 +57,20 @@ public class IncLocalIns extends InstructionDefinition {
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
int regId = ins.operands[0];
|
||||
int regId = ins.operands[0];
|
||||
boolean isPostInc = false;
|
||||
if (!stack.isEmpty()) {
|
||||
GraphTargetItem stackTop = stack.peek();
|
||||
if (stackTop instanceof LocalRegAVM2Item) {
|
||||
if (regId == ((LocalRegAVM2Item) stackTop).regIndex) {
|
||||
stack.pop();
|
||||
stack.push(new PostIncrementAVM2Item(ins, localData.lineStartInstruction, stackTop));
|
||||
isPostInc = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isPostInc) {
|
||||
output.add(new IncLocalAVM2Item(ins, localData.lineStartInstruction, regId));
|
||||
}
|
||||
if (localData.localRegs.containsKey(regId)) {
|
||||
localData.localRegs.put(regId, new AddAVM2Item(ins, localData.lineStartInstruction, localData.localRegs.get(regId), new IntegerValueAVM2Item(ins, localData.lineStartInstruction, 1L)));
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user