mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-27 19:40:43 +00:00
java code format
This commit is contained in:
@@ -257,8 +257,8 @@ public class ConstantPool {
|
||||
}
|
||||
}
|
||||
return m;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,11 +44,11 @@ public class PopIns extends InstructionDefinition {
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, Stack<GraphTargetItem> stack, 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();
|
||||
//Note: Commands like "5;" - numbers are unsupported as it collide with try..finally block decompilation. TODO: allow this somehow
|
||||
if(!(top instanceof IntegerValueAVM2Item)){
|
||||
if (!(top instanceof IntegerValueAVM2Item)) {
|
||||
output.add(top);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ public class NewFunctionAVM2Item extends AVM2Item {
|
||||
methodInfo.get(methodIndex).getParamStr(writer, constants, body, abc, fullyQualifiedNames);
|
||||
writer.appendNoHilight("):");
|
||||
methodInfo.get(methodIndex).getReturnTypeStr(writer, constants, fullyQualifiedNames);
|
||||
writer.endMethod();
|
||||
writer.endMethod();
|
||||
writer.startBlock();
|
||||
if (body != null) {
|
||||
if (writer instanceof NulWriter) {
|
||||
|
||||
@@ -1,86 +1,86 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.avm2.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.NewObjectIns;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.TypeItem;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class NewObjectAVM2Item extends AVM2Item {
|
||||
|
||||
public List<NameValuePair> pairs;
|
||||
|
||||
public NewObjectAVM2Item(AVM2Instruction instruction, List<NameValuePair> pairs) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.pairs = pairs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
boolean singleLine = pairs.size() < 2;
|
||||
//no new line before as it may break return clause (#593)
|
||||
writer.append("{");
|
||||
if (!singleLine) {
|
||||
writer.newLine();
|
||||
writer.indent();
|
||||
}
|
||||
for (int n = 0; n < pairs.size(); n++) {
|
||||
if (n > 0) {
|
||||
writer.append(",").newLine();
|
||||
}
|
||||
pairs.get(n).toString(writer, localData);
|
||||
}
|
||||
if (!singleLine) {
|
||||
writer.newLine();
|
||||
writer.unindent();
|
||||
}
|
||||
writer.append("}");
|
||||
return writer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem returnType() {
|
||||
return new TypeItem("Object");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
List<GraphTargetItem> args = new ArrayList<>();
|
||||
for (NameValuePair p : pairs) {
|
||||
args.add(p.name);
|
||||
args.add(p.value);
|
||||
}
|
||||
return toSourceMerge(localData, generator, args,
|
||||
new AVM2Instruction(0, new NewObjectIns(), new int[]{pairs.size()}, new byte[0])
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.avm2.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.NewObjectIns;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.TypeItem;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class NewObjectAVM2Item extends AVM2Item {
|
||||
|
||||
public List<NameValuePair> pairs;
|
||||
|
||||
public NewObjectAVM2Item(AVM2Instruction instruction, List<NameValuePair> pairs) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.pairs = pairs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
boolean singleLine = pairs.size() < 2;
|
||||
//no new line before as it may break return clause (#593)
|
||||
writer.append("{");
|
||||
if (!singleLine) {
|
||||
writer.newLine();
|
||||
writer.indent();
|
||||
}
|
||||
for (int n = 0; n < pairs.size(); n++) {
|
||||
if (n > 0) {
|
||||
writer.append(",").newLine();
|
||||
}
|
||||
pairs.get(n).toString(writer, localData);
|
||||
}
|
||||
if (!singleLine) {
|
||||
writer.newLine();
|
||||
writer.unindent();
|
||||
}
|
||||
writer.append("}");
|
||||
return writer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem returnType() {
|
||||
return new TypeItem("Object");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
List<GraphTargetItem> args = new ArrayList<>();
|
||||
for (NameValuePair p : pairs) {
|
||||
args.add(p.name);
|
||||
args.add(p.value);
|
||||
}
|
||||
return toSourceMerge(localData, generator, args,
|
||||
new AVM2Instruction(0, new NewObjectIns(), new int[]{pairs.size()}, new byte[0])
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public class WithAVM2Item extends AVM2Item {
|
||||
scope.toString(writer, localData);
|
||||
writer.append(")").startBlock();
|
||||
//NOTE: endBlock is added with WithEndAVM2Item
|
||||
return writer;
|
||||
return writer;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -66,12 +66,12 @@ public class TryAVM2Item extends AVM2Item implements Block {
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("try").startBlock();
|
||||
writer.append("try").startBlock();
|
||||
for (GraphTargetItem ti : tryCommands) {
|
||||
if (!ti.isEmpty()) {
|
||||
ti.toStringSemicoloned(writer, localData).newLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
writer.endBlock();
|
||||
for (int e = 0; e < catchExceptions.size(); e++) {
|
||||
writer.newLine();
|
||||
|
||||
@@ -2032,7 +2032,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
continue;
|
||||
}
|
||||
TraitMethodGetterSetter tmgs = new TraitMethodGetterSetter();
|
||||
tmgs.kindType = (item instanceof GetterAVM2Item)?Trait.TRAIT_GETTER:((item instanceof SetterAVM2Item) ? Trait.TRAIT_SETTER : Trait.TRAIT_METHOD);
|
||||
tmgs.kindType = (item instanceof GetterAVM2Item) ? Trait.TRAIT_GETTER : ((item instanceof SetterAVM2Item) ? Trait.TRAIT_SETTER : Trait.TRAIT_METHOD);
|
||||
//tmgs.name_index = traitName(((MethodAVM2Item) item).namespace, ((MethodAVM2Item) item).functionName);
|
||||
tmgs.disp_id = mai.isStatic() ? disp_id++ : 0; //For a reason, there is disp_id only for static methods (or not?)
|
||||
if (mai.isFinal() || mai.isStatic()) {
|
||||
|
||||
@@ -99,7 +99,7 @@ public class TraitMethodGetterSetter extends Trait {
|
||||
writer.startBlock();
|
||||
if (bodyIndex != -1) {
|
||||
abc.bodies.get(bodyIndex).toString(path, exportMode, isStatic, scriptIndex, classIndex, abc, this, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), false, writer, fullyQualifiedNames, null);
|
||||
}
|
||||
}
|
||||
writer.endBlock();
|
||||
}
|
||||
writer.newLine();
|
||||
|
||||
Reference in New Issue
Block a user