Package org.spongepowered.asm.mixin.gen
Class AccessorInfo
java.lang.Object
org.spongepowered.asm.mixin.struct.AnnotatedMethodInfo
org.spongepowered.asm.mixin.struct.SpecialMethodInfo
org.spongepowered.asm.mixin.gen.AccessorInfo
- All Implemented Interfaces:
IInjectionPointContext,ISelectorContext,IMessageSink
Information about an accessor
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classAccessor Name structstatic enumAccessor types -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Class<? extends Annotation> Annotation classprotected final org.objectweb.asm.Type[]Accessor method argument types (raw, from method)protected AccessorGeneratorGenerator which will be responsible for actually generating the accessor method bodyprotected final booleanAccessor method staticnessprotected final org.objectweb.asm.TypeAccessor method return type (raw, from method)protected final StringName specified in the attached annotation, can be nullprotected final ITargetSelectorComputed information about the target field or method, name and descriptorprotected org.objectweb.asm.tree.FieldNodeFor accessors, stores the discovered target fieldprotected org.objectweb.asm.tree.MethodNodeFor invokers, stores the discovered target methodprotected final AccessorInfo.AccessorTypeType of accessor to generate, computed based on the signature of the target method.Fields inherited from class org.spongepowered.asm.mixin.struct.SpecialMethodInfo
classNode, mixinFields inherited from class org.spongepowered.asm.mixin.struct.AnnotatedMethodInfo
annotation, annotationType, method, methodName -
Constructor Summary
ConstructorsModifierConstructorDescriptionAccessorInfo(MixinTargetContext mixin, org.objectweb.asm.tree.MethodNode method) protectedAccessorInfo(MixinTargetContext mixin, org.objectweb.asm.tree.MethodNode method, Class<? extends Annotation> annotationClass) -
Method Summary
Modifier and TypeMethodDescriptionprotected <TNode> TNodefindTarget(List<ElementNode<TNode>> nodes) Generified candidate search, since the search logic is the same for both fields and methods.org.objectweb.asm.tree.MethodNodegenerate()Second pass, generate the actual accessor method for this accessor.final org.objectweb.asm.Type[]Get the argument types of the annotated methodfinal org.objectweb.asm.TypeGet the return type of the annotated methodfinal ITargetSelectorGet the inflected/specified target member for this accessorfinal org.objectweb.asm.tree.FieldNodeFor field accessors, returns the target field, returns null for invokersfinal org.objectweb.asm.TypeFor field accessors, returns the field type, returns null for invokersfinal org.objectweb.asm.tree.MethodNodeFor invokers, returns the target method, returns null for field accessorsprotected StringgetTargetName(String name) protected StringUses the name of this accessor method and the calculated accessor type to try and inflect the name of the target field or method.static StringinflectTarget(String name, AccessorInfo.AccessorType type, String description, ISelectorContext context, boolean verbose) Uses the name of an accessor method and the accessor type to try and inflect the name of the target field or method.static StringinflectTarget(AccessorInfo.AccessorName name, AccessorInfo.AccessorType type, String description, ISelectorContext context, boolean verbose) Uses the name of an accessor method and the accessor type to try and inflect the name of the target field or method.protected ITargetSelectorprotected org.objectweb.asm.Typeprotected AccessorInfo.AccessorTypeinitType()booleanisStatic()Get whether the accessor itself is staticvoidlocate()First pass, locate the target field in the class.static AccessorInfoof(MixinTargetContext mixin, org.objectweb.asm.tree.MethodNode method, Class<? extends Annotation> type) Return a wrapper AccessorInfo of the correct type based on the method passed in.toString()voidvalidate()Called immediately after locate, initialises the generator for this accessor and runs validation.Methods inherited from class org.spongepowered.asm.mixin.struct.SpecialMethodInfo
getClassInfo, getClassNode, getMethodName, getTargetClassInfo, getTargetClassNodeMethods inherited from class org.spongepowered.asm.mixin.struct.AnnotatedMethodInfo
addMessage, getAnnotation, getAnnotationNode, getDynamicInfo, getDynamicInfo, getDynamicInfo, getElementDescription, getMethod, getMixin, getParent, getSelectorAnnotation, getSelectorCoordinate, remap
-
Field Details
-
annotationClass
Annotation class -
argTypes
protected final org.objectweb.asm.Type[] argTypesAccessor method argument types (raw, from method) -
returnType
protected final org.objectweb.asm.Type returnTypeAccessor method return type (raw, from method) -
isStatic
protected final boolean isStaticAccessor method staticness -
specifiedName
Name specified in the attached annotation, can be null -
type
Type of accessor to generate, computed based on the signature of the target method. -
target
Computed information about the target field or method, name and descriptor -
targetField
protected org.objectweb.asm.tree.FieldNode targetFieldFor accessors, stores the discovered target field -
targetMethod
protected org.objectweb.asm.tree.MethodNode targetMethodFor invokers, stores the discovered target method -
generator
Generator which will be responsible for actually generating the accessor method body
-
-
Constructor Details
-
AccessorInfo
-
AccessorInfo
protected AccessorInfo(MixinTargetContext mixin, org.objectweb.asm.tree.MethodNode method, Class<? extends Annotation> annotationClass)
-
-
Method Details
-
initType
-
initTargetFieldType
protected org.objectweb.asm.Type initTargetFieldType() -
initTarget
-
getTargetName
-
inflectTarget
Uses the name of this accessor method and the calculated accessor type to try and inflect the name of the target field or method. This allows a method named getFoo to be inflected to a target named foo for example. -
inflectTarget
public static String inflectTarget(String name, AccessorInfo.AccessorType type, String description, ISelectorContext context, boolean verbose) Uses the name of an accessor method and the accessor type to try and inflect the name of the target field or method. This allows a method named getFoo to be inflected to a target named foo for example.- Parameters:
name- Name of the accessor methodtype- Type of accessor being processed, this is calculated from the method signature (void methods being setters, methods with return types being getters)description- description of the accessor to include in error messagescontext- Mixin contextverbose- Emit warnings when accessor prefix doesn't match type- Returns:
- inflected target member name or null if name cannot be inflected
-
inflectTarget
public static String inflectTarget(AccessorInfo.AccessorName name, AccessorInfo.AccessorType type, String description, ISelectorContext context, boolean verbose) Uses the name of an accessor method and the accessor type to try and inflect the name of the target field or method. This allows a method named getFoo to be inflected to a target named foo for example.- Parameters:
name- Name of the accessor methodtype- Type of accessor being processed, this is calculated from the method signature (void methods being setters, methods with return types being getters)description- description of the accessor to include in error messagescontext- Mixin contextverbose- Emit warnings when accessor prefix doesn't match type- Returns:
- inflected target member name or null if name cannot be inflected
-
getTarget
Get the inflected/specified target member for this accessor -
getTargetFieldType
public final org.objectweb.asm.Type getTargetFieldType()For field accessors, returns the field type, returns null for invokers -
getTargetField
public final org.objectweb.asm.tree.FieldNode getTargetField()For field accessors, returns the target field, returns null for invokers -
getTargetMethod
public final org.objectweb.asm.tree.MethodNode getTargetMethod()For invokers, returns the target method, returns null for field accessors -
getReturnType
public final org.objectweb.asm.Type getReturnType()Get the return type of the annotated method -
getArgTypes
public final org.objectweb.asm.Type[] getArgTypes()Get the argument types of the annotated method -
isStatic
public boolean isStatic()Get whether the accessor itself is static -
toString
-
locate
public void locate()First pass, locate the target field in the class. This is done after all other mixins are applied so that mixin-added fields and methods can be targetted. -
validate
public void validate()Called immediately after locate, initialises the generator for this accessor and runs validation. -
generate
public org.objectweb.asm.tree.MethodNode generate()Second pass, generate the actual accessor method for this accessor. The method still respects intrinsic/mixinmerged rules so is not guaranteed to be added to the target class- Returns:
- generated accessor method
-
findTarget
Generified candidate search, since the search logic is the same for both fields and methods.- Type Parameters:
TNode- node type- Parameters:
nodes- Node list to search (method/field list)- Returns:
- best match
-
of
public static AccessorInfo of(MixinTargetContext mixin, org.objectweb.asm.tree.MethodNode method, Class<? extends Annotation> type) Return a wrapper AccessorInfo of the correct type based on the method passed in.- Parameters:
mixin- mixin context which owns this accessormethod- annotated methodtype- annotation type to process- Returns:
- parsed AccessorInfo
-