use of org.objectweb.asm.Type in project cglib by cglib.
the class ParallelSorterEmitter method generateConstructor.
private void generateConstructor(Object[] arrays) {
CodeEmitter e = begin_method(Constants.ACC_PUBLIC, CSTRUCT_OBJECT_ARRAY, null);
e.load_this();
e.super_invoke_constructor();
e.load_this();
e.load_arg(0);
e.super_putfield("a", Constants.TYPE_OBJECT_ARRAY);
for (int i = 0; i < arrays.length; i++) {
Type type = Type.getType(arrays[i].getClass());
declare_field(Constants.ACC_PRIVATE, getFieldName(i), type, null);
e.load_this();
e.load_arg(0);
e.push(i);
e.aaload();
e.checkcast(type);
e.putfield(getFieldName(i));
}
e.return_value();
e.end_method();
}
use of org.objectweb.asm.Type in project cglib by cglib.
the class ParallelSorterEmitter method generateSwap.
private void generateSwap(final Object[] arrays) {
CodeEmitter e = begin_method(Constants.ACC_PUBLIC, SWAP, null);
for (int i = 0; i < arrays.length; i++) {
Type type = Type.getType(arrays[i].getClass());
Type component = TypeUtils.getComponentType(type);
Local T = e.make_local(type);
e.load_this();
e.getfield(getFieldName(i));
e.store_local(T);
e.load_local(T);
e.load_arg(0);
e.load_local(T);
e.load_arg(1);
e.array_load(component);
e.load_local(T);
e.load_arg(1);
e.load_local(T);
e.load_arg(0);
e.array_load(component);
e.array_store(component);
e.array_store(component);
}
e.return_value();
e.end_method();
}
use of org.objectweb.asm.Type in project buck by facebook.
the class FirstOrderHelper method addFirstOrderTypes.
private void addFirstOrderTypes(Type type) {
addTypeAndSupers(type);
FirstOrderTypeInfo info = knownTypes.get(type);
if (info != null) {
for (Type dependency : info.observedDependencies) {
addTypeAndSupers(dependency);
}
}
}
use of org.objectweb.asm.Type in project buck by facebook.
the class FirstOrderHelper method addDependencies.
private ImmutableSet<String> addDependencies(Iterable<ClassNode> allClasses) {
for (ClassNode classNode : allClasses) {
FirstOrderVisitorContext context = new FirstOrderVisitorContext();
classNode.accept(context.classVisitor);
FirstOrderTypeInfo info = context.builder.build();
knownTypes.put(info.type, info);
}
for (Type type : scenarioTypes) {
addFirstOrderTypes(type);
}
return resultBuilder.build();
}
use of org.objectweb.asm.Type in project enumerable by hraberg.
the class ExpressionInterpreter method newOperation.
public Value newOperation(final AbstractInsnNode insn) throws AnalyzerException {
switch(insn.getOpcode()) {
case ACONST_NULL:
return new ExpressionValue(createClassOrInterfaceType(Object.class.getName()), new NullLiteralExpr());
case ICONST_M1:
return new ExpressionValue(PRIMITIVE_INT, new UnaryExpr(new IntegerLiteralExpr("1"), UnaryExpr.Operator.negative));
case ICONST_0:
return new ExpressionValue(PRIMITIVE_INT, new IntegerLiteralExpr("0"));
case ICONST_1:
return new ExpressionValue(PRIMITIVE_INT, new IntegerLiteralExpr("1"));
case ICONST_2:
return new ExpressionValue(PRIMITIVE_INT, new IntegerLiteralExpr("2"));
case ICONST_3:
return new ExpressionValue(PRIMITIVE_INT, new IntegerLiteralExpr("3"));
case ICONST_4:
return new ExpressionValue(PRIMITIVE_INT, new IntegerLiteralExpr("4"));
case ICONST_5:
return new ExpressionValue(PRIMITIVE_INT, new IntegerLiteralExpr("5"));
case LCONST_0:
return new ExpressionValue(PRIMITIVE_LONG, new LongLiteralExpr("0L"));
case LCONST_1:
return new ExpressionValue(PRIMITIVE_LONG, new LongLiteralExpr("1L"));
case FCONST_0:
return new ExpressionValue(PRIMITIVE_FLOAT, new DoubleLiteralExpr("0.0f"));
case FCONST_1:
return new ExpressionValue(PRIMITIVE_FLOAT, new DoubleLiteralExpr("1.0f"));
case FCONST_2:
return new ExpressionValue(PRIMITIVE_FLOAT, new DoubleLiteralExpr("2.0f"));
case DCONST_0:
return new ExpressionValue(PRIMITIVE_DOUBLE, new DoubleLiteralExpr("0.0"));
case DCONST_1:
return new ExpressionValue(PRIMITIVE_DOUBLE, new DoubleLiteralExpr("1.0"));
case BIPUSH:
case SIPUSH:
int operand = ((IntInsnNode) insn).operand;
if (operand < 0)
return new ExpressionValue(PRIMITIVE_INT, new UnaryExpr(new IntegerLiteralExpr("" + Math.abs(operand)), UnaryExpr.Operator.negative));
return new ExpressionValue(PRIMITIVE_INT, new IntegerLiteralExpr("" + operand));
case LDC:
Object cst = ((LdcInsnNode) insn).cst;
if (cst instanceof Number) {
ExpressionValue value = null;
if (cst instanceof Integer) {
value = new ExpressionValue(PRIMITIVE_INT, new IntegerLiteralExpr(cst.toString()));
} else if (cst instanceof Float) {
value = new ExpressionValue(PRIMITIVE_FLOAT, new DoubleLiteralExpr(cst.toString() + "f"));
} else if (cst instanceof Long) {
value = new ExpressionValue(PRIMITIVE_LONG, new LongLiteralExpr(cst.toString() + "L"));
} else if (cst instanceof Double) {
value = new ExpressionValue(PRIMITIVE_DOUBLE, new DoubleLiteralExpr(cst.toString()));
}
if (((Number) cst).intValue() < 0) {
StringLiteralExpr expr = (StringLiteralExpr) value.expression;
expr.setValue(expr.getValue().substring("-".length()));
value.expression = new UnaryExpr(expr, UnaryExpr.Operator.negative);
}
return value;
} else if (cst instanceof Type) {
ClassExpr classExpr = new ClassExpr(new ReferenceType(createClassOrInterfaceType(((Type) cst).getClassName())));
return new ExpressionValue(createClassOrInterfaceType(Class.class.getName()), classExpr);
} else {
return new ExpressionValue(createClassOrInterfaceType(String.class.getName()), new StringLiteralExpr(cst.toString()));
}
case JSR:
throw new UnsupportedOperationException(AbstractVisitor.OPCODES[insn.getOpcode()]);
case GETSTATIC:
FieldInsnNode fieldNode = (FieldInsnNode) insn;
ExpressionValue getField = (ExpressionValue) newValue(getType(fieldNode.desc));
getField.expression = new FieldAccessExpr(new NameExpr(removeJavaLang(getObjectType(fieldNode.owner).getClassName())), fieldNode.name);
return getField;
case NEW:
return newValue(Type.getObjectType(((TypeInsnNode) insn).desc));
default:
throw new Error("Internal error.");
}
}
Aggregations