From 8ddaa28137a8d94638c3236491b1d390079aecc6 Mon Sep 17 00:00:00 2001 From: Juerg Billeter Date: Sun, 25 May 2008 13:49:21 +0000 Subject: [PATCH] Support qualified access to global symbols within expressions 2008-05-25 Juerg Billeter * vala/valamemberaccess.vala: * vala/valaparser.vala: * vala/valasemanticanalyzer.vala: Support qualified access to global symbols within expressions svn path=/trunk/; revision=1428 --- ChangeLog | 8 ++++++++ vala/valamemberaccess.vala | 5 +++++ vala/valaparser.vala | 6 ++++++ vala/valasemanticanalyzer.vala | 5 ++++- 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a4f378c..a2e301f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2008-05-25 Jürg Billeter + * vala/valamemberaccess.vala: + * vala/valaparser.vala: + * vala/valasemanticanalyzer.vala: + + Support qualified access to global symbols within expressions + +2008-05-25 Jürg Billeter + * vapi/sqlite3.vapi: use [Compact] attribute 2008-05-25 Jürg Billeter diff --git a/vala/valamemberaccess.vala b/vala/valamemberaccess.vala index f38da9a..a480985 100644 --- a/vala/valamemberaccess.vala +++ b/vala/valamemberaccess.vala @@ -63,6 +63,11 @@ public class Vala.MemberAccess : Expression { */ public bool creation_member { get; set; } + /** + * Qualified access to global symbol. + */ + public bool qualified { get; set; } + private Expression? _inner; private Gee.List type_argument_list = new ArrayList (); diff --git a/vala/valaparser.vala b/vala/valaparser.vala index 30c0b5e..93dd2f8 100644 --- a/vala/valaparser.vala +++ b/vala/valaparser.vala @@ -510,8 +510,14 @@ public class Vala.Parser : CodeVisitor { Expression parse_simple_name () throws ParseError { var begin = get_location (); string id = parse_identifier (); + bool qualified = false; + if (id == "global" && accept (TokenType.DOUBLE_COLON)) { + id = parse_identifier (); + qualified = true; + } Gee.List type_arg_list = parse_type_argument_list (true); var expr = new MemberAccess (null, id, get_src (begin)); + expr.qualified = qualified; if (type_arg_list != null) { foreach (DataType type_arg in type_arg_list) { expr.add_type_argument (type_arg); diff --git a/vala/valasemanticanalyzer.vala b/vala/valasemanticanalyzer.vala index 90cbbaf..5e3b905 100644 --- a/vala/valasemanticanalyzer.vala +++ b/vala/valasemanticanalyzer.vala @@ -1563,7 +1563,10 @@ public class Vala.SemanticAnalyzer : CodeVisitor { expr.symbol_reference = null; - if (expr.inner == null) { + if (expr.qualified) { + base_symbol = root_symbol; + expr.symbol_reference = root_symbol.scope.lookup (expr.member_name); + } else if (expr.inner == null) { if (expr.member_name == "this") { if (!is_in_instance_method ()) { expr.error = true; -- 2.7.4