Issue #45 Unicode character cannot save

Code formatting
This commit is contained in:
Jindra Pet��k
2013-03-30 16:43:26 +01:00
parent d3bd9b641d
commit be106cc34b
772 changed files with 84378 additions and 84353 deletions
@@ -32,286 +32,286 @@ import java.util.List;
public class ASMParser {
public static List<Action> parse(boolean ignoreNops, List<Label> labels, long address, FlasmLexer lexer, List<String> constantPool, int version) throws IOException, ParseException {
List<Action> list = new ArrayList<Action>();
while (true) {
ParsedSymbol symb = lexer.yylex();
if (symb.type == ParsedSymbol.TYPE_LABEL) {
labels.add(new Label((String) symb.value, address));
} else if (symb.type == ParsedSymbol.TYPE_COMMENT) {
if (!list.isEmpty()) {
String cmt = (String) symb.value;
if (cmt.equals("compileTime")) {
Action a = list.get(list.size() - 1);
if (a instanceof ActionIf) {
((ActionIf) a).compileTime = true;
}
}
}
} else if (symb.type == ParsedSymbol.TYPE_INSTRUCTION_NAME) {
String instructionName = ((String) symb.value).toLowerCase();
if (instructionName.equals("GetURL".toLowerCase())) {
list.add(new ActionGetURL(lexer));
} else if (instructionName.equals("GoToLabel".toLowerCase())) {
list.add(new ActionGoToLabel(lexer));
} else if (instructionName.equals("GotoFrame".toLowerCase())) {
list.add(new ActionGotoFrame(lexer));
} else if (instructionName.equals("NextFrame".toLowerCase())) {
list.add(new ActionNextFrame());
} else if (instructionName.equals("Play".toLowerCase())) {
list.add(new ActionPlay());
} else if (instructionName.equals("PrevFrame".toLowerCase())) {
list.add(new ActionPrevFrame());
} else if (instructionName.equals("SetTarget".toLowerCase())) {
list.add(new ActionSetTarget(lexer));
} else if (instructionName.equals("Stop".toLowerCase())) {
list.add(new ActionStop());
} else if (instructionName.equals("StopSounds".toLowerCase())) {
list.add(new ActionStopSounds());
} else if (instructionName.equals("ToggleQuality".toLowerCase())) {
list.add(new ActionToggleQuality());
} else if (instructionName.equals("WaitForFrame".toLowerCase())) {
list.add(new ActionWaitForFrame(lexer));
} else if (instructionName.equals("Add".toLowerCase())) {
list.add(new ActionAdd());
} else if (instructionName.equals("And".toLowerCase())) {
list.add(new ActionAnd());
} else if (instructionName.equals("AsciiToChar".toLowerCase())) {
list.add(new ActionAsciiToChar());
} else if (instructionName.equals("Call".toLowerCase())) {
list.add(new ActionCall());
} else if (instructionName.equals("CharToAscii".toLowerCase())) {
list.add(new ActionCharToAscii());
} else if (instructionName.equals("CloneSprite".toLowerCase())) {
list.add(new ActionCloneSprite());
} else if (instructionName.equals("Divide".toLowerCase())) {
list.add(new ActionDivide());
} else if (instructionName.equals("EndDrag".toLowerCase())) {
list.add(new ActionEndDrag());
} else if (instructionName.equals("Equals".toLowerCase())) {
list.add(new ActionEquals());
} else if (instructionName.equals("GetProperty".toLowerCase())) {
list.add(new ActionGetProperty());
} else if (instructionName.equals("GetTime".toLowerCase())) {
list.add(new ActionGetTime());
} else if (instructionName.equals("GetURL2".toLowerCase())) {
list.add(new ActionGetURL2(lexer));
} else if (instructionName.equals("GetVariable".toLowerCase())) {
list.add(new ActionGetVariable());
} else if (instructionName.equals("GotoFrame2".toLowerCase())) {
list.add(new ActionGotoFrame2(lexer));
} else if (instructionName.equals("If".toLowerCase())) {
list.add(new ActionIf(lexer));
} else if (instructionName.equals("Jump".toLowerCase())) {
list.add(new ActionJump(lexer));
} else if (instructionName.equals("Less".toLowerCase())) {
list.add(new ActionLess());
} else if (instructionName.equals("MBAsciiToChar".toLowerCase())) {
list.add(new ActionMBAsciiToChar());
} else if (instructionName.equals("MBCharToAscii".toLowerCase())) {
list.add(new ActionMBCharToAscii());
} else if (instructionName.equals("MBStringExtract".toLowerCase())) {
list.add(new ActionMBStringExtract());
} else if (instructionName.equals("MBStringLength".toLowerCase())) {
list.add(new ActionMBStringLength());
} else if (instructionName.equals("Multiply".toLowerCase())) {
list.add(new ActionMultiply());
} else if (instructionName.equals("Not".toLowerCase())) {
list.add(new ActionNot());
} else if (instructionName.equals("Or".toLowerCase())) {
list.add(new ActionOr());
} else if (instructionName.equals("Pop".toLowerCase())) {
list.add(new ActionPop());
} else if (instructionName.equals("Push".toLowerCase())) {
list.add(new ActionPush(lexer, constantPool));
} else if (instructionName.equals("RandomNumber".toLowerCase())) {
list.add(new ActionRandomNumber());
} else if (instructionName.equals("RemoveSprite".toLowerCase())) {
list.add(new ActionRemoveSprite());
} else if (instructionName.equals("SetProperty".toLowerCase())) {
list.add(new ActionSetProperty());
} else if (instructionName.equals("SetTarget2".toLowerCase())) {
list.add(new ActionSetTarget2());
} else if (instructionName.equals("SetVariable".toLowerCase())) {
list.add(new ActionSetVariable());
} else if (instructionName.equals("StartDrag".toLowerCase())) {
list.add(new ActionStartDrag());
} else if (instructionName.equals("StringAdd".toLowerCase())) {
list.add(new ActionStringAdd());
} else if (instructionName.equals("StringEquals".toLowerCase())) {
list.add(new ActionStringEquals());
} else if (instructionName.equals("StringExtract".toLowerCase())) {
list.add(new ActionStringExtract());
} else if (instructionName.equals("StringLength".toLowerCase())) {
list.add(new ActionStringLength());
} else if (instructionName.equals("StringLess".toLowerCase())) {
list.add(new ActionStringLess());
} else if (instructionName.equals("Subtract".toLowerCase())) {
list.add(new ActionSubtract());
} else if (instructionName.equals("ToInteger".toLowerCase())) {
list.add(new ActionToInteger());
} else if (instructionName.equals("Trace".toLowerCase())) {
list.add(new ActionTrace());
} else if (instructionName.equals("WaitForFrame2".toLowerCase())) {
list.add(new ActionWaitForFrame2(lexer));
} else if (instructionName.equals("Add2".toLowerCase())) {
list.add(new ActionAdd2());
} else if (instructionName.equals("BitAnd".toLowerCase())) {
list.add(new ActionBitAnd());
} else if (instructionName.equals("BitLShift".toLowerCase())) {
list.add(new ActionBitLShift());
} else if (instructionName.equals("BitOr".toLowerCase())) {
list.add(new ActionBitOr());
} else if (instructionName.equals("BitRShift".toLowerCase())) {
list.add(new ActionBitRShift());
} else if (instructionName.equals("BitURShift".toLowerCase())) {
list.add(new ActionBitURShift());
} else if (instructionName.equals("BitXor".toLowerCase())) {
list.add(new ActionBitXor());
} else if (instructionName.equals("CallFunction".toLowerCase())) {
list.add(new ActionCallFunction());
} else if (instructionName.equals("CallMethod".toLowerCase())) {
list.add(new ActionCallMethod());
} else if (instructionName.equals("ConstantPool".toLowerCase())) {
ActionConstantPool acp = new ActionConstantPool(lexer);
constantPool = acp.constantPool;
list.add(acp);
} else if (instructionName.equals("Decrement".toLowerCase())) {
list.add(new ActionDecrement());
} else if (instructionName.equals("DefineFunction".toLowerCase())) {
list.add(new ActionDefineFunction(ignoreNops, labels, address, lexer, constantPool, version));
} else if (instructionName.equals("DefineLocal".toLowerCase())) {
list.add(new ActionDefineLocal());
} else if (instructionName.equals("DefineLocal2".toLowerCase())) {
list.add(new ActionDefineLocal2());
} else if (instructionName.equals("Delete".toLowerCase())) {
list.add(new ActionDelete());
} else if (instructionName.equals("Delete2".toLowerCase())) {
list.add(new ActionDelete2());
} else if (instructionName.equals("Enumerate".toLowerCase())) {
list.add(new ActionEnumerate());
} else if (instructionName.equals("Equals2".toLowerCase())) {
list.add(new ActionEquals2());
} else if (instructionName.equals("GetMember".toLowerCase())) {
list.add(new ActionGetMember());
} else if (instructionName.equals("Increment".toLowerCase())) {
list.add(new ActionIncrement());
} else if (instructionName.equals("InitArray".toLowerCase())) {
list.add(new ActionInitArray());
} else if (instructionName.equals("InitObject".toLowerCase())) {
list.add(new ActionInitObject());
} else if (instructionName.equals("Less2".toLowerCase())) {
list.add(new ActionLess2());
} else if (instructionName.equals("Modulo".toLowerCase())) {
list.add(new ActionModulo());
} else if (instructionName.equals("NewMethod".toLowerCase())) {
list.add(new ActionNewMethod());
} else if (instructionName.equals("NewObject".toLowerCase())) {
list.add(new ActionNewObject());
} else if (instructionName.equals("PushDuplicate".toLowerCase())) {
list.add(new ActionPushDuplicate());
} else if (instructionName.equals("Return".toLowerCase())) {
list.add(new ActionReturn());
} else if (instructionName.equals("SetMember".toLowerCase())) {
list.add(new ActionSetMember());
} else if (instructionName.equals("StackSwap".toLowerCase())) {
list.add(new ActionStackSwap());
} else if (instructionName.equals("StoreRegister".toLowerCase())) {
list.add(new ActionStoreRegister(lexer));
} else if (instructionName.equals("TargetPath".toLowerCase())) {
list.add(new ActionTargetPath());
} else if (instructionName.equals("ToNumber".toLowerCase())) {
list.add(new ActionToNumber());
} else if (instructionName.equals("ToString".toLowerCase())) {
list.add(new ActionToString());
} else if (instructionName.equals("TypeOf".toLowerCase())) {
list.add(new ActionTypeOf());
} else if (instructionName.equals("With".toLowerCase())) {
list.add(new ActionWith(ignoreNops, labels, address, lexer, constantPool, version));
} else if (instructionName.equals("Enumerate2".toLowerCase())) {
list.add(new ActionEnumerate2());
} else if (instructionName.equals("Greater".toLowerCase())) {
list.add(new ActionGreater());
} else if (instructionName.equals("InstanceOf".toLowerCase())) {
list.add(new ActionInstanceOf());
} else if (instructionName.equals("StrictEquals".toLowerCase())) {
list.add(new ActionStrictEquals());
} else if (instructionName.equals("StringGreater".toLowerCase())) {
list.add(new ActionStringGreater());
} else if (instructionName.equals("CastOp".toLowerCase())) {
list.add(new ActionCastOp());
} else if (instructionName.equals("DefineFunction2".toLowerCase())) {
list.add(new ActionDefineFunction2(ignoreNops, labels, address, lexer, constantPool, version));
} else if (instructionName.equals("Extends".toLowerCase())) {
list.add(new ActionExtends());
} else if (instructionName.equals("ImplementsOp".toLowerCase())) {
list.add(new ActionImplementsOp());
} else if (instructionName.equals("Throw".toLowerCase())) {
list.add(new ActionThrow());
} else if (instructionName.equals("Try".toLowerCase())) {
list.add(new ActionTry(ignoreNops, labels, address, lexer, constantPool, version));
} else if (instructionName.equals("FSCommand2".toLowerCase())) {
list.add(new ActionFSCommand2());
} else if (instructionName.equals("StrictMode".toLowerCase())) {
list.add(new ActionStrictMode(lexer));
} else if (instructionName.equals("Nop".toLowerCase())) {
if (!ignoreNops) {
list.add(new ActionNop());
}
public static List<Action> parse(boolean ignoreNops, List<Label> labels, long address, FlasmLexer lexer, List<String> constantPool, int version) throws IOException, ParseException {
List<Action> list = new ArrayList<Action>();
while (true) {
ParsedSymbol symb = lexer.yylex();
if (symb.type == ParsedSymbol.TYPE_LABEL) {
labels.add(new Label((String) symb.value, address));
} else if (symb.type == ParsedSymbol.TYPE_COMMENT) {
if (!list.isEmpty()) {
String cmt = (String) symb.value;
if (cmt.equals("compileTime")) {
Action a = list.get(list.size() - 1);
if (a instanceof ActionIf) {
((ActionIf) a).compileTime = true;
}
}
}
} else if (symb.type == ParsedSymbol.TYPE_INSTRUCTION_NAME) {
String instructionName = ((String) symb.value).toLowerCase();
if (instructionName.equals("GetURL".toLowerCase())) {
list.add(new ActionGetURL(lexer));
} else if (instructionName.equals("GoToLabel".toLowerCase())) {
list.add(new ActionGoToLabel(lexer));
} else if (instructionName.equals("GotoFrame".toLowerCase())) {
list.add(new ActionGotoFrame(lexer));
} else if (instructionName.equals("NextFrame".toLowerCase())) {
list.add(new ActionNextFrame());
} else if (instructionName.equals("Play".toLowerCase())) {
list.add(new ActionPlay());
} else if (instructionName.equals("PrevFrame".toLowerCase())) {
list.add(new ActionPrevFrame());
} else if (instructionName.equals("SetTarget".toLowerCase())) {
list.add(new ActionSetTarget(lexer));
} else if (instructionName.equals("Stop".toLowerCase())) {
list.add(new ActionStop());
} else if (instructionName.equals("StopSounds".toLowerCase())) {
list.add(new ActionStopSounds());
} else if (instructionName.equals("ToggleQuality".toLowerCase())) {
list.add(new ActionToggleQuality());
} else if (instructionName.equals("WaitForFrame".toLowerCase())) {
list.add(new ActionWaitForFrame(lexer));
} else if (instructionName.equals("Add".toLowerCase())) {
list.add(new ActionAdd());
} else if (instructionName.equals("And".toLowerCase())) {
list.add(new ActionAnd());
} else if (instructionName.equals("AsciiToChar".toLowerCase())) {
list.add(new ActionAsciiToChar());
} else if (instructionName.equals("Call".toLowerCase())) {
list.add(new ActionCall());
} else if (instructionName.equals("CharToAscii".toLowerCase())) {
list.add(new ActionCharToAscii());
} else if (instructionName.equals("CloneSprite".toLowerCase())) {
list.add(new ActionCloneSprite());
} else if (instructionName.equals("Divide".toLowerCase())) {
list.add(new ActionDivide());
} else if (instructionName.equals("EndDrag".toLowerCase())) {
list.add(new ActionEndDrag());
} else if (instructionName.equals("Equals".toLowerCase())) {
list.add(new ActionEquals());
} else if (instructionName.equals("GetProperty".toLowerCase())) {
list.add(new ActionGetProperty());
} else if (instructionName.equals("GetTime".toLowerCase())) {
list.add(new ActionGetTime());
} else if (instructionName.equals("GetURL2".toLowerCase())) {
list.add(new ActionGetURL2(lexer));
} else if (instructionName.equals("GetVariable".toLowerCase())) {
list.add(new ActionGetVariable());
} else if (instructionName.equals("GotoFrame2".toLowerCase())) {
list.add(new ActionGotoFrame2(lexer));
} else if (instructionName.equals("If".toLowerCase())) {
list.add(new ActionIf(lexer));
} else if (instructionName.equals("Jump".toLowerCase())) {
list.add(new ActionJump(lexer));
} else if (instructionName.equals("Less".toLowerCase())) {
list.add(new ActionLess());
} else if (instructionName.equals("MBAsciiToChar".toLowerCase())) {
list.add(new ActionMBAsciiToChar());
} else if (instructionName.equals("MBCharToAscii".toLowerCase())) {
list.add(new ActionMBCharToAscii());
} else if (instructionName.equals("MBStringExtract".toLowerCase())) {
list.add(new ActionMBStringExtract());
} else if (instructionName.equals("MBStringLength".toLowerCase())) {
list.add(new ActionMBStringLength());
} else if (instructionName.equals("Multiply".toLowerCase())) {
list.add(new ActionMultiply());
} else if (instructionName.equals("Not".toLowerCase())) {
list.add(new ActionNot());
} else if (instructionName.equals("Or".toLowerCase())) {
list.add(new ActionOr());
} else if (instructionName.equals("Pop".toLowerCase())) {
list.add(new ActionPop());
} else if (instructionName.equals("Push".toLowerCase())) {
list.add(new ActionPush(lexer, constantPool));
} else if (instructionName.equals("RandomNumber".toLowerCase())) {
list.add(new ActionRandomNumber());
} else if (instructionName.equals("RemoveSprite".toLowerCase())) {
list.add(new ActionRemoveSprite());
} else if (instructionName.equals("SetProperty".toLowerCase())) {
list.add(new ActionSetProperty());
} else if (instructionName.equals("SetTarget2".toLowerCase())) {
list.add(new ActionSetTarget2());
} else if (instructionName.equals("SetVariable".toLowerCase())) {
list.add(new ActionSetVariable());
} else if (instructionName.equals("StartDrag".toLowerCase())) {
list.add(new ActionStartDrag());
} else if (instructionName.equals("StringAdd".toLowerCase())) {
list.add(new ActionStringAdd());
} else if (instructionName.equals("StringEquals".toLowerCase())) {
list.add(new ActionStringEquals());
} else if (instructionName.equals("StringExtract".toLowerCase())) {
list.add(new ActionStringExtract());
} else if (instructionName.equals("StringLength".toLowerCase())) {
list.add(new ActionStringLength());
} else if (instructionName.equals("StringLess".toLowerCase())) {
list.add(new ActionStringLess());
} else if (instructionName.equals("Subtract".toLowerCase())) {
list.add(new ActionSubtract());
} else if (instructionName.equals("ToInteger".toLowerCase())) {
list.add(new ActionToInteger());
} else if (instructionName.equals("Trace".toLowerCase())) {
list.add(new ActionTrace());
} else if (instructionName.equals("WaitForFrame2".toLowerCase())) {
list.add(new ActionWaitForFrame2(lexer));
} else if (instructionName.equals("Add2".toLowerCase())) {
list.add(new ActionAdd2());
} else if (instructionName.equals("BitAnd".toLowerCase())) {
list.add(new ActionBitAnd());
} else if (instructionName.equals("BitLShift".toLowerCase())) {
list.add(new ActionBitLShift());
} else if (instructionName.equals("BitOr".toLowerCase())) {
list.add(new ActionBitOr());
} else if (instructionName.equals("BitRShift".toLowerCase())) {
list.add(new ActionBitRShift());
} else if (instructionName.equals("BitURShift".toLowerCase())) {
list.add(new ActionBitURShift());
} else if (instructionName.equals("BitXor".toLowerCase())) {
list.add(new ActionBitXor());
} else if (instructionName.equals("CallFunction".toLowerCase())) {
list.add(new ActionCallFunction());
} else if (instructionName.equals("CallMethod".toLowerCase())) {
list.add(new ActionCallMethod());
} else if (instructionName.equals("ConstantPool".toLowerCase())) {
ActionConstantPool acp = new ActionConstantPool(lexer);
constantPool = acp.constantPool;
list.add(acp);
} else if (instructionName.equals("Decrement".toLowerCase())) {
list.add(new ActionDecrement());
} else if (instructionName.equals("DefineFunction".toLowerCase())) {
list.add(new ActionDefineFunction(ignoreNops, labels, address, lexer, constantPool, version));
} else if (instructionName.equals("DefineLocal".toLowerCase())) {
list.add(new ActionDefineLocal());
} else if (instructionName.equals("DefineLocal2".toLowerCase())) {
list.add(new ActionDefineLocal2());
} else if (instructionName.equals("Delete".toLowerCase())) {
list.add(new ActionDelete());
} else if (instructionName.equals("Delete2".toLowerCase())) {
list.add(new ActionDelete2());
} else if (instructionName.equals("Enumerate".toLowerCase())) {
list.add(new ActionEnumerate());
} else if (instructionName.equals("Equals2".toLowerCase())) {
list.add(new ActionEquals2());
} else if (instructionName.equals("GetMember".toLowerCase())) {
list.add(new ActionGetMember());
} else if (instructionName.equals("Increment".toLowerCase())) {
list.add(new ActionIncrement());
} else if (instructionName.equals("InitArray".toLowerCase())) {
list.add(new ActionInitArray());
} else if (instructionName.equals("InitObject".toLowerCase())) {
list.add(new ActionInitObject());
} else if (instructionName.equals("Less2".toLowerCase())) {
list.add(new ActionLess2());
} else if (instructionName.equals("Modulo".toLowerCase())) {
list.add(new ActionModulo());
} else if (instructionName.equals("NewMethod".toLowerCase())) {
list.add(new ActionNewMethod());
} else if (instructionName.equals("NewObject".toLowerCase())) {
list.add(new ActionNewObject());
} else if (instructionName.equals("PushDuplicate".toLowerCase())) {
list.add(new ActionPushDuplicate());
} else if (instructionName.equals("Return".toLowerCase())) {
list.add(new ActionReturn());
} else if (instructionName.equals("SetMember".toLowerCase())) {
list.add(new ActionSetMember());
} else if (instructionName.equals("StackSwap".toLowerCase())) {
list.add(new ActionStackSwap());
} else if (instructionName.equals("StoreRegister".toLowerCase())) {
list.add(new ActionStoreRegister(lexer));
} else if (instructionName.equals("TargetPath".toLowerCase())) {
list.add(new ActionTargetPath());
} else if (instructionName.equals("ToNumber".toLowerCase())) {
list.add(new ActionToNumber());
} else if (instructionName.equals("ToString".toLowerCase())) {
list.add(new ActionToString());
} else if (instructionName.equals("TypeOf".toLowerCase())) {
list.add(new ActionTypeOf());
} else if (instructionName.equals("With".toLowerCase())) {
list.add(new ActionWith(ignoreNops, labels, address, lexer, constantPool, version));
} else if (instructionName.equals("Enumerate2".toLowerCase())) {
list.add(new ActionEnumerate2());
} else if (instructionName.equals("Greater".toLowerCase())) {
list.add(new ActionGreater());
} else if (instructionName.equals("InstanceOf".toLowerCase())) {
list.add(new ActionInstanceOf());
} else if (instructionName.equals("StrictEquals".toLowerCase())) {
list.add(new ActionStrictEquals());
} else if (instructionName.equals("StringGreater".toLowerCase())) {
list.add(new ActionStringGreater());
} else if (instructionName.equals("CastOp".toLowerCase())) {
list.add(new ActionCastOp());
} else if (instructionName.equals("DefineFunction2".toLowerCase())) {
list.add(new ActionDefineFunction2(ignoreNops, labels, address, lexer, constantPool, version));
} else if (instructionName.equals("Extends".toLowerCase())) {
list.add(new ActionExtends());
} else if (instructionName.equals("ImplementsOp".toLowerCase())) {
list.add(new ActionImplementsOp());
} else if (instructionName.equals("Throw".toLowerCase())) {
list.add(new ActionThrow());
} else if (instructionName.equals("Try".toLowerCase())) {
list.add(new ActionTry(ignoreNops, labels, address, lexer, constantPool, version));
} else if (instructionName.equals("FSCommand2".toLowerCase())) {
list.add(new ActionFSCommand2());
} else if (instructionName.equals("StrictMode".toLowerCase())) {
list.add(new ActionStrictMode(lexer));
} else if (instructionName.equals("Nop".toLowerCase())) {
if (!ignoreNops) {
list.add(new ActionNop());
}
} else {
throw new ParseException("Unknown instruction name :" + instructionName, lexer.yyline());
}
if (instructionName.equals("Nop".toLowerCase())) {
if (!ignoreNops) {
address += 1;
}
} else {
address += (list.get(list.size() - 1)).getBytes(version).length;
}
} else if (symb.type == ParsedSymbol.TYPE_EOL) {
} else if ((symb.type == ParsedSymbol.TYPE_BLOCK_END) || (symb.type == ParsedSymbol.TYPE_EOF)) {
return list;
} else {
throw new ParseException("Unknown instruction name :" + instructionName, lexer.yyline());
throw new ParseException("Label or Instruction name expected, found:" + symb.type, lexer.yyline());
}
if (instructionName.equals("Nop".toLowerCase())) {
if (!ignoreNops) {
address += 1;
}
} else {
address += (list.get(list.size() - 1)).getBytes(version).length;
}
} else if (symb.type == ParsedSymbol.TYPE_EOL) {
} else if ((symb.type == ParsedSymbol.TYPE_BLOCK_END) || (symb.type == ParsedSymbol.TYPE_EOF)) {
return list;
} else {
throw new ParseException("Label or Instruction name expected, found:" + symb.type, lexer.yyline());
}
}
}
}
}
public static List<Action> parse(boolean ignoreNops, InputStream is, int version) throws IOException, ParseException {
FlasmLexer lexer = new FlasmLexer(is);
List<Label> labels = new ArrayList<Label>();
List<Action> ret = parse(ignoreNops, labels, 0, lexer, new ArrayList<String>(), version);
List<Action> links = Action.getActionsAllIfsOrJumps(ret);
Action.setActionsAddresses(ret, 0, version);
for (Action link : links) {
boolean found = false;
String identifier = null;
if (link instanceof ActionJump) {
identifier = ((ActionJump) link).identifier;
for (Label label : labels) {
if (((ActionJump) link).identifier.equals(label.name)) {
((ActionJump) link).offset = (int) (label.address - (((ActionJump) link).getAddress() + ((ActionJump) link).getBytes(version).length));
found = true;
break;
}
public static List<Action> parse(boolean ignoreNops, InputStream is, int version) throws IOException, ParseException {
FlasmLexer lexer = new FlasmLexer(is);
List<Label> labels = new ArrayList<Label>();
List<Action> ret = parse(ignoreNops, labels, 0, lexer, new ArrayList<String>(), version);
List<Action> links = Action.getActionsAllIfsOrJumps(ret);
Action.setActionsAddresses(ret, 0, version);
for (Action link : links) {
boolean found = false;
String identifier = null;
if (link instanceof ActionJump) {
identifier = ((ActionJump) link).identifier;
for (Label label : labels) {
if (((ActionJump) link).identifier.equals(label.name)) {
((ActionJump) link).offset = (int) (label.address - (((ActionJump) link).getAddress() + ((ActionJump) link).getBytes(version).length));
found = true;
break;
}
}
}
}
if (link instanceof ActionIf) {
identifier = ((ActionIf) link).identifier;
for (Label label : labels) {
if (((ActionIf) link).identifier.equals(label.name)) {
((ActionIf) link).offset = (int) (label.address - (((ActionIf) link).getAddress() + ((ActionIf) link).getBytes(version).length));
found = true;
break;
}
if (link instanceof ActionIf) {
identifier = ((ActionIf) link).identifier;
for (Label label : labels) {
if (((ActionIf) link).identifier.equals(label.name)) {
((ActionIf) link).offset = (int) (label.address - (((ActionIf) link).getAddress() + ((ActionIf) link).getBytes(version).length));
found = true;
break;
}
}
}
}
if ((link instanceof ActionJump) || (link instanceof ActionIf)) {
if (!found) {
//System.err.println("TARGET NOT FOUND - identifier:" + identifier+" addr: ofs"+Helper.formatAddress(link.getAddress()));
if ((link instanceof ActionJump) || (link instanceof ActionIf)) {
if (!found) {
//System.err.println("TARGET NOT FOUND - identifier:" + identifier+" addr: ofs"+Helper.formatAddress(link.getAddress()));
}
}
}
}
return ret;
}
}
return ret;
}
}
File diff suppressed because it is too large Load Diff
@@ -18,11 +18,11 @@ package com.jpexs.decompiler.flash.action.parser;
public class Label {
public String name;
public long address;
public String name;
public long address;
public Label(String name, long address) {
this.name = name;
this.address = address;
}
public Label(String name, long address) {
this.name = name;
this.address = address;
}
}
@@ -18,12 +18,12 @@ package com.jpexs.decompiler.flash.action.parser;
public class ParseException extends Exception {
public long line;
public String text;
public long line;
public String text;
public ParseException(String text, long line) {
super("ParseException:" + text + " on line " + line);
this.line = line;
this.text = text;
}
public ParseException(String text, long line) {
super("ParseException:" + text + " on line " + line);
this.line = line;
this.text = text;
}
}
@@ -18,32 +18,32 @@ package com.jpexs.decompiler.flash.action.parser;
public class ParsedSymbol {
public int type;
public Object value;
public static final int TYPE_STRING = 1;
public static final int TYPE_BLOCK_END = 2;
public static final int TYPE_INSTRUCTION_NAME = 3;
public static final int TYPE_INTEGER = 4;
public static final int TYPE_FLOAT = 5;
public static final int TYPE_BOOLEAN = 11;
public static final int TYPE_IDENTIFIER = 6;
public static final int TYPE_EOF = 7;
public static final int TYPE_LABEL = 8;
public static final int TYPE_COMMENT = 9;
public static final int TYPE_BLOCK_START = 10;
public static final int TYPE_REGISTER = 12;
public static final int TYPE_CONSTANT = 13;
public static final int TYPE_NULL = 14;
public static final int TYPE_UNDEFINED = 15;
public static final int TYPE_EOL = 16;
public static final int TYPE_CONSTANT_LITERAL = 17;
public int type;
public Object value;
public static final int TYPE_STRING = 1;
public static final int TYPE_BLOCK_END = 2;
public static final int TYPE_INSTRUCTION_NAME = 3;
public static final int TYPE_INTEGER = 4;
public static final int TYPE_FLOAT = 5;
public static final int TYPE_BOOLEAN = 11;
public static final int TYPE_IDENTIFIER = 6;
public static final int TYPE_EOF = 7;
public static final int TYPE_LABEL = 8;
public static final int TYPE_COMMENT = 9;
public static final int TYPE_BLOCK_START = 10;
public static final int TYPE_REGISTER = 12;
public static final int TYPE_CONSTANT = 13;
public static final int TYPE_NULL = 14;
public static final int TYPE_UNDEFINED = 15;
public static final int TYPE_EOL = 16;
public static final int TYPE_CONSTANT_LITERAL = 17;
public ParsedSymbol(int type, Object value) {
this.type = type;
this.value = value;
}
public ParsedSymbol(int type, Object value) {
this.type = type;
this.value = value;
}
public ParsedSymbol(int type) {
this.type = type;
}
public ParsedSymbol(int type) {
this.type = type;
}
}