use of org.objectweb.asm.Type in project bytecode-viewer by Konloch.
the class SimpleVerifier method isSubTypeOf.
@Override
protected boolean isSubTypeOf(final BasicValue value, final BasicValue expected) {
Type expectedType = expected.getType();
Type type = value.getType();
switch(expectedType.getSort()) {
case Type.INT:
case Type.FLOAT:
case Type.LONG:
case Type.DOUBLE:
return type.equals(expectedType);
case Type.ARRAY:
case Type.OBJECT:
if ("Lnull;".equals(type.getDescriptor())) {
return true;
} else if (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY) {
return isAssignableFrom(expectedType, type);
} else {
return false;
}
default:
throw new Error("Internal error");
}
}
use of org.objectweb.asm.Type in project bytecode-viewer by Konloch.
the class SimpleVerifier method merge.
@Override
public BasicValue merge(final BasicValue v, final BasicValue w) {
if (!v.equals(w)) {
Type t = v.getType();
Type u = w.getType();
if (t != null && (t.getSort() == Type.OBJECT || t.getSort() == Type.ARRAY)) {
if (u != null && (u.getSort() == Type.OBJECT || u.getSort() == Type.ARRAY)) {
if ("Lnull;".equals(t.getDescriptor())) {
return w;
}
if ("Lnull;".equals(u.getDescriptor())) {
return v;
}
if (isAssignableFrom(t, u)) {
return v;
}
if (isAssignableFrom(u, t)) {
return w;
}
// interfaces
do {
if (t == null || isInterface(t)) {
return BasicValue.REFERENCE_VALUE;
}
t = getSuperClass(t);
if (isAssignableFrom(t, u)) {
return newValue(t);
}
} while (true);
}
}
return BasicValue.UNINITIALIZED_VALUE;
}
return v;
}
use of org.objectweb.asm.Type in project gradle by gradle.
the class ClassDependenciesVisitor method visitMethod.
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
Type methodType = Type.getMethodType(desc);
maybeAddDependentType(methodType.getReturnType().getClassName());
for (Type argType : methodType.getArgumentTypes()) {
maybeAddDependentType(argType.getClassName());
}
return localVariableVisitor;
}
use of org.objectweb.asm.Type in project gradle by gradle.
the class ManagedCollectionProxyClassGenerator method generate.
/**
* Generates an implementation of the given managed type.
*
* <p>The generated type will:</p>
*
* <ul>
* <li>extend the given implementation class</li>
* <li>implement the given public interface</li>
* <li>override each public constructor of the given implementation class</li>
* </ul>
*/
public Class<?> generate(Class<?> implClass, Class<?> publicContractType) {
AsmClassGenerator classGenerator = new AsmClassGenerator(publicContractType, "_Impl");
ClassWriter visitor = classGenerator.getVisitor();
Type generatedType = classGenerator.getGeneratedType();
Type superclassType = Type.getType(implClass);
Type publicType = Type.getType(publicContractType);
generateClass(visitor, generatedType, superclassType, publicType);
generateConstructors(visitor, implClass, superclassType);
visitor.visitEnd();
return classGenerator.define();
}
use of org.objectweb.asm.Type in project Lucee by lucee.
the class ExpressionAsStatement method _writeOut.
/**
* @see lucee.transformer.bytecode.statement.StatementBase#_writeOut(org.objectweb.asm.commons.GeneratorAdapter)
*/
@Override
public void _writeOut(BytecodeContext bc) throws TransformerException {
GeneratorAdapter adapter = bc.getAdapter();
int rtn = bc.getReturn();
// set rtn
if (rtn > -1) {
Type type = expr.writeOut(bc, Expression.MODE_REF);
bc.getAdapter().storeLocal(rtn);
} else {
if (!(expr instanceof Literal)) {
Type type = expr.writeOut(bc, Expression.MODE_VALUE);
if (!type.equals(Types.VOID)) {
ASMUtil.pop(adapter, type);
}
}
}
}
Aggregations