public static Expr unary(UnaryOperation op, OperationType type, Expr arg) { UnaryExpr expr = new UnaryExpr(); expr.setOperand(arg); expr.setOperation(op); expr.setType(type); return expr; }
@Override protected Expr clone(Map<Expr, Expr> cache) { Expr known = cache.get(this); if (known != null) { return known; } UnaryExpr copy = new UnaryExpr(); copy.setOperation(operation); copy.setOperand(operand != null ? operand.clone(cache) : null); copy.setType(type); return copy; } }
public static Expr invert(Expr expr) { UnaryExpr result = new UnaryExpr(); result.setOperand(expr); result.setOperation(UnaryOperation.NOT); result.setLocation(expr.getLocation()); return result; }
@Override public void visit(UnaryExpr expr) { pushLocation(expr.getLocation()); try { expr.getOperand().acceptVisitor(this); Expr operand = resultExpr; if (expr.getOperation() == UnaryOperation.NEGATE && operand instanceof ConstantExpr) { ConstantExpr constantExpr = (ConstantExpr) operand; if (tryMakePositive(constantExpr)) { resultExpr = expr; return; } } expr.setOperand(operand); resultExpr = expr; } finally { popLocation(); } }
byte valueType = input.readByte(); expr.setType(valueType > 0 ? OperationType.values()[valueType] : null); expr.setOperand(readExpr(input)); return expr;
public static Expr unary(UnaryOperation op, OperationType type, Expr arg) { UnaryExpr expr = new UnaryExpr(); expr.setOperand(arg); expr.setOperation(op); expr.setType(type); return expr; }
@Override protected Expr clone(Map<Expr, Expr> cache) { Expr known = cache.get(this); if (known != null) { return known; } UnaryExpr copy = new UnaryExpr(); copy.setOperation(operation); copy.setOperand(operand != null ? operand.clone(cache) : null); copy.setType(type); return copy; } }
public static Expr invert(Expr expr) { UnaryExpr result = new UnaryExpr(); result.setOperand(expr); result.setOperation(UnaryOperation.NOT); result.setLocation(expr.getLocation()); return result; }
@Override public void visit(UnaryExpr expr) { pushLocation(expr.getLocation()); try { expr.getOperand().acceptVisitor(this); Expr operand = resultExpr; if (expr.getOperation() == UnaryOperation.NEGATE && operand instanceof ConstantExpr) { ConstantExpr constantExpr = (ConstantExpr) operand; if (tryMakePositive(constantExpr)) { resultExpr = expr; return; } } expr.setOperand(operand); resultExpr = expr; } finally { popLocation(); } }
byte valueType = input.readByte(); expr.setType(valueType > 0 ? OperationType.values()[valueType] : null); expr.setOperand(readExpr(input)); return expr;