mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 05:40:45 +00:00
AS2: Better decompiling for..in
This commit is contained in:
@@ -769,7 +769,7 @@ public class Action {
|
||||
List<TreeItem> finalExpression = null;
|
||||
|
||||
TreeItem variableName = null;
|
||||
if (isForIn) {
|
||||
/*if (isForIn) {
|
||||
for (int t = ip + 1; t <= end; t++) {
|
||||
Action actionSV = actions.get(t);
|
||||
actionSV.translate(stack, constants, output, registerNames);
|
||||
@@ -780,7 +780,7 @@ public class Action {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
try {
|
||||
|
||||
@@ -834,6 +834,10 @@ public class Action {
|
||||
}
|
||||
}
|
||||
if (isForIn) {
|
||||
variableName=onTrue.remove(0);
|
||||
if(variableName instanceof SetTypeTreeItem){
|
||||
variableName=((SetTypeTreeItem)variableName).getObject();
|
||||
}
|
||||
output.add(new ForInTreeItem(action, jumpIp, loopStart, variableName, inItem, onTrue));
|
||||
} else if (isFor) {
|
||||
output.add(new ForTreeItem(action, currentLoop.loopBreak, currentLoop.loopContinue, new ArrayList<TreeItem>(), expression, finalExpression, onTrue));
|
||||
|
||||
@@ -28,7 +28,9 @@ public class DirectValueTreeItem extends TreeItem {
|
||||
|
||||
public DirectValueTreeItem(Action instruction, Object value, ConstantPool constants) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.constants = constants.constants;
|
||||
if (constants != null) {
|
||||
this.constants = constants.constants;
|
||||
}
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ package com.jpexs.asdec.action.treemodel;
|
||||
|
||||
import com.jpexs.asdec.action.Action;
|
||||
|
||||
public class SetMemberTreeItem extends TreeItem {
|
||||
public class SetMemberTreeItem extends TreeItem implements SetTypeTreeItem{
|
||||
|
||||
public TreeItem object;
|
||||
public TreeItem objectName;
|
||||
@@ -35,4 +35,11 @@ public class SetMemberTreeItem extends TreeItem {
|
||||
public String toString(ConstantPool constants) {
|
||||
return object.toString(constants) + "." + stripQuotes(objectName) + "=" + value.toString(constants) + ";";
|
||||
}
|
||||
|
||||
@Override
|
||||
public TreeItem getObject() {
|
||||
return new GetMemberTreeItem(instruction, object, objectName);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ package com.jpexs.asdec.action.treemodel;
|
||||
|
||||
import com.jpexs.asdec.action.Action;
|
||||
|
||||
public class SetPropertyTreeItem extends TreeItem {
|
||||
public class SetPropertyTreeItem extends TreeItem implements SetTypeTreeItem{
|
||||
|
||||
public TreeItem target;
|
||||
public int propertyIndex;
|
||||
@@ -38,4 +38,11 @@ public class SetPropertyTreeItem extends TreeItem {
|
||||
}
|
||||
return target.toString(constants) + "." + Action.propertyNames[propertyIndex] + "=" + value.toString(constants) + ";";
|
||||
}
|
||||
|
||||
@Override
|
||||
public TreeItem getObject() {
|
||||
return new GetPropertyTreeItem(instruction, target, propertyIndex);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2013 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.asdec.action.treemodel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public interface SetTypeTreeItem {
|
||||
public TreeItem getObject();
|
||||
}
|
||||
@@ -18,7 +18,7 @@ package com.jpexs.asdec.action.treemodel;
|
||||
|
||||
import com.jpexs.asdec.action.Action;
|
||||
|
||||
public class SetVariableTreeItem extends TreeItem {
|
||||
public class SetVariableTreeItem extends TreeItem implements SetTypeTreeItem {
|
||||
|
||||
public TreeItem name;
|
||||
public TreeItem value;
|
||||
@@ -33,4 +33,9 @@ public class SetVariableTreeItem extends TreeItem {
|
||||
public String toString(ConstantPool constants) {
|
||||
return stripQuotes(name) + hilight("=") + value.toString(constants) + ";";
|
||||
}
|
||||
|
||||
@Override
|
||||
public TreeItem getObject() {
|
||||
return new GetVariableTreeItem(instruction, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package com.jpexs.asdec.action.treemodel;
|
||||
import com.jpexs.asdec.action.Action;
|
||||
import com.jpexs.asdec.action.swf4.RegisterNumber;
|
||||
|
||||
public class StoreRegisterTreeItem extends TreeItem {
|
||||
public class StoreRegisterTreeItem extends TreeItem implements SetTypeTreeItem {
|
||||
|
||||
public RegisterNumber register;
|
||||
public TreeItem value;
|
||||
@@ -34,4 +34,9 @@ public class StoreRegisterTreeItem extends TreeItem {
|
||||
public String toString(ConstantPool constants) {
|
||||
return register.toString() + "=" + value.toString(constants) + ";";
|
||||
}
|
||||
|
||||
@Override
|
||||
public TreeItem getObject() {
|
||||
return new DirectValueTreeItem(instruction, register, null);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user