示例#1
0
        private void SetWellKnownTypeSignatureName(WellKnownType wellKnownType, string mangledSignatureName)
        {
            var type = _compilation.TypeSystemContext.GetWellKnownType(wellKnownType);
            var typeNode = _compilation.NodeFactory.ConstructedTypeSymbol(type);

            _cppSignatureNames.Add(type, mangledSignatureName);
        }
示例#2
0
文件: TypeDesc.cs 项目: mjp41/corert
        internal void SetWellKnownType(WellKnownType wellKnownType)
        {
            TypeFlags flags;

            switch (wellKnownType)
            {
                case WellKnownType.Void:
                case WellKnownType.Boolean:
                case WellKnownType.Char:
                case WellKnownType.SByte:
                case WellKnownType.Byte:
                case WellKnownType.Int16:
                case WellKnownType.UInt16:
                case WellKnownType.Int32:
                case WellKnownType.UInt32:
                case WellKnownType.Int64:
                case WellKnownType.UInt64:
                case WellKnownType.IntPtr:
                case WellKnownType.UIntPtr:
                case WellKnownType.Single:
                case WellKnownType.Double:
                    flags = (TypeFlags)wellKnownType;
                    break;

                case WellKnownType.ValueType:
                case WellKnownType.Enum:
                    flags = TypeFlags.Class;
                    break;

                case WellKnownType.Nullable:
                    flags = TypeFlags.Nullable;
                    break;

                case WellKnownType.Object:
                case WellKnownType.String:
                case WellKnownType.Array:
                case WellKnownType.MulticastDelegate:
                case WellKnownType.Exception:
                    flags = TypeFlags.Class;
                    break;

                case WellKnownType.RuntimeTypeHandle:
                case WellKnownType.RuntimeMethodHandle:
                case WellKnownType.RuntimeFieldHandle:
                    flags = TypeFlags.ValueType;
                    break;

                default:
                    throw new ArgumentException();
            }

            _typeFlags = flags;
        }
示例#3
0
 private TypeDesc GetWellKnownType(WellKnownType wellKnownType)
 {
     return(_tsc.GetWellKnownType(wellKnownType));
 }
        public override DefType GetWellKnownType(WellKnownType wellKnownType)
        {
            switch (wellKnownType)
            {
                case WellKnownType.Void:
                    return (DefType)ResolveRuntimeTypeHandle(typeof(void).TypeHandle);

                case WellKnownType.Boolean:
                    return (DefType)ResolveRuntimeTypeHandle(typeof(Boolean).TypeHandle);

                case WellKnownType.Char:
                    return (DefType)ResolveRuntimeTypeHandle(typeof(Char).TypeHandle);

                case WellKnownType.SByte:
                    return (DefType)ResolveRuntimeTypeHandle(typeof(SByte).TypeHandle);

                case WellKnownType.Byte:
                    return (DefType)ResolveRuntimeTypeHandle(typeof(Byte).TypeHandle);

                case WellKnownType.Int16:
                    return (DefType)ResolveRuntimeTypeHandle(typeof(Int16).TypeHandle);

                case WellKnownType.UInt16:
                    return (DefType)ResolveRuntimeTypeHandle(typeof(UInt16).TypeHandle);

                case WellKnownType.Int32:
                    return (DefType)ResolveRuntimeTypeHandle(typeof(Int32).TypeHandle);

                case WellKnownType.UInt32:
                    return (DefType)ResolveRuntimeTypeHandle(typeof(UInt32).TypeHandle);

                case WellKnownType.Int64:
                    return (DefType)ResolveRuntimeTypeHandle(typeof(Int64).TypeHandle);

                case WellKnownType.UInt64:
                    return (DefType)ResolveRuntimeTypeHandle(typeof(UInt64).TypeHandle);

                case WellKnownType.IntPtr:
                    return (DefType)ResolveRuntimeTypeHandle(typeof(IntPtr).TypeHandle);

                case WellKnownType.UIntPtr:
                    return (DefType)ResolveRuntimeTypeHandle(typeof(UIntPtr).TypeHandle);

                case WellKnownType.Single:
                    return (DefType)ResolveRuntimeTypeHandle(typeof(Single).TypeHandle);

                case WellKnownType.Double:
                    return (DefType)ResolveRuntimeTypeHandle(typeof(Double).TypeHandle);

                case WellKnownType.ValueType:
                    return (DefType)ResolveRuntimeTypeHandle(typeof(ValueType).TypeHandle);

                case WellKnownType.Enum:
                    return (DefType)ResolveRuntimeTypeHandle(typeof(Enum).TypeHandle);

                case WellKnownType.Nullable:
                    return (DefType)ResolveRuntimeTypeHandle(typeof(Nullable<>).TypeHandle);

                case WellKnownType.Object:
                    return (DefType)ResolveRuntimeTypeHandle(typeof(Object).TypeHandle);

                case WellKnownType.String:
                    return (DefType)ResolveRuntimeTypeHandle(typeof(String).TypeHandle);

                case WellKnownType.Array:
                    return (DefType)ResolveRuntimeTypeHandle(typeof(Array).TypeHandle);

                case WellKnownType.MulticastDelegate:
                    return (DefType)ResolveRuntimeTypeHandle(typeof(MulticastDelegate).TypeHandle);

                case WellKnownType.RuntimeTypeHandle:
                    return (DefType)ResolveRuntimeTypeHandle(typeof(RuntimeTypeHandle).TypeHandle);

                case WellKnownType.RuntimeMethodHandle:
                    return (DefType)ResolveRuntimeTypeHandle(typeof(RuntimeMethodHandle).TypeHandle);

                case WellKnownType.RuntimeFieldHandle:
                    return (DefType)ResolveRuntimeTypeHandle(typeof(RuntimeFieldHandle).TypeHandle);

                case WellKnownType.Exception:
                    return (DefType)ResolveRuntimeTypeHandle(typeof(Exception).TypeHandle);

                default:
                    throw new NotImplementedException();
            }
        }
