mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-27 14:20:43 +00:00
Fixed AS1/2 - get/set top level properties
Fixed AS1/2 - properties postincrement
This commit is contained in:
@@ -158,6 +158,14 @@ public abstract class Action implements GraphSourceItem {
|
||||
|
||||
public static final List<String> propertyNamesList = Arrays.asList(propertyNames);
|
||||
|
||||
public static final List<String> propertyNamesListLowerCase = new ArrayList<>();
|
||||
|
||||
{
|
||||
for (String s : propertyNamesList) {
|
||||
propertyNamesListLowerCase.add(s.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
private static final Logger logger = Logger.getLogger(Action.class.getName());
|
||||
|
||||
/**
|
||||
|
||||
+4
-4
@@ -56,16 +56,16 @@ public class GetPropertyActionItem extends ActionItem {
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
/*if (isEmptyString(target)) {
|
||||
if (isEmptyString(target)) {
|
||||
return writer.append(Action.propertyNames[propertyIndex]);
|
||||
}*/
|
||||
}
|
||||
|
||||
if (!useGetPropertyFunction && !isEmptyString(target)) {
|
||||
/*if (!useGetPropertyFunction) {
|
||||
target.appendToNoQuotes(writer, localData);
|
||||
writer.append(":");
|
||||
writer.append(Action.propertyNames[propertyIndex]);
|
||||
return writer;
|
||||
}
|
||||
}*/
|
||||
|
||||
writer.append("getProperty");
|
||||
writer.spaceBeforeCallParenthesies(2);
|
||||
|
||||
+2
-2
@@ -79,10 +79,10 @@ public class SetPropertyActionItem extends ActionItem implements SetTypeActionIt
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
/*if (isEmptyString(target)) {
|
||||
if (isEmptyString(target)) {
|
||||
writer.append(Action.propertyNames[propertyIndex]).append(" = ");
|
||||
return value.toString(writer, localData);
|
||||
}*/
|
||||
}
|
||||
|
||||
writer.append("setProperty");
|
||||
writer.spaceBeforeCallParenthesies(3);
|
||||
|
||||
+7
-18
@@ -2034,13 +2034,13 @@ public class ActionScript2Parser {
|
||||
if (var.getVariableName().equals("getProperty")
|
||||
&& args.size() == 2
|
||||
&& (args.get(1) instanceof VariableActionItem)
|
||||
&& (Action.propertyNamesList.contains(((VariableActionItem) args.get(1)).getVariableName()))) {
|
||||
ret = new GetPropertyActionItem(null, null, args.get(0), Action.propertyNamesList.indexOf(((VariableActionItem) args.get(1)).getVariableName()));
|
||||
&& (Action.propertyNamesListLowerCase.contains(((VariableActionItem) args.get(1)).getVariableName().toLowerCase()))) {
|
||||
ret = new GetPropertyActionItem(null, null, args.get(0), Action.propertyNamesListLowerCase.indexOf(((VariableActionItem) args.get(1)).getVariableName().toLowerCase()));
|
||||
} else if (var.getVariableName().equals("setProperty")
|
||||
&& args.size() == 3
|
||||
&& (args.get(1) instanceof VariableActionItem)
|
||||
&& (Action.propertyNamesList.contains(((VariableActionItem) args.get(1)).getVariableName()))) {
|
||||
ret = new SetPropertyActionItem(null, null, args.get(0), Action.propertyNamesList.indexOf(((VariableActionItem) args.get(1)).getVariableName()), args.get(2));
|
||||
&& (Action.propertyNamesListLowerCase.contains(((VariableActionItem) args.get(1)).getVariableName().toLowerCase()))) {
|
||||
ret = new SetPropertyActionItem(null, null, args.get(0), Action.propertyNamesListLowerCase.indexOf(((VariableActionItem) args.get(1)).getVariableName().toLowerCase()), args.get(2));
|
||||
} else {
|
||||
ret = new CallFunctionActionItem(null, null, var, args);
|
||||
}
|
||||
@@ -2287,18 +2287,7 @@ public class ActionScript2Parser {
|
||||
GraphTargetItem stored = v.getStoreValue();
|
||||
int propIndex = -1;
|
||||
boolean hasSubVars = false;
|
||||
if (varName.contains(":")) {
|
||||
hasSubVars = true;
|
||||
String lowerNameStr = varName.toLowerCase();
|
||||
for (int p = 0; p < Action.propertyNames.length; p++) {
|
||||
String prop = Action.propertyNames[p];
|
||||
if (lowerNameStr.endsWith(":" + prop.toLowerCase())) {
|
||||
propIndex = p;
|
||||
varName = varName.substring(0, varName.lastIndexOf(":"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
propIndex = Action.propertyNamesListLowerCase.indexOf(varName.toLowerCase());
|
||||
if (v.isDefinition()) {
|
||||
if (hasSubVars) {
|
||||
throw new ActionParseException("Invalid : character in variable definition", lexer.yyline());
|
||||
@@ -2306,13 +2295,13 @@ public class ActionScript2Parser {
|
||||
v.setBoxedValue(new DefineLocalActionItem(null, null, pushConst(varName), stored));
|
||||
} else if (stored != null) {
|
||||
if (propIndex > -1) {
|
||||
v.setBoxedValue(new SetPropertyActionItem(null, null, pushConst(varName), propIndex, stored));
|
||||
v.setBoxedValue(new SetPropertyActionItem(null, null, pushConst(""), propIndex, stored));
|
||||
} else {
|
||||
v.setBoxedValue(new SetVariableActionItem(null, null, pushConst(varName), stored));
|
||||
}
|
||||
|
||||
} else if (propIndex > -1) {
|
||||
v.setBoxedValue(new GetPropertyActionItem(null, null, pushConst(varName), propIndex));
|
||||
v.setBoxedValue(new GetPropertyActionItem(null, null, pushConst(""), propIndex));
|
||||
} else {
|
||||
v.setBoxedValue(new GetVariableActionItem(null, null, pushConst(varName)));
|
||||
}
|
||||
|
||||
@@ -106,6 +106,15 @@ public class ActionSetProperty extends Action {
|
||||
}
|
||||
stack.push(new PostIncrementActionItem(this, lineStartAction, obj));
|
||||
return;
|
||||
} else {
|
||||
IncrementActionItem dec = (IncrementActionItem) value.getThroughDuplicate();
|
||||
if (dec.object instanceof GetPropertyActionItem) {
|
||||
GetPropertyActionItem gp = (GetPropertyActionItem) dec.object;
|
||||
if (gp.target.valueEquals(target) && gp.propertyIndex == indexInt) {
|
||||
output.add(new PostIncrementActionItem(this, lineStartAction, gp));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (value.getThroughDuplicate() instanceof DecrementActionItem) {
|
||||
@@ -117,6 +126,15 @@ public class ActionSetProperty extends Action {
|
||||
}
|
||||
stack.push(new PostDecrementActionItem(this, lineStartAction, obj));
|
||||
return;
|
||||
} else {
|
||||
DecrementActionItem dec = (DecrementActionItem) value.getThroughDuplicate();
|
||||
if (dec.object instanceof GetPropertyActionItem) {
|
||||
GetPropertyActionItem gp = (GetPropertyActionItem) dec.object;
|
||||
if (gp.target.valueEquals(target) && gp.propertyIndex == indexInt) {
|
||||
output.add(new PostDecrementActionItem(this, lineStartAction, gp));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user