vala r1783 - in trunk: . compiler tests vala
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r1783 - in trunk: . compiler tests vala
- Date: Fri, 26 Sep 2008 19:09:31 +0000 (UTC)
Author: juergbi
Date: Fri Sep 26 19:09:30 2008
New Revision: 1783
URL: http://svn.gnome.org/viewvc/vala?rev=1783&view=rev
Log:
2008-09-26 JÃrg Billeter <j bitron ch>
* vala/Makefile.am:
* vala/valacodevisitor.vala:
* vala/valagenieparser.vala:
* vala/valaparser.vala:
* vala/valasemanticanalyzer.vala:
* vala/valasourcefile.vala:
* vala/valasymbolresolver.vala:
* vala/valaunresolvedsymbol.vala:
* vala/valausingdirective.vala:
* compiler/valacompiler.vala:
Replace NamespaceReference by UsingDirective and UnresolvedSymbol,
fixes bug 537510
* tests/namespaces.vala:
Test using directive with nested namespaces
Added:
trunk/vala/valausingdirective.vala (contents, props changed)
- copied, changed from r1781, /trunk/vala/valanamespacereference.vala
Removed:
trunk/vala/valanamespacereference.vala
Modified:
trunk/ChangeLog
trunk/compiler/valacompiler.vala
trunk/tests/namespaces.vala
trunk/vala/Makefile.am
trunk/vala/valacodevisitor.vala
trunk/vala/valagenieparser.vala
trunk/vala/valaparser.vala
trunk/vala/valasemanticanalyzer.vala
trunk/vala/valasourcefile.vala
trunk/vala/valasymbolresolver.vala
trunk/vala/valaunresolvedsymbol.vala
Modified: trunk/compiler/valacompiler.vala
==============================================================================
--- trunk/compiler/valacompiler.vala (original)
+++ trunk/compiler/valacompiler.vala Fri Sep 26 19:09:30 2008
@@ -215,7 +215,7 @@
var source_file = new SourceFile (context, rpath);
// import the GLib namespace by default (namespace of backend-specific standard library)
- source_file.add_using_directive (new NamespaceReference ("GLib"));
+ source_file.add_using_directive (new UsingDirective (new UnresolvedSymbol (null, "GLib", null)));
context.add_source_file (source_file);
} else if (source.has_suffix (".vapi")) {
Modified: trunk/tests/namespaces.vala
==============================================================================
--- trunk/tests/namespaces.vala (original)
+++ trunk/tests/namespaces.vala Fri Sep 26 19:09:30 2008
@@ -1,4 +1,4 @@
-using GLib;
+using Foo.Sub;
public class GlobalTestClass {
public GlobalTestClass() {
@@ -19,6 +19,8 @@
new global::GlobalTestClass();
+ var obj = new ClassInNestedNamespace ();
+
return 0;
}
@@ -29,3 +31,6 @@
}
}
+public class Foo.Sub.ClassInNestedNamespace {
+}
+
Modified: trunk/vala/Makefile.am
==============================================================================
--- trunk/vala/Makefile.am (original)
+++ trunk/vala/Makefile.am Fri Sep 26 19:09:30 2008
@@ -94,7 +94,6 @@
valamethodtype.vala \
valanamedargument.vala \
valanamespace.vala \
- valanamespacereference.vala \
valanullchecker.vala \
valanullliteral.vala \
valanulltype.vala \
@@ -143,6 +142,7 @@
valaunaryexpression.vala \
valaunresolvedsymbol.vala \
valaunresolvedtype.vala \
+ valausingdirective.vala \
valavaluetype.vala \
valavoidtype.vala \
valawhilestatement.vala \
Modified: trunk/vala/valacodevisitor.vala
==============================================================================
--- trunk/vala/valacodevisitor.vala (original)
+++ trunk/vala/valacodevisitor.vala Fri Sep 26 19:09:30 2008
@@ -212,11 +212,11 @@
}
/**
- * Visit operation called for namespace references.
+ * Visit operation called for using directives.
*
- * @param ns a namespace reference
+ * @param ns a using directive
*/
- public virtual void visit_namespace_reference (NamespaceReference ns) {
+ public virtual void visit_using_directive (UsingDirective ns) {
}
/**
Modified: trunk/vala/valagenieparser.vala
==============================================================================
--- trunk/vala/valagenieparser.vala (original)
+++ trunk/vala/valagenieparser.vala Fri Sep 26 19:09:30 2008
@@ -2337,7 +2337,7 @@
void add_uses_clause () throws ParseError {
var begin = get_location ();
var sym = parse_symbol_name ();
- var ns_ref = new NamespaceReference (sym.name, get_src (begin));
+ var ns_ref = new UsingDirective (sym, get_src (begin));
scanner.source_file.add_using_directive (ns_ref);
}
Modified: trunk/vala/valaparser.vala
==============================================================================
--- trunk/vala/valaparser.vala (original)
+++ trunk/vala/valaparser.vala Fri Sep 26 19:09:30 2008
@@ -1916,7 +1916,7 @@
do {
var begin = get_location ();
var sym = parse_symbol_name ();
- var ns_ref = new NamespaceReference (sym.name, get_src (begin));
+ var ns_ref = new UsingDirective (sym, get_src (begin));
scanner.source_file.add_using_directive (ns_ref);
} while (accept (TokenType.COMMA));
expect (TokenType.SEMICOLON);
Modified: trunk/vala/valasemanticanalyzer.vala
==============================================================================
--- trunk/vala/valasemanticanalyzer.vala (original)
+++ trunk/vala/valasemanticanalyzer.vala Fri Sep 26 19:09:30 2008
@@ -37,7 +37,7 @@
Class current_class;
Struct current_struct;
- Gee.List<NamespaceReference> current_using_directives;
+ Gee.List<UsingDirective> current_using_directives;
DataType bool_type;
DataType string_type;
@@ -1601,7 +1601,7 @@
}
if (expr.symbol_reference == null) {
- foreach (NamespaceReference ns in current_using_directives) {
+ foreach (UsingDirective ns in current_using_directives) {
var local_sym = ns.namespace_symbol.scope.lookup (expr.member_name);
if (local_sym != null) {
if (expr.symbol_reference != null) {
Modified: trunk/vala/valasourcefile.vala
==============================================================================
--- trunk/vala/valasourcefile.vala (original)
+++ trunk/vala/valasourcefile.vala Fri Sep 26 19:09:30 2008
@@ -69,7 +69,7 @@
*/
public weak CodeContext context { get; set; }
- private Gee.List<NamespaceReference> using_directives = new ArrayList<NamespaceReference> ();
+ private Gee.List<UsingDirective> using_directives = new ArrayList<UsingDirective> ();
private Gee.List<CodeNode> nodes = new ArrayList<CodeNode> ();
@@ -109,23 +109,39 @@
*
* @param ns reference to namespace
*/
- public void add_using_directive (NamespaceReference ns) {
- foreach (NamespaceReference using_directive in using_directives) {
- if (using_directive.name == ns.name) {
+ public void add_using_directive (UsingDirective ns) {
+ foreach (UsingDirective using_directive in using_directives) {
+ if (same_symbol (using_directive.namespace_symbol, ns.namespace_symbol)) {
// ignore duplicates
return;
}
}
using_directives.add (ns);
}
-
+
+ bool same_symbol (Symbol? sym1, Symbol? sym2) {
+ if (sym1 == sym2) {
+ return true;
+ }
+
+ var unresolved_symbol1 = sym1 as UnresolvedSymbol;
+ var unresolved_symbol2 = sym2 as UnresolvedSymbol;
+ if (unresolved_symbol1 != null && unresolved_symbol2 != null) {
+ if (same_symbol (unresolved_symbol1.inner, unresolved_symbol2.inner)) {
+ return (unresolved_symbol1.name == unresolved_symbol2.name);
+ }
+ }
+
+ return false;
+ }
+
/**
* Returns a copy of the list of using directives.
*
* @return using directive list
*/
- public Gee.List<NamespaceReference> get_using_directives () {
- return new ReadOnlyList<NamespaceReference> (using_directives);
+ public Gee.List<UsingDirective> get_using_directives () {
+ return new ReadOnlyList<UsingDirective> (using_directives);
}
/**
@@ -155,7 +171,7 @@
}
public void accept_children (CodeVisitor visitor) {
- foreach (NamespaceReference ns_ref in using_directives) {
+ foreach (UsingDirective ns_ref in using_directives) {
ns_ref.accept (visitor);
}
Modified: trunk/vala/valasymbolresolver.vala
==============================================================================
--- trunk/vala/valasymbolresolver.vala (original)
+++ trunk/vala/valasymbolresolver.vala Fri Sep 26 19:09:30 2008
@@ -30,7 +30,7 @@
public class Vala.SymbolResolver : CodeVisitor {
Symbol root_symbol;
Scope current_scope;
- Gee.List<NamespaceReference> current_using_directives;
+ Gee.List<UsingDirective> current_using_directives;
/**
* Resolve symbol names in the specified code context.
@@ -179,12 +179,15 @@
b.accept_children (this);
}
- public override void visit_namespace_reference (NamespaceReference ns) {
- ns.namespace_symbol = current_scope.lookup (ns.name);
- if (ns.namespace_symbol == null) {
- ns.error = true;
- Report.error (ns.source_reference, "The namespace name `%s' could not be found".printf (ns.name));
- return;
+ public override void visit_using_directive (UsingDirective ns) {
+ var unresolved_symbol = ns.namespace_symbol as UnresolvedSymbol;
+ if (unresolved_symbol != null) {
+ ns.namespace_symbol = resolve_symbol (unresolved_symbol);
+ if (ns.namespace_symbol == null) {
+ ns.error = true;
+ Report.error (ns.source_reference, "The namespace name `%s' could not be found".printf (unresolved_symbol.to_string ()));
+ return;
+ }
}
}
@@ -200,7 +203,7 @@
scope = scope.parent_scope;
}
if (sym == null) {
- foreach (NamespaceReference ns in current_using_directives) {
+ foreach (UsingDirective ns in current_using_directives) {
if (ns.error) {
continue;
}
Modified: trunk/vala/valaunresolvedsymbol.vala
==============================================================================
--- trunk/vala/valaunresolvedsymbol.vala (original)
+++ trunk/vala/valaunresolvedsymbol.vala Fri Sep 26 19:09:30 2008
@@ -20,23 +20,16 @@
* JÃrg Billeter <j bitron ch>
*/
-using GLib;
-
/**
* An unresolved reference to a symbol.
*/
-public class Vala.UnresolvedSymbol : CodeNode {
+public class Vala.UnresolvedSymbol : Symbol {
/**
* The parent of the symbol or null.
*/
public UnresolvedSymbol? inner { get; set; }
/**
- * The symbol name.
- */
- public string name { get; set; }
-
- /**
* Qualified access to global symbol.
*/
public bool qualified { get; set; }
Copied: trunk/vala/valausingdirective.vala (from r1781, /trunk/vala/valanamespacereference.vala)
==============================================================================
--- /trunk/vala/valanamespacereference.vala (original)
+++ trunk/vala/valausingdirective.vala Fri Sep 26 19:09:30 2008
@@ -1,4 +1,4 @@
-/* valanamespacereference.vala
+/* valausingdirective.vala
*
* Copyright (C) 2006-2008 JÃrg Billeter
*
@@ -25,30 +25,24 @@
/**
* A reference to a namespace symbol.
*/
-public class Vala.NamespaceReference : CodeNode {
+public class Vala.UsingDirective : CodeNode {
/**
- * The name of the namespace this reference is referring to.
+ * The symbol of the namespace this using directive is referring to.
*/
- public string name { get; set; }
-
- /**
- * The resolved symbol of the namespace this reference is referring to.
- */
- public weak Symbol namespace_symbol { get; set; }
+ public Symbol namespace_symbol { get; set; }
/**
- * Creates a new namespace reference.
+ * Creates a new using directive.
*
- * @param name namespace name
- * @param source_reference reference to source code
- * @return newly created namespace reference
+ * @param namespace_symbol namespace symbol
+ * @return newly created using directive
*/
- public NamespaceReference (string name, SourceReference? source_reference = null) {
- this.name = name;
+ public UsingDirective (Symbol namespace_symbol, SourceReference? source_reference = null) {
+ this.namespace_symbol = namespace_symbol;
this.source_reference = source_reference;
}
public override void accept (CodeVisitor visitor) {
- visitor.visit_namespace_reference (this);
+ visitor.visit_using_directive (this);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]