Visitor for `UnaryOperation` AST node.
199713
def visit_UnaryOperation(self, node):
        """"""
        if node.op.nature == Nature.PLUS:
            return +self.visit(node.right)
        elif node.op.nature == Nature.MINUS:
            return -self.visit(node.right)
        elif node.op.nature == Nature.NOT:
            return Bool(not self.visit(node.right))
298709
def make_unary(lineno, operator, operand, func=None, type_=None):
    
    return symbols.UNARY.make_node(lineno, operator, operand, func, type_)
22785
def visit_Lambda(self, node: AST, dfltChaining: bool = True) -> str:
        """"""
        with self.op_man(node):
            src = f"lambda {self.visit(node.args)}: {self.visit(node.body)}"
            return self.wrap_expr(src, dfltChaining)
843654
def unary_operator(op):
    
    valid_ops = {'~'}
    if op not in valid_ops:
        raise ValueError("Invalid unary operator %s." % op)

    def unary_operator(self):
        # This can't be hoisted up a scope because the types returned by
        # unary_op_return_type aren't defined when the top-level function is
        # invoked.
        if isinstance(self, NumericalExpression):
            return NumExprFilter.create(
                "{op}({expr})".format(op=op, expr=self._expr),
                self.inputs,
            )
        else:
            return NumExprFilter.create("{op}x_0".format(op=op), (self,))

    unary_operator.__doc__ = "Unary Operator: '%s'" % op
    return unary_operator
405168
def visit_UnaryOp(self, node):
        """"""

        if isinstance(node.op, Not):
            self._debug('UnaryOp', node.op, incr=1)
            operand = self[node.operand]
            self._debug('|-', operand, incr=2)
            tn = self._tn()
            result = numpy.logical_not(operand)
            self._debug('|_', result, incr=2)
            self[tn] = result
            return ast_name(tn)
        else:
            return self.generic_visit(node)
13209
def p_factor_unary_operators(self, p):
        

        p[0] = p[2]
        if p[1] == '-':
            p[0] = Instruction('-x', context={'x': p[0]})
993745
def generic_visit(self, node):
        """"""
        if node.__class__.__name__ == 'Name':
            if node.ctx.__class__ == ast.Load and node.id not in self.names:
                self.names.append(node.id)
        ast.NodeVisitor.generic_visit(self, node)
645373
def unary_operator(op):
    
    # Only negate is currently supported.
    valid_ops = {'-'}
    if op not in valid_ops:
        raise ValueError("Invalid unary operator %s." % op)

    @with_doc("Unary Operator: '%s'" % op)
    @with_name(unary_op_name(op))
    def unary_operator(self):
        if self.dtype != float64_dtype:
            raise TypeError(
                "Can't apply unary operator {op!r} to instance of "
                "{typename!r} with dtype {dtypename!r}.\n"
                "{op!r} is only supported for Factors of dtype "
                "'float64'.".format(
                    op=op,
                    typename=type(self).__name__,
                    dtypename=self.dtype.name,
                )
            )

        # This can't be hoisted up a scope because the types returned by
        # unary_op_return_type aren't defined when the top-level function is
        # invoked.
        if isinstance(self, NumericalExpression):
            return NumExprFactor(
                "{op}({expr})".format(op=op, expr=self._expr),
                self.inputs,
                dtype=float64_dtype,
            )
        else:
            return NumExprFactor(
                "{op}x_0".format(op=op),
                (self,),
                dtype=float64_dtype,
            )
    return unary_operator
990922
def p_ex_expression(tok):
        """"""
        if len(tok) == 3:
            tok[0] = UnaryOperationRule(tok[1], tok[2])
        else:
            tok[0] = tok[1]
522225
protected AstNode unary(boolean required) throws ScanException, ParseException {
		AstNode v = null;
		switch (token.getSymbol()) {
			case NOT:
				consumeToken();
				v = createAstUnary(unary(true), AstUnary.NOT);
				break;
			case MINUS:
				consumeToken();
				v = createAstUnary(unary(true), AstUnary.NEG);
				break;
			case EMPTY:
				consumeToken();
				v = createAstUnary(unary(true), AstUnary.EMPTY);
				break;
			case EXTENSION:
				if (getExtensionHandler(token).getExtensionPoint() == ExtensionPoint.UNARY) {
					v = getExtensionHandler(consumeToken()).createAstNode(unary(true));
					break;
				}
			default:
				v = value();
		}
		if (v == null && required) {
			fail(EXPR_FIRST);
		}
		return v;
	}
1181565
public static <T, E extends Exception> UnaryOperator<T> sneaked(
      SneakyUnaryOperator<T, E> unaryOperator) {
    return t -> {
      @SuppressWarnings("unchecked")
      SneakyUnaryOperator<T, RuntimeException> castedUnaryOperator =
          (SneakyUnaryOperator<T, RuntimeException>) unaryOperator;
      return castedUnaryOperator.apply(t);
    };
  }
400369
def _eval_unaryop(self, node):
        
        return self.operators[type(node.op)](self._eval(node.operand))
1259137
public static FunctionalType unboxedUnaryOperator(TypeMirror type, Types types) {
    switch (type.getKind()) {
      case INT:
      case LONG:
      case DOUBLE:
        return primitiveUnaryOperator((PrimitiveType) type);

      case BOOLEAN:
      case BYTE:
      case CHAR:
      case SHORT:
      case FLOAT:
        return unaryOperator(types.boxedClass((PrimitiveType) type).asType());

      default:
        return unaryOperator(type);
    }
  }
