diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/AVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/AVM2Item.java
index a56d7ba59..313f210d5 100644
--- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/AVM2Item.java
+++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/AVM2Item.java
@@ -39,14 +39,6 @@ public abstract class AVM2Item extends GraphTargetItem {
return writer.toString();
}
- public HilightedTextWriter toStringSemicoloned(HilightedTextWriter writer, LocalData localData) {
- toString(writer, localData);
- if (needsSemicolon()) {
- hilight(";", writer);
- }
- return writer;
- }
-
@Override
public boolean needsSemicolon() {
return true;
diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java
index dfae5fbfd..51e671d0c 100644
--- a/trunk/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java
+++ b/trunk/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java
@@ -87,7 +87,7 @@ public class DirectValueActionItem extends ActionItem {
}
@Override
- public HilightedTextWriter toStringNoQuotes(HilightedTextWriter writer, LocalData localData) {
+ protected HilightedTextWriter appendToNoQuotes(HilightedTextWriter writer, LocalData localData) {
if (value instanceof Double) {
if (Double.compare((double) (Double) value, 0) == 0) {
return hilight("0", writer);
diff --git a/trunk/src/com/jpexs/decompiler/flash/helpers/GraphSourceItemPosition.java b/trunk/src/com/jpexs/decompiler/flash/helpers/GraphSourceItemPosition.java
new file mode 100644
index 000000000..3b2c0563d
--- /dev/null
+++ b/trunk/src/com/jpexs/decompiler/flash/helpers/GraphSourceItemPosition.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2010-2013 JPEXS
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package com.jpexs.decompiler.flash.helpers;
+
+import com.jpexs.decompiler.graph.GraphSourceItem;
+
+/**
+ * Provides methods for highlighting positions of instructions in the text.
+ *
+ * @author JPEXS
+ */
+public class GraphSourceItemPosition {
+
+ public GraphSourceItem graphSourceItem;
+ public int position;
+
+}
diff --git a/trunk/src/com/jpexs/decompiler/flash/helpers/HilightedTextWriter.java b/trunk/src/com/jpexs/decompiler/flash/helpers/HilightedTextWriter.java
index ef510459b..ea13a2f63 100644
--- a/trunk/src/com/jpexs/decompiler/flash/helpers/HilightedTextWriter.java
+++ b/trunk/src/com/jpexs/decompiler/flash/helpers/HilightedTextWriter.java
@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.helpers;
import com.jpexs.decompiler.flash.helpers.hilight.Highlighting;
import com.jpexs.decompiler.graph.GraphSourceItem;
+import java.util.Stack;
/**
* Provides methods for highlighting positions of instructions in the text.
@@ -28,6 +29,7 @@ public class HilightedTextWriter {
private StringBuilder sb = new StringBuilder();
private boolean hilight;
+ private Stack offsets = new Stack<>();
public HilightedTextWriter() {
}
@@ -39,8 +41,25 @@ public class HilightedTextWriter {
public boolean getIsHighlighted() {
return hilight;
}
+
+ public void addOffset(GraphSourceItem src, int pos) {
+ GraphSourceItemPosition itemPos = new GraphSourceItemPosition();
+ itemPos.graphSourceItem = src;
+ itemPos.position = pos;
+ offsets.add(itemPos);
+ }
- public HilightedTextWriter append(String str, GraphSourceItem src, int pos) {
+ public void removeOffset() {
+ offsets.pop();
+ }
+
+ public HilightedTextWriter append(String str) {
+ if (offsets.isEmpty()) {
+ System.out.println("WTF?");
+ }
+ GraphSourceItemPosition itemPos = offsets.peek();
+ GraphSourceItem src = itemPos.graphSourceItem;
+ int pos = itemPos.position;
if (src != null && hilight) {
sb.append(Highlighting.hilighOffset(str, src.getOffset() + pos + 1));
} else {
diff --git a/trunk/src/com/jpexs/decompiler/graph/GraphTargetItem.java b/trunk/src/com/jpexs/decompiler/graph/GraphTargetItem.java
index a82b85d7f..f7a597433 100644
--- a/trunk/src/com/jpexs/decompiler/graph/GraphTargetItem.java
+++ b/trunk/src/com/jpexs/decompiler/graph/GraphTargetItem.java
@@ -84,14 +84,16 @@ public abstract class GraphTargetItem implements Serializable {
}
public HilightedTextWriter hilight(String str, HilightedTextWriter writer) {
- return writer.append(str, src, pos);
+ return writer.append(str);
}
public HilightedTextWriter toStringSemicoloned(HilightedTextWriter writer, LocalData localData) {
- toString(writer, localData);
+ writer.addOffset(src, pos);
+ appendTo(writer, localData);
if (needsSemicolon()) {
hilight(";", writer);
}
+ writer.removeOffset();
return writer;
}
@@ -105,7 +107,10 @@ public abstract class GraphTargetItem implements Serializable {
}
public HilightedTextWriter toString(HilightedTextWriter writer, LocalData localData) {
- return appendTo(writer, localData);
+ writer.addOffset(src, pos);
+ appendTo(writer, localData);
+ writer.removeOffset();
+ return writer;
}
protected abstract HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData);
@@ -150,6 +155,13 @@ public abstract class GraphTargetItem implements Serializable {
}
public HilightedTextWriter toStringNoQuotes(HilightedTextWriter writer, LocalData localData) {
+ writer.addOffset(src, pos);
+ appendToNoQuotes(writer, localData);
+ writer.removeOffset();
+ return writer;
+ }
+
+ protected HilightedTextWriter appendToNoQuotes(HilightedTextWriter writer, LocalData localData) {
return toString(writer, localData);
}
@@ -166,10 +178,12 @@ public abstract class GraphTargetItem implements Serializable {
}
public HilightedTextWriter toStringNL(HilightedTextWriter writer, LocalData localData) {
- toString(writer, localData);
+ writer.addOffset(src, pos);
+ appendTo(writer, localData);
if (needsNewLine()) {
writer.appendNewLine();
}
+ writer.removeOffset();
return writer;
}