diff options
author | Jürg Billeter <j@bitron.ch> | 2010-10-28 13:34:13 +0200 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2010-10-28 16:20:17 +0200 |
commit | 2cd44b166403f4cd29de30aaa328637d7d207591 (patch) | |
tree | 1c85202b54769c481f18cbd8d6106a35f7e5567b | |
parent | e81776c024ab1e72b918612e49606f8500aaad06 (diff) | |
download | vala-2cd44b166403f4cd29de30aaa328637d7d207591.tar.gz |
Add CodeContext.check method
-rw-r--r-- | compiler/valacompiler.vala | 17 | ||||
-rw-r--r-- | vala/valacodecontext.vala | 28 | ||||
-rw-r--r-- | vapigen/valavapigen.vala | 10 |
3 files changed, 32 insertions, 23 deletions
diff --git a/compiler/valacompiler.vala b/compiler/valacompiler.vala index 331060415..772ed94a0 100644 --- a/compiler/valacompiler.vala +++ b/compiler/valacompiler.vala @@ -343,17 +343,13 @@ class Vala.Compiler { interface_writer.write_file (context, fast_vapi_filename); return quit (); } - - var resolver = new SymbolResolver (); - resolver.resolve (context); - + + context.check (); + if (context.report.get_errors () > 0 || (fatal_warnings && context.report.get_warnings () > 0)) { return quit (); } - var analyzer = new SemanticAnalyzer (); - analyzer.analyze (context); - if (!ccode_only && !compile_only && library == null) { // building program, require entry point if (!has_c_files && context.entry_point == null) { @@ -370,13 +366,6 @@ class Vala.Compiler { return quit (); } - var flow_analyzer = new FlowAnalyzer (); - flow_analyzer.analyze (context); - - if (context.report.get_errors () > 0 || (fatal_warnings && context.report.get_warnings () > 0)) { - return quit (); - } - context.codegen.emit (context); if (context.report.get_errors () > 0 || (fatal_warnings && context.report.get_warnings () > 0)) { diff --git a/vala/valacodecontext.vala b/vala/valacodecontext.vala index 5d3b02284..cfb0a9bbc 100644 --- a/vala/valacodecontext.vala +++ b/vala/valacodecontext.vala @@ -200,12 +200,21 @@ public class Vala.CodeContext { get { return _root; } } + public SymbolResolver resolver { get; private set; } + + public SemanticAnalyzer analyzer { get; private set; } + + public FlowAnalyzer flow_analyzer { get; private set; } + /** * The selected code generator. */ public CodeGenerator codegen { get; set; } public CodeContext () { + resolver = new SymbolResolver (); + analyzer = new SemanticAnalyzer (); + flow_analyzer = new FlowAnalyzer (); } /** @@ -444,6 +453,25 @@ public class Vala.CodeContext { } } + /** + * Resolve and analyze. + */ + public void check () { + resolver.resolve (this); + + if (report.get_errors () > 0) { + return; + } + + analyzer.analyze (this); + + if (report.get_errors () > 0) { + return; + } + + flow_analyzer.analyze (this); + } + public void add_define (string define) { defines.add (define); } diff --git a/vapigen/valavapigen.vala b/vapigen/valavapigen.vala index 32bbb25a6..a5cc9234f 100644 --- a/vapigen/valavapigen.vala +++ b/vapigen/valavapigen.vala @@ -153,16 +153,8 @@ class Vala.VAPIGen : Object { if (context.report.get_errors () > 0) { return quit (); } - - var resolver = new SymbolResolver (); - resolver.resolve (context); - - if (context.report.get_errors () > 0) { - return quit (); - } - var analyzer = new SemanticAnalyzer (); - analyzer.analyze (context); + context.check (); if (context.report.get_errors () > 0) { return quit (); |