示例#5
0
        private void SetWellKnownTypeSignatureName(WellKnownType wellKnownType, string mangledSignatureName)
        {
            var type = _compilation.TypeSystemContext.GetWellKnownType(wellKnownType);

            _cppSignatureNames.Add(type, mangledSignatureName);
        }
示例#6
0
 private void ImportStoreIndirect(WellKnownType wellKnownType)
 {
     ImportStoreIndirect(GetWellKnownType(wellKnownType));
 }
 public TopLevel(ModuleSymbol module, ref MetadataTypeName fullName, WellKnownType wellKnownType)
     : this(module, ref fullName, (int)wellKnownType)
 {
 }
示例#8
0
 public static string GetMetadataName(this WellKnownType id)
 {
     return(s_metadataNames[(int)(id - WellKnownType.First)]);
 }
 public TopLevel(ModuleSymbol module, ref MetadataTypeName fullName, WellKnownType wellKnownType)
     : this(module, ref fullName, (int)wellKnownType)
 {
 }
示例#10
0
 void ImportLoadElement(WellKnownType wellKnownType)
 {
     ImportLoadElement(GetWellKnownType(wellKnownType));
 }
示例#11
0
 void ImportLoadIndirect(WellKnownType wellKnownType)
 {
     ImportLoadIndirect(GetWellKnownType(wellKnownType));
 }
 public override DefType GetWellKnownType(WellKnownType wellKnownType)
 {
     Debug.Assert(_wellKnownTypes != null, "Forgot to call SetSystemModule?");
     return _wellKnownTypes[(int)wellKnownType - 1];
 }
示例#13
0
 private void RootWellKnownType(WellKnownType wellKnownType, IRootingServiceProvider rootProvider)
 {
     var type = _context.GetWellKnownType(wellKnownType);
     rootProvider.AddCompilationRoot(type, "Enables CPP codegen");
 }
示例#14
0
 private void AddWellKnownType(WellKnownType wellKnownType, DependencyAnalysisFramework.DependencyAnalyzerBase<NodeFactory> graph)
 {
     var type = TypeSystemContext.GetWellKnownType(wellKnownType);
     var typeNode = ConstructedTypeSymbol(type);
     graph.AddRoot(typeNode, "Enables CPP codegen");
 }
