Commit 15989e7d authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter

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

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
parent 9fb31a48
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
......
......@@ -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;
......
......@@ -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;
......
......@@ -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) {
......
......@@ -58,6 +58,7 @@ public enum Vala.TokenType {
DELETE,
DIV,
DO,
DOUBLE_COLON,
DOT,
DYNAMIC,
ELLIPSIS,
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment