public function leaveOp(Op $op, Block $block) { if (!$op instanceof Op\Expr\Assign) { return null; } if (!$op->expr instanceof Operand\Literal) { // Non-constant op return null; } Helper::replaceVar($op->var, $op->expr); Helper::replaceVar($op->result, $op->expr); Helper::removeUsage($op->expr, $op); return Visitor::REMOVE_OP; }
public function leaveOp(Op $op, Block $block) { if (!$op instanceof Op\Expr\BooleanNot) { return null; } if (!$op->expr instanceof Operand\Literal) { // Non-constant op return null; } $value = new Operand\Literal(-$op->expr->value); $value->type = Type::fromValue($newValue->value); Helper::replaceVar($op->result, $value); Helper::removeUsage($op->expr, $op); return Visitor::REMOVE_OP; }