mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-17 16:58:09 +00:00
further as2/3 execution fixes
This commit is contained in:
@@ -46,7 +46,7 @@ public class MBStringExtractActionItem extends ActionItem {
|
||||
}
|
||||
|
||||
public MBStringExtractActionItem(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem value, GraphTargetItem index, GraphTargetItem count) {
|
||||
super(instruction, lineStartIns, PRECEDENCE_PRIMARY, value);
|
||||
super(instruction, lineStartIns, PRECEDENCE_PRIMARY, value);
|
||||
this.index = index;
|
||||
this.count = count;
|
||||
}
|
||||
@@ -80,10 +80,10 @@ public class MBStringExtractActionItem extends ActionItem {
|
||||
|
||||
public static String getResult(Object count, Object index, Object value) {
|
||||
String str = EcmaScript.toString(value);
|
||||
int idx = (int) (double) EcmaScript.toNumberAs2(index);
|
||||
int idx = EcmaScript.toInt32(index);
|
||||
idx--; // index seems to be 1 based
|
||||
|
||||
int cnt = (int) (double) EcmaScript.toNumberAs2(count);
|
||||
int cnt = EcmaScript.toInt32(count);
|
||||
|
||||
/*if (idx < 0) {
|
||||
idx = str.length() + idx;
|
||||
|
||||
@@ -36,7 +36,7 @@ public class StringExtractActionItem extends ActionItem {
|
||||
public GraphTargetItem count;
|
||||
|
||||
public StringExtractActionItem(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem value, GraphTargetItem index, GraphTargetItem count) {
|
||||
super(instruction, lineStartIns, PRECEDENCE_PRIMARY, value);
|
||||
super(instruction, lineStartIns, PRECEDENCE_PRIMARY, value);
|
||||
this.index = index;
|
||||
this.count = count;
|
||||
}
|
||||
@@ -69,10 +69,10 @@ public class StringExtractActionItem extends ActionItem {
|
||||
|
||||
public static String getResult(Object count, Object index, Object value) {
|
||||
String str = EcmaScript.toString(value);
|
||||
int idx = (int) (double) EcmaScript.toNumberAs2(index);
|
||||
int idx = EcmaScript.toInt32(index);
|
||||
idx--; // index seems to be 1 based
|
||||
|
||||
int cnt = (int) (double) EcmaScript.toNumberAs2(count);
|
||||
int cnt = EcmaScript.toInt32(count);
|
||||
|
||||
/*if (idx < 0) {
|
||||
idx = str.length() + idx;
|
||||
|
||||
@@ -44,13 +44,13 @@ public class GtActionItem extends BinaryOpItem implements LogicalOpItem {
|
||||
}
|
||||
|
||||
public static Object getResult(Object rightResult, Object leftResult) {
|
||||
Object ret = EcmaScript.compare(rightResult, leftResult, true);
|
||||
Object ret = EcmaScript.compare(leftResult, rightResult, true);
|
||||
if (ret == Undefined.INSTANCE) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
int reti = (int) ret;
|
||||
return reti == -1;
|
||||
return reti == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -41,13 +41,13 @@ public class LeActionItem extends BinaryOpItem implements LogicalOpItem, Inverte
|
||||
|
||||
@Override
|
||||
public Object getResult() {
|
||||
Object ret = EcmaScript.compare(rightSide.getResult(), leftSide.getResult(), true);
|
||||
Object ret = EcmaScript.compare(leftSide.getResult(), rightSide.getResult(), true);
|
||||
if (ret == Undefined.INSTANCE) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
int reti = (int) ret;
|
||||
return reti != -1;
|
||||
return reti != 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -38,10 +38,10 @@ public class ModuloActionItem extends BinaryOpItem {
|
||||
}
|
||||
|
||||
public static Number getResult(Double rightResult, Double leftResult) {
|
||||
if (Double.isNaN(rightResult) || Double.compare(rightResult, 0) == 0) {
|
||||
if (Double.isNaN(leftResult) || Double.isNaN(rightResult) || Double.compare(rightResult, 0) == 0) {
|
||||
return Double.NaN;
|
||||
}
|
||||
return ((long) (double) leftResult) % ((long) (double) rightResult);
|
||||
return ((double) leftResult) % ((double) rightResult);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -188,6 +188,15 @@ public class EcmaScript {
|
||||
if (sx.equals(sy)) {
|
||||
return 0;
|
||||
}
|
||||
if (as2) {
|
||||
// in AS2 an empty string is greater than a non-empty string...
|
||||
if (sx.isEmpty()) {
|
||||
return 1;
|
||||
}
|
||||
if (sy.isEmpty()) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (sx.startsWith(sy)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user