示例#1
0
        private protected FunctionDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
        {
            if ((CX_DeclKind.CX_DeclKind_LastFunction < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstFunction))
            {
                throw new ArgumentException(nameof(handle));
            }

            _body       = new Lazy <Stmt>(() => CursorChildren.OfType <Stmt>().SingleOrDefault());
            _decls      = new Lazy <IReadOnlyList <Decl> >(() => CursorChildren.OfType <Decl>().ToList());
            _parameters = new Lazy <IReadOnlyList <ParmVarDecl> >(() => Decls.OfType <ParmVarDecl>().ToList());
            _returnType = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.ResultType));
        }
示例#2
0
        private protected CXXRecordDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
        {
            if ((CX_DeclKind.CX_DeclKind_LastCXXRecord < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstCXXRecord))
            {
                throw new ArgumentException(nameof(handle));
            }

            _bases      = new Lazy <IReadOnlyList <CXXBaseSpecifier> >(() => CursorChildren.OfType <CXXBaseSpecifier>().ToList());
            _ctors      = new Lazy <IReadOnlyList <CXXConstructorDecl> >(() => Methods.OfType <CXXConstructorDecl>().ToList());
            _destructor = new Lazy <CXXDestructorDecl>(() => Methods.OfType <CXXDestructorDecl>().SingleOrDefault());
            _friends    = new Lazy <IReadOnlyList <FriendDecl> >(() => Decls.OfType <FriendDecl>().ToList());
            _methods    = new Lazy <IReadOnlyList <CXXMethodDecl> >(() => Decls.OfType <CXXMethodDecl>().ToList());
            _vbases     = new Lazy <IReadOnlyList <CXXBaseSpecifier> >(() => Bases.Where((@base) => @base.IsVirtual).ToList());
        }
        private protected ObjCContainerDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
        {
            if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastObjCContainer or < CX_DeclKind.CX_DeclKind_FirstObjCContainer)
            {
                throw new ArgumentOutOfRangeException(nameof(handle));
            }

            _classMethods       = new Lazy <IReadOnlyList <ObjCMethodDecl> >(() => Methods.Where((method) => method.IsClassMethod).ToList());
            _classProperties    = new Lazy <IReadOnlyList <ObjCPropertyDecl> >(() => Properties.Where((property) => property.IsClassProperty).ToList());
            _instanceMethods    = new Lazy <IReadOnlyList <ObjCMethodDecl> >(() => Methods.Where((method) => method.IsInstanceMethod).ToList());
            _instanceProperties = new Lazy <IReadOnlyList <ObjCPropertyDecl> >(() => Properties.Where((property) => property.IsInstanceProperty).ToList());
            _methods            = new Lazy <IReadOnlyList <ObjCMethodDecl> >(() => Decls.OfType <ObjCMethodDecl>().ToList());
            _properties         = new Lazy <IReadOnlyList <ObjCPropertyDecl> >(() => Decls.OfType <ObjCPropertyDecl>().ToList());
        }
示例#4
0
        private protected RecordDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
        {
            if ((CX_DeclKind.CX_DeclKind_LastRecord < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstRecord))
            {
                throw new ArgumentException(nameof(handle));
            }

            if ((handle.Kind != CXCursorKind.CXCursor_StructDecl) && (handle.Kind != CXCursorKind.CXCursor_UnionDecl) && (handle.Kind != CXCursorKind.CXCursor_ClassDecl) && (handle.Kind != CXCursorKind.CXCursor_ClassTemplatePartialSpecialization))
            {
                throw new ArgumentException(nameof(handle));
            }

            _fields = new Lazy <IReadOnlyList <FieldDecl> >(() => Decls.OfType <FieldDecl>().ToList());
        }
示例#5
0
        internal ObjCImplementationDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCImplementationDecl, CX_DeclKind.CX_DeclKind_ObjCImplementation)
        {
            _initExprs = new Lazy <IReadOnlyList <Expr> >(() => {
                var numInitExprs = Handle.NumExprs;
                var initExprs    = new List <Expr>(numInitExprs);

                for (var i = 0; i < numInitExprs; i++)
                {
                    var initExpr = TranslationUnit.GetOrCreate <Expr>(Handle.GetExpr(unchecked ((uint)i)));
                    initExprs.Add(initExpr);
                }

                return(initExprs);
            });

            _ivars      = new Lazy <IReadOnlyList <ObjCIvarDecl> >(() => Decls.OfType <ObjCIvarDecl>().ToList());
            _superClass = new Lazy <ObjCInterfaceDecl>(() => TranslationUnit.GetOrCreate <ObjCInterfaceDecl>(Handle.GetSubDecl(1)));
        }
