From 3dbbd7778ef021fa83597ca6c377f7403bd5f155 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sat, 13 Feb 2021 18:05:46 +0100 Subject: [PATCH] Fixed #1489 AS1/2 direct editation - for in loop --- CHANGELOG.md | 1 + .../flash/action/model/clauses/ForInActionItem.java | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a26723b83..36e365edd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ All notable changes to this project will be documented in this file. - #1339 AS1/2 direct editation - targetPath as an expression - #1467 AS1/2 direct editation - allow new Number call - #1489 AS1/2 direct editation - reversed conditions in if +- #1489 AS1/2 direct editation - for in loop ## [13.0.3] - 2021-02-12 ### Added diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/clauses/ForInActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/clauses/ForInActionItem.java index ccde62107..85c6acc44 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/clauses/ForInActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/clauses/ForInActionItem.java @@ -20,7 +20,9 @@ import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; +import com.jpexs.decompiler.flash.action.model.SetVariableActionItem; import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator; +import com.jpexs.decompiler.flash.action.parser.script.VariableActionItem; import com.jpexs.decompiler.flash.action.swf4.ActionIf; import com.jpexs.decompiler.flash.action.swf4.ActionJump; import com.jpexs.decompiler.flash.action.swf4.ActionPush; @@ -158,8 +160,12 @@ public class ForInActionItem extends LoopActionItem implements Block { ActionIf forInEndIf = new ActionIf(0); loopExpr.add(forInEndIf); List loopBody = new ArrayList<>(); - loopBody.add(new ActionPush(new RegisterNumber(exprReg))); - loopBody.addAll(asGenerator.toActionList(variableName.toSourceIgnoreReturnValue(localData, generator))); + + //assuming (variableName instanceof VariableActionItem) + SetVariableActionItem setVar = new SetVariableActionItem(null, null, asGenerator.pushConstTargetItem(((VariableActionItem) variableName).getVariableName()), new DirectValueActionItem(new RegisterNumber(exprReg))); + + loopBody.addAll(asGenerator.toActionList(setVar.toSourceIgnoreReturnValue(localData, generator))); + //loopBody.add(new ActionPush(new RegisterNumber(exprReg))); int oldForIn = asGenerator.getForInLevel(localData); asGenerator.setForInLevel(localData, oldForIn + 1); loopBody.addAll(asGenerator.toActionList(asGenerator.generate(localData, commands)));