示例#1
0
        protected Compilation(
            DependencyAnalyzerBase<NodeFactory> dependencyGraph,
            NodeFactory nodeFactory,
            IEnumerable<ICompilationRootProvider> compilationRoots,
            NameMangler nameMangler,
            Logger logger)
        {
            _dependencyGraph = dependencyGraph;
            _nodeFactory = nodeFactory;
            _nameMangler = nameMangler;
            _logger = logger;

            _dependencyGraph.ComputeDependencyRoutine += ComputeDependencyNodeDependencies;
            NodeFactory.AttachToDependencyGraph(_dependencyGraph);

            // TODO: hacky static field
            NodeFactory.NameMangler = nameMangler;

            var rootingService = new RootingServiceProvider(dependencyGraph, nodeFactory);
            foreach (var rootProvider in compilationRoots)
                rootProvider.AddCompilationRoots(rootingService);

            // TODO: use a better owning type for multi-file friendliness
            _typeGetTypeMethodThunks = new TypeGetTypeMethodThunkCache(TypeSystemContext.SystemModule.GetGlobalModuleType());
        }
示例#2
0
        protected Compilation(
            DependencyAnalyzerBase<NodeFactory> dependencyGraph,
            NodeFactory nodeFactory,
            IEnumerable<ICompilationRootProvider> compilationRoots,
            NameMangler nameMangler,
            Logger logger)
        {
            _dependencyGraph = dependencyGraph;
            _nodeFactory = nodeFactory;
            _nameMangler = nameMangler;
            _logger = logger;

            _dependencyGraph.ComputeDependencyRoutine += ComputeDependencyNodeDependencies;
            NodeFactory.AttachToDependencyGraph(_dependencyGraph);

            // TODO: hacky static field
            NodeFactory.NameMangler = nameMangler;

            var rootingService = new RootingServiceProvider(dependencyGraph, nodeFactory);
            foreach (var rootProvider in compilationRoots)
                rootProvider.AddCompilationRoots(rootingService);

            _typeGetTypeMethodThunks = new TypeGetTypeMethodThunkCache(nodeFactory.CompilationModuleGroup.GeneratedAssembly.GetGlobalModuleType());

            PInvokeILProvider = new PInvokeILProvider(new PInvokeILEmitterConfiguration(!nodeFactory.CompilationModuleGroup.IsSingleFileCompilation));
            _methodILCache = new ILProvider(PInvokeILProvider);
        }
示例#3
0
        public Compilation(CompilerTypeSystemContext typeSystemContext, CompilationOptions options)
        {
            _typeSystemContext = typeSystemContext;
            _options = options;

            _nameMangler = new NameMangler(this);
        }
示例#4
0
        public Compilation(CompilationOptions options, CompilerTypeSystemContext context, CompilationModuleGroup compilationGroup)
        {
            _options = options;

            _nameMangler = new NameMangler(options.IsCppCodeGen);

            _typeSystemContext = context;
            _compilationModuleGroup = compilationGroup;
        }
示例#5
0
        public Compilation(CompilationOptions options)
        {
            _options = options;

            _typeSystemContext = new CompilerTypeSystemContext(new TargetDetails(options.TargetArchitecture, options.TargetOS));
            _typeSystemContext.InputFilePaths = options.InputFilePaths;
            _typeSystemContext.ReferenceFilePaths = options.ReferenceFilePaths;

            _typeSystemContext.SetSystemModule(_typeSystemContext.GetModuleForSimpleName(options.SystemModuleName));

            _nameMangler = new NameMangler(this);
        }
示例#6
0
        protected Compilation(
            DependencyAnalyzerBase<NodeFactory> dependencyGraph,
            NodeFactory nodeFactory,
            IEnumerable<ICompilationRootProvider> compilationRoots,
            NameMangler nameMangler,
            Logger logger)
        {
            _dependencyGraph = dependencyGraph;
            _nodeFactory = nodeFactory;
            _nameMangler = nameMangler;
            _logger = logger;

            _dependencyGraph.ComputeDependencyRoutine += ComputeDependencyNodeDependencies;
            NodeFactory.AttachToDependencyGraph(_dependencyGraph);

            // TODO: hacky static field
            NodeFactory.NameMangler = nameMangler;

            var rootingService = new RootingServiceProvider(dependencyGraph, nodeFactory);
            foreach (var rootProvider in compilationRoots)
                rootProvider.AddCompilationRoots(rootingService);
        }
示例#7
0
        public Compilation(CompilationOptions options)
        {
            _options = options;

            _typeSystemContext = new CompilerTypeSystemContext(new TargetDetails(options.TargetArchitecture, options.TargetOS));
            _typeSystemContext.InputFilePaths = options.InputFilePaths;
            _typeSystemContext.ReferenceFilePaths = options.ReferenceFilePaths;

            _typeSystemContext.SetSystemModule(_typeSystemContext.GetModuleForSimpleName(options.SystemModuleName));

            _nameMangler = new NameMangler(this);

            _typeInitManager = new TypeInitialization();

            if (options.MultiFile)
            {
                _compilationModuleGroup = new MultiFileCompilationModuleGroup(_typeSystemContext, this);
            }
            else
            {
                _compilationModuleGroup = new SingleFileCompilationModuleGroup(_typeSystemContext, this);
            }
        }
示例#8
0
 public sealed override string EEType(TypeDesc type)
 {
     return("__EEType_" + NameMangler.GetMangledTypeName(type));
 }
示例#9
0
 public sealed override string ThreadStatics(TypeDesc type)
 {
     return(NameMangler.CompilationUnitPrefix + NameMangler.GetMangledTypeName(type) + "::" + ThreadStaticMemberName);
 }
示例#10
0
 public sealed override string NonGCStatics(TypeDesc type)
 {
     return(NameMangler.GetMangledTypeName(type) + "::" + NonGCStaticMemberName);
 }
 public CompilationBuilder(CompilerTypeSystemContext context, CompilationModuleGroup compilationGroup, NameMangler nameMangler)
 {
     _context          = context;
     _compilationGroup = compilationGroup;
     _nameMangler      = nameMangler;
     _metadataManager  = new EmptyMetadataManager(compilationGroup, context);
 }
示例#12
0
 public sealed override string TypeGenericDictionary(TypeDesc type)
 {
     return(GenericDictionaryNamePrefix + NameMangler.GetMangledTypeName(type));
 }
示例#13
0
 public sealed override string NonGCStatics(TypeDesc type)
 {
     return(NameMangler.GetMangledTypeName(type) + "::__NONGCSTATICS");
 }
示例#14
0
 public sealed override string ThreadStatics(TypeDesc type)
 {
     return(NameMangler.CompilationUnitPrefix + NameMangler.GetMangledTypeName(type) + "::__THREADSTATICS");
 }
示例#15
0
 // Mangled name of boxed version of a type
 public sealed override string MangledBoxedTypeName(TypeDesc type)
 {
     Debug.Assert(type.IsValueType);
     return("Boxed_" + NameMangler.GetMangledTypeName(type));
 }
示例#16
0
 public override string MethodGenericDictionary(MethodDesc method)
 {
     return(GenericDictionaryNamePrefix + NameMangler.GetMangledMethodName(method));
 }
示例#17
0
 public CompilationBuilder(CompilerTypeSystemContext context, CompilationModuleGroup compilationGroup, NameMangler nameMangler)
 {
     _context          = context;
     _compilationGroup = compilationGroup;
     _nameMangler      = nameMangler;
     InitializePartial();
 }
示例#18
0
 public BlobNode FieldRvaDataBlob(FieldDesc field)
 {
     // Use the typical field definition in case this is an instantiated generic type
     field = field.GetTypicalFieldDefinition();
     return(ReadOnlyDataBlob(NameMangler.GetMangledFieldName(field), ((EcmaField)field).GetFieldRvaData(), Target.PointerSize));
 }
示例#19
0
        public void Compile()
        {
            NodeFactory.NameMangler = NameMangler;

            string systemModuleName = ((IAssemblyDesc)_typeSystemContext.SystemModule).GetName().Name;

            // TODO: just something to get Runtime.Base compiled
            if (systemModuleName != "System.Private.CoreLib")
            {
                NodeFactory.CompilationUnitPrefix = systemModuleName.Replace(".", "_");
            }
            else
            {
                NodeFactory.CompilationUnitPrefix = NameMangler.SanitizeName(Path.GetFileNameWithoutExtension(Options.OutputFilePath));
            }

            if (_options.IsCppCodeGen)
            {
                _nodeFactory = new CppCodegenNodeFactory(_typeSystemContext, _compilationModuleGroup);
            }
            else
            {
                _nodeFactory = new RyuJitNodeFactory(_typeSystemContext, _compilationModuleGroup);
            }

            // Choose which dependency graph implementation to use based on the amount of logging requested.
            if (_options.DgmlLog == null)
            {
                // No log uses the NoLogStrategy
                _dependencyGraph = new DependencyAnalyzer <NoLogStrategy <NodeFactory>, NodeFactory>(_nodeFactory, null);
            }
            else
            {
                if (_options.FullLog)
                {
                    // Full log uses the full log strategy
                    _dependencyGraph = new DependencyAnalyzer <FullGraphLogStrategy <NodeFactory>, NodeFactory>(_nodeFactory, null);
                }
                else
                {
                    // Otherwise, use the first mark strategy
                    _dependencyGraph = new DependencyAnalyzer <FirstMarkLogStrategy <NodeFactory>, NodeFactory>(_nodeFactory, null);
                }
            }

            _nodeFactory.AttachToDependencyGraph(_dependencyGraph);

            if (_options.IsCppCodeGen)
            {
                _cppWriter = new CppCodeGen.CppWriter(this);

                _dependencyGraph.ComputeDependencyRoutine += CppCodeGenComputeDependencyNodeDependencies;

                var nodes = _dependencyGraph.MarkedNodeList;

                _cppWriter.OutputCode(nodes, _compilationModuleGroup.StartupCodeMain, _nodeFactory);
            }
            else
            {
                _corInfo = new CorInfoImpl(this, new JitConfigProvider(_options.CodegenOptions));

                _dependencyGraph.ComputeDependencyRoutine += ComputeDependencyNodeDependencies;

                var nodes = _dependencyGraph.MarkedNodeList;

                ObjectWriter.EmitObject(_options.OutputFilePath, nodes, _nodeFactory);
            }

            if (_options.DgmlLog != null)
            {
                using (FileStream dgmlOutput = new FileStream(_options.DgmlLog, FileMode.Create))
                {
                    DgmlWriter.WriteDependencyGraphToStream(dgmlOutput, _dependencyGraph);
                    dgmlOutput.Flush();
                }
            }
        }
示例#20
0
 public sealed override string ThreadStatics(TypeDesc type)
 {
     return("__ThreadStaticBase_" + NameMangler.GetMangledTypeName(type));
 }
示例#21
0
 internal ILScannerBuilder(CompilerTypeSystemContext context, CompilationModuleGroup compilationGroup, NameMangler mangler, ILProvider ilProvider)
 {
     _context          = context;
     _compilationGroup = compilationGroup;
     _nameMangler      = mangler;
     _metadataManager  = new EmptyMetadataManager(context);
     _ilProvider       = ilProvider;
 }