@Override protected int calculateRequiredBits(Object object) { if (object instanceof SpecializationData) { SpecializationData specialization = (SpecializationData) object; if (specialization.isPolymorphic()) { return 0; } else { return 1; } } else if (object instanceof TypeGuard) { TypeGuard guard = (TypeGuard) object; TypeMirror type = guard.getType(); List<TypeMirror> sourceTypes = typeSystem.lookupSourceTypes(type); if (sourceTypes.size() > 1) { return sourceTypes.size(); } throw new AssertionError(); } else if (object instanceof GuardExpression) { return 1; } else { throw new AssertionError(); } }
int index = 0; for (TypeGuard typeGuard : signature) { signatureMirrors[index] = typeGuard.getType(); index++;
if (needsCastTo(value.getTypeMirror(), guard.getType())) { return true;
cachedTriples.add(triple); hasImplicitCast = hasImplicitCast || node.getTypeSystem().hasImplicitSourceTypes(guard.getType()); if (!mode.isGuardFallback()) { triple = createTypeCheckOrCast(frameState, group, guard, mode, true, true);
int signatureIndex = typeGuard.getSignatureIndex(); LocalVariable value = currentValues.getValue(signatureIndex); TypeMirror targetType = typeGuard.getType(); if (!ElementUtils.needsCastTo(value.getTypeMirror(), targetType)) { continue; LocalVariable castVariable = currentValues.getValue(execution).nextName().newType(typeGuard.getType()).accessWith(null); currentValues.setValue(execution, castVariable); localsBuilder.tree(castVariable.createDeclaration(castBuilder.build()));
int signatureIndex = typeGuard.getSignatureIndex(); LocalVariable value = frameState.getValue(signatureIndex); TypeMirror targetType = typeGuard.getType(); LocalVariable currentValue = frameState.getValue(execution); CodeTreeBuilder localsBuilder = CodeTreeBuilder.createBuilder(); LocalVariable castVariable = currentValue.nextName().newType(typeGuard.getType()).accessWith(null); frameState.setValue(execution, castVariable); localsBuilder.tree(castVariable.createDeclaration(castBuilder.build()));
if (boxingEliminationEnabled) { for (TypeGuard checkedGuard : group.getTypeGuards()) { if (!ElementUtils.isPrimitive(checkedGuard.getType())) { } else if (node.getChildExecutions().get(checkedGuard.getSignatureIndex()).getChild().findExecutableType(checkedGuard.getType()) == null) { targetType = eliminatedGuard.getType(); } else { targetType = execution.getChild().findAnyGenericExecutableType(context).getReturnType();
if (resolveOptimizedImplicitSourceTypes(execution, checkedGuard.getType()).size() > 1) { canExecuteChild = false; break;
protected String toString(Object element) { if (element instanceof SpecializationData) { SpecializationData specialization = (SpecializationData) element; if (specialization.isUninitialized()) { return "uninitialized"; } return ElementUtils.createReferenceName(specialization.getMethod()); } else if (element instanceof TypeGuard) { int index = ((TypeGuard) element).getSignatureIndex(); String simpleName = ElementUtils.getSimpleName(((TypeGuard) element).getType()); return index + ":" + simpleName; } return element.toString(); }