def get_type(operation_type): if operation_type == '=': return AssignmentOperationType.ASSIGN if operation_type == '|=': return AssignmentOperationType.ASSIGN_OR if operation_type == '^=': return AssignmentOperationType.ASSIGN_CARET if operation_type == '&=': return AssignmentOperationType.ASSIGN_AND if operation_type == '<<=': return AssignmentOperationType.ASSIGN_LEFT_SHIFT if operation_type == '>>=': return AssignmentOperationType.ASSIGN_RIGHT_SHIFT if operation_type == '+=': return AssignmentOperationType.ASSIGN_ADDITION if operation_type == '-=': return AssignmentOperationType.ASSIGN_SUBTRACTION if operation_type == '*=': return AssignmentOperationType.ASSIGN_MULTIPLICATION if operation_type == '/=': return AssignmentOperationType.ASSIGN_DIVISION if operation_type == '%=': return AssignmentOperationType.ASSIGN_MODULO raise SlitherCoreError( 'get_type: Unknown operation type {})'.format(operation_type))
def get_type(operation_type: "AssignmentOperationType"): if operation_type == "=": return AssignmentOperationType.ASSIGN if operation_type == "|=": return AssignmentOperationType.ASSIGN_OR if operation_type == "^=": return AssignmentOperationType.ASSIGN_CARET if operation_type == "&=": return AssignmentOperationType.ASSIGN_AND if operation_type == "<<=": return AssignmentOperationType.ASSIGN_LEFT_SHIFT if operation_type == ">>=": return AssignmentOperationType.ASSIGN_RIGHT_SHIFT if operation_type == "+=": return AssignmentOperationType.ASSIGN_ADDITION if operation_type == "-=": return AssignmentOperationType.ASSIGN_SUBTRACTION if operation_type == "*=": return AssignmentOperationType.ASSIGN_MULTIPLICATION if operation_type == "/=": return AssignmentOperationType.ASSIGN_DIVISION if operation_type == "%=": return AssignmentOperationType.ASSIGN_MODULO raise SlitherCoreError( "get_type: Unknown operation type {})".format(operation_type))
def str(operation_type): if operation_type == AssignmentOperationType.ASSIGN: return '=' if operation_type == AssignmentOperationType.ASSIGN_OR: return '|=' if operation_type == AssignmentOperationType.ASSIGN_CARET: return '^=' if operation_type == AssignmentOperationType.ASSIGN_AND: return '&=' if operation_type == AssignmentOperationType.ASSIGN_LEFT_SHIFT: return '<<=' if operation_type == AssignmentOperationType.ASSIGN_RIGHT_SHIFT: return '>>=' if operation_type == AssignmentOperationType.ASSIGN_ADDITION: return '+=' if operation_type == AssignmentOperationType.ASSIGN_SUBTRACTION: return '-=' if operation_type == AssignmentOperationType.ASSIGN_MULTIPLICATION: return '*=' if operation_type == AssignmentOperationType.ASSIGN_DIVISION: return '/=' if operation_type == AssignmentOperationType.ASSIGN_MODULO: return '%=' raise SlitherCoreError( 'str: Unknown operation type {})'.format(operation_type))
def get_type(operation_type: "BinaryOperation", ) -> "BinaryOperationType": if operation_type == "**": return BinaryOperationType.POWER if operation_type == "*": return BinaryOperationType.MULTIPLICATION if operation_type == "/": return BinaryOperationType.DIVISION if operation_type == "%": return BinaryOperationType.MODULO if operation_type == "+": return BinaryOperationType.ADDITION if operation_type == "-": return BinaryOperationType.SUBTRACTION if operation_type == "<<": return BinaryOperationType.LEFT_SHIFT if operation_type == ">>": return BinaryOperationType.RIGHT_SHIFT if operation_type == "&": return BinaryOperationType.AND if operation_type == "^": return BinaryOperationType.CARET if operation_type == "|": return BinaryOperationType.OR if operation_type == "<": return BinaryOperationType.LESS if operation_type == ">": return BinaryOperationType.GREATER if operation_type == "<=": return BinaryOperationType.LESS_EQUAL if operation_type == ">=": return BinaryOperationType.GREATER_EQUAL if operation_type == "==": return BinaryOperationType.EQUAL if operation_type == "!=": return BinaryOperationType.NOT_EQUAL if operation_type == "&&": return BinaryOperationType.ANDAND if operation_type == "||": return BinaryOperationType.OROR if operation_type == "/'": return BinaryOperationType.DIVISION_SIGNED if operation_type == "%'": return BinaryOperationType.MODULO_SIGNED if operation_type == "<'": return BinaryOperationType.LESS_SIGNED if operation_type == ">'": return BinaryOperationType.GREATER_SIGNED if operation_type == ">>'": return BinaryOperationType.RIGHT_SHIFT_ARITHMETIC raise SlitherCoreError( f"get_type: Unknown operation type {operation_type})")
def is_prefix(operation_type): if operation_type in [UnaryOperationType.BANG, UnaryOperationType.TILD, UnaryOperationType.DELETE, UnaryOperationType.PLUSPLUS_PRE, UnaryOperationType.MINUSMINUS_PRE, UnaryOperationType.PLUS_PRE, UnaryOperationType.MINUS_PRE]: return True elif operation_type in [UnaryOperationType.PLUSPLUS_POST, UnaryOperationType.MINUSMINUS_POST]: return False raise SlitherCoreError('is_prefix: Unknown operation type {}'.format(operation_type))
def __str__(self) -> str: # pylint: disable=too-many-branches if self == BinaryOperationType.POWER: return "**" if self == BinaryOperationType.MULTIPLICATION: return "*" if self == BinaryOperationType.DIVISION: return "/" if self == BinaryOperationType.MODULO: return "%" if self == BinaryOperationType.ADDITION: return "+" if self == BinaryOperationType.SUBTRACTION: return "-" if self == BinaryOperationType.LEFT_SHIFT: return "<<" if self == BinaryOperationType.RIGHT_SHIFT: return ">>" if self == BinaryOperationType.AND: return "&" if self == BinaryOperationType.CARET: return "^" if self == BinaryOperationType.OR: return "|" if self == BinaryOperationType.LESS: return "<" if self == BinaryOperationType.GREATER: return ">" if self == BinaryOperationType.LESS_EQUAL: return "<=" if self == BinaryOperationType.GREATER_EQUAL: return ">=" if self == BinaryOperationType.EQUAL: return "==" if self == BinaryOperationType.NOT_EQUAL: return "!=" if self == BinaryOperationType.ANDAND: return "&&" if self == BinaryOperationType.OROR: return "||" if self == BinaryOperationType.DIVISION_SIGNED: return "/'" if self == BinaryOperationType.MODULO_SIGNED: return "%'" if self == BinaryOperationType.LESS_SIGNED: return "<'" if self == BinaryOperationType.GREATER_SIGNED: return ">'" if self == BinaryOperationType.RIGHT_SHIFT_ARITHMETIC: return ">>'" raise SlitherCoreError(f"str: Unknown operation type {self})")
def str(operation_type): if operation_type == UnaryOperationType.BANG: return '!' if operation_type == UnaryOperationType.TILD: return '~' if operation_type == UnaryOperationType.DELETE: return 'delete' if operation_type == UnaryOperationType.PLUS_PRE: return '+' if operation_type == UnaryOperationType.MINUS_PRE: return '-' if operation_type in [UnaryOperationType.PLUSPLUS_PRE, UnaryOperationType.PLUSPLUS_POST]: return '++' if operation_type in [UnaryOperationType.MINUSMINUS_PRE, UnaryOperationType.MINUSMINUS_POST]: return '--' raise SlitherCoreError('str: Unknown operation type {}'.format(operation_type))
def is_prefix(operation_type): if operation_type in [ UnaryOperationType.BANG, UnaryOperationType.TILD, UnaryOperationType.DELETE, UnaryOperationType.PLUSPLUS_PRE, UnaryOperationType.MINUSMINUS_PRE, UnaryOperationType.PLUS_PRE, UnaryOperationType.MINUS_PRE, ]: return True if operation_type in [ UnaryOperationType.PLUSPLUS_POST, UnaryOperationType.MINUSMINUS_POST, ]: return False raise SlitherCoreError( f"is_prefix: Unknown operation type {operation_type}")
def get_type(operation_type): if operation_type == '**': return BinaryOperationType.POWER if operation_type == '*': return BinaryOperationType.MULTIPLICATION if operation_type == '/': return BinaryOperationType.DIVISION if operation_type == '%': return BinaryOperationType.MODULO if operation_type == '+': return BinaryOperationType.ADDITION if operation_type == '-': return BinaryOperationType.SUBTRACTION if operation_type == '<<': return BinaryOperationType.LEFT_SHIFT if operation_type == '>>': return BinaryOperationType.RIGHT_SHIFT if operation_type == '&': return BinaryOperationType.AND if operation_type == '^': return BinaryOperationType.CARET if operation_type == '|': return BinaryOperationType.OR if operation_type == '<': return BinaryOperationType.LESS if operation_type == '>': return BinaryOperationType.GREATER if operation_type == '<=': return BinaryOperationType.LESS_EQUAL if operation_type == '>=': return BinaryOperationType.GREATER_EQUAL if operation_type == '==': return BinaryOperationType.EQUAL if operation_type == '!=': return BinaryOperationType.NOT_EQUAL if operation_type == '&&': return BinaryOperationType.ANDAND if operation_type == '||': return BinaryOperationType.OROR raise SlitherCoreError( 'get_type: Unknown operation type {})'.format(operation_type))
def str(operation_type): if operation_type == BinaryOperationType.POWER: return '**' if operation_type == BinaryOperationType.MULTIPLICATION: return '*' if operation_type == BinaryOperationType.DIVISION: return '/' if operation_type == BinaryOperationType.MODULO: return '%' if operation_type == BinaryOperationType.ADDITION: return '+' if operation_type == BinaryOperationType.SUBTRACTION: return '-' if operation_type == BinaryOperationType.LEFT_SHIFT: return '<<' if operation_type == BinaryOperationType.RIGHT_SHIFT: return '>>' if operation_type == BinaryOperationType.AND: return '&' if operation_type == BinaryOperationType.CARET: return '^' if operation_type == BinaryOperationType.OR: return '|' if operation_type == BinaryOperationType.LESS: return '<' if operation_type == BinaryOperationType.GREATER: return '>' if operation_type == BinaryOperationType.LESS_EQUAL: return '<=' if operation_type == BinaryOperationType.GREATER_EQUAL: return '>=' if operation_type == BinaryOperationType.EQUAL: return '==' if operation_type == BinaryOperationType.NOT_EQUAL: return '!=' if operation_type == BinaryOperationType.ANDAND: return '&&' if operation_type == BinaryOperationType.OROR: return '||' raise SlitherCoreError( 'str: Unknown operation type {})'.format(operation_type))
def get_type(operation_type, isprefix): if isprefix: if operation_type == '!': return UnaryOperationType.BANG if operation_type == '~': return UnaryOperationType.TILD if operation_type == 'delete': return UnaryOperationType.DELETE if operation_type == '++': return UnaryOperationType.PLUSPLUS_PRE if operation_type == '--': return UnaryOperationType.MINUSMINUS_PRE if operation_type == '+': return UnaryOperationType.PLUS_PRE if operation_type == '-': return UnaryOperationType.MINUS_PRE else: if operation_type == '++': return UnaryOperationType.PLUSPLUS_POST if operation_type == '--': return UnaryOperationType.MINUSMINUS_POST raise SlitherCoreError('get_type: Unknown operation type {}'.format(operation_type))
def __str__(self): if self == UnaryOperationType.BANG: return "!" if self == UnaryOperationType.TILD: return "~" if self == UnaryOperationType.DELETE: return "delete" if self == UnaryOperationType.PLUS_PRE: return "+" if self == UnaryOperationType.MINUS_PRE: return "-" if self in [ UnaryOperationType.PLUSPLUS_PRE, UnaryOperationType.PLUSPLUS_POST ]: return "++" if self in [ UnaryOperationType.MINUSMINUS_PRE, UnaryOperationType.MINUSMINUS_POST, ]: return "--" raise SlitherCoreError(f"str: Unknown operation type {self}")
def get_type(operation_type, isprefix): if isprefix: if operation_type == "!": return UnaryOperationType.BANG if operation_type == "~": return UnaryOperationType.TILD if operation_type == "delete": return UnaryOperationType.DELETE if operation_type == "++": return UnaryOperationType.PLUSPLUS_PRE if operation_type == "--": return UnaryOperationType.MINUSMINUS_PRE if operation_type == "+": return UnaryOperationType.PLUS_PRE if operation_type == "-": return UnaryOperationType.MINUS_PRE else: if operation_type == "++": return UnaryOperationType.PLUSPLUS_POST if operation_type == "--": return UnaryOperationType.MINUSMINUS_POST raise SlitherCoreError( f"get_type: Unknown operation type {operation_type}")
def __str__(self): if self == AssignmentOperationType.ASSIGN: return "=" if self == AssignmentOperationType.ASSIGN_OR: return "|=" if self == AssignmentOperationType.ASSIGN_CARET: return "^=" if self == AssignmentOperationType.ASSIGN_AND: return "&=" if self == AssignmentOperationType.ASSIGN_LEFT_SHIFT: return "<<=" if self == AssignmentOperationType.ASSIGN_RIGHT_SHIFT: return ">>=" if self == AssignmentOperationType.ASSIGN_ADDITION: return "+=" if self == AssignmentOperationType.ASSIGN_SUBTRACTION: return "-=" if self == AssignmentOperationType.ASSIGN_MULTIPLICATION: return "*=" if self == AssignmentOperationType.ASSIGN_DIVISION: return "/=" if self == AssignmentOperationType.ASSIGN_MODULO: return "%=" raise SlitherCoreError("str: Unknown operation type {})".format(self))