InlineIfBytecodeExpression(BytecodeExpression condition, BytecodeExpression ifTrue, BytecodeExpression ifFalse) { super(ifTrue.getType()); this.condition = condition; this.ifTrue = requireNonNull(ifTrue, "ifTrue is null"); this.ifFalse = requireNonNull(ifFalse, "ifFalse is null"); checkArgument(condition.getType().getPrimitiveType() == boolean.class, "Expected condition to be type boolean but is %s", condition.getType()); checkArgument(ifTrue.getType().equals(ifFalse.getType()), "Expected ifTrue and ifFalse to be the same type"); }
private boolean isSubclassOf(ClassInfo that) { for (ClassInfo classInfo = this; classInfo != null; classInfo = classInfo.getSuperclass()) { if (classInfo.getSuperclass() != null && classInfo.getSuperclass().type.equals(that.type)) { return true; } } return false; }
private boolean implementsInterface(ClassInfo that) { for (ClassInfo classInfo = this; classInfo != null; classInfo = classInfo.getSuperclass()) { for (ClassInfo anInterface : classInfo.getInterfaces()) { if (anInterface.type.equals(that.type) || anInterface.implementsInterface(that)) { return true; } } } return false; }
public SetArrayElementBytecodeExpression(BytecodeExpression instance, BytecodeExpression index, BytecodeExpression value) { super(type(void.class)); this.instance = requireNonNull(instance, "instance is null"); this.index = requireNonNull(index, "index is null"); this.value = requireNonNull(value, "value is null"); ParameterizedType componentType = instance.getType().getArrayComponentType(); checkArgument(index.getType().getPrimitiveType() == int.class, "index must be int type, but is " + index.getType()); checkArgument(componentType.equals(value.getType()), "value must be %s type, but is %s", componentType, value.getType()); this.arrayStoreInstruction = getArrayOpCode(componentType).getStore(); }
checkArgument(left.getType().equals(right.getType()), "left and right must be the same type");
checkArgument(left.getType().equals(right.getType()), "left and right must be the same type");
public boolean isAssignableFrom(ClassInfo that) { if (this == that) { return true; } if (that.isSubclassOf(this)) { return true; } if (that.implementsInterface(this)) { return true; } if (that.isInterface() && getType().equals(type(Object.class))) { return true; } return false; }
return block.invokeStatic(targetType, "valueOf", targetType, sourceType); case OTHER: checkArgument(OBJECT_TYPE.equals(targetType), "Type %s can not be cast to %s", sourceType, targetType); Class<?> sourceClass = sourceType.getPrimitiveType(); return block return block.invokeVirtual(sourceType, targetType.getPrimitiveType().getSimpleName() + "Value", targetType); case BOXED_PRIMITVE: checkArgument(sourceType.equals(targetType), "Type %s can not be cast to %s", sourceType, targetType); return block; case OTHER: switch (getTypeKind(targetType)) { case PRIMITIVE: checkArgument(OBJECT_TYPE.equals(sourceType), "Type %s can not be cast to %s", sourceType, targetType); return block .checkCast(wrap(targetType.getPrimitiveType()))
if (!classDefinition.getSuperClass().equals(type(Object.class))) { classDeclaration.add("extends").add(classDefinition.getSuperClass().getJavaClassName());