示例#15
0
        private void ImportConvert(WellKnownType wellKnownType, bool checkOverflow, bool unsigned)
        {
            var op = _stack.Pop();

            TypeDesc type = GetWellKnownType(wellKnownType);

            PushTemp(GetStackValueKind(type));
            Append("(");
            Append(_writer.GetCppSignatureTypeName(type));
            Append(")");
            Append(op);
            AppendSemicolon();
        }
示例#16
0
 private void ImportStoreElement(WellKnownType wellKnownType)
 {
     ImportStoreElement(GetWellKnownType(wellKnownType));
 }
 public TopLevelWithCustomErrorInfo(ModuleSymbol module, ref MetadataTypeName emittedName, DiagnosticInfo errorInfo, WellKnownType typeId)
     : base(module, ref emittedName, typeId)
 {
     Debug.Assert(errorInfo != null);
     _errorInfo = errorInfo;
 }
示例#18
0
 public static bool IsValueTupleType(this WellKnownType typeId)
 {
     Debug.Assert(typeId != WellKnownType.ExtSentinel);
     return(typeId >= WellKnownType.System_ValueTuple_T1 && typeId <= WellKnownType.System_ValueTuple_TRest);
 }
示例#19
0
 static public bool IsWellKnownType(this TypeDesc type, WellKnownType wellKnownType)
 {
     return type == type.Context.GetWellKnownType(wellKnownType);
 }
 public NamedTypeSymbol WellKnownType(WellKnownType wt)
 {
     NamedTypeSymbol wellKnownType = Compilation.GetWellKnownType(wt);
     Binder.ReportUseSiteDiagnostics(wellKnownType, Diagnostics, Syntax);
     return wellKnownType;
 }
示例#21
0
 private void SetWellKnownTypeSignatureName(WellKnownType wellKnownType, string mangledSignatureName)
 {
     var type = _compilation.TypeSystemContext.GetWellKnownType(wellKnownType);
     _compilation.GetRegisteredType(type).MangledSignatureName = mangledSignatureName;
 }
示例#22
0
        internal void AssertDeclaresType(PEModuleSymbol peModule, WellKnownType type, Accessibility expectedAccessibility)
        {
            var name = MetadataTypeName.FromFullName(type.GetMetadataName());

            Assert.Equal(expectedAccessibility, peModule.LookupTopLevelMetadataType(ref name).DeclaredAccessibility);
        }
示例#23
0
 private TypeDesc GetWellKnownType(WellKnownType wellKnownType)
 {
     return _module.Context.GetWellKnownType(wellKnownType);
 }
示例#24
0
 public abstract DefType GetWellKnownType(WellKnownType wellKnownType, bool throwIfNotFound = true);
示例#25
0
 public static INamedTypeSymbol GetWellKnownType(this Compilation compilation, WellKnownType type)
 {
     return(((CSharpCompilation)compilation).GetWellKnownType(type).GetPublicSymbol());
 }
示例#26
0
 public override DefType GetWellKnownType(WellKnownType wellKnownType)
 {
     return(_wellKnownTypes[(int)wellKnownType - 1]);
 }
