예제 #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);
            }
        }
예제 #2
0
        public CorInfoImpl(Compilation compilation)
        {
            _compilation = compilation;

            _comp = GetJitInterfaceWrapper(CreateUnmanagedInstance());

            _jit = getJit();
        }
예제 #3
0
        public CorInfoImpl(Compilation compilation)
        {
            _compilation = compilation;

            _comp = CreateUnmanagedInstance();

            _jit = getJit();

            _compile = Marshal.GetDelegateForFunctionPointer<_compileMethod>(**((IntPtr**)_jit));
        }
예제 #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);
        }
예제 #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] };
            }
        }
예제 #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);
        }
예제 #7
0
파일: Program.cs 프로젝트: nguerrera/corert
        private void SingleFileCompilation()
        {
            Compilation compilation = new Compilation(_options);
            compilation.Log = _options.Verbose ? Console.Out : TextWriter.Null;

            compilation.CompileSingleFile();
        }
예제 #8
0
파일: Program.cs 프로젝트: hoyMS/corert
        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;
        }
예제 #9
0
 public NameMangler(Compilation compilation)
 {
     _compilation = compilation;
 }
예제 #10
0
 public RvaFieldData(Compilation compilation, FieldDesc field)
 {
     Debug.Assert(field.HasRva);
     Field = field;
     _compilation = compilation;
 }
예제 #11
0
파일: JitHelper.cs 프로젝트: ericeil/corert
        public JitHelper(Compilation compilation, JitHelperId id)
        {
            _compilation = compilation;

            this.Id = id;
        }