mirror of
https://github.com/LegacyModdingMC/UniMix.git
synced 2026-11-26 20:53:06 +00:00
Add new internal interface for token provider
This commit is contained in:
1 parent
7434e54b60
commit
f66760a5bf
3 files changed
+46
-3
No files matched your search
@@ -41,6 +41,7 @@ import org.apache.logging.log4j.core.helpers.Booleans;
|
||||
import org.spongepowered.asm.launch.MixinBootstrap;
|
||||
import org.spongepowered.asm.mixin.extensibility.IEnvironmentTokenProvider;
|
||||
import org.spongepowered.asm.mixin.transformer.MixinTransformer;
|
||||
import org.spongepowered.asm.util.ITokenProvider;
|
||||
import org.spongepowered.asm.util.PrettyPrinter;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -57,7 +58,7 @@ import net.minecraft.launchwrapper.LaunchClassLoader;
|
||||
* The mixin environment manages global state information for the mixin
|
||||
* subsystem.
|
||||
*/
|
||||
public class MixinEnvironment {
|
||||
public class MixinEnvironment implements ITokenProvider {
|
||||
|
||||
/**
|
||||
* Environment phase, deliberately not implemented as an enum
|
||||
@@ -588,6 +589,7 @@ public class MixinEnvironment {
|
||||
* @return token value or null if the token is not present in the
|
||||
* environment
|
||||
*/
|
||||
@Override
|
||||
public Integer getToken(String token) {
|
||||
token = token.toUpperCase();
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.spongepowered.asm.lib.tree.AnnotationNode;
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment;
|
||||
|
||||
|
||||
/**
|
||||
@@ -220,7 +219,7 @@ public final class ConstraintParser {
|
||||
return this.max;
|
||||
}
|
||||
|
||||
public void check(MixinEnvironment environment) throws ConstraintViolationException {
|
||||
public void check(ITokenProvider environment) throws ConstraintViolationException {
|
||||
if (this != Constraint.NONE) {
|
||||
Integer value = environment.getToken(this.token);
|
||||
if (value == null) {
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* This file is part of Mixin, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) SpongePowered <https://www.spongepowered.org>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.asm.util;
|
||||
|
||||
|
||||
/**
|
||||
* Agent which can supply token values to a
|
||||
* {@link org.spongepowered.asm.util.ConstraintParser.Constraint}.
|
||||
*/
|
||||
public interface ITokenProvider {
|
||||
|
||||
/**
|
||||
* Get a token value from this provider
|
||||
*
|
||||
* @param token Token to fetch
|
||||
* @return token value or null if the token is not provided by this provider
|
||||
*/
|
||||
public abstract Integer getToken(String token);
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user