Skip to content

Commit

Permalink
Fixed some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
CheaterCodes committed Nov 23, 2021
1 parent 0a4b202 commit 20c4519
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/main/java/org/quiltmc/chasm/internal/LazyClassNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ public LazyClassNode(ClassReader reader) {
public MapNode copy() {
LazyClassNode copy = new LazyClassNode(classReader);
copy.metadataProvider = metadataProvider.copy();

for (Entry<String, Node> entry : nonLazyChildren.entrySet()) {
copy.nonLazyChildren.put(entry.getKey(), entry.getValue().copy());
}

return copy;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import org.quiltmc.chasm.api.Transformation;
import org.quiltmc.chasm.api.Transformer;
import org.quiltmc.chasm.api.tree.ValueNode;

public class TopologicalSorter {
public static List<List<Transformer>> sortTransformers(List<Transformer> transformers) {
Expand Down Expand Up @@ -78,6 +79,10 @@ public static <T> List<List<T>> sort(List<T> list, DependencyProvider<T> depende
// Determine dependencies
for (Vertex<T> first : toSort) {
for (Vertex<T> second : toSort) {
if (first == second) {
continue;
}

Dependency dependency = dependencyProvider.get(first.getValue(), second.getValue());
if (dependency == Dependency.STRONG) {
first.addDependency(second);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public AnnotationVisitor visitAnnotation(String descriptor, boolean visible) {
ListNode values = new LinkedListNode();
annotation.put(NodeConstants.DESCRIPTOR, new ValueNode<>(descriptor));
annotation.put(NodeConstants.VISIBLE, new ValueNode<>(visible));
annotation.put(NodeConstants.VALUES, new ValueNode<>(values));
annotation.put(NodeConstants.VALUES, values);
annotations.add(annotation);

return new ChasmAnnotationVisitor(api, values);
Expand All @@ -40,7 +40,7 @@ public AnnotationVisitor visitTypeAnnotation(int typeRef, TypePath typePath, Str
ListNode values = new LinkedListNode();
annotation.put(NodeConstants.DESCRIPTOR, new ValueNode<>(descriptor));
annotation.put(NodeConstants.VISIBLE, new ValueNode<>(visible));
annotation.put(NodeConstants.VALUES, new ValueNode<>(values));
annotation.put(NodeConstants.VALUES, values);
annotation.put(NodeConstants.TYPE_REF, new ValueNode<>(typeRef));
annotation.put(NodeConstants.TYPE_PATH, new ValueNode<>(typePath.toString()));
annotations.add(annotation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.ArrayList;
import java.util.Objects;
import java.util.stream.Collectors;

import org.quiltmc.chasm.api.tree.ListNode;
import org.quiltmc.chasm.api.tree.MapNode;
Expand Down Expand Up @@ -46,7 +47,7 @@ public boolean startsWith(PathMetadata other) {
}

for (int i = 0; i < other.size(); i++) {
if (this.get(i).equals(other.get(i))) {
if (!this.get(i).equals(other.get(i))) {
return false;
}
}
Expand All @@ -69,6 +70,11 @@ public Node resolve(Node root) {
return current;
}

@Override
public String toString() {
return String.join("/", this.stream().map(e -> e.value.toString()).toArray(String[]::new));
}

public static class Entry {
private final Object value;

Expand Down

0 comments on commit 20c4519

Please sign in to comment.