mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-05-24 11:25:29 +00:00
handling imported vars fix
This commit is contained in:
@@ -2709,6 +2709,8 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
typeItem = item;
|
||||
} else if (item instanceof ApplyTypeAVM2Item) {
|
||||
typeItem = ((ApplyTypeAVM2Item) item).object;
|
||||
} else if (item instanceof ImportedSlotConstItem) {
|
||||
typeItem = ((ImportedSlotConstItem) item).type;
|
||||
} else {
|
||||
throw new CompilationException("Invalid type:" + item + " (" + item.getClass().getName() + ")", 0/*??*/);
|
||||
}
|
||||
|
||||
@@ -73,6 +73,9 @@ public class CallAVM2Item extends AVM2Item {
|
||||
if (callable instanceof UnresolvedAVM2Item) {
|
||||
callable = ((UnresolvedAVM2Item) callable).resolved;
|
||||
}
|
||||
if (callable instanceof ImportedSlotConstItem) {
|
||||
callable = ((ImportedSlotConstItem) callable).type;
|
||||
}
|
||||
if (callable instanceof NameAVM2Item) {
|
||||
NameAVM2Item n = (NameAVM2Item) callable;
|
||||
/*List<ABC> allAbcs = new ArrayList<>();
|
||||
|
||||
@@ -30,11 +30,11 @@ import java.util.List;
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class TypeAssignableItem extends AssignableAVM2Item {
|
||||
public class ImportedSlotConstItem extends AssignableAVM2Item {
|
||||
|
||||
private final TypeItem type;
|
||||
public TypeItem type;
|
||||
|
||||
public TypeAssignableItem(TypeItem type) {
|
||||
public ImportedSlotConstItem(TypeItem type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@@ -50,12 +50,12 @@ public class TypeAssignableItem extends AssignableAVM2Item {
|
||||
|
||||
@Override
|
||||
public GraphTargetItem returnType() {
|
||||
return TypeItem.UNBOUNDED;
|
||||
return type.returnType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AssignableAVM2Item copy() {
|
||||
return new TypeAssignableItem(type);
|
||||
return new ImportedSlotConstItem(type);
|
||||
}
|
||||
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn) throws CompilationException {
|
||||
@@ -116,4 +116,14 @@ public class TypeAssignableItem extends AssignableAVM2Item {
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return type.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(LocalData localData) throws InterruptedException {
|
||||
return super.toString(localData); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
}
|
||||
@@ -330,11 +330,12 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
|
||||
}
|
||||
|
||||
if (name.size() == 1) {
|
||||
resolved = new TypeAssignableItem(ret);
|
||||
//TODO: check whether it is really an assignable and not a Class
|
||||
if (assignedValue != null) {
|
||||
((TypeAssignableItem) resolved).assignedValue = assignedValue;
|
||||
//throw new CompilationException("Cannot assign type", line);
|
||||
AbcIndexing.TraitIndex ti = abc.findScriptProperty(imp);
|
||||
if (ti != null && (ti.trait instanceof TraitSlotConst)) {
|
||||
resolved = new ImportedSlotConstItem(ret);
|
||||
if (assignedValue != null) {
|
||||
((ImportedSlotConstItem) resolved).assignedValue = assignedValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ package
|
||||
TestIfElse;
|
||||
TestIfInIf;
|
||||
TestIgnoreAndOr;
|
||||
TestImportedVar;
|
||||
TestInc2;
|
||||
TestIncDec;
|
||||
TestInlineFunctions;
|
||||
|
||||
14
libsrc/ffdec_lib/testdata/as3_new/src/tests/TestImportedVar.as
vendored
Normal file
14
libsrc/ffdec_lib/testdata/as3_new/src/tests/TestImportedVar.as
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
package tests
|
||||
{
|
||||
import tests_classes.myvar;
|
||||
|
||||
public class TestImportedVar
|
||||
{
|
||||
public function run():void
|
||||
{
|
||||
trace(myvar);
|
||||
//myvar++;
|
||||
myvar = 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user