Skip to content

Commit

Permalink
Fixed some things, API is now v1 instead of v0.
Browse files Browse the repository at this point in the history
  • Loading branch information
gudenau committed Nov 4, 2020
1 parent a621a3f commit 7e277a6
Show file tree
Hide file tree
Showing 19 changed files with 224 additions and 180 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ yarn_mappings=1.16.2+build.46:v2
loader_version=0.9.2+build.206

# Mod Properties
mod_version = 0.1.9
mod_version = 0.2.10
maven_group = net.gudenau.minecraft
archives_base_name = gud_asm

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.gudenau.minecraft.asm.api.v0;
package net.gudenau.minecraft.asm.api.v1;

/**
* An ASM mod initializer.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.gudenau.minecraft.asm.api.v0;
package net.gudenau.minecraft.asm.api.v1;

import net.gudenau.minecraft.asm.impl.RegistryImpl;

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.gudenau.minecraft.asm.api.v0;
package net.gudenau.minecraft.asm.api.v1;

import java.io.IOException;
import java.util.Optional;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.gudenau.minecraft.asm.api.v0;
package net.gudenau.minecraft.asm.api.v1;

import java.util.Objects;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.gudenau.minecraft.asm.api.v0;
package net.gudenau.minecraft.asm.api.v1;

import java.util.Objects;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.gudenau.minecraft.asm.api.v0;
package net.gudenau.minecraft.asm.api.v1;

import org.objectweb.asm.tree.ClassNode;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.gudenau.minecraft.asm.api.v0.annotation;
package net.gudenau.minecraft.asm.api.v1.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.gudenau.minecraft.asm.api.v0.annotation;
package net.gudenau.minecraft.asm.api.v1.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.gudenau.minecraft.asm.api.v0.functional;
package net.gudenau.minecraft.asm.api.v1.functional;

/**
* A {@link java.util.function.Function} that returns a boolean.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package net.gudenau.minecraft.asm.api.v0.type;
package net.gudenau.minecraft.asm.api.v1.type;

import java.util.Objects;
import org.jetbrains.annotations.NotNull;
import org.objectweb.asm.Type;

import java.util.Objects;

/**
* A simple field type that contains the fully qualified type of a field.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package net.gudenau.minecraft.asm.api.v0.type;
package net.gudenau.minecraft.asm.api.v1.type;

import java.util.Objects;
import org.jetbrains.annotations.NotNull;
import org.objectweb.asm.Type;

import java.util.Objects;

/**
* A simple method type that contains the fully qualified type of a method.
*
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/gudenau/minecraft/asm/impl/Bootstrap.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import java.lang.invoke.MethodHandle;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.entrypoint.EntrypointContainer;
import net.gudenau.minecraft.asm.api.v0.AsmInitializer;
import net.gudenau.minecraft.asm.api.v0.ClassCache;
import net.gudenau.minecraft.asm.api.v1.AsmInitializer;
import net.gudenau.minecraft.asm.api.v1.ClassCache;
import net.gudenau.minecraft.asm.util.FileUtils;
import org.spongepowered.asm.mixin.MixinEnvironment;
import org.spongepowered.asm.mixin.transformer.FabricMixinTransformerProxy;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package net.gudenau.minecraft.asm.impl;

import java.util.List;
import net.gudenau.minecraft.asm.api.v0.AsmUtils;
import net.gudenau.minecraft.asm.api.v0.Identifier;
import net.gudenau.minecraft.asm.api.v0.Transformer;
import net.gudenau.minecraft.asm.api.v1.AsmUtils;
import net.gudenau.minecraft.asm.api.v1.Identifier;
import net.gudenau.minecraft.asm.api.v1.Transformer;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.AnnotationNode;
import org.objectweb.asm.tree.ClassNode;
Expand All @@ -27,7 +27,6 @@ public class BootstrapTransformer implements Transformer{
ENABLED = enable;
}

private static final AsmUtils ASM_UTILS = AsmUtils.getInstance();
private static final Type FORCEBOOTLOADER = Type.getObjectType("net/gudenau/minecraft/asm/api/v0/annotation/ForceBootloader");
private static final Type ASM_FORCEINLINE = Type.getObjectType("net/gudenau/minecraft/asm/api/v0/annotation/ForceInline");
private static final Type JVM_FORCEINLINE = Type.getObjectType("jdk/internal/vm/annotation/ForceInline");
Expand All @@ -45,10 +44,10 @@ public boolean handlesClass(String name, String transformedName){

@Override
public boolean transform(ClassNode classNode, Flags flags){
boolean changed = ASM_UTILS.removeAnnotations(classNode, FORCEBOOTLOADER);
boolean changed = AsmUtils.removeAnnotations(classNode, FORCEBOOTLOADER);

for(MethodNode method : classNode.methods){
List<AnnotationNode> annotations = ASM_UTILS.getAnnotations(method, ASM_FORCEINLINE);
List<AnnotationNode> annotations = AsmUtils.getAnnotations(method, ASM_FORCEINLINE);
if(!annotations.isEmpty()){
for(AnnotationNode annotation : annotations){
annotation.desc = JVM_FORCEINLINE.getDescriptor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import java.security.ProtectionDomain;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
Expand All @@ -20,9 +19,9 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Supplier;
import net.fabricmc.loader.api.FabricLoader;
import net.gudenau.minecraft.asm.api.v0.ClassCache;
import net.gudenau.minecraft.asm.api.v0.Transformer;
import net.gudenau.minecraft.asm.util.AsmUtilsImpl;
import net.gudenau.minecraft.asm.api.v1.AsmUtils;
import net.gudenau.minecraft.asm.api.v1.ClassCache;
import net.gudenau.minecraft.asm.api.v1.Transformer;
import net.gudenau.minecraft.asm.util.Locker;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
Expand Down Expand Up @@ -99,20 +98,21 @@ public byte[] transformClassBytes(String name, String transformedName, byte[] ba
return false;
}
})){
return basicClass;
return parent.transformClassBytes(name, transformedName, basicClass);
}

for(String prefix : BLACKLIST){
if(name.startsWith(prefix)){
byte[] transformedClass = parent.transformClassBytes(name, transformedName, basicClass);
if(forceDump){
dump(name, basicClass);
}
return bootstrap(cache(basicClass, ()->parent.transformClassBytes(name, transformedName, basicClass)));
return bootstrap(cache(basicClass, ()->transformedClass));
}
}
return cache(basicClass, ()->{
if(basicClass == null){
return null;
return parent.transformClassBytes(name, transformedName, basicClass);
}

boolean shouldBootstrap = shouldBootstrap(basicClass);
Expand Down Expand Up @@ -219,7 +219,7 @@ private boolean shouldBootstrap(byte[] bytecode){

ClassNode classNode = new ClassNode();
new ClassReader(bytecode).accept(classNode, ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
return AsmUtilsImpl.INSTANCE.hasAnnotation(classNode, ANNOTATION_FORCE_BOOTLOADER);
return AsmUtils.hasAnnotation(classNode, ANNOTATION_FORCE_BOOTLOADER);
}

private byte[] bootstrap(byte[] bytecode){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import net.gudenau.minecraft.asm.api.v0.ClassCache;
import net.gudenau.minecraft.asm.api.v0.AsmRegistry;
import net.gudenau.minecraft.asm.api.v0.Identifier;
import net.gudenau.minecraft.asm.api.v0.Transformer;
import net.gudenau.minecraft.asm.api.v1.ClassCache;
import net.gudenau.minecraft.asm.api.v1.AsmRegistry;
import net.gudenau.minecraft.asm.api.v1.Identifier;
import net.gudenau.minecraft.asm.api.v1.Transformer;

// Basic registry implementation
public class RegistryImpl implements AsmRegistry{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package net.gudenau.minecraft.asm.impl;

import net.gudenau.minecraft.asm.api.v0.Transformer;
import net.gudenau.minecraft.asm.api.v1.Transformer;
import org.objectweb.asm.ClassWriter;

public class TransformerFlagsImpl implements Transformer.Flags{
Expand Down
Loading

0 comments on commit 7e277a6

Please sign in to comment.