示例#27
0
 private TypeDesc GetWellKnownType(WellKnownType wellKnownType)
 {
     return(_compilation.TypeSystemContext.GetWellKnownType(wellKnownType));
 }
        private void ExportToShapeFile(Collection <Feature> resultFeatures, Collection <FeatureSourceColumn> columns, FeatureLayerPlugin sourceLayerPlugin, WellKnownType type)
        {
            int count = resultFeatures.Count;

            if (count > 0)
            {
                FeatureLayerPlugin targetLayerPlugin = (FeatureLayerPlugin)GisEditor.LayerManager.GetLayerPlugins(typeof(ShapeFileFeatureLayer)).FirstOrDefault();
                FeatureLayer       resultLayer       = null;

                if (targetLayerPlugin != null)
                {
                    GetLayersParameters             getLayerParameters = new GetLayersParameters();
                    ConfigureFeatureLayerParameters parameters         = targetLayerPlugin.GetCreateFeatureLayerParameters(columns);
                    if (parameters != null && sourceLayerPlugin != null)
                    {
                        bool needColumns = false;
                        Collection <string> tempColumns = new Collection <string>();
                        if (parameters.CustomData.ContainsKey("Columns"))
                        {
                            tempColumns = parameters.CustomData["Columns"] as Collection <string>;
                        }
                        else
                        {
                            needColumns = true;
                        }

                        var featureColumns = columns.Where(c => needColumns || tempColumns.Contains(c.ColumnName));
                        if (targetLayerPlugin.CanCreateFeatureLayerWithSourceColumns(sourceLayerPlugin))
                        {
                            foreach (var item in featureColumns)
                            {
                                FeatureSourceColumn column = new FeatureSourceColumn(item.ColumnName, item.TypeName, item.MaxLength);
                                if (column.TypeName.Equals("c", StringComparison.InvariantCultureIgnoreCase))
                                {
                                    column.TypeName = "Character";
                                }
                                parameters.AddedColumns.Add(column);
                            }
                        }
                        else
                        {
                            var geoColumns = sourceLayerPlugin.GetIntermediateColumns(featureColumns);
                            foreach (var item in geoColumns)
                            {
                                if (item.TypeName.Equals("c", StringComparison.InvariantCultureIgnoreCase))
                                {
                                    item.TypeName = "Character";
                                }
                                parameters.AddedColumns.Add(item);
                            }
                        }


                        parameters.WellKnownType = type;
                        //parameters.CustomData["SourceLayer"] = featureLayer;

                        getLayerParameters.LayerUris.Add(parameters.LayerUri);
                        foreach (var item in parameters.CustomData)
                        {
                            getLayerParameters.CustomData[item.Key] = item.Value;
                        }

                        Proj4Projection proj4 = new Proj4Projection();
                        proj4.InternalProjectionParametersString = parameters.Proj4ProjectionParametersString;
                        proj4.ExternalProjectionParametersString = GisEditor.ActiveMap.DisplayProjectionParameters;
                        proj4.SyncProjectionParametersString();
                        proj4.Open();

                        foreach (var item in resultFeatures)
                        {
                            Feature feature = proj4.ConvertToInternalProjection(item);
                            parameters.AddedFeatures.Add(feature);
                        }

                        if (parameters.MemoColumnConvertMode == MemoColumnConvertMode.ToCharacter)
                        {
                            foreach (var item in parameters.AddedColumns.Where(c => c.TypeName.Equals("Memo", StringComparison.InvariantCultureIgnoreCase)).ToList())
                            {
                                item.TypeName  = "Character";
                                item.MaxLength = 254;
                                DbfColumn tmpDbfColumn = item as DbfColumn;
                                if (tmpDbfColumn != null)
                                {
                                    tmpDbfColumn.ColumnType = DbfColumnType.Character;
                                    tmpDbfColumn.Length     = 254;
                                }
                            }
                        }

                        resultLayer = targetLayerPlugin.CreateFeatureLayer(parameters);
                        resultLayer.FeatureSource.Projection = proj4;
                        resultLayer = targetLayerPlugin.GetLayers(getLayerParameters).FirstOrDefault() as FeatureLayer;
                    }
                }

                if (resultLayer != null)
                {
                    GisEditorMessageBox messageBox = new GisEditorMessageBox(MessageBoxButton.YesNo);
                    messageBox.Owner = Application.Current.MainWindow;
                    messageBox.WindowStartupLocation = WindowStartupLocation.CenterOwner;
                    messageBox.Title        = GisEditor.LanguageManager.GetStringResource("NavigatePluginAddToMap");
                    messageBox.Message      = GisEditor.LanguageManager.GetStringResource("DoYouWantToAddToMap");
                    messageBox.ErrorMessage = string.Empty;
                    if (messageBox.ShowDialog().Value)
                    {
                        GisEditor.ActiveMap.AddLayerToActiveOverlay(resultLayer);
                        GisEditor.ActiveMap.RefreshActiveOverlay();
                        RefreshArgs refreshArgs = new RefreshArgs(this, "LoadToMapCore");
                        InvokeRefreshPlugins(GisEditor.UIManager, refreshArgs);
                        GisEditor.ActiveMap.Refresh();
                    }
                }
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("There is no features to export.", "Export");
            }
        }
