mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-27 00:00:59 +00:00
Issue #302 AS3 goto local variable declaration
Ant upload release/nightly task
This commit is contained in:
@@ -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.helpers;
|
||||
|
||||
import com.jpexs.helpers.utf8.Utf8OutputStreamWriter;
|
||||
@@ -20,6 +21,7 @@ import java.io.BufferedWriter;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -58,6 +60,14 @@ public class FileTextWriter extends GraphTextWriter implements AutoCloseable {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendWithData(String str, Map<String, String> data) {
|
||||
writeToFile(str);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public FileTextWriter append(String str, long offset) {
|
||||
writeToFile(str);
|
||||
|
||||
+4
-1
@@ -12,10 +12,12 @@
|
||||
* 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.helpers;
|
||||
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Provides methods for highlighting positions of instructions in the text.
|
||||
@@ -26,5 +28,6 @@ public class GraphSourceItemPosition {
|
||||
|
||||
public GraphSourceItem graphSourceItem;
|
||||
public int position;
|
||||
public Map<String,String> data;
|
||||
|
||||
}
|
||||
|
||||
@@ -12,10 +12,13 @@
|
||||
* 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.helpers;
|
||||
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Provides methods for highlighting positions of instructions in the text.
|
||||
@@ -46,9 +49,10 @@ public abstract class GraphTextWriter {
|
||||
*
|
||||
* @param src
|
||||
* @param pos Offset of instruction
|
||||
* @param data
|
||||
* @return GraphTextWriter
|
||||
*/
|
||||
public GraphTextWriter startOffset(GraphSourceItem src, int pos) {
|
||||
public GraphTextWriter startOffset(GraphSourceItem src, int pos, Map<String,String> data) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -99,10 +103,14 @@ public abstract class GraphTextWriter {
|
||||
}
|
||||
|
||||
public GraphTextWriter hilightSpecial(String text, String type) {
|
||||
return this;
|
||||
return hilightSpecial(text, type, 0);
|
||||
}
|
||||
|
||||
public GraphTextWriter hilightSpecial(String text, String type, int index) {
|
||||
return hilightSpecial(text, type, 0, new HashMap<String, String>());
|
||||
}
|
||||
|
||||
public GraphTextWriter hilightSpecial(String text, String type, int index, Map<String,String> data) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -110,6 +118,8 @@ public abstract class GraphTextWriter {
|
||||
return "";
|
||||
}
|
||||
|
||||
public abstract GraphTextWriter appendWithData(String str, Map<String,String> data);
|
||||
|
||||
public abstract GraphTextWriter append(String str);
|
||||
|
||||
public abstract GraphTextWriter append(String str, long offset);
|
||||
|
||||
@@ -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.helpers;
|
||||
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
@@ -68,13 +69,15 @@ public class HilightedTextWriter extends GraphTextWriter {
|
||||
*
|
||||
* @param src
|
||||
* @param pos Offset of instruction
|
||||
* @param data
|
||||
* @return HilightedTextWriter
|
||||
*/
|
||||
@Override
|
||||
public HilightedTextWriter startOffset(GraphSourceItem src, int pos) {
|
||||
public HilightedTextWriter startOffset(GraphSourceItem src, int pos, Map<String,String> data) {
|
||||
GraphSourceItemPosition itemPos = new GraphSourceItemPosition();
|
||||
itemPos.graphSourceItem = src;
|
||||
itemPos.position = pos;
|
||||
itemPos.data = data;
|
||||
offsets.add(itemPos);
|
||||
return this;
|
||||
}
|
||||
@@ -146,25 +149,42 @@ public class HilightedTextWriter extends GraphTextWriter {
|
||||
|
||||
@Override
|
||||
public HilightedTextWriter hilightSpecial(String text, String type, int index) {
|
||||
Map<String, String> data = new HashMap<>();
|
||||
data.put("subtype", type);
|
||||
data.put("index", Long.toString(index));
|
||||
start(data, HilightType.SPECIAL);
|
||||
return hilightSpecial(text, type, index, new HashMap<String, String>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public HilightedTextWriter hilightSpecial(String text, String type, int index, Map<String, String> data) {
|
||||
Map<String, String> ndata = new HashMap<>();
|
||||
ndata.putAll(data);
|
||||
ndata.put("subtype", type);
|
||||
ndata.put("index", Long.toString(index));
|
||||
start(ndata, HilightType.SPECIAL);
|
||||
appendNoHilight(text);
|
||||
return end(HilightType.SPECIAL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public HilightedTextWriter append(String str) {
|
||||
return appendWithData(str, new HashMap<String, String>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public HilightedTextWriter appendWithData(String str, Map<String,String> data) {
|
||||
Highlighting h = null;
|
||||
if (!offsets.empty()) {
|
||||
GraphSourceItemPosition itemPos = offsets.peek();
|
||||
GraphSourceItem src = itemPos.graphSourceItem;
|
||||
int pos = itemPos.position;
|
||||
if (src != null && hilight) {
|
||||
Map<String, String> data = new HashMap<>();
|
||||
data.put("offset", Long.toString(src.getOffset() + pos + 1));
|
||||
h = new Highlighting(sb.length() - newLineCount, data, HilightType.OFFSET, str);
|
||||
Map<String,String> ndata=new HashMap<>();
|
||||
ndata.putAll(itemPos.data);
|
||||
ndata.putAll(data);
|
||||
ndata.put("offset", Long.toString(src.getOffset() + pos + 1));
|
||||
h = new Highlighting(sb.length() - newLineCount, ndata, HilightType.OFFSET, str);
|
||||
instructionHilights.add(h);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,9 +12,11 @@
|
||||
* 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.helpers;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Stack;
|
||||
|
||||
/**
|
||||
@@ -102,12 +104,28 @@ public class NulWriter extends GraphTextWriter {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NulWriter hilightSpecial(String text, String type, int index, Map<String, String> data) {
|
||||
stringAdded = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public NulWriter append(String str) {
|
||||
stringAdded = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendWithData(String str, Map<String, String> data) {
|
||||
stringAdded = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public NulWriter append(String str, long offset) {
|
||||
stringAdded = true;
|
||||
|
||||
@@ -12,12 +12,15 @@
|
||||
* 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.helpers.hilight;
|
||||
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.helpers.HilightType;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -52,6 +55,12 @@ public class Highlighting implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, String> getProperties() {
|
||||
return new HashMap<>(properties);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getPropertyString(String key) {
|
||||
return properties.get(key);
|
||||
}
|
||||
@@ -63,23 +72,39 @@ public class Highlighting implements Serializable {
|
||||
public static Highlighting search(List<Highlighting> list, String property, String value) {
|
||||
return search(list, -1, property, value, -1, -1);
|
||||
}
|
||||
|
||||
public static Highlighting search(List<Highlighting> list, Map<String,String> properties) {
|
||||
return search(list, -1, properties, -1, -1);
|
||||
}
|
||||
|
||||
public static Highlighting search(List<Highlighting> list, String property, String value, int from, int to) {
|
||||
return search(list, -1, property, value, from, to);
|
||||
}
|
||||
|
||||
|
||||
public static Highlighting search(List<Highlighting> list, Map<String,String> properties, int from, int to) {
|
||||
return search(list, -1, properties, from, to);
|
||||
}
|
||||
|
||||
public static Highlighting search(List<Highlighting> list, long pos, String property, String value, long from, long to) {
|
||||
Map<String,String> map= new HashMap<>();
|
||||
map.put(property, value);
|
||||
return search(list, pos, map, from, to);
|
||||
}
|
||||
public static Highlighting search(List<Highlighting> list, long pos, Map<String,String> properties, long from, long to) {
|
||||
Highlighting ret = null;
|
||||
for (Highlighting h : list) {
|
||||
if (property != null) {
|
||||
String v = h.getPropertyString(property);
|
||||
if (v == null) {
|
||||
if (value != null) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (!v.equals(value)) {
|
||||
continue;
|
||||
looph:for (Highlighting h : list) {
|
||||
for(String property:properties.keySet()){
|
||||
if (property != null) {
|
||||
String v = h.getPropertyString(property);
|
||||
String value = properties.get(property);
|
||||
if (v == null) {
|
||||
if (value != null) {
|
||||
continue looph;
|
||||
}
|
||||
} else {
|
||||
if (!v.equals(value)) {
|
||||
continue looph;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -112,6 +137,44 @@ public class Highlighting implements Serializable {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static List<Highlighting> searchAll(List<Highlighting> list, long pos, String property, String value, long from, long to) {
|
||||
List<Highlighting> ret = new ArrayList<>();
|
||||
for (Highlighting h : list) {
|
||||
if (property != null) {
|
||||
String v = h.getPropertyString(property);
|
||||
if (v == null) {
|
||||
if (value != null) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (!v.equals(value)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (from > -1) {
|
||||
if (h.startPos < from) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (to > -1) {
|
||||
if (h.startPos > to) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (pos == -1 ||(pos >= h.startPos && (pos < h.startPos + h.len))) {
|
||||
//if (ret == null || h.startPos > ret.startPos) { //get the closest one
|
||||
ret.add(h);
|
||||
//}
|
||||
}
|
||||
//if (pos == -1) {
|
||||
// return ret;
|
||||
//}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the object
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user