Missing few pops after expression as command

Issue #527 linkage as duplicate export
This commit is contained in:
Jindra Petřík
2014-06-05 20:20:26 +02:00
parent 2dd1c3f01d
commit 10fb289ad8
6 changed files with 43 additions and 7 deletions
@@ -49,7 +49,8 @@ public class PopIns extends InstructionDefinition {
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap<Integer, GraphTargetItem> localRegs, Stack<GraphTargetItem> stack, java.util.Stack<GraphTargetItem> scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
if (stack.size() > 0) {
GraphTargetItem top = stack.pop();
GraphTargetItem top = stack.pop();
//TODO: handle all values (#585) - beware collision with return inside finally block
if (top instanceof CallPropertyAVM2Item) {
output.add(top);
} else if (top instanceof CallSuperAVM2Item) {
@@ -62,9 +63,9 @@ public class PopIns extends InstructionDefinition {
output.add(top);
} else if (top instanceof AssignmentAVM2Item) {
output.add(top);
}
}
}
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
@@ -2421,4 +2421,13 @@ public class AVM2SourceGenerator implements SourceGenerator {
return name_index;
}
@Override
public List<GraphSourceItem> generateDiscardValue(SourceGeneratorLocalData localData, GraphTargetItem item) throws CompilationException {
List<GraphSourceItem> ret=item.toSource(localData, this);
ret.add(ins(new PopIns()));
return ret;
}
}
@@ -777,4 +777,13 @@ public class ActionSourceGenerator implements SourceGenerator {
return new ArrayList<>();
}
@Override
public List<GraphSourceItem> generateDiscardValue(SourceGeneratorLocalData localData, GraphTargetItem item) throws CompilationException {
List<GraphSourceItem> ret=item.toSource(localData, this);
ret.add(new ActionPop());
return ret;
}
}
@@ -1522,12 +1522,18 @@ public class XFLConverter {
mediaLinkStr += "\"";
mediaLinkStr += " exportFormat=\"" + format + "\" exportBits=\"" + bits + "\" sampleCount=\"" + soundSampleCount + "\"";
boolean linkageExportForAS = false;
if (characterClasses.containsKey(symbol.getCharacterId())) {
mediaLinkStr += " linkageExportForAS=\"true\" linkageClassName=\"" + characterClasses.get(symbol.getCharacterId()) + "\"";
linkageExportForAS = true;
mediaLinkStr += " linkageClassName=\"" + characterClasses.get(symbol.getCharacterId()) + "\"";
}
if (characterVariables.containsKey(symbol.getCharacterId())) {
mediaLinkStr += " linkageExportForAS=\"true\" linkageIdentifier=\"" + xmlString(characterVariables.get(symbol.getCharacterId())) + "\"";
linkageExportForAS = true;
mediaLinkStr += " linkageIdentifier=\"" + xmlString(characterVariables.get(symbol.getCharacterId())) + "\"";
}
if (linkageExportForAS) {
mediaLinkStr += " linkageExportForAS=\"true\"";
}
mediaLinkStr += "/>\n";
@@ -1589,11 +1595,17 @@ public class XFLConverter {
mediaLinkStr += " height=\"" + video.height + "\"";
double len = ((double) video.numFrames) / ((double) swf.frameRate);
mediaLinkStr += " length=\"" + len + "\"";
boolean linkageExportForAS = false;
if (characterClasses.containsKey(symbol.getCharacterId())) {
mediaLinkStr += " linkageExportForAS=\"true\" linkageClassName=\"" + characterClasses.get(symbol.getCharacterId()) + "\"";
linkageExportForAS = true;
mediaLinkStr += " linkageClassName=\"" + characterClasses.get(symbol.getCharacterId()) + "\"";
}
if (characterVariables.containsKey(symbol.getCharacterId())) {
mediaLinkStr += " linkageExportForAS=\"true\" linkageIdentifier=\"" + xmlString(characterVariables.get(symbol.getCharacterId())) + "\"";
linkageExportForAS = true;
mediaLinkStr += " linkageIdentifier=\"" + xmlString(characterVariables.get(symbol.getCharacterId())) + "\"";
}
if(linkageExportForAS){
mediaLinkStr += " linkageExportForAS=\"true\"";
}
mediaLinkStr += "/>\n";
}
@@ -206,7 +206,10 @@ public abstract class GraphTargetItem implements Serializable {
}
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
return toSource(localData, generator);
if(!hasReturnValue()){
return toSource(localData, generator);
}
return generator.generateDiscardValue(localData, this);
}
protected List<GraphSourceItem> toSourceBinary(BinaryOp op, GraphSourceItem action) {
@@ -67,4 +67,6 @@ public interface SourceGenerator {
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, CommaExpressionItem item) throws CompilationException;
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, TypeItem item) throws CompilationException;
public List<GraphSourceItem> generateDiscardValue(SourceGeneratorLocalData localData, GraphTargetItem item) throws CompilationException;
}