List of usage examples for org.objectweb.asm Type CHAR_TYPE
Type CHAR_TYPE
To view the source code for org.objectweb.asm Type CHAR_TYPE.
Click Source Link
From source file:boilerplate.processor.adapters.EqualsGenerators.java
License:Open Source License
private static final List<BytecodeGenerator> createGeneratorList() { BytecodeGenerator[] generators = { new Int32Generator(Type.BOOLEAN_TYPE), new Int32Generator(Type.CHAR_TYPE), new Int32Generator(Type.INT_TYPE), new Int32Generator(Type.SHORT_TYPE), new Int32Generator(Type.BYTE_TYPE), new LongGenerator(), new FloatGenerator(), new DoubleGenerator(), new ArraysGenerator(), new ObjectGenerator(), }; List<BytecodeGenerator> list = Arrays.asList(generators); return Collections.unmodifiableList(list); }
From source file:boilerplate.processor.adapters.ToStringMethodInsertion.java
License:Open Source License
private static List<BytecodeGenerator> createMethodList() { final Type objectType = Type.getType(Object.class); class ObjectMethodInsn extends ToStringMethodInsertion { ObjectMethodInsn() {//from ww w . ja v a 2 s .co m super(objectType, "appendObject", "(Ljava/lang/StringBuilder;Ljava/lang/String;Ljava/lang/Object;)V"); } @Override public boolean matches(Type type) { return true; } } BytecodeGenerator[] arr = { new ToStringMethodInsertion(Type.BOOLEAN_TYPE, "appendBoolean", "(Ljava/lang/StringBuilder;Ljava/lang/String;Z)V"), new ToStringMethodInsertion(Type.BYTE_TYPE, "appendByte", "(Ljava/lang/StringBuilder;Ljava/lang/String;B)V"), new ToStringMethodInsertion(Type.CHAR_TYPE, "appendChar", "(Ljava/lang/StringBuilder;Ljava/lang/String;C)V"), new ToStringMethodInsertion(Type.DOUBLE_TYPE, "appendDouble", "(Ljava/lang/StringBuilder;Ljava/lang/String;D)V"), new ToStringMethodInsertion(Type.FLOAT_TYPE, "appendFloat", "(Ljava/lang/StringBuilder;Ljava/lang/String;F)V"), new ToStringMethodInsertion(Type.INT_TYPE, "appendInt", "(Ljava/lang/StringBuilder;Ljava/lang/String;I)V"), new ToStringMethodInsertion(Type.LONG_TYPE, "appendLong", "(Ljava/lang/StringBuilder;Ljava/lang/String;J)V"), new ToStringMethodInsertion(Type.SHORT_TYPE, "appendShort", "(Ljava/lang/StringBuilder;Ljava/lang/String;S)V"), // default new ObjectMethodInsn(), }; List<BytecodeGenerator> list = Arrays.asList(arr); return Collections.unmodifiableList(list); }
From source file:com.asakusafw.dag.compiler.codegen.AsmUtil.java
License:Apache License
/** * Returns the ASM {@link Type} object./* www . j ava 2 s . c o m*/ * @param type the target type description * @return the corresponded {@link Type} object */ public static Type typeOf(TypeDescription type) { Arguments.requireNonNull(type); TypeDescription e = type.getErasure(); switch (e.getTypeKind()) { case BASIC: switch (((BasicTypeDescription) e).getBasicTypeKind()) { case BOOLEAN: return Type.BOOLEAN_TYPE; case BYTE: return Type.BYTE_TYPE; case CHAR: return Type.CHAR_TYPE; case DOUBLE: return Type.DOUBLE_TYPE; case FLOAT: return Type.FLOAT_TYPE; case INT: return Type.INT_TYPE; case LONG: return Type.LONG_TYPE; case SHORT: return Type.SHORT_TYPE; case VOID: return Type.VOID_TYPE; default: throw new AssertionError(type); } case ARRAY: return Type.getType('[' + typeOf(((ArrayTypeDescription) e).getComponentType()).getDescriptor()); case CLASS: return Type.getObjectType(((ClassDescription) e).getInternalName()); default: throw new AssertionError(type); } }
From source file:com.facebook.buck.jvm.java.abi.DescriptorFactory.java
License:Apache License
public Type getType(TypeMirror typeMirror) { return Preconditions.checkNotNull(typeMirror.accept(new SimpleTypeVisitor8<Type, Void>() { @Override/* ww w .j a v a 2 s. c o m*/ protected Type defaultAction(TypeMirror t, Void aVoid) { throw new IllegalArgumentException(String.format("Unexpected type kind: %s", t.getKind())); } @Override public Type visitPrimitive(PrimitiveType type, Void aVoid) { switch (type.getKind()) { case BOOLEAN: return Type.BOOLEAN_TYPE; case BYTE: return Type.BYTE_TYPE; case CHAR: return Type.CHAR_TYPE; case SHORT: return Type.SHORT_TYPE; case INT: return Type.INT_TYPE; case LONG: return Type.LONG_TYPE; case FLOAT: return Type.FLOAT_TYPE; case DOUBLE: return Type.DOUBLE_TYPE; // $CASES-OMITTED$ default: throw new IllegalArgumentException(String.format("Unexpected type kind: %s", type.getKind())); } } @Override public Type visitNoType(NoType t, Void aVoid) { if (t.getKind() != TypeKind.VOID) { throw new IllegalArgumentException(String.format("Unexpected type kind: %s", t.getKind())); } return Type.VOID_TYPE; } @Override public Type visitArray(ArrayType t, Void aVoid) { return Type.getObjectType("[" + getDescriptor(t.getComponentType())); } @Override public Type visitDeclared(DeclaredType t, Void aVoid) { // The erasure of a parameterized type is just the unparameterized version (JLS8 4.6) TypeElement typeElement = (TypeElement) t.asElement(); if (typeElement.getQualifiedName().contentEquals("")) { // javac 7 uses a DeclaredType to model an intersection type if (typeElement.getKind() == ElementKind.INTERFACE) { return getType(typeElement.getInterfaces().get(0)); } return getType(typeElement.getSuperclass()); } return Type.getObjectType(getInternalName(typeElement)); } @Override public Type visitError(ErrorType t, Void aVoid) { // If there's an ErrorType, compilation is going to fail anyway, so it doesn't // matter what we return. return Type.getObjectType("java/lang/Object"); } @Override public Type visitTypeVariable(TypeVariable t, Void aVoid) { // The erasure of a type variable is the erasure of its leftmost bound (JLS8 4.6) // If there's only one bound, getUpperBound returns it directly; if there's more than // one it returns an IntersectionType return getType(t.getUpperBound()); } @Override public Type visitIntersection(IntersectionType t, Void aVoid) { // The erasure of a type variable is the erasure of its leftmost bound (JLS8 4.6) return getType(t.getBounds().get(0)); } }, null)); }
From source file:com.github.javalbert.reflection.ClassAccessFactory.java
License:Apache License
private void visitFieldAccessMethods() { List<AccessInfo> fieldAccessInfoList = Collections.unmodifiableList(Arrays.asList( // Primitive types ///* ww w .j a v a2 s.co m*/ AccessInfo.forPrimitive(MEMBER_TYPE_FIELD, Type.BOOLEAN_TYPE), AccessInfo.forPrimitive(MEMBER_TYPE_FIELD, Type.BYTE_TYPE), AccessInfo.forPrimitive(MEMBER_TYPE_FIELD, Type.CHAR_TYPE), AccessInfo.forPrimitive(MEMBER_TYPE_FIELD, Type.DOUBLE_TYPE), AccessInfo.forPrimitive(MEMBER_TYPE_FIELD, Type.FLOAT_TYPE), AccessInfo.forPrimitive(MEMBER_TYPE_FIELD, Type.INT_TYPE), AccessInfo.forPrimitive(MEMBER_TYPE_FIELD, Type.LONG_TYPE), AccessInfo.forPrimitive(MEMBER_TYPE_FIELD, Type.SHORT_TYPE), // Primitive wrapper types // AccessInfo.forPrimitiveWrapper(MEMBER_TYPE_FIELD, Boolean.class), AccessInfo.forPrimitiveWrapper(MEMBER_TYPE_FIELD, Byte.class), AccessInfo.forPrimitiveWrapper(MEMBER_TYPE_FIELD, Character.class), AccessInfo.forPrimitiveWrapper(MEMBER_TYPE_FIELD, Double.class), AccessInfo.forPrimitiveWrapper(MEMBER_TYPE_FIELD, Float.class), AccessInfo.forPrimitiveWrapper(MEMBER_TYPE_FIELD, Integer.class), AccessInfo.forPrimitiveWrapper(MEMBER_TYPE_FIELD, Long.class), AccessInfo.forPrimitiveWrapper(MEMBER_TYPE_FIELD, Short.class), // Common reference types // AccessInfo.forReferenceType(MEMBER_TYPE_FIELD, BigDecimal.class), AccessInfo.forReferenceType(MEMBER_TYPE_FIELD, Date.class), AccessInfo.forReferenceType(MEMBER_TYPE_FIELD, LocalDate.class), AccessInfo.forReferenceType(MEMBER_TYPE_FIELD, LocalDateTime.class), AccessInfo.forReferenceType(MEMBER_TYPE_FIELD, String.class))); for (int i = 0; i < fieldAccessInfoList.size(); i++) { AccessInfo fieldAccessInfo = fieldAccessInfoList.get(i); List<FieldInfo> fieldInfoList = typeToFieldsMap.get(fieldAccessInfo.className); visitAccessGetter(fieldInfoList, fieldAccessInfo); visitAccessGetterBridge(fieldAccessInfo); visitAccessSetter(fieldInfoList, fieldAccessInfo); visitAccessSetterBridge(fieldAccessInfo); } visitGeneralAccessGetter("getField", MEMBER_TYPE_FIELD, fieldInfoList); visitAccessGetterBridge("getField", "Ljava/lang/Object;", ARETURN); visitGeneralAccessSetter("setField", MEMBER_TYPE_FIELD, fieldInfoList); visitAccessSetterBridge("setField", ALOAD, "Ljava/lang/Object;"); }
From source file:com.github.javalbert.reflection.ClassAccessFactory.java
License:Apache License
private void visitPropertyAccessMethods() { List<AccessInfo> propertyAccessInfoList = Collections.unmodifiableList(Arrays.asList( // Primitive types ///* w w w. j ava 2 s .c o m*/ AccessInfo.forPrimitive(MEMBER_TYPE_PROPERTY, Type.BOOLEAN_TYPE), AccessInfo.forPrimitive(MEMBER_TYPE_PROPERTY, Type.BYTE_TYPE), AccessInfo.forPrimitive(MEMBER_TYPE_PROPERTY, Type.CHAR_TYPE), AccessInfo.forPrimitive(MEMBER_TYPE_PROPERTY, Type.DOUBLE_TYPE), AccessInfo.forPrimitive(MEMBER_TYPE_PROPERTY, Type.FLOAT_TYPE), AccessInfo.forPrimitive(MEMBER_TYPE_PROPERTY, Type.INT_TYPE), AccessInfo.forPrimitive(MEMBER_TYPE_PROPERTY, Type.LONG_TYPE), AccessInfo.forPrimitive(MEMBER_TYPE_PROPERTY, Type.SHORT_TYPE), // Primitive wrapper types // AccessInfo.forPrimitiveWrapper(MEMBER_TYPE_PROPERTY, Boolean.class), AccessInfo.forPrimitiveWrapper(MEMBER_TYPE_PROPERTY, Byte.class), AccessInfo.forPrimitiveWrapper(MEMBER_TYPE_PROPERTY, Character.class), AccessInfo.forPrimitiveWrapper(MEMBER_TYPE_PROPERTY, Double.class), AccessInfo.forPrimitiveWrapper(MEMBER_TYPE_PROPERTY, Float.class), AccessInfo.forPrimitiveWrapper(MEMBER_TYPE_PROPERTY, Integer.class), AccessInfo.forPrimitiveWrapper(MEMBER_TYPE_PROPERTY, Long.class), AccessInfo.forPrimitiveWrapper(MEMBER_TYPE_PROPERTY, Short.class), // Common reference types // AccessInfo.forReferenceType(MEMBER_TYPE_PROPERTY, BigDecimal.class), AccessInfo.forReferenceType(MEMBER_TYPE_PROPERTY, Date.class), AccessInfo.forReferenceType(MEMBER_TYPE_PROPERTY, LocalDate.class), AccessInfo.forReferenceType(MEMBER_TYPE_PROPERTY, LocalDateTime.class), AccessInfo.forReferenceType(MEMBER_TYPE_PROPERTY, String.class))); for (int i = 0; i < propertyAccessInfoList.size(); i++) { AccessInfo propertyAccessInfo = propertyAccessInfoList.get(i); visitAccessGetter(typeToAccessorsMap.get(propertyAccessInfo.className), propertyAccessInfo); visitAccessGetterBridge(propertyAccessInfo); visitAccessSetter(typeToMutatorsMap.get(propertyAccessInfo.className), propertyAccessInfo); visitAccessSetterBridge(propertyAccessInfo); } visitGeneralAccessGetter("getProperty", MEMBER_TYPE_PROPERTY, accessorInfoList); visitAccessGetterBridge("getProperty", "Ljava/lang/Object;", ARETURN); visitGeneralAccessSetter("setProperty", MEMBER_TYPE_PROPERTY, mutatorInfoList); visitAccessSetterBridge("setProperty", ALOAD, "Ljava/lang/Object;"); }
From source file:com.google.gwtorm.schema.sql.SqlCharTypeInfo.java
License:Apache License
@Override public void generatePreparedStatementSet(final CodeGenSupport cgs) { cgs.pushSqlHandle();// w ww .j av a 2s .c o m cgs.pushColumnIndex(); cgs.pushFieldValue(); cgs.mv.visitMethodInsn(Opcodes.INVOKESTATIC, Type.getInternalName(Character.class), "toString", Type.getMethodDescriptor(Type.getType(String.class), new Type[] { Type.CHAR_TYPE })); cgs.invokePreparedStatementSet(getJavaSqlTypeAlias()); }
From source file:com.google.gwtorm.schema.sql.SqlCharTypeInfo.java
License:Apache License
@Override public void generateResultSetGet(final CodeGenSupport cgs) { cgs.fieldSetBegin();/* w w w . j a va 2 s .co m*/ cgs.pushSqlHandle(); cgs.pushColumnIndex(); cgs.invokeResultSetGet(getJavaSqlTypeAlias()); cgs.push(0); cgs.mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, Type.getInternalName(String.class), "charAt", Type.getMethodDescriptor(Type.CHAR_TYPE, new Type[] { Type.INT_TYPE })); cgs.fieldSetEnd(); }
From source file:com.google.template.soy.jbcsrc.BytecodeUtils.java
License:Apache License
/** Returns an {@link Expression} that can load the given 'char' constant. */ static Expression constant(final char value) { return new Expression(Type.CHAR_TYPE, Feature.CHEAP) { @Override/*from w w w .j a v a 2s . co m*/ void doGen(CodeBuilder mv) { mv.pushInt(value); } }; }
From source file:com.google.template.soy.jbcsrc.restricted.BytecodeUtils.java
License:Apache License
/** Returns an {@link Expression} that can load the given char constant. */ public static Expression constant(final char value) { return new Expression(Type.CHAR_TYPE, Feature.CHEAP) { @Override/*w w w .j a v a 2s. c om*/ protected void doGen(CodeBuilder mv) { mv.pushInt(value); } }; }