]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Support qualified access to global symbols with `global::'
authorJuerg Billeter <j@bitron.ch>
Sun, 25 May 2008 11:40:01 +0000 (11:40 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Sun, 25 May 2008 11:40:01 +0000 (11:40 +0000)
2008-05-25  Juerg Billeter  <j@bitron.ch>

* vala/valaparser.vala:
* vala/valascanner.vala:
* vala/valasymbolresolver.vala:
* vala/valatokentype.vala:
* vala/valaunresolvedsymbol.vala:

Support qualified access to global symbols with `global::'

svn path=/trunk/; revision=1424

ChangeLog
vala/valaparser.vala
vala/valascanner.vala
vala/valasymbolresolver.vala
vala/valatokentype.vala
vala/valaunresolvedsymbol.vala

index 861f517e6c395b21f09015892e6153974415fb25..d511c252c4e8e2074910f307d0b6c2717ccc7329 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2008-05-25  Jürg Billeter  <j@bitron.ch>
+
+       * vala/valaparser.vala:
+       * vala/valascanner.vala:
+       * vala/valasymbolresolver.vala:
+       * vala/valatokentype.vala:
+       * vala/valaunresolvedsymbol.vala:
+
+       Support qualified access to global symbols with `global::'
+
 2008-05-25  Jürg Billeter  <j@bitron.ch>
 
        * vapi/tiff.vapi: various binding fixes, patch by Christian Meyer
index c7a3d71e6dda9e3f914cb39402273ebeac4e3a9e..30c0b5ed948ba6c270eee7ca6124c85947cc72ac 100644 (file)
@@ -299,7 +299,7 @@ public class Vala.Parser : CodeVisitor {
        void skip_symbol_name () throws ParseError {
                do {
                        skip_identifier ();
-               } while (accept (TokenType.DOT));
+               } while (accept (TokenType.DOT) || accept (TokenType.DOUBLE_COLON));
        }
 
        UnresolvedSymbol parse_symbol_name () throws ParseError {
@@ -307,6 +307,14 @@ public class Vala.Parser : CodeVisitor {
                UnresolvedSymbol sym = null;
                do {
                        string name = parse_identifier ();
+                       if (name == "global" && accept (TokenType.DOUBLE_COLON)) {
+                               // global::Name
+                               // qualified access to global symbol
+                               name = parse_identifier ();
+                               sym = new UnresolvedSymbol (sym, name, get_src (begin));
+                               sym.qualified = true;
+                               continue;
+                       }
                        sym = new UnresolvedSymbol (sym, name, get_src (begin));
                } while (accept (TokenType.DOT));
                return sym;
index ba197549811f8d3d83538f08b445805cb9a5066b..38eaf9001d2f9e2eb85ec760afcfd81e6d95970e 100644 (file)
@@ -433,6 +433,10 @@ public class Vala.Scanner : Object {
                        case ':':
                                type = TokenType.COLON;
                                current++;
+                               if (current < end && current[0] == ':') {
+                                       type = TokenType.DOUBLE_COLON;
+                                       current++;
+                               }
                                break;
                        case ',':
                                type = TokenType.COMMA;
index 40f32c58ee8e4e35f398910fc671d9df5b79cfa2..f574798f8eaed9b712a34e533b59846ec8ac4f9e 100644 (file)
@@ -189,7 +189,10 @@ public class Vala.SymbolResolver : CodeVisitor {
        }
 
        private Symbol? resolve_symbol (UnresolvedSymbol unresolved_symbol) {
-               if (unresolved_symbol.inner == null) {
+               if (unresolved_symbol.qualified) {
+                       // qualified access to global symbol
+                       return root_symbol.scope.lookup (unresolved_symbol.name);
+               } else if (unresolved_symbol.inner == null) {
                        Symbol sym = null;
                        Scope scope = current_scope;
                        while (sym == null && scope != null) {
index 1a7384da67ab060a59d579a24fe6c788fd2fa82a..94fc0a0a87e70a5a56b9f63fd2d8d881cee94f5b 100644 (file)
@@ -58,6 +58,7 @@ public enum Vala.TokenType {
        DELETE,
        DIV,
        DO,
+       DOUBLE_COLON,
        DOT,
        DYNAMIC,
        ELLIPSIS,
index df8c30b94b6a72b8516006f4f98f2fb9887fda7d..4ba4469e088d8513803fae5b6c397f63fd4aabfb 100644 (file)
@@ -36,6 +36,11 @@ public class Vala.UnresolvedSymbol : CodeNode {
         */
        public string name { get; set; }
 
+       /**
+        * Qualified access to global symbol.
+        */
+       public bool qualified { get; set; }
+
        public UnresolvedSymbol (UnresolvedSymbol? inner, string name, SourceReference? source_reference = null) {
                this.inner = inner;
                this.name = name;