diff --git a/trunk/src/com/jpexs/decompiler/flash/AppStrings.java b/trunk/src/com/jpexs/decompiler/flash/AppStrings.java index dab0f2428..30f372bf9 100644 --- a/trunk/src/com/jpexs/decompiler/flash/AppStrings.java +++ b/trunk/src/com/jpexs/decompiler/flash/AppStrings.java @@ -31,7 +31,7 @@ public class AppStrings { resourceClass = cls; updateLanguage(); } - + public static String getResourcePath(Class cls) { String name = cls.getName(); if (name.startsWith("com.jpexs.decompiler.flash.gui.")) { diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/AVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/AVM2Item.java index c70006f5d..7d065a2b2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/AVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/AVM2Item.java @@ -46,7 +46,7 @@ public abstract class AVM2Item extends GraphTargetItem { } protected GraphTextWriter formatProperty(GraphTextWriter writer, GraphTargetItem object, GraphTargetItem propertyName, LocalData localData) throws InterruptedException { - boolean empty = object instanceof FindPropertyAVM2Item; + boolean empty = object instanceof FindPropertyAVM2Item; if (object instanceof LocalRegAVM2Item) { if (((LocalRegAVM2Item) object).computedValue != null) { if (((LocalRegAVM2Item) object).computedValue.getThroughNotCompilable() instanceof FindPropertyAVM2Item) { @@ -55,13 +55,13 @@ public abstract class AVM2Item extends GraphTargetItem { } } - if(object instanceof FindPropertyAVM2Item){ - FindPropertyAVM2Item fp=(FindPropertyAVM2Item)object; - if(fp.propertyName instanceof FullMultinameAVM2Item){ + if (object instanceof FindPropertyAVM2Item) { + FindPropertyAVM2Item fp = (FindPropertyAVM2Item) object; + if (fp.propertyName instanceof FullMultinameAVM2Item) { propertyName = fp.propertyName; } } - + if (!empty) { if (object.getPrecedence() > PRECEDENCE_PRIMARY) { writer.append("("); @@ -77,7 +77,7 @@ public abstract class AVM2Item extends GraphTargetItem { } } - if (empty) { + if (empty) { return propertyName.toString(writer, localData); } if (propertyName instanceof FullMultinameAVM2Item) { diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/AsTypeAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/AsTypeAVM2Item.java index 2271d38e0..b1b72ba48 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/AsTypeAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/AsTypeAVM2Item.java @@ -42,5 +42,5 @@ public class AsTypeAVM2Item extends BinaryOpItem { @Override public GraphTargetItem returnType() { return rightSide; - } + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/SubtractAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/SubtractAVM2Item.java index 5d4546bac..a45668d22 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/SubtractAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/SubtractAVM2Item.java @@ -19,7 +19,6 @@ package com.jpexs.decompiler.flash.abc.avm2.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.DecrementIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.IncrementIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.SubtractIns; import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item; import com.jpexs.decompiler.flash.ecma.EcmaScript; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java index fa284f329..13b26209e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java @@ -366,7 +366,7 @@ public class AVM2SourceGenerator implements SourceGenerator { if (ins.definition instanceof JumpIns) { if (ins.definition instanceof ContinueJumpIns) { if (continueOffset != Integer.MAX_VALUE) { - ins.operands[0] = (-pos + continueOffset); + ins.operands[0] = (-pos + continueOffset); code.get(a).definition = new JumpIns(); } } @@ -419,22 +419,22 @@ public class AVM2SourceGenerator implements SourceGenerator { } public List generate(SourceGeneratorLocalData localData, ForEachInAVM2Item item) throws CompilationException { - return generateForIn(localData,item.loop, item.expression.collection, (AssignableAVM2Item) item.expression.object, item.commands, true); + return generateForIn(localData, item.loop, item.expression.collection, (AssignableAVM2Item) item.expression.object, item.commands, true); } public List generate(SourceGeneratorLocalData localData, ForInAVM2Item item) throws CompilationException { - return generateForIn(localData,item.loop, item.expression.collection, (AssignableAVM2Item) item.expression.object, item.commands, false); + return generateForIn(localData, item.loop, item.expression.collection, (AssignableAVM2Item) item.expression.object, item.commands, false); } - public List generateForIn(SourceGeneratorLocalData localData,Loop loop, GraphTargetItem collection, AssignableAVM2Item assignable, List commands, final boolean each) throws CompilationException { + public List generateForIn(SourceGeneratorLocalData localData, Loop loop, GraphTargetItem collection, AssignableAVM2Item assignable, List commands, final boolean each) throws CompilationException { List ret = new ArrayList<>(); final Reference counterReg = new Reference<>(0); final Reference collectionReg = new Reference<>(0); - if(assignable instanceof UnresolvedAVM2Item){ - assignable = (AssignableAVM2Item)((UnresolvedAVM2Item)assignable).resolved; + if (assignable instanceof UnresolvedAVM2Item) { + assignable = (AssignableAVM2Item) ((UnresolvedAVM2Item) assignable).resolved; } - + ret.addAll(GraphTargetItem.toSourceMerge(localData, this, ins(new PushByteIns(), 0), AssignableAVM2Item.setTemp(localData, this, counterReg), @@ -1159,7 +1159,7 @@ public class AVM2SourceGenerator implements SourceGenerator { return abc; } - public void generateClass(List sinitVariables,boolean staticNeedsActivation, List staticInit,List openedNamespaces, int namespace, int initScope, PackageAVM2Item pkg, ClassInfo classInfo, InstanceInfo instanceInfo, SourceGeneratorLocalData localData, boolean isInterface, String name, String superName, GraphTargetItem extendsVal, List implementsStr, GraphTargetItem constructor, List traitItems) throws ParseException, CompilationException { + public void generateClass(List sinitVariables, boolean staticNeedsActivation, List staticInit, List openedNamespaces, int namespace, int initScope, PackageAVM2Item pkg, ClassInfo classInfo, InstanceInfo instanceInfo, SourceGeneratorLocalData localData, boolean isInterface, String name, String superName, GraphTargetItem extendsVal, List implementsStr, GraphTargetItem constructor, List traitItems) throws ParseException, CompilationException { localData.currentClass = pkg.packageName.isEmpty() ? name : pkg.packageName + "." + name; List ret = new ArrayList<>(); if (extendsVal == null && !isInterface) { @@ -1181,58 +1181,56 @@ public class AVM2SourceGenerator implements SourceGenerator { instanceInfo.iinit_index = init = method(new ArrayList(), pkg.packageName, m.needsActivation, m.subvariables, initScope + 1, m.hasRest, m.line, name, extendsVal != null ? extendsVal.toString() : null, true, localData, m.paramTypes, m.paramNames, m.paramValues, m.body, TypeItem.UNBOUNDED/*?? FIXME*/); } - - //Class initializer - int staticMi = method(new ArrayList(), pkg.packageName, staticNeedsActivation, sinitVariables, initScope, false,0, name, superName, false, localData, new ArrayList(),new ArrayList(),new ArrayList(), staticInit, TypeItem.UNBOUNDED); - MethodBody sinitBody=abc.findBody(staticMi); - + int staticMi = method(new ArrayList(), pkg.packageName, staticNeedsActivation, sinitVariables, initScope, false, 0, name, superName, false, localData, new ArrayList(), new ArrayList(), new ArrayList(), staticInit, TypeItem.UNBOUNDED); + MethodBody sinitBody = abc.findBody(staticMi); + List sinitcode = new ArrayList<>(); List initcode = new ArrayList<>(); - for (GraphTargetItem ti : traitItems) { - if ((ti instanceof SlotAVM2Item)||(ti instanceof ConstAVM2Item)) { + for (GraphTargetItem ti : traitItems) { + if ((ti instanceof SlotAVM2Item) || (ti instanceof ConstAVM2Item)) { GraphTargetItem val = null; boolean isStatic = false; - int ns=-1; - String tname=null; + int ns = -1; + String tname = null; boolean isConst = false; - if(ti instanceof SlotAVM2Item){ + if (ti instanceof SlotAVM2Item) { val = ((SlotAVM2Item) ti).value; isStatic = ((SlotAVM2Item) ti).isStatic(); ns = ((SlotAVM2Item) ti).getNamespace(); tname = ((SlotAVM2Item) ti).var; } - if(ti instanceof ConstAVM2Item){ + if (ti instanceof ConstAVM2Item) { val = ((ConstAVM2Item) ti).value; isStatic = ((ConstAVM2Item) ti).isStatic(); ns = ((ConstAVM2Item) ti).getNamespace(); tname = ((ConstAVM2Item) ti).var; isConst = true; } - if (isStatic && val!=null) { + if (isStatic && val != null) { sinitcode.add(ins(new FindPropertyIns(), traitName(ns, tname))); sinitcode.addAll(toInsList(val.toSource(localData, this))); - sinitcode.add(ins(isConst?new InitPropertyIns():new SetPropertyIns(), traitName(ns, tname))); + sinitcode.add(ins(isConst ? new InitPropertyIns() : new SetPropertyIns(), traitName(ns, tname))); } - if (!isStatic && val!=null) { + if (!isStatic && val != null) { //do not init basic values, that can be stored in trait - if(!(val instanceof IntegerValueAVM2Item) && !(val instanceof StringAVM2Item) && !(val instanceof BooleanAVM2Item) && !(val instanceof NullAVM2Item) && !(val instanceof UndefinedAVM2Item)){ + if (!(val instanceof IntegerValueAVM2Item) && !(val instanceof StringAVM2Item) && !(val instanceof BooleanAVM2Item) && !(val instanceof NullAVM2Item) && !(val instanceof UndefinedAVM2Item)) { initcode.add(ins(new GetLocal0Ins())); initcode.addAll(toInsList(val.toSource(localData, this))); - initcode.add(ins(isConst?new InitPropertyIns():new SetPropertyIns(), traitName(ns, tname))); + initcode.add(ins(isConst ? new InitPropertyIns() : new SetPropertyIns(), traitName(ns, tname))); } } } } - - MethodBody initBody=abc.findBody(init); - initBody.code.code.addAll(constructor==null?0:2,initcode);//after getlocal0,pushscope - - if(sinitBody.code.code.get(sinitBody.code.code.size()-1).definition instanceof ReturnVoidIns){ - sinitBody.code.code.addAll(2,sinitcode); //after getlocal0,pushscope + + MethodBody initBody = abc.findBody(init); + initBody.code.code.addAll(constructor == null ? 0 : 2, initcode);//after getlocal0,pushscope + + if (sinitBody.code.code.get(sinitBody.code.code.size() - 1).definition instanceof ReturnVoidIns) { + sinitBody.code.code.addAll(2, sinitcode); //after getlocal0,pushscope } sinitBody.markOffsets(); - sinitBody.autoFillStats(abc, initScope); + sinitBody.autoFillStats(abc, initScope); classInfo.cinit_index = staticMi; initBody.autoFillStats(abc, initScope + 1); @@ -1266,7 +1264,7 @@ public class AVM2SourceGenerator implements SourceGenerator { */ if (cls instanceof ClassAVM2Item) { ClassAVM2Item cai = (ClassAVM2Item) cls; - generateClass(cai.sinitVariables,cai.staticInitActivation,cai.staticInit,cai.openedNamespaces, namespace, initScope, pkg, ci, ii, localData, false, cai.className, cai.extendsOp.toString(), cai.extendsOp, cai.implementsOp, cai.constructor, cai.traits); + generateClass(cai.sinitVariables, cai.staticInitActivation, cai.staticInit, cai.openedNamespaces, namespace, initScope, pkg, ci, ii, localData, false, cai.className, cai.extendsOp.toString(), cai.extendsOp, cai.implementsOp, cai.constructor, cai.traits); if (!cai.isDynamic) { ii.flags |= InstanceInfo.CLASS_SEALED; } @@ -1278,7 +1276,7 @@ public class AVM2SourceGenerator implements SourceGenerator { } if (cls instanceof InterfaceAVM2Item) { InterfaceAVM2Item iai = (InterfaceAVM2Item) cls; - generateClass(new ArrayList(),false,new ArrayList(),iai.openedNamespaces, namespace, initScope, pkg, ci, ii, localData, true, iai.name, null, null, iai.superInterfaces, null, iai.methods); + generateClass(new ArrayList(), false, new ArrayList(), iai.openedNamespaces, namespace, initScope, pkg, ci, ii, localData, true, iai.name, null, null, iai.superInterfaces, null, iai.methods); ii.flags |= InstanceInfo.CLASS_INTERFACE; } @@ -1295,8 +1293,8 @@ public class AVM2SourceGenerator implements SourceGenerator { } if (type instanceof UnresolvedAVM2Item) { - String fullClass = localData.currentClass==null?null:(localData.pkg.isEmpty()?localData.currentClass:localData.pkg+"."+localData.currentClass); - type = ((UnresolvedAVM2Item) type).resolve(new TypeItem(fullClass),new ArrayList(), new ArrayList(), abc, allABCs, new ArrayList(), new ArrayList()); + String fullClass = localData.currentClass == null ? null : (localData.pkg.isEmpty() ? localData.currentClass : localData.pkg + "." + localData.currentClass); + type = ((UnresolvedAVM2Item) type).resolve(new TypeItem(fullClass), new ArrayList(), new ArrayList(), abc, allABCs, new ArrayList(), new ArrayList()); } String pkg = ""; @@ -1394,8 +1392,8 @@ public class AVM2SourceGenerator implements SourceGenerator { if (an instanceof UnresolvedAVM2Item) { UnresolvedAVM2Item n = (UnresolvedAVM2Item) an; if (n.resolved == null) { - String fullClass = localData.currentClass==null?null:(localData.pkg.isEmpty()?localData.currentClass:localData.pkg+"."+localData.currentClass); - GraphTargetItem res = n.resolve(new TypeItem(fullClass),paramTypes, paramNames, abc, allABCs, callStack, subvariables); + String fullClass = localData.currentClass == null ? null : (localData.pkg.isEmpty() ? localData.currentClass : localData.pkg + "." + localData.currentClass); + GraphTargetItem res = n.resolve(new TypeItem(fullClass), paramTypes, paramNames, abc, allABCs, callStack, subvariables); if (res instanceof AssignableAVM2Item) { subvariables.set(i, (AssignableAVM2Item) res); } else { @@ -1529,11 +1527,11 @@ public class AVM2SourceGenerator implements SourceGenerator { if (n.getNs() != null) { continue; } - - if("this".equals(n.getVariableName()) || paramNames.contains(n.getVariableName())||"argmuments".equals(n.getVariableName())){ + + if ("this".equals(n.getVariableName()) || paramNames.contains(n.getVariableName()) || "argmuments".equals(n.getVariableName())) { continue; } - + NameAVM2Item d = new NameAVM2Item(n.type, n.line, n.getVariableName(), NameAVM2Item.getDefaultValue("" + n.type), true, n.openedNamespaces); //no index if (needsActivation) { @@ -1716,8 +1714,6 @@ public class AVM2SourceGenerator implements SourceGenerator { return mbody.method_info; } - - public ValueKind getValueKind(int nsKind, GraphTargetItem type, GraphTargetItem val) { diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptParser.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptParser.java index 6620bf94c..ae8b7f3ce 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptParser.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptParser.java @@ -173,7 +173,7 @@ public class ActionScriptParser { ret = member(needsActivation, importedClasses, openedNamespaces, ret, registerVars, inFunction, inMethod, variables); break; case PARENT_OPEN: - ret = new CallAVM2Item(lexer.yyline(),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(); @@ -188,22 +188,22 @@ public class ActionScriptParser { while (s.isType(SymbolType.DOT, SymbolType.BRACKET_OPEN)) { ParsedSymbol s2 = lex(); boolean attr = false; - if(s.type == SymbolType.DOT){ - if(s2.type == SymbolType.ATTRIBUTE){ + if (s.type == SymbolType.DOT) { + if (s2.type == SymbolType.ATTRIBUTE) { attr = true; s = lex(); - }else{ + } else { lexer.pushback(s2); } - - }else{ - lexer.pushback(s2); + + } else { + lexer.pushback(s2); } if (s.type == SymbolType.BRACKET_OPEN) { - GraphTargetItem index = expression(needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); - expectedType(SymbolType.BRACKET_CLOSE); - ret = new IndexAVM2Item(attr, ret, index, null, openedNamespaces); - s = lex(); + GraphTargetItem index = expression(needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); + expectedType(SymbolType.BRACKET_CLOSE); + ret = new IndexAVM2Item(attr, ret, index, null, openedNamespaces); + s = lex(); } else { s = lex(); expected(s, lexer.yyline(), SymbolType.IDENTIFIER); @@ -216,7 +216,7 @@ public class ActionScriptParser { ns = new UnresolvedAVM2Item(new ArrayList(), importedClasses, false, null, lexer.yyline(), propName, null, openedNamespaces); variables.add((UnresolvedAVM2Item) ns); propName = s.value.toString(); - }else{ + } else { lexer.pushback(s); } if (ns != null) { @@ -336,12 +336,12 @@ public class ActionScriptParser { } if (s.type == SymbolType.BRACKET_OPEN) { lexer.pushback(s); - if(attrBracket){ - lexer.pushback(new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ATTRIBUTE,"@")); - lexer.pushback(new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.DOT,".")); + if (attrBracket) { + lexer.pushback(new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ATTRIBUTE, "@")); + lexer.pushback(new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.DOT, ".")); } ret = member(needsActivation, importedClasses, openedNamespaces, ret, registerVars, inFunction, inMethod, variables); - }else{ + } else { lexer.pushback(s); } return ret; @@ -738,7 +738,7 @@ public class ActionScriptParser { if (s.type == SymbolType.COLON) { type = type(new Reference(false), importedClasses, openedNamespaces, new ArrayList()); s = lex(); - }else{ + } else { type = TypeItem.UNBOUNDED; } @@ -2009,7 +2009,7 @@ public class ActionScriptParser { case NEW: GraphTargetItem newvar = name(needsActivation, true, openedNamespaces, registerVars, inFunction, inMethod, variables, importedClasses); expectedType(SymbolType.PARENT_OPEN); - ret = new ConstructSomethingAVM2Item(lexer.yyline(),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: diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/CallAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/CallAVM2Item.java index 9c236beeb..96417b47f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/CallAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/CallAVM2Item.java @@ -95,15 +95,14 @@ public class CallAVM2Item extends AVM2Item { p.setAssignedValue(n.getAssignedValue()); callable = p; } - - + int propIndex = -1; - if(callable instanceof TypeItem){ - TypeItem t=(TypeItem)callable; - propIndex = AVM2SourceGenerator.resolveType(t, ((AVM2SourceGenerator)generator).abc); + if (callable instanceof TypeItem) { + TypeItem t = (TypeItem) callable; + propIndex = AVM2SourceGenerator.resolveType(t, ((AVM2SourceGenerator) generator).abc); } Object obj = null; - + if (callable instanceof PropertyAVM2Item) { PropertyAVM2Item prop = (PropertyAVM2Item) callable; obj = prop.object; @@ -125,24 +124,24 @@ public class CallAVM2Item extends AVM2Item { Reference outPropNsKind = new Reference<>(1); Reference outPropType = new Reference<>(""); Reference outPropValue = new Reference<>(null); - 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()))) { + 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()); nobj.setRegNumber(0); obj = nobj; - } - } + } + } propIndex = prop.resolveProperty(localData); } - - if(propIndex!=-1){ - if(obj == null){ + + if (propIndex != -1) { + if (obj == null) { obj = new AVM2Instruction(0, new FindPropertyStrictIns(), new int[]{propIndex}, new byte[0]); } return toSourceMerge(localData, generator, obj, arguments, - ins(new CallPropertyIns(),propIndex,arguments.size()) + ins(new CallPropertyIns(), propIndex, arguments.size()) ); } - + throw new CompilationException("Not a callable", line); } @@ -180,15 +179,14 @@ public class CallAVM2Item extends AVM2Item { @Override public GraphTargetItem returnType() { GraphTargetItem callable = name; - if(callable instanceof UnresolvedAVM2Item){ - callable = ((UnresolvedAVM2Item)callable).resolved; + if (callable instanceof UnresolvedAVM2Item) { + callable = ((UnresolvedAVM2Item) callable).resolved; } - - if(callable instanceof TypeItem){ + + if (callable instanceof TypeItem) { return TypeItem.UNBOUNDED; } - - + GraphTargetItem ti = callable.returnType(); if (ti instanceof TypeFunctionItem) { TypeFunctionItem tfi = (TypeFunctionItem) ti; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ClassAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ClassAVM2Item.java index 221406469..d2ff03423 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ClassAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ClassAVM2Item.java @@ -51,7 +51,7 @@ public class ClassAVM2Item extends AVM2Item implements Block { return ret; } - public ClassAVM2Item(List openedNamespaces, int protectedNs, boolean isDynamic, boolean isFinal, int namespace, String className, GraphTargetItem extendsOp, List implementsOp, List staticInit,boolean staticInitActivation, List sinitVariables, GraphTargetItem constructor, List traits) { + public ClassAVM2Item(List openedNamespaces, int protectedNs, boolean isDynamic, boolean isFinal, int namespace, String className, GraphTargetItem extendsOp, List implementsOp, List staticInit, boolean staticInitActivation, List sinitVariables, GraphTargetItem constructor, List traits) { super(null, NOPRECEDENCE); this.protectedNs = protectedNs; this.className = className; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ConstructSomethingAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ConstructSomethingAVM2Item.java index 942997425..f55aed062 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ConstructSomethingAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ConstructSomethingAVM2Item.java @@ -43,8 +43,8 @@ public class ConstructSomethingAVM2Item extends CallAVM2Item { public List openedNamespaces; - public ConstructSomethingAVM2Item(int line,List openedNamespaces, GraphTargetItem name, List arguments) { - super(line,name, arguments); + public ConstructSomethingAVM2Item(int line, List openedNamespaces, GraphTargetItem name, List arguments) { + super(line, name, arguments); this.openedNamespaces = openedNamespaces; } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/IndexAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/IndexAVM2Item.java index bd832c38a..8c959ac04 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/IndexAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/IndexAVM2Item.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.decompiler.flash.abc.avm2.parser.script; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; @@ -54,23 +53,21 @@ public class IndexAVM2Item extends AssignableAVM2Item { public GraphTargetItem index; public boolean attr; - public IndexAVM2Item(boolean attr,GraphTargetItem object, GraphTargetItem index, GraphTargetItem storeValue,List openedNamespaces) { + public IndexAVM2Item(boolean attr, GraphTargetItem object, GraphTargetItem index, GraphTargetItem storeValue, List openedNamespaces) { super(storeValue); this.object = object; this.index = index; this.openedNamespaces = openedNamespaces; this.attr = attr; } - - - private int allNsSet(ABC abc) { + + private int allNsSet(ABC abc) { int nssa[] = new int[openedNamespaces.size()]; for (int i = 0; i < openedNamespaces.size(); i++) { nssa[i] = openedNamespaces.get(i); } return abc.constants.getNamespaceSetId(new NamespaceSet(nssa), true); } - @Override public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException { @@ -89,72 +86,66 @@ public class IndexAVM2Item extends AssignableAVM2Item { @Override public AssignableAVM2Item copy() { - return new IndexAVM2Item(attr,object,index,assignedValue,openedNamespaces); + return new IndexAVM2Item(attr, object, index, assignedValue, openedNamespaces); } @Override public List toSourceChange(SourceGeneratorLocalData localData, SourceGenerator generator, boolean post, boolean decrement, boolean needsReturn) throws CompilationException { - Reference obj_temp=new Reference<>(-1); - Reference index_temp=new Reference<>(-1); + Reference obj_temp = new Reference<>(-1); + Reference index_temp = new Reference<>(-1); Reference val_temp = new Reference<>(-1); - AVM2SourceGenerator g=(AVM2SourceGenerator)generator; - int indexPropIndex = g.abc.constants.getMultinameId(new Multiname(attr?Multiname.MULTINAMELA:Multiname.MULTINAMEL, 0, 0, allNsSet(g.abc), 0, new ArrayList()), true); - - return toSourceMerge(localData, generator, - object,dupSetTemp(localData, generator, obj_temp), - index,dupSetTemp(localData, generator, index_temp), - ins(new GetPropertyIns(),indexPropIndex), - post?ins(new ConvertDIns()):null, - (!post)?(decrement?ins(new DecrementIns()):ins(new IncrementIns())):null, - needsReturn?ins(new DupIns()):null, - post?(decrement?ins(new DecrementIns()):ins(new IncrementIns())):null, + AVM2SourceGenerator g = (AVM2SourceGenerator) generator; + int indexPropIndex = g.abc.constants.getMultinameId(new Multiname(attr ? Multiname.MULTINAMELA : Multiname.MULTINAMEL, 0, 0, allNsSet(g.abc), 0, new ArrayList()), true); + + return toSourceMerge(localData, generator, + object, dupSetTemp(localData, generator, obj_temp), + index, dupSetTemp(localData, generator, index_temp), + ins(new GetPropertyIns(), indexPropIndex), + post ? ins(new ConvertDIns()) : null, + (!post) ? (decrement ? ins(new DecrementIns()) : ins(new IncrementIns())) : null, + needsReturn ? ins(new DupIns()) : null, + post ? (decrement ? ins(new DecrementIns()) : ins(new IncrementIns())) : null, setTemp(localData, generator, val_temp), getTemp(localData, generator, obj_temp), getTemp(localData, generator, index_temp), getTemp(localData, generator, val_temp), - ins(new SetPropertyIns(),indexPropIndex), - killTemp(localData, generator, Arrays.asList(val_temp,obj_temp,index_temp)) - ); - + ins(new SetPropertyIns(), indexPropIndex), + killTemp(localData, generator, Arrays.asList(val_temp, obj_temp, index_temp)) + ); + } - - + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn) throws CompilationException { - AVM2SourceGenerator g = (AVM2SourceGenerator)generator; - int indexPropIndex = g.abc.constants.getMultinameId(new Multiname(attr?Multiname.MULTINAMELA:Multiname.MULTINAMEL, 0, 0, allNsSet(g.abc), 0, new ArrayList()), true); + AVM2SourceGenerator g = (AVM2SourceGenerator) generator; + int indexPropIndex = g.abc.constants.getMultinameId(new Multiname(attr ? Multiname.MULTINAMELA : Multiname.MULTINAMEL, 0, 0, allNsSet(g.abc), 0, new ArrayList()), true); Reference ret_temp = new Reference<>(-1); - - if(assignedValue!=null){ + + if (assignedValue != null) { return toSourceMerge(localData, generator, - object, - index, - assignedValue, - needsReturn ? dupSetTemp(localData, generator, ret_temp) : null, - ins(new SetPropertyIns(), indexPropIndex), - needsReturn ? getTemp(localData, generator, ret_temp) : null, - killTemp(localData, generator, Arrays.asList(ret_temp))); - }else{ + object, + index, + assignedValue, + needsReturn ? dupSetTemp(localData, generator, ret_temp) : null, + ins(new SetPropertyIns(), indexPropIndex), + needsReturn ? getTemp(localData, generator, ret_temp) : null, + killTemp(localData, generator, Arrays.asList(ret_temp))); + } else { return toSourceMerge(localData, generator, - object, - index, - ins(new GetPropertyIns(), indexPropIndex)); + object, + index, + ins(new GetPropertyIns(), indexPropIndex)); } - + } - @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { - return toSource(localData, generator, true); + return toSource(localData, generator, true); } @Override public List toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { return toSource(localData, generator, false); } - - - - - + } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NameAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NameAVM2Item.java index 5008da5b5..359ebf36d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NameAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NameAVM2Item.java @@ -143,7 +143,6 @@ public class NameAVM2Item extends AssignableAVM2Item { public int getNsKind() { return nsKind; } - public String getVariableName() { return variableName; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NamespacedAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NamespacedAVM2Item.java index b0bca8805..350b2b677 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NamespacedAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NamespacedAVM2Item.java @@ -91,26 +91,26 @@ public class NamespacedAVM2Item extends AssignableAVM2Item { Reference name_temp = new Reference<>(-1); Reference ret_temp = new Reference<>(-1); /*if (name == null && index != null) { - return toSourceMerge(localData, generator, - ns, generateCoerce(generator, new TypeItem("Namespace")), index, ins(new ConvertSIns()), - ins(new FindPropertyStrictIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAMEL, 0, 0, 0, 0, new ArrayList()), true)), - dupSetTemp(localData, generator, name_temp), - ns, generateCoerce(generator, new TypeItem("Namespace")), - dupSetTemp(localData, generator, ns_temp), - ins(new GetPropertyIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.MULTINAMEL, 0, 0, allNsSet(g.abc), 0, new ArrayList()), true)), - !isInteger ? ins(new ConvertDIns()) : null, - //End get original - (!post) ? (decrement ? ins(isInteger ? new DecrementIIns() : new DecrementIns()) : ins(isInteger ? new IncrementIIns() : new IncrementIns())) : null, - needsReturn ? ins(new DupIns()) : null, - (post) ? (decrement ? ins(isInteger ? new DecrementIIns() : new DecrementIns()) : ins(isInteger ? new IncrementIIns() : new IncrementIns())) : null, - setTemp(localData, generator, ret_temp), - getTemp(localData, generator, name_temp), - getTemp(localData, generator, ns_temp), - getTemp(localData, generator, ret_temp), - ins(new SetPropertyIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.MULTINAMEL, 0, 0, allNsSet(g.abc), 0, new ArrayList()), true)), - killTemp(localData, generator, Arrays.asList(ret_temp, name_temp, ns_temp))); - } else - */ + return toSourceMerge(localData, generator, + ns, generateCoerce(generator, new TypeItem("Namespace")), index, ins(new ConvertSIns()), + ins(new FindPropertyStrictIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAMEL, 0, 0, 0, 0, new ArrayList()), true)), + dupSetTemp(localData, generator, name_temp), + ns, generateCoerce(generator, new TypeItem("Namespace")), + dupSetTemp(localData, generator, ns_temp), + ins(new GetPropertyIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.MULTINAMEL, 0, 0, allNsSet(g.abc), 0, new ArrayList()), true)), + !isInteger ? ins(new ConvertDIns()) : null, + //End get original + (!post) ? (decrement ? ins(isInteger ? new DecrementIIns() : new DecrementIns()) : ins(isInteger ? new IncrementIIns() : new IncrementIns())) : null, + needsReturn ? ins(new DupIns()) : null, + (post) ? (decrement ? ins(isInteger ? new DecrementIIns() : new DecrementIns()) : ins(isInteger ? new IncrementIIns() : new IncrementIns())) : null, + setTemp(localData, generator, ret_temp), + getTemp(localData, generator, name_temp), + getTemp(localData, generator, ns_temp), + getTemp(localData, generator, ret_temp), + ins(new SetPropertyIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.MULTINAMEL, 0, 0, allNsSet(g.abc), 0, new ArrayList()), true)), + killTemp(localData, generator, Arrays.asList(ret_temp, name_temp, ns_temp))); + } else + */ if (name != null) { return toSourceMerge(localData, generator, ns, generateCoerce(generator, new TypeItem("Namespace")), diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java index 211349e34..4db70ee96 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java @@ -509,7 +509,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item { GraphTargetItem coerced = assignedValue; if (!targetType.equals(srcType) && !propertyName.startsWith("@")) { coerced = new CoerceAVM2Item(null, assignedValue, targetType); - } + } return toSourceMerge(localData, generator, obj, coerced, needsReturn ? dupSetTemp(localData, generator, ret_temp) : null, ins(new SetPropertyIns(), propertyId), @@ -567,7 +567,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item { List abcs = new ArrayList<>(); abcs.add(abc); abcs.addAll(otherABCs); - if (cname != null && AVM2SourceGenerator.searchPrototypeChain(true, abcs, pkgName, cname, propertyName, outName, outNs, outPropNs, outPropNsKind, outPropType, outPropValue) && (localData.currentClass.equals("".equals(outNs.getVal())?outName.getVal():outNs.getVal()+"."+outName.getVal())) ) { + if (cname != null && AVM2SourceGenerator.searchPrototypeChain(true, abcs, pkgName, cname, 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, openedNamespaces); nobj.setRegNumber(0); obj = nobj; @@ -611,7 +611,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item { needsReturn ? ins(new DupIns()) : null, (post) ? (decrement ? ins(isInteger ? new DecrementIIns() : new DecrementIns()) : ins(isInteger ? new IncrementIIns() : new IncrementIns())) : null, setTemp(localData, generator, ret_temp), - getTemp(localData, generator, obj_temp), + getTemp(localData, generator, obj_temp), getTemp(localData, generator, ret_temp), ins(new SetPropertyIns(), propertyId), //needsReturn?getTemp(localData, generator, ret_temp):null, diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/UnresolvedAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/UnresolvedAVM2Item.java index e9d1416ef..4e02e62c8 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/UnresolvedAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/UnresolvedAVM2Item.java @@ -128,7 +128,6 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { } } - public void setNsKind(int nsKind) { this.nsKind = nsKind; } @@ -261,7 +260,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { @Override public GraphTargetItem returnType() { - if(resolved != null){ + if (resolved != null) { return resolved.returnType(); } if (type == null) { @@ -281,7 +280,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { throw new RuntimeException("Cannot assign"); } - public GraphTargetItem resolve(GraphTargetItem thisType,List paramTypes, List paramNames, ABC abc, List otherAbcs, List callStack, List variables) throws CompilationException { + public GraphTargetItem resolve(GraphTargetItem thisType, List paramTypes, List paramNames, ABC abc, List otherAbcs, List callStack, List variables) throws CompilationException { List parts = new ArrayList<>(); if (name.contains(".")) { String partsArr[] = name.split("\\."); @@ -332,7 +331,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { continue; } UnresolvedAVM2Item su = new UnresolvedAVM2Item(new ArrayList(), importedClasses, true, null, line, s, null, openedNamespaces); - su.resolve(thisType,paramTypes, paramNames, abc, otherAbcs, callStack, variables); + su.resolve(thisType, paramTypes, paramNames, abc, otherAbcs, callStack, variables); if (!(su.resolved instanceof TypeItem)) { throw new CompilationException("Not a type", line); } @@ -368,7 +367,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { TypeItem ret = new TypeItem(fname); for (String s : subtypes) { UnresolvedAVM2Item su = new UnresolvedAVM2Item(new ArrayList(), importedClasses, true, null, line, s, null, openedNamespaces); - su.resolve(thisType,paramTypes, paramNames, abc, otherAbcs, callStack, variables); + su.resolve(thisType, paramTypes, paramNames, abc, otherAbcs, callStack, variables); if (!(su.resolved instanceof TypeItem)) { throw new CompilationException("Not a type", line); } @@ -381,7 +380,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { if (j == parts.size() - 1) { ((PropertyAVM2Item) resolved).assignedValue = assignedValue; } - } + } if (parts.size() == i + 1 && assignedValue != null) { throw new CompilationException("Cannot assign type", line); } @@ -406,7 +405,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { TypeItem ret = new TypeItem(a.instance_info.get(c).getName(a.constants).getNameWithNamespace(a.constants)); for (String s : subtypes) { UnresolvedAVM2Item su = new UnresolvedAVM2Item(new ArrayList(), importedClasses, true, null, line, s, null, openedNamespaces); - su.resolve(thisType,paramTypes, paramNames, abc, otherAbcs, callStack, variables); + su.resolve(thisType, paramTypes, paramNames, abc, otherAbcs, callStack, variables); if (!(su.resolved instanceof TypeItem)) { throw new CompilationException("Not a type", line); } @@ -431,12 +430,11 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { } } - - if(parts.get(0).equals("this") ){ - if(thisType == null){ + if (parts.get(0).equals("this")) { + if (thisType == null) { throw new CompilationException("Cannot use this in that context", line); - } - GraphTargetItem ret = new NameAVM2Item(thisType, line, parts.get(0), null, false, openedNamespaces); + } + GraphTargetItem ret = new NameAVM2Item(thisType, line, parts.get(0), null, false, openedNamespaces); resolved = ret; for (int i = 1; i < parts.size(); i++) { resolved = new PropertyAVM2Item(resolved, parts.get(i), abc, otherAbcs, openedNamespaces, new ArrayList()); @@ -449,7 +447,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { } return ret; } - + if (paramNames.contains(parts.get(0)) || parts.get(0).equals("arguments")) { int ind = paramNames.indexOf(parts.get(0)); @@ -471,7 +469,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { TypeItem ret = new TypeItem("__AS3__.vec.Vector"); for (String s : subtypes) { UnresolvedAVM2Item su = new UnresolvedAVM2Item(new ArrayList(), importedClasses, true, null, line, s, null, openedNamespaces); - su.resolve(thisType,paramTypes, paramNames, abc, otherAbcs, callStack, variables); + su.resolve(thisType, paramTypes, paramNames, abc, otherAbcs, callStack, variables); if (!(su.resolved instanceof TypeItem)) { throw new CompilationException("Not a type", line); } @@ -493,8 +491,8 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { ((PropertyAVM2Item) resolved).scopeStack = scopeStack; ret = resolved; } - if(i == parts.size()-1){ - ((PropertyAVM2Item)resolved).setAssignedValue(assignedValue); + if (i == parts.size() - 1) { + ((PropertyAVM2Item) resolved).setAssignedValue(assignedValue); } } return ret; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java index cfa194319..01fae348d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java @@ -67,10 +67,10 @@ public class MethodBody implements Cloneable, Serializable { } return ret; } - - public void markOffsets(){ + + public void markOffsets() { long offset = 0; - for(int i=0;i warningExperimentalAS12Edit = null; - + @ConfigurationDefaultBoolean(true) @ConfigurationName("warning.experimental.as3edit") public static final ConfigurationItem warningExperimentalAS3Edit = null; - - + private enum OSId { WINDOWS, OSX, UNIX @@ -629,7 +628,7 @@ public class Configuration { public static File getPlayerSWC() { File libsdir = getFlashLibPath(); - if (libsdir!=null && libsdir.exists()) { + if (libsdir != null && libsdir.exists()) { File libs[] = libsdir.listFiles(new FilenameFilter() { @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/TextExporter.java b/trunk/src/com/jpexs/decompiler/flash/exporters/TextExporter.java index 3b100fc4f..65a910670 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/TextExporter.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/TextExporter.java @@ -41,7 +41,7 @@ public class TextExporter { public static final String TEXT_EXPORT_FOLDER = "texts"; public static final String TEXT_EXPORT_FILENAME_FORMATTED = "textsformatted.txt"; public static final String TEXT_EXPORT_FILENAME_PLAIN = "textsplain.txt"; - + public List exportTexts(AbortRetryIgnoreHandler handler, String outdir, List tags, final TextExportSettings settings) throws IOException { List ret = new ArrayList<>(); if (tags.isEmpty()) { @@ -57,8 +57,8 @@ public class TextExporter { } if (settings.singleFile) { - final File file = new File(outdir + File.separator + - (settings.mode == TextExportMode.FORMATTED ? TEXT_EXPORT_FILENAME_FORMATTED : TEXT_EXPORT_FILENAME_PLAIN)); + final File file = new File(outdir + File.separator + + (settings.mode == TextExportMode.FORMATTED ? TEXT_EXPORT_FILENAME_FORMATTED : TEXT_EXPORT_FILENAME_PLAIN)); try (FileOutputStream fos = new FileOutputStream(file)) { for (final Tag t : tags) { if (t instanceof TextTag) { diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/commonshape/SVGExporter.java b/trunk/src/com/jpexs/decompiler/flash/exporters/commonshape/SVGExporter.java index eb716527d..6fc94da42 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/commonshape/SVGExporter.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/commonshape/SVGExporter.java @@ -85,7 +85,7 @@ public class SVGExporter { + roundPixels20(-bounds.xMin / (double) SWF.unitDivisor) + ", " + roundPixels20(-bounds.yMin / (double) SWF.unitDivisor) + ")"); _svg.getDocumentElement().appendChild(_svgG); } - + public final void createNewGroup(Matrix transform) { _svgG = _svg.createElement("g"); double translateX = roundPixels400(transform.translateX / SWF.unitDivisor); @@ -98,19 +98,19 @@ public class SVGExporter { + ", " + rotateSkew1 + ", " + scaleY + ", " + translateX + ", " + translateY + ")"); _svg.getDocumentElement().appendChild(_svgG); } - + public void addToGroup(Node newChild) { _svgG.appendChild(newChild); } - + public void addToDefs(Node newChild) { _svgDefs.appendChild(newChild); } - + public Element createElement(String tagName) { return _svg.createElement(tagName); } - + public String getSVG() { TransformerFactory transformerFactory = TransformerFactory.newInstance(); StringWriter writer = new StringWriter(); diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/settings/BinaryDataExportSettings.java b/trunk/src/com/jpexs/decompiler/flash/exporters/settings/BinaryDataExportSettings.java index 6257f3e65..341a7092e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/settings/BinaryDataExportSettings.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/settings/BinaryDataExportSettings.java @@ -25,7 +25,7 @@ import com.jpexs.decompiler.flash.exporters.modes.BinaryDataExportMode; public class BinaryDataExportSettings { public BinaryDataExportMode mode; - + public BinaryDataExportSettings(BinaryDataExportMode mode) { this.mode = mode; } diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/settings/FontExportSettings.java b/trunk/src/com/jpexs/decompiler/flash/exporters/settings/FontExportSettings.java index 3a6e636bf..b371d7158 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/settings/FontExportSettings.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/settings/FontExportSettings.java @@ -25,7 +25,7 @@ import com.jpexs.decompiler.flash.exporters.modes.FontExportMode; public class FontExportSettings { public FontExportMode mode; - + public FontExportSettings(FontExportMode mode) { this.mode = mode; } diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/settings/FramesExportSettings.java b/trunk/src/com/jpexs/decompiler/flash/exporters/settings/FramesExportSettings.java index 49d7e53f7..8e5c13749 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/settings/FramesExportSettings.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/settings/FramesExportSettings.java @@ -25,7 +25,7 @@ import com.jpexs.decompiler.flash.exporters.modes.FramesExportMode; public class FramesExportSettings { public FramesExportMode mode; - + public FramesExportSettings(FramesExportMode mode) { this.mode = mode; } diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/settings/ImageExportSettings.java b/trunk/src/com/jpexs/decompiler/flash/exporters/settings/ImageExportSettings.java index 9020be97b..373d3b0f4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/settings/ImageExportSettings.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/settings/ImageExportSettings.java @@ -25,7 +25,7 @@ import com.jpexs.decompiler.flash.exporters.modes.ImageExportMode; public class ImageExportSettings { public ImageExportMode mode; - + public ImageExportSettings(ImageExportMode mode) { this.mode = mode; } diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/settings/MorphShapeExportSettings.java b/trunk/src/com/jpexs/decompiler/flash/exporters/settings/MorphShapeExportSettings.java index ec2b8fd8f..221891aea 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/settings/MorphShapeExportSettings.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/settings/MorphShapeExportSettings.java @@ -25,7 +25,7 @@ import com.jpexs.decompiler.flash.exporters.modes.MorphShapeExportMode; public class MorphShapeExportSettings { public MorphShapeExportMode mode; - + public MorphShapeExportSettings(MorphShapeExportMode mode) { this.mode = mode; } diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/settings/MovieExportSettings.java b/trunk/src/com/jpexs/decompiler/flash/exporters/settings/MovieExportSettings.java index fc4f24ccf..40fbe1002 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/settings/MovieExportSettings.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/settings/MovieExportSettings.java @@ -25,7 +25,7 @@ import com.jpexs.decompiler.flash.exporters.modes.MovieExportMode; public class MovieExportSettings { public MovieExportMode mode; - + public MovieExportSettings(MovieExportMode mode) { this.mode = mode; } diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/settings/ScriptExportSettings.java b/trunk/src/com/jpexs/decompiler/flash/exporters/settings/ScriptExportSettings.java index 5515688e8..c61a0f997 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/settings/ScriptExportSettings.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/settings/ScriptExportSettings.java @@ -25,7 +25,7 @@ import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; public class ScriptExportSettings { public ScriptExportMode mode; - + public ScriptExportSettings(ScriptExportMode mode) { this.mode = mode; } diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/settings/ShapeExportSettings.java b/trunk/src/com/jpexs/decompiler/flash/exporters/settings/ShapeExportSettings.java index 6b92bf018..e5cba35e4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/settings/ShapeExportSettings.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/settings/ShapeExportSettings.java @@ -25,7 +25,7 @@ import com.jpexs.decompiler.flash.exporters.modes.ShapeExportMode; public class ShapeExportSettings { public ShapeExportMode mode; - + public ShapeExportSettings(ShapeExportMode mode) { this.mode = mode; } diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/settings/SoundExportSettings.java b/trunk/src/com/jpexs/decompiler/flash/exporters/settings/SoundExportSettings.java index 7d4c1ab2d..40d037e96 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/settings/SoundExportSettings.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/settings/SoundExportSettings.java @@ -25,7 +25,7 @@ import com.jpexs.decompiler.flash.exporters.modes.SoundExportMode; public class SoundExportSettings { public SoundExportMode mode; - + public SoundExportSettings(SoundExportMode mode) { this.mode = mode; } diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/settings/TextExportSettings.java b/trunk/src/com/jpexs/decompiler/flash/exporters/settings/TextExportSettings.java index 13074c72e..3f6a243df 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/settings/TextExportSettings.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/settings/TextExportSettings.java @@ -26,7 +26,7 @@ public class TextExportSettings { public TextExportMode mode; public boolean singleFile; - + public TextExportSettings(TextExportMode mode, boolean singleFile) { this.mode = mode; this.singleFile = singleFile; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/Main.java b/trunk/src/com/jpexs/decompiler/flash/gui/Main.java index 682fc8a81..5406159bb 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/Main.java @@ -28,7 +28,6 @@ import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.console.CommandLineArgumentParser; import com.jpexs.decompiler.flash.console.ContextMenuTools; -import com.jpexs.decompiler.flash.gui.player.FlashPlayerPanel; import com.jpexs.decompiler.flash.gui.proxy.ProxyFrame; import com.jpexs.decompiler.flash.tags.base.FontTag; import com.jpexs.decompiler.flash.treeitems.SWFList; @@ -1014,9 +1013,6 @@ public class Main { public static void exit() { Configuration.saveConfig(); - if (!GraphicsEnvironment.isHeadless()) { - FlashPlayerPanel.unload(); - } System.exit(0); } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameClassic.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameClassic.java index 96daf512f..d85019eb9 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameClassic.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameClassic.java @@ -45,6 +45,16 @@ public final class MainFrameClassic extends AppFrame implements MainFrame { } catch (FlashUnsupportedException fue) { } + addWindowListener(new java.awt.event.WindowAdapter() { + + @Override + public void windowClosed(java.awt.event.WindowEvent evt) { + if (panel != null) { + panel.unloadFlashPlayer(); + } + } + }); + boolean externalFlashPlayerUnavailable = flashPanel == null; mainMenu = new MainFrameClassicMenu(this, externalFlashPlayerUnavailable); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java index b9cd92157..2c635c3b7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java @@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.gui.player.FlashPlayerPanel; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; +import java.awt.Container; import java.awt.Dimension; import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; @@ -50,7 +51,17 @@ public final class MainFrameRibbon extends AppRibbonFrame implements MainFrame { } catch (FlashUnsupportedException fue) { } - java.awt.Container cnt = getContentPane(); + addWindowListener(new java.awt.event.WindowAdapter() { + + @Override + public void windowClosed(java.awt.event.WindowEvent evt) { + if (panel != null) { + panel.unloadFlashPlayer(); + } + } + }); + + Container cnt = getContentPane(); cnt.setLayout(new BorderLayout()); JRibbon ribbon = getRibbon(); cnt.add(ribbon, BorderLayout.NORTH); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java index e3aceda69..6b22a33c3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -1282,25 +1282,25 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec } final ScriptExportMode scriptMode = export.getValue(ScriptExportMode.class); - ret.addAll(new ImageExporter().exportImages(handler, selFile + File.separator + "images", images, + ret.addAll(new ImageExporter().exportImages(handler, selFile + File.separator + "images", images, new ImageExportSettings(export.getValue(ImageExportMode.class)))); - ret.addAll(new ShapeExporter().exportShapes(handler, selFile + File.separator + "shapes", shapes, + ret.addAll(new ShapeExporter().exportShapes(handler, selFile + File.separator + "shapes", shapes, new ShapeExportSettings(export.getValue(ShapeExportMode.class)))); - ret.addAll(new MorphShapeExporter().exportMorphShapes(handler, selFile + File.separator + "morphshapes", morphshapes, + ret.addAll(new MorphShapeExporter().exportMorphShapes(handler, selFile + File.separator + "morphshapes", morphshapes, new MorphShapeExportSettings(export.getValue(MorphShapeExportMode.class)))); - ret.addAll(new TextExporter().exportTexts(handler, selFile + File.separator + "texts", texts, + ret.addAll(new TextExporter().exportTexts(handler, selFile + File.separator + "texts", texts, new TextExportSettings(export.getValue(TextExportMode.class), Configuration.textExportSingleFile.get()))); - ret.addAll(new MovieExporter().exportMovies(handler, selFile + File.separator + "movies", movies, + ret.addAll(new MovieExporter().exportMovies(handler, selFile + File.separator + "movies", movies, new MovieExportSettings(export.getValue(MovieExportMode.class)))); - ret.addAll(new SoundExporter().exportSounds(handler, selFile + File.separator + "sounds", sounds, + ret.addAll(new SoundExporter().exportSounds(handler, selFile + File.separator + "sounds", sounds, new SoundExportSettings(export.getValue(SoundExportMode.class)))); - ret.addAll(new BinaryDataExporter().exportBinaryData(handler, selFile + File.separator + "binaryData", binaryData, + ret.addAll(new BinaryDataExporter().exportBinaryData(handler, selFile + File.separator + "binaryData", binaryData, new BinaryDataExportSettings(export.getValue(BinaryDataExportMode.class)))); - ret.addAll(new FontExporter().exportFonts(handler, selFile + File.separator + "fonts", fonts, + ret.addAll(new FontExporter().exportFonts(handler, selFile + File.separator + "fonts", fonts, new FontExportSettings(export.getValue(FontExportMode.class)))); for (Entry> entry : frames.entrySet()) { - ret.addAll(swf.exportFrames(handler, selFile + File.separator + "frames", entry.getKey(), entry.getValue(), + ret.addAll(swf.exportFrames(handler, selFile + File.separator + "frames", entry.getKey(), entry.getValue(), new FramesExportSettings(export.getValue(FramesExportMode.class)))); } List abcList = swf.abcList; @@ -1656,7 +1656,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec }.execute(); } } - + private Map splitTextRecords(String texts) { String[] textsArr = texts.split(Helper.newLine + Configuration.textExportSingleFileSeparator.get() + Helper.newLine); String recordSeparator = Helper.newLine + Configuration.textExportSingleFileRecordSeparator.get() + Helper.newLine; @@ -1817,27 +1817,27 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec if (onlySel) { exportSelection(errorHandler, selFile, export); } else { - swf.exportImages(errorHandler, selFile + File.separator + "images", + swf.exportImages(errorHandler, selFile + File.separator + "images", new ImageExportSettings(export.getValue(ImageExportMode.class))); - swf.exportShapes(errorHandler, selFile + File.separator + "shapes", + swf.exportShapes(errorHandler, selFile + File.separator + "shapes", new ShapeExportSettings(export.getValue(ShapeExportMode.class))); - swf.exportMorphShapes(errorHandler, selFile + File.separator + "morphshapes", + swf.exportMorphShapes(errorHandler, selFile + File.separator + "morphshapes", new MorphShapeExportSettings(export.getValue(MorphShapeExportMode.class))); - swf.exportTexts(errorHandler, selFile + File.separator + "texts", + swf.exportTexts(errorHandler, selFile + File.separator + "texts", new TextExportSettings(export.getValue(TextExportMode.class), Configuration.textExportSingleFile.get())); - swf.exportMovies(errorHandler, selFile + File.separator + "movies", + swf.exportMovies(errorHandler, selFile + File.separator + "movies", new MovieExportSettings(export.getValue(MovieExportMode.class))); - swf.exportSounds(errorHandler, selFile + File.separator + "sounds", + swf.exportSounds(errorHandler, selFile + File.separator + "sounds", new SoundExportSettings(export.getValue(SoundExportMode.class))); - swf.exportBinaryData(errorHandler, selFile + File.separator + "binaryData", + swf.exportBinaryData(errorHandler, selFile + File.separator + "binaryData", new BinaryDataExportSettings(export.getValue(BinaryDataExportMode.class))); - swf.exportFonts(errorHandler, selFile + File.separator + "fonts", + swf.exportFonts(errorHandler, selFile + File.separator + "fonts", new FontExportSettings(export.getValue(FontExportMode.class))); - swf.exportFrames(errorHandler, selFile + File.separator + "frames", 0, null, + swf.exportFrames(errorHandler, selFile + File.separator + "frames", 0, null, new FramesExportSettings(export.getValue(FramesExportMode.class))); for (CharacterTag c : swf.characters.values()) { if (c instanceof DefineSpriteTag) { - swf.exportFrames(errorHandler, selFile + File.separator + "frames", c.getCharacterId(), null, + swf.exportFrames(errorHandler, selFile + File.separator + "frames", c.getCharacterId(), null, new FramesExportSettings(export.getValue(FramesExportMode.class))); } } @@ -2323,6 +2323,16 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec reload(false); } + public void unloadFlashPlayer() { + if (flashPanel != null) { + try { + flashPanel.close(); + } catch (IOException ex) { + // ignore + } + } + } + private void stopFlashPlayer() { if (flashPanel != null) { if (!flashPanel.isStopped()) { diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/View.java b/trunk/src/com/jpexs/decompiler/flash/gui/View.java index ca7926229..980a59b92 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/View.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/View.java @@ -363,21 +363,20 @@ public class View { }); return ret[0]; } - - + public static int showConfirmDialog(final Component parentComponent, String message, final String title, final int optionType, final int messageTyp, ConfigurationItem showAgainConfig, int defaultOption) { - + JLabel warLabel = new JLabel(message); final JPanel warPanel = new JPanel(new BorderLayout()); - warPanel.add(warLabel,BorderLayout.CENTER); + warPanel.add(warLabel, BorderLayout.CENTER); JCheckBox donotShowAgainCheckBox = new JCheckBox(AppStrings.translate("message.confirm.donotshowagain")); donotShowAgainCheckBox.setSelected(!showAgainConfig.get()); - warPanel.add(donotShowAgainCheckBox,BorderLayout.SOUTH); - - if(donotShowAgainCheckBox.isSelected()){ + warPanel.add(donotShowAgainCheckBox, BorderLayout.SOUTH); + + if (donotShowAgainCheckBox.isSelected()) { return defaultOption; } - + final int ret[] = new int[1]; execInEventDispatch(new Runnable() { @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java index 8d591d2c5..aba5dca70 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java @@ -135,12 +135,12 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se static final String ACTION_SAVE_DECOMPILED = "SAVEDECOMPILED"; static final String ACTION_EDIT_DECOMPILED = "EDITDECOMPILED"; static final String ACTION_CANCEL_DECOMPILED = "CANCELDECOMPILED"; - + public JLabel experimentalLabel = new JLabel(AppStrings.translate("action.edit.experimental")); public JButton editDecompiledButton = new JButton(AppStrings.translate("button.edit"), View.getIcon("edit16")); public JButton saveDecompiledButton = new JButton(AppStrings.translate("button.save"), View.getIcon("save16")); public JButton cancelDecompiledButton = new JButton(AppStrings.translate("button.cancel"), View.getIcon("cancel16")); - + static final String ACTION_ADD_TRAIT = "ADDTRAIT"; public boolean search(String txt, boolean ignoreCase, boolean regexp) { @@ -379,7 +379,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se iconDecPanel.add(scriptNameLabel); iconDecPanel.add(iconsPanel); iconDecPanel.add(decompiledScrollPane); - + JPanel decButtonsPan = new JPanel(new FlowLayout()); decButtonsPan.setBorder(new BevelBorder(BevelBorder.RAISED)); decButtonsPan.add(editDecompiledButton); @@ -390,7 +390,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se editDecompiledButton.setMargin(new Insets(3, 3, 3, 10)); saveDecompiledButton.setMargin(new Insets(3, 3, 3, 10)); cancelDecompiledButton.setMargin(new Insets(3, 3, 3, 10)); - + saveDecompiledButton.addActionListener(this); saveDecompiledButton.setActionCommand(ACTION_SAVE_DECOMPILED); editDecompiledButton.addActionListener(this); @@ -401,7 +401,6 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se saveDecompiledButton.setVisible(false); cancelDecompiledButton.setVisible(false); decButtonsPan.setAlignmentX(0); - JPanel decPanel = new JPanel(new BorderLayout()); decPanel.add(searchPanel, BorderLayout.NORTH); @@ -422,7 +421,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se splitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent pce) { - if(!directEditing){ + if (!directEditing) { Configuration.guiAvm2SplitPaneDividerLocation.set((int) pce.getNewValue()); } } @@ -587,12 +586,11 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se searchPanel.showQuickFindDialog(decompiledTextArea); } - public String lastDecompiled = null; public boolean directEditing = false; private int detWidth = 0; private int detsp = 0; - + public void setDecompiledEditMode(boolean val) { if (val) { lastDecompiled = decompiledTextArea.getText(); @@ -616,25 +614,25 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se cancelDecompiledButton.setVisible(false); decompiledTextArea.getCaret().setVisible(true); decLabel.setIcon(null); - directEditing = false; - detailPanel.setVisible(true); + directEditing = false; + detailPanel.setVisible(true); detailPanel.setSize(detailPanel.getHeight(), detWidth); splitPane.setDividerLocation(detsp); } decompiledTextArea.ignoreCarret = directEditing; - + decompiledTextArea.requestFocusInWindow(); } - + @Override public void actionPerformed(ActionEvent e) { switch (e.getActionCommand()) { case ACTION_EDIT_DECOMPILED: File swc = Configuration.getPlayerSWC(); final String adobePage = "http://www.adobe.com/support/flashplayer/downloads.html"; - if(swc == null){ - if(View.showConfirmDialog(this, AppStrings.translate("message.action.playerglobal.needed").replace("%adobehomepage%",adobePage),AppStrings.translate("message.action.playerglobal.title"),JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE)==JOptionPane.OK_OPTION){ - + if (swc == null) { + if (View.showConfirmDialog(this, AppStrings.translate("message.action.playerglobal.needed").replace("%adobehomepage%", adobePage), AppStrings.translate("message.action.playerglobal.title"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE) == JOptionPane.OK_OPTION) { + java.awt.Desktop desktop = null; if (java.awt.Desktop.isDesktopSupported()) { desktop = java.awt.Desktop.getDesktop(); @@ -648,18 +646,18 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se desktop = null; } } - + int ret = 0; - do{ - ret = View.showConfirmDialog(this, AppStrings.translate("message.action.playerglobal.place").replace("%libpath%", Configuration.getFlashLibPath().getAbsolutePath()),AppStrings.translate("message.action.playerglobal.title"),JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE); + do { + ret = View.showConfirmDialog(this, AppStrings.translate("message.action.playerglobal.place").replace("%libpath%", Configuration.getFlashLibPath().getAbsolutePath()), AppStrings.translate("message.action.playerglobal.title"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE); swc = Configuration.getPlayerSWC(); - }while(ret == JOptionPane.OK_OPTION && swc == null); + } while (ret == JOptionPane.OK_OPTION && swc == null); } } - if(swc!=null){ - if(View.showConfirmDialog(null, AppStrings.translate("message.confirm.experimental.function"), AppStrings.translate("message.warning"), JOptionPane.OK_CANCEL_OPTION,JOptionPane.WARNING_MESSAGE,Configuration.warningExperimentalAS3Edit,JOptionPane.OK_OPTION)==JOptionPane.OK_OPTION){ + if (swc != null) { + if (View.showConfirmDialog(null, AppStrings.translate("message.confirm.experimental.function"), AppStrings.translate("message.warning"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, Configuration.warningExperimentalAS3Edit, JOptionPane.OK_OPTION) == JOptionPane.OK_OPTION) { setDecompiledEditMode(true); - } + } } break; case ACTION_CANCEL_DECOMPILED: @@ -667,11 +665,12 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se break; case ACTION_SAVE_DECOMPILED: ScriptPack pack = decompiledTextArea.getScriptLeaf(); - String scriptName = pack.getPathScriptName()+".as"; + String scriptName = pack.getPathScriptName() + ".as"; int oldIndex = pack.scriptIndex; int newIndex = abc.script_info.size(); String documentClass = ""; - loopt:for (Tag t : swf.tags) { + loopt: + for (Tag t : swf.tags) { if (t instanceof SymbolClassTag) { SymbolClassTag sc = (SymbolClassTag) t; for (int i = 0; i < sc.tags.length; i++) { @@ -683,29 +682,29 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se } } boolean isDocumentClass = documentClass.equals(pack.getPath().toString()); - - try { - ActionScriptParser.compile(decompiledTextArea.getText(), abc,isDocumentClass, scriptName); + + try { + ActionScriptParser.compile(decompiledTextArea.getText(), abc, isDocumentClass, scriptName); //Move newly added script to its position abc.script_info.set(oldIndex, abc.script_info.get(newIndex)); abc.script_info.remove(newIndex); - ((Tag)abc.parentTag).setModified(true); + ((Tag) abc.parentTag).setModified(true); lastDecompiled = decompiledTextArea.getText(); decompiledTextArea.setClassIndex(-1); View.showMessageDialog(this, AppStrings.translate("message.action.saved")); setDecompiledEditMode(false); - reload(); + reload(); } catch (ParseException ex) { //ex.printStackTrace(); View.showMessageDialog(this, AppStrings.translate("error.action.save").replace("%error%", ex.text).replace("%line%", "" + ex.line), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE); - decompiledTextArea.gotoLine((int)ex.line); + decompiledTextArea.gotoLine((int) ex.line); } catch (CompilationException ex) { //ex.printStackTrace(); View.showMessageDialog(this, AppStrings.translate("error.action.save").replace("%error%", ex.text).replace("%line%", "" + ex.line), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE); - decompiledTextArea.gotoLine((int)ex.line); - } catch (IOException|InterruptedException ex) { + decompiledTextArea.gotoLine((int) ex.line); + } catch (IOException | InterruptedException ex) { //ignore - } + } break; case ACTION_ADD_TRAIT: int class_index = decompiledTextArea.getClassIndex(); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java index fe4367a1f..2f9774bd3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java @@ -739,11 +739,11 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene } catch (IOException ex) { } catch (ParseException ex) { View.showMessageDialog(this, AppStrings.translate("error.action.save").replace("%error%", ex.text).replace("%line%", "" + ex.line), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE); - editor.gotoLine((int)ex.line); + editor.gotoLine((int) ex.line); } break; case ACTION_EDIT_DECOMPILED: - if(View.showConfirmDialog(null, AppStrings.translate("message.confirm.experimental.function"), AppStrings.translate("message.warning"), JOptionPane.OK_CANCEL_OPTION,JOptionPane.WARNING_MESSAGE,Configuration.warningExperimentalAS12Edit,JOptionPane.OK_OPTION)==JOptionPane.OK_OPTION){ + if (View.showConfirmDialog(null, AppStrings.translate("message.confirm.experimental.function"), AppStrings.translate("message.warning"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, Configuration.warningExperimentalAS12Edit, JOptionPane.OK_OPTION) == JOptionPane.OK_OPTION) { setDecompiledEditMode(true); } break; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java index 08b65cdb2..7a0d6ba2f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java @@ -35,7 +35,9 @@ import java.awt.Graphics; import java.awt.Panel; import java.awt.event.ComponentEvent; import java.awt.event.ComponentListener; +import java.io.Closeable; import java.io.File; +import java.io.IOException; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; @@ -45,7 +47,7 @@ import java.util.concurrent.TimeoutException; * * @author JPEXS */ -public class FlashPlayerPanel extends Panel implements MediaDisplay { +public class FlashPlayerPanel extends Panel implements Closeable, MediaDisplay { private boolean executed = false; private String flash; @@ -293,21 +295,11 @@ public class FlashPlayerPanel extends Panel implements MediaDisplay { } @Override - protected void finalize() throws Throwable { - super.finalize(); + public void close() throws IOException { Kernel32.INSTANCE.CloseHandle(pipe); Kernel32.INSTANCE.TerminateProcess(process, 0); } - public static void unload() { - /*if (Platform.isWindows()) { - for (int i = 0; i < processes.size(); i++) { - Kernel32.INSTANCE.CloseHandle(pipes.get(i)); - Kernel32.INSTANCE.TerminateProcess(processes.get(i), 0); - } - }*/ - } - @Override public void paint(Graphics g) { if (flash != null) { diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java index fa99fbea8..f9f851f14 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java @@ -101,8 +101,8 @@ public class DefineText2Tag extends TextTag { } if (rec.styleFlagsHasXOffset || rec.styleFlagsHasYOffset) { /*if (!ret.isEmpty()) { - ret += "\r\n"; - }*/ + ret += "\r\n"; + }*/ } ret += rec.getText(fnt); } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java index ee421c8f0..ca2d96eed 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java @@ -102,8 +102,8 @@ public class DefineTextTag extends TextTag { } if (rec.styleFlagsHasXOffset || rec.styleFlagsHasYOffset) { /*if (!ret.isEmpty()) { - ret += "\r\n"; - }*/ + ret += "\r\n"; + }*/ } ret += rec.getText(fnt); } diff --git a/trunk/test/com/jpexs/decompiler/flash/ActionScript2ParserTest.java b/trunk/test/com/jpexs/decompiler/flash/ActionScript2ParserTest.java index 2392d58bc..5694e2ef7 100644 --- a/trunk/test/com/jpexs/decompiler/flash/ActionScript2ParserTest.java +++ b/trunk/test/com/jpexs/decompiler/flash/ActionScript2ParserTest.java @@ -49,52 +49,52 @@ public class ActionScript2ParserTest extends ActionStript2TestBase { fail("Unable to parse: " + script); } } - + @Test private void testAS2Parse1() { parseAS2( - "var x = true;\n" + - "while(x) { }"); + "var x = true;\n" + + "while(x) { }"); } @Test private void testAS2Parse2() { parseAS2( - "function test(a, b, c)\n" + - "{\n" + - " return a != 0?b * 2:c;\n" + - "}"); + "function test(a, b, c)\n" + + "{\n" + + " return a != 0?b * 2:c;\n" + + "}"); } @Test private void testAS2Parse3() { parseAS2( - "for(;i < 10;i++) { }"); + "for(;i < 10;i++) { }"); } @Test private void testAS2Parse4() { parseAS2( - "class cl1\n" + - "{\n" + - " function stop()\n" + - " {\n" + - " }\n" + - "}"); + "class cl1\n" + + "{\n" + + " function stop()\n" + + " {\n" + + " }\n" + + "}"); } @Test private void testAS2Parse5() { parseAS2( - "if(!test.T1)\n" + - "{\n" + - " test.T1 = function()\n" + - " {\n" + - " super();\n" + - " }.Initialize = function(obj)\n" + - " {\n" + - " var x = 1;\n" + - " };\n" + - "}"); + "if(!test.T1)\n" + + "{\n" + + " test.T1 = function()\n" + + " {\n" + + " super();\n" + + " }.Initialize = function(obj)\n" + + " {\n" + + " var x = 1;\n" + + " };\n" + + "}"); } } diff --git a/trunk/test/com/jpexs/decompiler/flash/RecompileTest.java b/trunk/test/com/jpexs/decompiler/flash/RecompileTest.java index a6608edc1..dc5271a13 100644 --- a/trunk/test/com/jpexs/decompiler/flash/RecompileTest.java +++ b/trunk/test/com/jpexs/decompiler/flash/RecompileTest.java @@ -120,7 +120,7 @@ public class RecompileTest { } } } - + private void testAS2DirectEditingOne(String filename) { try { SWF swf = new SWF(new BufferedInputStream(new FileInputStream(TESTDATADIR + File.separator + filename)), false); diff --git a/trunk/test/com/jpexs/decompiler/flash/generators/AS3Generator.java b/trunk/test/com/jpexs/decompiler/flash/generators/AS3Generator.java index f42b063b1..1c3423682 100644 --- a/trunk/test/com/jpexs/decompiler/flash/generators/AS3Generator.java +++ b/trunk/test/com/jpexs/decompiler/flash/generators/AS3Generator.java @@ -67,7 +67,7 @@ public class AS3Generator { s.append("\", "); HilightedTextWriter src = new HilightedTextWriter(new CodeFormatting(), false); MethodBody b = abc.findBody(((TraitMethodGetterSetter) t).method_info); - b.convert("", ScriptExportMode.AS, false, -1/*FIX?*/, classId, abc, null, abc.constants, abc.method_info, new Stack(), false, new NulWriter(), new ArrayList(), abc.instance_info.get(classId).instance_traits, true); + b.convert("", ScriptExportMode.AS, false, -1/*FIX?*/, classId, abc, null, abc.constants, abc.method_info, new Stack(), false, new NulWriter(), new ArrayList(), abc.instance_info.get(classId).instance_traits, true); b.toString("", ScriptExportMode.AS, false, -1/*FIX?*/, classId, abc, null, abc.constants, abc.method_info, new Stack(), false, src, new ArrayList(), abc.instance_info.get(classId).instance_traits); String[] srcs = src.toString().split("[\r\n]+"); for (int i = 0; i < srcs.length; i++) {