Esempio n. 1
0
        private ICompileUnit TryToLoadAssemblyContainingNamespace(string @namespace)
        {
            ICompileUnit asm = Parameters.LoadAssembly(@namespace, false);

            if (asm != null)
            {
                return(asm);
            }

            //try to load assemblies name after the parent namespaces
            var namespaces = @namespace.Split('.');

            if (namespaces.Length == 1)
            {
                return(null);
            }

            for (var level = namespaces.Length - 1; level > 0; level--)
            {
                var parentNamespace   = string.Join(".", namespaces, 0, level);
                var existingReference = Parameters.FindAssembly(parentNamespace);
                if (existingReference != null)
                {
                    return(null);
                }
                var parentNamespaceAssembly = Parameters.LoadAssembly(parentNamespace, false);
                if (parentNamespaceAssembly != null)
                {
                    return(parentNamespaceAssembly);
                }
            }
            return(null);
        }
Esempio n. 2
0
 public SourceMethodBuilder(ICompileUnit comp_unit, int ns_id, IMethodDef method)
 {
     this._comp_unit = comp_unit;
     this._method    = method;
     this._ns_id     = ns_id;
     method_lines    = new List <LineNumberEntry> ();
 }
Esempio n. 3
0
        public GlobalNamespace()
        {
            var internalTypeSystemProvider = My <InternalTypeSystemProvider> .Instance;

            _compileUnit = internalTypeSystemProvider.EntityFor(My <CompileUnit> .Instance);
            _references  = My <CompilerParameters> .Instance.References;
        }
        public void CloningPreservesTypeIdentityAccrossProviders()
        {
            var          type     = typeof(int);
            ICompileUnit original = _subject.ForAssembly(type.Assembly);
            IReflectionTypeSystemProvider clone = _subject.Clone();

            Assert.AreSame(_subject.Map(type), clone.Map(type));
        }
Esempio n. 5
0
        public SourceMethodBuilder OpenMethod(ICompileUnit file, int ns_id, IMethodDef method)
        {
            SourceMethodBuilder builder = new SourceMethodBuilder(file, ns_id, method);

            current_method_stack.Push(current_method);
            current_method = builder;
            return(builder);
        }
Esempio n. 6
0
		public override void SetUp()
		{
			base.SetUp();
			RunInCompilerContextEnvironment(() =>
			{	
				_subject = My<InternalTypeSystemProvider>.Instance.EntityFor(Context.CompileUnit);
			});
		}
Esempio n. 7
0
 public override void SetUp()
 {
     base.SetUp();
     RunInCompilerContextEnvironment(() =>
     {
         _subject = My <InternalTypeSystemProvider> .Instance.EntityFor(Context.CompileUnit);
     });
 }
        public void ReferencesToSameAssemblyAreEqual()
        {
            ICompileUnit ref1 = _subject.ForAssembly(GetType().Assembly);
            ICompileUnit ref2 = _subject.ForAssembly(GetType().Assembly);

            Assert.IsNotNull(ref1);
            Assert.IsNotNull(ref2);
            Assert.AreEqual(ref1, ref2);
        }
        public void ClonePreservesOriginalReferences()
        {
            ICompileUnit original = _subject.ForAssembly(GetType().Assembly);
            IReflectionTypeSystemProvider clone = _subject.Clone();

            Assert.AreNotSame(_subject, clone);
            ICompileUnit referenceFromClone = clone.ForAssembly(GetType().Assembly);

            Assert.AreSame(original, referenceFromClone);
        }
Esempio n. 10
0
 public static SourceMethodBuilder OpenMethod(ICompileUnit file, IMethodDef method)
 {
     if (symwriter != null)
     {
         return(symwriter.OpenMethod(file, -1 /* Not used */, method));
     }
     else
     {
         return(null);
     }
 }
        public ICompileUnit EntityFor(CompileUnit unit)
        {
            ICompileUnit compileUnit = (ICompileUnit)unit.Entity;

            if (null != compileUnit)
            {
                return(compileUnit);
            }

            return(Bind(unit, new InternalCompileUnit(unit)));
        }
Esempio n. 12
0
 public static SourceMethodBuilder OpenMethod(ICompileUnit file, int ns_id,
                                              IMethodDef method)
 {
     if (symwriter != null)
     {
         return(symwriter.OpenMethod(file, ns_id, method));
     }
     else
     {
         return(null);
     }
 }
        public void RootNamespace()
        {
            ICompileUnit reference = _subject.ForAssembly(GetType().Assembly);
            INamespace   root      = reference.RootNamespace;

            Assert.IsFalse(root.Resolve(new List <IEntity>(), "XXX", EntityType.Any));

            IEntity type = NamespaceAssert.ResolveQualifiedNameToSingle(root, GetType().FullName);

            Assert.AreEqual(EntityType.Type, type.EntityType);
            Assert.AreEqual(type.FullName, GetType().FullName);
        }
