mirror of
https://github.com/LegacyModdingMC/UniMix.git
synced 2026-11-21 03:22:17 +00:00
Tidy up code
This commit is contained in:
1 parent
5a7eaeae79
commit
bc8296da0e
6 files changed
+154
-50
No files matched your search
@@ -351,7 +351,7 @@ class MixinConfig implements Comparable<MixinConfig>, IMixinConfig {
|
||||
this.unhandledTargets.add(targetClassName);
|
||||
}
|
||||
if (hotSwapper != null) {
|
||||
hotSwapper.registerMixinClass(mixin.getClassName(), mixin.getClassBytes());
|
||||
hotSwapper.registerMixinClass(mixin.getClassName());
|
||||
}
|
||||
this.mixins.add(mixin);
|
||||
}
|
||||
@@ -509,6 +509,13 @@ class MixinConfig implements Comparable<MixinConfig>, IMixinConfig {
|
||||
return mixins;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a mixin with new bytecode
|
||||
*
|
||||
* @param mixinClass Name of the mixin class
|
||||
* @param bytes New bytecode
|
||||
* @return List of classes that need to be updated
|
||||
*/
|
||||
public List<String> reloadMixin(String mixinClass, byte[] bytes) {
|
||||
for (Iterator<MixinInfo> iter = this.mixins.iterator(); iter.hasNext();) {
|
||||
MixinInfo mixin = iter.next();
|
||||
|
||||
@@ -539,9 +539,14 @@ class MixinInfo extends TreeInfo implements Comparable<MixinInfo>, IMixinInfo {
|
||||
return mixinBytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates this mixin with new bytecode
|
||||
*
|
||||
* @param mixinBytes New bytecode
|
||||
*/
|
||||
void reloadMixin(byte[] mixinBytes) {
|
||||
this.mixinBytes = mixinBytes;
|
||||
this.validationClassNode = getClassNode(0);
|
||||
this.validationClassNode = this.getClassNode(0);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
@@ -425,7 +425,11 @@ public class MixinTransformer extends TreeTransformer {
|
||||
this.logger.warn("Re-entrance detected, this will cause serious problems.", new RuntimeException());
|
||||
throw new MixinApplyError("Re-entrance error.");
|
||||
}
|
||||
|
||||
|
||||
if (this.hotSwapper != null) {
|
||||
this.hotSwapper.registerTargetClass(transformedName, basicClass);
|
||||
}
|
||||
|
||||
try {
|
||||
basicClass = this.applyMixins(transformedName, basicClass, mixins);
|
||||
} catch (InvalidMixinException th) {
|
||||
@@ -449,9 +453,17 @@ public class MixinTransformer extends TreeTransformer {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a mixin class with new bytecode.
|
||||
*
|
||||
* @param mixinClass Name of the mixin
|
||||
* @param bytes New bytecode
|
||||
* @return List of classes that need to be updated
|
||||
*/
|
||||
public List<String> reload(String mixinClass, byte[] bytes) {
|
||||
if (this.lock.getDepth() > 0)
|
||||
if (this.lock.getDepth() > 0) {
|
||||
throw new MixinApplyError("Cannot reload mixin if re-entrant lock entered");
|
||||
}
|
||||
List<String> targets = new ArrayList<String>();
|
||||
for (MixinConfig config:this.configs) {
|
||||
targets.addAll(config.reloadMixin(mixinClass, bytes));
|
||||
|
||||
@@ -35,8 +35,17 @@ public interface IHotSwap {
|
||||
* This is needed as the mixin needs to be loaded to be redefined.
|
||||
*
|
||||
* @param name Fully qualified name of the mixin class
|
||||
* @param bytecode Bytecode of the mixin
|
||||
*/
|
||||
public abstract void registerMixinClass(String name, byte[] bytecode);
|
||||
public abstract void registerMixinClass(String name);
|
||||
|
||||
/**
|
||||
* Registers a class targeted by at least one mixin.
|
||||
*
|
||||
* This is used to rollback the target class to a state before the mixin's
|
||||
* where applied.
|
||||
*
|
||||
* @param name Name of the class
|
||||
* @param bytecode Bytecode of the class before mixin's have been applied
|
||||
*/
|
||||
public abstract void registerTargetClass(String name, byte[] bytecode);
|
||||
}
|
||||
Reference in new issue
Block a user