mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-28 03:00:59 +00:00
Fixed: AS1/2 - Push action hilighting, GetProperty, Call action hilighting
This commit is contained in:
@@ -4266,8 +4266,8 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
pu.replacement = new ArrayList<>();
|
||||
pu.replacement.addAll(pu.values);
|
||||
}
|
||||
if (pu.replacement.get(it.getKey().pos) instanceof ConstantIndex) {
|
||||
ConstantIndex ci = (ConstantIndex) pu.replacement.get(it.getKey().pos);
|
||||
if (pu.replacement.get(it.getKey().getPos()) instanceof ConstantIndex) {
|
||||
ConstantIndex ci = (ConstantIndex) pu.replacement.get(it.getKey().getPos());
|
||||
ConstantPool pool = it.getValue();
|
||||
if (pool == null) {
|
||||
continue;
|
||||
@@ -4286,7 +4286,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
pu.replacement.set(it.getKey().pos, changed);
|
||||
pu.replacement.set(it.getKey().getPos(), changed);
|
||||
}
|
||||
ret++;
|
||||
}
|
||||
|
||||
@@ -96,7 +96,10 @@ public abstract class ActionItem extends GraphTargetItem implements Serializable
|
||||
protected GraphTextWriter stripQuotes(GraphTargetItem target, LocalData localData, GraphTextWriter writer) throws InterruptedException {
|
||||
if (target instanceof DirectValueActionItem) {
|
||||
if (((DirectValueActionItem) target).value instanceof String) {
|
||||
return writer.append((String) ((DirectValueActionItem) target).value);
|
||||
DirectValueActionItem dv = (DirectValueActionItem) target;
|
||||
|
||||
//dv.toStringNoQuotes(writer, localData);
|
||||
return writer.append((String) dv.value);
|
||||
}
|
||||
}
|
||||
if (target == null) {
|
||||
|
||||
@@ -50,7 +50,7 @@ public class CallActionItem extends ActionItem {
|
||||
writer.append("call");
|
||||
writer.spaceBeforeCallParenthesis(1);
|
||||
writer.append("(");
|
||||
value.appendTo(writer, localData);
|
||||
value.toString(writer, localData);
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
|
||||
+1
-10
@@ -61,10 +61,6 @@ public class DirectValueActionItem extends ActionItem implements SimpleValue {
|
||||
*/
|
||||
public GraphTargetItem computedRegValue;
|
||||
|
||||
/**
|
||||
* Position.
|
||||
*/
|
||||
public final int pos;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -91,11 +87,6 @@ public class DirectValueActionItem extends ActionItem implements SimpleValue {
|
||||
this.pos = instructionPos;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPos() {
|
||||
return pos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVariableComputed() {
|
||||
return (computedRegValue != null);
|
||||
@@ -224,7 +215,7 @@ public class DirectValueActionItem extends ActionItem implements SimpleValue {
|
||||
HighlightData srcData = getSrcData();
|
||||
srcData.localName = ((RegisterNumber) value).translate();
|
||||
srcData.regIndex = ((RegisterNumber) value).number;
|
||||
|
||||
|
||||
return writer.appendWithData(IdentifiersDeobfuscation.printIdentifier(false, ((RegisterNumber) value).translate()), srcData);
|
||||
}
|
||||
return writer.append(EcmaScript.toString(value));
|
||||
|
||||
+1
-1
@@ -88,7 +88,7 @@ public class GetPropertyActionItem extends ActionItem {
|
||||
writer.append("getProperty");
|
||||
writer.spaceBeforeCallParenthesis(2);
|
||||
writer.append("(");
|
||||
target.appendTo(writer, localData);
|
||||
target.toString(writer, localData);
|
||||
writer.append(", ");
|
||||
writer.append(Action.propertyNames[propertyIndex]);
|
||||
writer.append(")");
|
||||
|
||||
+1
-1
@@ -109,7 +109,7 @@ public class GetVariableActionItem extends ActionItem {
|
||||
HighlightData srcData = getSrcData();
|
||||
srcData.localName = name.toStringNoQuotes(localData);
|
||||
return stripQuotes(name, localData, writer);
|
||||
} else {
|
||||
} else {
|
||||
writer.append("eval(");
|
||||
name.appendTry(writer, localData);
|
||||
return writer.append(")");
|
||||
|
||||
+1
-10
@@ -44,11 +44,6 @@ public class UnresolvedConstantActionItem extends ActionItem implements SimpleVa
|
||||
*/
|
||||
public GraphTargetItem computedRegValue;
|
||||
|
||||
/**
|
||||
* Position
|
||||
*/
|
||||
public final int pos;
|
||||
|
||||
/**
|
||||
* Index
|
||||
*/
|
||||
@@ -76,11 +71,7 @@ public class UnresolvedConstantActionItem extends ActionItem implements SimpleVa
|
||||
this.index = index;
|
||||
this.pos = instructionPos;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPos() {
|
||||
return pos;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isVariableComputed() {
|
||||
|
||||
@@ -417,7 +417,7 @@ public class ActionPush extends Action {
|
||||
if (i > 0) {
|
||||
writer.appendNoHilight(", ");
|
||||
}
|
||||
writer.append(toString(i), getAddress() + i + 1, getFileOffset());
|
||||
writer.append(toString(i), getAddress() + i, getFileOffset());
|
||||
}
|
||||
return writer;
|
||||
}
|
||||
@@ -489,47 +489,51 @@ public class ActionPush extends Action {
|
||||
public void translate(Map<String, Map<String, Trait>> uninitializedClassTraits, SecondPassData secondPassData, boolean insideDoInitAction, GraphSourceItem lineStartAction, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
|
||||
int pos = 0;
|
||||
for (Object o : values) {
|
||||
GraphTargetItem toPush = null;
|
||||
if (o instanceof ConstantIndex) {
|
||||
if ((constantPool == null) || (((ConstantIndex) o).index >= constantPool.size())) {
|
||||
stack.push(new UnresolvedConstantActionItem(((ConstantIndex) o).index));
|
||||
continue;
|
||||
toPush = new UnresolvedConstantActionItem(((ConstantIndex) o).index);
|
||||
} else {
|
||||
o = constantPool.get(((ConstantIndex) o).index);
|
||||
}
|
||||
}
|
||||
if (o instanceof Boolean) {
|
||||
Boolean b = (Boolean) o;
|
||||
if (b) {
|
||||
stack.push(new TrueItem(this, lineStartAction));
|
||||
} else {
|
||||
stack.push(new FalseItem(this, lineStartAction));
|
||||
}
|
||||
} else {
|
||||
DirectValueActionItem dvt = new DirectValueActionItem(this, lineStartAction, pos, o, constantPool);
|
||||
|
||||
if (o instanceof RegisterNumber) { //TemporaryRegister
|
||||
dvt.computedRegValue = variables.get("__register" + ((RegisterNumber) o).number);
|
||||
if (regNames.containsKey(((RegisterNumber) o).number)) {
|
||||
((RegisterNumber) o).name = regNames.get(((RegisterNumber) o).number);
|
||||
if (toPush == null) {
|
||||
if (o instanceof Boolean) {
|
||||
Boolean b = (Boolean) o;
|
||||
if (b) {
|
||||
toPush = new TrueItem(this, lineStartAction);
|
||||
} else {
|
||||
toPush = new FalseItem(this, lineStartAction);
|
||||
}
|
||||
}
|
||||
if (dvt.computedRegValue instanceof TemporaryRegister) {
|
||||
((TemporaryRegister) dvt.computedRegValue).used = true;
|
||||
for (int i = 0; i < output.size(); i++) {
|
||||
if (output.get(i) instanceof TemporaryRegisterMark) {
|
||||
TemporaryRegisterMark trm = (TemporaryRegisterMark) output.get(i);
|
||||
if (trm.tempReg == dvt.computedRegValue) {
|
||||
output.remove(i);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
DirectValueActionItem dvt = new DirectValueActionItem(this, lineStartAction, pos, o, constantPool);
|
||||
|
||||
if (o instanceof RegisterNumber) { //TemporaryRegister
|
||||
dvt.computedRegValue = variables.get("__register" + ((RegisterNumber) o).number);
|
||||
if (regNames.containsKey(((RegisterNumber) o).number)) {
|
||||
((RegisterNumber) o).name = regNames.get(((RegisterNumber) o).number);
|
||||
}
|
||||
}
|
||||
stack.push(new TemporaryRegister(((RegisterNumber) o).number, ((TemporaryRegister) dvt.computedRegValue).value));
|
||||
} else {
|
||||
stack.push(dvt);
|
||||
if (dvt.computedRegValue instanceof TemporaryRegister) {
|
||||
((TemporaryRegister) dvt.computedRegValue).used = true;
|
||||
for (int i = 0; i < output.size(); i++) {
|
||||
if (output.get(i) instanceof TemporaryRegisterMark) {
|
||||
TemporaryRegisterMark trm = (TemporaryRegisterMark) output.get(i);
|
||||
if (trm.tempReg == dvt.computedRegValue) {
|
||||
output.remove(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
toPush = new TemporaryRegister(((RegisterNumber) o).number, ((TemporaryRegister) dvt.computedRegValue).value);
|
||||
} else {
|
||||
toPush = dvt;
|
||||
}
|
||||
}
|
||||
}
|
||||
pos++;
|
||||
toPush.setPos(pos);
|
||||
stack.push(toPush);
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -131,6 +131,11 @@ public abstract class GraphTargetItem implements Serializable, Cloneable {
|
||||
* Line start item
|
||||
*/
|
||||
public GraphSourceItem lineStartItem;
|
||||
|
||||
/**
|
||||
* ASM Position
|
||||
*/
|
||||
protected int pos = 0;
|
||||
|
||||
/**
|
||||
* Gets the line start item
|
||||
@@ -362,8 +367,16 @@ public abstract class GraphTargetItem implements Serializable, Cloneable {
|
||||
*
|
||||
* @return Position
|
||||
*/
|
||||
protected int getPos() {
|
||||
return 0;
|
||||
public int getPos() {
|
||||
return pos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets position
|
||||
* @param pos Position
|
||||
*/
|
||||
public void setPos(int pos) {
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user