public TypeDesc getRootComponentType() { TypeDesc type = mComponent; while (type.isArray()) { type = type.getComponentType(); } return type; }
/** * Returns this in Java method signature syntax. * * @param name method name * @param varargs request that the last argument, if it is an array, to * be formatted in varargs syntax. */ public String toMethodSignature(String name, boolean varargs) { StringBuffer buf = new StringBuffer(); buf.append(mRetType.getFullName()); buf.append(' '); buf.append(name); buf.append('('); TypeDesc[] params = mParams; for (int i=0; i<params.length; i++) { if (i > 0) { buf.append(", "); } TypeDesc param = params[i]; if (varargs && param.isArray() && i == (params.length - 1)) { buf.append(param.getComponentType().getFullName()); buf.append("..."); } else { buf.append(param.getFullName()); } } return buf.append(')').toString(); }
buf.append(" = "); TypeDesc componentType = type.getComponentType(); if (componentType != null) { buf.append(getTypeDescName(componentType));
private void print(TypeDesc type) { if (type == null || type == TypeDesc.VOID) { print("null"); return; } if (type.isPrimitive()) { print("TypeDesc.".concat(type.getFullName().toUpperCase())); return; } else if (type == TypeDesc.OBJECT) { print("TypeDesc.OBJECT"); return; } else if (type == TypeDesc.STRING) { print("TypeDesc.STRING"); return; } TypeDesc componentType = type.getComponentType(); if (componentType != null) { print(componentType); print(".toArrayType()"); } else { print("TypeDesc.forClass(\""); print(escape(type.getRootName())); print("\")"); } }
public void newObject(TypeDesc type, int dimensions) { if (dimensions <= 0) { // If type refers to an array, then this code is bogus. mInstructions.new NewObjectInstruction(mCp.addConstantClass(type)); return; } TypeDesc componentType = type.getComponentType(); if (dimensions == 1) { if (componentType.isPrimitive()) { addInstruction(0, type, Opcode.NEWARRAY, (byte)componentType.getTypeCode()); return; } addInstruction(0, type, Opcode.ANEWARRAY, mCp.addConstantClass(componentType)); return; } int stackAdjust = -(dimensions - 1); ConstantInfo info = mCp.addConstantClass(type); byte[] bytes = new byte[4]; bytes[0] = Opcode.MULTIANEWARRAY; //bytes[1] = (byte)0; //bytes[2] = (byte)0; bytes[3] = (byte)dimensions; mInstructions.new ConstantOperandInstruction(stackAdjust, type, bytes, info); }
public TypeDesc getRootComponentType() { TypeDesc type = mComponent; while (type.isArray()) { type = type.getComponentType(); } return type; }
/** * Returns this in Java method signature syntax. * * @param name method name * @param varargs request that the last argument, if it is an array, to * be formatted in varargs syntax. */ public String toMethodSignature(String name, boolean varargs) { StringBuffer buf = new StringBuffer(); buf.append(mRetType.getFullName()); buf.append(' '); buf.append(name); buf.append('('); TypeDesc[] params = mParams; for (int i=0; i<params.length; i++) { if (i > 0) { buf.append(", "); } TypeDesc param = params[i]; if (varargs && param.isArray() && i == (params.length - 1)) { buf.append(param.getComponentType().getFullName()); buf.append("..."); } else { buf.append(param.getFullName()); } } return buf.append(')').toString(); }
buf.append(" = "); TypeDesc componentType = type.getComponentType(); if (componentType != null) { buf.append(getTypeDescName(componentType));
private static void addValueHashCodeCallTo(CodeBuilder b, TypeDesc valueType) { if (valueType.isArray()) { if (!valueType.getComponentType().isPrimitive()) { b.invokeStatic("java.util.Arrays", "deepHashCode", TypeDesc.INT, new TypeDesc[] {TypeDesc.forClass(Object[].class)}); } else { b.invokeStatic("java.util.Arrays", "hashCode", TypeDesc.INT, new TypeDesc[] {valueType}); } } else { b.invokeVirtual(TypeDesc.OBJECT, "hashCode", TypeDesc.INT, null); } }
private static void addValueHashCodeCallTo(CodeBuilder b, TypeDesc valueType) { if (valueType.isArray()) { if (!valueType.getComponentType().isPrimitive()) { b.invokeStatic("java.util.Arrays", "deepHashCode", TypeDesc.INT, new TypeDesc[] {TypeDesc.forClass(Object[].class)}); } else { b.invokeStatic("java.util.Arrays", "hashCode", TypeDesc.INT, new TypeDesc[] {valueType}); } } else { b.invokeVirtual(TypeDesc.OBJECT, "hashCode", TypeDesc.INT, null); } }
private void print(TypeDesc type) { if (type == null || type == TypeDesc.VOID) { print("null"); return; } if (type.isPrimitive()) { print("TypeDesc.".concat(type.getFullName().toUpperCase())); return; } else if (type == TypeDesc.OBJECT) { print("TypeDesc.OBJECT"); return; } else if (type == TypeDesc.STRING) { print("TypeDesc.STRING"); return; } TypeDesc componentType = type.getComponentType(); if (componentType != null) { print(componentType); print(".toArrayType()"); } else { print("TypeDesc.forClass(\""); print(escape(type.getRootName())); print("\")"); } }
public void newObject(TypeDesc type, int dimensions) { if (dimensions <= 0) { // If type refers to an array, then this code is bogus. mInstructions.new NewObjectInstruction(mCp.addConstantClass(type)); return; } TypeDesc componentType = type.getComponentType(); if (dimensions == 1) { if (componentType.isPrimitive()) { addInstruction(0, type, Opcode.NEWARRAY, (byte)componentType.getTypeCode()); return; } addInstruction(0, type, Opcode.ANEWARRAY, mCp.addConstantClass(componentType)); return; } int stackAdjust = -(dimensions - 1); ConstantInfo info = mCp.addConstantClass(type); byte[] bytes = new byte[4]; bytes[0] = Opcode.MULTIANEWARRAY; //bytes[1] = (byte)0; //bytes[2] = (byte)0; bytes[3] = (byte)dimensions; mInstructions.new ConstantOperandInstruction(stackAdjust, type, bytes, info); }
if (fieldType.isArray()) { if (!fieldType.getComponentType().isPrimitive()) { TypeDesc type = TypeDesc.forClass(Object[].class); b.invokeStatic("java.util.Arrays", "deepEquals",
if (fieldType.isArray()) { if (!fieldType.getComponentType().isPrimitive()) { TypeDesc type = TypeDesc.forClass(Object[].class); b.invokeStatic("java.util.Arrays", "deepEquals",
private void addPropertyAppendCall(CodeBuilder b, StorableProperty property) { b.loadConstant(property.getName()); invokeAppend(b, TypeDesc.STRING); b.loadConstant('='); invokeAppend(b, TypeDesc.CHAR); loadThisProperty(b, property); TypeDesc type = TypeDesc.forClass(property.getType()); if (type.isPrimitive()) { if (type == TypeDesc.BYTE || type == TypeDesc.SHORT) { type = TypeDesc.INT; } } else { if (type != TypeDesc.STRING) { if (type.isArray()) { if (!type.getComponentType().isPrimitive()) { b.invokeStatic("java.util.Arrays", "deepToString", TypeDesc.STRING, new TypeDesc[] {TypeDesc.OBJECT.toArrayType()}); } else { b.invokeStatic("java.util.Arrays", TO_STRING_METHOD_NAME, TypeDesc.STRING, new TypeDesc[] {type}); } } type = TypeDesc.OBJECT; } } invokeAppend(b, type); }
private void addPropertyAppendCall(CodeBuilder b, StorableProperty property) { b.loadConstant(property.getName()); invokeAppend(b, TypeDesc.STRING); b.loadConstant('='); invokeAppend(b, TypeDesc.CHAR); loadThisProperty(b, property); TypeDesc type = TypeDesc.forClass(property.getType()); if (type.isPrimitive()) { if (type == TypeDesc.BYTE || type == TypeDesc.SHORT) { type = TypeDesc.INT; } } else { if (type != TypeDesc.STRING) { if (type.isArray()) { if (!type.getComponentType().isPrimitive()) { b.invokeStatic("java.util.Arrays", "deepToString", TypeDesc.STRING, new TypeDesc[] {TypeDesc.OBJECT.toArrayType()}); } else { b.invokeStatic("java.util.Arrays", TO_STRING_METHOD_NAME, TypeDesc.STRING, new TypeDesc[] {type}); } } type = TypeDesc.OBJECT; } } invokeAppend(b, type); }
if (fieldType.isArray()) { TypeDesc arraysDesc = TypeDesc.forClass(Arrays.class); TypeDesc componentType = fieldType.getComponentType(); TypeDesc arrayType = fieldType; String methodName;
if (fieldType.isArray()) { TypeDesc arraysDesc = TypeDesc.forClass(Arrays.class); TypeDesc componentType = fieldType.getComponentType(); TypeDesc arrayType = fieldType; String methodName;