示例#29
0
 public override MetadataType GetWellKnownType(WellKnownType wellKnownType)
 {
     return _wellKnownTypes[(int)wellKnownType - 1];
 }
 public TopLevelWithCustomErrorInfo(ModuleSymbol module, ref MetadataTypeName emittedName, DiagnosticInfo errorInfo, WellKnownType typeId)
     : base(module, ref emittedName, typeId)
 {
     RoslynDebug.Assert(errorInfo != null);
     _errorInfo = errorInfo;
 }
示例#31
0
 public override DefType GetWellKnownType(WellKnownType wellKnownType)
 {
     return _wellKnownTypes[(int)wellKnownType - 1];
 }
示例#32
0
 private TypeDesc GetWellKnownType(WellKnownType wellKnownType)
 {
     return _typeSystemContext.GetWellKnownType(wellKnownType);
 }
        private static Feature MakeFeatureValidate(Feature feature)
        {
            Feature validFeature = feature.MakeValid();

            WellKnownType featureType   = feature.GetWellKnownType();
            WellKnownType validatedType = validFeature.GetWellKnownType();

            Feature result = validFeature;

            if (validatedType != featureType &&
                validatedType == WellKnownType.GeometryCollection)
            {
                GeometryCollectionShape geoCollectionShape = validFeature.GetShape() as GeometryCollectionShape;
                if (geoCollectionShape != null)
                {
                    BaseShape resultShape = null;
                    switch (featureType)
                    {
                    case WellKnownType.Point:
                    case WellKnownType.Multipoint:
                        Collection <PointShape> points = new Collection <PointShape>();
                        foreach (var shape in geoCollectionShape.Shapes)
                        {
                            PointShape point = shape as PointShape;
                            if (point != null)
                            {
                                points.Add(point);
                            }
                        }
                        resultShape = new MultipointShape(points);
                        break;

                    case WellKnownType.Line:
                    case WellKnownType.Multiline:
                        Collection <LineShape> lines = new Collection <LineShape>();
                        foreach (var shape in geoCollectionShape.Shapes)
                        {
                            LineShape line = shape as LineShape;
                            if (line != null)
                            {
                                lines.Add(line);
                            }
                        }
                        resultShape = new MultilineShape(lines);
                        break;

                    case WellKnownType.Polygon:
                    case WellKnownType.Multipolygon:
                        Collection <PolygonShape> polygons = new Collection <PolygonShape>();
                        foreach (var shape in geoCollectionShape.Shapes)
                        {
                            PolygonShape polygon = shape as PolygonShape;
                            if (polygon != null)
                            {
                                polygons.Add(polygon);
                            }
                        }
                        resultShape = new MultipolygonShape(polygons);
                        break;

                    default:
                        break;
                    }

                    if (resultShape != null)
                    {
                        result = new Feature(resultShape);
                    }
                }
            }

            return(result);
        }
 public override DefType GetWellKnownType(WellKnownType wellKnownType)
 {
     Debug.Assert(_wellKnownTypes != null, "Forgot to call SetSystemModule?");
     return(_wellKnownTypes[(int)wellKnownType - 1]);
 }
示例#35
0
 internal override ITypeSymbolInternal CommonGetWellKnownType(WellKnownType wellknownType)
 {
     return(GetWellKnownType(wellknownType));
 }
