Lines Matching +full:sub +full:- +full:function
1 # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
13 def ToPerfJson(self) -> str:
17 def ToPython(self) -> str:
25 def Equals(self, other) -> bool:
29 def Substitute(self, name: str, expression: 'Expression') -> 'Expression':
32 def __str__(self) -> str:
35 def __or__(self, other: Union[int, float, 'Expression']) -> 'Operator':
38 def __ror__(self, other: Union[int, float, 'Expression']) -> 'Operator':
41 def __xor__(self, other: Union[int, float, 'Expression']) -> 'Operator':
44 def __and__(self, other: Union[int, float, 'Expression']) -> 'Operator':
47 def __rand__(self, other: Union[int, float, 'Expression']) -> 'Operator':
50 def __lt__(self, other: Union[int, float, 'Expression']) -> 'Operator':
53 def __gt__(self, other: Union[int, float, 'Expression']) -> 'Operator':
56 def __add__(self, other: Union[int, float, 'Expression']) -> 'Operator':
59 def __radd__(self, other: Union[int, float, 'Expression']) -> 'Operator':
62 def __sub__(self, other: Union[int, float, 'Expression']) -> 'Operator':
63 return Operator('-', self, other)
65 def __rsub__(self, other: Union[int, float, 'Expression']) -> 'Operator':
66 return Operator('-', other, self)
68 def __mul__(self, other: Union[int, float, 'Expression']) -> 'Operator':
71 def __rmul__(self, other: Union[int, float, 'Expression']) -> 'Operator':
74 def __truediv__(self, other: Union[int, float, 'Expression']) -> 'Operator':
77 def __rtruediv__(self, other: Union[int, float, 'Expression']) -> 'Operator':
80 def __mod__(self, other: Union[int, float, 'Expression']) -> 'Operator':
84 def _Constify(val: Union[bool, int, float, Expression]) -> Expression:
105 '-': 4,
124 rhs: bool = False) -> str:
145 if _PRECEDENCE.get(self.operator, -1) > _PRECEDENCE.get(
146 other.operator, -1):
148 if rhs and _PRECEDENCE.get(self.operator, -1) == _PRECEDENCE.get(
149 other.operator, -1):
161 def Simplify(self) -> Expression:
192 def Equals(self, other: Expression) -> bool:
198 def Substitute(self, name: str, expression: Expression) -> Expression:
228 def Simplify(self) -> Expression:
240 def Equals(self, other: Expression) -> bool:
246 def Substitute(self, name: str, expression: Expression) -> Expression:
255 class Function(Expression): class
256 """A function in an expression like min, max, d_ratio."""
276 def Simplify(self) -> Expression:
286 return Function(self.fn, lhs, rhs)
288 def Equals(self, other: Expression) -> bool:
289 if isinstance(other, Function):
296 def Substitute(self, name: str, expression: Expression) -> Expression:
303 return Function(self.fn, lhs, rhs)
306 def _FixEscapes(s: str) -> str:
307 s = re.sub(r'([^\\]),', r'\1\\,', s)
308 return re.sub(r'([^\\])=', r'\1\\=', s)
319 result = re.sub('/', '@', self.name)
325 def Simplify(self) -> Expression:
328 def Equals(self, other: Expression) -> bool:
331 def Substitute(self, name: str, expression: Expression) -> Expression:
352 def Simplify(self) -> Expression:
355 def Equals(self, other: Expression) -> bool:
358 def Substitute(self, name: str, expression: Expression) -> Expression:
374 def Simplify(self) -> Expression:
377 def Equals(self, other: Expression) -> bool:
380 def Substitute(self, name: str, expression: Expression) -> Expression:
385 Expression]) -> Function:
386 # pylint: disable=redefined-builtin
387 # pylint: disable=invalid-name
388 return Function('min', lhs, rhs)
392 Expression]) -> Function:
393 # pylint: disable=redefined-builtin
394 # pylint: disable=invalid-name
395 return Function('max', lhs, rhs)
399 rhs: Union[int, float, Expression]) -> Function:
400 # pylint: disable=redefined-builtin
401 # pylint: disable=invalid-name
402 return Function('d_ratio', lhs, rhs)
405 def source_count(event: Event) -> Function:
406 # pylint: disable=redefined-builtin
407 # pylint: disable=invalid-name
408 return Function('source_count', event)
411 def has_event(event: Event) -> Function:
412 # pylint: disable=redefined-builtin
413 # pylint: disable=invalid-name
414 return Function('has_event', event)
416 def strcmp_cpuid_str(cpuid: Event) -> Function:
417 # pylint: disable=redefined-builtin
418 # pylint: disable=invalid-name
419 return Function('strcmp_cpuid_str', cpuid)
454 def Flatten(self) -> Set['Metric']:
458 def ToPerfJson(self) -> Dict[str, str]:
502 def Flatten(self) -> Set[Metric]:
510 def ToPerfJson(self) -> str:
513 def __str__(self) -> str:
518 """Transformer to convert if-else nodes to Select expressions."""
521 # pylint: disable=invalid-name
531 def ParsePerfJson(orig: str) -> Expression:
537 appropriate calls. Python's ast is used to match if-else that can't
546 # pylint: disable=eval-used
550 py = re.sub(r'([a-zA-Z][^-+/\* \\\(\),]*(?:\\.[^-+/\* \\\(\),]*)*)',
553 py = re.sub(r'#Event\(r"([^"]*)"\)', r'Literal("#\1")', py)
557 py = re.sub(r'0Event\(r"[xX]([0-9a-fA-F]*)"\)', r'Event("0x\1")', py)
559 py = re.sub(r'([0-9]+)Event\(r"(e[0-9]+)"\)', r'\1\2', py)
563 py = re.sub(rf'Event\(r"{kw}"\)', kw, py)
574 )-> Dict[Tuple[str, str], Expression]: