mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-08-02 15:51:16 +00:00
Fixed: #1838 AS3 - Properly handling of long unsigned values, hex values, default uint values etc.
Changed: AS3 integer values are internally (e.g. in the lib) handled as java int type instead of long.
This commit is contained in:
@@ -271,7 +271,13 @@ ExceptionTarget = "exceptiontarget "{PositiveNumberLiteral}":"
|
||||
|
||||
/* numeric literals */
|
||||
|
||||
{NumberLiteral} { return new ParsedSymbol(ParsedSymbol.TYPE_INTEGER, Long.parseLong((yytext()))); }
|
||||
{NumberLiteral} {
|
||||
try {
|
||||
return new ParsedSymbol(ParsedSymbol.TYPE_INTEGER, Integer.parseInt((yytext())));
|
||||
} catch(NumberFormatException nfe) {
|
||||
return new ParsedSymbol(ParsedSymbol.TYPE_FLOAT, Double.parseDouble((yytext())));
|
||||
}
|
||||
}
|
||||
{FloatLiteral} { return new ParsedSymbol(ParsedSymbol.TYPE_FLOAT, Double.parseDouble((yytext()))); }
|
||||
{Identifier} { return new ParsedSymbol(ParsedSymbol.TYPE_IDENTIFIER, yytext()); }
|
||||
{LineTerminator} {yybegin(YYINITIAL);}
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.io.StringReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
import java.math.BigInteger;
|
||||
|
||||
%%
|
||||
|
||||
@@ -188,10 +189,10 @@ XmlSQuoteStringChar = [^\r\n\']
|
||||
/* integer literals */
|
||||
DecIntegerLiteral = 0 | [1-9][0-9]*
|
||||
|
||||
HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8}
|
||||
HexIntegerLiteral = 0 [xX] 0* {HexDigit}+
|
||||
HexDigit = [0-9a-fA-F]
|
||||
|
||||
OctIntegerLiteral = 0+ [1-3]? {OctDigit} {1,15}
|
||||
OctIntegerLiteral = 0+ [1-3]? {OctDigit}+
|
||||
OctDigit = [0-7]
|
||||
|
||||
/* floating point literals */
|
||||
@@ -355,17 +356,29 @@ RegExp = \/([^\r\n/]|\\\/)+\/[a-z]*
|
||||
|
||||
{DecIntegerLiteral} {
|
||||
try{
|
||||
return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, Long.parseLong(yytext()));
|
||||
return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, Integer.parseInt(yytext()));
|
||||
} catch(NumberFormatException nfe){
|
||||
//its too long for a Long var
|
||||
//its too long for an Integer var
|
||||
return new ParsedSymbol(SymbolGroup.DOUBLE, SymbolType.DOUBLE, Double.parseDouble(yytext()));
|
||||
}
|
||||
}
|
||||
|
||||
{HexIntegerLiteral} { return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, Long.parseLong(yytext().substring(2), 16)); }
|
||||
|
||||
{OctIntegerLiteral} { return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, Long.parseLong(yytext(), 8)); }
|
||||
|
||||
{HexIntegerLiteral} {
|
||||
try {
|
||||
return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, Integer.parseInt(yytext().substring(2), 16));
|
||||
} catch (NumberFormatException nfe) {
|
||||
//its too long for an Integer var
|
||||
return new ParsedSymbol(SymbolGroup.DOUBLE, SymbolType.DOUBLE, new BigInteger(yytext().substring(2), 16).doubleValue());
|
||||
}
|
||||
}
|
||||
{OctIntegerLiteral} {
|
||||
try {
|
||||
return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, Integer.parseInt(yytext(), 8));
|
||||
} catch (NumberFormatException nfe) {
|
||||
//its too long for an Integer var
|
||||
return new ParsedSymbol(SymbolGroup.DOUBLE, SymbolType.DOUBLE, new BigInteger(yytext(), 8).doubleValue());
|
||||
}
|
||||
}
|
||||
{DoubleLiteral} { return new ParsedSymbol(SymbolGroup.DOUBLE, SymbolType.DOUBLE, Double.parseDouble(yytext())); }
|
||||
|
||||
/* comments */
|
||||
|
||||
@@ -116,10 +116,10 @@ IdentifierOrParent = {Identifier} | ".."
|
||||
/* integer literals */
|
||||
DecIntegerLiteral = 0 | [1-9][0-9]*
|
||||
|
||||
HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8}
|
||||
HexIntegerLiteral = 0 [xX] 0* {HexDigit}+
|
||||
HexDigit = [0-9a-fA-F]
|
||||
|
||||
OctIntegerLiteral = 0+ [1-3]? {OctDigit} {1,15}
|
||||
OctIntegerLiteral = 0+ [1-3]? {OctDigit}+
|
||||
OctDigit = [0-7]
|
||||
|
||||
/* floating point literals */
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc;
|
||||
|
||||
import com.jpexs.decompiler.flash.EndOfStreamException;
|
||||
@@ -236,7 +237,7 @@ public class ABCInputStream implements AutoCloseable {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
public int readS32(String name) throws IOException {
|
||||
int i;
|
||||
long ret = 0;
|
||||
int bytePos = 0;
|
||||
@@ -258,7 +259,7 @@ public class ABCInputStream implements AutoCloseable {
|
||||
}
|
||||
} while (nextByte && byteCount < 5);
|
||||
endDumpLevel(ret);
|
||||
endDumpLevel(ret);
|
||||
return (int) ret;
|
||||
}
|
||||
|
||||
public int available() throws IOException {
|
||||
|
||||
@@ -48,7 +48,7 @@ public class AVM2ConstantPool implements Cloneable {
|
||||
private static final Logger logger = Logger.getLogger(AVM2ConstantPool.class.getName());
|
||||
|
||||
@SWFField
|
||||
private HashArrayList<Long> constant_int = new HashArrayList<>();
|
||||
private HashArrayList<Integer> constant_int = new HashArrayList<>();
|
||||
|
||||
@SWFField
|
||||
private HashArrayList<Long> constant_uint = new HashArrayList<>();
|
||||
@@ -165,10 +165,10 @@ public class AVM2ConstantPool implements Cloneable {
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized int addInt(long value) {
|
||||
public synchronized int addInt(int value) {
|
||||
ensureDefault(constant_int);
|
||||
value = (int) value;
|
||||
constant_int.add(value);
|
||||
constant_int.add((Integer) value);
|
||||
return constant_int.size() - 1;
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ public class AVM2ConstantPool implements Cloneable {
|
||||
return constant_string.size() - 1;
|
||||
}
|
||||
|
||||
public long setInt(int index, long value) {
|
||||
public long setInt(int index, int value) {
|
||||
constant_int.set(index, value);
|
||||
return value;
|
||||
}
|
||||
@@ -281,7 +281,7 @@ public class AVM2ConstantPool implements Cloneable {
|
||||
return value;
|
||||
}
|
||||
|
||||
public long getInt(int index) {
|
||||
public int getInt(int index) {
|
||||
try {
|
||||
if (index == 0) {
|
||||
return 0;
|
||||
@@ -502,7 +502,7 @@ public class AVM2ConstantPool implements Cloneable {
|
||||
return getNamespaceId(kind, nameIndex, index, add);
|
||||
}
|
||||
|
||||
private int getIntId(long value) {
|
||||
private int getIntId(int value) {
|
||||
return constant_int.indexOf(value);
|
||||
}
|
||||
|
||||
@@ -587,7 +587,7 @@ public class AVM2ConstantPool implements Cloneable {
|
||||
return getStringId(val.toRawString(), add);
|
||||
}
|
||||
|
||||
public int getIntId(long val, boolean add) {
|
||||
public int getIntId(int val, boolean add) {
|
||||
int id = getIntId(val);
|
||||
if (add && id == -1) {
|
||||
id = addInt(val);
|
||||
@@ -738,8 +738,8 @@ public class AVM2ConstantPool implements Cloneable {
|
||||
}
|
||||
|
||||
public AVM2Instruction makePush(Object ovalue) {
|
||||
if (ovalue instanceof Long) {
|
||||
long value = (Long) ovalue;
|
||||
if (ovalue instanceof Integer) {
|
||||
int value = (Integer) ovalue;
|
||||
if (value >= -128 && value <= 127) {
|
||||
return new AVM2Instruction(0, AVM2Instructions.PushByte, new int[]{(int) (long) value});
|
||||
} else if (value >= -32768 && value <= 32767) {
|
||||
@@ -792,7 +792,7 @@ public class AVM2ConstantPool implements Cloneable {
|
||||
}
|
||||
intMap.put(0, 0);
|
||||
for (int i = 1; i < secondPool.constant_int.size(); i++) {
|
||||
Long val = secondPool.constant_int.get(i);
|
||||
int val = secondPool.constant_int.get(i);
|
||||
intMap.put(i, getIntId(val, true));
|
||||
}
|
||||
uintMap.put(0, 0);
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.AVM2LocalData;
|
||||
@@ -71,7 +72,7 @@ public class DecLocalIIns extends InstructionDefinition {
|
||||
output.add(new DecLocalAVM2Item(ins, localData.lineStartInstruction, regId));
|
||||
}
|
||||
if (localData.localRegs.containsKey(regId)) {
|
||||
if (localData.localRegs.containsKey(regId)) {
|
||||
localData.localRegs.put(regId, new SubtractAVM2Item(ins, localData.lineStartInstruction, localData.localRegs.get(regId), new IntegerValueAVM2Item(ins, localData.lineStartInstruction, 1)));
|
||||
} else {
|
||||
//localRegs.put(regIndex, new SubtractAVM2Item(ins, localData.lineStartInstruction, new IntegerValueAVM2Item(ins, localData.lineStartInstruction, new Long(0)), new IntegerValueAVM2Item(ins, localData.lineStartInstruction, new Long(1))));
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.AVM2LocalData;
|
||||
@@ -71,7 +72,7 @@ public class DecLocalIns extends InstructionDefinition {
|
||||
output.add(new DecLocalAVM2Item(ins, localData.lineStartInstruction, regId));
|
||||
}
|
||||
if (localData.localRegs.containsKey(regId)) {
|
||||
if (localData.localRegs.containsKey(regId)) {
|
||||
localData.localRegs.put(regId, new SubtractAVM2Item(ins, localData.lineStartInstruction, localData.localRegs.get(regId), new IntegerValueAVM2Item(ins, localData.lineStartInstruction, 1)));
|
||||
} else {
|
||||
//localRegs.put(regIndex, new SubtractAVM2Item(ins, localData.lineStartInstruction, new IntegerValueAVM2Item(ins, localData.lineStartInstruction, new Long(0)), new IntegerValueAVM2Item(ins, localData.lineStartInstruction, new Long(1))));
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.AVM2LocalData;
|
||||
@@ -71,7 +72,7 @@ public class IncLocalIIns extends InstructionDefinition {
|
||||
output.add(new IncLocalAVM2Item(ins, localData.lineStartInstruction, regId));
|
||||
}
|
||||
if (localData.localRegs.containsKey(regId)) {
|
||||
if (localData.localRegs.containsKey(regId)) {
|
||||
localData.localRegs.put(regId, new AddAVM2Item(ins, localData.lineStartInstruction, localData.localRegs.get(regId), new IntegerValueAVM2Item(ins, localData.lineStartInstruction, 1)));
|
||||
}
|
||||
if (!localData.localRegAssignmentIps.containsKey(regId)) {
|
||||
localData.localRegAssignmentIps.put(regId, 0);
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.AVM2LocalData;
|
||||
@@ -71,7 +72,7 @@ public class IncLocalIns extends InstructionDefinition {
|
||||
output.add(new IncLocalAVM2Item(ins, localData.lineStartInstruction, regId));
|
||||
}
|
||||
if (localData.localRegs.containsKey(regId)) {
|
||||
if (localData.localRegs.containsKey(regId)) {
|
||||
localData.localRegs.put(regId, new AddAVM2Item(ins, localData.lineStartInstruction, localData.localRegs.get(regId), new IntegerValueAVM2Item(ins, localData.lineStartInstruction, 1)));
|
||||
} else {
|
||||
//localRegs.put(regIndex, new AddAVM2Item(ins, localData.lineStartInstruction, null, new IntegerValueAVM2Item(ins, localData.lineStartInstruction, new Long(1))));
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.stack;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
@@ -45,7 +46,7 @@ public class PushByteIns extends InstructionDefinition implements PushIntegerTyp
|
||||
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
stack.push(new IntegerValueAVM2Item(ins, localData.lineStartInstruction, (int) (byte) ins.operands[0]));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.stack;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
@@ -45,7 +46,7 @@ public class PushShortIns extends InstructionDefinition implements PushIntegerTy
|
||||
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
stack.push(new IntegerValueAVM2Item(ins, localData.lineStartInstruction, (int) (short) ins.operands[0]));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.stack;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
@@ -22,6 +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.IntegerValueAVM2Item;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
@@ -45,7 +47,7 @@ public class PushUIntIns extends InstructionDefinition implements PushIntegerTyp
|
||||
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
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])));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -123,13 +123,13 @@ public class InitVectorAVM2Item extends AVM2Item {
|
||||
ins(AVM2Instructions.GetProperty, constants.getMultinameId(Multiname.createMultiname(false, constants.getStringId("Vector", true), allNsSet(g.abcIndex)), true)),
|
||||
subtype,
|
||||
ins(AVM2Instructions.ApplyType, 1),
|
||||
new IntegerValueAVM2Item(null, null, (long) arguments.size()),
|
||||
new IntegerValueAVM2Item(null, null, arguments.size()),
|
||||
ins(AVM2Instructions.Construct, 1)
|
||||
);
|
||||
for (int i = 0; i < arguments.size(); i++) {
|
||||
ret.addAll(toSourceMerge(localData, generator,
|
||||
ins(AVM2Instructions.Dup),
|
||||
new IntegerValueAVM2Item(null, null, (long) i),
|
||||
new IntegerValueAVM2Item(null, null, i),
|
||||
arguments.get(i),
|
||||
ins(AVM2Instructions.SetProperty, constants.getMultinameId(Multiname.createMultinameL(false, NamespaceItem.getCpoolSetIndex(g.abcIndex, openedNamespaces)), true))
|
||||
));
|
||||
|
||||
@@ -42,9 +42,9 @@ import java.util.Set;
|
||||
*/
|
||||
public class IntegerValueAVM2Item extends NumberValueAVM2Item implements IntegerValueTypeItem {
|
||||
|
||||
public Long value;
|
||||
public Integer value;
|
||||
|
||||
public IntegerValueAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, Long value) {
|
||||
public IntegerValueAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, Integer value) {
|
||||
super(instruction, lineStartIns);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@@ -483,7 +483,7 @@ public class ASM3Parser {
|
||||
value_index = 0;
|
||||
} else {
|
||||
expected(value, ParsedSymbol.TYPE_INTEGER, "Integer or null");
|
||||
value_index = constants.getIntId((Long) value.value, true);
|
||||
value_index = constants.getIntId((Integer) value.value, true);
|
||||
}
|
||||
expected(ParsedSymbol.TYPE_PARENT_CLOSE, ")", lexer);
|
||||
break;
|
||||
@@ -517,7 +517,7 @@ public class ASM3Parser {
|
||||
break;*/
|
||||
case ParsedSymbol.TYPE_INTEGER:
|
||||
value_kind = ValueKind.CONSTANT_Int;
|
||||
value_index = constants.getIntId((Long) type.value, true);
|
||||
value_index = constants.getIntId((Integer) type.value, true);
|
||||
break;
|
||||
case ParsedSymbol.TYPE_FLOAT:
|
||||
value_kind = ValueKind.CONSTANT_Double;
|
||||
@@ -935,7 +935,7 @@ public class ASM3Parser {
|
||||
if (parsedOperand.type == ParsedSymbol.TYPE_KEYWORD_NULL) {
|
||||
operandsList.add(0);
|
||||
} else if (parsedOperand.type == ParsedSymbol.TYPE_INTEGER) {
|
||||
long intVal = (Long) parsedOperand.value;
|
||||
int intVal = (Integer) parsedOperand.value;
|
||||
int iid = constants.getIntId(intVal, false);
|
||||
if (iid == -1) {
|
||||
if ((missingHandler != null) && (missingHandler.missingInt(intVal))) {
|
||||
@@ -1117,7 +1117,7 @@ public class ASM3Parser {
|
||||
break;
|
||||
case AVM2Code.OPT_S8:
|
||||
if (parsedOperand.type == ParsedSymbol.TYPE_INTEGER) {
|
||||
long val = (long) (Long) parsedOperand.value;
|
||||
int val = (Integer) parsedOperand.value;
|
||||
if (val < Byte.MIN_VALUE || val > Byte.MAX_VALUE) {
|
||||
throw new AVM2ParseException("Byte value expected (" + Byte.MIN_VALUE + " to " + Byte.MAX_VALUE + "). Use pushshort or pushint to push larger values", lexer.yyline());
|
||||
}
|
||||
|
||||
@@ -2226,7 +2226,11 @@ public final class Flasm3Lexer {
|
||||
}
|
||||
case 115: break;
|
||||
case 10:
|
||||
{ return new ParsedSymbol(ParsedSymbol.TYPE_INTEGER, Long.parseLong((yytext())));
|
||||
{ try {
|
||||
return new ParsedSymbol(ParsedSymbol.TYPE_INTEGER, Integer.parseInt((yytext())));
|
||||
} catch(NumberFormatException nfe) {
|
||||
return new ParsedSymbol(ParsedSymbol.TYPE_FLOAT, Double.parseDouble((yytext())));
|
||||
}
|
||||
}
|
||||
case 116: break;
|
||||
case 11:
|
||||
|
||||
@@ -625,11 +625,11 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
}
|
||||
|
||||
List<AVM2Instruction> cases = new ArrayList<>();
|
||||
cases.addAll(toInsList(new IntegerValueAVM2Item(null, null, (long) defIndex).toSource(localData, this)));
|
||||
cases.addAll(toInsList(new IntegerValueAVM2Item(null, null, defIndex).toSource(localData, this)));
|
||||
int cLen = insToBytes(cases).length;
|
||||
List<AVM2Instruction> caseLast = new ArrayList<>();
|
||||
caseLast.add(0, ins(AVM2Instructions.Jump, cLen));
|
||||
caseLast.addAll(0, toInsList(new IntegerValueAVM2Item(null, null, (long) defIndex).toSource(localData, this)));
|
||||
caseLast.addAll(0, toInsList(new IntegerValueAVM2Item(null, null, defIndex).toSource(localData, this)));
|
||||
int cLastLen = insToBytes(caseLast).length;
|
||||
caseLast.add(0, ins(AVM2Instructions.Jump, cLastLen));
|
||||
cases.addAll(0, caseLast);
|
||||
@@ -643,7 +643,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
continue;
|
||||
}
|
||||
List<AVM2Instruction> sub = new ArrayList<>();
|
||||
sub.addAll(toInsList(new IntegerValueAVM2Item(null, null, (long) i).toSource(localData, this)));
|
||||
sub.addAll(toInsList(new IntegerValueAVM2Item(null, null, i).toSource(localData, this)));
|
||||
sub.add(ins(AVM2Instructions.Jump, insToBytes(cases).length));
|
||||
int subLen = insToBytes(sub).length;
|
||||
|
||||
@@ -717,7 +717,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
}
|
||||
cnt++;
|
||||
localData.finallyCounter.put(clauseId, cnt);
|
||||
ret.addAll(new IntegerValueAVM2Item(null, null, (long) cnt).toSource(localData, this));
|
||||
ret.addAll(new IntegerValueAVM2Item(null, null, cnt).toSource(localData, this));
|
||||
ret.add(ins(new FinallyJumpIns(clauseId), 0));
|
||||
ret.add(ins(AVM2Instructions.Label));
|
||||
ret.add(ins(AVM2Instructions.Pop));
|
||||
@@ -1103,7 +1103,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
}
|
||||
cnt++;
|
||||
localData.finallyCounter.put(clauseId, cnt);
|
||||
ret.addAll(new IntegerValueAVM2Item(null, null, (long) cnt).toSource(localData, this));
|
||||
ret.addAll(new IntegerValueAVM2Item(null, null, cnt).toSource(localData, this));
|
||||
ret.add(ins(new FinallyJumpIns(clauseId), 0));
|
||||
ret.add(ins(AVM2Instructions.Label));
|
||||
ret.add(ins(AVM2Instructions.Pop));
|
||||
@@ -1143,7 +1143,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
}
|
||||
cnt++;
|
||||
localData.finallyCounter.put(clauseId, cnt);
|
||||
ret.addAll(new IntegerValueAVM2Item(null, null, (long) cnt).toSource(localData, this));
|
||||
ret.addAll(new IntegerValueAVM2Item(null, null, cnt).toSource(localData, this));
|
||||
ret.add(ins(new FinallyJumpIns(clauseId), 0));
|
||||
ret.add(ins(AVM2Instructions.Label));
|
||||
ret.add(ins(AVM2Instructions.Pop));
|
||||
@@ -1171,7 +1171,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
}
|
||||
cnt++;
|
||||
localData.finallyCounter.put(clauseId, cnt);
|
||||
ret.addAll(new IntegerValueAVM2Item(null, null, (long) cnt).toSource(localData, this));
|
||||
ret.addAll(new IntegerValueAVM2Item(null, null, cnt).toSource(localData, this));
|
||||
ret.add(ins(new FinallyJumpIns(clauseId), 0));
|
||||
ret.add(ins(AVM2Instructions.Label));
|
||||
ret.add(ins(AVM2Instructions.Pop));
|
||||
@@ -1568,7 +1568,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
|
||||
public int propertyName(GraphTargetItem name) {
|
||||
if (name instanceof NameAVM2Item) {
|
||||
NameAVM2Item va = (NameAVM2Item) name;
|
||||
NameAVM2Item va = (NameAVM2Item) name;
|
||||
return abcIndex.getSelectedAbc().constants.getMultinameId(Multiname.createQName(false, str(va.getVariableName()), namespace(Namespace.KIND_PACKAGE, "")), true);
|
||||
}
|
||||
throw new RuntimeException("no prop"); //FIXME
|
||||
@@ -2103,6 +2103,10 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
if (val instanceof UndefinedAVM2Item) {
|
||||
return new ValueKind(ValueKind.CONSTANT_Undefined, ValueKind.CONSTANT_Undefined);
|
||||
}
|
||||
|
||||
//TODO: the compiler should check whether default value is compatible with its type
|
||||
//Flash CS6 does this, example message: "Incompatible default value of type int where String is expected."
|
||||
//However a negative integer value on uint type silently loses its negation. Weird.
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -129,6 +129,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Stack;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@@ -510,14 +511,16 @@ public class ActionScript3Parser {
|
||||
paramNames.add(s.value.toString());
|
||||
s = lex();
|
||||
if (!hasRest) {
|
||||
GraphTargetItem currentType;
|
||||
if (s.type == SymbolType.COLON) {
|
||||
paramTypes.add(type(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, variables));
|
||||
paramTypes.add(currentType = type(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, variables));
|
||||
s = lex();
|
||||
} else {
|
||||
paramTypes.add(new UnboundedTypeItem());
|
||||
paramTypes.add(currentType = new UnboundedTypeItem());
|
||||
}
|
||||
if (s.type == SymbolType.ASSIGN) {
|
||||
paramValues.add(expression(allOpenedNamespaces, thisType, pkg, new Reference<>(false), importedClasses, openedNamespaces, null, isMethod, isMethod, isMethod, variables, false));
|
||||
GraphTargetItem currentValue = expression(allOpenedNamespaces, thisType, pkg, new Reference<>(false), importedClasses, openedNamespaces, null, isMethod, isMethod, isMethod, variables, false);
|
||||
paramValues.add(currentValue);
|
||||
s = lex();
|
||||
} else if (!paramValues.isEmpty()) {
|
||||
throw new AVM2ParseException("Some of parameters do not have default values", lexer.yyline());
|
||||
@@ -1588,7 +1591,7 @@ public class ActionScript3Parser {
|
||||
//GraphTargetItem firstCommand = command(thisType,pkg,needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables);
|
||||
forExpr = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables, false);
|
||||
if (forExpr == null) {
|
||||
forExpr = new TrueItem(null,null);
|
||||
forExpr = new TrueItem(null, null);
|
||||
}
|
||||
expectedType(SymbolType.SEMICOLON);
|
||||
GraphTargetItem fcom = command(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables);
|
||||
@@ -2266,7 +2269,7 @@ public class ActionScript3Parser {
|
||||
ret = new FloatValueAVM2Item(null, null, -(Double) s.value);
|
||||
|
||||
} else if (s.isType(SymbolType.INTEGER)) {
|
||||
ret = new IntegerValueAVM2Item(null, null, -(Long) s.value);
|
||||
ret = new IntegerValueAVM2Item(null, null, -(Integer) s.value);
|
||||
|
||||
} else {
|
||||
lexer.pushback(s);
|
||||
@@ -2360,7 +2363,7 @@ public class ActionScript3Parser {
|
||||
|
||||
break;
|
||||
case INTEGER:
|
||||
ret = new IntegerValueAVM2Item(null, null, (Long) s.value);
|
||||
ret = new IntegerValueAVM2Item(null, null, (Integer) s.value);
|
||||
|
||||
break;
|
||||
case DOUBLE:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -166,7 +166,7 @@ public class NameAVM2Item extends AssignableAVM2Item {
|
||||
case "*":
|
||||
return new UndefinedAVM2Item(null, null);
|
||||
case "int":
|
||||
return new IntegerValueAVM2Item(null, null, 0L);
|
||||
return new IntegerValueAVM2Item(null, null, 0);
|
||||
case "Boolean":
|
||||
return new BooleanAVM2Item(null, null, Boolean.FALSE);
|
||||
case "Number":
|
||||
|
||||
@@ -195,7 +195,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
|
||||
case "*":
|
||||
return new UndefinedAVM2Item(null, null);
|
||||
case "int":
|
||||
return new IntegerValueAVM2Item(null, null, 0L);
|
||||
return new IntegerValueAVM2Item(null, null, 0);
|
||||
case "Boolean":
|
||||
return new BooleanAVM2Item(null, null, Boolean.FALSE);
|
||||
case "Number":
|
||||
@@ -493,7 +493,6 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
|
||||
return resolvedRoot = ret;
|
||||
}
|
||||
|
||||
|
||||
if (!isProperty && (name.size() == 1 && name.get(0).equals("Vector"))) {
|
||||
TypeItem ret = new TypeItem(InitVectorAVM2Item.VECTOR_FQN);
|
||||
resolved = ret;
|
||||
|
||||
@@ -62,7 +62,7 @@ public class MethodInfoParser {
|
||||
int id = 0;
|
||||
switch (symbValue.type) {
|
||||
case ParsedSymbol.TYPE_INTEGER:
|
||||
value = new ValueKind(abc.constants.getIntId((Long) symbValue.value, true), ValueKind.CONSTANT_Int);
|
||||
value = new ValueKind(abc.constants.getIntId((Integer) symbValue.value, true), ValueKind.CONSTANT_Int);
|
||||
break;
|
||||
case ParsedSymbol.TYPE_FLOAT:
|
||||
value = new ValueKind(abc.constants.getDoubleId((Double) symbValue.value, true), ValueKind.CONSTANT_Double);
|
||||
@@ -177,7 +177,7 @@ public class MethodInfoParser {
|
||||
if (symb.type == ParsedSymbol.TYPE_COLON) {
|
||||
ParsedSymbol symbType = lexer.yylex();
|
||||
if (symbType.type == ParsedSymbol.TYPE_STAR) {
|
||||
paramTypes.add((Long)0L);
|
||||
paramTypes.add((Long) 0L);
|
||||
} else if (symbType.type == ParsedSymbol.TYPE_MULTINAME) {
|
||||
paramTypes.add((Long) symbType.value);
|
||||
} else {
|
||||
@@ -200,7 +200,7 @@ public class MethodInfoParser {
|
||||
int id = 0;
|
||||
switch (symbValue.type) {
|
||||
case ParsedSymbol.TYPE_INTEGER:
|
||||
optionalValues.add(new ValueKind(abc.constants.getIntId((Long) symbValue.value, true), ValueKind.CONSTANT_Int));
|
||||
optionalValues.add(new ValueKind(abc.constants.getIntId((Integer) symbValue.value, true), ValueKind.CONSTANT_Int));
|
||||
break;
|
||||
case ParsedSymbol.TYPE_FLOAT:
|
||||
optionalValues.add(new ValueKind(abc.constants.getDoubleId((Double) symbValue.value, true), ValueKind.CONSTANT_Double));
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.abc.types;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.helpers.Helper;
|
||||
|
||||
/**
|
||||
@@ -131,13 +132,13 @@ public class ValueKind {
|
||||
String ret = "?";
|
||||
switch (value_kind) {
|
||||
case CONSTANT_Int:
|
||||
ret = "" + constants.getInt(value_index);
|
||||
ret = EcmaScript.toString(constants.getInt(value_index));
|
||||
break;
|
||||
case CONSTANT_UInt:
|
||||
ret = "" + constants.getUInt(value_index);
|
||||
ret = EcmaScript.toString(constants.getUInt(value_index));
|
||||
break;
|
||||
case CONSTANT_Double:
|
||||
ret = "" + constants.getDouble(value_index);
|
||||
ret = EcmaScript.toString(constants.getDouble(value_index));
|
||||
break;
|
||||
case CONSTANT_DecimalOrFloat:
|
||||
ret = "" + constants.getDecimal(value_index);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -121,10 +121,10 @@ public abstract class GraphTargetItem implements Serializable, Cloneable {
|
||||
return new StringAVM2Item(null, null, (String) r);
|
||||
}
|
||||
if (r instanceof Long) {
|
||||
return new IntegerValueAVM2Item(null, null, (Long) r);
|
||||
return new FloatValueAVM2Item(null, null, (double) (Long) r);
|
||||
}
|
||||
if (r instanceof Integer) {
|
||||
return new IntegerValueAVM2Item(null, null, (long) (int) (Integer) r);
|
||||
return new IntegerValueAVM2Item(null, null, (Integer) r);
|
||||
}
|
||||
|
||||
if (r instanceof Double) {
|
||||
|
||||
Reference in New Issue
Block a user