Esempio n. 1
0
        public DelegateInfo(Compilation compilation, MethodDesc target)
        {
            this.Target = target;

            var systemDelegate = compilation.TypeSystemContext.GetWellKnownType(WellKnownType.MulticastDelegate).BaseType;

            // TODO: delegates on virtuals
            if (target.IsVirtual && !target.IsFinal)
                throw new NotImplementedException("Delegate to virtual");

            // TODO: Delegates on valuetypes
            if (target.OwningType.IsValueType)
                throw new NotImplementedException("Delegate to valuetype");

            if (target.Signature.IsStatic)
            {
                this.ShuffleThunk = new DelegateShuffleThunk(target);

                this.Ctor = systemDelegate.GetKnownMethod("InitializeClosedStaticThunk", null);
            }
            else
            {
                this.Ctor = systemDelegate.GetKnownMethod("InitializeClosedInstance", null);
            }
        }
Esempio n. 2
0
        public CorInfoImpl(Compilation compilation)
        {
            _compilation = compilation;

            _comp = GetJitInterfaceWrapper(CreateUnmanagedInstance());

            _jit = getJit();
        }
Esempio n. 3
0
        public CorInfoImpl(Compilation compilation)
        {
            _compilation = compilation;

            _comp = CreateUnmanagedInstance();

            _jit = getJit();

            _compile = Marshal.GetDelegateForFunctionPointer<_compileMethod>(**((IntPtr**)_jit));
        }
Esempio n. 4
0
        public CorInfoImpl(Compilation compilation)
        {
            //
            // Global initialization
            //
            _compilation = compilation;

            jitStartup(GetJitHost());

            _jit = getJit();
            if (_jit == IntPtr.Zero)
            {
                throw new IOException("Failed to initialize JIT");
            }

            _unmanagedCallbacks = GetUnmanagedCallbacks(out _keepAlive);
        }
Esempio n. 5
0
        public ILImporter(Compilation compilation, CppWriter writer, MethodDesc method, MethodIL methodIL)
        {
            _compilation = compilation;
            _nodeFactory = _compilation.NodeFactory;

            _writer = writer;

            _method = method;
            _methodSignature = method.Signature;

            _typeSystemContext = method.Context;

            if (!_methodSignature.IsStatic)
                _thisType = method.OwningType;

            _methodIL = methodIL;

            _ilBytes = _methodIL.GetILBytes();
            _locals = _methodIL.GetLocals();

            var ilExceptionRegions = _methodIL.GetExceptionRegions();
            _exceptionRegions = new ExceptionRegion[ilExceptionRegions.Length];
            for (int i = 0; i < ilExceptionRegions.Length; i++)
            {
                _exceptionRegions[i] = new ExceptionRegion() { ILRegion = ilExceptionRegions[i] };
            }
        }
Esempio n. 6
0
        private void SingleFileCompilation()
        {
            List<MethodDesc> rootMethods = new List<MethodDesc>();
            MethodDesc entryPointMethod = null;

            EcmaModule entryPointModule = GetEntryPointModule();
            if (entryPointModule != null)
            {
                int entryPointToken = entryPointModule.PEReader.PEHeaders.CorHeader.EntryPointTokenOrRelativeVirtualAddress;
                entryPointMethod = entryPointModule.GetMethod(MetadataTokens.EntityHandle(entryPointToken));
            }

            Compilation compilation = new Compilation(_compilerTypeSystemContext, _options);
            compilation.Log = Console.Out;
            compilation.OutputPath = _outputPath;
            if (_options.IsCppCodeGen)
            {
                // Don't set Out when using object writer which is handled by LLVM.
                compilation.Out = new StreamWriter(File.Create(_outputPath));
            }

            compilation.CompileSingleFile(entryPointMethod);
        }
Esempio n. 7
0
        private void SingleFileCompilation()
        {
            Compilation compilation = new Compilation(_options);
            compilation.Log = _options.Verbose ? Console.Out : TextWriter.Null;

            compilation.CompileSingleFile();
        }
Esempio n. 8
0
        private int Run(string[] args)
        {
            InitializeDefaultOptions();

            ArgumentSyntax syntax = ParseCommandLine(args);
            if (_help)
            {
                Help(syntax.GetHelpText());
                return 1;
            }

            if (_inputFilePaths.Count == 0)
                throw new CommandLineException("No input files specified");

            if (_options.OutputFilePath == null)
                throw new CommandLineException("Output filename must be specified (/out <file>)");

            //
            // Initialize type system context
            //

            SharedGenericsMode genericsMode = _useSharedGenerics ?
                SharedGenericsMode.CanonicalReferenceTypes : SharedGenericsMode.Disabled;

            var typeSystemContext = new CompilerTypeSystemContext(new TargetDetails(_targetArchitecture, _targetOS), genericsMode);
            typeSystemContext.InputFilePaths = _inputFilePaths;
            typeSystemContext.ReferenceFilePaths = _referenceFilePaths;

            typeSystemContext.SetSystemModule(typeSystemContext.GetModuleForSimpleName(_systemModuleName));

            //
            // Initialize compilation group
            //

            // Single method mode?
            MethodDesc singleMethod = CheckAndParseSingleMethodModeArguments(typeSystemContext);

            CompilationModuleGroup compilationGroup;
            if (singleMethod != null)
            {
                compilationGroup = new SingleMethodCompilationModuleGroup(typeSystemContext, singleMethod);
            }
            else if (_multiFile)
            {
                compilationGroup = new MultiFileCompilationModuleGroup(typeSystemContext);
            }
            else
            {
                compilationGroup = new SingleFileCompilationModuleGroup(typeSystemContext);
            }

            //
            // Compile
            //

            Compilation compilation = new Compilation(_options, typeSystemContext, compilationGroup);
            compilation.Log = _options.Verbose ? Console.Out : TextWriter.Null;
            compilation.Compile();

            return 0;
        }
Esempio n. 9
0
 public NameMangler(Compilation compilation)
 {
     _compilation = compilation;
 }
Esempio n. 10
0
 public RvaFieldData(Compilation compilation, FieldDesc field)
 {
     Debug.Assert(field.HasRva);
     Field = field;
     _compilation = compilation;
 }
Esempio n. 11
0
        public JitHelper(Compilation compilation, JitHelperId id)
        {
            _compilation = compilation;

            this.Id = id;
        }