@Override public String visitCast(Cast node, Void context) { return (node.isSafe() ? "TRY_CAST" : "CAST") + "(" + process(node.getExpression(), context) + " AS " + node.getType() + ")"; }
@Override public String visitCast(Cast node, Void context) { return (node.isSafe() ? "TRY_CAST" : "CAST") + "(" + process(node.getExpression(), context) + " AS " + node.getType() + ")"; }
@Override protected Boolean visitCast(Cast actual, Node expectedExpression) { if (!(expectedExpression instanceof Cast)) { return false; } Cast expected = (Cast) expectedExpression; if (!actual.getType().equals(expected.getType())) { return false; } return process(actual.getExpression(), expected.getExpression()); }
@Override protected Boolean visitCast(Cast actual, Node expectedExpression) { if (!(expectedExpression instanceof Cast)) { return false; } Cast expected = (Cast) expectedExpression; if (!actual.getType().equals(expected.getType())) { return false; } return process(actual.getExpression(), expected.getExpression()); }
@Override public Type visitCast(Cast node, StackableAstVisitorContext<Context> context) { Type type; try { type = typeManager.getType(parseTypeSignature(node.getType())); } catch (IllegalArgumentException e) { throw new SemanticException(TYPE_MISMATCH, node, "Unknown type: " + node.getType()); } if (type.equals(UNKNOWN)) { throw new SemanticException(TYPE_MISMATCH, node, "UNKNOWN is not a valid type"); } Type value = process(node.getExpression(), context); if (!value.equals(UNKNOWN) && !node.isTypeOnly()) { try { functionRegistry.getCoercion(value, type); } catch (OperatorNotFoundException e) { throw new SemanticException(TYPE_MISMATCH, node, "Cannot cast %s to %s", value, type); } } return setExpressionType(node, type); }
@Override public Type visitCast(Cast node, StackableAstVisitorContext<Context> context) { Type type; try { type = typeManager.getType(parseTypeSignature(node.getType())); } catch (IllegalArgumentException e) { throw new SemanticException(TYPE_MISMATCH, node, "Unknown type: " + node.getType()); } if (type.equals(UNKNOWN)) { throw new SemanticException(TYPE_MISMATCH, node, "UNKNOWN is not a valid type"); } Type value = process(node.getExpression(), context); if (!value.equals(UNKNOWN) && !node.isTypeOnly()) { try { functionRegistry.getCoercion(value, type); } catch (OperatorNotFoundException e) { throw new SemanticException(TYPE_MISMATCH, node, "Cannot cast %s to %s", value, type); } } return setExpressionType(node, type); }
Type targetType = metadata.getType(parseTypeSignature(node.getType())); if (targetType == null) { throw new IllegalArgumentException("Unsupported type: " + node.getType()); return new Cast((Expression) value, node.getType(), node.isSafe(), node.isTypeOnly()); return new Cast(toExpression(value, sourceType), node.getType(), node.isSafe(), node.isTypeOnly());
Type targetType = metadata.getType(parseTypeSignature(node.getType())); if (targetType == null) { throw new IllegalArgumentException("Unsupported type: " + node.getType()); return new Cast((Expression) value, node.getType(), node.isSafe(), node.isTypeOnly()); return new Cast(toExpression(value, sourceType), node.getType(), node.isSafe(), node.isTypeOnly());
TypeSignature targetType = TypeSignature.parseTypeSignature(node.getType());
TypeSignature targetType = TypeSignature.parseTypeSignature(node.getType());