public static boolean isTypeBoxingOptimized(TypeBoxingOptimization boxing, TypeMirror type) { switch (boxing) { case NONE: return false; case ALWAYS: return !ElementUtils.isObject(type) && !ElementUtils.isVoid(type); case PRIMITIVE: return ElementUtils.isPrimitive(type); default: throw new AssertionError(); } }
public String checkSignature(ExecutableElement method) { final List<? extends VariableElement> params = method.getParameters(); boolean hasFrameArgument = false; if (params.size() >= 1) { hasFrameArgument = ElementUtils.typeEquals(params.get(0).asType(), Utils.getTypeMirror(processingEnv, VirtualFrame.class)); } int expectedNumberOfArguments = hasFrameArgument ? 2 : 1; if (!ElementUtils.typeEquals(params.get(hasFrameArgument ? 1 : 0).asType(), Utils.getTypeMirror(processingEnv, TruffleObject.class))) { return "The receiver type must be TruffleObject"; } if (!ElementUtils.isPrimitive(method.getReturnType()) || method.getReturnType().getKind() != TypeKind.BOOLEAN) { return "Method must return a boolean value"; } if (params.size() != expectedNumberOfArguments) { return "Wrong number of arguments."; } if (method.getThrownTypes().size() > 0) { return "Method test must not throw a checked exception."; } return null; }
private List<TypeMirror> resolveOptimizedImplicitSourceTypes(NodeExecutionData execution, TypeMirror targetType) { List<TypeMirror> allSourceTypes = typeSystem.lookupSourceTypes(targetType); List<TypeMirror> filteredSourceTypes = new ArrayList<>(); for (TypeMirror sourceType : allSourceTypes) { ExecutableTypeData executableType = resolveTargetExecutable(execution, sourceType); if (executableType == null) { continue; } if (!ElementUtils.isPrimitive(sourceType) || !boxingEliminationEnabled) { // don't optimize non primitives continue; } if (!ElementUtils.typeEquals(executableType.getReturnType(), sourceType)) { // no boxing optimization possible continue; } filteredSourceTypes.add(sourceType); } return filteredSourceTypes; }
for (Parameter p : specialization.getSignatureParameters()) { index++; if (!ElementUtils.isPrimitive(p.getType())) { continue; } else if (index < evaluatedcount) {
if (ElementUtils.isPrimitive(from) && ElementUtils.isPrimitive(to)) { TypeKind fromKind = from.getKind(); TypeKind toKind = to.getKind(); } else if (ElementUtils.isPrimitive(from) || ElementUtils.isPrimitive(to)) { return false;
if (ElementUtils.isPrimitive(from) && ElementUtils.isPrimitive(to)) { TypeKind fromKind = from.getKind(); TypeKind toKind = to.getKind(); } else if (ElementUtils.isPrimitive(from) || ElementUtils.isPrimitive(to)) { return false;
} else { TypeMirror returnType = executable.getReturnType(); if (boxingEliminationEnabled && (isVoid(returnType) || ElementUtils.isPrimitive(returnType))) { for (TypeMirror specializedReturnType : specializedReturnTypes) { if (isSubtypeBoxed(context, specializedReturnType, returnType)) {
public void visitBinary(Binary binary) { String operator = binary.getOperator(); TypeMirror leftType = binary.getLeft().getResolvedType(); TypeMirror rightType = binary.getRight().getResolvedType(); if (!ElementUtils.areTypesCompatible(leftType, rightType)) { throw new InvalidExpressionException(String.format("Incompatible operand types %s and %s.", ElementUtils.getSimpleName(leftType), ElementUtils.getSimpleName(rightType))); } TypeMirror booleanType = context.getType(boolean.class); boolean valid; if (LOGIC_OPERATORS.contains(operator)) { valid = ElementUtils.typeEquals(leftType, booleanType); } else if (COMPARABLE_OPERATORS.contains(operator)) { valid = ElementUtils.isPrimitive(leftType); } else if (IDENTITY_OPERATORS.contains(operator)) { valid = leftType.getKind().isPrimitive() || leftType.getKind() == TypeKind.DECLARED || leftType.getKind() == TypeKind.ARRAY; } else { throw new InvalidExpressionException(String.format("The operator %s is undefined.", operator)); } binary.setResolvedType(booleanType); if (!valid) { throw new InvalidExpressionException(String.format("The operator %s is undefined for the argument type(s) %s %s.", operator, ElementUtils.getSimpleName(leftType), ElementUtils.getSimpleName(rightType))); } }
public void visitBinary(Binary binary) { String operator = binary.getOperator(); TypeMirror leftType = binary.getLeft().getResolvedType(); TypeMirror rightType = binary.getRight().getResolvedType(); if (!ElementUtils.areTypesCompatible(leftType, rightType)) { throw new InvalidExpressionException(String.format("Incompatible operand types %s and %s.", ElementUtils.getSimpleName(leftType), ElementUtils.getSimpleName(rightType))); } TypeMirror booleanType = context.getType(boolean.class); boolean valid; if (LOGIC_OPERATORS.contains(operator)) { valid = ElementUtils.typeEquals(leftType, booleanType); } else if (COMPARABLE_OPERATORS.contains(operator)) { valid = ElementUtils.isPrimitive(leftType); } else if (IDENTITY_OPERATORS.contains(operator)) { valid = leftType.getKind().isPrimitive() || leftType.getKind() == TypeKind.DECLARED || leftType.getKind() == TypeKind.ARRAY; } else { throw new InvalidExpressionException(String.format("The operator %s is undefined.", operator)); } binary.setResolvedType(booleanType); if (!valid) { throw new InvalidExpressionException(String.format("The operator %s is undefined for the argument type(s) %s %s.", operator, ElementUtils.getSimpleName(leftType), ElementUtils.getSimpleName(rightType))); } }
if (isPrimitive(type1) || isPrimitive(type2)) { return context.getType(Object.class);
if (isPrimitive(type1) || isPrimitive(type2)) { return context.getType(Object.class);
for (CacheExpression expression : specialization.getCaches()) { TypeMirror type = expression.getParameter().getType(); if (ElementUtils.isPrimitive(type)) { switch (type.getKind()) { case BOOLEAN:
for (SpecializationData specialization : reachableSpecializations) { TypeMirror returnType = specialization.getReturnType().getType(); if (ElementUtils.isPrimitive(returnType)) { optimizeTypes.add(returnType);
if (boxingEliminationEnabled) { for (TypeGuard checkedGuard : group.getTypeGuards()) { if (!ElementUtils.isPrimitive(checkedGuard.getType())) { if (ElementUtils.isPrimitive(sType)) { accessBuilder.string("(").type(generic).string(") "); if (first && ElementUtils.isPrimitive(targetType)) { accessBuilder.string("(").type(generic).string(") ");
checkBuilder.string("("); CodeTreeBuilder referenceBuilder = checkBuilder.create(); if (!ElementUtils.isPrimitive(shortCircuit.getTypeMirror())) { referenceBuilder.string("(boolean) ");