mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2025-01-08 07:54:11 -08:00
Rename InstructionLocation to TextLocation. Replace NodeLocation by TextLocation
This commit is contained in:
parent
3dd76c9355
commit
1be9ffb19e
|
@ -17,15 +17,12 @@ package org.teavm.ast;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import org.teavm.model.TextLocation;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Alexey Andreev
|
|
||||||
*/
|
|
||||||
public class AssignmentStatement extends Statement {
|
public class AssignmentStatement extends Statement {
|
||||||
private Expr leftValue;
|
private Expr leftValue;
|
||||||
private Expr rightValue;
|
private Expr rightValue;
|
||||||
private NodeLocation location;
|
private TextLocation location;
|
||||||
private Set<String> debugNames = new HashSet<>();
|
private Set<String> debugNames = new HashSet<>();
|
||||||
private boolean async;
|
private boolean async;
|
||||||
|
|
||||||
|
@ -45,11 +42,11 @@ public class AssignmentStatement extends Statement {
|
||||||
this.rightValue = rightValue;
|
this.rightValue = rightValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NodeLocation getLocation() {
|
public TextLocation getLocation() {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLocation(NodeLocation location) {
|
public void setLocation(TextLocation location) {
|
||||||
this.location = location;
|
this.location = location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,9 +15,11 @@
|
||||||
*/
|
*/
|
||||||
package org.teavm.ast;
|
package org.teavm.ast;
|
||||||
|
|
||||||
|
import org.teavm.model.TextLocation;
|
||||||
|
|
||||||
public class BreakStatement extends Statement {
|
public class BreakStatement extends Statement {
|
||||||
private IdentifiedStatement target;
|
private IdentifiedStatement target;
|
||||||
private NodeLocation location;
|
private TextLocation location;
|
||||||
|
|
||||||
public IdentifiedStatement getTarget() {
|
public IdentifiedStatement getTarget() {
|
||||||
return target;
|
return target;
|
||||||
|
@ -27,11 +29,11 @@ public class BreakStatement extends Statement {
|
||||||
this.target = target;
|
this.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NodeLocation getLocation() {
|
public TextLocation getLocation() {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLocation(NodeLocation location) {
|
public void setLocation(TextLocation location) {
|
||||||
this.location = location;
|
this.location = location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,11 @@
|
||||||
*/
|
*/
|
||||||
package org.teavm.ast;
|
package org.teavm.ast;
|
||||||
|
|
||||||
/**
|
import org.teavm.model.TextLocation;
|
||||||
*
|
|
||||||
* @author Alexey Andreev
|
|
||||||
*/
|
|
||||||
public class ContinueStatement extends Statement {
|
public class ContinueStatement extends Statement {
|
||||||
private IdentifiedStatement target;
|
private IdentifiedStatement target;
|
||||||
private NodeLocation location;
|
private TextLocation location;
|
||||||
|
|
||||||
public IdentifiedStatement getTarget() {
|
public IdentifiedStatement getTarget() {
|
||||||
return target;
|
return target;
|
||||||
|
@ -31,11 +29,11 @@ public class ContinueStatement extends Statement {
|
||||||
this.target = target;
|
this.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NodeLocation getLocation() {
|
public TextLocation getLocation() {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLocation(NodeLocation location) {
|
public void setLocation(TextLocation location) {
|
||||||
this.location = location;
|
this.location = location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ import java.util.Map;
|
||||||
import org.teavm.model.*;
|
import org.teavm.model.*;
|
||||||
|
|
||||||
public abstract class Expr implements Cloneable {
|
public abstract class Expr implements Cloneable {
|
||||||
private NodeLocation location;
|
private TextLocation location;
|
||||||
|
|
||||||
public abstract void acceptVisitor(ExprVisitor visitor);
|
public abstract void acceptVisitor(ExprVisitor visitor);
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ public abstract class Expr implements Cloneable {
|
||||||
return expr;
|
return expr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Expr binary(BinaryOperation op, OperationType type, Expr first, Expr second, NodeLocation loc) {
|
public static Expr binary(BinaryOperation op, OperationType type, Expr first, Expr second, TextLocation loc) {
|
||||||
Expr expr = binary(op, type, first, second);
|
Expr expr = binary(op, type, first, second);
|
||||||
expr.setLocation(loc);
|
expr.setLocation(loc);
|
||||||
return expr;
|
return expr;
|
||||||
|
@ -151,11 +151,11 @@ public abstract class Expr implements Cloneable {
|
||||||
return expr;
|
return expr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NodeLocation getLocation() {
|
public TextLocation getLocation() {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLocation(NodeLocation location) {
|
public void setLocation(TextLocation location) {
|
||||||
this.location = location;
|
this.location = location;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,12 +15,10 @@
|
||||||
*/
|
*/
|
||||||
package org.teavm.ast;
|
package org.teavm.ast;
|
||||||
|
|
||||||
/**
|
import org.teavm.model.TextLocation;
|
||||||
*
|
|
||||||
* @author Alexey Andreev
|
|
||||||
*/
|
|
||||||
public class InitClassStatement extends Statement {
|
public class InitClassStatement extends Statement {
|
||||||
private NodeLocation location;
|
private TextLocation location;
|
||||||
private String className;
|
private String className;
|
||||||
|
|
||||||
public String getClassName() {
|
public String getClassName() {
|
||||||
|
@ -31,11 +29,11 @@ public class InitClassStatement extends Statement {
|
||||||
this.className = className;
|
this.className = className;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NodeLocation getLocation() {
|
public TextLocation getLocation() {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLocation(NodeLocation location) {
|
public void setLocation(TextLocation location) {
|
||||||
this.location = location;
|
this.location = location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,12 +15,10 @@
|
||||||
*/
|
*/
|
||||||
package org.teavm.ast;
|
package org.teavm.ast;
|
||||||
|
|
||||||
/**
|
import org.teavm.model.TextLocation;
|
||||||
*
|
|
||||||
* @author shannah
|
|
||||||
*/
|
|
||||||
public class MonitorEnterStatement extends Statement {
|
public class MonitorEnterStatement extends Statement {
|
||||||
private NodeLocation location;
|
private TextLocation location;
|
||||||
private Expr objectRef;
|
private Expr objectRef;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -28,11 +26,11 @@ public class MonitorEnterStatement extends Statement {
|
||||||
visitor.visit(this);
|
visitor.visit(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public NodeLocation getLocation() {
|
public TextLocation getLocation() {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLocation(NodeLocation location) {
|
public void setLocation(TextLocation location) {
|
||||||
this.location = location;
|
this.location = location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,12 +15,10 @@
|
||||||
*/
|
*/
|
||||||
package org.teavm.ast;
|
package org.teavm.ast;
|
||||||
|
|
||||||
/**
|
import org.teavm.model.TextLocation;
|
||||||
*
|
|
||||||
* @author shannah
|
|
||||||
*/
|
|
||||||
public class MonitorExitStatement extends Statement {
|
public class MonitorExitStatement extends Statement {
|
||||||
private NodeLocation location;
|
private TextLocation location;
|
||||||
private Expr objectRef;
|
private Expr objectRef;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -28,11 +26,11 @@ public class MonitorExitStatement extends Statement {
|
||||||
visitor.visit(this);
|
visitor.visit(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public NodeLocation getLocation() {
|
public TextLocation getLocation() {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLocation(NodeLocation location) {
|
public void setLocation(TextLocation location) {
|
||||||
this.location = location;
|
this.location = location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2016 Alexey Andreev.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.teavm.ast;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Alexey Andreev
|
|
||||||
*/
|
|
||||||
public class NodeLocation {
|
|
||||||
private String fileName;
|
|
||||||
private int line;
|
|
||||||
|
|
||||||
public NodeLocation(String fileName, int line) {
|
|
||||||
this.fileName = fileName;
|
|
||||||
this.line = line;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFileName() {
|
|
||||||
return fileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLine() {
|
|
||||||
return line;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -15,13 +15,11 @@
|
||||||
*/
|
*/
|
||||||
package org.teavm.ast;
|
package org.teavm.ast;
|
||||||
|
|
||||||
/**
|
import org.teavm.model.TextLocation;
|
||||||
*
|
|
||||||
* @author Alexey Andreev
|
|
||||||
*/
|
|
||||||
public class ReturnStatement extends Statement {
|
public class ReturnStatement extends Statement {
|
||||||
private Expr result;
|
private Expr result;
|
||||||
private NodeLocation location;
|
private TextLocation location;
|
||||||
|
|
||||||
public Expr getResult() {
|
public Expr getResult() {
|
||||||
return result;
|
return result;
|
||||||
|
@ -31,11 +29,11 @@ public class ReturnStatement extends Statement {
|
||||||
this.result = result;
|
this.result = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NodeLocation getLocation() {
|
public TextLocation getLocation() {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLocation(NodeLocation location) {
|
public void setLocation(TextLocation location) {
|
||||||
this.location = location;
|
this.location = location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,6 @@ package org.teavm.ast;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Alexey Andreev
|
|
||||||
*/
|
|
||||||
public abstract class Statement {
|
public abstract class Statement {
|
||||||
public abstract void acceptVisitor(StatementVisitor visitor);
|
public abstract void acceptVisitor(StatementVisitor visitor);
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,11 @@
|
||||||
*/
|
*/
|
||||||
package org.teavm.ast;
|
package org.teavm.ast;
|
||||||
|
|
||||||
/**
|
import org.teavm.model.TextLocation;
|
||||||
*
|
|
||||||
* @author Alexey Andreev
|
|
||||||
*/
|
|
||||||
public class ThrowStatement extends Statement {
|
public class ThrowStatement extends Statement {
|
||||||
private Expr exception;
|
private Expr exception;
|
||||||
private NodeLocation location;
|
private TextLocation location;
|
||||||
|
|
||||||
public Expr getException() {
|
public Expr getException() {
|
||||||
return exception;
|
return exception;
|
||||||
|
@ -31,11 +29,11 @@ public class ThrowStatement extends Statement {
|
||||||
this.exception = exception;
|
this.exception = exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NodeLocation getLocation() {
|
public TextLocation getLocation() {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLocation(NodeLocation location) {
|
public void setLocation(TextLocation location) {
|
||||||
this.location = location;
|
this.location = location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,6 @@ import org.teavm.ast.GotoPartStatement;
|
||||||
import org.teavm.ast.IdentifiedStatement;
|
import org.teavm.ast.IdentifiedStatement;
|
||||||
import org.teavm.ast.MethodNode;
|
import org.teavm.ast.MethodNode;
|
||||||
import org.teavm.ast.NativeMethodNode;
|
import org.teavm.ast.NativeMethodNode;
|
||||||
import org.teavm.ast.NodeLocation;
|
|
||||||
import org.teavm.ast.NodeModifier;
|
import org.teavm.ast.NodeModifier;
|
||||||
import org.teavm.ast.RegularMethodNode;
|
import org.teavm.ast.RegularMethodNode;
|
||||||
import org.teavm.ast.SequentialStatement;
|
import org.teavm.ast.SequentialStatement;
|
||||||
|
@ -62,7 +61,7 @@ import org.teavm.model.ClassHolderSource;
|
||||||
import org.teavm.model.ElementModifier;
|
import org.teavm.model.ElementModifier;
|
||||||
import org.teavm.model.FieldHolder;
|
import org.teavm.model.FieldHolder;
|
||||||
import org.teavm.model.Instruction;
|
import org.teavm.model.Instruction;
|
||||||
import org.teavm.model.InstructionLocation;
|
import org.teavm.model.TextLocation;
|
||||||
import org.teavm.model.MethodHolder;
|
import org.teavm.model.MethodHolder;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
import org.teavm.model.Program;
|
import org.teavm.model.Program;
|
||||||
|
@ -456,17 +455,15 @@ public class Decompiler {
|
||||||
|
|
||||||
if (node >= 0) {
|
if (node >= 0) {
|
||||||
generator.statements.clear();
|
generator.statements.clear();
|
||||||
InstructionLocation lastLocation = null;
|
TextLocation lastLocation = null;
|
||||||
NodeLocation nodeLocation = null;
|
|
||||||
List<Instruction> instructions = generator.currentBlock.getInstructions();
|
List<Instruction> instructions = generator.currentBlock.getInstructions();
|
||||||
for (int j = 0; j < instructions.size(); ++j) {
|
for (int j = 0; j < instructions.size(); ++j) {
|
||||||
Instruction insn = generator.currentBlock.getInstructions().get(j);
|
Instruction insn = generator.currentBlock.getInstructions().get(j);
|
||||||
if (insn.getLocation() != null && lastLocation != insn.getLocation()) {
|
if (insn.getLocation() != null && lastLocation != insn.getLocation()) {
|
||||||
lastLocation = insn.getLocation();
|
lastLocation = insn.getLocation();
|
||||||
nodeLocation = new NodeLocation(lastLocation.getFileName(), lastLocation.getLine());
|
|
||||||
}
|
}
|
||||||
if (insn.getLocation() != null) {
|
if (insn.getLocation() != null) {
|
||||||
generator.setCurrentLocation(nodeLocation);
|
generator.setCurrentLocation(lastLocation);
|
||||||
}
|
}
|
||||||
insn.acceptVisitor(generator);
|
insn.acceptVisitor(generator);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,6 @@ import org.teavm.ast.InitClassStatement;
|
||||||
import org.teavm.ast.InvocationExpr;
|
import org.teavm.ast.InvocationExpr;
|
||||||
import org.teavm.ast.MonitorEnterStatement;
|
import org.teavm.ast.MonitorEnterStatement;
|
||||||
import org.teavm.ast.MonitorExitStatement;
|
import org.teavm.ast.MonitorExitStatement;
|
||||||
import org.teavm.ast.NodeLocation;
|
|
||||||
import org.teavm.ast.OperationType;
|
import org.teavm.ast.OperationType;
|
||||||
import org.teavm.ast.PrimitiveCastExpr;
|
import org.teavm.ast.PrimitiveCastExpr;
|
||||||
import org.teavm.ast.ReturnStatement;
|
import org.teavm.ast.ReturnStatement;
|
||||||
|
@ -48,6 +47,7 @@ import org.teavm.model.InvokeDynamicInstruction;
|
||||||
import org.teavm.model.MethodDescriptor;
|
import org.teavm.model.MethodDescriptor;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
import org.teavm.model.Program;
|
import org.teavm.model.Program;
|
||||||
|
import org.teavm.model.TextLocation;
|
||||||
import org.teavm.model.ValueType;
|
import org.teavm.model.ValueType;
|
||||||
import org.teavm.model.Variable;
|
import org.teavm.model.Variable;
|
||||||
import org.teavm.model.instructions.ArrayElementType;
|
import org.teavm.model.instructions.ArrayElementType;
|
||||||
|
@ -101,10 +101,10 @@ class StatementGenerator implements InstructionVisitor {
|
||||||
Decompiler.Block[] blockMap;
|
Decompiler.Block[] blockMap;
|
||||||
Program program;
|
Program program;
|
||||||
ClassHolderSource classSource;
|
ClassHolderSource classSource;
|
||||||
private NodeLocation currentLocation;
|
private TextLocation currentLocation;
|
||||||
boolean async;
|
boolean async;
|
||||||
|
|
||||||
void setCurrentLocation(NodeLocation currentLocation) {
|
void setCurrentLocation(TextLocation currentLocation) {
|
||||||
this.currentLocation = currentLocation;
|
this.currentLocation = currentLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
10
core/src/main/java/org/teavm/cache/AstIO.java
vendored
10
core/src/main/java/org/teavm/cache/AstIO.java
vendored
|
@ -51,7 +51,6 @@ import org.teavm.ast.MonitorExitStatement;
|
||||||
import org.teavm.ast.NewArrayExpr;
|
import org.teavm.ast.NewArrayExpr;
|
||||||
import org.teavm.ast.NewExpr;
|
import org.teavm.ast.NewExpr;
|
||||||
import org.teavm.ast.NewMultiArrayExpr;
|
import org.teavm.ast.NewMultiArrayExpr;
|
||||||
import org.teavm.ast.NodeLocation;
|
|
||||||
import org.teavm.ast.NodeModifier;
|
import org.teavm.ast.NodeModifier;
|
||||||
import org.teavm.ast.OperationType;
|
import org.teavm.ast.OperationType;
|
||||||
import org.teavm.ast.PrimitiveCastExpr;
|
import org.teavm.ast.PrimitiveCastExpr;
|
||||||
|
@ -75,6 +74,7 @@ import org.teavm.ast.WhileStatement;
|
||||||
import org.teavm.model.FieldReference;
|
import org.teavm.model.FieldReference;
|
||||||
import org.teavm.model.MethodDescriptor;
|
import org.teavm.model.MethodDescriptor;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
|
import org.teavm.model.TextLocation;
|
||||||
import org.teavm.model.ValueType;
|
import org.teavm.model.ValueType;
|
||||||
import org.teavm.model.instructions.ArrayElementType;
|
import org.teavm.model.instructions.ArrayElementType;
|
||||||
import org.teavm.model.util.VariableType;
|
import org.teavm.model.util.VariableType;
|
||||||
|
@ -227,7 +227,7 @@ public class AstIO {
|
||||||
expr.acceptVisitor(this);
|
expr.acceptVisitor(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeLocation(NodeLocation location) throws IOException {
|
private void writeLocation(TextLocation location) throws IOException {
|
||||||
if (location == null || location.getFileName() == null) {
|
if (location == null || location.getFileName() == null) {
|
||||||
output.writeShort(-1);
|
output.writeShort(-1);
|
||||||
} else {
|
} else {
|
||||||
|
@ -659,12 +659,12 @@ public class AstIO {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private NodeLocation readLocation(DataInput input) throws IOException {
|
private TextLocation readLocation(DataInput input) throws IOException {
|
||||||
int fileIndex = input.readShort();
|
int fileIndex = input.readShort();
|
||||||
if (fileIndex == -1) {
|
if (fileIndex == -1) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return new NodeLocation(fileTable.at(fileIndex), input.readShort());
|
return new TextLocation(fileTable.at(fileIndex), input.readShort());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -846,7 +846,7 @@ public class AstIO {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Expr readExpr(DataInput input) throws IOException {
|
private Expr readExpr(DataInput input) throws IOException {
|
||||||
NodeLocation location = readLocation(input);
|
TextLocation location = readLocation(input);
|
||||||
Expr expr = readExprWithoutLocation(input);
|
Expr expr = readExprWithoutLocation(input);
|
||||||
expr.setLocation(location);
|
expr.setLocation(location);
|
||||||
return expr;
|
return expr;
|
||||||
|
|
|
@ -75,7 +75,7 @@ public class ProgramIO {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
InstructionLocation location = null;
|
TextLocation location = null;
|
||||||
InstructionWriter insnWriter = new InstructionWriter(data);
|
InstructionWriter insnWriter = new InstructionWriter(data);
|
||||||
for (Instruction insn : basicBlock.getInstructions()) {
|
for (Instruction insn : basicBlock.getInstructions()) {
|
||||||
try {
|
try {
|
||||||
|
@ -158,7 +158,7 @@ public class ProgramIO {
|
||||||
block.getTryCatchBlocks().add(tryCatch);
|
block.getTryCatchBlocks().add(tryCatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
InstructionLocation location = null;
|
TextLocation location = null;
|
||||||
insnLoop: while (true) {
|
insnLoop: while (true) {
|
||||||
byte insnType = data.readByte();
|
byte insnType = data.readByte();
|
||||||
switch (insnType) {
|
switch (insnType) {
|
||||||
|
@ -170,7 +170,7 @@ public class ProgramIO {
|
||||||
case -3: {
|
case -3: {
|
||||||
String file = fileTable.at(data.readShort());
|
String file = fileTable.at(data.readShort());
|
||||||
short line = data.readShort();
|
short line = data.readShort();
|
||||||
location = new InstructionLocation(file, line);
|
location = new TextLocation(file, line);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package org.teavm.callgraph;
|
package org.teavm.callgraph;
|
||||||
|
|
||||||
import org.teavm.model.InstructionLocation;
|
import org.teavm.model.TextLocation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Call site that represents exact place in the code that calls a method.</p>.
|
* <p>Call site that represents exact place in the code that calls a method.</p>.
|
||||||
|
@ -27,7 +27,7 @@ public interface CallSite {
|
||||||
*
|
*
|
||||||
* @return location of the call site or <code>null</code> if no debug information found for this call site.
|
* @return location of the call site or <code>null</code> if no debug information found for this call site.
|
||||||
*/
|
*/
|
||||||
InstructionLocation getLocation();
|
TextLocation getLocation();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Gets a method that this call site invokes.</p>
|
* <p>Gets a method that this call site invokes.</p>
|
||||||
|
|
|
@ -15,14 +15,14 @@
|
||||||
*/
|
*/
|
||||||
package org.teavm.callgraph;
|
package org.teavm.callgraph;
|
||||||
|
|
||||||
import org.teavm.model.InstructionLocation;
|
import org.teavm.model.TextLocation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Alexey Andreev
|
* @author Alexey Andreev
|
||||||
*/
|
*/
|
||||||
public interface ClassAccessSite {
|
public interface ClassAccessSite {
|
||||||
InstructionLocation getLocation();
|
TextLocation getLocation();
|
||||||
|
|
||||||
CallGraphNode getCallee();
|
CallGraphNode getCallee();
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ package org.teavm.callgraph;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import org.teavm.model.FieldReference;
|
import org.teavm.model.FieldReference;
|
||||||
import org.teavm.model.InstructionLocation;
|
import org.teavm.model.TextLocation;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,7 +67,7 @@ public class DefaultCallGraphNode implements CallGraphNode {
|
||||||
return safeCallersCallSites;
|
return safeCallersCallSites;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean addCallSite(MethodReference method, InstructionLocation location) {
|
public boolean addCallSite(MethodReference method, TextLocation location) {
|
||||||
DefaultCallGraphNode callee = graph.getNode(method);
|
DefaultCallGraphNode callee = graph.getNode(method);
|
||||||
DefaultCallSite callSite = new DefaultCallSite(location, callee, this);
|
DefaultCallSite callSite = new DefaultCallSite(location, callee, this);
|
||||||
if (callSites.add(callSite)) {
|
if (callSites.add(callSite)) {
|
||||||
|
@ -90,7 +90,7 @@ public class DefaultCallGraphNode implements CallGraphNode {
|
||||||
return safeFieldAccessSites;
|
return safeFieldAccessSites;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean addFieldAccess(FieldReference field, InstructionLocation location) {
|
public boolean addFieldAccess(FieldReference field, TextLocation location) {
|
||||||
DefaultFieldAccessSite site = new DefaultFieldAccessSite(location, this, field);
|
DefaultFieldAccessSite site = new DefaultFieldAccessSite(location, this, field);
|
||||||
if (fieldAccessSites.add(site)) {
|
if (fieldAccessSites.add(site)) {
|
||||||
graph.addFieldAccess(site);
|
graph.addFieldAccess(site);
|
||||||
|
@ -108,7 +108,7 @@ public class DefaultCallGraphNode implements CallGraphNode {
|
||||||
return safeClassAccessSites;
|
return safeClassAccessSites;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean addClassAccess(String className, InstructionLocation location) {
|
public boolean addClassAccess(String className, TextLocation location) {
|
||||||
DefaultClassAccessSite site = new DefaultClassAccessSite(location, this, className);
|
DefaultClassAccessSite site = new DefaultClassAccessSite(location, this, className);
|
||||||
if (classAccessSites.add(site)) {
|
if (classAccessSites.add(site)) {
|
||||||
graph.addClassAccess(site);
|
graph.addClassAccess(site);
|
||||||
|
|
|
@ -16,25 +16,25 @@
|
||||||
package org.teavm.callgraph;
|
package org.teavm.callgraph;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import org.teavm.model.InstructionLocation;
|
import org.teavm.model.TextLocation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Alexey Andreev
|
* @author Alexey Andreev
|
||||||
*/
|
*/
|
||||||
public class DefaultCallSite implements CallSite {
|
public class DefaultCallSite implements CallSite {
|
||||||
private InstructionLocation location;
|
private TextLocation location;
|
||||||
private DefaultCallGraphNode callee;
|
private DefaultCallGraphNode callee;
|
||||||
private DefaultCallGraphNode caller;
|
private DefaultCallGraphNode caller;
|
||||||
|
|
||||||
DefaultCallSite(InstructionLocation location, DefaultCallGraphNode callee, DefaultCallGraphNode caller) {
|
DefaultCallSite(TextLocation location, DefaultCallGraphNode callee, DefaultCallGraphNode caller) {
|
||||||
this.location = location;
|
this.location = location;
|
||||||
this.callee = callee;
|
this.callee = callee;
|
||||||
this.caller = caller;
|
this.caller = caller;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InstructionLocation getLocation() {
|
public TextLocation getLocation() {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,25 +16,25 @@
|
||||||
package org.teavm.callgraph;
|
package org.teavm.callgraph;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import org.teavm.model.InstructionLocation;
|
import org.teavm.model.TextLocation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Alexey Andreev
|
* @author Alexey Andreev
|
||||||
*/
|
*/
|
||||||
public class DefaultClassAccessSite implements ClassAccessSite {
|
public class DefaultClassAccessSite implements ClassAccessSite {
|
||||||
private InstructionLocation location;
|
private TextLocation location;
|
||||||
private CallGraphNode callee;
|
private CallGraphNode callee;
|
||||||
private String className;
|
private String className;
|
||||||
|
|
||||||
DefaultClassAccessSite(InstructionLocation location, CallGraphNode callee, String className) {
|
DefaultClassAccessSite(TextLocation location, CallGraphNode callee, String className) {
|
||||||
this.location = location;
|
this.location = location;
|
||||||
this.callee = callee;
|
this.callee = callee;
|
||||||
this.className = className;
|
this.className = className;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InstructionLocation getLocation() {
|
public TextLocation getLocation() {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,25 +17,25 @@ package org.teavm.callgraph;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import org.teavm.model.FieldReference;
|
import org.teavm.model.FieldReference;
|
||||||
import org.teavm.model.InstructionLocation;
|
import org.teavm.model.TextLocation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Alexey Andreev
|
* @author Alexey Andreev
|
||||||
*/
|
*/
|
||||||
public class DefaultFieldAccessSite implements FieldAccessSite {
|
public class DefaultFieldAccessSite implements FieldAccessSite {
|
||||||
private InstructionLocation location;
|
private TextLocation location;
|
||||||
private CallGraphNode callee;
|
private CallGraphNode callee;
|
||||||
private FieldReference field;
|
private FieldReference field;
|
||||||
|
|
||||||
DefaultFieldAccessSite(InstructionLocation location, CallGraphNode callee, FieldReference field) {
|
DefaultFieldAccessSite(TextLocation location, CallGraphNode callee, FieldReference field) {
|
||||||
this.location = location;
|
this.location = location;
|
||||||
this.callee = callee;
|
this.callee = callee;
|
||||||
this.field = field;
|
this.field = field;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InstructionLocation getLocation() {
|
public TextLocation getLocation() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,14 +16,14 @@
|
||||||
package org.teavm.callgraph;
|
package org.teavm.callgraph;
|
||||||
|
|
||||||
import org.teavm.model.FieldReference;
|
import org.teavm.model.FieldReference;
|
||||||
import org.teavm.model.InstructionLocation;
|
import org.teavm.model.TextLocation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Alexey Andreev
|
* @author Alexey Andreev
|
||||||
*/
|
*/
|
||||||
public interface FieldAccessSite {
|
public interface FieldAccessSite {
|
||||||
InstructionLocation getLocation();
|
TextLocation getLocation();
|
||||||
|
|
||||||
CallGraphNode getCallee();
|
CallGraphNode getCallee();
|
||||||
|
|
||||||
|
|
|
@ -128,7 +128,7 @@ public class DataFlowGraphBuilder implements InstructionReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void location(InstructionLocation location) {
|
public void location(TextLocation location) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -42,7 +42,7 @@ import org.teavm.model.ElementModifier;
|
||||||
import org.teavm.model.FieldHolder;
|
import org.teavm.model.FieldHolder;
|
||||||
import org.teavm.model.FieldReader;
|
import org.teavm.model.FieldReader;
|
||||||
import org.teavm.model.FieldReference;
|
import org.teavm.model.FieldReference;
|
||||||
import org.teavm.model.InstructionLocation;
|
import org.teavm.model.TextLocation;
|
||||||
import org.teavm.model.MethodDescriptor;
|
import org.teavm.model.MethodDescriptor;
|
||||||
import org.teavm.model.MethodHolder;
|
import org.teavm.model.MethodHolder;
|
||||||
import org.teavm.model.MethodReader;
|
import org.teavm.model.MethodReader;
|
||||||
|
@ -273,7 +273,7 @@ public class DependencyChecker implements DependencyInfo {
|
||||||
return dep;
|
return dep;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean addClassAccess(DefaultCallGraphNode node, String className, InstructionLocation loc) {
|
private boolean addClassAccess(DefaultCallGraphNode node, String className, TextLocation loc) {
|
||||||
if (!node.addClassAccess(className, loc)) {
|
if (!node.addClassAccess(className, loc)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ import org.teavm.model.FieldReference;
|
||||||
import org.teavm.model.Incoming;
|
import org.teavm.model.Incoming;
|
||||||
import org.teavm.model.IncomingReader;
|
import org.teavm.model.IncomingReader;
|
||||||
import org.teavm.model.Instruction;
|
import org.teavm.model.Instruction;
|
||||||
import org.teavm.model.InstructionLocation;
|
import org.teavm.model.TextLocation;
|
||||||
import org.teavm.model.InvokeDynamicInstruction;
|
import org.teavm.model.InvokeDynamicInstruction;
|
||||||
import org.teavm.model.MethodDescriptor;
|
import org.teavm.model.MethodDescriptor;
|
||||||
import org.teavm.model.MethodHandle;
|
import org.teavm.model.MethodHandle;
|
||||||
|
@ -73,7 +73,7 @@ class DependencyGraphBuilder {
|
||||||
private DependencyNode resultNode;
|
private DependencyNode resultNode;
|
||||||
private Program program;
|
private Program program;
|
||||||
private DefaultCallGraphNode caller;
|
private DefaultCallGraphNode caller;
|
||||||
private InstructionLocation currentLocation;
|
private TextLocation currentLocation;
|
||||||
private ExceptionConsumer currentExceptionConsumer;
|
private ExceptionConsumer currentExceptionConsumer;
|
||||||
|
|
||||||
public DependencyGraphBuilder(DependencyChecker dependencyChecker) {
|
public DependencyGraphBuilder(DependencyChecker dependencyChecker) {
|
||||||
|
@ -334,13 +334,13 @@ class DependencyGraphBuilder {
|
||||||
private final DependencyNode[] parameters;
|
private final DependencyNode[] parameters;
|
||||||
private final DependencyNode result;
|
private final DependencyNode result;
|
||||||
private final DefaultCallGraphNode caller;
|
private final DefaultCallGraphNode caller;
|
||||||
private final InstructionLocation location;
|
private final TextLocation location;
|
||||||
private final Set<MethodReference> knownMethods = new HashSet<>();
|
private final Set<MethodReference> knownMethods = new HashSet<>();
|
||||||
private ExceptionConsumer exceptionConsumer;
|
private ExceptionConsumer exceptionConsumer;
|
||||||
|
|
||||||
public VirtualCallConsumer(DependencyNode node, ClassReader filterClass,
|
public VirtualCallConsumer(DependencyNode node, ClassReader filterClass,
|
||||||
MethodDescriptor methodDesc, DependencyChecker checker, DependencyNode[] parameters,
|
MethodDescriptor methodDesc, DependencyChecker checker, DependencyNode[] parameters,
|
||||||
DependencyNode result, DefaultCallGraphNode caller, InstructionLocation location,
|
DependencyNode result, DefaultCallGraphNode caller, TextLocation location,
|
||||||
ExceptionConsumer exceptionConsumer) {
|
ExceptionConsumer exceptionConsumer) {
|
||||||
this.node = node;
|
this.node = node;
|
||||||
this.filterClass = filterClass;
|
this.filterClass = filterClass;
|
||||||
|
@ -392,7 +392,7 @@ class DependencyGraphBuilder {
|
||||||
|
|
||||||
private InstructionReader reader = new InstructionReader() {
|
private InstructionReader reader = new InstructionReader() {
|
||||||
@Override
|
@Override
|
||||||
public void location(InstructionLocation location) {
|
public void location(TextLocation location) {
|
||||||
currentLocation = location;
|
currentLocation = location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
package org.teavm.diagnostics;
|
package org.teavm.diagnostics;
|
||||||
|
|
||||||
import org.teavm.model.FieldReference;
|
import org.teavm.model.FieldReference;
|
||||||
import org.teavm.model.InstructionLocation;
|
import org.teavm.model.TextLocation;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
import org.teavm.model.ValueType;
|
import org.teavm.model.ValueType;
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ public class DefaultProblemTextConsumer implements ProblemTextConsumer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void appendLocation(InstructionLocation location) {
|
public void appendLocation(TextLocation location) {
|
||||||
sb.append(location);
|
sb.append(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -132,10 +132,10 @@ public class Problem {
|
||||||
consumer.appendField((FieldReference) param);
|
consumer.appendField((FieldReference) param);
|
||||||
break;
|
break;
|
||||||
case LOCATION:
|
case LOCATION:
|
||||||
if (!(param instanceof InstructionLocation)) {
|
if (!(param instanceof TextLocation)) {
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
consumer.appendLocation((InstructionLocation) param);
|
consumer.appendLocation((TextLocation) param);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
next += 2;
|
next += 2;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
package org.teavm.diagnostics;
|
package org.teavm.diagnostics;
|
||||||
|
|
||||||
import org.teavm.model.FieldReference;
|
import org.teavm.model.FieldReference;
|
||||||
import org.teavm.model.InstructionLocation;
|
import org.teavm.model.TextLocation;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
import org.teavm.model.ValueType;
|
import org.teavm.model.ValueType;
|
||||||
|
|
||||||
|
@ -35,5 +35,5 @@ public interface ProblemTextConsumer {
|
||||||
|
|
||||||
void appendField(FieldReference field);
|
void appendField(FieldReference field);
|
||||||
|
|
||||||
void appendLocation(InstructionLocation location);
|
void appendLocation(TextLocation location);
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,6 @@ import org.teavm.ast.NativeMethodNode;
|
||||||
import org.teavm.ast.NewArrayExpr;
|
import org.teavm.ast.NewArrayExpr;
|
||||||
import org.teavm.ast.NewExpr;
|
import org.teavm.ast.NewExpr;
|
||||||
import org.teavm.ast.NewMultiArrayExpr;
|
import org.teavm.ast.NewMultiArrayExpr;
|
||||||
import org.teavm.ast.NodeLocation;
|
|
||||||
import org.teavm.ast.NodeModifier;
|
import org.teavm.ast.NodeModifier;
|
||||||
import org.teavm.ast.OperationType;
|
import org.teavm.ast.OperationType;
|
||||||
import org.teavm.ast.PrimitiveCastExpr;
|
import org.teavm.ast.PrimitiveCastExpr;
|
||||||
|
@ -101,6 +100,7 @@ import org.teavm.model.MethodDescriptor;
|
||||||
import org.teavm.model.MethodHolder;
|
import org.teavm.model.MethodHolder;
|
||||||
import org.teavm.model.MethodReader;
|
import org.teavm.model.MethodReader;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
|
import org.teavm.model.TextLocation;
|
||||||
import org.teavm.model.ValueType;
|
import org.teavm.model.ValueType;
|
||||||
|
|
||||||
public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext {
|
public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext {
|
||||||
|
@ -141,9 +141,9 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class LocationStackEntry {
|
private static class LocationStackEntry {
|
||||||
final NodeLocation location;
|
final TextLocation location;
|
||||||
|
|
||||||
LocationStackEntry(NodeLocation location) {
|
LocationStackEntry(TextLocation location) {
|
||||||
this.location = location;
|
this.location = location;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -909,7 +909,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pushLocation(NodeLocation location) {
|
private void pushLocation(TextLocation location) {
|
||||||
LocationStackEntry prevEntry = locationStack.peek();
|
LocationStackEntry prevEntry = locationStack.peek();
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
if (prevEntry == null || !location.equals(prevEntry.location)) {
|
if (prevEntry == null || !location.equals(prevEntry.location)) {
|
||||||
|
|
|
@ -52,7 +52,7 @@ import org.teavm.model.CallLocation;
|
||||||
import org.teavm.model.ClassHolder;
|
import org.teavm.model.ClassHolder;
|
||||||
import org.teavm.model.ClassHolderTransformer;
|
import org.teavm.model.ClassHolderTransformer;
|
||||||
import org.teavm.model.ElementModifier;
|
import org.teavm.model.ElementModifier;
|
||||||
import org.teavm.model.InstructionLocation;
|
import org.teavm.model.TextLocation;
|
||||||
import org.teavm.model.ListableClassHolderSource;
|
import org.teavm.model.ListableClassHolderSource;
|
||||||
import org.teavm.model.MethodHolder;
|
import org.teavm.model.MethodHolder;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
|
@ -338,8 +338,8 @@ public class JavaScriptTarget implements TeaVMTarget, TeaVMJavaScriptHost {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void emitCFG(DebugInformationEmitter emitter, Program program) {
|
private void emitCFG(DebugInformationEmitter emitter, Program program) {
|
||||||
Map<InstructionLocation, InstructionLocation[]> cfg = ProgramUtils.getLocationCFG(program);
|
Map<TextLocation, TextLocation[]> cfg = ProgramUtils.getLocationCFG(program);
|
||||||
for (Map.Entry<InstructionLocation, InstructionLocation[]> entry : cfg.entrySet()) {
|
for (Map.Entry<TextLocation, TextLocation[]> entry : cfg.entrySet()) {
|
||||||
SourceLocation location = map(entry.getKey());
|
SourceLocation location = map(entry.getKey());
|
||||||
SourceLocation[] successors = new SourceLocation[entry.getValue().length];
|
SourceLocation[] successors = new SourceLocation[entry.getValue().length];
|
||||||
for (int i = 0; i < entry.getValue().length; ++i) {
|
for (int i = 0; i < entry.getValue().length; ++i) {
|
||||||
|
@ -349,7 +349,7 @@ public class JavaScriptTarget implements TeaVMTarget, TeaVMJavaScriptHost {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SourceLocation map(InstructionLocation location) {
|
private static SourceLocation map(TextLocation location) {
|
||||||
if (location == null) {
|
if (location == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,7 +177,7 @@ public class BasicBlock implements BasicBlockReader {
|
||||||
@Override
|
@Override
|
||||||
public void readAllInstructions(InstructionReader reader) {
|
public void readAllInstructions(InstructionReader reader) {
|
||||||
InstructionReadVisitor visitor = new InstructionReadVisitor(reader);
|
InstructionReadVisitor visitor = new InstructionReadVisitor(reader);
|
||||||
InstructionLocation location = null;
|
TextLocation location = null;
|
||||||
for (Instruction insn : instructions) {
|
for (Instruction insn : instructions) {
|
||||||
if (!Objects.equals(location, insn.getLocation())) {
|
if (!Objects.equals(location, insn.getLocation())) {
|
||||||
location = insn.getLocation();
|
location = insn.getLocation();
|
||||||
|
|
|
@ -17,19 +17,15 @@ package org.teavm.model;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Alexey Andreev
|
|
||||||
*/
|
|
||||||
public class CallLocation {
|
public class CallLocation {
|
||||||
private MethodReference method;
|
private MethodReference method;
|
||||||
private InstructionLocation sourceLocation;
|
private TextLocation sourceLocation;
|
||||||
|
|
||||||
public CallLocation(MethodReference method) {
|
public CallLocation(MethodReference method) {
|
||||||
this(method, null);
|
this(method, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CallLocation(MethodReference method, InstructionLocation sourceLocation) {
|
public CallLocation(MethodReference method, TextLocation sourceLocation) {
|
||||||
if (method == null) {
|
if (method == null) {
|
||||||
throw new IllegalArgumentException("Method must not be null");
|
throw new IllegalArgumentException("Method must not be null");
|
||||||
}
|
}
|
||||||
|
@ -41,7 +37,7 @@ public class CallLocation {
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
|
|
||||||
public InstructionLocation getSourceLocation() {
|
public TextLocation getSourceLocation() {
|
||||||
return sourceLocation;
|
return sourceLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ import org.teavm.model.instructions.InstructionVisitor;
|
||||||
|
|
||||||
public abstract class Instruction {
|
public abstract class Instruction {
|
||||||
private BasicBlock basicBlock;
|
private BasicBlock basicBlock;
|
||||||
private InstructionLocation location;
|
private TextLocation location;
|
||||||
|
|
||||||
void setBasicBlock(BasicBlock basicBlock) {
|
void setBasicBlock(BasicBlock basicBlock) {
|
||||||
this.basicBlock = basicBlock;
|
this.basicBlock = basicBlock;
|
||||||
|
@ -33,11 +33,11 @@ public abstract class Instruction {
|
||||||
return basicBlock != null ? basicBlock.getProgram() : null;
|
return basicBlock != null ? basicBlock.getProgram() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public InstructionLocation getLocation() {
|
public TextLocation getLocation() {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLocation(InstructionLocation location) {
|
public void setLocation(TextLocation location) {
|
||||||
this.location = location;
|
this.location = location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ public class Interpreter {
|
||||||
private Objenesis objenesis = new ObjenesisStd();
|
private Objenesis objenesis = new ObjenesisStd();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void location(InstructionLocation location) {
|
public void location(TextLocation location) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -17,15 +17,11 @@ package org.teavm.model;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
public class TextLocation {
|
||||||
*
|
|
||||||
* @author Alexey Andreev
|
|
||||||
*/
|
|
||||||
public class InstructionLocation {
|
|
||||||
private String fileName;
|
private String fileName;
|
||||||
private int line = -1;
|
private int line = -1;
|
||||||
|
|
||||||
public InstructionLocation(String fileName, int line) {
|
public TextLocation(String fileName, int line) {
|
||||||
this.fileName = fileName;
|
this.fileName = fileName;
|
||||||
this.line = line;
|
this.line = line;
|
||||||
}
|
}
|
||||||
|
@ -52,10 +48,10 @@ public class InstructionLocation {
|
||||||
if (this == obj) {
|
if (this == obj) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!(obj instanceof InstructionLocation)) {
|
if (!(obj instanceof TextLocation)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
InstructionLocation other = (InstructionLocation) obj;
|
TextLocation other = (TextLocation) obj;
|
||||||
return Objects.equals(fileName, other.fileName) && line == other.line;
|
return Objects.equals(fileName, other.fileName) && line == other.line;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ import org.teavm.model.ClassReaderSource;
|
||||||
import org.teavm.model.FieldReader;
|
import org.teavm.model.FieldReader;
|
||||||
import org.teavm.model.FieldReference;
|
import org.teavm.model.FieldReference;
|
||||||
import org.teavm.model.Instruction;
|
import org.teavm.model.Instruction;
|
||||||
import org.teavm.model.InstructionLocation;
|
import org.teavm.model.TextLocation;
|
||||||
import org.teavm.model.MethodDescriptor;
|
import org.teavm.model.MethodDescriptor;
|
||||||
import org.teavm.model.MethodHolder;
|
import org.teavm.model.MethodHolder;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
|
@ -56,7 +56,7 @@ public final class ProgramEmitter {
|
||||||
private Program program;
|
private Program program;
|
||||||
private BasicBlock block;
|
private BasicBlock block;
|
||||||
ClassReaderSource classSource;
|
ClassReaderSource classSource;
|
||||||
private InstructionLocation currentLocation;
|
private TextLocation currentLocation;
|
||||||
|
|
||||||
private ProgramEmitter(Program program, BasicBlock block, ClassReaderSource classSource) {
|
private ProgramEmitter(Program program, BasicBlock block, ClassReaderSource classSource) {
|
||||||
this.program = program;
|
this.program = program;
|
||||||
|
@ -373,11 +373,11 @@ public final class ProgramEmitter {
|
||||||
return var(program.createVariable(), type);
|
return var(program.createVariable(), type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InstructionLocation getCurrentLocation() {
|
public TextLocation getCurrentLocation() {
|
||||||
return currentLocation;
|
return currentLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCurrentLocation(InstructionLocation currentLocation) {
|
public void setCurrentLocation(TextLocation currentLocation) {
|
||||||
this.currentLocation = currentLocation;
|
this.currentLocation = currentLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ import java.util.List;
|
||||||
import org.teavm.model.*;
|
import org.teavm.model.*;
|
||||||
|
|
||||||
public interface InstructionReader {
|
public interface InstructionReader {
|
||||||
void location(InstructionLocation location);
|
void location(TextLocation location);
|
||||||
|
|
||||||
void nop();
|
void nop();
|
||||||
|
|
||||||
|
|
|
@ -237,7 +237,7 @@ public class AsyncMethodFinder {
|
||||||
boolean async;
|
boolean async;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void location(InstructionLocation location) {
|
public void location(TextLocation location) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -21,7 +21,7 @@ import org.teavm.model.BasicBlock;
|
||||||
import org.teavm.model.BasicBlockReader;
|
import org.teavm.model.BasicBlockReader;
|
||||||
import org.teavm.model.FieldReference;
|
import org.teavm.model.FieldReference;
|
||||||
import org.teavm.model.Instruction;
|
import org.teavm.model.Instruction;
|
||||||
import org.teavm.model.InstructionLocation;
|
import org.teavm.model.TextLocation;
|
||||||
import org.teavm.model.InvokeDynamicInstruction;
|
import org.teavm.model.InvokeDynamicInstruction;
|
||||||
import org.teavm.model.MethodDescriptor;
|
import org.teavm.model.MethodDescriptor;
|
||||||
import org.teavm.model.MethodHandle;
|
import org.teavm.model.MethodHandle;
|
||||||
|
@ -82,7 +82,7 @@ import org.teavm.model.instructions.UnwrapArrayInstruction;
|
||||||
public class InstructionCopyReader implements InstructionReader {
|
public class InstructionCopyReader implements InstructionReader {
|
||||||
private Instruction copy;
|
private Instruction copy;
|
||||||
private Program programCopy;
|
private Program programCopy;
|
||||||
private InstructionLocation location;
|
private TextLocation location;
|
||||||
|
|
||||||
public InstructionCopyReader(Program programCopy) {
|
public InstructionCopyReader(Program programCopy) {
|
||||||
this.programCopy = programCopy;
|
this.programCopy = programCopy;
|
||||||
|
@ -97,7 +97,7 @@ public class InstructionCopyReader implements InstructionReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void location(InstructionLocation location) {
|
public void location(TextLocation location) {
|
||||||
this.location = location;
|
this.location = location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,19 +26,19 @@ import org.teavm.model.instructions.*;
|
||||||
* @author Alexey Andreev
|
* @author Alexey Andreev
|
||||||
*/
|
*/
|
||||||
public class InstructionStringifier implements InstructionReader {
|
public class InstructionStringifier implements InstructionReader {
|
||||||
private InstructionLocation location;
|
private TextLocation location;
|
||||||
private StringBuilder sb;
|
private StringBuilder sb;
|
||||||
|
|
||||||
public InstructionStringifier(StringBuilder sb) {
|
public InstructionStringifier(StringBuilder sb) {
|
||||||
this.sb = sb;
|
this.sb = sb;
|
||||||
}
|
}
|
||||||
|
|
||||||
public InstructionLocation getLocation() {
|
public TextLocation getLocation() {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void location(InstructionLocation location) {
|
public void location(TextLocation location) {
|
||||||
this.location = location;
|
this.location = location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class ListingBuilder {
|
||||||
sb.append("\n");
|
sb.append("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
InstructionLocation location = null;
|
TextLocation location = null;
|
||||||
for (int j = 0; j < block.instructionCount(); ++j) {
|
for (int j = 0; j < block.instructionCount(); ++j) {
|
||||||
insnSb.setLength(0);
|
insnSb.setLength(0);
|
||||||
block.readInstruction(j, stringifier);
|
block.readInstruction(j, stringifier);
|
||||||
|
|
|
@ -19,7 +19,7 @@ import java.util.*;
|
||||||
import org.teavm.common.Graph;
|
import org.teavm.common.Graph;
|
||||||
import org.teavm.model.BasicBlock;
|
import org.teavm.model.BasicBlock;
|
||||||
import org.teavm.model.Instruction;
|
import org.teavm.model.Instruction;
|
||||||
import org.teavm.model.InstructionLocation;
|
import org.teavm.model.TextLocation;
|
||||||
import org.teavm.model.Program;
|
import org.teavm.model.Program;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,11 +27,11 @@ import org.teavm.model.Program;
|
||||||
* @author Alexey Andreev
|
* @author Alexey Andreev
|
||||||
*/
|
*/
|
||||||
class LocationGraphBuilder {
|
class LocationGraphBuilder {
|
||||||
private Map<InstructionLocation, Set<InstructionLocation>> graphBuilder;
|
private Map<TextLocation, Set<TextLocation>> graphBuilder;
|
||||||
private List<Set<InstructionLocation>> startLocations;
|
private List<Set<TextLocation>> startLocations;
|
||||||
private List<AdditionalConnection> additionalConnections;
|
private List<AdditionalConnection> additionalConnections;
|
||||||
|
|
||||||
public Map<InstructionLocation, InstructionLocation[]> build(Program program) {
|
public Map<TextLocation, TextLocation[]> build(Program program) {
|
||||||
graphBuilder = new HashMap<>();
|
graphBuilder = new HashMap<>();
|
||||||
Graph graph = ProgramUtils.buildControlFlowGraph(program);
|
Graph graph = ProgramUtils.buildControlFlowGraph(program);
|
||||||
dfs(graph, program);
|
dfs(graph, program);
|
||||||
|
@ -39,7 +39,7 @@ class LocationGraphBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dfs(Graph graph, Program program) {
|
private void dfs(Graph graph, Program program) {
|
||||||
startLocations = new ArrayList<>(Collections.<Set<InstructionLocation>>nCopies(graph.size(), null));
|
startLocations = new ArrayList<>(Collections.<Set<TextLocation>>nCopies(graph.size(), null));
|
||||||
additionalConnections = new ArrayList<>();
|
additionalConnections = new ArrayList<>();
|
||||||
Deque<Step> stack = new ArrayDeque<>();
|
Deque<Step> stack = new ArrayDeque<>();
|
||||||
for (int i = 0; i < graph.size(); ++i) {
|
for (int i = 0; i < graph.size(); ++i) {
|
||||||
|
@ -48,7 +48,7 @@ class LocationGraphBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
boolean[] visited = new boolean[graph.size()];
|
boolean[] visited = new boolean[graph.size()];
|
||||||
InstructionLocation[] blockLocations = new InstructionLocation[graph.size()];
|
TextLocation[] blockLocations = new TextLocation[graph.size()];
|
||||||
|
|
||||||
while (!stack.isEmpty()) {
|
while (!stack.isEmpty()) {
|
||||||
Step step = stack.pop();
|
Step step = stack.pop();
|
||||||
|
@ -61,7 +61,7 @@ class LocationGraphBuilder {
|
||||||
visited[step.block] = true;
|
visited[step.block] = true;
|
||||||
startLocations.set(step.block, step.startLocations);
|
startLocations.set(step.block, step.startLocations);
|
||||||
BasicBlock block = program.basicBlockAt(step.block);
|
BasicBlock block = program.basicBlockAt(step.block);
|
||||||
InstructionLocation location = step.location;
|
TextLocation location = step.location;
|
||||||
boolean started = false;
|
boolean started = false;
|
||||||
for (Instruction insn : block.getInstructions()) {
|
for (Instruction insn : block.getInstructions()) {
|
||||||
if (insn.getLocation() != null) {
|
if (insn.getLocation() != null) {
|
||||||
|
@ -80,7 +80,7 @@ class LocationGraphBuilder {
|
||||||
}
|
}
|
||||||
if (graph.outgoingEdgesCount(step.block) == 0) {
|
if (graph.outgoingEdgesCount(step.block) == 0) {
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
addEdge(location, new InstructionLocation(null, -1));
|
addEdge(location, new TextLocation(null, -1));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int next : graph.outgoingEdges(step.block)) {
|
for (int next : graph.outgoingEdges(step.block)) {
|
||||||
|
@ -90,15 +90,15 @@ class LocationGraphBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<InstructionLocation, InstructionLocation[]> assemble() {
|
private Map<TextLocation, TextLocation[]> assemble() {
|
||||||
for (AdditionalConnection additionalConn : additionalConnections) {
|
for (AdditionalConnection additionalConn : additionalConnections) {
|
||||||
for (InstructionLocation succ : additionalConn.successors) {
|
for (TextLocation succ : additionalConn.successors) {
|
||||||
addEdge(additionalConn.location, succ);
|
addEdge(additionalConn.location, succ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Map<InstructionLocation, InstructionLocation[]> locationGraph = new HashMap<>();
|
Map<TextLocation, TextLocation[]> locationGraph = new HashMap<>();
|
||||||
for (Map.Entry<InstructionLocation, Set<InstructionLocation>> entry : graphBuilder.entrySet()) {
|
for (Map.Entry<TextLocation, Set<TextLocation>> entry : graphBuilder.entrySet()) {
|
||||||
InstructionLocation[] successors = entry.getValue().toArray(new InstructionLocation[0]);
|
TextLocation[] successors = entry.getValue().toArray(new TextLocation[0]);
|
||||||
for (int i = 0; i < successors.length; ++i) {
|
for (int i = 0; i < successors.length; ++i) {
|
||||||
if (successors[i] != null && successors[i].getLine() < 0) {
|
if (successors[i] != null && successors[i].getLine() < 0) {
|
||||||
successors[i] = null;
|
successors[i] = null;
|
||||||
|
@ -109,8 +109,8 @@ class LocationGraphBuilder {
|
||||||
return locationGraph;
|
return locationGraph;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addEdge(InstructionLocation source, InstructionLocation dest) {
|
private void addEdge(TextLocation source, TextLocation dest) {
|
||||||
Set<InstructionLocation> successors = graphBuilder.get(source);
|
Set<TextLocation> successors = graphBuilder.get(source);
|
||||||
if (successors == null) {
|
if (successors == null) {
|
||||||
successors = new HashSet<>();
|
successors = new HashSet<>();
|
||||||
graphBuilder.put(source, successors);
|
graphBuilder.put(source, successors);
|
||||||
|
@ -119,10 +119,10 @@ class LocationGraphBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Step {
|
static class Step {
|
||||||
InstructionLocation location;
|
TextLocation location;
|
||||||
Set<InstructionLocation> startLocations;
|
Set<TextLocation> startLocations;
|
||||||
int block;
|
int block;
|
||||||
public Step(InstructionLocation location, Set<InstructionLocation> startLocations, int block) {
|
public Step(TextLocation location, Set<TextLocation> startLocations, int block) {
|
||||||
this.location = location;
|
this.location = location;
|
||||||
this.startLocations = startLocations;
|
this.startLocations = startLocations;
|
||||||
this.block = block;
|
this.block = block;
|
||||||
|
@ -130,9 +130,9 @@ class LocationGraphBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
static class AdditionalConnection {
|
static class AdditionalConnection {
|
||||||
InstructionLocation location;
|
TextLocation location;
|
||||||
Set<InstructionLocation> successors;
|
Set<TextLocation> successors;
|
||||||
public AdditionalConnection(InstructionLocation location, Set<InstructionLocation> successors) {
|
public AdditionalConnection(TextLocation location, Set<TextLocation> successors) {
|
||||||
this.location = location;
|
this.location = location;
|
||||||
this.successors = successors;
|
this.successors = successors;
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,7 @@ public class MissingItemsProcessor {
|
||||||
block.getInstructions().addAll(instructionsToAdd);
|
block.getInstructions().addAll(instructionsToAdd);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void emitExceptionThrow(InstructionLocation location, String exceptionName, String text) {
|
private void emitExceptionThrow(TextLocation location, String exceptionName, String text) {
|
||||||
Variable exceptionVar = program.createVariable();
|
Variable exceptionVar = program.createVariable();
|
||||||
ConstructInstruction newExceptionInsn = new ConstructInstruction();
|
ConstructInstruction newExceptionInsn = new ConstructInstruction();
|
||||||
newExceptionInsn.setType(exceptionName);
|
newExceptionInsn.setType(exceptionName);
|
||||||
|
@ -125,7 +125,7 @@ public class MissingItemsProcessor {
|
||||||
instructionsToAdd.add(raiseInsn);
|
instructionsToAdd.add(raiseInsn);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkClass(InstructionLocation location, String className) {
|
private boolean checkClass(TextLocation location, String className) {
|
||||||
if (!achievableClasses.contains(className) || !dependencyInfo.getClass(className).isMissing()) {
|
if (!achievableClasses.contains(className) || !dependencyInfo.getClass(className).isMissing()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ public class MissingItemsProcessor {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkClass(InstructionLocation location, ValueType type) {
|
private boolean checkClass(TextLocation location, ValueType type) {
|
||||||
while (type instanceof ValueType.Array) {
|
while (type instanceof ValueType.Array) {
|
||||||
type = ((ValueType.Array) type).getItemType();
|
type = ((ValueType.Array) type).getItemType();
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ public class MissingItemsProcessor {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkMethod(InstructionLocation location, MethodReference method) {
|
private boolean checkMethod(TextLocation location, MethodReference method) {
|
||||||
if (!checkClass(location, method.getClassName())) {
|
if (!checkClass(location, method.getClassName())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ public class MissingItemsProcessor {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkField(InstructionLocation location, FieldReference field) {
|
private boolean checkField(TextLocation location, FieldReference field) {
|
||||||
if (!checkClass(location, field.getClassName())) {
|
if (!checkClass(location, field.getClassName())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ import org.teavm.model.BasicBlockReader;
|
||||||
import org.teavm.model.Incoming;
|
import org.teavm.model.Incoming;
|
||||||
import org.teavm.model.IncomingReader;
|
import org.teavm.model.IncomingReader;
|
||||||
import org.teavm.model.Instruction;
|
import org.teavm.model.Instruction;
|
||||||
import org.teavm.model.InstructionLocation;
|
import org.teavm.model.TextLocation;
|
||||||
import org.teavm.model.Phi;
|
import org.teavm.model.Phi;
|
||||||
import org.teavm.model.PhiReader;
|
import org.teavm.model.PhiReader;
|
||||||
import org.teavm.model.Program;
|
import org.teavm.model.Program;
|
||||||
|
@ -62,7 +62,7 @@ public final class ProgramUtils {
|
||||||
return graphBuilder.build();
|
return graphBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<InstructionLocation, InstructionLocation[]> getLocationCFG(Program program) {
|
public static Map<TextLocation, TextLocation[]> getLocationCFG(Program program) {
|
||||||
return new LocationGraphBuilder().build(program);
|
return new LocationGraphBuilder().build(program);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -271,7 +271,7 @@ public class TypeInferer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void location(InstructionLocation location) {
|
public void location(TextLocation location) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -269,7 +269,7 @@ public class ProgramParser {
|
||||||
BasicBlock basicBlock = null;
|
BasicBlock basicBlock = null;
|
||||||
Map<Integer, String> accumulatedDebugNames = new HashMap<>();
|
Map<Integer, String> accumulatedDebugNames = new HashMap<>();
|
||||||
Integer lastLineNumber = null;
|
Integer lastLineNumber = null;
|
||||||
InstructionLocation lastLocation = null;
|
TextLocation lastLocation = null;
|
||||||
for (int i = 0; i < basicBlocks.size(); ++i) {
|
for (int i = 0; i < basicBlocks.size(); ++i) {
|
||||||
BasicBlock newBasicBlock = basicBlocks.get(i);
|
BasicBlock newBasicBlock = basicBlocks.get(i);
|
||||||
if (newBasicBlock != null) {
|
if (newBasicBlock != null) {
|
||||||
|
@ -303,7 +303,7 @@ public class ProgramParser {
|
||||||
Integer lineNumber = lineNumbers.get(label);
|
Integer lineNumber = lineNumbers.get(label);
|
||||||
if (lineNumber != null && !lineNumber.equals(lastLineNumber)) {
|
if (lineNumber != null && !lineNumber.equals(lastLineNumber)) {
|
||||||
lastLineNumber = lineNumber;
|
lastLineNumber = lineNumber;
|
||||||
lastLocation = new InstructionLocation(fileName, lastLineNumber);
|
lastLocation = new TextLocation(fileName, lastLineNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (builtInstructions != null) {
|
if (builtInstructions != null) {
|
||||||
|
|
|
@ -45,7 +45,6 @@ import org.teavm.ast.MonitorExitStatement;
|
||||||
import org.teavm.ast.NewArrayExpr;
|
import org.teavm.ast.NewArrayExpr;
|
||||||
import org.teavm.ast.NewExpr;
|
import org.teavm.ast.NewExpr;
|
||||||
import org.teavm.ast.NewMultiArrayExpr;
|
import org.teavm.ast.NewMultiArrayExpr;
|
||||||
import org.teavm.ast.NodeLocation;
|
|
||||||
import org.teavm.ast.OperationType;
|
import org.teavm.ast.OperationType;
|
||||||
import org.teavm.ast.PrimitiveCastExpr;
|
import org.teavm.ast.PrimitiveCastExpr;
|
||||||
import org.teavm.ast.QualificationExpr;
|
import org.teavm.ast.QualificationExpr;
|
||||||
|
@ -65,8 +64,8 @@ import org.teavm.ast.WhileStatement;
|
||||||
import org.teavm.interop.Address;
|
import org.teavm.interop.Address;
|
||||||
import org.teavm.model.CallLocation;
|
import org.teavm.model.CallLocation;
|
||||||
import org.teavm.model.FieldReference;
|
import org.teavm.model.FieldReference;
|
||||||
import org.teavm.model.InstructionLocation;
|
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
|
import org.teavm.model.TextLocation;
|
||||||
import org.teavm.model.ValueType;
|
import org.teavm.model.ValueType;
|
||||||
import org.teavm.model.classes.TagRegistry;
|
import org.teavm.model.classes.TagRegistry;
|
||||||
import org.teavm.model.classes.VirtualTableEntry;
|
import org.teavm.model.classes.VirtualTableEntry;
|
||||||
|
@ -446,7 +445,7 @@ class WasmGenerationVisitor implements StatementVisitor, ExprVisitor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void storeField(Expr qualified, FieldReference field, Expr value, NodeLocation location) {
|
private void storeField(Expr qualified, FieldReference field, Expr value, TextLocation location) {
|
||||||
WasmExpression address = getAddress(qualified, field, location);
|
WasmExpression address = getAddress(qualified, field, location);
|
||||||
ValueType type = context.getFieldType(field);
|
ValueType type = context.getFieldType(field);
|
||||||
value.acceptVisitor(this);
|
value.acceptVisitor(this);
|
||||||
|
@ -800,9 +799,9 @@ class WasmGenerationVisitor implements StatementVisitor, ExprVisitor {
|
||||||
VirtualTableEntry vtableEntry = context.getVirtualTableProvider().lookup(expr.getMethod());
|
VirtualTableEntry vtableEntry = context.getVirtualTableProvider().lookup(expr.getMethod());
|
||||||
if (vtableEntry == null) {
|
if (vtableEntry == null) {
|
||||||
result = new WasmInt32Constant(0);
|
result = new WasmInt32Constant(0);
|
||||||
InstructionLocation insnLocation = null;
|
TextLocation insnLocation = null;
|
||||||
if (expr.getLocation() != null) {
|
if (expr.getLocation() != null) {
|
||||||
insnLocation = new InstructionLocation(expr.getLocation().getFileName(),
|
insnLocation = new TextLocation(expr.getLocation().getFileName(),
|
||||||
expr.getLocation().getLine());
|
expr.getLocation().getLine());
|
||||||
}
|
}
|
||||||
CallLocation location = new CallLocation(method, insnLocation);
|
CallLocation location = new CallLocation(method, insnLocation);
|
||||||
|
@ -891,7 +890,7 @@ class WasmGenerationVisitor implements StatementVisitor, ExprVisitor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private WasmExpression getAddress(Expr qualified, FieldReference field, NodeLocation location) {
|
private WasmExpression getAddress(Expr qualified, FieldReference field, TextLocation location) {
|
||||||
int offset = classGenerator.getFieldOffset(field);
|
int offset = classGenerator.getFieldOffset(field);
|
||||||
if (qualified == null) {
|
if (qualified == null) {
|
||||||
WasmExpression result = new WasmInt32Constant(offset);
|
WasmExpression result = new WasmInt32Constant(offset);
|
||||||
|
@ -942,7 +941,7 @@ class WasmGenerationVisitor implements StatementVisitor, ExprVisitor {
|
||||||
result = allocateObject(expr.getConstructedClass(), expr.getLocation());
|
result = allocateObject(expr.getConstructedClass(), expr.getLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
private WasmExpression allocateObject(String className, NodeLocation location) {
|
private WasmExpression allocateObject(String className, TextLocation location) {
|
||||||
int tag = classGenerator.getClassPointer(ValueType.object(className));
|
int tag = classGenerator.getClassPointer(ValueType.object(className));
|
||||||
String allocName = WasmMangling.mangleMethod(new MethodReference(Allocator.class, "allocate",
|
String allocName = WasmMangling.mangleMethod(new MethodReference(Allocator.class, "allocate",
|
||||||
RuntimeClass.class, Address.class));
|
RuntimeClass.class, Address.class));
|
||||||
|
|
|
@ -15,19 +15,19 @@
|
||||||
*/
|
*/
|
||||||
package org.teavm.wasm.model.expression;
|
package org.teavm.wasm.model.expression;
|
||||||
|
|
||||||
import org.teavm.ast.NodeLocation;
|
import org.teavm.model.TextLocation;
|
||||||
|
|
||||||
public abstract class WasmExpression {
|
public abstract class WasmExpression {
|
||||||
private NodeLocation location;
|
private TextLocation location;
|
||||||
|
|
||||||
WasmExpression() {
|
WasmExpression() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public NodeLocation getLocation() {
|
public TextLocation getLocation() {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLocation(NodeLocation location) {
|
public void setLocation(TextLocation location) {
|
||||||
this.location = location;
|
this.location = location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ import org.teavm.model.ClassReaderSource;
|
||||||
import org.teavm.model.ElementModifier;
|
import org.teavm.model.ElementModifier;
|
||||||
import org.teavm.model.FieldHolder;
|
import org.teavm.model.FieldHolder;
|
||||||
import org.teavm.model.Instruction;
|
import org.teavm.model.Instruction;
|
||||||
import org.teavm.model.InstructionLocation;
|
import org.teavm.model.TextLocation;
|
||||||
import org.teavm.model.MethodDescriptor;
|
import org.teavm.model.MethodDescriptor;
|
||||||
import org.teavm.model.MethodHolder;
|
import org.teavm.model.MethodHolder;
|
||||||
import org.teavm.model.MethodReader;
|
import org.teavm.model.MethodReader;
|
||||||
|
@ -675,7 +675,7 @@ class JSClassProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addPropertyGet(String propertyName, Variable instance, Variable receiver,
|
private void addPropertyGet(String propertyName, Variable instance, Variable receiver,
|
||||||
InstructionLocation location) {
|
TextLocation location) {
|
||||||
Variable nameVar = addStringWrap(addString(propertyName, location), location);
|
Variable nameVar = addStringWrap(addString(propertyName, location), location);
|
||||||
InvokeInstruction insn = new InvokeInstruction();
|
InvokeInstruction insn = new InvokeInstruction();
|
||||||
insn.setType(InvocationType.SPECIAL);
|
insn.setType(InvocationType.SPECIAL);
|
||||||
|
@ -687,7 +687,7 @@ class JSClassProcessor {
|
||||||
replacement.add(insn);
|
replacement.add(insn);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addPropertySet(String propertyName, Variable instance, Variable value, InstructionLocation location) {
|
private void addPropertySet(String propertyName, Variable instance, Variable value, TextLocation location) {
|
||||||
Variable nameVar = addStringWrap(addString(propertyName, location), location);
|
Variable nameVar = addStringWrap(addString(propertyName, location), location);
|
||||||
InvokeInstruction insn = new InvokeInstruction();
|
InvokeInstruction insn = new InvokeInstruction();
|
||||||
insn.setType(InvocationType.SPECIAL);
|
insn.setType(InvocationType.SPECIAL);
|
||||||
|
@ -700,7 +700,7 @@ class JSClassProcessor {
|
||||||
replacement.add(insn);
|
replacement.add(insn);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addIndexerGet(Variable array, Variable index, Variable receiver, InstructionLocation location) {
|
private void addIndexerGet(Variable array, Variable index, Variable receiver, TextLocation location) {
|
||||||
InvokeInstruction insn = new InvokeInstruction();
|
InvokeInstruction insn = new InvokeInstruction();
|
||||||
insn.setType(InvocationType.SPECIAL);
|
insn.setType(InvocationType.SPECIAL);
|
||||||
insn.setMethod(new MethodReference(JS.class, "get", JSObject.class, JSObject.class, JSObject.class));
|
insn.setMethod(new MethodReference(JS.class, "get", JSObject.class, JSObject.class, JSObject.class));
|
||||||
|
@ -711,7 +711,7 @@ class JSClassProcessor {
|
||||||
replacement.add(insn);
|
replacement.add(insn);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addIndexerSet(Variable array, Variable index, Variable value, InstructionLocation location) {
|
private void addIndexerSet(Variable array, Variable index, Variable value, TextLocation location) {
|
||||||
InvokeInstruction insn = new InvokeInstruction();
|
InvokeInstruction insn = new InvokeInstruction();
|
||||||
insn.setType(InvocationType.SPECIAL);
|
insn.setType(InvocationType.SPECIAL);
|
||||||
insn.setMethod(new MethodReference(JS.class, "set", JSObject.class, JSObject.class,
|
insn.setMethod(new MethodReference(JS.class, "set", JSObject.class, JSObject.class,
|
||||||
|
@ -723,7 +723,7 @@ class JSClassProcessor {
|
||||||
replacement.add(insn);
|
replacement.add(insn);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copyVar(Variable a, Variable b, InstructionLocation location) {
|
private void copyVar(Variable a, Variable b, TextLocation location) {
|
||||||
AssignInstruction insn = new AssignInstruction();
|
AssignInstruction insn = new AssignInstruction();
|
||||||
insn.setAssignee(a);
|
insn.setAssignee(a);
|
||||||
insn.setReceiver(b);
|
insn.setReceiver(b);
|
||||||
|
@ -731,11 +731,11 @@ class JSClassProcessor {
|
||||||
replacement.add(insn);
|
replacement.add(insn);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Variable addStringWrap(Variable var, InstructionLocation location) {
|
private Variable addStringWrap(Variable var, TextLocation location) {
|
||||||
return wrap(var, ValueType.object("java.lang.String"), location);
|
return wrap(var, ValueType.object("java.lang.String"), location);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Variable addString(String str, InstructionLocation location) {
|
private Variable addString(String str, TextLocation location) {
|
||||||
Variable var = program.createVariable();
|
Variable var = program.createVariable();
|
||||||
StringConstantInstruction nameInsn = new StringConstantInstruction();
|
StringConstantInstruction nameInsn = new StringConstantInstruction();
|
||||||
nameInsn.setReceiver(var);
|
nameInsn.setReceiver(var);
|
||||||
|
@ -957,7 +957,7 @@ class JSClassProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Variable unwrap(Variable var, String methodName, ValueType argType, ValueType resultType,
|
private Variable unwrap(Variable var, String methodName, ValueType argType, ValueType resultType,
|
||||||
InstructionLocation location) {
|
TextLocation location) {
|
||||||
if (!argType.isObject(JSObject.class.getName())) {
|
if (!argType.isObject(JSObject.class.getName())) {
|
||||||
Variable castValue = program.createVariable();
|
Variable castValue = program.createVariable();
|
||||||
CastInstruction castInsn = new CastInstruction();
|
CastInstruction castInsn = new CastInstruction();
|
||||||
|
@ -1013,7 +1013,7 @@ class JSClassProcessor {
|
||||||
return functor;
|
return functor;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Variable wrap(Variable var, ValueType type, InstructionLocation location) {
|
private Variable wrap(Variable var, ValueType type, TextLocation location) {
|
||||||
if (type instanceof ValueType.Object) {
|
if (type instanceof ValueType.Object) {
|
||||||
String className = ((ValueType.Object) type).getClassName();
|
String className = ((ValueType.Object) type).getClassName();
|
||||||
if (!className.equals("java.lang.String")) {
|
if (!className.equals("java.lang.String")) {
|
||||||
|
|
|
@ -22,7 +22,7 @@ import java.util.stream.Collectors;
|
||||||
import org.teavm.common.DisjointSet;
|
import org.teavm.common.DisjointSet;
|
||||||
import org.teavm.model.BasicBlockReader;
|
import org.teavm.model.BasicBlockReader;
|
||||||
import org.teavm.model.FieldReference;
|
import org.teavm.model.FieldReference;
|
||||||
import org.teavm.model.InstructionLocation;
|
import org.teavm.model.TextLocation;
|
||||||
import org.teavm.model.MethodDescriptor;
|
import org.teavm.model.MethodDescriptor;
|
||||||
import org.teavm.model.MethodHandle;
|
import org.teavm.model.MethodHandle;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
|
@ -134,7 +134,7 @@ class AliasFinder {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void location(InstructionLocation location) {
|
public void location(TextLocation location) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -39,7 +39,7 @@ import org.teavm.model.FieldReference;
|
||||||
import org.teavm.model.Incoming;
|
import org.teavm.model.Incoming;
|
||||||
import org.teavm.model.IncomingReader;
|
import org.teavm.model.IncomingReader;
|
||||||
import org.teavm.model.Instruction;
|
import org.teavm.model.Instruction;
|
||||||
import org.teavm.model.InstructionLocation;
|
import org.teavm.model.TextLocation;
|
||||||
import org.teavm.model.InvokeDynamicInstruction;
|
import org.teavm.model.InvokeDynamicInstruction;
|
||||||
import org.teavm.model.MethodDescriptor;
|
import org.teavm.model.MethodDescriptor;
|
||||||
import org.teavm.model.MethodHandle;
|
import org.teavm.model.MethodHandle;
|
||||||
|
@ -103,8 +103,8 @@ import org.teavm.model.instructions.UnwrapArrayInstruction;
|
||||||
public class CompositeMethodGenerator {
|
public class CompositeMethodGenerator {
|
||||||
private Diagnostics diagnostics;
|
private Diagnostics diagnostics;
|
||||||
Program program;
|
Program program;
|
||||||
InstructionLocation location;
|
TextLocation location;
|
||||||
InstructionLocation forcedLocation;
|
TextLocation forcedLocation;
|
||||||
int blockIndex;
|
int blockIndex;
|
||||||
int returnBlockIndex;
|
int returnBlockIndex;
|
||||||
private Variable resultVar;
|
private Variable resultVar;
|
||||||
|
@ -467,7 +467,7 @@ public class CompositeMethodGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void location(InstructionLocation location) {
|
public void location(TextLocation location) {
|
||||||
CompositeMethodGenerator.this.location = location;
|
CompositeMethodGenerator.this.location = location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ package org.teavm.metaprogramming.impl;
|
||||||
|
|
||||||
import org.teavm.metaprogramming.LazyComputation;
|
import org.teavm.metaprogramming.LazyComputation;
|
||||||
import org.teavm.metaprogramming.Value;
|
import org.teavm.metaprogramming.Value;
|
||||||
import org.teavm.model.InstructionLocation;
|
import org.teavm.model.TextLocation;
|
||||||
import org.teavm.model.ValueType;
|
import org.teavm.model.ValueType;
|
||||||
|
|
||||||
public class LazyValueImpl<T> implements Value<T> {
|
public class LazyValueImpl<T> implements Value<T> {
|
||||||
|
@ -25,10 +25,10 @@ public class LazyValueImpl<T> implements Value<T> {
|
||||||
VariableContext context;
|
VariableContext context;
|
||||||
LazyComputation<T> computation;
|
LazyComputation<T> computation;
|
||||||
ValueType type;
|
ValueType type;
|
||||||
InstructionLocation forcedLocation;
|
TextLocation forcedLocation;
|
||||||
|
|
||||||
public LazyValueImpl(VariableContext context, LazyComputation<T> computation, ValueType type,
|
public LazyValueImpl(VariableContext context, LazyComputation<T> computation, ValueType type,
|
||||||
InstructionLocation forcedLocation) {
|
TextLocation forcedLocation) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.computation = computation;
|
this.computation = computation;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
|
|
@ -39,7 +39,7 @@ import org.teavm.model.ClassHolder;
|
||||||
import org.teavm.model.ClassReaderSource;
|
import org.teavm.model.ClassReaderSource;
|
||||||
import org.teavm.model.ElementModifier;
|
import org.teavm.model.ElementModifier;
|
||||||
import org.teavm.model.Instruction;
|
import org.teavm.model.Instruction;
|
||||||
import org.teavm.model.InstructionLocation;
|
import org.teavm.model.TextLocation;
|
||||||
import org.teavm.model.MethodHolder;
|
import org.teavm.model.MethodHolder;
|
||||||
import org.teavm.model.MethodReader;
|
import org.teavm.model.MethodReader;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
|
@ -407,7 +407,7 @@ public final class MetaprogrammingImpl {
|
||||||
MethodReader method = ((ReflectMethodImpl) location.getMethod()).method;
|
MethodReader method = ((ReflectMethodImpl) location.getMethod()).method;
|
||||||
return location.getFileName() != null
|
return location.getFileName() != null
|
||||||
? new CallLocation(method.getReference(),
|
? new CallLocation(method.getReference(),
|
||||||
new InstructionLocation(location.getFileName(), location.getLineNumber()))
|
new TextLocation(location.getFileName(), location.getLineNumber()))
|
||||||
: new CallLocation(method.getReference());
|
: new CallLocation(method.getReference());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -37,7 +37,7 @@ class InstructionLocationReader implements InstructionReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void location(InstructionLocation location) {
|
public void location(TextLocation location) {
|
||||||
if (location != null && location.getFileName() != null) {
|
if (location != null && location.getFileName() != null) {
|
||||||
resources.add(location.getFileName());
|
resources.add(location.getFileName());
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import org.teavm.callgraph.CallSite;
|
||||||
import org.teavm.diagnostics.DefaultProblemTextConsumer;
|
import org.teavm.diagnostics.DefaultProblemTextConsumer;
|
||||||
import org.teavm.diagnostics.Problem;
|
import org.teavm.diagnostics.Problem;
|
||||||
import org.teavm.model.CallLocation;
|
import org.teavm.model.CallLocation;
|
||||||
import org.teavm.model.InstructionLocation;
|
import org.teavm.model.TextLocation;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
import org.teavm.vm.TeaVM;
|
import org.teavm.vm.TeaVM;
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ public final class TeaVMProblemRenderer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void renderCallLocation(MethodReference method, InstructionLocation location, StringBuilder sb) {
|
public static void renderCallLocation(MethodReference method, TextLocation location, StringBuilder sb) {
|
||||||
if (method != null) {
|
if (method != null) {
|
||||||
sb.append(method.getClassName() + "." + method.getName());
|
sb.append(method.getClassName() + "." + method.getName());
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -35,7 +35,7 @@ class ProgramSourceAggregator implements InstructionReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void location(InstructionLocation location) {
|
public void location(TextLocation location) {
|
||||||
if (location != null && location.getFileName() != null && !location.getFileName().isEmpty()) {
|
if (location != null && location.getFileName() != null && !location.getFileName().isEmpty()) {
|
||||||
sourceFiles.add(location.getFileName());
|
sourceFiles.add(location.getFileName());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user