def make_node(cls, lineno, operator, operand, func=None, type_=None):
        """ Creates a node for a unary operation. E.g. -x or LEN(a$)

        Parameters:
            -func: lambda function used on constant folding when possible
            -type_: the resulting type (by default, the same as the argument).
                For example, for LEN (str$), result type is 'u16'
                and arg type is 'string'
        """
        assert type_ is None or isinstance(type_, SymbolTYPE)

        if func is not None:  # Try constant-folding
            if is_number(operand):  # e.g. ABS(-5)
                return SymbolNUMBER(func(operand.value), lineno=lineno)
            elif is_string(operand):  # e.g. LEN("a")
                return SymbolSTRING(func(operand.text), lineno=lineno)

        if type_ is None:
            type_ = operand.type_

        if operator == 'MINUS':
            if not type_.is_signed:
                type_ = type_.to_signed()
                operand = SymbolTYPECAST.make_node(type_, operand, lineno)
        elif operator == 'NOT':
            type_ = TYPE.ubyte

        return cls(operator, operand, lineno, type_)
def make_node ( cls , lineno , operator , operand , func = None , type_ = None ) : assert type_ is None or isinstance ( type_ , SymbolTYPE ) if func is not None : if is_number ( operand ) : return SymbolNUMBER ( func ( operand . value ) , lineno = lineno ) elif is_string ( operand ) : return SymbolSTRING ( func ( operand . text ) , lineno = lineno ) if type_ is None : type_ = operand . type_ if operator == 'MINUS' : if not type_ . is_signed : type_ = type_ . to_signed ( ) operand = SymbolTYPECAST . make_node ( type_ , operand , lineno ) elif operator == 'NOT' : type_ = TYPE . ubyte return cls ( operator , operand , lineno , type_ )
Creates a node for a unary operation. E.g. -x or LEN(a$)

        Parameters:
            -func: lambda function used on constant folding when possible
            -type_: the resulting type (by default, the same as the argument).
                For example, for LEN (str$), result type is 'u16'
                and arg type is 'string'