Exemple #1
0
		public ModuleContainer (CompilerContext context)
			: base (null, null, MemberName.Null, null, 0)
		{
			this.context = context;

			caching_flags &= ~(Flags.Obsolete_Undetected | Flags.Excluded_Undetected);

			types = new List<TypeContainer> ();
			anonymous_types = new Dictionary<int, List<AnonymousTypeClass>> ();
			global_ns = new GlobalRootNamespace ();
			alias_ns = new Dictionary<string, RootNamespace> ();
		}
Exemple #2
0
		public static void DefineRootNamespace (string alias, Assembly assembly)
		{
			if (alias == "global") {
				NamespaceEntry.Error_GlobalNamespaceRedefined (Location.Null);
				return;
			}

			RootNamespace retval = GetRootNamespace (alias);
			if (retval == null) {
				retval = new RootNamespace (alias);
				root_namespaces.Add (alias, retval);
			}

			retval.AddAssemblyReference (assembly);
		}
        /// <summary>
        ///   Constructor Takes the current namespace and the
        ///   name.  This is bootstrapped with parent == null
        ///   and name = ""
        /// </summary>
        public Namespace(Namespace parent, string name)
        {
            // Expression members.
            this.eclass = ExprClass.Namespace;
            this.Type = InternalType.FakeInternalType;
            this.loc = Location.Null;

            this.parent = parent;

            if (parent != null)
                this.root = parent.root;
            else
                this.root = this as RootNamespace;

            if (this.root == null)
                throw new InternalErrorException ("Root namespaces must be created using RootNamespace");

            string pname = parent != null ? parent.fullname : "";

            if (pname == "")
                fullname = name;
            else
                fullname = parent.fullname + "." + name;

            if (fullname == null)
                throw new InternalErrorException ("Namespace has a null fullname");

            if (parent != null && parent.MemberName != MemberName.Null)
                MemberName = new MemberName (parent.MemberName, name);
            else if (name.Length == 0)
                MemberName = MemberName.Null;
            else
                MemberName = new MemberName (name);

            namespaces = new Dictionary<string, Namespace> ();
            cached_types = new Dictionary<string, TypeExpr> ();

            root.RegisterNamespace (this);
        }
Exemple #4
0
		//
		// Creates alias global namespace
		//
		public RootNamespace CreateRootNamespace (string alias)
		{
			if (alias == global_ns.Alias) {
				NamespaceEntry.Error_GlobalNamespaceRedefined (Location.Null, Report);
				return global_ns;
			}

			RootNamespace rn;
			if (!alias_ns.TryGetValue (alias, out rn)) {
				rn = new RootNamespace (alias);
				alias_ns.Add (alias, rn);
			}

			return rn;
		}
		public void DefineRootNamespace (string alias, Assembly assembly, CompilerContext ctx)
		{
			if (alias == alias_name) {
				NamespaceEntry.Error_GlobalNamespaceRedefined (Location.Null, ctx.Report);
				return;
			}

			RootNamespace retval = GetRootNamespace (alias);
			if (retval == null) {
				retval = new RootNamespace (alias);
				root_namespaces.Add (alias, retval);
			}

			retval.AddAssemblyReference (assembly);
		}
Exemple #6
0
		public ModuleContainer (CompilerContext context)
			: base (null, MemberName.Null, null, 0)
		{
			this.context = context;

			caching_flags &= ~(Flags.Obsolete_Undetected | Flags.Excluded_Undetected);

			containers = new List<TypeContainer> ();
			anonymous_types = new Dictionary<int, List<AnonymousTypeClass>> ();
			global_ns = new GlobalRootNamespace ();
			alias_ns = new Dictionary<string, RootNamespace> ();
			array_types = new Dictionary<ArrayContainer.TypeRankPair, ArrayContainer> ();
			pointer_types = new Dictionary<TypeSpec, PointerContainer> ();
			reference_types = new Dictionary<TypeSpec, ReferenceContainer> ();
			attrs_cache = new Dictionary<TypeSpec, MethodSpec> ();
			awaiters = new Dictionary<TypeSpec, AwaiterDefinition> ();
		}
Exemple #7
0
 public void ImportModule(Module module, RootNamespace targetNamespace)
 {
     throw new NotSupportedException();
 }
Exemple #8
0
 public void ImportAssembly(Assembly assembly, RootNamespace targetNamespace)
 {
     throw new NotSupportedException();
 }
Exemple #9
0
		public ImportedModuleDefinition ImportModule (Module module, RootNamespace targetNamespace)
		{
			var module_definition = new ImportedModuleDefinition (module, this);
			module_definition.ReadAttributes ();

			Type[] all_types;
			try {
				all_types = module.GetTypes ();
			} catch (ReflectionTypeLoadException e) {
				all_types = e.Types;
			}

			ImportTypes (all_types, targetNamespace, false);

			return module_definition;
		}
Exemple #10
0
		public void ImportAssembly (Assembly assembly, RootNamespace targetNamespace)
		{
			// It can be used more than once when importing same assembly
			// into 2 or more global aliases
			ImportedAssemblyDefinition definition;
			if (!assembly_2_definition.TryGetValue (assembly, out definition)) {
				definition = new ImportedAssemblyDefinition (assembly);
				assembly_2_definition.Add (assembly, definition);

				definition.ReadAttributes ();
			}

			//
			// This part tries to simulate loading of top-level
			// types only, any missing dependencies are ignores here.
			// Full error report is reported later when the type is
			// actually used
			//
			Type[] all_types;
			try {
				all_types = assembly.GetTypes ();
			} catch (ReflectionTypeLoadException e) {
				all_types = e.Types;
			}

			ImportTypes (all_types, targetNamespace, definition.HasExtensionMethod);
		}
Exemple #11
0
 public ImportedModuleDefinition ImportModule(Module module, RootNamespace targetNamespace)
 {
     throw new NotSupportedException();
 }
Exemple #12
0
		public ImportedModuleDefinition ImportModule (Module module, RootNamespace targetNamespace)
		{
			var module_definition = new ImportedModuleDefinition (module, this);
			module_definition.ReadAttributes ();

			Type extension_type = HasExtensionAttribute (CustomAttributeData.GetCustomAttributes (module));

			Type[] all_types;
			try {
				all_types = module.GetTypes ();
			} catch (ReflectionTypeLoadException e) {
				all_types = e.Types;
			}

			ImportTypes (all_types, targetNamespace, extension_type);

			return module_definition;
		}