small fixes/improvements

This commit is contained in:
honfika@gmail.com
2015-07-09 16:42:42 +02:00
parent d9e358d536
commit cc8bf6fb7a
56 changed files with 225 additions and 213 deletions

View File

@@ -72,8 +72,6 @@ public abstract class GraphTargetItem implements Serializable, Cloneable {
private GraphSourceItem src;
public int pos = -1;
protected int precedence;
private List<GraphSourceItemPos> moreSrc;
@@ -118,6 +116,12 @@ public abstract class GraphTargetItem implements Serializable, Cloneable {
this.precedence = precedence;
}
public GraphTargetItem(GraphSourceItem src, int precedence, GraphTargetItem value) {
this.src = src;
this.precedence = precedence;
this.value = value;
}
public GraphSourceItem getSrc() {
return src;
}
@@ -138,9 +142,13 @@ public abstract class GraphTargetItem implements Serializable, Cloneable {
return srcData;
}
protected int getPos() {
return 0;
}
public List<GraphSourceItemPos> getNeededSources() {
List<GraphSourceItemPos> ret = new ArrayList<>();
ret.add(new GraphSourceItemPos(src, pos));
ret.add(new GraphSourceItemPos(src, getPos()));
if (moreSrc != null) {
ret.addAll(moreSrc);
}
@@ -153,7 +161,7 @@ public abstract class GraphTargetItem implements Serializable, Cloneable {
}
public GraphTextWriter toStringSemicoloned(GraphTextWriter writer, LocalData localData) throws InterruptedException {
writer.startOffset(src, pos, srcData);
writer.startOffset(src, getPos(), srcData);
appendTo(writer, localData);
if (needsSemicolon()) {
writer.appendNoHilight(";");
@@ -176,7 +184,7 @@ public abstract class GraphTargetItem implements Serializable, Cloneable {
throw new InterruptedException();
}
writer.startOffset(src, pos, srcData);
writer.startOffset(src, getPos(), srcData);
appendTo(writer, localData);
writer.endOffset();
return writer;
@@ -221,7 +229,7 @@ public abstract class GraphTargetItem implements Serializable, Cloneable {
}
public GraphTextWriter toStringNoQuotes(GraphTextWriter writer, LocalData localData) throws InterruptedException {
writer.startOffset(src, pos, srcData);
writer.startOffset(src, getPos(), srcData);
appendToNoQuotes(writer, localData);
writer.endOffset();
return writer;
@@ -244,7 +252,7 @@ public abstract class GraphTargetItem implements Serializable, Cloneable {
}
public GraphTextWriter toStringNL(GraphTextWriter writer, LocalData localData) throws InterruptedException {
writer.startOffset(src, pos, srcData);
writer.startOffset(src, getPos(), srcData);
appendTo(writer, localData);
if (needsNewLine()) {
writer.newLine();

View File

@@ -27,7 +27,7 @@ import java.util.logging.Logger;
*/
public class TranslateStack extends Stack<GraphTargetItem> {
private static PopItem pop = new PopItem(null);
private static PopItem pop;
private final String path;
@@ -39,12 +39,20 @@ public class TranslateStack extends Stack<GraphTargetItem> {
return path;
}
private PopItem getPop() {
if (pop == null) {
pop = new PopItem(null);
}
return pop;
}
@Override
public synchronized GraphTargetItem get(int index) {
if (path != null) {
if (index >= this.size() || index < 0) {
Logger.getLogger(TranslateStack.class.getName()).log(Level.FINE, "{0}: Attemp to Get item outside of bounds of stack", path);
return pop;
return getPop();
}
}
return super.get(index);
@@ -55,7 +63,7 @@ public class TranslateStack extends Stack<GraphTargetItem> {
if (path != null) {
if (this.isEmpty()) {
Logger.getLogger(TranslateStack.class.getName()).log(Level.FINE, "{0}: Attemp to Peek empty stack", path);
return pop;
return getPop();
}
}
return super.peek();
@@ -65,8 +73,8 @@ public class TranslateStack extends Stack<GraphTargetItem> {
public synchronized GraphTargetItem pop() {
if (path != null) {
if (this.isEmpty()) {
PopItem oldpop = pop;
pop = new PopItem(null);
PopItem oldpop = getPop();
pop = null;
Logger.getLogger(TranslateStack.class.getName()).log(Level.FINE, "{0}: Attemp to Pop empty stack", path);
return oldpop;
}

View File

@@ -34,8 +34,7 @@ import java.util.Set;
public class DuplicateItem extends GraphTargetItem implements SimpleValue {
public DuplicateItem(GraphSourceItem src, GraphTargetItem value) {
super(src, value.getPrecedence());
this.value = value;
super(src, value.getPrecedence(), value);
}
@Override

View File

@@ -1,18 +1,19 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
*
* This library 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
* 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;
@@ -30,8 +31,7 @@ import java.util.List;
public class ParenthesisItem extends GraphTargetItem {
public ParenthesisItem(GraphSourceItem src, GraphTargetItem value) {
public ParenthesisItem(GraphSourceItem src, GraphTargetItem value) {
super(src, PRECEDENCE_PRIMARY);
super(src, PRECEDENCE_PRIMARY, value);
}
@Override

View File

@@ -25,9 +25,8 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
*/
public class PushItem extends GraphTargetItem {
public PushItem(GraphTargetItem val) {
super(val.getSrc(), val.getPrecedence());
this.value = val;
public PushItem(GraphTargetItem value) {
super(value.getSrc(), value.getPrecedence(), value);
}
@Override

View File

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