847746
def _infer_unaryop(self, context=None):
    """"""
    for operand in self.operand.infer(context):
        try:
            yield operand.infer_unary_op(self.op)
        except TypeError as exc:
            # The operand doesn't support this operation.
            yield util.BadUnaryOperationMessage(operand, self.op, exc)
        except AttributeError as exc:
            meth = protocols.UNARY_OP_METHOD[self.op]
            if meth is None:
                # `not node`. Determine node's boolean
                # value and negate its result, unless it is
                # Uninferable, which will be returned as is.
                bool_value = operand.bool_value()
                if bool_value is not util.Uninferable:
                    yield nodes.const_factory(not bool_value)
                else:
                    yield util.Uninferable
            else:
                if not isinstance(operand, (bases.Instance, nodes.ClassDef)):
                    # The operation was used on something which
                    # doesn't support it.
                    yield util.BadUnaryOperationMessage(operand, self.op, exc)
                    continue

                try:
                    try:
                        methods = dunder_lookup.lookup(operand, meth)
                    except exceptions.AttributeInferenceError:
                        yield util.BadUnaryOperationMessage(operand, self.op, exc)
                        continue

                    meth = methods[0]
                    inferred = next(meth.infer(context=context))
                    if inferred is util.Uninferable or not inferred.callable():
                        continue

                    context = contextmod.copy_context(context)
                    context.callcontext = contextmod.CallContext(args=[operand])
                    call_results = inferred.infer_call_result(self, context=context)
                    result = next(call_results, None)
                    if result is None:
                        # Failed to infer, return the same type.
                        yield operand
                    else:
                        yield result
                except exceptions.AttributeInferenceError as exc:
                    # The unary operation special method was not found.
                    yield util.BadUnaryOperationMessage(operand, self.op, exc)
                except exceptions.InferenceError:
                    yield util.Uninferable
325290
@Nullable
  private static Type unaryNumericPromotion(Type type, VisitorState state) {
    Type unboxed = unboxAndEnsureNumeric(type, state);
    switch (unboxed.getTag()) {
      case BYTE:
      case SHORT:
      case CHAR:
        return state.getSymtab().intType;
      case INT:
      case LONG:
      case FLOAT:
      case DOUBLE:
        return unboxed;
      default:
        throw new AssertionError("Should not reach here: " + type);
    }
  }
1015140
private void visitMemberDeclarator(AstNode node) {

    if (isOverriddenMethod(node)) {
      // assume that ancestor method is documented
      // and do not count as public API
      return;
    }

    AstNode container = node.getFirstAncestor(
      CxxGrammarImpl.templateDeclaration,
      CxxGrammarImpl.classSpecifier);

    AstNode docNode = node;
    List<Token> comments;

    if (container == null || container.getType().equals(CxxGrammarImpl.classSpecifier)) {
      comments = getBlockDocumentation(docNode);
    } else { // template
      do {
        comments = getBlockDocumentation(container);
        if (!comments.isEmpty()) {
          break;
        }
        container = container.getFirstAncestor(CxxGrammarImpl.templateDeclaration);
      } while (container != null);
    }

    // documentation may be inlined
    if (comments.isEmpty()) {
      comments = getDeclaratorInlineComment(node);
    }

    // find the identifier to present to concrete visitors
    String id = null;

    // first look for an operator function id
    AstNode idNode = node.getFirstDescendant(CxxGrammarImpl.operatorFunctionId);

    if (idNode != null) {
      id = getOperatorId(idNode);
    } else {
      // look for a declarator id
      idNode = node.getFirstDescendant(CxxGrammarImpl.declaratorId);

      if (idNode != null) {
        id = idNode.getTokenValue();
      } else {
        // look for an identifier (e.g in bitfield declaration)
        idNode = node.getFirstDescendant(GenericTokenType.IDENTIFIER);

        if (idNode != null) {
          id = idNode.getTokenValue();
        } else {
          LOG.error("Unsupported declarator at {}", node.getTokenLine());
        }
      }
    }

    if (idNode != null && id != null) {
      visitPublicApi(idNode, id, comments);
    }
  }
917961
def is_unary_operator(oper):
    """"""
    # definition:
    # member in class
    # ret-type operator symbol()
    # ret-type operator [++ --](int)
    # globally
    # ret-type operator symbol( arg )
    # ret-type operator [++ --](X&, int)
    symbols = ['!', '&', '~', '*', '+', '++', '-', '--']
    if not isinstance(oper, calldef_members.operator_t):
        return False
    if oper.symbol not in symbols:
        return False
    if isinstance(oper, calldef_members.member_operator_t):
        if len(oper.arguments) == 0:
            return True
        elif oper.symbol in ['++', '--'] and \
                isinstance(oper.arguments[0].decl_type, cpptypes.int_t):
            return True
        return False

    if len(oper.arguments) == 1:
        return True
    elif oper.symbol in ['++', '--'] \
            and len(oper.arguments) == 2 \
            and isinstance(oper.arguments[1].decl_type, cpptypes.int_t):
        # may be I need to add additional check whether first argument is
        # reference or not?
        return True
    return False