+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
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 {
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;
case ':':
type = TokenType.COLON;
current++;
+ if (current < end && current[0] == ':') {
+ type = TokenType.DOUBLE_COLON;
+ current++;
+ }
break;
case ',':
type = TokenType.COMMA;
}
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) {
DELETE,
DIV,
DO,
+ DOUBLE_COLON,
DOT,
DYNAMIC,
ELLIPSIS,
*/
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;