Fixed AS1/2 - get/setProperty when propertyindex is string

This commit is contained in:
Jindra Petřík
2021-11-23 21:10:00 +01:00
parent dcc066262c
commit 01cd1a3a1f
3 changed files with 23 additions and 1 deletions

View File

@@ -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.action.swf4;
import com.jpexs.decompiler.flash.BaseLocalData;
@@ -29,6 +30,8 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
@@ -76,7 +79,15 @@ public class ActionGetProperty extends Action {
indexInt = (int) Math.round((Double) value);
} else if (value instanceof Float) {
indexInt = (int) Math.round((Float) value);
} else if (((DirectValueActionItem) index).isString()) {
try {
indexInt = Integer.parseInt(((DirectValueActionItem) index).toString());
} catch (NumberFormatException nfe) {
Logger.getLogger(ActionGetProperty.class.getName()).log(Level.SEVERE, "Invalid property index: {0}", index.toString());
}
}
} else {
Logger.getLogger(ActionGetProperty.class.getName()).log(Level.SEVERE, "Invalid property index: {0}", index.getClass().getSimpleName());
}
stack.push(new GetPropertyActionItem(this, lineStartAction, target, indexInt));
}

View File

@@ -37,6 +37,8 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
@@ -83,7 +85,15 @@ public class ActionSetProperty extends Action {
indexInt = (int) Math.round((Double) ((DirectValueActionItem) index).value);
} else if (((DirectValueActionItem) index).value instanceof Float) {
indexInt = (int) Math.round((Float) ((DirectValueActionItem) index).value);
} else if (((DirectValueActionItem) index).isString()) {
try {
indexInt = Integer.parseInt(((DirectValueActionItem) index).toString());
} catch (NumberFormatException nfe) {
Logger.getLogger(ActionGetProperty.class.getName()).log(Level.SEVERE, "Invalid property index: {0}", index.toString());
}
}
} else {
Logger.getLogger(ActionGetProperty.class.getName()).log(Level.SEVERE, "Invalid property index: {0}", index.getClass().getSimpleName());
}
if (value.getThroughDuplicate() instanceof IncrementActionItem) {
GraphTargetItem obj = ((IncrementActionItem) value).object;