public void atCastExpr(CastExpr expr) throws CompileError { String cname = resolveClassName(expr.getClassName()); String toClass = checkCastExpr(expr, cname); int srcType = exprType; exprType = expr.getType(); arrayDim = expr.getArrayDim(); className = cname; if (toClass == null) atNumCastExpr(srcType, exprType); // built-in type else bytecode.addCheckcast(toClass); }
@Override public Expr visitCastExpr(ExprNormalizedResult ctx, Stack<Expr> stack, CastExpr expr) throws PlanningException { super.visitCastExpr(ctx, stack, expr); if (expr.getChild().getType() == OpType.GeneralSetFunction || expr.getChild().getType() == OpType.CountRowsFunction) { String referenceName = ctx.block.namedExprsMgr.addExpr(expr.getChild()); ctx.aggExprs.add(new NamedExpr(expr.getChild(), referenceName)); expr.setChild(new ColumnReferenceExpr(referenceName)); } return expr; }
@Override public Boolean visit(final CastExpr n1, final Node arg) { final CastExpr n2 = (CastExpr) arg; if (!nodeEquals(n1.getType(), n2.getType())) { return Boolean.FALSE; } if (!nodeEquals(n1.getExpr(), n2.getExpr())) { return Boolean.FALSE; } return Boolean.TRUE; }
private String checkCastExpr(CastExpr expr, String name) throws CompileError { final String msg = "invalid cast"; ASTree oprand = expr.getOprand(); int dim = expr.getArrayDim(); int type = expr.getType(); oprand.accept(this); int srcType = exprType; if (invalidDim(srcType, arrayDim, className, type, dim, name, true) || srcType == VOID || type == VOID) throw new CompileError(msg); if (type == CLASS) { if (!isRefType(srcType)) throw new CompileError(msg); return toJvmArrayName(name, dim); } else if (dim > 0) return toJvmTypeName(type, dim); else return null; // built-in type }
public void visit(CastExpr n, Object arg) { n.getType().accept(this, arg); n.getExpr().accept(this, arg); }
public Object visit(CastExpr node) { return layoutUnary("cast to " + node.getType(), node.getExpr()); }