public Size apply()

in java/clickhouse-client/src/main/java/com/epam/deltix/clickhouse/writer/WriterCodecGenerator.java [69:114]


    public Size apply(MethodVisitor methodVisitor,
                      Implementation.Context implementationContext,
                      MethodDescription instrumentedMethod) {
        generatedClassName = implementationContext.getInstrumentedType().getCanonicalName();
        localVarSize = instrumentedMethod.getStackSize();
        // load a reference (`clazz`) onto the stack from a local variable #1
        methodVisitor.visitVarInsn(ALOAD, 1);
        // checks whether an object reference is of a certain type,
        // the class reference of which is in the constant pool at index #1
        methodVisitor.visitTypeInsn(CHECKCAST, internalClassName);
        // store a reference(`clazz`) into a local variable #3
        methodVisitor.visitVarInsn(ASTORE, 3);
        localVarSize++;

        // initialize 'parameterIndex' variable with value - 1;
        methodVisitor.visitInsn(ICONST_1);
        storeParameterIndexValue(methodVisitor);

        Label l1 = new Label();
        methodVisitor.visitLabel(l1);

        for (BindDeclaration bind : binds) {
            String memberName = BindHelper.memberName.apply(bind);
            Class<?> memberDataType = BindHelper.memberType.apply(bind);

            String memberTypeDescriptor = BindHelper.memberDescriptor.apply(bind);

            SqlDataType dbDataType = bind.getDbDataType();
            DataTypes dbDataTypeValue = dbDataType.getType();

            SchemaArrayElement elementAnnotation = BindHelper.memberArrayElement.apply(bind);

            processAnyType(methodVisitor, memberDataType, memberName, memberTypeDescriptor,
                    elementAnnotation, dbDataType, dbDataTypeValue);
        }

        loadPsOnStack(methodVisitor);
        methodVisitor.visitInsn(ARETURN);

        Label l2 = new Label();
        methodVisitor.visitLabel(l2);

        methodVisitor.visitLocalVariable("parameterIndex", "I", null, l1, l2, 4);

        return new Size(4, localVarSize);
    }