Search in sources :

Example 16 with Method

use of org.jetbrains.org.objectweb.asm.commons.Method in project intellij-community by JetBrains.

the class FontPropertyCodeGenerator method generateCustomSetValue.

public boolean generateCustomSetValue(final LwComponent lwComponent, final InstrumentationClassFinder.PseudoClass componentClass, final LwIntrospectedProperty property, final GeneratorAdapter generator, final int componentLocal, final String formClassName) {
    FontDescriptor descriptor = (FontDescriptor) property.getPropertyValue(lwComponent);
    if (descriptor.isFixedFont() && !descriptor.isFullyDefinedFont()) {
        Label fontNullLabel = generator.newLabel();
        generatePushFont(generator, componentLocal, lwComponent, descriptor, property.getReadMethodName(), fontNullLabel);
        Method setFontMethod = new Method(property.getWriteMethodName(), Type.VOID_TYPE, new Type[] { ourFontType });
        Type componentType = AsmCodeGenerator.typeFromClassName(lwComponent.getComponentClassName());
        generator.invokeVirtual(componentType, setFontMethod);
        generator.mark(fontNullLabel);
        return true;
    }
    return false;
}
Also used : Label(org.jetbrains.org.objectweb.asm.Label) Method(org.jetbrains.org.objectweb.asm.commons.Method) FontDescriptor(com.intellij.uiDesigner.lw.FontDescriptor)

Example 17 with Method

use of org.jetbrains.org.objectweb.asm.commons.Method in project intellij-community by JetBrains.

the class GridBagLayoutCodeGenerator method checkSetSize.

private static void checkSetSize(final GeneratorAdapter generator, final int componentLocal, final String methodName, final Dimension dimension) {
    if (dimension != null) {
        generator.loadLocal(componentLocal);
        AsmCodeGenerator.pushPropValue(generator, "java.awt.Dimension", dimension);
        generator.invokeVirtual(Type.getType(Component.class), new Method(methodName, Type.VOID_TYPE, new Type[] { Type.getType(Dimension.class) }));
    }
}
Also used : Type(org.jetbrains.org.objectweb.asm.Type) Method(org.jetbrains.org.objectweb.asm.commons.Method) LwComponent(com.intellij.uiDesigner.lw.LwComponent)

Example 18 with Method

use of org.jetbrains.org.objectweb.asm.commons.Method in project intellij-community by JetBrains.

the class FontPropertyCodeGenerator method generatePushFont.

public static void generatePushFont(final GeneratorAdapter generator, final int componentLocal, final LwComponent lwComponent, final FontDescriptor descriptor, final String readMethodName, Label fontNullLabel) {
    final int fontLocal = generator.newLocal(ourFontType);
    generator.loadLocal(componentLocal);
    Type componentType = AsmCodeGenerator.typeFromClassName(lwComponent.getComponentClassName());
    Method getFontMethod = new Method(readMethodName, ourFontType, new Type[0]);
    generator.invokeVirtual(componentType, getFontMethod);
    generator.storeLocal(fontLocal);
    if (fontNullLabel != null) {
        generator.loadLocal(fontLocal);
        generator.ifNull(fontNullLabel);
        generator.loadLocal(componentLocal);
    }
    generator.newInstance(ourFontType);
    generator.dup();
    if (descriptor.getFontName() != null) {
        generator.push(descriptor.getFontName());
    } else {
        generator.loadLocal(fontLocal);
        generator.invokeVirtual(ourFontType, ourGetNameMethod);
    }
    if (descriptor.getFontStyle() >= 0) {
        generator.push(descriptor.getFontStyle());
    } else {
        generator.loadLocal(fontLocal);
        generator.invokeVirtual(ourFontType, ourGetStyleMethod);
    }
    if (descriptor.getFontSize() >= 0) {
        generator.push(descriptor.getFontSize());
    } else {
        generator.loadLocal(fontLocal);
        generator.invokeVirtual(ourFontType, ourGetSizeMethod);
    }
    generator.invokeConstructor(ourFontType, ourInitMethod);
}
Also used : Method(org.jetbrains.org.objectweb.asm.commons.Method)

Example 19 with Method

use of org.jetbrains.org.objectweb.asm.commons.Method in project intellij-community by JetBrains.

the class StringPropertyCodeGenerator method generateCustomSetValue.

public boolean generateCustomSetValue(final LwComponent lwComponent, final InstrumentationClassFinder.PseudoClass componentClass, final LwIntrospectedProperty property, final GeneratorAdapter generator, final int componentLocal, final String formClassName) throws IOException, ClassNotFoundException {
    final InstrumentationClassFinder.PseudoClass abstractButtonClass = componentClass.getFinder().loadClass(AbstractButton.class.getName());
    final InstrumentationClassFinder.PseudoClass jLabelClass = componentClass.getFinder().loadClass(JLabel.class.getName());
    if ("text".equals(property.getName()) && (abstractButtonClass.isAssignableFrom(componentClass) || jLabelClass.isAssignableFrom(componentClass))) {
        final StringDescriptor propertyValue = (StringDescriptor) lwComponent.getPropertyValue(property);
        if (propertyValue.getValue() != null) {
            final SupportCode.TextWithMnemonic textWithMnemonic = SupportCode.parseText(propertyValue.getValue());
            if (textWithMnemonic.myMnemonicIndex >= 0) {
                generator.loadLocal(componentLocal);
                generator.push(textWithMnemonic.myText);
                generator.invokeVirtual(Type.getType(componentClass.getDescriptor()), new Method(property.getWriteMethodName(), Type.VOID_TYPE, new Type[] { Type.getType(String.class) }));
                String setMnemonicMethodName;
                if (abstractButtonClass.isAssignableFrom(componentClass)) {
                    setMnemonicMethodName = "setMnemonic";
                } else {
                    setMnemonicMethodName = "setDisplayedMnemonic";
                }
                generator.loadLocal(componentLocal);
                generator.push(textWithMnemonic.getMnemonicChar());
                generator.invokeVirtual(Type.getType(componentClass.getDescriptor()), new Method(setMnemonicMethodName, Type.VOID_TYPE, new Type[] { Type.CHAR_TYPE }));
                if (myHaveSetDisplayedMnemonicIndex) {
                    generator.loadLocal(componentLocal);
                    generator.push(textWithMnemonic.myMnemonicIndex);
                    generator.invokeVirtual(Type.getType(componentClass.getDescriptor()), new Method("setDisplayedMnemonicIndex", Type.VOID_TYPE, new Type[] { Type.INT_TYPE }));
                }
                return true;
            }
        } else {
            Method method;
            if (abstractButtonClass.isAssignableFrom(componentClass)) {
                myClassesRequiringLoadButtonText.add(formClassName);
                method = myLoadButtonTextMethod;
            } else {
                myClassesRequiringLoadLabelText.add(formClassName);
                method = myLoadLabelTextMethod;
            }
            generator.loadThis();
            generator.loadLocal(componentLocal);
            generator.push(propertyValue.getBundleName());
            generator.invokeStatic(myResourceBundleType, myGetBundleMethod);
            generator.push(propertyValue.getKey());
            generator.invokeVirtual(myResourceBundleType, myGetStringMethod);
            generator.invokeVirtual(Type.getType("L" + formClassName + ";"), method);
            return true;
        }
    }
    return false;
}
Also used : Type(org.jetbrains.org.objectweb.asm.Type) SupportCode(com.intellij.uiDesigner.core.SupportCode) InstrumentationClassFinder(com.intellij.compiler.instrumentation.InstrumentationClassFinder) StringDescriptor(com.intellij.uiDesigner.lw.StringDescriptor) Method(org.jetbrains.org.objectweb.asm.commons.Method)

Example 20 with Method

use of org.jetbrains.org.objectweb.asm.commons.Method in project kotlin by JetBrains.

the class JvmSerializerExtension method serializeProperty.

@Override
public void serializeProperty(@NotNull PropertyDescriptor descriptor, @NotNull ProtoBuf.Property.Builder proto) {
    SignatureSerializer signatureSerializer = new SignatureSerializer();
    PropertyGetterDescriptor getter = descriptor.getGetter();
    PropertySetterDescriptor setter = descriptor.getSetter();
    Method getterMethod = getter == null ? null : bindings.get(METHOD_FOR_FUNCTION, getter);
    Method setterMethod = setter == null ? null : bindings.get(METHOD_FOR_FUNCTION, setter);
    Pair<Type, String> field = bindings.get(FIELD_FOR_PROPERTY, descriptor);
    Method syntheticMethod = bindings.get(SYNTHETIC_METHOD_FOR_PROPERTY, descriptor);
    JvmProtoBuf.JvmPropertySignature signature = signatureSerializer.propertySignature(descriptor, field != null ? field.second : null, field != null ? field.first.getDescriptor() : null, syntheticMethod != null ? signatureSerializer.methodSignature(null, syntheticMethod) : null, getterMethod != null ? signatureSerializer.methodSignature(null, getterMethod) : null, setterMethod != null ? signatureSerializer.methodSignature(null, setterMethod) : null);
    proto.setExtension(JvmProtoBuf.propertySignature, signature);
}
Also used : JvmProtoBuf(org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf) KotlinType(org.jetbrains.kotlin.types.KotlinType) FlexibleType(org.jetbrains.kotlin.types.FlexibleType) Type(org.jetbrains.org.objectweb.asm.Type) Method(org.jetbrains.org.objectweb.asm.commons.Method)

Aggregations

Method (org.jetbrains.org.objectweb.asm.commons.Method)25 KotlinType (org.jetbrains.kotlin.types.KotlinType)11 Type (org.jetbrains.org.objectweb.asm.Type)9 NotNull (org.jetbrains.annotations.NotNull)7 InstructionAdapter (org.jetbrains.org.objectweb.asm.commons.InstructionAdapter)5 Unit (kotlin.Unit)3 JvmMethodGenericSignature (org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodGenericSignature)2 JvmMethodSignature (org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature)2 MethodVisitor (org.jetbrains.org.objectweb.asm.MethodVisitor)2 MethodNode (org.jetbrains.org.objectweb.asm.tree.MethodNode)2 TraceMethodVisitor (org.jetbrains.org.objectweb.asm.util.TraceMethodVisitor)2 InstrumentationClassFinder (com.intellij.compiler.instrumentation.InstrumentationClassFinder)1 PsiElement (com.intellij.psi.PsiElement)1 IElementType (com.intellij.psi.tree.IElementType)1 SupportCode (com.intellij.uiDesigner.core.SupportCode)1 FontDescriptor (com.intellij.uiDesigner.lw.FontDescriptor)1 LwComponent (com.intellij.uiDesigner.lw.LwComponent)1 StringDescriptor (com.intellij.uiDesigner.lw.StringDescriptor)1 ArrayList (java.util.ArrayList)1 Bridge (org.jetbrains.kotlin.backend.common.bridges.Bridge)1