diff options
| author | J08nY | 2021-01-16 16:33:43 +0100 |
|---|---|---|
| committer | J08nY | 2021-01-16 16:42:20 +0100 |
| commit | b6d03e0935b21bf35542a282ba66ba25094234ca (patch) | |
| tree | 2533c8098d05e499b49f76155ff7bb6b1ff8831a /pyecsca/ec/context.py | |
| parent | cb397341f7e7b0647157ca8225d9dbeda14c7d2b (diff) | |
| download | pyecsca-b6d03e0935b21bf35542a282ba66ba25094234ca.tar.gz pyecsca-b6d03e0935b21bf35542a282ba66ba25094234ca.tar.zst pyecsca-b6d03e0935b21bf35542a282ba66ba25094234ca.zip | |
Diffstat (limited to 'pyecsca/ec/context.py')
| -rw-r--r-- | pyecsca/ec/context.py | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/pyecsca/ec/context.py b/pyecsca/ec/context.py index 02c8a6d..39bf6f0 100644 --- a/pyecsca/ec/context.py +++ b/pyecsca/ec/context.py @@ -156,6 +156,10 @@ class DefaultContext(Context): actions: Tree current: List[Action] + def __init__(self): + self.actions = Tree() + self.current = [] + def enter_action(self, action: Action) -> None: self.actions.get_by_key(self.current)[action] = Tree() self.current.append(action) @@ -165,10 +169,6 @@ class DefaultContext(Context): raise ValueError self.current.pop() - def __init__(self): - self.actions = Tree() - self.current = [] - def __repr__(self): return f"{self.__class__.__name__}({self.actions!r}, current={self.current!r})" @@ -181,6 +181,17 @@ class PathContext(Context): current_depth: int value: Any + def __init__(self, path: Sequence[int]): + """ + Create a :py:class:`PathContext`. + + :param path: The path of an action in the execution tree that will be captured. + """ + self.path = list(path) + self.current = [] + self.current_depth = 0 + self.value = None + def enter_action(self, action: Action) -> None: if self.current_depth == len(self.current): self.current.append(0) @@ -195,17 +206,6 @@ class PathContext(Context): self.current.pop() self.current_depth -= 1 - def __init__(self, path: Sequence[int]): - """ - Create a :py:class:`PathContext`. - - :param path: The path of an action in the execution tree that will be captured. - """ - self.path = list(path) - self.current = [] - self.current_depth = 0 - self.value = None - def __repr__(self): return f"{self.__class__.__name__}({self.current!r}, depth={self.current_depth!r})" |
