diff --git a/Pystan/config/Compte rendu TP 2 AnaStat.docx b/Pystan/config/Compte rendu TP 2 AnaStat.docx new file mode 100644 index 0000000000000000000000000000000000000000..db98fa0f378c683bf4ded86a1a6973d2aee197ec Binary files /dev/null and b/Pystan/config/Compte rendu TP 2 AnaStat.docx differ diff --git a/Pystan/config/iteration.py b/Pystan/config/iteration.py index 2ca3afbd1fdc314cc23cd489473003c90fd38db2..100ea677bd4bfdcada8f6f066bfed1c9e880d55d 100644 --- a/Pystan/config/iteration.py +++ b/Pystan/config/iteration.py @@ -86,7 +86,7 @@ def fixpoint_iteration[T](transfer: Transfer[T], cfg: Cfg) -> dict[Node,T]: output maps each node to the computed state """ - # Étape 1 : Initialisation + # initialisation mapping: dict[Node, T] = {} for node in cfg.g.nodes: if node == cfg.init_node: @@ -94,17 +94,17 @@ def fixpoint_iteration[T](transfer: Transfer[T], cfg: Cfg) -> dict[Node,T]: else: mapping[node] = transfer.bottom() - # Étape 2 : Initialisation de la worklist avec les successeurs du nœud initial + # initialisation de la worklist avec les successeurs du nœud initial worklist: list[tuple[Node, Node, Label]] = [] for (dst, label) in cfg.init_node.succs: worklist.append((cfg.init_node, dst, label)) - # Étape 3 : Itération principale + # itération principale while worklist: src, dst, label = worklist.pop(0) src_state = mapping[src] - # Appliquer la bonne fonction de transfert selon le label + # applique la fonction de transfert selon le label match label: case LSkip(): new_state = transfer.tr_skip(src_state) @@ -117,13 +117,13 @@ def fixpoint_iteration[T](transfer: Transfer[T], cfg: Cfg) -> dict[Node,T]: case _: continue # ou raise NotImplementedError - # Joindre avec l'ancien état + # joindre avc l'ancien état joined_state = transfer.join(mapping[dst], new_state) - # Si le nouvel état apporte de l'information, on met à jour + # si nouvel état apporte de l'information, on met à jour if not transfer.included(joined_state, mapping[dst]): mapping[dst] = joined_state - # Et on ajoute les successeurs à la worklist + # + on ajoute les successeurs à la worklist for (succ, lab) in dst.succs: worklist.append((dst, succ, lab)) diff --git a/Pystan/config/opsem.py b/Pystan/config/opsem.py index 8cc38099adb87a52e25a533dca01efeed513b4e2..d8b6621c0793ebfc5445cf77a14888577649803b 100644 --- a/Pystan/config/opsem.py +++ b/Pystan/config/opsem.py @@ -34,18 +34,16 @@ def eval_aexp(env: dict[str,int], exp: ArithExpr) -> int | None: if left_val is None or right_val is None: return None - # Match on the binary operator using the available operations if bop == Bop.ADD: return left_val + right_val elif bop == Bop.MUL: return left_val * right_val - # Check for other potential operators in Bop - # Using string representation as fallback + # check for other potential operators in Bop elif str(bop) == "Bop.SUB" or str(bop) == "-": return left_val - right_val elif str(bop) == "Bop.DIV" or str(bop) == "/": if right_val == 0: - return None # Division by zero + return None # div by zero return left_val // right_val else: return None