public CLITypePrinter(Driver driver) { Driver = driver; TypeMapDatabase = driver.TypeDatabase; Options = driver.Options; Context = new CLITypePrinterContext(); }
public static void CheckTypeForSpecialization(Type type, Declaration container, Action <ClassTemplateSpecialization> addSpecialization, ITypeMapDatabase typeMaps, bool internalOnly = false) { type = type.Desugar(); type = (type.GetFinalPointee() ?? type).Desugar(); ClassTemplateSpecialization specialization = GetParentSpecialization(type); if (specialization == null) { return; } if (IsSpecializationNeeded(container, typeMaps, internalOnly, specialization)) { return; } if (!internalOnly) { if (IsSpecializationSelfContained(specialization, container)) { return; } if (IsMappedToPrimitive(typeMaps, type, specialization)) { return; } } addSpecialization(specialization); }
public CLITypeReferenceCollector(ITypeMapDatabase typeMapDatabase, DriverOptions driverOptions) { TypeMapDatabase = typeMapDatabase; DriverOptions = driverOptions; typeReferences = new Dictionary <Declaration, CLITypeReference>(); GeneratedDeclarations = new HashSet <Declaration>(); }
public TypeIgnoreChecker(ITypeMapDatabase database, GeneratorKind generatorKind = GeneratorKind.CSharp) { TypeMapDatabase = database; VisitOptions.ClearFlags(VisitFlags.ClassBases | VisitFlags.TemplateArguments); this.generatorKind = generatorKind; }
public static void CheckTypeForSpecialization(Type type, Declaration container, Action <ClassTemplateSpecialization> addSpecialization, ITypeMapDatabase typeMaps, bool internalOnly = false) { type = type.Desugar(); type = type.GetFinalPointee() ?? type; ClassTemplateSpecialization specialization; type.TryGetDeclaration(out specialization); if (specialization == null || specialization.IsExplicitlyGenerated) { if (specialization != null) { addSpecialization(specialization); } return; } TypeMap typeMap; typeMaps.FindTypeMap(specialization, out typeMap); if ((!internalOnly && (((specialization.Ignore || specialization.TemplatedDecl.TemplatedClass.Ignore) && typeMap == null) || specialization.Arguments.Any(a => UnsupportedTemplateArgument( specialization, a, typeMaps)))) || specialization.IsIncomplete || (!internalOnly && specialization.TemplatedDecl.TemplatedClass.IsIncomplete) || specialization is ClassTemplatePartialSpecialization || container.Namespace == specialization) { return; } while (container.Namespace != null) { if (container.Namespace == specialization) { return; } container = container.Namespace; } if (!internalOnly && typeMaps.FindTypeMap(specialization, out typeMap)) { var typePrinterContext = new TypePrinterContext { Type = type }; var mappedTo = typeMap.CSharpSignatureType(typePrinterContext); mappedTo = mappedTo.Desugar(); mappedTo = (mappedTo.GetFinalPointee() ?? mappedTo); if (mappedTo.IsPrimitiveType() || mappedTo.IsPointerToPrimitiveType() || mappedTo.IsEnum()) { return; } } addSpecialization(specialization); }
public TypeIgnoreChecker(ITypeMapDatabase database, GeneratorKind generatorKind = GeneratorKind.CSharp) { TypeMapDatabase = database; VisitOptions.VisitClassBases = false; VisitOptions.VisitTemplateArguments = false; this.generatorKind = generatorKind; }
public CSharpTypePrinter(ITypeMapDatabase database, Library library) { TypeMapDatabase = database; Library = library; contexts = new Stack <CSharpTypePrinterContextKind>(); PushContext(CSharpTypePrinterContextKind.Managed); Context = new CSharpTypePrinterContext(); }
public CSharpTypePrinter(ITypeMapDatabase database, ASTContext context) { TypeMapDatabase = database; AstContext = context; contexts = new Stack <CSharpTypePrinterContextKind>(); PushContext(CSharpTypePrinterContextKind.Managed); Context = new CSharpTypePrinterContext(); }
public CSharpTypePrinter(ITypeMapDatabase database, DriverOptions driverOptions, ASTContext context) { TypeMapDatabase = database; this.driverOptions = driverOptions; AstContext = context; contexts = new Stack <CSharpTypePrinterContextKind>(); PushContext(CSharpTypePrinterContextKind.Managed); Context = new CSharpTypePrinterContext(); }
private static bool IsSpecializationNeeded(Declaration container, ITypeMapDatabase typeMaps, bool internalOnly, Type type, ClassTemplateSpecialization specialization) { typeMaps.FindTypeMap(type, out var typeMap); return((!internalOnly && (((specialization.Ignore || specialization.TemplatedDecl.TemplatedClass.Ignore) && typeMap == null) || specialization.Arguments.Any(a => specialization.UnsupportedTemplateArgument(a, typeMaps)) || container.Namespace == specialization)) || (!internalOnly && specialization.TemplatedDecl.TemplatedClass.IsIncomplete) || specialization is ClassTemplatePartialSpecialization); }
private static bool UnsupportedTemplateArgument( ClassTemplateSpecialization specialization, TemplateArgument a, ITypeMapDatabase typeMaps) { if (a.Type.Type == null || IsTypeExternal(specialization.TranslationUnit.Module, a.Type.Type)) { return(true); } var typeIgnoreChecker = new TypeIgnoreChecker(typeMaps); a.Type.Type.Visit(typeIgnoreChecker); return(typeIgnoreChecker.IsIgnored); }
public static bool IsMappedToPrimitive(ITypeMapDatabase typeMaps, Type type) { if (!typeMaps.FindTypeMap(type, out var typeMap)) { return(false); } var typePrinterContext = new TypePrinterContext { Type = type }; var mappedTo = typeMap.CSharpSignatureType(typePrinterContext); mappedTo = mappedTo.Desugar(); mappedTo = (mappedTo.GetFinalPointee() ?? mappedTo).Desugar(); return(mappedTo.IsPrimitiveType() || mappedTo.IsPointerToPrimitiveType() || mappedTo.IsEnum()); }
public static bool CheckTypeForSpecialization(Type type, Declaration container, Action <ClassTemplateSpecialization> addSpecialization, ITypeMapDatabase typeMaps, bool internalOnly = false) { type = type.Desugar(); type = (type.GetFinalPointee() ?? type).Desugar(); ClassTemplateSpecialization specialization = GetParentSpecialization(type); if (specialization == null) { return(true); } if (IsSpecializationNeeded(container, typeMaps, internalOnly, type, specialization)) { return(false); } if (!internalOnly) { if (IsSpecializationSelfContained(specialization, container)) { return(true); } if (IsMappedToPrimitive(typeMaps, type)) { return(true); } } if (specialization.Arguments.Select( a => a.Type.Type).Any(t => t != null && !CheckTypeForSpecialization(t, specialization, addSpecialization, typeMaps, internalOnly))) { return(false); } addSpecialization(specialization); return(true); }
private static bool IsMappedToPrimitive(ITypeMapDatabase typeMaps, Type type, ClassTemplateSpecialization specialization) { TypeMap typeMap; if (!typeMaps.FindTypeMap(specialization, out typeMap)) { return(false); } var typePrinterContext = new TypePrinterContext { Type = type }; var mappedTo = typeMap.CSharpSignatureType(typePrinterContext); mappedTo = mappedTo.Desugar(); mappedTo = (mappedTo.GetFinalPointee() ?? mappedTo).Desugar(); return(mappedTo.IsPrimitiveType() || mappedTo.IsPointerToPrimitiveType() || mappedTo.IsEnum()); }
public CppTypePrinter(ITypeMapDatabase database) { }
private static bool FindTypeMap(ITypeMapDatabase typeMapDatabase, Class @class, out TypeMap typeMap) { return(typeMapDatabase.FindTypeMap(@class, out typeMap) || (@class.HasBase && FindTypeMap(typeMapDatabase, @class.Bases[0].Class, out typeMap))); }
public TypeIgnoreChecker(ITypeMapDatabase database) { TypeMapDatabase = database; VisitOptions.VisitClassBases = false; VisitOptions.VisitTemplateArguments = false; }
public FindEventsPass(ITypeMapDatabase typeMapDatabase) { this.typeMapDatabase = typeMapDatabase; }
public CLITypeReferenceCollector(ITypeMapDatabase typeMapDatabase) { TypeMapDatabase = typeMapDatabase; typeReferences = new Dictionary<Declaration,CLITypeReference>(); }
public CppTypePrinter(ITypeMapDatabase database, bool printTypeQualifiers = true) { PrintScopeKind = CppTypePrintScopeKind.GlobalQualified; PrintTypeQualifiers = printTypeQualifiers; }
public CLITypeReferenceCollector(ITypeMapDatabase typeMapDatabase, DriverOptions driverOptions) { TypeMapDatabase = typeMapDatabase; DriverOptions = driverOptions; typeReferences = new Dictionary<Declaration,CLITypeReference>(); }
public CLITypeReferenceCollector(ITypeMapDatabase typeMapDatabase) { TypeMapDatabase = typeMapDatabase; typeReferences = new Dictionary <Declaration, CLITypeReference>(); }
private static bool FindTypeMap(ITypeMapDatabase typeMapDatabase, Class @class, out TypeMap typeMap) { return typeMapDatabase.FindTypeMap(@class, out typeMap) || (@class.HasBase && FindTypeMap(typeMapDatabase, @class.Bases[0].Class, out typeMap)); }
public TypeIgnoreChecker(ITypeMapDatabase database) { TypeMapDatabase = database; Options.VisitClassBases = false; Options.VisitTemplateArguments = false; }
public CppTypePrinter(ITypeMapDatabase database) { PrintKind = CppTypePrintKind.GlobalQualified; }