+
+ public class NamespaceUsing
+ {
+ readonly MemberName name;
+ Namespace resolved;
+
+ public NamespaceUsing (MemberName name)
+ {
+ this.name = name;
+ }
+
+ public string GetSignatureForError ()
+ {
+ return name.GetSignatureForError ();
+ }
+
+ public Location Location
+ {
+ get { return name.Location; }
+ }
+
+ public MemberName MemberName
+ {
+ get { return name; }
+ }
+
+ public string Name
+ {
+ get { return GetSignatureForError (); }
+ }
+
+ public Namespace Resolve (IMemberContext rc)
+ {
+ if (resolved != null)
+ return resolved;
+
+ FullNamedExpression fne = name.GetTypeExpression ().ResolveAsTypeOrNamespace (rc);
+ if (fne == null)
+ return null;
+
+ resolved = fne as Namespace;
+ if (resolved == null) {
+ rc.Module.Compiler.Report.SymbolRelatedToPreviousError (fne.Type);
+ rc.Module.Compiler.Report.Error (138, Location,
+ "`{0}' is a type not a namespace. A using namespace directive can only be applied to namespaces",
+ GetSignatureForError ());
+ }
+ return resolved;
+ }
+ }
+
+ public class NamespaceUsingAlias
+ {
+ public readonly string Alias;
+ public Location Location;
+
+ public NamespaceUsingAlias (string alias, Location loc)
+ {
+ this.Alias = alias;
+ this.Location = loc;
+ }
+
+ public virtual FullNamedExpression Resolve (IMemberContext rc, bool local)
+ {
+ FullNamedExpression fne = rc.Module.GetRootNamespace (Alias);
+ if (fne == null) {
+ rc.Module.Compiler.Report.Error (430, Location,
+ "The extern alias `{0}' was not specified in -reference option",
+ Alias);
+ }
+
+ return fne;
+ }
+ }
+
+ class LocalUsingAliasEntry : NamespaceUsingAlias
+ {
+ FullNamedExpression resolved;
+ MemberName value;
+
+ public LocalUsingAliasEntry (string alias, MemberName name, Location loc)
+ : base (alias, loc)
+ {
+ this.value = name;
+ }
+
+ public override FullNamedExpression Resolve (IMemberContext rc, bool local)
+ {
+ if (resolved != null || value == null)
+ return resolved;
+
+ if (local)
+ return null;
+
+ resolved = value.GetTypeExpression ().ResolveAsTypeOrNamespace (rc);
+ if (resolved == null) {
+ value = null;
+ return null;
+ }
+
+ if (resolved is TypeExpr)
+ resolved = resolved.ResolveAsType (rc);
+
+ return resolved;
+ }
+ }