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;
}
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) }));
}
}
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);
}
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;
}
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);
}
Aggregations