private static void textGroupMethod(ClassWriter classWriter, String varName, String visitName){
        MethodVisitor mVisitor = classWriter.visitMethod(ACC_PUBLIC, varName, "(" + JAVA_OBJECT_DESC + ")" + elementTypeDesc, "<R:" + JAVA_OBJECT_DESC + ">(TR;)TT;", null);
        mVisitor.visitLocalVariable(varName, JAVA_STRING_DESC, null, new Label(), new Label(),1);
        mVisitor.visitCode();
        mVisitor.visitVarInsn(ALOAD, 0);
        mVisitor.visitMethodInsn(INVOKEINTERFACE, textGroupType, "getVisitor", "()" + elementVisitorTypeDesc, true);
        mVisitor.visitTypeInsn(NEW, textType);
        mVisitor.visitInsn(DUP);
        mVisitor.visitVarInsn(ALOAD, 0);
        mVisitor.visitMethodInsn(INVOKEINTERFACE, textGroupType, "self", "()" + elementTypeDesc, true);
        mVisitor.visitVarInsn(ALOAD, 0);
        mVisitor.visitMethodInsn(INVOKEINTERFACE, textGroupType, "getVisitor", "()" + elementVisitorTypeDesc, true);
        mVisitor.visitVarInsn(ALOAD, 1);
        mVisitor.visitMethodInsn(INVOKESPECIAL, textType, CONSTRUCTOR, "(" + elementTypeDesc + elementVisitorTypeDesc + JAVA_OBJECT_DESC + ")V", false);
        mVisitor.visitMethodInsn(INVOKEVIRTUAL, elementVisitorType, visitName, "(" + textTypeDesc + ")V", false);
        mVisitor.visitVarInsn(ALOAD, 0);
        mVisitor.visitMethodInsn(INVOKEINTERFACE, textGroupType, "self", "()" + elementTypeDesc, true);
        mVisitor.visitInsn(ARETURN);
        mVisitor.visitMaxs(6, 2);
        mVisitor.visitEnd();
    }
private static void textGroupMethod ( ClassWriter classWriter , String varName , String visitName ) { MethodVisitor mVisitor = classWriter . visitMethod ( ACC_PUBLIC , varName , "(" + JAVA_OBJECT_DESC + ")" + elementTypeDesc , "<R:" + JAVA_OBJECT_DESC + ">(TR;)TT;" , null ) ; mVisitor . visitLocalVariable ( varName , JAVA_STRING_DESC , null , new Label ( ) , new Label ( ) , 1 ) ; mVisitor . visitCode ( ) ; mVisitor . visitVarInsn ( ALOAD , 0 ) ; mVisitor . visitMethodInsn ( INVOKEINTERFACE , textGroupType , "getVisitor" , "()" + elementVisitorTypeDesc , true ) ; mVisitor . visitTypeInsn ( NEW , textType ) ; mVisitor . visitInsn ( DUP ) ; mVisitor . visitVarInsn ( ALOAD , 0 ) ; mVisitor . visitMethodInsn ( INVOKEINTERFACE , textGroupType , "self" , "()" + elementTypeDesc , true ) ; mVisitor . visitVarInsn ( ALOAD , 0 ) ; mVisitor . visitMethodInsn ( INVOKEINTERFACE , textGroupType , "getVisitor" , "()" + elementVisitorTypeDesc , true ) ; mVisitor . visitVarInsn ( ALOAD , 1 ) ; mVisitor . visitMethodInsn ( INVOKESPECIAL , textType , CONSTRUCTOR , "(" + elementTypeDesc + elementVisitorTypeDesc + JAVA_OBJECT_DESC + ")V" , false ) ; mVisitor . visitMethodInsn ( INVOKEVIRTUAL , elementVisitorType , visitName , "(" + textTypeDesc + ")V" , false ) ; mVisitor . visitVarInsn ( ALOAD , 0 ) ; mVisitor . visitMethodInsn ( INVOKEINTERFACE , textGroupType , "self" , "()" + elementTypeDesc , true ) ; mVisitor . visitInsn ( ARETURN ) ; mVisitor . visitMaxs ( 6 , 2 ) ; mVisitor . visitEnd ( ) ; }
Creates a method present in the TextGroup interface.
Code:
getVisitor().visitComment(new Text<>(self(), getVisitor(), text));
return this.self();
@param classWriter The TextGroup {@link ClassWriter} object.
@param varName The name of the method, i.e. text or comment.
@param visitName The name of the visit method to invoke on the method, i.e. visitText or visitComment.