-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathoperation.py
More file actions
66 lines (53 loc) · 1.61 KB
/
operation.py
File metadata and controls
66 lines (53 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import abc
from typing import Any, TYPE_CHECKING
from slither.core.context.context import Context
from slither.core.expressions.expression import Expression
from slither.core.variables.variable import Variable
from slither.utils.utils import unroll
if TYPE_CHECKING:
from slither.core.compilation_unit import SlitherCompilationUnit
from slither.core.cfg.node import Node
class AbstractOperation(abc.ABC):
@property
@abc.abstractmethod
def read(self):
"""
Return the list of variables READ
"""
pass
@property
@abc.abstractmethod
def used(self):
"""
Return the list of variables used
"""
pass
class Operation(Context, AbstractOperation):
def __init__(self) -> None:
super().__init__()
self._node: Node | None = None
self._expression: Expression | None = None
def set_node(self, node: "Node") -> None:
self._node = node
@property
def node(self) -> "Node":
assert self._node
return self._node
@property
def compilation_unit(self) -> "SlitherCompilationUnit":
return self.node.compilation_unit
@property
def used(self) -> list[Variable]:
"""
By default used is all the variables read
"""
return self.read
# if array inside the parameters
@staticmethod
def _unroll(l: list[Any]) -> list[Any]:
return unroll(l)
def set_expression(self, expression: Expression) -> None:
self._expression = expression
@property
def expression(self) -> Expression | None:
return self._expression