If you are looking for the decompiler itself, visit https://github.com/jindrapetrik/jpexs-decompiler
NEW : You can now close your own issues and reopen them later if needed. You can also comment closed issues.
List of issues#2651 AS1 decompilation: Regression on for loop
Author:
Randomno
RandomnoDate created:
Type: bug
Visibility: Everybody
Assigned to:
Labels: AS1/2Decompilation
State: upgraded 

Compiling this P Code:
DefineFunction "updateActivatedFurniture", 0 {
Push "myPlayer"
GetVariable
Push "furniturelist"
GetMember
Enumerate2
loc0042:StoreRegister 0
Push null
Equals2
If loc00a1
Push "n", register0
DefineLocal
Push "myPlayer"
GetVariable
Push "furniturelist"
GetMember
Push "n"
GetVariable
GetMember
Push "IsActivated", 0.0
SetMember
Jump loc0042
loc00a1:Push "myPlayerRoom"
GetVariable
Push "furniturelist"
GetMember
Enumerate2
loc00c7:StoreRegister 0
Push null
Equals2
If loc0247
Push "n", register0
DefineLocal
Push "itemId", "myPlayerRoom"
GetVariable
Push "furniturelist"
GetMember
Push "n"
GetVariable
GetMember
Push "ItemId"
GetMember
DefineLocal
Push "myPlayer"
GetVariable
Push "furniturelist"
GetMember
Enumerate2
loc0142:StoreRegister 0
Push null
Equals2
If loc0242
Push "i", register0
DefineLocal
Push "myPlayer"
GetVariable
Push "furniturelist"
GetMember
Push "i"
GetVariable
GetMember
Push "ItemId"
GetMember
Push "itemId"
GetVariable
Equals2
Not
If loc0232
Push "myPlayer"
GetVariable
Push "furniturelist"
GetMember
Push "i"
GetVariable
GetMember
Push "IsActivated"
GetMember
Push 0.0
Equals2
Not
If loc0232
Push "myPlayer"
GetVariable
Push "furniturelist"
GetMember
Push "i"
GetVariable
GetMember
Push "IsActivated", 1
SetMember
Jump loc0237
loc0232:Jump loc0142
loc0237:Push null
Equals2
Not
If loc0237
loc0242:Jump loc00c7
}
loc0247:
In 25.0.0 and earlier, it decompiles to:
function updateActivatedFurniture()
{
for(var n in myPlayer.furniturelist)
{
myPlayer.furniturelist[n].IsActivated = 0;
}
for(var n in myPlayerRoom.furniturelist)
{
var itemId = myPlayerRoom.furniturelist[n].ItemId;
for(var i in myPlayer.furniturelist)
{
if(myPlayer.furniturelist[i].ItemId == itemId)
{
if(myPlayer.furniturelist[i].IsActivated == 0)
{
myPlayer.furniturelist[i].IsActivated = 1;
break;
}
}
}
}
}
Since 25.1.0, it leaves enumeration instructions in the decompilation.
decompfor.swf (1 KiB)This is fixed in nightly 3442.
State: new→upgraded