Esempio n. 14
0
        private bool TryAutoAddAssemblyReference(Boo.Lang.Compiler.Ast.Import import)
        {
            ICompileUnit asm = Parameters.FindAssembly(import.Namespace);

            if (asm != null)
            {
                return(false);                //name resolution already failed earlier, don't try twice
            }
            asm = Parameters.LoadAssembly(import.Namespace, false);
            if (asm == null)
            {
                //try generalized namespaces
                string[] namespaces = import.Namespace.Split(new char[] { '.', });
                if (namespaces.Length == 1)
                {
                    return(false);
                }
                string ns;
                int    level = namespaces.Length - 1;
                while (level > 0)
                {
                    ns  = string.Join(".", namespaces, 0, level);
                    asm = Parameters.FindAssembly(ns);
                    if (asm != null)
                    {
                        return(false);                                 //name resolution already failed earlier, don't try twice
                    }
                    asm = Parameters.LoadAssembly(ns, false);
                    if (asm != null)
                    {
                        break;
                    }
                    level--;
                }
            }

            if (asm != null)
            {
                Parameters.References.Add(asm);
                import.AssemblyReference        = new ReferenceExpression(import.LexicalInfo, asm.FullName);
                import.AssemblyReference.Entity = asm;

                NameResolutionService.ClearResolutionCacheFor(asm.Name);
                return(true);
            }
            return(false);
        }
Esempio n. 15
0
        private ICompileUnit ResolveAssemblyReference(ReferenceExpression reference)
        {
            ICompileUnit existing = Parameters.FindAssembly(reference.Name);

            if (null != existing)
            {
                return(existing);
            }

            ICompileUnit newAssembly = Parameters.LoadAssembly(reference.Name);

            if (null != newAssembly)
            {
                Parameters.References.Add(newAssembly);
                return(newAssembly);
            }
            return(null);
        }
		public void SetMethodUnit (ICompileUnit file)
		{
			current_method._comp_unit = file;
		}
		public SourceMethodBuilder (ICompileUnit comp_unit, int ns_id, IMethodDef method)
		{
			this._comp_unit = comp_unit;
			this._method = method;
			this._ns_id = ns_id;

			method_lines = new LineNumberEntry [50];
		}
Esempio n. 18
0
 public void SetMethodUnit(ICompileUnit file)
 {
     current_method._comp_unit = file;
 }
		public SourceMethodBuilder OpenMethod (ICompileUnit file, int ns_id, IMethodDef method)
		{
			SourceMethodBuilder builder = new SourceMethodBuilder (file, ns_id, method);
			current_method_stack.Push (current_method);
			current_method = builder;
			methods.Add (current_method);
			return builder;
		}
		public static SourceMethodBuilder OpenMethod (ICompileUnit file, int ns_id,
							      IMethodDef method)
		{
			if (symwriter != null)
				return symwriter.OpenMethod (file, ns_id, method);
			else
				return null;
		}
Esempio n. 21
0
		public SourceMethodBuilder (ICompileUnit comp_unit)
		{
			this._comp_unit = comp_unit;
			method_lines = new List<LineNumberEntry> ();
		}
Esempio n. 22
0
 public SourceMethodBuilder(ICompileUnit comp_unit)
 {
     this._comp_unit = comp_unit;
     method_lines    = new List <LineNumberEntry> ();
 }
Esempio n. 23
0
		protected SourceMethod (DeclSpace parent, MethodBase method, ICompileUnit file)
		{
			this.method = method;
			
			builder = SymbolWriter.OpenMethod (file, parent.NamespaceEntry.SymbolFileID, this);
		}
Esempio n. 24
0
		SourceMethod (MethodBase method, ICompileUnit file)
		{
			this.method = method;
			SymbolWriter.OpenMethod (file, this);
		}
Esempio n. 25
0
		public SourceMethodBuilder (ICompileUnit comp_unit, int ns_id, IMethodDef method)
			: this (comp_unit)
		{
			this.ns_id = ns_id;
			this.method = method;
		}
Esempio n. 26
0
		public GlobalNamespace()
		{
			var internalTypeSystemProvider = My<InternalTypeSystemProvider>.Instance;
			_compileUnit = internalTypeSystemProvider.EntityFor(My<CompileUnit>.Instance);
			_references = My<CompilerParameters>.Instance.References;
		}
Esempio n. 27
0
 public SourceMethodBuilder(ICompileUnit comp_unit, int ns_id, IMethodDef method)
     : this(comp_unit)
 {
     this.ns_id  = ns_id;
     this.method = method;
 }
Esempio n. 28
0
		public static SourceMethodBuilder OpenMethod (ICompileUnit file, IMethodDef method)
		{
			if (symwriter != null)
				return symwriter.OpenMethod (file, -1 /* Not used */, method);
			else
				return null;
		}