/** * @return the result {@link Type#getArgumentsAndReturnSizes} on {@link #value} (memoized in * {@link #info} for efficiency). This should only be used for {@link * #CONSTANT_METHODREF_TAG}, {@link #CONSTANT_INTERFACE_METHODREF_TAG} and {@link * #CONSTANT_INVOKE_DYNAMIC_TAG} symbols. */ int getArgumentsAndReturnSizes() { if (info == 0) { info = Type.getArgumentsAndReturnSizes(value); } return info; } }
} else if (value instanceof Type) { Type type = (Type) value; int typeSort = type.getSort(); if (typeSort == Type.OBJECT) { return addConstantClass(type.getInternalName()); } else if (typeSort == Type.METHOD) { return addConstantMethodType(type.getDescriptor()); } else { // type is a primitive or array type. return addConstantClass(type.getDescriptor());
public void emitUnboxed(C context, ObjExpr objx, GeneratorAdapter gen){ if(method != null) { Type type = Type.getType(method.getDeclaringClass()); target.emit(C.EXPRESSION, objx, gen); //if(!method.getDeclaringClass().isInterface()) gen.checkCast(type); MethodExpr.emitTypedArgs(objx, gen, method.getParameterTypes(), args); gen.visitLineNumber(line, gen.mark()); if(context == C.RETURN) { ObjMethod method = (ObjMethod) METHOD.deref(); method.emitClearLocals(gen); } Method m = new Method(methodName, Type.getReturnType(method), Type.getArgumentTypes(method)); if(method.getDeclaringClass().isInterface()) gen.invokeInterface(type, m); else gen.invokeVirtual(type, m); } else throw new UnsupportedOperationException("Unboxed emit of unknown member"); }
Type[] types = Type.getArgumentTypes(desc); for (int i = 0; i < types.length; ++i) { Type type = types[i]; switch (type.getSort()) { case Type.BOOLEAN: case Type.CHAR: break; case Type.ARRAY: locals.add(types[i].getDescriptor()); break; locals.add(types[i].getInternalName());
static Type getType(Class c){ String descriptor = Type.getType(c).getDescriptor(); if(descriptor.startsWith("L")) descriptor = "L" + destubClassName(descriptor.substring(1)); return Type.getType(descriptor); }
@Override public void visitInvokeDynamicInsn(String name, String desc, Handle bsm, Object... bsmArgs) { mv.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs); if (constructor) { Type[] types = Type.getArgumentTypes(desc); for (int i = 0; i < types.length; i++) { popValue(); if (types[i].getSize() == 2) { popValue(); } } Type returnType = Type.getReturnType(desc); if (returnType != Type.VOID_TYPE) { pushValue(OTHER); if (returnType.getSize() == 2) { pushValue(OTHER); } } } }
return "double"; case ARRAY: StringBuffer b = new StringBuffer(getElementType().getClassName()); for(int i = getDimensions(); i > 0; --i)
if(lb.getPrimitiveType() != null) cv.visitField(access , lb.name, Type.getType(lb.getPrimitiveType()).getDescriptor(), null, null); else , lb.name, OBJECT_TYPE.getDescriptor(), null, null); ctorgen.visitCode(); ctorgen.loadThis(); ctorgen.invokeConstructor(Type.getObjectType(superName), voidctor); ctorgen.returnValue(); ctorgen.endMethod(); ctorgen.visitInsn(Opcodes.ACONST_NULL); ctorgen.invokeConstructor(Type.getObjectType(COMPILE_STUB_PREFIX + "/" + ret.internalName), new Method("<init>", Type.VOID_TYPE, ctorTypes));
+ ACC_STATIC, constantName(i), constantType(i).getDescriptor(), null, null); + ACC_STATIC, siteNameStatic(i), KEYWORD_LOOKUPSITE_TYPE.getDescriptor(), null, null); cv.visitField(ACC_STATIC, thunkNameStatic(i), ILOOKUP_THUNK_TYPE.getDescriptor(), null, null); cv.visitField(ACC_FINAL, "__meta", IPERSISTENTMAP_TYPE.getDescriptor(), null, null); if(lb.getPrimitiveType() != null) fv = cv.visitField(access , lb.name, Type.getType(lb.getPrimitiveType()).getDescriptor(), null, null); else , lb.name, OBJECT_TYPE.getDescriptor(), null, null); addAnnotation(fv, RT.meta(lb.sym)); , lb.name, Type.getType(lb.getPrimitiveType()).getDescriptor(), null, null); else cv.visitField(0 //+ (oneTimeUse ? 0 : ACC_FINAL) , lb.name, OBJECT_TYPE.getDescriptor(), null, null); cv.visitField(ACC_PRIVATE + ACC_STATIC, cachedClassName(i), CLASS_TYPE.getDescriptor(), null, null); ctorgen.invokeConstructor(Type.getObjectType(superName), voidctor);
/** * Creates a new {@link LocalVariablesSorter}. * * @param access access flags of the adapted method. * @param desc the method's descriptor (see {@link Type Type}). * @param mv the method visitor to which this adapter delegates calls. */ public LocalVariablesSorter( final int access, final String desc, final MethodVisitor mv){ super(mv); Type[] args = Type.getArgumentTypes(desc); nextLocal = (Opcodes.ACC_STATIC & access) != 0 ? 0 : 1; for(int i = 0; i < args.length; i++) { nextLocal += args[i].getSize(); } firstLocal = nextLocal; }
/** * Creates a new {@link GeneratorAdapter}. * * @param access access flags of the adapted method. * @param method the adapted method. * @param mv the method visitor to which this adapter delegates calls. */ public GeneratorAdapter( final int access, final Method method, final MethodVisitor mv){ super(access, method.getDescriptor(), mv); this.access = access; this.returnType = method.getReturnType(); this.argumentTypes = method.getArgumentTypes(); }
public final static Type VOID_TYPE = new Type(VOID); public final static Type BOOLEAN_TYPE = new Type(BOOLEAN); public final static Type CHAR_TYPE = new Type(CHAR); public final static Type BYTE_TYPE = new Type(BYTE); return getType(typeDescriptor.toCharArray(), 0); while(buf[off] != ')') args[size] = getType(buf, off); off += args[size].len; size += 1; return getType(buf, methodDescriptor.indexOf(')') + 1); for(int i = 0; i < argumentTypes.length; ++i) argumentTypes[i].getDescriptor(buf); returnType.getDescriptor(buf); return buf.toString();
/** * Returns a string representation of this type. * * @return the descriptor of this type. */ @Override public String toString() { return getDescriptor(); } }
gen.invokeStatic(Type.getType(Integer.class), Method.getMethod("Integer valueOf(int)")); gen.invokeStatic(Type.getType(Long.class), Method.getMethod("Long valueOf(long)")); gen.invokeStatic(Type.getType(Double.class), Method.getMethod("Double valueOf(double)")); gen.invokeStatic(Type.getType(Character.class), Method.getMethod("Character valueOf(char)")); if ( cc == boolean.class ) bt = Type.getType(Boolean.class); else if ( cc == byte.class ) bt = Type.getType(Byte.class); else if ( cc == char.class ) bt = Type.getType(Character.class); else if ( cc == double.class ) bt = Type.getType(Double.class); else if ( cc == float.class ) bt = Type.getType(Float.class); else if ( cc == int.class ) bt = Type.getType(Integer.class); else if ( cc == long.class ) bt = Type.getType(Long.class); else if ( cc == short.class ) bt = Type.getType(Short.class); else throw Util.runtimeException( "Can't embed unknown primitive in code: " + value); gen.getStatic( bt, "TYPE", Type.getType(Class.class) ); gen.invokeStatic(Type.getType(Symbol.class), Method.getMethod("clojure.lang.Symbol intern(String,String)")); Method ctor = new Method("<init>", Type.getConstructorDescriptor(value.getClass().getConstructors()[0])); gen.newInstance(Type.getType(value.getClass())); gen.dup(); IPersistentVector fields = (IPersistentVector) Reflector.invokeStaticMethod(value.getClass(), "getBasis", new Object[]{}); Type b = Type.getType(boxClass(k));
gen.visitVarInsn(Type.getType(primc).getOpcode(Opcodes.ISTORE), bi.binding.idx); gen.visitVarInsn(OBJECT_TYPE.getOpcode(Opcodes.ISTORE), bi.binding.idx); Class primc = maybePrimitiveType(bi.init); if(primc != null) gen.visitLocalVariable(lname, Type.getDescriptor(primc), null, bindingLabels.get(bi), end, bi.binding.idx); else
if(k.isPrimitive()) mv.visitTypeInsn(CHECKCAST, Type.getType(boxClass(k)).getInternalName()); if(k.isPrimitive()) String b = Type.getType(boxClass(k)).getInternalName(); String p = Type.getType(k).getDescriptor(); String n = k.getName();
/** * Returns the Java method type corresponding to the given constructor. * * @param c * a {@link Constructor Constructor} object. * @return the Java method type corresponding to the given constructor. */ public static Type getType(final Constructor<?> c) { return getType(getConstructorDescriptor(c)); }
/** * Returns the argument types of methods of this type. This method should * only be used for method types. * * @return the argument types of methods of this type. */ public Type[] getArgumentTypes() { return getArgumentTypes(getDescriptor()); }
/** * Returns the type of the elements of this array type. This method should * only be used for an array type. * * @return Returns the type of the elements of this array type. */ public Type getElementType() { return getType(buf, off + getDimensions()); }
/** * Returns the return type of methods of this type. This method should only * be used for method types. * * @return the return type of methods of this type. */ public Type getReturnType() { return getReturnType(getDescriptor()); }