Better decimal support (For ABCs with minor version 17)

This commit is contained in:
Jindra Petřík
2024-08-10 07:48:12 +02:00
parent 9ee2549e60
commit 534ac03314
53 changed files with 4443 additions and 91 deletions

View File

@@ -18,7 +18,6 @@ package com.jpexs.decompiler.flash.abc;
import com.jpexs.decompiler.flash.EndOfStreamException;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.abc.types.Decimal;
import com.jpexs.decompiler.flash.abc.types.Float4;
import com.jpexs.decompiler.flash.abc.types.InstanceInfo;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
@@ -38,6 +37,7 @@ import com.jpexs.helpers.MemoryInputStream;
import com.jpexs.helpers.utf8.Utf8Helper;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import macromedia.asc.util.Decimal128;
/**
* ABC input stream.
@@ -684,11 +684,11 @@ public class ABCInputStream implements AutoCloseable {
* @return Decimal
* @throws IOException On I/O error
*/
public Decimal readDecimal(String name) throws IOException {
public Decimal128 readDecimal(String name) throws IOException {
newDumpLevel(name, "Decimal");
byte[] data = readBytesInternal(16);
endDumpLevel();
return new Decimal(data);
return new Decimal128(data);
}
/**

View File

@@ -16,7 +16,6 @@
*/
package com.jpexs.decompiler.flash.abc;
import com.jpexs.decompiler.flash.abc.types.Decimal;
import com.jpexs.decompiler.flash.abc.types.Float4;
import com.jpexs.decompiler.flash.abc.types.InstanceInfo;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
@@ -31,6 +30,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.helpers.utf8.Utf8Helper;
import java.io.IOException;
import java.io.OutputStream;
import macromedia.asc.util.Decimal128;
/**
* ABC output stream.
@@ -456,8 +456,8 @@ public class ABCOutputStream extends OutputStream {
* @param value Decimal to write
* @throws IOException On I/O error
*/
public void writeDecimal(Decimal value) throws IOException {
write(value.data);
public void writeDecimal(Decimal128 value) throws IOException {
write(value.toIEEE());
}
/**

View File

@@ -19,7 +19,6 @@ package com.jpexs.decompiler.flash.abc.avm2;
import com.jpexs.decompiler.flash.abc.ABCVersionRequirements;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions;
import com.jpexs.decompiler.flash.abc.types.Decimal;
import com.jpexs.decompiler.flash.abc.types.Float4;
import com.jpexs.decompiler.flash.abc.types.Multiname;
import com.jpexs.decompiler.flash.abc.types.Namespace;
@@ -37,6 +36,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import macromedia.asc.util.Decimal128;
/**
* AVM2 constant pool.
@@ -73,7 +73,7 @@ public class AVM2ConstantPool implements Cloneable {
*/
@SWFField
@ABCVersionRequirements(exactMinor = 17)
private HashArrayList<Decimal> constant_decimal = new HashArrayList<>();
private HashArrayList<Decimal128> constant_decimal = new HashArrayList<>();
/**
* Constant pool of floats
@@ -389,7 +389,7 @@ public class AVM2ConstantPool implements Cloneable {
* @param value Value
* @return Index
*/
public synchronized int addDecimal(Decimal value) {
public synchronized int addDecimal(Decimal128 value) {
ensureDefault(constant_decimal);
constant_decimal.add(value);
return constant_decimal.size() - 1;
@@ -510,7 +510,7 @@ public class AVM2ConstantPool implements Cloneable {
* @param value Value
* @return Value
*/
public Decimal setDecimal(int index, Decimal value) {
public Decimal128 setDecimal(int index, Decimal128 value) {
constant_decimal.set(index, value);
return value;
}
@@ -650,7 +650,7 @@ public class AVM2ConstantPool implements Cloneable {
* @param index Index
* @return Value
*/
public Decimal getDecimal(int index) {
public Decimal128 getDecimal(int index) {
return constant_decimal.get(index);
}
@@ -878,7 +878,7 @@ public class AVM2ConstantPool implements Cloneable {
* @param add Whether to add the decimal if it does not exist
* @return Decimal id
*/
public int getDecimalId(Decimal val, boolean add) {
public int getDecimalId(Decimal128 val, boolean add) {
int id = getDecimalId(val);
if (add && id == -1) {
id = addDecimal(val);
@@ -892,7 +892,7 @@ public class AVM2ConstantPool implements Cloneable {
* @param value Value
* @return Decimal id
*/
private int getDecimalId(Decimal value) {
private int getDecimalId(Decimal128 value) {
return constant_decimal.indexOf(value);
}
@@ -1375,7 +1375,7 @@ public class AVM2ConstantPool implements Cloneable {
}
decimalMap.put(0, 0);
for (int i = 1; i < secondPool.constant_decimal.size(); i++) {
Decimal val = secondPool.constant_decimal.get(i);
Decimal128 val = secondPool.constant_decimal.get(i);
decimalMap.put(i, getDecimalId(val, true));
}
namespaceMap.put(0, 0);

View File

@@ -81,7 +81,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushUndefinedIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.SwapIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceOrConvertTypeIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.types.TypeOfIns;
import com.jpexs.decompiler.flash.abc.avm2.model.FloatValueAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.DoubleValueAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.GetPropertyAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.NewArrayAVM2Item;
@@ -147,8 +147,8 @@ public class AVM2DeobfuscatorSimpleOld extends AVM2DeobfuscatorZeroJumpsNullPush
if (graphTargetItem instanceof IntegerValueAVM2Item) {
IntegerValueAVM2Item iv = (IntegerValueAVM2Item) graphTargetItem;
return cpool.makePush(iv.value);
} else if (graphTargetItem instanceof FloatValueAVM2Item) {
FloatValueAVM2Item fv = (FloatValueAVM2Item) graphTargetItem;
} else if (graphTargetItem instanceof DoubleValueAVM2Item) {
DoubleValueAVM2Item fv = (DoubleValueAVM2Item) graphTargetItem;
return cpool.makePush(fv.value);
} else if (graphTargetItem instanceof StringAVM2Item) {
StringAVM2Item fv = (StringAVM2Item) graphTargetItem;

View File

@@ -292,6 +292,12 @@ public class AVM2Instruction implements Cloneable, GraphSourceItem {
return constants.getUInt(operands[idx]);
case AVM2Code.DAT_DOUBLE_INDEX:
return constants.getDouble(operands[idx]);
case AVM2Code.DAT_DECIMAL_INDEX:
return constants.getDecimal(operands[idx]);
case AVM2Code.DAT_FLOAT_INDEX:
return constants.getFloat(operands[idx]);
case AVM2Code.DAT_FLOAT4_INDEX:
return constants.getFloat4(operands[idx]);
case AVM2Code.DAT_OFFSET:
return address + operands[idx] + getBytesLength();
case AVM2Code.DAT_CASE_BASEOFFSET:
@@ -447,7 +453,7 @@ public class AVM2Instruction implements Cloneable, GraphSourceItem {
} else {
s.append(" ");
try {
s.append(constants.getDecimal(operands[i]));
s.append(constants.getDecimal(operands[i]).toActionScriptString());
} catch (IndexOutOfBoundsException iob) {
s.append("Unknown(").append(operands[i]).append(")");
}

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.instructions.other.decimalsupport;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.AVM2LocalData;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime;
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
@@ -24,6 +25,11 @@ import com.jpexs.decompiler.flash.abc.avm2.exceptions.AVM2VerifyErrorException;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2InstructionFlag;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.DNanAVM2Item;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.List;
import macromedia.asc.util.Decimal128;
/**
* pushdnan instruction - push a decimal NaN.
@@ -38,6 +44,12 @@ public class PushDNanIns extends InstructionDefinition {
public PushDNanIns() {
super(0x34, "pushdnan", new int[]{}, true, AVM2InstructionFlag.NO_FLASH_PLAYER, AVM2InstructionFlag.ES4_NUMERICS_MINOR);
}
@Override
public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
lda.operandStack.push(Decimal128.NaN);
return true;
}
@Override
public void verify(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2VerifyErrorException {
@@ -57,4 +69,9 @@ public class PushDNanIns extends InstructionDefinition {
public int getStackPushCount(AVM2Instruction ins, ABC abc) {
return 1;
}
@Override
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
stack.push(new DNanAVM2Item(ins, localData.lineStartInstruction));
}
}

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.instructions.other.decimalsupport;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.AVM2LocalData;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime;
@@ -25,6 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.exceptions.AVM2VerifyErrorException;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2InstructionFlag;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.DecimalValueAVM2Item;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.List;
/**
* pushdecimal instruction - push a decimal.
@@ -40,6 +45,12 @@ public class PushDecimalIns extends InstructionDefinition {
super(0x33, "pushdecimal", new int[]{AVM2Code.DAT_DECIMAL_INDEX}, true, AVM2InstructionFlag.NO_FLASH_PLAYER, AVM2InstructionFlag.ES4_NUMERICS_MINOR);
}
@Override
public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
lda.operandStack.push(ins.getParam(constants, 0));
return true;
}
@Override
public void verify(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2VerifyErrorException {
if (lda.getRuntime() == AVM2Runtime.ADOBE_FLASH) {
@@ -58,4 +69,9 @@ public class PushDecimalIns extends InstructionDefinition {
public int getStackPushCount(AVM2Instruction ins, ABC abc) {
return 1;
}
@Override
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
stack.push(new DecimalValueAVM2Item(ins, localData.lineStartInstruction, localData.getConstants().getDecimal(ins.operands[0])));
}
}

View File

@@ -23,7 +23,7 @@ import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.FloatValueAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.DoubleValueAVM2Item;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.List;
@@ -50,7 +50,7 @@ public class PushDoubleIns extends InstructionDefinition {
@Override
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
stack.push(new FloatValueAVM2Item(ins, localData.lineStartInstruction, localData.getConstants().getDouble(ins.operands[0])));
stack.push(new DoubleValueAVM2Item(ins, localData.lineStartInstruction, localData.getConstants().getDouble(ins.operands[0])));
}
@Override

View File

@@ -23,7 +23,7 @@ import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.FloatValueAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.DoubleValueAVM2Item;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.List;
@@ -50,7 +50,7 @@ public class PushUIntIns extends InstructionDefinition implements PushIntegerTyp
@Override
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
stack.push(new FloatValueAVM2Item(ins, localData.lineStartInstruction, (double) localData.getConstants().getUInt(ins.operands[0])));
stack.push(new DoubleValueAVM2Item(ins, localData.lineStartInstruction, (double) localData.getConstants().getUInt(ins.operands[0])));
}
@Override

View File

@@ -0,0 +1,96 @@
/*
* Copyright (C) 2010-2024 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
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.AVM2Instructions;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.DottedChain;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SimpleValue;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.LocalData;
import java.util.List;
/**
* Decimal NaN value.
*
* @author JPEXS
*/
public class DNanAVM2Item extends AVM2Item implements SimpleValue {
/**
* Constructor.
* @param instruction Instruction
* @param lineStartIns Line start instruction
*/
public DNanAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns) {
super(instruction, lineStartIns, NOPRECEDENCE);
}
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
return writer.append("NaN"); //How is this distinct from classic NaN? There should be separate constant
}
@Override
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
return toSourceMerge(localData, generator,
new AVM2Instruction(0, AVM2Instructions.PushDNan, null)
);
}
@Override
public GraphTargetItem returnType() {
return new TypeItem(DottedChain.DECIMAL);
}
@Override
public boolean hasReturnValue() {
return true;
}
@Override
public boolean isSimpleValue() {
return true;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 3;
return hash;
}
}

View File

@@ -0,0 +1,117 @@
/*
* Copyright (C) 2010-2024 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
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.AVM2Instructions;
import com.jpexs.decompiler.flash.abc.avm2.parser.script.AVM2SourceGenerator;
import com.jpexs.decompiler.flash.ecma.EcmaScript;
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.List;
import java.util.Objects;
import java.util.Set;
import macromedia.asc.util.Decimal128;
/**
* Decimal value.
*
* @author JPEXS
*/
public class DecimalValueAVM2Item extends NumberValueAVM2Item {
/**
* Value
*/
public Decimal128 value;
/**
* Constructor.
*
* @param instruction Instruction
* @param lineStartIns Line start instruction
* @param value Value
*/
public DecimalValueAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, Decimal128 value) {
super(instruction, lineStartIns);
this.value = value;
}
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
return writer.append(value.toActionScriptString());
}
@Override
public Object getResult() {
return value;
}
@Override
public boolean isCompileTime(Set<GraphTargetItem> dependencies) {
return true;
}
@Override
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
return toSourceMerge(localData, generator,
new AVM2Instruction(0, AVM2Instructions.PushDecimal, new int[]{((AVM2SourceGenerator) generator).abcIndex.getSelectedAbc().constants.getDecimalId(value, true)})
);
}
@Override
public GraphTargetItem returnType() {
return TypeItem.NUMBER;
}
@Override
public boolean hasReturnValue() {
return true;
}
@Override
public int hashCode() {
int hash = 7;
hash = 53 * hash + Objects.hashCode(this.value);
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final DecimalValueAVM2Item other = (DecimalValueAVM2Item) obj;
if (!Objects.equals(this.value, other.value)) {
return false;
}
return true;
}
}

View File

@@ -37,7 +37,7 @@ import java.util.Set;
*
* @author JPEXS
*/
public class FloatValueAVM2Item extends NumberValueAVM2Item {
public class DoubleValueAVM2Item extends NumberValueAVM2Item {
/**
* Value
@@ -51,7 +51,7 @@ public class FloatValueAVM2Item extends NumberValueAVM2Item {
* @param lineStartIns Line start instruction
* @param value Value
*/
public FloatValueAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, Double value) {
public DoubleValueAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, Double value) {
super(instruction, lineStartIns);
this.value = value;
}
@@ -106,7 +106,7 @@ public class FloatValueAVM2Item extends NumberValueAVM2Item {
if (getClass() != obj.getClass()) {
return false;
}
final FloatValueAVM2Item other = (FloatValueAVM2Item) obj;
final DoubleValueAVM2Item other = (DoubleValueAVM2Item) obj;
if (!Objects.equals(this.value, other.value)) {
return false;
}

View File

@@ -53,6 +53,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Stack;
import macromedia.asc.util.Decimal128;
/**
* Parses AVM2 P-code.
@@ -1093,6 +1094,7 @@ public class ASM3Parser {
case AVM2Code.DAT_INT_INDEX:
case AVM2Code.DAT_UINT_INDEX:
case AVM2Code.DAT_DOUBLE_INDEX:
case AVM2Code.DAT_DECIMAL_INDEX:
case AVM2Code.DAT_FLOAT_INDEX:
case AVM2Code.DAT_FLOAT4_INDEX:
if (parsedOperand.type == ParsedSymbol.TYPE_KEYWORD_UNKNOWN) {
@@ -1193,6 +1195,31 @@ public class ASM3Parser {
throw new AVM2ParseException("Double or null expected", lexer.yyline());
}
break;
case AVM2Code.DAT_DECIMAL_INDEX:
if (parsedOperand.type == ParsedSymbol.TYPE_KEYWORD_NULL) {
operandsList.add(0);
} else if ((parsedOperand.type == ParsedSymbol.TYPE_INTEGER) || (parsedOperand.type == ParsedSymbol.TYPE_FLOAT)) {
Decimal128 decimalVal = Decimal128.ZERO;
if (parsedOperand.type == ParsedSymbol.TYPE_INTEGER) {
decimalVal = new Decimal128((Integer) parsedOperand.value);
}
if (parsedOperand.type == ParsedSymbol.TYPE_FLOAT) {
decimalVal = new Decimal128((Double) parsedOperand.value);
}
int did = constants.getDecimalId(decimalVal, false);
if (did == -1) {
if ((missingHandler != null) && (missingHandler.missingDecimal(decimalVal))) {
did = constants.addDecimal(decimalVal);
} else {
throw new AVM2ParseException("Unknown decimal", lexer.yyline());
}
}
operandsList.add(did);
} else {
throw new AVM2ParseException("Float or null expected", lexer.yyline());
}
break;
case AVM2Code.DAT_FLOAT_INDEX:
if (parsedOperand.type == ParsedSymbol.TYPE_KEYWORD_NULL) {
operandsList.add(0);

View File

@@ -16,8 +16,8 @@
*/
package com.jpexs.decompiler.flash.abc.avm2.parser.pcode;
import com.jpexs.decompiler.flash.abc.types.Decimal;
import com.jpexs.decompiler.flash.abc.types.Float4;
import macromedia.asc.util.Decimal128;
/**
* Missing symbol handler.
@@ -37,5 +37,5 @@ public interface MissingSymbolHandler {
public boolean missingFloat4(Float4 value);
public boolean missingDecimal(Decimal value);
public boolean missingDecimal(Decimal128 value);
}

View File

@@ -32,7 +32,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PopScopeIns;
import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.ApplyTypeAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.BooleanAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.FloatValueAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.DoubleValueAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.GetDescendantsAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item;
@@ -1546,8 +1546,8 @@ public class AVM2SourceGenerator implements SourceGenerator {
if (val instanceof IntegerValueAVM2Item) {
return new ValueKind(abcIndex.getSelectedAbc().constants.getIntId(((IntegerValueAVM2Item) val).value, true), ValueKind.CONSTANT_Int);
}
if (val instanceof FloatValueAVM2Item) {
return new ValueKind(abcIndex.getSelectedAbc().constants.getDoubleId(((FloatValueAVM2Item) val).value, true), ValueKind.CONSTANT_Double);
if (val instanceof DoubleValueAVM2Item) {
return new ValueKind(abcIndex.getSelectedAbc().constants.getDoubleId(((DoubleValueAVM2Item) val).value, true), ValueKind.CONSTANT_Double);
}
if (val instanceof NanAVM2Item) {
return new ValueKind(abcIndex.getSelectedAbc().constants.getDoubleId(Double.NaN, true), ValueKind.CONSTANT_Double);

View File

@@ -26,7 +26,7 @@ import com.jpexs.decompiler.flash.abc.avm2.model.ConstructSuperAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.DefaultXMLNamespace;
import com.jpexs.decompiler.flash.abc.avm2.model.EscapeXAttrAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.EscapeXElemAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.FloatValueAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.DoubleValueAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.GetDescendantsAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.GetPropertyAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.HasNextAVM2Item;
@@ -2336,7 +2336,7 @@ public class ActionScript3Parser {
case MINUS:
s = lex();
if (s.isType(SymbolType.DOUBLE)) {
ret = new FloatValueAVM2Item(null, null, -(Double) s.value);
ret = new DoubleValueAVM2Item(null, null, -(Double) s.value);
} else if (s.isType(SymbolType.INTEGER)) {
ret = new IntegerValueAVM2Item(null, null, -(Integer) s.value);
@@ -2348,12 +2348,12 @@ public class ActionScript3Parser {
((IntegerValueAVM2Item) num).value = -((IntegerValueAVM2Item) num).value;
((IntegerValueAVM2Item) num).detectFormat();
ret = num;
} else if (num instanceof FloatValueAVM2Item) {
Double d = ((FloatValueAVM2Item) num).value;
} else if (num instanceof DoubleValueAVM2Item) {
Double d = ((DoubleValueAVM2Item) num).value;
if (d.isInfinite()) {
((FloatValueAVM2Item) num).value = Double.NEGATIVE_INFINITY;
((DoubleValueAVM2Item) num).value = Double.NEGATIVE_INFINITY;
} else {
((FloatValueAVM2Item) num).value = -d;
((DoubleValueAVM2Item) num).value = -d;
}
ret = (num);
} else {
@@ -2435,7 +2435,7 @@ public class ActionScript3Parser {
break;
case INFINITY:
ret = new FloatValueAVM2Item(null, null, Double.POSITIVE_INFINITY);
ret = new DoubleValueAVM2Item(null, null, Double.POSITIVE_INFINITY);
break;
case INTEGER:
@@ -2443,7 +2443,7 @@ public class ActionScript3Parser {
break;
case DOUBLE:
ret = new FloatValueAVM2Item(null, null, (Double) s.value);
ret = new DoubleValueAVM2Item(null, null, (Double) s.value);
allowMemberOrCall = true; // 5.2.toString();
break;
case DELETE:

View File

@@ -1,39 +0,0 @@
/*
* Copyright (C) 2010-2024 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.types;
/**
* Decimal value.
*
* @author JPEXS
*/
public class Decimal {
public byte[] data;
public Decimal() {
}
public Decimal(byte[] data) {
this.data = data;
}
@Override
public String toString() {
return new String(data);
}
}

View File

@@ -22,7 +22,6 @@ import com.jpexs.decompiler.flash.abc.ABCVersion;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.types.ABCException;
import com.jpexs.decompiler.flash.abc.types.ClassInfo;
import com.jpexs.decompiler.flash.abc.types.Decimal;
import com.jpexs.decompiler.flash.abc.types.InstanceInfo;
import com.jpexs.decompiler.flash.abc.types.MetadataInfo;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
@@ -132,6 +131,7 @@ import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import macromedia.asc.util.Decimal128;
/**
* SWF XML importer.
@@ -180,7 +180,7 @@ public class SwfXmlImporter {
CurvedEdgeRecord.class, EndShapeRecord.class, StraightEdgeRecord.class, StyleChangeRecord.class,
BEVELFILTER.class, BLURFILTER.class, COLORMATRIXFILTER.class, CONVOLUTIONFILTER.class,
DROPSHADOWFILTER.class, GLOWFILTER.class, GRADIENTBEVELFILTER.class, GRADIENTGLOWFILTER.class,
AVM2ConstantPool.class, Decimal.class, Namespace.class, NamespaceSet.class, Multiname.class, MethodInfo.class, MetadataInfo.class,
AVM2ConstantPool.class, Decimal128.class, Namespace.class, NamespaceSet.class, Multiname.class, MethodInfo.class, MetadataInfo.class,
ValueKind.class, InstanceInfo.class, Traits.class, TraitClass.class, TraitFunction.class,
TraitMethodGetterSetter.class, TraitSlotConst.class, ClassInfo.class, ScriptInfo.class, MethodBody.class,
ABCException.class, ABCVersion.class, Amf3Value.class,

View File

@@ -46,6 +46,8 @@ public class DottedChain implements Serializable, Comparable<DottedChain> {
public static final DottedChain ARRAY = new DottedChain(new String[]{"Array"});
public static final DottedChain NUMBER = new DottedChain(new String[]{"Number"});
public static final DottedChain DECIMAL = new DottedChain(new String[]{"decimal"});
public static final DottedChain OBJECT = new DottedChain(new String[]{"Object"});

View File

@@ -18,7 +18,7 @@ package com.jpexs.decompiler.graph;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.abc.avm2.model.ConvertAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.FloatValueAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.DoubleValueAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.NameValuePair;
import com.jpexs.decompiler.flash.abc.avm2.model.NewArrayAVM2Item;
@@ -157,14 +157,14 @@ public abstract class GraphTargetItem implements Serializable, Cloneable {
return new StringAVM2Item(null, null, (String) r);
}
if (r instanceof Long) {
return new FloatValueAVM2Item(null, null, (double) (Long) r);
return new DoubleValueAVM2Item(null, null, (double) (Long) r);
}
if (r instanceof Integer) {
return new IntegerValueAVM2Item(null, null, (Integer) r);
}
if (r instanceof Double) {
return new FloatValueAVM2Item(null, null, (Double) r);
return new DoubleValueAVM2Item(null, null, (Double) r);
}
if (r instanceof Null) {
return new NullAVM2Item(null, null);