示例#6
0
        private protected CXXRecordDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind)
        {
            if ((CX_DeclKind.CX_DeclKind_LastCXXRecord < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstCXXRecord))
            {
                throw new ArgumentException(nameof(handle));
            }

            _bases = new Lazy <IReadOnlyList <CXXBaseSpecifier> >(() => CursorChildren.OfType <CXXBaseSpecifier>().ToList());
            _ctors = new Lazy <IReadOnlyList <CXXConstructorDecl> >(() => Methods.OfType <CXXConstructorDecl>().ToList());
            _dependentLambdaCallOperator = new Lazy <FunctionTemplateDecl>(() => TranslationUnit.GetOrCreate <FunctionTemplateDecl>(Handle.DependentLambdaCallOperator));
            _describedClassTemplate      = new Lazy <ClassTemplateDecl>(() => TranslationUnit.GetOrCreate <ClassTemplateDecl>(Handle.DescribedClassTemplate));
            _destructor = new Lazy <CXXDestructorDecl>(() => TranslationUnit.GetOrCreate <CXXDestructorDecl>(Handle.Destructor));
            _friends    = new Lazy <IReadOnlyList <FriendDecl> >(() => Decls.OfType <FriendDecl>().ToList());
            _instantiatedFromMemberClass = new Lazy <CXXRecordDecl>(() => TranslationUnit.GetOrCreate <CXXRecordDecl>(Handle.InstantiatedFromMember));
            _lambdaCallOperator          = new Lazy <CXXMethodDecl>(() => TranslationUnit.GetOrCreate <CXXMethodDecl>(Handle.LambdaCallOperator));
            _lambdaContextDecl           = new Lazy <Decl>(() => TranslationUnit.GetOrCreate <Decl>(Handle.LambdaContextDecl));
            _lambdaStaticInvoker         = new Lazy <CXXMethodDecl>(() => TranslationUnit.GetOrCreate <CXXMethodDecl>(Handle.LambdaStaticInvoker));
            _methods = new Lazy <IReadOnlyList <CXXMethodDecl> >(() => Decls.OfType <CXXMethodDecl>().ToList());
            _mostRecentNonInjectedDecl    = new Lazy <CXXRecordDecl>(() => TranslationUnit.GetOrCreate <CXXRecordDecl>(Handle.MostRecentNonInjectedDecl));
            _templateInstantiationPattern = new Lazy <CXXRecordDecl>(() => TranslationUnit.GetOrCreate <CXXRecordDecl>(Handle.TemplateInstantiationPattern));
            _vbases = new Lazy <IReadOnlyList <CXXBaseSpecifier> >(() => Bases.Where((@base) => @base.IsVirtual).ToList());
        }
