tests/TreeBuilder.vala
[app.Builder.js] / tests / TreeBuilder.vala
1
2 // valac TreeBuilder.vala --pkg libvala-0.24 --pkg posix -o /tmp/treebuilder
3
4 public class MyReport  : Vala.Report {
5
6         
7
8 }
9 public class TreeBuilder : Vala.CodeVisitor {
10         
11         public Vala.CodeContext create_valac_tree () {
12                 // init context:
13                 var context = new Vala.CodeContext ();
14                 Vala.CodeContext.push (context);
15                 
16                 context.experimental = false;
17                 context.experimental_non_null = false;
18                 context.vapi_directories = { "/usr/share/vala-0.24/vapi" };
19                 context.report.enable_warnings = true;
20                 context.metadata_directories = { };
21                 context.gir_directories = {};
22
23                 
24                 context.basedir = Posix.realpath (".");
25                 
26                 context.directory = context.basedir;
27                 
28
29                 // add default packages:
30                 //if (settings.profile == "gobject-2.0" || settings.profile == "gobject" || settings.profile == null) {
31                         context.profile = Vala.Profile.GOBJECT;
32                 //      context.add_define ("GOBJECT");
33                 //}
34                 //add_depencies (context, settings.packages);
35                 //if (reporter.errors > 0) {
36                 //      return context;
37                 //}
38
39                 var source_file = new Vala.SourceFile (context, 
40                                Vala.SourceFileType.SOURCE, 
41                                "/home/alan/gitlive/app.Builder.js/tests/TreeBuilder.vala");
42
43                 //if (source_package == null) {
44                 //source_package = register_package (new Package (settings.pkg_name, false, null));
45                 //}
46
47                 //register_source_file (source_package, source_file);
48
49                 //if (context.profile == Vala.Profile.GOBJECT) {
50                         // import the GLib namespace by default (namespace of backend-specific standard library)
51                         var ns_ref = new Vala.UsingDirective (new Vala.UnresolvedSymbol (null, "GLib", null));
52                         source_file.add_using_directive (ns_ref);
53                         context.root.add_using_directive (ns_ref);
54                 //}
55
56                 context.add_source_file (source_file);
57
58                 
59                 //add_documented_files (context, settings.source_files);
60                 
61                 Vala.Parser parser = new Vala.Parser ();
62                 parser.parse (context);
63                 //gir_parser.parse (context);
64                 if (context.report.get_errors () > 0) {
65                         print("got errors");
66                         return context;
67                 }
68
69
70
71                 // check context:
72                 context.check ();
73                 if (context.report.get_errors () > 0) {
74                         return context;
75                 }
76                 return context;
77         }
78 //
79         // startpoint:
80         //
81  
82 }
83
84 int main (string[] args) {
85
86         var a = new TreeBuilder();
87         a.create_valac_tree();
88         return 0;
89 }
90
91