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