示例#7
0
        public IDecl CreateDecl(DeclKind kind, IDecl parent)
        {
            Decl ret;

            switch (kind)
            {
            case DeclKind.AccessSpec: ret = new AccessSpecDecl(parent); break;

            case DeclKind.Block: ret = new BlockDecl(parent); break;

            case DeclKind.Captured: ret = new CapturedDecl(parent); break;

            case DeclKind.ClassScopeFunctionSpecialization: ret = new ClassScopeFunctionSpecializationDecl(parent); break;

            case DeclKind.Empty: ret = new EmptyDecl(parent); break;

            case DeclKind.Export: ret = new ExportDecl(parent); break;

            case DeclKind.ExternCContext: ret = new ExternCContextDecl(parent); break;

            case DeclKind.FileScopeAsm: ret = new FileScopeAsmDecl(parent); break;

            case DeclKind.Friend: ret = new FriendDecl(parent); break;

            case DeclKind.FriendTemplate: ret = new FriendTemplateDecl(parent); break;

            case DeclKind.Import: ret = new ImportDecl(parent); break;

            case DeclKind.LinkageSpec: ret = new LinkageSpecDecl(parent); break;

            case DeclKind.Label: ret = new LabelDecl(parent); break;

            case DeclKind.Namespace: ret = new NamespaceDecl(parent); break;

            case DeclKind.NamespaceAlias: ret = new NamespaceAliasDecl(parent); break;

            case DeclKind.ObjCCompatibleAlias: ret = new ObjCCompatibleAliasDecl(parent); break;

            case DeclKind.ObjCCategory: ret = new ObjCCategoryDecl(parent); break;

            case DeclKind.ObjCCategoryImpl: ret = new ObjCCategoryImplDecl(parent); break;

            case DeclKind.ObjCImplementation: ret = new ObjCImplementationDecl(parent); break;

            case DeclKind.ObjCInterface: ret = new ObjCInterfaceDecl(parent); break;

            case DeclKind.ObjCProtocol: ret = new ObjCProtocolDecl(parent); break;

            case DeclKind.ObjCMethod: ret = new ObjCMethodDecl(parent); break;

            case DeclKind.ObjCProperty: ret = new ObjCPropertyDecl(parent); break;

            case DeclKind.BuiltinTemplate: ret = new BuiltinTemplateDecl(parent); break;

            case DeclKind.ClassTemplate: ret = new ClassTemplateDecl(parent); break;

            case DeclKind.FunctionTemplate: ret = new FunctionTemplateDecl(parent); break;

            case DeclKind.TypeAliasTemplate: ret = new TypeAliasTemplateDecl(parent); break;

            case DeclKind.VarTemplate: ret = new VarTemplateDecl(parent); break;

            case DeclKind.TemplateTemplateParm: ret = new TemplateTemplateParmDecl(parent); break;

            case DeclKind.Enum: ret = new EnumDecl(parent); break;

            case DeclKind.Record: ret = new RecordDecl(parent); break;

            case DeclKind.CXXRecord: ret = new CXXRecordDecl(parent); break;

            case DeclKind.ClassTemplateSpecialization: ret = new ClassTemplateSpecializationDecl(parent); break;

            case DeclKind.ClassTemplatePartialSpecialization: ret = new ClassTemplatePartialSpecializationDecl(parent); break;

            case DeclKind.TemplateTypeParm: ret = new TemplateTypeParmDecl(parent); break;

            case DeclKind.ObjCTypeParam: ret = new ObjCTypeParamDecl(parent); break;

            case DeclKind.TypeAlias: ret = new TypeAliasDecl(parent); break;

            case DeclKind.Typedef: ret = new TypedefDecl(parent); break;

            case DeclKind.UnresolvedUsingTypename: ret = new UnresolvedUsingTypenameDecl(parent); break;

            case DeclKind.Using: ret = new UsingDecl(parent); break;

            case DeclKind.UsingDirective: ret = new UsingDirectiveDecl(parent); break;

            case DeclKind.UsingPack: ret = new UsingPackDecl(parent); break;

            case DeclKind.UsingShadow: ret = new UsingShadowDecl(parent); break;

            case DeclKind.ConstructorUsingShadow: ret = new ConstructorUsingShadowDecl(parent); break;

            case DeclKind.Binding: ret = new BindingDecl(parent); break;

            case DeclKind.Field: ret = new FieldDecl(parent); break;

            case DeclKind.ObjCAtDefsField: ret = new ObjCAtDefsFieldDecl(parent); break;

            case DeclKind.ObjCIvar: ret = new ObjCIvarDecl(parent); break;

            case DeclKind.Function: ret = new FunctionDecl(parent); break;

            case DeclKind.CXXDeductionGuide: ret = new CXXDeductionGuideDecl(parent); break;

            case DeclKind.CXXMethod: ret = new CXXMethodDecl(parent); break;

            case DeclKind.CXXConstructor: ret = new CXXConstructorDecl(parent); break;

            case DeclKind.CXXConversion: ret = new CXXConversionDecl(parent); break;

            case DeclKind.CXXDestructor: ret = new CXXDestructorDecl(parent); break;

            case DeclKind.MSProperty: ret = new MSPropertyDecl(parent); break;

            case DeclKind.NonTypeTemplateParm: ret = new NonTypeTemplateParmDecl(parent); break;

            case DeclKind.Var: ret = new VarDecl(parent); break;

            case DeclKind.Decomposition: ret = new DecompositionDecl(parent); break;

            case DeclKind.ImplicitParam: ret = new ImplicitParamDecl(parent); break;

            case DeclKind.OMPCapturedExpr: ret = new OMPCapturedExprDecl(parent); break;

            case DeclKind.ParmVar: ret = new ParmVarDecl(parent); break;

            case DeclKind.VarTemplateSpecialization: ret = new VarTemplateSpecializationDecl(parent); break;

            case DeclKind.VarTemplatePartialSpecialization: ret = new VarTemplatePartialSpecializationDecl(parent); break;

            case DeclKind.EnumConstant: ret = new EnumConstantDecl(parent); break;

            case DeclKind.IndirectField: ret = new IndirectFieldDecl(parent); break;

            case DeclKind.OMPDeclareReduction: ret = new OMPDeclareReductionDecl(parent); break;

            case DeclKind.UnresolvedUsingValue: ret = new UnresolvedUsingValueDecl(parent); break;

            case DeclKind.OMPThreadPrivate: ret = new OMPThreadPrivateDecl(parent); break;

            case DeclKind.ObjCPropertyImpl: ret = new ObjCPropertyImplDecl(parent); break;

            case DeclKind.PragmaComment: ret = new PragmaCommentDecl(parent); break;

            case DeclKind.PragmaDetectMismatch: ret = new PragmaDetectMismatchDecl(parent); break;

            case DeclKind.StaticAssert: ret = new StaticAssertDecl(parent); break;

            case DeclKind.TranslationUnit: ret = new TranslationUnitDecl(parent); break;

            default: throw new NotImplementedException();
            }

            if (parent == null)
            {
                Decls.Add(ret);
            }

            return(ret);
        }
示例#8
0
 internal EnumDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_EnumDecl, CX_DeclKind.CX_DeclKind_Enum)
 {
     _enumerators = new Lazy <IReadOnlyList <EnumConstantDecl> >(() => Decls.OfType <EnumConstantDecl>().ToList());
     _integerType = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.EnumDecl_IntegerType));
 }
示例#9
0
 internal RecordDecl(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind)
 {
     _fields = new Lazy <IReadOnlyList <FieldDecl> >(() => Decls.Where((decl) => decl is FieldDecl).Cast <FieldDecl>().ToList());
 }
示例#10
0
 internal RecordDecl(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind)
 {
     _fields = new Lazy <IReadOnlyList <FieldDecl> >(() => Decls.OfType <FieldDecl>().ToList());
 }