示例#36
0
 public static bool IsWellKnownType(this WellKnownType typeId)
 {
     Debug.Assert(typeId != WellKnownType.ExtSentinel);
     return(typeId >= WellKnownType.First && typeId < WellKnownType.NextAvailable);
 }
        public IEnumerable <NtObjectBase> ListDirectory(string path, bool recurse = false, WellKnownType filterType = WellKnownType.Unknown)
        {
            OBJECT_ATTRIBUTES objectAttributes = new OBJECT_ATTRIBUTES(path, 0);
            NtStatus          retVal           = Win32.NtOpenDirectoryObject(out var directoryHandle, DirectoryAccessEnum.DIRECTORY_QUERY, ref objectAttributes);

            if (retVal != NtStatus.STATUS_SUCCESS)
            {
                ErrorHelper.Throw(retVal, $"NtOpenDirectoryObject, parentPath: {path}");
            }

            uint singleDirInfo = (uint)Marshal.SizeOf <OBJECT_DIRECTORY_INFORMATION>();

            using (directoryHandle)
                using (UnmanagedMemory mem = new UnmanagedMemory((int)(256 * singleDirInfo)))
                {
                    bool     restart = true;
                    NtStatus status;
                    uint     context = 0;

                    do
                    {
                        mem.Clear();

                        status = Win32.NtQueryDirectoryObject(directoryHandle, mem.Handle, mem.Bytes, false, restart,
                                                              ref context, out _);
                        restart = false;

                        IntPtr ptr = mem.Handle;

                        while (true)
                        {
                            OBJECT_DIRECTORY_INFORMATION dir = Marshal.PtrToStructure <OBJECT_DIRECTORY_INFORMATION>(ptr);
                            ptr = new IntPtr(ptr.ToInt64() + (int)singleDirInfo);

                            if (dir.Name.Length == 0)
                            {
                                break;
                            }

                            string        typeName      = dir.TypeName.ToString();
                            string        name          = dir.Name.ToString();
                            WellKnownType wellKnownType = StaticStrings.ToWellKnownType(typeName);

                            if (filterType != WellKnownType.Unknown && filterType != wellKnownType)
                            {
                                continue;
                            }

                            if (wellKnownType == WellKnownType.Directory)
                            {
                                NtDirectory directory = new NtDirectory(typeName, path, name);
                                yield return(directory);

                                if (recurse)
                                {
                                    foreach (NtObjectBase subObject in ListDirectory(directory.FullName, true, filterType))
                                    {
                                        yield return(subObject);
                                    }
                                }

                                continue;
                            }

                            NtObjectBase result = new NtObjectBase(typeName, path, name);

                            result = ConvertToSpecificType(result);

                            yield return(result);
                        }
                    } while (status == NtStatus.STATUS_MORE_ENTRIES);
                }
        }
示例#38
0
 public static bool IsValid(this WellKnownType typeId)
 {
     return(typeId >= WellKnownType.First && typeId < WellKnownType.NextAvailable && typeId != WellKnownType.ExtSentinel);
 }
示例#39
0
            private void RootWellKnownType(WellKnownType wellKnownType, IRootingServiceProvider rootProvider)
            {
                var type = _context.GetWellKnownType(wellKnownType);

                rootProvider.AddCompilationRoot(type, "Enables CPP codegen");
            }
 public ArrayTypeSymbol WellKnownArrayType(WellKnownType elementType)
 {
     return Compilation.CreateArrayTypeSymbol(WellKnownType(elementType));
 }
