Better line start detection

Fixed debug info injection
This commit is contained in:
Jindra Petřík
2015-11-17 09:24:42 +01:00
parent 632e5156c8
commit 4a4e0e4898
547 changed files with 2058 additions and 1911 deletions

View File

@@ -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.graph.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -34,8 +35,8 @@ public class AndItem extends BinaryOpItem {
return ret;
}
public AndItem(GraphSourceItem src, GraphTargetItem leftSide, GraphTargetItem rightSide) {
public AndItem(GraphSourceItem src, GraphSourceItem lineStartIns, GraphTargetItem leftSide, GraphTargetItem rightSide) {
super(src, lineStartIns, PRECEDENCE_LOGICALAND, leftSide, rightSide, "&&");
this.leftSide = leftSide;
this.rightSide = rightSide;
}

View File

@@ -43,8 +43,8 @@ public abstract class BinaryOpItem extends GraphTargetItem implements BinaryOp {
return fp;
}
public BinaryOpItem(GraphSourceItem instruction, int precedence, GraphTargetItem leftSide, GraphTargetItem rightSide, String operator) {
super(instruction, precedence);
public BinaryOpItem(GraphSourceItem instruction, GraphSourceItem lineStartItem, int precedence, GraphTargetItem leftSide, GraphTargetItem rightSide, String operator) {
super(instruction, lineStartItem, precedence);
this.leftSide = leftSide;
this.rightSide = rightSide;
this.operator = operator;
@@ -147,10 +147,7 @@ public abstract class BinaryOpItem extends GraphTargetItem implements BinaryOp {
if (!Objects.equals(rightSide, other.rightSide)) {
return false;
}
if (!Objects.equals(operator, other.operator)) {
return false;
}
return true;
return (Objects.equals(operator, other.operator));
}
/*@Override

View File

@@ -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.graph.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -33,8 +34,8 @@ public class BlockItem extends GraphTargetItem {
List<GraphTargetItem> commands;
public BlockItem(GraphSourceItem src, List<GraphTargetItem> commands) {
public BlockItem(GraphSourceItem src, GraphSourceItem lineStartIns, List<GraphTargetItem> commands) {
super(src, lineStartIns, PRECEDENCE_PRIMARY);
this.commands = commands;
}

View File

@@ -36,8 +36,8 @@ public class BreakItem extends GraphTargetItem {
private boolean labelRequired;
public BreakItem(GraphSourceItem src, long loopId) {
super(src, NOPRECEDENCE);
public BreakItem(GraphSourceItem src, GraphSourceItem lineStartIns, long loopId) {
super(src, lineStartIns, NOPRECEDENCE);
this.loopId = loopId;
}

View File

@@ -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.graph.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -32,8 +33,8 @@ public class CommaExpressionItem extends GraphTargetItem {
public List<GraphTargetItem> commands;
public CommaExpressionItem(GraphSourceItem src, List<GraphTargetItem> commands) {
public CommaExpressionItem(GraphSourceItem src, GraphSourceItem lineStartIns, List<GraphTargetItem> commands) {
super(src, lineStartIns, PRECEDENCE_PRIMARY);
this.commands = commands;
}

View File

@@ -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.graph.model;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
@@ -28,12 +29,12 @@ public class CommentItem extends GraphTargetItem {
private final String[] commentLines;
public CommentItem(String comment) {
public CommentItem(String comment) {
super(null, null, NOPRECEDENCE);
this.commentLines = new String[]{comment};
}
public CommentItem(String[] commentLines) {
public CommentItem(String[] commentLines) {
super(null, null, NOPRECEDENCE);
this.commentLines = commentLines;
}

View File

@@ -36,8 +36,8 @@ public class ContinueItem extends GraphTargetItem {
private boolean labelRequired;
public ContinueItem(GraphSourceItem src, long loopId) {
super(src, NOPRECEDENCE);
public ContinueItem(GraphSourceItem src, GraphSourceItem lineStartIns, long loopId) {
super(src, lineStartIns, NOPRECEDENCE);
this.loopId = loopId;
}

View File

@@ -52,8 +52,8 @@ public class DoWhileItem extends LoopItem implements Block {
return ret;
}
public DoWhileItem(GraphSourceItem src, Loop loop, List<GraphTargetItem> commands, List<GraphTargetItem> expression) {
super(src, loop);
public DoWhileItem(GraphSourceItem src, GraphSourceItem lineStartIns, Loop loop, List<GraphTargetItem> commands, List<GraphTargetItem> expression) {
super(src, lineStartIns, loop);
this.expression = expression;
this.commands = commands;
}

View File

@@ -33,8 +33,8 @@ import java.util.Set;
*/
public class DuplicateItem extends GraphTargetItem implements SimpleValue {
public DuplicateItem(GraphSourceItem src, GraphTargetItem value) {
super(src, value.getPrecedence(), value);
public DuplicateItem(GraphSourceItem src, GraphSourceItem lineStartIns, GraphTargetItem value) {
super(src, lineStartIns, value.getPrecedence(), value);
}
@Override

View File

@@ -32,8 +32,8 @@ import java.util.Set;
*/
public class FalseItem extends GraphTargetItem implements LogicalOpItem, SimpleValue {
public FalseItem(GraphSourceItem src) {
super(src, PRECEDENCE_PRIMARY);
public FalseItem(GraphSourceItem src, GraphSourceItem lineStartIns) {
super(src, lineStartIns, PRECEDENCE_PRIMARY);
}
@Override
@@ -58,7 +58,7 @@ public class FalseItem extends GraphTargetItem implements LogicalOpItem, SimpleV
@Override
public GraphTargetItem invert(GraphSourceItem neqSrc) {
return new TrueItem(null);
return new TrueItem(getSrc(), getLineStartItem());
}
@Override

View File

@@ -57,8 +57,8 @@ public class ForItem extends LoopItem implements Block {
return ret;
}
public ForItem(GraphSourceItem src, Loop loop, List<GraphTargetItem> firstCommands, GraphTargetItem expression, List<GraphTargetItem> finalCommands, List<GraphTargetItem> commands) {
super(src, loop);
public ForItem(GraphSourceItem src, GraphSourceItem lineStartIns, Loop loop, List<GraphTargetItem> firstCommands, GraphTargetItem expression, List<GraphTargetItem> finalCommands, List<GraphTargetItem> commands) {
super(src, lineStartIns, loop);
this.firstCommands = firstCommands;
this.expression = expression;
this.finalCommands = finalCommands;

View File

@@ -29,8 +29,8 @@ public class GotoItem extends GraphTargetItem {
public String labelName;
public GotoItem(GraphSourceItem src, String labelName) {
super(src, PRECEDENCE_PRIMARY);
public GotoItem(GraphSourceItem src, GraphSourceItem lineStartIns, String labelName) {
super(src, lineStartIns, PRECEDENCE_PRIMARY);
this.labelName = labelName;
}

View File

@@ -57,8 +57,8 @@ public class IfItem extends GraphTargetItem implements Block {
return ret;
}
public IfItem(GraphSourceItem src, GraphTargetItem expression, List<GraphTargetItem> onTrue, List<GraphTargetItem> onFalse) {
super(src, NOPRECEDENCE);
public IfItem(GraphSourceItem src, GraphSourceItem lineStartIns, GraphTargetItem expression, List<GraphTargetItem> onTrue, List<GraphTargetItem> onFalse) {
super(src, lineStartIns, NOPRECEDENCE);
this.expression = expression;
this.onTrue = onTrue;
this.onFalse = onFalse;

View File

@@ -30,8 +30,8 @@ public class IntegerValueItem extends GraphTargetItem implements IntegerValueTyp
private final int intValue;
public IntegerValueItem(GraphSourceItem src, int value) {
super(src, PRECEDENCE_PRIMARY);
public IntegerValueItem(GraphSourceItem src, GraphSourceItem lineStartIns, int value) {
super(src, lineStartIns, PRECEDENCE_PRIMARY);
this.intValue = value;
}

View File

@@ -29,8 +29,8 @@ public class LabelItem extends GraphTargetItem {
public String labelName;
public LabelItem(GraphSourceItem src, String labelName) {
super(src, PRECEDENCE_PRIMARY);
public LabelItem(GraphSourceItem src, GraphSourceItem lineStartIns, String labelName) {
super(src, lineStartIns, PRECEDENCE_PRIMARY);
this.labelName = labelName;
}

View File

@@ -24,8 +24,8 @@ public abstract class LoopItem extends GraphTargetItem {
public Loop loop;
public LoopItem(GraphSourceItem src, Loop loop) {
super(src, NOPRECEDENCE);
public LoopItem(GraphSourceItem src, GraphSourceItem lineStartItem, Loop loop) {
super(src, lineStartItem, NOPRECEDENCE);
this.loop = loop;
}
}

View File

@@ -33,8 +33,8 @@ import java.util.Set;
*/
public class NotItem extends UnaryOpItem implements LogicalOpItem, Inverted {
public NotItem(GraphSourceItem instruction, GraphTargetItem value) {
super(instruction, PRECEDENCE_UNARY, value, "!");
public NotItem(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem value) {
super(instruction, lineStartIns, PRECEDENCE_UNARY, value, "!");
}
@Override

View File

@@ -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.graph.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -26,8 +27,8 @@ import java.util.List;
public class OrItem extends BinaryOpItem {
public OrItem(GraphSourceItem src, GraphTargetItem leftSide, GraphTargetItem rightSide) {
public OrItem(GraphSourceItem src, GraphSourceItem lineStartIns, GraphTargetItem leftSide, GraphTargetItem rightSide) {
super(src, lineStartIns, PRECEDENCE_LOGICALOR, leftSide, rightSide, "||");
this.leftSide = leftSide;
this.rightSide = rightSide;
}

View File

@@ -30,8 +30,8 @@ import java.util.List;
*/
public class ParenthesisItem extends GraphTargetItem {
public ParenthesisItem(GraphSourceItem src, GraphTargetItem value) {
super(src, PRECEDENCE_PRIMARY, value);
public ParenthesisItem(GraphSourceItem src, GraphSourceItem lineStartIns, GraphTargetItem value) {
super(src, lineStartIns, PRECEDENCE_PRIMARY, value);
}
@Override

View File

@@ -28,8 +28,8 @@ import com.jpexs.decompiler.graph.TypeItem;
*/
public class PopItem extends GraphTargetItem {
public PopItem(GraphSourceItem src) {
super(src, PRECEDENCE_PRIMARY);
public PopItem(GraphSourceItem src, GraphSourceItem lineStartIns) {
super(src, lineStartIns, PRECEDENCE_PRIMARY);
}
@Override

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.graph.model;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
/**
@@ -26,7 +27,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
public class PushItem extends GraphTargetItem {
public PushItem(GraphTargetItem value) {
super(value.getSrc(), value.getPrecedence(), value);
super(value.getSrc(), value.getLineStartItem(), value.getPrecedence(), value);
}
@Override

View File

@@ -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.graph.model;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
@@ -26,7 +27,7 @@ import com.jpexs.decompiler.graph.TypeItem;
public class ScriptEndItem extends GraphTargetItem implements ExitItem {
public ScriptEndItem() {
public ScriptEndItem() {
super(null, null, NOPRECEDENCE);
}
@Override

View File

@@ -54,8 +54,8 @@ public class SwitchItem extends LoopItem implements Block {
return ret;
}
public SwitchItem(GraphSourceItem instruction, Loop loop, GraphTargetItem switchedObject, List<GraphTargetItem> caseValues, List<List<GraphTargetItem>> caseCommands, List<GraphTargetItem> defaultCommands, List<Integer> valuesMapping) {
super(instruction, loop);
public SwitchItem(GraphSourceItem instruction, GraphSourceItem lineStartIns, Loop loop, GraphTargetItem switchedObject, List<GraphTargetItem> caseValues, List<List<GraphTargetItem>> caseCommands, List<GraphTargetItem> defaultCommands, List<Integer> valuesMapping) {
super(instruction, lineStartIns, loop);
this.switchedObject = switchedObject;
this.caseValues = caseValues;
this.caseCommands = caseCommands;

View File

@@ -32,8 +32,8 @@ public class TernarOpItem extends GraphTargetItem {
public GraphTargetItem onFalse;
public TernarOpItem(GraphSourceItem src, GraphTargetItem expression, GraphTargetItem onTrue, GraphTargetItem onFalse) {
super(src, PRECEDENCE_CONDITIONAL);
public TernarOpItem(GraphSourceItem src, GraphSourceItem lineStartIns, GraphTargetItem expression, GraphTargetItem onTrue, GraphTargetItem onFalse) {
super(src, lineStartIns, PRECEDENCE_CONDITIONAL);
this.expression = expression;
this.onTrue = onTrue;
this.onFalse = onFalse;

View File

@@ -33,8 +33,8 @@ import java.util.Set;
*/
public class TrueItem extends GraphTargetItem implements LogicalOpItem, SimpleValue {
public TrueItem(GraphSourceItem src) {
super(src, PRECEDENCE_PRIMARY);
public TrueItem(GraphSourceItem src, GraphSourceItem lineStartIns) {
super(src, lineStartIns, PRECEDENCE_PRIMARY);
}
@Override
@@ -59,7 +59,7 @@ public class TrueItem extends GraphTargetItem implements LogicalOpItem, SimpleVa
@Override
public GraphTargetItem invert(GraphSourceItem neqSrc) {
return new FalseItem(null);
return new FalseItem(getSrc(), getLineStartItem());
}
@Override

View File

@@ -27,8 +27,8 @@ public abstract class UnaryOpItem extends GraphTargetItem implements UnaryOp {
public String operator;
public UnaryOpItem(GraphSourceItem instruction, int precedence, GraphTargetItem value, String operator) {
super(instruction, precedence, value);
public UnaryOpItem(GraphSourceItem instruction, GraphSourceItem lineStartItem, int precedence, GraphTargetItem value, String operator) {
super(instruction, lineStartItem, precedence, value);
this.operator = operator;
}

View File

@@ -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.graph.model;
import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item;
@@ -26,7 +27,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
public class UnboundedTypeItem extends AVM2Item {
public UnboundedTypeItem() {
public UnboundedTypeItem() {
super(null, null, NOPRECEDENCE);
}
@Override

View File

@@ -37,8 +37,8 @@ public class UniversalLoopItem extends LoopItem implements Block {
private boolean labelUsed;
public UniversalLoopItem(GraphSourceItem src, Loop loop) {
super(src, loop);
public UniversalLoopItem(GraphSourceItem src, GraphSourceItem lineStartIns, Loop loop) {
super(src, lineStartIns, loop);
}
@Override

View File

@@ -47,8 +47,8 @@ public class WhileItem extends LoopItem implements Block {
return ret;
}
public WhileItem(GraphSourceItem src, Loop loop, List<GraphTargetItem> expression, List<GraphTargetItem> commands) {
super(src, loop);
public WhileItem(GraphSourceItem src, GraphSourceItem lineStartIns, Loop loop, List<GraphTargetItem> expression, List<GraphTargetItem> commands) {
super(src, lineStartIns, loop);
this.expression = expression;
this.commands = commands;
}