From 1be9ffb19efe94213b88ebeeecbdb497bb1fa6de Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Sat, 20 Aug 2016 13:45:27 +0300 Subject: [PATCH] Rename InstructionLocation to TextLocation. Replace NodeLocation by TextLocation --- .../org/teavm/ast/AssignmentStatement.java | 11 ++--- .../java/org/teavm/ast/BreakStatement.java | 8 ++-- .../java/org/teavm/ast/ContinueStatement.java | 12 +++--- core/src/main/java/org/teavm/ast/Expr.java | 8 ++-- .../org/teavm/ast/InitClassStatement.java | 12 +++--- .../org/teavm/ast/MonitorEnterStatement.java | 12 +++--- .../org/teavm/ast/MonitorExitStatement.java | 12 +++--- .../main/java/org/teavm/ast/NodeLocation.java | 38 ----------------- .../java/org/teavm/ast/ReturnStatement.java | 12 +++--- .../main/java/org/teavm/ast/Statement.java | 4 -- .../java/org/teavm/ast/ThrowStatement.java | 12 +++--- .../teavm/ast/decompilation/Decompiler.java | 9 ++-- .../ast/decompilation/StatementGenerator.java | 6 +-- core/src/main/java/org/teavm/cache/AstIO.java | 10 ++--- .../main/java/org/teavm/cache/ProgramIO.java | 6 +-- .../java/org/teavm/callgraph/CallSite.java | 4 +- .../org/teavm/callgraph/ClassAccessSite.java | 4 +- .../teavm/callgraph/DefaultCallGraphNode.java | 8 ++-- .../org/teavm/callgraph/DefaultCallSite.java | 8 ++-- .../callgraph/DefaultClassAccessSite.java | 8 ++-- .../callgraph/DefaultFieldAccessSite.java | 8 ++-- .../org/teavm/callgraph/FieldAccessSite.java | 4 +- .../dependency/DataFlowGraphBuilder.java | 2 +- .../teavm/dependency/DependencyChecker.java | 4 +- .../dependency/DependencyGraphBuilder.java | 10 ++--- .../DefaultProblemTextConsumer.java | 4 +- .../java/org/teavm/diagnostics/Problem.java | 4 +- .../diagnostics/ProblemTextConsumer.java | 4 +- .../java/org/teavm/javascript/Renderer.java | 8 ++-- .../javascript/backend/JavaScriptTarget.java | 8 ++-- .../main/java/org/teavm/model/BasicBlock.java | 2 +- .../java/org/teavm/model/CallLocation.java | 10 ++--- .../java/org/teavm/model/Instruction.java | 6 +-- .../java/org/teavm/model/Interpreter.java | 2 +- ...ructionLocation.java => TextLocation.java} | 12 ++---- .../org/teavm/model/emit/ProgramEmitter.java | 8 ++-- .../model/instructions/InstructionReader.java | 2 +- .../teavm/model/util/AsyncMethodFinder.java | 2 +- .../model/util/InstructionCopyReader.java | 6 +-- .../model/util/InstructionStringifier.java | 6 +-- .../org/teavm/model/util/ListingBuilder.java | 2 +- .../model/util/LocationGraphBuilder.java | 42 +++++++++---------- .../model/util/MissingItemsProcessor.java | 10 ++--- .../org/teavm/model/util/ProgramUtils.java | 4 +- .../org/teavm/model/util/TypeInferer.java | 2 +- .../java/org/teavm/parsing/ProgramParser.java | 4 +- .../wasm/generate/WasmGenerationVisitor.java | 13 +++--- .../wasm/model/expression/WasmExpression.java | 8 ++-- .../org/teavm/jso/impl/JSClassProcessor.java | 20 ++++----- .../metaprogramming/impl/AliasFinder.java | 4 +- .../impl/CompositeMethodGenerator.java | 8 ++-- .../metaprogramming/impl/LazyValueImpl.java | 6 +-- .../impl/MetaprogrammingImpl.java | 4 +- .../tooling/InstructionLocationReader.java | 2 +- .../teavm/tooling/TeaVMProblemRenderer.java | 4 +- .../sources/ProgramSourceAggregator.java | 2 +- 56 files changed, 192 insertions(+), 259 deletions(-) delete mode 100644 core/src/main/java/org/teavm/ast/NodeLocation.java rename core/src/main/java/org/teavm/model/{InstructionLocation.java => TextLocation.java} (85%) diff --git a/core/src/main/java/org/teavm/ast/AssignmentStatement.java b/core/src/main/java/org/teavm/ast/AssignmentStatement.java index 0923a8f83..fc02e6f03 100644 --- a/core/src/main/java/org/teavm/ast/AssignmentStatement.java +++ b/core/src/main/java/org/teavm/ast/AssignmentStatement.java @@ -17,15 +17,12 @@ package org.teavm.ast; import java.util.HashSet; import java.util.Set; +import org.teavm.model.TextLocation; -/** - * - * @author Alexey Andreev - */ public class AssignmentStatement extends Statement { private Expr leftValue; private Expr rightValue; - private NodeLocation location; + private TextLocation location; private Set debugNames = new HashSet<>(); private boolean async; @@ -45,11 +42,11 @@ public class AssignmentStatement extends Statement { this.rightValue = rightValue; } - public NodeLocation getLocation() { + public TextLocation getLocation() { return location; } - public void setLocation(NodeLocation location) { + public void setLocation(TextLocation location) { this.location = location; } diff --git a/core/src/main/java/org/teavm/ast/BreakStatement.java b/core/src/main/java/org/teavm/ast/BreakStatement.java index cfcb54ae7..eab5f133f 100644 --- a/core/src/main/java/org/teavm/ast/BreakStatement.java +++ b/core/src/main/java/org/teavm/ast/BreakStatement.java @@ -15,9 +15,11 @@ */ package org.teavm.ast; +import org.teavm.model.TextLocation; + public class BreakStatement extends Statement { private IdentifiedStatement target; - private NodeLocation location; + private TextLocation location; public IdentifiedStatement getTarget() { return target; @@ -27,11 +29,11 @@ public class BreakStatement extends Statement { this.target = target; } - public NodeLocation getLocation() { + public TextLocation getLocation() { return location; } - public void setLocation(NodeLocation location) { + public void setLocation(TextLocation location) { this.location = location; } diff --git a/core/src/main/java/org/teavm/ast/ContinueStatement.java b/core/src/main/java/org/teavm/ast/ContinueStatement.java index 212f04248..22ac7640c 100644 --- a/core/src/main/java/org/teavm/ast/ContinueStatement.java +++ b/core/src/main/java/org/teavm/ast/ContinueStatement.java @@ -15,13 +15,11 @@ */ package org.teavm.ast; -/** - * - * @author Alexey Andreev - */ +import org.teavm.model.TextLocation; + public class ContinueStatement extends Statement { private IdentifiedStatement target; - private NodeLocation location; + private TextLocation location; public IdentifiedStatement getTarget() { return target; @@ -31,11 +29,11 @@ public class ContinueStatement extends Statement { this.target = target; } - public NodeLocation getLocation() { + public TextLocation getLocation() { return location; } - public void setLocation(NodeLocation location) { + public void setLocation(TextLocation location) { this.location = location; } diff --git a/core/src/main/java/org/teavm/ast/Expr.java b/core/src/main/java/org/teavm/ast/Expr.java index d2dad0f31..3e5f42220 100644 --- a/core/src/main/java/org/teavm/ast/Expr.java +++ b/core/src/main/java/org/teavm/ast/Expr.java @@ -21,7 +21,7 @@ import java.util.Map; import org.teavm.model.*; public abstract class Expr implements Cloneable { - private NodeLocation location; + private TextLocation location; public abstract void acceptVisitor(ExprVisitor visitor); @@ -53,7 +53,7 @@ public abstract class Expr implements Cloneable { 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.setLocation(loc); return expr; @@ -151,11 +151,11 @@ public abstract class Expr implements Cloneable { return expr; } - public NodeLocation getLocation() { + public TextLocation getLocation() { return location; } - public void setLocation(NodeLocation location) { + public void setLocation(TextLocation location) { this.location = location; } } diff --git a/core/src/main/java/org/teavm/ast/InitClassStatement.java b/core/src/main/java/org/teavm/ast/InitClassStatement.java index 08a6f4fe4..41fd9cde1 100644 --- a/core/src/main/java/org/teavm/ast/InitClassStatement.java +++ b/core/src/main/java/org/teavm/ast/InitClassStatement.java @@ -15,12 +15,10 @@ */ package org.teavm.ast; -/** - * - * @author Alexey Andreev - */ +import org.teavm.model.TextLocation; + public class InitClassStatement extends Statement { - private NodeLocation location; + private TextLocation location; private String className; public String getClassName() { @@ -31,11 +29,11 @@ public class InitClassStatement extends Statement { this.className = className; } - public NodeLocation getLocation() { + public TextLocation getLocation() { return location; } - public void setLocation(NodeLocation location) { + public void setLocation(TextLocation location) { this.location = location; } diff --git a/core/src/main/java/org/teavm/ast/MonitorEnterStatement.java b/core/src/main/java/org/teavm/ast/MonitorEnterStatement.java index 2f6ec53b0..9733e18fd 100644 --- a/core/src/main/java/org/teavm/ast/MonitorEnterStatement.java +++ b/core/src/main/java/org/teavm/ast/MonitorEnterStatement.java @@ -15,12 +15,10 @@ */ package org.teavm.ast; -/** - * - * @author shannah - */ +import org.teavm.model.TextLocation; + public class MonitorEnterStatement extends Statement { - private NodeLocation location; + private TextLocation location; private Expr objectRef; @Override @@ -28,11 +26,11 @@ public class MonitorEnterStatement extends Statement { visitor.visit(this); } - public NodeLocation getLocation() { + public TextLocation getLocation() { return location; } - public void setLocation(NodeLocation location) { + public void setLocation(TextLocation location) { this.location = location; } diff --git a/core/src/main/java/org/teavm/ast/MonitorExitStatement.java b/core/src/main/java/org/teavm/ast/MonitorExitStatement.java index f749345f3..872ba6d67 100644 --- a/core/src/main/java/org/teavm/ast/MonitorExitStatement.java +++ b/core/src/main/java/org/teavm/ast/MonitorExitStatement.java @@ -15,12 +15,10 @@ */ package org.teavm.ast; -/** - * - * @author shannah - */ +import org.teavm.model.TextLocation; + public class MonitorExitStatement extends Statement { - private NodeLocation location; + private TextLocation location; private Expr objectRef; @Override @@ -28,11 +26,11 @@ public class MonitorExitStatement extends Statement { visitor.visit(this); } - public NodeLocation getLocation() { + public TextLocation getLocation() { return location; } - public void setLocation(NodeLocation location) { + public void setLocation(TextLocation location) { this.location = location; } diff --git a/core/src/main/java/org/teavm/ast/NodeLocation.java b/core/src/main/java/org/teavm/ast/NodeLocation.java deleted file mode 100644 index 741e305f4..000000000 --- a/core/src/main/java/org/teavm/ast/NodeLocation.java +++ /dev/null @@ -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; - } -} diff --git a/core/src/main/java/org/teavm/ast/ReturnStatement.java b/core/src/main/java/org/teavm/ast/ReturnStatement.java index e0a37a5bc..7750211ab 100644 --- a/core/src/main/java/org/teavm/ast/ReturnStatement.java +++ b/core/src/main/java/org/teavm/ast/ReturnStatement.java @@ -15,13 +15,11 @@ */ package org.teavm.ast; -/** - * - * @author Alexey Andreev - */ +import org.teavm.model.TextLocation; + public class ReturnStatement extends Statement { private Expr result; - private NodeLocation location; + private TextLocation location; public Expr getResult() { return result; @@ -31,11 +29,11 @@ public class ReturnStatement extends Statement { this.result = result; } - public NodeLocation getLocation() { + public TextLocation getLocation() { return location; } - public void setLocation(NodeLocation location) { + public void setLocation(TextLocation location) { this.location = location; } diff --git a/core/src/main/java/org/teavm/ast/Statement.java b/core/src/main/java/org/teavm/ast/Statement.java index 0839be8e7..d99758155 100644 --- a/core/src/main/java/org/teavm/ast/Statement.java +++ b/core/src/main/java/org/teavm/ast/Statement.java @@ -18,10 +18,6 @@ package org.teavm.ast; import java.util.Collections; import java.util.List; -/** - * - * @author Alexey Andreev - */ public abstract class Statement { public abstract void acceptVisitor(StatementVisitor visitor); diff --git a/core/src/main/java/org/teavm/ast/ThrowStatement.java b/core/src/main/java/org/teavm/ast/ThrowStatement.java index c1565cdea..7f1e0dda0 100644 --- a/core/src/main/java/org/teavm/ast/ThrowStatement.java +++ b/core/src/main/java/org/teavm/ast/ThrowStatement.java @@ -15,13 +15,11 @@ */ package org.teavm.ast; -/** - * - * @author Alexey Andreev - */ +import org.teavm.model.TextLocation; + public class ThrowStatement extends Statement { private Expr exception; - private NodeLocation location; + private TextLocation location; public Expr getException() { return exception; @@ -31,11 +29,11 @@ public class ThrowStatement extends Statement { this.exception = exception; } - public NodeLocation getLocation() { + public TextLocation getLocation() { return location; } - public void setLocation(NodeLocation location) { + public void setLocation(TextLocation location) { this.location = location; } diff --git a/core/src/main/java/org/teavm/ast/decompilation/Decompiler.java b/core/src/main/java/org/teavm/ast/decompilation/Decompiler.java index fee4d67ca..0878aed82 100644 --- a/core/src/main/java/org/teavm/ast/decompilation/Decompiler.java +++ b/core/src/main/java/org/teavm/ast/decompilation/Decompiler.java @@ -37,7 +37,6 @@ import org.teavm.ast.GotoPartStatement; import org.teavm.ast.IdentifiedStatement; import org.teavm.ast.MethodNode; import org.teavm.ast.NativeMethodNode; -import org.teavm.ast.NodeLocation; import org.teavm.ast.NodeModifier; import org.teavm.ast.RegularMethodNode; import org.teavm.ast.SequentialStatement; @@ -62,7 +61,7 @@ import org.teavm.model.ClassHolderSource; import org.teavm.model.ElementModifier; import org.teavm.model.FieldHolder; import org.teavm.model.Instruction; -import org.teavm.model.InstructionLocation; +import org.teavm.model.TextLocation; import org.teavm.model.MethodHolder; import org.teavm.model.MethodReference; import org.teavm.model.Program; @@ -456,17 +455,15 @@ public class Decompiler { if (node >= 0) { generator.statements.clear(); - InstructionLocation lastLocation = null; - NodeLocation nodeLocation = null; + TextLocation lastLocation = null; List instructions = generator.currentBlock.getInstructions(); for (int j = 0; j < instructions.size(); ++j) { Instruction insn = generator.currentBlock.getInstructions().get(j); if (insn.getLocation() != null && lastLocation != insn.getLocation()) { lastLocation = insn.getLocation(); - nodeLocation = new NodeLocation(lastLocation.getFileName(), lastLocation.getLine()); } if (insn.getLocation() != null) { - generator.setCurrentLocation(nodeLocation); + generator.setCurrentLocation(lastLocation); } insn.acceptVisitor(generator); } diff --git a/core/src/main/java/org/teavm/ast/decompilation/StatementGenerator.java b/core/src/main/java/org/teavm/ast/decompilation/StatementGenerator.java index 2ffdf8031..5a2899456 100644 --- a/core/src/main/java/org/teavm/ast/decompilation/StatementGenerator.java +++ b/core/src/main/java/org/teavm/ast/decompilation/StatementGenerator.java @@ -31,7 +31,6 @@ import org.teavm.ast.InitClassStatement; import org.teavm.ast.InvocationExpr; import org.teavm.ast.MonitorEnterStatement; import org.teavm.ast.MonitorExitStatement; -import org.teavm.ast.NodeLocation; import org.teavm.ast.OperationType; import org.teavm.ast.PrimitiveCastExpr; import org.teavm.ast.ReturnStatement; @@ -48,6 +47,7 @@ import org.teavm.model.InvokeDynamicInstruction; import org.teavm.model.MethodDescriptor; import org.teavm.model.MethodReference; import org.teavm.model.Program; +import org.teavm.model.TextLocation; import org.teavm.model.ValueType; import org.teavm.model.Variable; import org.teavm.model.instructions.ArrayElementType; @@ -101,10 +101,10 @@ class StatementGenerator implements InstructionVisitor { Decompiler.Block[] blockMap; Program program; ClassHolderSource classSource; - private NodeLocation currentLocation; + private TextLocation currentLocation; boolean async; - void setCurrentLocation(NodeLocation currentLocation) { + void setCurrentLocation(TextLocation currentLocation) { this.currentLocation = currentLocation; } diff --git a/core/src/main/java/org/teavm/cache/AstIO.java b/core/src/main/java/org/teavm/cache/AstIO.java index d358b2c6a..db67b352f 100644 --- a/core/src/main/java/org/teavm/cache/AstIO.java +++ b/core/src/main/java/org/teavm/cache/AstIO.java @@ -51,7 +51,6 @@ import org.teavm.ast.MonitorExitStatement; import org.teavm.ast.NewArrayExpr; import org.teavm.ast.NewExpr; import org.teavm.ast.NewMultiArrayExpr; -import org.teavm.ast.NodeLocation; import org.teavm.ast.NodeModifier; import org.teavm.ast.OperationType; import org.teavm.ast.PrimitiveCastExpr; @@ -75,6 +74,7 @@ import org.teavm.ast.WhileStatement; import org.teavm.model.FieldReference; import org.teavm.model.MethodDescriptor; import org.teavm.model.MethodReference; +import org.teavm.model.TextLocation; import org.teavm.model.ValueType; import org.teavm.model.instructions.ArrayElementType; import org.teavm.model.util.VariableType; @@ -227,7 +227,7 @@ public class AstIO { expr.acceptVisitor(this); } - private void writeLocation(NodeLocation location) throws IOException { + private void writeLocation(TextLocation location) throws IOException { if (location == null || location.getFileName() == null) { output.writeShort(-1); } 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(); if (fileIndex == -1) { return null; } 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 { - NodeLocation location = readLocation(input); + TextLocation location = readLocation(input); Expr expr = readExprWithoutLocation(input); expr.setLocation(location); return expr; diff --git a/core/src/main/java/org/teavm/cache/ProgramIO.java b/core/src/main/java/org/teavm/cache/ProgramIO.java index 53c2c7d5b..fd8278f61 100644 --- a/core/src/main/java/org/teavm/cache/ProgramIO.java +++ b/core/src/main/java/org/teavm/cache/ProgramIO.java @@ -75,7 +75,7 @@ public class ProgramIO { } } } - InstructionLocation location = null; + TextLocation location = null; InstructionWriter insnWriter = new InstructionWriter(data); for (Instruction insn : basicBlock.getInstructions()) { try { @@ -158,7 +158,7 @@ public class ProgramIO { block.getTryCatchBlocks().add(tryCatch); } - InstructionLocation location = null; + TextLocation location = null; insnLoop: while (true) { byte insnType = data.readByte(); switch (insnType) { @@ -170,7 +170,7 @@ public class ProgramIO { case -3: { String file = fileTable.at(data.readShort()); short line = data.readShort(); - location = new InstructionLocation(file, line); + location = new TextLocation(file, line); break; } default: { diff --git a/core/src/main/java/org/teavm/callgraph/CallSite.java b/core/src/main/java/org/teavm/callgraph/CallSite.java index b5282ca4b..bcf942681 100644 --- a/core/src/main/java/org/teavm/callgraph/CallSite.java +++ b/core/src/main/java/org/teavm/callgraph/CallSite.java @@ -15,7 +15,7 @@ */ package org.teavm.callgraph; -import org.teavm.model.InstructionLocation; +import org.teavm.model.TextLocation; /** *

Call site that represents exact place in the code that calls a method.

. @@ -27,7 +27,7 @@ public interface CallSite { * * @return location of the call site or null if no debug information found for this call site. */ - InstructionLocation getLocation(); + TextLocation getLocation(); /** *

Gets a method that this call site invokes.

diff --git a/core/src/main/java/org/teavm/callgraph/ClassAccessSite.java b/core/src/main/java/org/teavm/callgraph/ClassAccessSite.java index 51bbb2528..4fc8cce1f 100644 --- a/core/src/main/java/org/teavm/callgraph/ClassAccessSite.java +++ b/core/src/main/java/org/teavm/callgraph/ClassAccessSite.java @@ -15,14 +15,14 @@ */ package org.teavm.callgraph; -import org.teavm.model.InstructionLocation; +import org.teavm.model.TextLocation; /** * * @author Alexey Andreev */ public interface ClassAccessSite { - InstructionLocation getLocation(); + TextLocation getLocation(); CallGraphNode getCallee(); diff --git a/core/src/main/java/org/teavm/callgraph/DefaultCallGraphNode.java b/core/src/main/java/org/teavm/callgraph/DefaultCallGraphNode.java index 421a1efc8..55415a788 100644 --- a/core/src/main/java/org/teavm/callgraph/DefaultCallGraphNode.java +++ b/core/src/main/java/org/teavm/callgraph/DefaultCallGraphNode.java @@ -17,7 +17,7 @@ package org.teavm.callgraph; import java.util.*; import org.teavm.model.FieldReference; -import org.teavm.model.InstructionLocation; +import org.teavm.model.TextLocation; import org.teavm.model.MethodReference; /** @@ -67,7 +67,7 @@ public class DefaultCallGraphNode implements CallGraphNode { return safeCallersCallSites; } - public boolean addCallSite(MethodReference method, InstructionLocation location) { + public boolean addCallSite(MethodReference method, TextLocation location) { DefaultCallGraphNode callee = graph.getNode(method); DefaultCallSite callSite = new DefaultCallSite(location, callee, this); if (callSites.add(callSite)) { @@ -90,7 +90,7 @@ public class DefaultCallGraphNode implements CallGraphNode { return safeFieldAccessSites; } - public boolean addFieldAccess(FieldReference field, InstructionLocation location) { + public boolean addFieldAccess(FieldReference field, TextLocation location) { DefaultFieldAccessSite site = new DefaultFieldAccessSite(location, this, field); if (fieldAccessSites.add(site)) { graph.addFieldAccess(site); @@ -108,7 +108,7 @@ public class DefaultCallGraphNode implements CallGraphNode { return safeClassAccessSites; } - public boolean addClassAccess(String className, InstructionLocation location) { + public boolean addClassAccess(String className, TextLocation location) { DefaultClassAccessSite site = new DefaultClassAccessSite(location, this, className); if (classAccessSites.add(site)) { graph.addClassAccess(site); diff --git a/core/src/main/java/org/teavm/callgraph/DefaultCallSite.java b/core/src/main/java/org/teavm/callgraph/DefaultCallSite.java index 404bdde58..6cb40f152 100644 --- a/core/src/main/java/org/teavm/callgraph/DefaultCallSite.java +++ b/core/src/main/java/org/teavm/callgraph/DefaultCallSite.java @@ -16,25 +16,25 @@ package org.teavm.callgraph; import java.util.Objects; -import org.teavm.model.InstructionLocation; +import org.teavm.model.TextLocation; /** * * @author Alexey Andreev */ public class DefaultCallSite implements CallSite { - private InstructionLocation location; + private TextLocation location; private DefaultCallGraphNode callee; private DefaultCallGraphNode caller; - DefaultCallSite(InstructionLocation location, DefaultCallGraphNode callee, DefaultCallGraphNode caller) { + DefaultCallSite(TextLocation location, DefaultCallGraphNode callee, DefaultCallGraphNode caller) { this.location = location; this.callee = callee; this.caller = caller; } @Override - public InstructionLocation getLocation() { + public TextLocation getLocation() { return location; } diff --git a/core/src/main/java/org/teavm/callgraph/DefaultClassAccessSite.java b/core/src/main/java/org/teavm/callgraph/DefaultClassAccessSite.java index 98da28dd8..85da4fdfa 100644 --- a/core/src/main/java/org/teavm/callgraph/DefaultClassAccessSite.java +++ b/core/src/main/java/org/teavm/callgraph/DefaultClassAccessSite.java @@ -16,25 +16,25 @@ package org.teavm.callgraph; import java.util.Objects; -import org.teavm.model.InstructionLocation; +import org.teavm.model.TextLocation; /** * * @author Alexey Andreev */ public class DefaultClassAccessSite implements ClassAccessSite { - private InstructionLocation location; + private TextLocation location; private CallGraphNode callee; private String className; - DefaultClassAccessSite(InstructionLocation location, CallGraphNode callee, String className) { + DefaultClassAccessSite(TextLocation location, CallGraphNode callee, String className) { this.location = location; this.callee = callee; this.className = className; } @Override - public InstructionLocation getLocation() { + public TextLocation getLocation() { return location; } diff --git a/core/src/main/java/org/teavm/callgraph/DefaultFieldAccessSite.java b/core/src/main/java/org/teavm/callgraph/DefaultFieldAccessSite.java index 4d4c91c7b..21cb13f18 100644 --- a/core/src/main/java/org/teavm/callgraph/DefaultFieldAccessSite.java +++ b/core/src/main/java/org/teavm/callgraph/DefaultFieldAccessSite.java @@ -17,25 +17,25 @@ package org.teavm.callgraph; import java.util.Objects; import org.teavm.model.FieldReference; -import org.teavm.model.InstructionLocation; +import org.teavm.model.TextLocation; /** * * @author Alexey Andreev */ public class DefaultFieldAccessSite implements FieldAccessSite { - private InstructionLocation location; + private TextLocation location; private CallGraphNode callee; private FieldReference field; - DefaultFieldAccessSite(InstructionLocation location, CallGraphNode callee, FieldReference field) { + DefaultFieldAccessSite(TextLocation location, CallGraphNode callee, FieldReference field) { this.location = location; this.callee = callee; this.field = field; } @Override - public InstructionLocation getLocation() { + public TextLocation getLocation() { return null; } diff --git a/core/src/main/java/org/teavm/callgraph/FieldAccessSite.java b/core/src/main/java/org/teavm/callgraph/FieldAccessSite.java index 938a8721f..b68810247 100644 --- a/core/src/main/java/org/teavm/callgraph/FieldAccessSite.java +++ b/core/src/main/java/org/teavm/callgraph/FieldAccessSite.java @@ -16,14 +16,14 @@ package org.teavm.callgraph; import org.teavm.model.FieldReference; -import org.teavm.model.InstructionLocation; +import org.teavm.model.TextLocation; /** * * @author Alexey Andreev */ public interface FieldAccessSite { - InstructionLocation getLocation(); + TextLocation getLocation(); CallGraphNode getCallee(); diff --git a/core/src/main/java/org/teavm/dependency/DataFlowGraphBuilder.java b/core/src/main/java/org/teavm/dependency/DataFlowGraphBuilder.java index 339362cc3..018538cf4 100644 --- a/core/src/main/java/org/teavm/dependency/DataFlowGraphBuilder.java +++ b/core/src/main/java/org/teavm/dependency/DataFlowGraphBuilder.java @@ -128,7 +128,7 @@ public class DataFlowGraphBuilder implements InstructionReader { } @Override - public void location(InstructionLocation location) { + public void location(TextLocation location) { } @Override diff --git a/core/src/main/java/org/teavm/dependency/DependencyChecker.java b/core/src/main/java/org/teavm/dependency/DependencyChecker.java index e9cd537fb..f8f68a223 100644 --- a/core/src/main/java/org/teavm/dependency/DependencyChecker.java +++ b/core/src/main/java/org/teavm/dependency/DependencyChecker.java @@ -42,7 +42,7 @@ import org.teavm.model.ElementModifier; import org.teavm.model.FieldHolder; import org.teavm.model.FieldReader; import org.teavm.model.FieldReference; -import org.teavm.model.InstructionLocation; +import org.teavm.model.TextLocation; import org.teavm.model.MethodDescriptor; import org.teavm.model.MethodHolder; import org.teavm.model.MethodReader; @@ -273,7 +273,7 @@ public class DependencyChecker implements DependencyInfo { 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)) { return false; } diff --git a/core/src/main/java/org/teavm/dependency/DependencyGraphBuilder.java b/core/src/main/java/org/teavm/dependency/DependencyGraphBuilder.java index 0145ee2a0..52d5459b1 100644 --- a/core/src/main/java/org/teavm/dependency/DependencyGraphBuilder.java +++ b/core/src/main/java/org/teavm/dependency/DependencyGraphBuilder.java @@ -33,7 +33,7 @@ import org.teavm.model.FieldReference; import org.teavm.model.Incoming; import org.teavm.model.IncomingReader; import org.teavm.model.Instruction; -import org.teavm.model.InstructionLocation; +import org.teavm.model.TextLocation; import org.teavm.model.InvokeDynamicInstruction; import org.teavm.model.MethodDescriptor; import org.teavm.model.MethodHandle; @@ -73,7 +73,7 @@ class DependencyGraphBuilder { private DependencyNode resultNode; private Program program; private DefaultCallGraphNode caller; - private InstructionLocation currentLocation; + private TextLocation currentLocation; private ExceptionConsumer currentExceptionConsumer; public DependencyGraphBuilder(DependencyChecker dependencyChecker) { @@ -334,13 +334,13 @@ class DependencyGraphBuilder { private final DependencyNode[] parameters; private final DependencyNode result; private final DefaultCallGraphNode caller; - private final InstructionLocation location; + private final TextLocation location; private final Set knownMethods = new HashSet<>(); private ExceptionConsumer exceptionConsumer; public VirtualCallConsumer(DependencyNode node, ClassReader filterClass, MethodDescriptor methodDesc, DependencyChecker checker, DependencyNode[] parameters, - DependencyNode result, DefaultCallGraphNode caller, InstructionLocation location, + DependencyNode result, DefaultCallGraphNode caller, TextLocation location, ExceptionConsumer exceptionConsumer) { this.node = node; this.filterClass = filterClass; @@ -392,7 +392,7 @@ class DependencyGraphBuilder { private InstructionReader reader = new InstructionReader() { @Override - public void location(InstructionLocation location) { + public void location(TextLocation location) { currentLocation = location; } diff --git a/core/src/main/java/org/teavm/diagnostics/DefaultProblemTextConsumer.java b/core/src/main/java/org/teavm/diagnostics/DefaultProblemTextConsumer.java index 89a708737..5413016b5 100644 --- a/core/src/main/java/org/teavm/diagnostics/DefaultProblemTextConsumer.java +++ b/core/src/main/java/org/teavm/diagnostics/DefaultProblemTextConsumer.java @@ -16,7 +16,7 @@ package org.teavm.diagnostics; import org.teavm.model.FieldReference; -import org.teavm.model.InstructionLocation; +import org.teavm.model.TextLocation; import org.teavm.model.MethodReference; import org.teavm.model.ValueType; @@ -56,7 +56,7 @@ public class DefaultProblemTextConsumer implements ProblemTextConsumer { } @Override - public void appendLocation(InstructionLocation location) { + public void appendLocation(TextLocation location) { sb.append(location); } diff --git a/core/src/main/java/org/teavm/diagnostics/Problem.java b/core/src/main/java/org/teavm/diagnostics/Problem.java index 87ef15bd2..ee35b6996 100644 --- a/core/src/main/java/org/teavm/diagnostics/Problem.java +++ b/core/src/main/java/org/teavm/diagnostics/Problem.java @@ -132,10 +132,10 @@ public class Problem { consumer.appendField((FieldReference) param); break; case LOCATION: - if (!(param instanceof InstructionLocation)) { + if (!(param instanceof TextLocation)) { return index; } - consumer.appendLocation((InstructionLocation) param); + consumer.appendLocation((TextLocation) param); break; } next += 2; diff --git a/core/src/main/java/org/teavm/diagnostics/ProblemTextConsumer.java b/core/src/main/java/org/teavm/diagnostics/ProblemTextConsumer.java index eebf4ac06..fda9160c4 100644 --- a/core/src/main/java/org/teavm/diagnostics/ProblemTextConsumer.java +++ b/core/src/main/java/org/teavm/diagnostics/ProblemTextConsumer.java @@ -16,7 +16,7 @@ package org.teavm.diagnostics; import org.teavm.model.FieldReference; -import org.teavm.model.InstructionLocation; +import org.teavm.model.TextLocation; import org.teavm.model.MethodReference; import org.teavm.model.ValueType; @@ -35,5 +35,5 @@ public interface ProblemTextConsumer { void appendField(FieldReference field); - void appendLocation(InstructionLocation location); + void appendLocation(TextLocation location); } diff --git a/core/src/main/java/org/teavm/javascript/Renderer.java b/core/src/main/java/org/teavm/javascript/Renderer.java index 51886a614..337d80323 100644 --- a/core/src/main/java/org/teavm/javascript/Renderer.java +++ b/core/src/main/java/org/teavm/javascript/Renderer.java @@ -57,7 +57,6 @@ import org.teavm.ast.NativeMethodNode; import org.teavm.ast.NewArrayExpr; import org.teavm.ast.NewExpr; import org.teavm.ast.NewMultiArrayExpr; -import org.teavm.ast.NodeLocation; import org.teavm.ast.NodeModifier; import org.teavm.ast.OperationType; import org.teavm.ast.PrimitiveCastExpr; @@ -101,6 +100,7 @@ import org.teavm.model.MethodDescriptor; import org.teavm.model.MethodHolder; import org.teavm.model.MethodReader; import org.teavm.model.MethodReference; +import org.teavm.model.TextLocation; import org.teavm.model.ValueType; public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext { @@ -141,9 +141,9 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext } private static class LocationStackEntry { - final NodeLocation location; + final TextLocation location; - LocationStackEntry(NodeLocation location) { + LocationStackEntry(TextLocation 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(); if (location != null) { if (prevEntry == null || !location.equals(prevEntry.location)) { diff --git a/core/src/main/java/org/teavm/javascript/backend/JavaScriptTarget.java b/core/src/main/java/org/teavm/javascript/backend/JavaScriptTarget.java index 83fff0e7c..76f0d7178 100644 --- a/core/src/main/java/org/teavm/javascript/backend/JavaScriptTarget.java +++ b/core/src/main/java/org/teavm/javascript/backend/JavaScriptTarget.java @@ -52,7 +52,7 @@ import org.teavm.model.CallLocation; import org.teavm.model.ClassHolder; import org.teavm.model.ClassHolderTransformer; import org.teavm.model.ElementModifier; -import org.teavm.model.InstructionLocation; +import org.teavm.model.TextLocation; import org.teavm.model.ListableClassHolderSource; import org.teavm.model.MethodHolder; import org.teavm.model.MethodReference; @@ -338,8 +338,8 @@ public class JavaScriptTarget implements TeaVMTarget, TeaVMJavaScriptHost { } private void emitCFG(DebugInformationEmitter emitter, Program program) { - Map cfg = ProgramUtils.getLocationCFG(program); - for (Map.Entry entry : cfg.entrySet()) { + Map cfg = ProgramUtils.getLocationCFG(program); + for (Map.Entry entry : cfg.entrySet()) { SourceLocation location = map(entry.getKey()); SourceLocation[] successors = new SourceLocation[entry.getValue().length]; 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) { return null; } diff --git a/core/src/main/java/org/teavm/model/BasicBlock.java b/core/src/main/java/org/teavm/model/BasicBlock.java index e0e52b4aa..7948403d5 100644 --- a/core/src/main/java/org/teavm/model/BasicBlock.java +++ b/core/src/main/java/org/teavm/model/BasicBlock.java @@ -177,7 +177,7 @@ public class BasicBlock implements BasicBlockReader { @Override public void readAllInstructions(InstructionReader reader) { InstructionReadVisitor visitor = new InstructionReadVisitor(reader); - InstructionLocation location = null; + TextLocation location = null; for (Instruction insn : instructions) { if (!Objects.equals(location, insn.getLocation())) { location = insn.getLocation(); diff --git a/core/src/main/java/org/teavm/model/CallLocation.java b/core/src/main/java/org/teavm/model/CallLocation.java index f7b33784a..5c753cd9a 100644 --- a/core/src/main/java/org/teavm/model/CallLocation.java +++ b/core/src/main/java/org/teavm/model/CallLocation.java @@ -17,19 +17,15 @@ package org.teavm.model; import java.util.Objects; -/** - * - * @author Alexey Andreev - */ public class CallLocation { private MethodReference method; - private InstructionLocation sourceLocation; + private TextLocation sourceLocation; public CallLocation(MethodReference method) { this(method, null); } - public CallLocation(MethodReference method, InstructionLocation sourceLocation) { + public CallLocation(MethodReference method, TextLocation sourceLocation) { if (method == null) { throw new IllegalArgumentException("Method must not be null"); } @@ -41,7 +37,7 @@ public class CallLocation { return method; } - public InstructionLocation getSourceLocation() { + public TextLocation getSourceLocation() { return sourceLocation; } diff --git a/core/src/main/java/org/teavm/model/Instruction.java b/core/src/main/java/org/teavm/model/Instruction.java index 4ba442207..f14c01a70 100644 --- a/core/src/main/java/org/teavm/model/Instruction.java +++ b/core/src/main/java/org/teavm/model/Instruction.java @@ -19,7 +19,7 @@ import org.teavm.model.instructions.InstructionVisitor; public abstract class Instruction { private BasicBlock basicBlock; - private InstructionLocation location; + private TextLocation location; void setBasicBlock(BasicBlock basicBlock) { this.basicBlock = basicBlock; @@ -33,11 +33,11 @@ public abstract class Instruction { return basicBlock != null ? basicBlock.getProgram() : null; } - public InstructionLocation getLocation() { + public TextLocation getLocation() { return location; } - public void setLocation(InstructionLocation location) { + public void setLocation(TextLocation location) { this.location = location; } diff --git a/core/src/main/java/org/teavm/model/Interpreter.java b/core/src/main/java/org/teavm/model/Interpreter.java index d4206757a..ec658c9f5 100644 --- a/core/src/main/java/org/teavm/model/Interpreter.java +++ b/core/src/main/java/org/teavm/model/Interpreter.java @@ -121,7 +121,7 @@ public class Interpreter { private Objenesis objenesis = new ObjenesisStd(); @Override - public void location(InstructionLocation location) { + public void location(TextLocation location) { } @Override diff --git a/core/src/main/java/org/teavm/model/InstructionLocation.java b/core/src/main/java/org/teavm/model/TextLocation.java similarity index 85% rename from core/src/main/java/org/teavm/model/InstructionLocation.java rename to core/src/main/java/org/teavm/model/TextLocation.java index d8ade12b0..9995d41ce 100644 --- a/core/src/main/java/org/teavm/model/InstructionLocation.java +++ b/core/src/main/java/org/teavm/model/TextLocation.java @@ -17,15 +17,11 @@ package org.teavm.model; import java.util.Objects; -/** - * - * @author Alexey Andreev - */ -public class InstructionLocation { +public class TextLocation { private String fileName; private int line = -1; - public InstructionLocation(String fileName, int line) { + public TextLocation(String fileName, int line) { this.fileName = fileName; this.line = line; } @@ -52,10 +48,10 @@ public class InstructionLocation { if (this == obj) { return true; } - if (!(obj instanceof InstructionLocation)) { + if (!(obj instanceof TextLocation)) { return false; } - InstructionLocation other = (InstructionLocation) obj; + TextLocation other = (TextLocation) obj; return Objects.equals(fileName, other.fileName) && line == other.line; } diff --git a/core/src/main/java/org/teavm/model/emit/ProgramEmitter.java b/core/src/main/java/org/teavm/model/emit/ProgramEmitter.java index 7bcf5c902..8721c382a 100644 --- a/core/src/main/java/org/teavm/model/emit/ProgramEmitter.java +++ b/core/src/main/java/org/teavm/model/emit/ProgramEmitter.java @@ -21,7 +21,7 @@ import org.teavm.model.ClassReaderSource; import org.teavm.model.FieldReader; import org.teavm.model.FieldReference; import org.teavm.model.Instruction; -import org.teavm.model.InstructionLocation; +import org.teavm.model.TextLocation; import org.teavm.model.MethodDescriptor; import org.teavm.model.MethodHolder; import org.teavm.model.MethodReference; @@ -56,7 +56,7 @@ public final class ProgramEmitter { private Program program; private BasicBlock block; ClassReaderSource classSource; - private InstructionLocation currentLocation; + private TextLocation currentLocation; private ProgramEmitter(Program program, BasicBlock block, ClassReaderSource classSource) { this.program = program; @@ -373,11 +373,11 @@ public final class ProgramEmitter { return var(program.createVariable(), type); } - public InstructionLocation getCurrentLocation() { + public TextLocation getCurrentLocation() { return currentLocation; } - public void setCurrentLocation(InstructionLocation currentLocation) { + public void setCurrentLocation(TextLocation currentLocation) { this.currentLocation = currentLocation; } diff --git a/core/src/main/java/org/teavm/model/instructions/InstructionReader.java b/core/src/main/java/org/teavm/model/instructions/InstructionReader.java index 076c0e6c8..1346dee71 100644 --- a/core/src/main/java/org/teavm/model/instructions/InstructionReader.java +++ b/core/src/main/java/org/teavm/model/instructions/InstructionReader.java @@ -19,7 +19,7 @@ import java.util.List; import org.teavm.model.*; public interface InstructionReader { - void location(InstructionLocation location); + void location(TextLocation location); void nop(); diff --git a/core/src/main/java/org/teavm/model/util/AsyncMethodFinder.java b/core/src/main/java/org/teavm/model/util/AsyncMethodFinder.java index ebdfed648..38065da05 100644 --- a/core/src/main/java/org/teavm/model/util/AsyncMethodFinder.java +++ b/core/src/main/java/org/teavm/model/util/AsyncMethodFinder.java @@ -237,7 +237,7 @@ public class AsyncMethodFinder { boolean async; @Override - public void location(InstructionLocation location) { + public void location(TextLocation location) { } @Override diff --git a/core/src/main/java/org/teavm/model/util/InstructionCopyReader.java b/core/src/main/java/org/teavm/model/util/InstructionCopyReader.java index 2d7d876fe..d9cc2262c 100644 --- a/core/src/main/java/org/teavm/model/util/InstructionCopyReader.java +++ b/core/src/main/java/org/teavm/model/util/InstructionCopyReader.java @@ -21,7 +21,7 @@ import org.teavm.model.BasicBlock; import org.teavm.model.BasicBlockReader; import org.teavm.model.FieldReference; import org.teavm.model.Instruction; -import org.teavm.model.InstructionLocation; +import org.teavm.model.TextLocation; import org.teavm.model.InvokeDynamicInstruction; import org.teavm.model.MethodDescriptor; import org.teavm.model.MethodHandle; @@ -82,7 +82,7 @@ import org.teavm.model.instructions.UnwrapArrayInstruction; public class InstructionCopyReader implements InstructionReader { private Instruction copy; private Program programCopy; - private InstructionLocation location; + private TextLocation location; public InstructionCopyReader(Program programCopy) { this.programCopy = programCopy; @@ -97,7 +97,7 @@ public class InstructionCopyReader implements InstructionReader { } @Override - public void location(InstructionLocation location) { + public void location(TextLocation location) { this.location = location; } diff --git a/core/src/main/java/org/teavm/model/util/InstructionStringifier.java b/core/src/main/java/org/teavm/model/util/InstructionStringifier.java index a9ff79c47..cbfbabc54 100644 --- a/core/src/main/java/org/teavm/model/util/InstructionStringifier.java +++ b/core/src/main/java/org/teavm/model/util/InstructionStringifier.java @@ -26,19 +26,19 @@ import org.teavm.model.instructions.*; * @author Alexey Andreev */ public class InstructionStringifier implements InstructionReader { - private InstructionLocation location; + private TextLocation location; private StringBuilder sb; public InstructionStringifier(StringBuilder sb) { this.sb = sb; } - public InstructionLocation getLocation() { + public TextLocation getLocation() { return location; } @Override - public void location(InstructionLocation location) { + public void location(TextLocation location) { this.location = location; } diff --git a/core/src/main/java/org/teavm/model/util/ListingBuilder.java b/core/src/main/java/org/teavm/model/util/ListingBuilder.java index 545c4dee1..5247c67ae 100644 --- a/core/src/main/java/org/teavm/model/util/ListingBuilder.java +++ b/core/src/main/java/org/teavm/model/util/ListingBuilder.java @@ -67,7 +67,7 @@ public class ListingBuilder { sb.append("\n"); } - InstructionLocation location = null; + TextLocation location = null; for (int j = 0; j < block.instructionCount(); ++j) { insnSb.setLength(0); block.readInstruction(j, stringifier); diff --git a/core/src/main/java/org/teavm/model/util/LocationGraphBuilder.java b/core/src/main/java/org/teavm/model/util/LocationGraphBuilder.java index e41c06fc2..84c2eac4a 100644 --- a/core/src/main/java/org/teavm/model/util/LocationGraphBuilder.java +++ b/core/src/main/java/org/teavm/model/util/LocationGraphBuilder.java @@ -19,7 +19,7 @@ import java.util.*; import org.teavm.common.Graph; import org.teavm.model.BasicBlock; import org.teavm.model.Instruction; -import org.teavm.model.InstructionLocation; +import org.teavm.model.TextLocation; import org.teavm.model.Program; /** @@ -27,11 +27,11 @@ import org.teavm.model.Program; * @author Alexey Andreev */ class LocationGraphBuilder { - private Map> graphBuilder; - private List> startLocations; + private Map> graphBuilder; + private List> startLocations; private List additionalConnections; - public Map build(Program program) { + public Map build(Program program) { graphBuilder = new HashMap<>(); Graph graph = ProgramUtils.buildControlFlowGraph(program); dfs(graph, program); @@ -39,7 +39,7 @@ class LocationGraphBuilder { } private void dfs(Graph graph, Program program) { - startLocations = new ArrayList<>(Collections.>nCopies(graph.size(), null)); + startLocations = new ArrayList<>(Collections.>nCopies(graph.size(), null)); additionalConnections = new ArrayList<>(); Deque stack = new ArrayDeque<>(); for (int i = 0; i < graph.size(); ++i) { @@ -48,7 +48,7 @@ class LocationGraphBuilder { } } boolean[] visited = new boolean[graph.size()]; - InstructionLocation[] blockLocations = new InstructionLocation[graph.size()]; + TextLocation[] blockLocations = new TextLocation[graph.size()]; while (!stack.isEmpty()) { Step step = stack.pop(); @@ -61,7 +61,7 @@ class LocationGraphBuilder { visited[step.block] = true; startLocations.set(step.block, step.startLocations); BasicBlock block = program.basicBlockAt(step.block); - InstructionLocation location = step.location; + TextLocation location = step.location; boolean started = false; for (Instruction insn : block.getInstructions()) { if (insn.getLocation() != null) { @@ -80,7 +80,7 @@ class LocationGraphBuilder { } if (graph.outgoingEdgesCount(step.block) == 0) { if (location != null) { - addEdge(location, new InstructionLocation(null, -1)); + addEdge(location, new TextLocation(null, -1)); } } else { for (int next : graph.outgoingEdges(step.block)) { @@ -90,15 +90,15 @@ class LocationGraphBuilder { } } - private Map assemble() { + private Map assemble() { for (AdditionalConnection additionalConn : additionalConnections) { - for (InstructionLocation succ : additionalConn.successors) { + for (TextLocation succ : additionalConn.successors) { addEdge(additionalConn.location, succ); } } - Map locationGraph = new HashMap<>(); - for (Map.Entry> entry : graphBuilder.entrySet()) { - InstructionLocation[] successors = entry.getValue().toArray(new InstructionLocation[0]); + Map locationGraph = new HashMap<>(); + for (Map.Entry> entry : graphBuilder.entrySet()) { + TextLocation[] successors = entry.getValue().toArray(new TextLocation[0]); for (int i = 0; i < successors.length; ++i) { if (successors[i] != null && successors[i].getLine() < 0) { successors[i] = null; @@ -109,8 +109,8 @@ class LocationGraphBuilder { return locationGraph; } - private void addEdge(InstructionLocation source, InstructionLocation dest) { - Set successors = graphBuilder.get(source); + private void addEdge(TextLocation source, TextLocation dest) { + Set successors = graphBuilder.get(source); if (successors == null) { successors = new HashSet<>(); graphBuilder.put(source, successors); @@ -119,10 +119,10 @@ class LocationGraphBuilder { } static class Step { - InstructionLocation location; - Set startLocations; + TextLocation location; + Set startLocations; int block; - public Step(InstructionLocation location, Set startLocations, int block) { + public Step(TextLocation location, Set startLocations, int block) { this.location = location; this.startLocations = startLocations; this.block = block; @@ -130,9 +130,9 @@ class LocationGraphBuilder { } static class AdditionalConnection { - InstructionLocation location; - Set successors; - public AdditionalConnection(InstructionLocation location, Set successors) { + TextLocation location; + Set successors; + public AdditionalConnection(TextLocation location, Set successors) { this.location = location; this.successors = successors; } diff --git a/core/src/main/java/org/teavm/model/util/MissingItemsProcessor.java b/core/src/main/java/org/teavm/model/util/MissingItemsProcessor.java index d5c42826f..252bc2ff3 100644 --- a/core/src/main/java/org/teavm/model/util/MissingItemsProcessor.java +++ b/core/src/main/java/org/teavm/model/util/MissingItemsProcessor.java @@ -95,7 +95,7 @@ public class MissingItemsProcessor { 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(); ConstructInstruction newExceptionInsn = new ConstructInstruction(); newExceptionInsn.setType(exceptionName); @@ -125,7 +125,7 @@ public class MissingItemsProcessor { 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()) { return true; } @@ -135,7 +135,7 @@ public class MissingItemsProcessor { return false; } - private boolean checkClass(InstructionLocation location, ValueType type) { + private boolean checkClass(TextLocation location, ValueType type) { while (type instanceof ValueType.Array) { type = ((ValueType.Array) type).getItemType(); } @@ -145,7 +145,7 @@ public class MissingItemsProcessor { return true; } - private boolean checkMethod(InstructionLocation location, MethodReference method) { + private boolean checkMethod(TextLocation location, MethodReference method) { if (!checkClass(location, method.getClassName())) { return false; } @@ -158,7 +158,7 @@ public class MissingItemsProcessor { return true; } - private boolean checkField(InstructionLocation location, FieldReference field) { + private boolean checkField(TextLocation location, FieldReference field) { if (!checkClass(location, field.getClassName())) { return false; } diff --git a/core/src/main/java/org/teavm/model/util/ProgramUtils.java b/core/src/main/java/org/teavm/model/util/ProgramUtils.java index 2e0f6002c..9a955f418 100644 --- a/core/src/main/java/org/teavm/model/util/ProgramUtils.java +++ b/core/src/main/java/org/teavm/model/util/ProgramUtils.java @@ -25,7 +25,7 @@ import org.teavm.model.BasicBlockReader; import org.teavm.model.Incoming; import org.teavm.model.IncomingReader; import org.teavm.model.Instruction; -import org.teavm.model.InstructionLocation; +import org.teavm.model.TextLocation; import org.teavm.model.Phi; import org.teavm.model.PhiReader; import org.teavm.model.Program; @@ -62,7 +62,7 @@ public final class ProgramUtils { return graphBuilder.build(); } - public static Map getLocationCFG(Program program) { + public static Map getLocationCFG(Program program) { return new LocationGraphBuilder().build(program); } diff --git a/core/src/main/java/org/teavm/model/util/TypeInferer.java b/core/src/main/java/org/teavm/model/util/TypeInferer.java index 838d44c79..0d75dede7 100644 --- a/core/src/main/java/org/teavm/model/util/TypeInferer.java +++ b/core/src/main/java/org/teavm/model/util/TypeInferer.java @@ -271,7 +271,7 @@ public class TypeInferer { } @Override - public void location(InstructionLocation location) { + public void location(TextLocation location) { } @Override diff --git a/core/src/main/java/org/teavm/parsing/ProgramParser.java b/core/src/main/java/org/teavm/parsing/ProgramParser.java index 89d59ea37..9586023b1 100644 --- a/core/src/main/java/org/teavm/parsing/ProgramParser.java +++ b/core/src/main/java/org/teavm/parsing/ProgramParser.java @@ -269,7 +269,7 @@ public class ProgramParser { BasicBlock basicBlock = null; Map accumulatedDebugNames = new HashMap<>(); Integer lastLineNumber = null; - InstructionLocation lastLocation = null; + TextLocation lastLocation = null; for (int i = 0; i < basicBlocks.size(); ++i) { BasicBlock newBasicBlock = basicBlocks.get(i); if (newBasicBlock != null) { @@ -303,7 +303,7 @@ public class ProgramParser { Integer lineNumber = lineNumbers.get(label); if (lineNumber != null && !lineNumber.equals(lastLineNumber)) { lastLineNumber = lineNumber; - lastLocation = new InstructionLocation(fileName, lastLineNumber); + lastLocation = new TextLocation(fileName, lastLineNumber); } } if (builtInstructions != null) { diff --git a/core/src/main/java/org/teavm/wasm/generate/WasmGenerationVisitor.java b/core/src/main/java/org/teavm/wasm/generate/WasmGenerationVisitor.java index 0ec1c7729..eac0c5294 100644 --- a/core/src/main/java/org/teavm/wasm/generate/WasmGenerationVisitor.java +++ b/core/src/main/java/org/teavm/wasm/generate/WasmGenerationVisitor.java @@ -45,7 +45,6 @@ import org.teavm.ast.MonitorExitStatement; import org.teavm.ast.NewArrayExpr; import org.teavm.ast.NewExpr; import org.teavm.ast.NewMultiArrayExpr; -import org.teavm.ast.NodeLocation; import org.teavm.ast.OperationType; import org.teavm.ast.PrimitiveCastExpr; import org.teavm.ast.QualificationExpr; @@ -65,8 +64,8 @@ import org.teavm.ast.WhileStatement; import org.teavm.interop.Address; import org.teavm.model.CallLocation; import org.teavm.model.FieldReference; -import org.teavm.model.InstructionLocation; import org.teavm.model.MethodReference; +import org.teavm.model.TextLocation; import org.teavm.model.ValueType; import org.teavm.model.classes.TagRegistry; 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); ValueType type = context.getFieldType(field); value.acceptVisitor(this); @@ -800,9 +799,9 @@ class WasmGenerationVisitor implements StatementVisitor, ExprVisitor { VirtualTableEntry vtableEntry = context.getVirtualTableProvider().lookup(expr.getMethod()); if (vtableEntry == null) { result = new WasmInt32Constant(0); - InstructionLocation insnLocation = null; + TextLocation insnLocation = null; if (expr.getLocation() != null) { - insnLocation = new InstructionLocation(expr.getLocation().getFileName(), + insnLocation = new TextLocation(expr.getLocation().getFileName(), expr.getLocation().getLine()); } 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); if (qualified == null) { WasmExpression result = new WasmInt32Constant(offset); @@ -942,7 +941,7 @@ class WasmGenerationVisitor implements StatementVisitor, ExprVisitor { 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)); String allocName = WasmMangling.mangleMethod(new MethodReference(Allocator.class, "allocate", RuntimeClass.class, Address.class)); diff --git a/core/src/main/java/org/teavm/wasm/model/expression/WasmExpression.java b/core/src/main/java/org/teavm/wasm/model/expression/WasmExpression.java index fad08ab08..3b8c893f3 100644 --- a/core/src/main/java/org/teavm/wasm/model/expression/WasmExpression.java +++ b/core/src/main/java/org/teavm/wasm/model/expression/WasmExpression.java @@ -15,19 +15,19 @@ */ package org.teavm.wasm.model.expression; -import org.teavm.ast.NodeLocation; +import org.teavm.model.TextLocation; public abstract class WasmExpression { - private NodeLocation location; + private TextLocation location; WasmExpression() { } - public NodeLocation getLocation() { + public TextLocation getLocation() { return location; } - public void setLocation(NodeLocation location) { + public void setLocation(TextLocation location) { this.location = location; } diff --git a/jso/impl/src/main/java/org/teavm/jso/impl/JSClassProcessor.java b/jso/impl/src/main/java/org/teavm/jso/impl/JSClassProcessor.java index 9985360d0..67ac20bfb 100644 --- a/jso/impl/src/main/java/org/teavm/jso/impl/JSClassProcessor.java +++ b/jso/impl/src/main/java/org/teavm/jso/impl/JSClassProcessor.java @@ -55,7 +55,7 @@ import org.teavm.model.ClassReaderSource; import org.teavm.model.ElementModifier; import org.teavm.model.FieldHolder; import org.teavm.model.Instruction; -import org.teavm.model.InstructionLocation; +import org.teavm.model.TextLocation; import org.teavm.model.MethodDescriptor; import org.teavm.model.MethodHolder; import org.teavm.model.MethodReader; @@ -675,7 +675,7 @@ class JSClassProcessor { } private void addPropertyGet(String propertyName, Variable instance, Variable receiver, - InstructionLocation location) { + TextLocation location) { Variable nameVar = addStringWrap(addString(propertyName, location), location); InvokeInstruction insn = new InvokeInstruction(); insn.setType(InvocationType.SPECIAL); @@ -687,7 +687,7 @@ class JSClassProcessor { 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); InvokeInstruction insn = new InvokeInstruction(); insn.setType(InvocationType.SPECIAL); @@ -700,7 +700,7 @@ class JSClassProcessor { 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(); insn.setType(InvocationType.SPECIAL); insn.setMethod(new MethodReference(JS.class, "get", JSObject.class, JSObject.class, JSObject.class)); @@ -711,7 +711,7 @@ class JSClassProcessor { 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(); insn.setType(InvocationType.SPECIAL); insn.setMethod(new MethodReference(JS.class, "set", JSObject.class, JSObject.class, @@ -723,7 +723,7 @@ class JSClassProcessor { 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(); insn.setAssignee(a); insn.setReceiver(b); @@ -731,11 +731,11 @@ class JSClassProcessor { 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); } - private Variable addString(String str, InstructionLocation location) { + private Variable addString(String str, TextLocation location) { Variable var = program.createVariable(); StringConstantInstruction nameInsn = new StringConstantInstruction(); nameInsn.setReceiver(var); @@ -957,7 +957,7 @@ class JSClassProcessor { } private Variable unwrap(Variable var, String methodName, ValueType argType, ValueType resultType, - InstructionLocation location) { + TextLocation location) { if (!argType.isObject(JSObject.class.getName())) { Variable castValue = program.createVariable(); CastInstruction castInsn = new CastInstruction(); @@ -1013,7 +1013,7 @@ class JSClassProcessor { 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) { String className = ((ValueType.Object) type).getClassName(); if (!className.equals("java.lang.String")) { diff --git a/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/AliasFinder.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/AliasFinder.java index f11c71ad3..925633854 100644 --- a/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/AliasFinder.java +++ b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/AliasFinder.java @@ -22,7 +22,7 @@ import java.util.stream.Collectors; import org.teavm.common.DisjointSet; import org.teavm.model.BasicBlockReader; import org.teavm.model.FieldReference; -import org.teavm.model.InstructionLocation; +import org.teavm.model.TextLocation; import org.teavm.model.MethodDescriptor; import org.teavm.model.MethodHandle; import org.teavm.model.MethodReference; @@ -134,7 +134,7 @@ class AliasFinder { } @Override - public void location(InstructionLocation location) { + public void location(TextLocation location) { } @Override diff --git a/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/CompositeMethodGenerator.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/CompositeMethodGenerator.java index 6918a4451..507ac817c 100644 --- a/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/CompositeMethodGenerator.java +++ b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/CompositeMethodGenerator.java @@ -39,7 +39,7 @@ import org.teavm.model.FieldReference; import org.teavm.model.Incoming; import org.teavm.model.IncomingReader; import org.teavm.model.Instruction; -import org.teavm.model.InstructionLocation; +import org.teavm.model.TextLocation; import org.teavm.model.InvokeDynamicInstruction; import org.teavm.model.MethodDescriptor; import org.teavm.model.MethodHandle; @@ -103,8 +103,8 @@ import org.teavm.model.instructions.UnwrapArrayInstruction; public class CompositeMethodGenerator { private Diagnostics diagnostics; Program program; - InstructionLocation location; - InstructionLocation forcedLocation; + TextLocation location; + TextLocation forcedLocation; int blockIndex; int returnBlockIndex; private Variable resultVar; @@ -467,7 +467,7 @@ public class CompositeMethodGenerator { } @Override - public void location(InstructionLocation location) { + public void location(TextLocation location) { CompositeMethodGenerator.this.location = location; } diff --git a/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/LazyValueImpl.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/LazyValueImpl.java index fe1bb6f0b..514830a55 100644 --- a/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/LazyValueImpl.java +++ b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/LazyValueImpl.java @@ -17,7 +17,7 @@ package org.teavm.metaprogramming.impl; import org.teavm.metaprogramming.LazyComputation; import org.teavm.metaprogramming.Value; -import org.teavm.model.InstructionLocation; +import org.teavm.model.TextLocation; import org.teavm.model.ValueType; public class LazyValueImpl implements Value { @@ -25,10 +25,10 @@ public class LazyValueImpl implements Value { VariableContext context; LazyComputation computation; ValueType type; - InstructionLocation forcedLocation; + TextLocation forcedLocation; public LazyValueImpl(VariableContext context, LazyComputation computation, ValueType type, - InstructionLocation forcedLocation) { + TextLocation forcedLocation) { this.context = context; this.computation = computation; this.type = type; diff --git a/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingImpl.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingImpl.java index 7b23a39ee..3938adcc6 100644 --- a/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingImpl.java +++ b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingImpl.java @@ -39,7 +39,7 @@ import org.teavm.model.ClassHolder; import org.teavm.model.ClassReaderSource; import org.teavm.model.ElementModifier; import org.teavm.model.Instruction; -import org.teavm.model.InstructionLocation; +import org.teavm.model.TextLocation; import org.teavm.model.MethodHolder; import org.teavm.model.MethodReader; import org.teavm.model.MethodReference; @@ -407,7 +407,7 @@ public final class MetaprogrammingImpl { MethodReader method = ((ReflectMethodImpl) location.getMethod()).method; return location.getFileName() != null ? new CallLocation(method.getReference(), - new InstructionLocation(location.getFileName(), location.getLineNumber())) + new TextLocation(location.getFileName(), location.getLineNumber())) : new CallLocation(method.getReference()); } }; diff --git a/tools/core/src/main/java/org/teavm/tooling/InstructionLocationReader.java b/tools/core/src/main/java/org/teavm/tooling/InstructionLocationReader.java index 16d87786b..667f1ed72 100644 --- a/tools/core/src/main/java/org/teavm/tooling/InstructionLocationReader.java +++ b/tools/core/src/main/java/org/teavm/tooling/InstructionLocationReader.java @@ -37,7 +37,7 @@ class InstructionLocationReader implements InstructionReader { } @Override - public void location(InstructionLocation location) { + public void location(TextLocation location) { if (location != null && location.getFileName() != null) { resources.add(location.getFileName()); } diff --git a/tools/core/src/main/java/org/teavm/tooling/TeaVMProblemRenderer.java b/tools/core/src/main/java/org/teavm/tooling/TeaVMProblemRenderer.java index 10cf1e52a..bfcbca450 100644 --- a/tools/core/src/main/java/org/teavm/tooling/TeaVMProblemRenderer.java +++ b/tools/core/src/main/java/org/teavm/tooling/TeaVMProblemRenderer.java @@ -22,7 +22,7 @@ import org.teavm.callgraph.CallSite; import org.teavm.diagnostics.DefaultProblemTextConsumer; import org.teavm.diagnostics.Problem; import org.teavm.model.CallLocation; -import org.teavm.model.InstructionLocation; +import org.teavm.model.TextLocation; import org.teavm.model.MethodReference; 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) { sb.append(method.getClassName() + "." + method.getName()); } else { diff --git a/tools/core/src/main/java/org/teavm/tooling/sources/ProgramSourceAggregator.java b/tools/core/src/main/java/org/teavm/tooling/sources/ProgramSourceAggregator.java index 8466ee2a3..138f1cec7 100644 --- a/tools/core/src/main/java/org/teavm/tooling/sources/ProgramSourceAggregator.java +++ b/tools/core/src/main/java/org/teavm/tooling/sources/ProgramSourceAggregator.java @@ -35,7 +35,7 @@ class ProgramSourceAggregator implements InstructionReader { } @Override - public void location(InstructionLocation location) { + public void location(TextLocation location) { if (location != null && location.getFileName() != null && !location.getFileName().isEmpty()) { sourceFiles.add(location.getFileName()); }