Wiki

root/cobra/trunk/Source/CobraMain-ObjectExplorer-WinForms.cobra

Revision 2478, 1.8 KB (checked in by Charles.Esterbrook, 16 months ago)

Fixed: win-comp.bat is broken with compilation errors.
reported-by:RIGHT_THEN

  • Property svn:eol-style set to native
Line 
1"""
2Cobra Compiler WinForms Explorer
3
4This runs the Cobra compiler as usual, but then follows it up with a GUI window (using WinForms) that
5enables you to explore all the objects that resulted from compilation including the compiler, modules,
6namespaces, declarations, statements and expressions.
7
8"""
9
10use System.Windows.Forms
11
12
13class CobraMain
14
15    shared
16
17        pro willTimeIt from var as bool
18       
19        pro runTime from var as TimeSpan?
20
21        pro compiler from var as Compiler?
22
23        def main
24            has STAThread
25            # CobraCore.willCheckAll = false
26           
27            # Run the command line as usual:
28            startTime = DateTime.now
29            exc as Exception?
30            try
31                try
32                    commandLine = CommandLine()
33                    commandLine.run
34                finally
35                    if _willTimeIt
36                        print 'timeit = [DateTime.now.subtract(startTime)]'
37            catch exc as Exception?
38                pass
39
40            compiler = commandLine.compiler
41
42            # Now explore the results:
43            Application.enableVisualStyles
44            form = ObjectExplorer()
45            form.text = 'Cobra Compiler WinForms Explorer'
46            if exc, form.addKeyValue('Exception', exc)
47            if CobraCore.hasDetailedStackTrace
48                form.addKeyValue('Detailed Stack Trace', sharp'CobraLangInternal.CobraImp.DetailedStackTrace')
49           
50            form.addKeyValue('CommandLine', commandLine)
51            form.addKeyValue('Compiler', compiler)
52
53            topDecls = List<of INode>()
54            for decl in compiler.globalNS.declsInOrder
55                topDecls.add(decl)
56            form.addKeyValue('Declarations (Global)', topDecls)
57
58            form.addKeyValue('Messages', compiler.messages)
59
60            topNameSpaces = List<of NameSpace>()
61            topNameSpaces.add(compiler.globalNS)
62            for module in compiler.modules
63                if module inherits CobraModule
64                    if not module.isCobraLibrary
65                        topNameSpaces.add(module.topNameSpace)
66            form.addKeyValue('Namespaces', topNameSpaces)
67
68            form.show
69            Application.run(form)
Note: See TracBrowser for help on using the browser.