ecmascript and push byte fix

This commit is contained in:
honfika@gmail.com
2015-11-16 11:09:49 +01:00
parent 07729800c9
commit 722c4fae24
4 changed files with 47 additions and 3 deletions

View File

@@ -122,6 +122,7 @@ public class AVM2ConstantPool implements Cloneable {
public synchronized int addInt(long value) {
ensureDefault(constant_int);
value = (int) value;
constant_int.add(value);
return constant_int.size() - 1;
}
@@ -150,6 +151,7 @@ public class AVM2ConstantPool implements Cloneable {
public synchronized int addUInt(long value) {
ensureDefault(constant_uint);
value &= 0xffffffffl;
constant_uint.add(value);
return constant_uint.size() - 1;
}

View File

@@ -36,13 +36,13 @@ public class PushByteIns extends InstructionDefinition implements PushIntegerTyp
@Override
public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
lda.operandStack.push(ins.getParam(constants, 0));
lda.operandStack.push((long) (byte) ins.operands[0]);
return true;
}
@Override
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
stack.push(new IntegerValueAVM2Item(ins, (long) ins.operands[0]));
stack.push(new IntegerValueAVM2Item(ins, (long) (byte) ins.operands[0]));
}
@Override

View File

@@ -48,8 +48,13 @@ public class EcmaScript {
return (double) (int) (Integer) o;
}
if (o instanceof String) {
String str = (String) o;
if (str.isEmpty()) {
return 0.0;
}
try {
return Double.parseDouble((String) o);
return Double.parseDouble(str);
} catch (NumberFormatException nfe) {
return Double.NaN;
}