AS3 direct editation - for(each) in fix, calling types fix

This commit is contained in:
Jindra Petk
2014-04-20 17:22:45 +02:00
parent 8bad9c8ec6
commit a5fa22d9eb
5 changed files with 22 additions and 13 deletions

View File

@@ -430,6 +430,10 @@ public class AVM2SourceGenerator implements SourceGenerator {
final Reference<Integer> counterReg = new Reference<>(0);
final Reference<Integer> collectionReg = new Reference<>(0);
if(assignable instanceof UnresolvedAVM2Item){
assignable = (AssignableAVM2Item)((UnresolvedAVM2Item)assignable).resolved;
}
ret.addAll(GraphTargetItem.toSourceMerge(localData, this,
ins(new PushByteIns(), 0),
AssignableAVM2Item.setTemp(localData, this, counterReg),

View File

@@ -173,7 +173,7 @@ public class ActionScriptParser {
ret = member(needsActivation, importedClasses, openedNamespaces, ret, registerVars, inFunction, inMethod, variables);
break;
case PARENT_OPEN:
ret = new CallAVM2Item(ret, call(needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, variables));
ret = new CallAVM2Item(lexer.yyline(),ret, call(needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, variables));
break;
}
s = lex();
@@ -2007,7 +2007,7 @@ public class ActionScriptParser {
case NEW:
GraphTargetItem newvar = name(needsActivation, true, openedNamespaces, registerVars, inFunction, inMethod, variables, importedClasses);
expectedType(SymbolType.PARENT_OPEN);
ret = new ConstructSomethingAVM2Item(openedNamespaces, newvar, call(needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, variables));
ret = new ConstructSomethingAVM2Item(lexer.yyline(),openedNamespaces, newvar, call(needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, variables));
existsRemainder = true;
break;
case IDENTIFIER:

View File

@@ -34,6 +34,7 @@ import com.jpexs.decompiler.graph.TypeFunctionItem;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.LocalData;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
@@ -44,11 +45,13 @@ public class CallAVM2Item extends AVM2Item {
public GraphTargetItem name;
public List<GraphTargetItem> arguments;
public int line;
public CallAVM2Item(GraphTargetItem name, List<GraphTargetItem> arguments) {
public CallAVM2Item(int line, GraphTargetItem name, List<GraphTargetItem> arguments) {
super(null, NOPRECEDENCE);
this.name = name;
this.arguments = arguments;
this.line = line;
}
@Override
@@ -93,7 +96,12 @@ public class CallAVM2Item extends AVM2Item {
p.setAssignedValue(n.getAssignedValue());
callable = p;
}
if(callable instanceof TypeItem){
TypeItem t=(TypeItem)callable;
callable = new PropertyAVM2Item(null, t.fullTypeName, g.abc, g.allABCs, new ArrayList<Integer>(), new ArrayList<MethodBody>());
}
if (callable instanceof PropertyAVM2Item) {
PropertyAVM2Item prop = (PropertyAVM2Item) callable;
Object obj = prop.object;
@@ -115,7 +123,7 @@ public class CallAVM2Item extends AVM2Item {
Reference<Integer> outPropNsKind = new Reference<>(1);
Reference<String> outPropType = new Reference<>("");
Reference<ValueKind> outPropValue = new Reference<>(null);
if (AVM2SourceGenerator.searchPrototypeChain(true, allAbcs, pkgName, cname, prop.propertyName, outName, outNs, outPropNs, outPropNsKind, outPropType, outPropValue)) {
if (AVM2SourceGenerator.searchPrototypeChain(true, allAbcs, pkgName, cname, prop.propertyName, outName, outNs, outPropNs, outPropNsKind, outPropType, outPropValue) && (localData.currentClass.equals("".equals(outNs.getVal())?outName.getVal():outNs.getVal()+"."+outName.getVal()))) {
NameAVM2Item nobj = new NameAVM2Item(new TypeItem(localData.currentClass), 0, "this", null, false, new ArrayList<Integer>());
nobj.setRegNumber(0);
obj = nobj;
@@ -127,7 +135,8 @@ public class CallAVM2Item extends AVM2Item {
new AVM2Instruction(0, new CallPropertyIns(), new int[]{prop.resolveProperty(localData), arguments.size()}, new byte[0])
);
}
return new ArrayList<>();
throw new CompilationException("Cannot call a type", line);
//return new ArrayList<>();
}
@Override

View File

@@ -43,8 +43,8 @@ public class ConstructSomethingAVM2Item extends CallAVM2Item {
public List<Integer> openedNamespaces;
public ConstructSomethingAVM2Item(List<Integer> openedNamespaces, GraphTargetItem name, List<GraphTargetItem> arguments) {
super(name, arguments);
public ConstructSomethingAVM2Item(int line,List<Integer> openedNamespaces, GraphTargetItem name, List<GraphTargetItem> arguments) {
super(line,name, arguments);
this.openedNamespaces = openedNamespaces;
}

View File

@@ -143,11 +143,7 @@ public class NameAVM2Item extends AssignableAVM2Item {
public int getNsKind() {
return nsKind;
}
@Override
public void setAssignedValue(GraphTargetItem storeValue) {
this.assignedValue = storeValue;
}
public String getVariableName() {
return variableName;