AS3 direct editation: Or coercion fix

This commit is contained in:
Jindra Petřík
2015-11-15 09:40:55 +01:00
parent 038316ac35
commit 338e3fd691
2 changed files with 12 additions and 2 deletions

View File

@@ -20,10 +20,12 @@ import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions;
import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.CoerceAVM2Item;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.OrItem;
import java.util.ArrayList;
import java.util.List;
@@ -35,6 +37,15 @@ public abstract class AssignableAVM2Item extends AVM2Item {
protected GraphTargetItem assignedValue;
protected GraphTargetItem makeCoerced(GraphTargetItem assignedValue, GraphTargetItem targetType) {
if (assignedValue instanceof OrItem) {
OrItem oi = (OrItem) assignedValue;
return new OrItem(assignedValue.getSrc(), makeCoerced(oi.leftSide, targetType), makeCoerced(oi.rightSide, targetType));
}
//TODO: Is it needed for AndItem too?
return new CoerceAVM2Item(null, assignedValue, targetType);
}
public AssignableAVM2Item() {
this(null);
}

View File

@@ -23,7 +23,6 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions;
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.FindPropertyStrictIns;
import com.jpexs.decompiler.flash.abc.avm2.model.ApplyTypeAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.CoerceAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.InitVectorAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.Multiname;
@@ -582,7 +581,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
String srcType = assignedValue.returnType().toString();
GraphTargetItem coerced = assignedValue;
if (!targetType.toString().equals(srcType) && !propertyName.startsWith("@")) {
coerced = new CoerceAVM2Item(null, assignedValue, targetType);
coerced = makeCoerced(assignedValue, targetType);
}
return toSourceMerge(localData, generator, obj, coerced,
needsReturn ? dupSetTemp(localData, generator, ret_temp) : null,