Salome HOME
PN bug
[tools/eficas.git] / Exemples / cyclops3 / main.py
1 # -*- coding: utf-8 -*-
2
3 """
4    Vérification des cycles de références d'objets sur un exemple
5    d'utilisation d'un JDC
6
7 """
8
9 import sys
10 sys.path[:0]=['../..','../../..']
11
12 import cata
13 from cata import JdC
14
15 cr=JdC.report()
16 print cr
17
18 text="""
19 DEBUT()
20 a=OP1(a=1)
21 b=OP1(a=1,b=a)
22 c=OP1(a=1)
23 """
24
25 j=JdC(procedure=text,cata=cata,nom="bidon")
26
27 j.compile()
28 if not j.cr.estvide():
29    print j.cr
30    sys.exit()
31
32 j.exec_compile()
33 if not j.cr.estvide():
34    print j.cr
35    sys.exit()
36
37 cr=j.report()
38 if not j.cr.estvide():
39    print j.cr
40    sys.exit()
41
42 JdC.supprime()
43 j.supprime()
44
45 def testcycle():
46    """
47        Cette fonction permet de détecter les cycles de références entre objets
48        à l'aide du module Cyclops
49    """
50    from Misc import Cyclops
51    global j
52    z=Cyclops.CycleFinder()
53    z.register(j)
54    del j
55    z.find_cycles()
56    z.show_stats()
57    z.show_cycles()
58    z.show_cycleobjs()
59    z.show_sccs()
60    z.show_arcs()
61    print "dead root set objects:"
62    for rc, cyclic, x in z.get_rootset():
63       if rc == 0:
64          z.show_obj(x)
65    z.find_cycles(1)
66    z.show_stats()
67
68 testcycle()
69