Пример #1
0
            public Value(TransientModule /*!*/ module, List <ProvidedType> /*!*/ typeDependencies)
            {
                Debug.Assert(module != null && typeDependencies != null);

                this.Module           = module;
                this.TypeDependencies = typeDependencies;
            }
Пример #2
0
        internal TransientModule /*!*/ AddModule(TransientModule /*!*/ module, List <ProvidedType> /*!*/ dependentTypes,
                                                 string code, SourceCodeDescriptor descriptor)
        {
            Key   key   = new Key(code, descriptor);
            Value value = new Value(module, dependentTypes);

            // adds item to the cache and the list if it is not there:

            rwLock.EnterWriteLock();
            try
            {
                Value existing;
                if (!cache.TryGetValue(key, out existing))
                {
                    cache.Add(key, value);

                    Debug.Assert(module.Id < modules.Count, "Slot should have been reserved.");
                    modules[module.Id] = module;
                }
                else
                {
                    module = existing.Module;
                }
            }
            finally
            {
                rwLock.ExitWriteLock();
            }

            return(module);
        }
Пример #3
0
        /// <summary>
        /// Used by the builder.
        /// </summary>
        public TransientModule(int id, EvalKinds kind, TransientCompilationUnit /*!*/ unit, TransientAssembly /*!*/ scriptAssembly,
                               TransientModule containingModule, string sourcePath)
            : base(unit, scriptAssembly)
        {
            Debug.Assert(unit != null && scriptAssembly != null);

            this.id               = id;
            this.sourcePath       = sourcePath;
            this.kind             = kind;
            this.containingModule = containingModule;
        }
Пример #4
0
        /// <summary>
        /// Fills a list by an eval trace starting with an eval of a specified id.
        /// </summary>
        /// <param name="evalId">The id of the eval which to start with.</param>
        /// <param name="result">The list of <see cref="ErrorStackInfo"/> to fill. </param>
        public void GetEvalFullTrace(int evalId, List <ErrorStackInfo> /*!*/ result)
        {
            TransientModule module = GetModule(evalId);

            Debug.Assert(module != null);

            do
            {
                SourceCodeUnit source_unit = module.TransientCompilationUnit.SourceUnit;

                result.Add(new ErrorStackInfo(source_unit.SourceFile.FullPath, module.GetErrorString(),
                                              source_unit.Line, source_unit.Column, false));

                module = module.ContainingModule;
            }while (module != null);
        }
Пример #5
0
		internal TransientModuleBuilder(int id, EvalKinds kind, TransientCompilationUnit/*!*/ compilationUnit,
			TransientAssemblyBuilder/*!*/ assemblyBuilder, TransientModule containingModule, string sourcePath)
            : base(id, kind, compilationUnit, assemblyBuilder.TransientAssembly, containingModule, sourcePath)
		{
			this.assemblyBuilder = assemblyBuilder;

			if (!compilationUnit.IsDynamic)
			{
				this.globalBuilder = assemblyBuilder.RealModuleBuilder.DefineType(MakeName("<Global>", true),
					TypeAttributes.SpecialName | TypeAttributes.Class | TypeAttributes.Public);
			}
			else
			{
				this.globalBuilder = null;
			}
		}
Пример #6
0
        /// <summary>
        /// Gets a root eval for a specified eval.
        /// </summary>
        /// <param name="id">The eval id.</param>
        /// <returns>An id of root eval.</returns>
        public TransientModule GetRootModule(int id)
        {
            // not synchronized - the modules are not removed

            if (id == InvalidEvalId)
            {
                return(null);
            }

            Debug.Assert(id >= 0 && id < modules.Count, "Eval id has invalid value.");

            TransientModule module = modules[id];

            while (module.ContainingModule != null)
            {
                module = module.ContainingModule;
            }

            return(module);
        }
Пример #7
0
        internal TransientModuleBuilder /*!*/ DefineModule(TransientAssemblyBuilder /*!*/ assemblyBuilder,
                                                           TransientCompilationUnit /*!*/ compilationUnit, int containerId, EvalKinds kind, string sourcePath)
        {
            TransientModule container = GetModule(containerId);

            int new_id;

            rwLock.EnterWriteLock();

            try
            {
                // reserve slot in the module list:
                new_id = modules.Count;
                modules.Add(null);
            }
            finally
            {
                rwLock.ExitWriteLock();
            }

            return(new TransientModuleBuilder(new_id, kind, compilationUnit, assemblyBuilder, container, sourcePath));
        }
Пример #8
0
        /// <summary>
        /// Used by the builder.
        /// </summary>
        public TransientModule(int id, EvalKinds kind, TransientCompilationUnit/*!*/ unit, TransientAssembly/*!*/ scriptAssembly,
            TransientModule containingModule, string sourcePath)
            : base(unit, scriptAssembly)
        {
            Debug.Assert(unit != null && scriptAssembly != null);

            this.id = id;
            this.sourcePath = sourcePath;
            this.kind = kind;
            this.containingModule = containingModule;
        }