示例#41
0
 private void SetWellKnownTypeSignatureName(WellKnownType wellKnownType, string mangledSignatureName)
 {
     var type = _compilation.TypeSystemContext.GetWellKnownType(wellKnownType);
     _cppSignatureNames.Add(type, mangledSignatureName);
 }
 public BoundExpression Typeof(WellKnownType type)
 {
     return Typeof(WellKnownType(type));
 }
        /// <summary>
        /// This method handles duplicate types in a few different ways:
        /// - for types before C# 7, the first candidate is returned with a warning
        /// - for types after C# 7, the type is considered missing
        /// - in both cases, when BinderFlags.IgnoreCorLibraryDuplicatedTypes is set, any duplicate coming from corlib will be ignored (ie not count as a duplicate)
        /// </summary>
        internal NamedTypeSymbol GetWellKnownType(WellKnownType type)
        {
            Debug.Assert(type.IsValid());

            bool ignoreCorLibraryDuplicatedTypes = this.Options.TopLevelBinderFlags.Includes(BinderFlags.IgnoreCorLibraryDuplicatedTypes);

            int index = (int)type - (int)WellKnownType.First;

            if (_lazyWellKnownTypes == null || (object)_lazyWellKnownTypes[index] == null)
            {
                if (_lazyWellKnownTypes == null)
                {
                    Interlocked.CompareExchange(ref _lazyWellKnownTypes, new NamedTypeSymbol[(int)WellKnownTypes.Count], null);
                }

                string          mdName   = type.GetMetadataName();
                var             warnings = DiagnosticBag.GetInstance();
                NamedTypeSymbol result;
                (AssemblySymbol, AssemblySymbol)conflicts = default;

                if (IsTypeMissing(type))
                {
                    result = null;
                }
                else
                {
                    // well-known types introduced before CSharp7 allow lookup ambiguity and report a warning
                    DiagnosticBag legacyWarnings = (type <= WellKnownType.CSharp7Sentinel) ? warnings : null;
                    result = this.Assembly.GetTypeByMetadataName(
                        mdName, includeReferences: true, useCLSCompliantNameArityEncoding: true, isWellKnownType: true, conflicts: out conflicts,
                        warnings: legacyWarnings, ignoreCorLibraryDuplicatedTypes: ignoreCorLibraryDuplicatedTypes);
                }

                if ((object)result == null)
                {
                    // TODO: should GetTypeByMetadataName rather return a missing symbol?
                    MetadataTypeName emittedName = MetadataTypeName.FromFullName(mdName, useCLSCompliantNameArityEncoding: true);
                    if (type.IsValueTupleType())
                    {
                        CSDiagnosticInfo errorInfo;
                        if (conflicts.Item1 is null)
                        {
                            Debug.Assert(conflicts.Item2 is null);
                            errorInfo = new CSDiagnosticInfo(ErrorCode.ERR_PredefinedValueTupleTypeNotFound, emittedName.FullName);
                        }
                        else
                        {
                            errorInfo = new CSDiagnosticInfo(ErrorCode.ERR_PredefinedValueTupleTypeAmbiguous3, emittedName.FullName, conflicts.Item1, conflicts.Item2);
                        }

                        result = new MissingMetadataTypeSymbol.TopLevelWithCustomErrorInfo(this.Assembly.Modules[0], ref emittedName, errorInfo, type);
                    }
                    else
                    {
                        result = new MissingMetadataTypeSymbol.TopLevel(this.Assembly.Modules[0], ref emittedName, type);
                    }
                }

                if ((object)Interlocked.CompareExchange(ref _lazyWellKnownTypes[index], result, null) != null)
                {
                    Debug.Assert(
                        result == _lazyWellKnownTypes[index] || (_lazyWellKnownTypes[index].IsErrorType() && result.IsErrorType())
                        );
                }
                else
                {
                    AdditionalCodegenWarnings.AddRange(warnings);
                }

                warnings.Free();
            }

            return(_lazyWellKnownTypes[index]);
        }
示例#44
0
 private TypeDesc GetWellKnownType(WellKnownType wellKnownType)
 {
     return(_module.Context.GetWellKnownType(wellKnownType));
 }
        private bool CheckIfAttributeShouldBeEmbedded(DiagnosticBag diagnosticsOpt, Location locationOpt, WellKnownType attributeType, WellKnownMember attributeCtor)
        {
            var userDefinedAttribute = GetWellKnownType(attributeType);

            if (userDefinedAttribute is MissingMetadataTypeSymbol)
            {
                if (Options.OutputKind == OutputKind.NetModule)
                {
                    if (diagnosticsOpt != null)
                    {
                        var errorReported = Binder.ReportUseSiteDiagnostics(userDefinedAttribute, diagnosticsOpt, locationOpt);
                        Debug.Assert(errorReported);
                    }
                }
                else
                {
                    return(true);
                }
            }
            else if (diagnosticsOpt != null)
            {
                // This should produce diagnostics if the member is missing or bad
                Binder.GetWellKnownTypeMember(this, attributeCtor, diagnosticsOpt, locationOpt);
            }

            return(false);
        }
示例#46
0
 public static bool IsWellKnownType(this TypeDesc type, WellKnownType wellKnownType)
 {
     return(type == type.Context.GetWellKnownType(wellKnownType, false));
 }
 public TopLevel(ModuleSymbol module, ref MetadataTypeName fullName, WellKnownType wellKnownType, DiagnosticInfo?errorInfo = null)
     : this(module, ref fullName, (int)wellKnownType, errorInfo)
 {
 }
示例#48
0
 private void ImportStoreElement(WellKnownType wellKnownType)
 {
     ImportStoreElement(GetWellKnownType(wellKnownType));
 }
示例#49
0
        private NamedTypeSymbol GetTypeSymbolForWellKnownType(WellKnownType type)
        {
            MetadataTypeName emittedName = MetadataTypeName.FromFullName(type.GetMetadataName(), useCLSCompliantNameArityEncoding: true);
            // First, check this module
            NamedTypeSymbol currentModuleResult = this.LookupTopLevelMetadataType(ref emittedName);

            if (IsAcceptableSystemTypeSymbol(currentModuleResult))
            {
                // It doesn't matter if there's another of this type in a referenced assembly -
                // we prefer the one in the current module.
                return currentModuleResult;
            }

            // If we didn't find it in this module, check the referenced assemblies
            NamedTypeSymbol referencedAssemblyResult = null;
            foreach (AssemblySymbol assembly in this.GetReferencedAssemblySymbols())
            {
                NamedTypeSymbol currResult = assembly.LookupTopLevelMetadataType(ref emittedName, digThroughForwardedTypes: true);
                if (IsAcceptableSystemTypeSymbol(currResult))
                {
                    if ((object)referencedAssemblyResult == null)
                    {
                        referencedAssemblyResult = currResult;
                    }
                    else
                    {
                        // CONSIDER: setting result to null will result in a MissingMetadataTypeSymbol 
                        // being returned.  Do we want to differentiate between no result and ambiguous
                        // results?  There doesn't seem to be an existing error code for "duplicate well-
                        // known type".
                        if (referencedAssemblyResult != currResult)
                        {
                            referencedAssemblyResult = null;
                        }
                        break;
                    }
                }
            }

            if ((object)referencedAssemblyResult != null)
            {
                Debug.Assert(IsAcceptableSystemTypeSymbol(referencedAssemblyResult));
                return referencedAssemblyResult;
            }

            Debug.Assert((object)currentModuleResult != null);
            return currentModuleResult;
        }
示例#50
0
 public void IsBlittableType_NonBilittableWellKnownTypes_ReturnsFalse(WellKnownType type) =>
 Assert.False(MarshalUtils.IsBlittableType(_context.GetWellKnownType(type)));
示例#51
0
 private TypeDesc GetWellKnownType(WellKnownType wellKnownType)
 {
     return(_interpreter.TypeSystemContext.GetWellKnownType(wellKnownType));
 }
示例#52
0
 internal NamedTypeSymbol GetWellKnownType(WellKnownType type)
 {
     return(this.GetTypeByMetadataName(WellKnownTypes.GetMetadataName(type)));
 }
示例#53
0
 private void ImportConvert(WellKnownType wellKnownType, bool checkOverflow, bool unsigned)
 {
     throw new NotImplementedException();
 }
示例#54
0
 private void ImportLoadIndirect(WellKnownType wellKnownType)
 {
     ImportLoadIndirect(GetWellKnownType(wellKnownType));
 }
示例#55
0
        void ImportConvert(WellKnownType wellKnownType, bool checkOverflow, bool unsigned)
        {
            var op = Pop();

            TypeDesc type = GetWellKnownType(wellKnownType);

            PushTemp(GetStackValueKind(type));
            Append("(");
            Append(_writer.GetCppSignatureTypeName(type));
            Append(")");
            Append(op.Value.Name);
            Finish();
        }