示例#1
0
        private protected Stmt(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind)
        {
            if ((handle.StmtClass == CX_StmtClass.CX_StmtClass_Invalid) || (handle.StmtClass != expectedStmtClass))
            {
                throw new ArgumentOutOfRangeException(nameof(handle));
            }

            _children = new Lazy <IReadOnlyList <Stmt> >(() => {
                var numChildren = Handle.NumChildren;
                var children    = new List <Stmt>(numChildren);

                for (var i = 0; i < numChildren; i++)
                {
                    var child = TranslationUnit.GetOrCreate <Stmt>(Handle.GetChild(unchecked ((uint)i)));
                    children.Add(child);
                }

                return(children);
            });

            _declContext = new Lazy <IDeclContext>(() => {
                var semanticParent = TranslationUnit.GetOrCreate <Cursor>(Handle.SemanticParent);

                while (semanticParent is not IDeclContext and not null)
                {
                    semanticParent = TranslationUnit.GetOrCreate <Cursor>(semanticParent.Handle.SemanticParent);
                }

                return((IDeclContext)semanticParent);
            });
        }
示例#2
0
 private protected AsmStmt(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass)
 {
     if ((CX_StmtClass.CX_StmtClass_LastAsmStmt < handle.StmtClass) || (handle.StmtClass < CX_StmtClass.CX_StmtClass_FirstAsmStmt))
     {
         throw new ArgumentException(nameof(handle));
     }
 }
示例#3
0
 private protected AsmStmt(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass)
 {
     if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastAsmStmt or < CX_StmtClass.CX_StmtClass_FirstAsmStmt)
     {
         throw new ArgumentOutOfRangeException(nameof(handle));
     }
 }
示例#4
0
        private protected Expr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass)
        {
            if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastExpr or < CX_StmtClass.CX_StmtClass_FirstExpr)
            {
                throw new ArgumentOutOfRangeException(nameof(handle));
            }

            _type = new Lazy <Type>(() => TranslationUnit.GetOrCreate <Type>(Handle.Type));
        }
示例#5
0
        private protected FullExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass)
        {
            if ((CX_StmtClass.CX_StmtClass_LastFullExpr < handle.StmtClass) || (handle.StmtClass < CX_StmtClass.CX_StmtClass_FirstFullExpr))
            {
                throw new ArgumentException(nameof(handle));
            }

            Debug.Assert(NumChildren is 1);
        }
示例#6
0
        private protected Stmt(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind)
        {
            if ((handle.StmtClass == CX_StmtClass.CX_StmtClass_Invalid) || (handle.StmtClass != expectedStmtClass))
            {
                throw new ArgumentException(nameof(handle));
            }

            _children = new Lazy <IReadOnlyList <Stmt> >(() => CursorChildren.OfType <Stmt>().ToList());
        }
示例#7
0
        private protected FullExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass)
        {
            if ((CX_StmtClass.CX_StmtClass_LastFullExpr < handle.StmtClass) || (handle.StmtClass < CX_StmtClass.CX_StmtClass_FirstFullExpr))
            {
                throw new ArgumentException(nameof(handle));
            }

            _subExpr = new Lazy <Expr>(() => TranslationUnit.GetOrCreate <Expr>(Handle.SubExpr));
        }
示例#8
0
        private protected FullExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass)
        {
            if ((CX_StmtClass.CX_StmtClass_LastFullExpr < handle.StmtClass) || (handle.StmtClass < CX_StmtClass.CX_StmtClass_FirstFullExpr))
            {
                throw new ArgumentException(nameof(handle));
            }

            _subExpr = new Lazy <Expr>(() => Children.OfType <Expr>().Single());
        }
示例#9
0
        private protected CastExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass)
        {
            if ((CX_StmtClass.CX_StmtClass_LastCastExpr < handle.StmtClass) || (handle.StmtClass < CX_StmtClass.CX_StmtClass_FirstCastExpr))
            {
                throw new ArgumentException(nameof(handle));
            }

            _conversionFunction = new Lazy <NamedDecl>(() => TranslationUnit.GetOrCreate <NamedDecl>(Handle.ConversionFunction));
            _subExpr            = new Lazy <Expr>(() => TranslationUnit.GetOrCreate <Expr>(Handle.SubExpr));
            _subExprAsWritten   = new Lazy <Expr>(() => TranslationUnit.GetOrCreate <Expr>(Handle.SubExprAsWritten));
            _targetUnionField   = new Lazy <FieldDecl>(() => TranslationUnit.GetOrCreate <FieldDecl>(Handle.TargetUnionField));
        }
示例#10
0
        private protected CallExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass)
        {
            if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastCallExpr or < CX_StmtClass.CX_StmtClass_FirstCallExpr)
            {
                throw new ArgumentOutOfRangeException(nameof(handle));
            }

            Debug.Assert(NumChildren >= 1);

            _args       = new Lazy <IReadOnlyList <Expr> >(() => Children.Skip(1).Take((int)NumArgs).Cast <Expr>().ToList());
            _calleeDecl = new Lazy <Decl>(() => TranslationUnit.GetOrCreate <Decl>(Handle.Referenced));
        }
示例#11
0
文件: Stmt.cs 项目: jmaine/ClangSharp
        private protected Stmt(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind)
        {
            if ((handle.StmtClass == CX_StmtClass.CX_StmtClass_Invalid) || (handle.StmtClass != expectedStmtClass))
            {
                throw new ArgumentException(nameof(handle));
            }

            _children    = new Lazy <IReadOnlyList <Stmt> >(() => CursorChildren.OfType <Stmt>().ToList());
            _declContext = new Lazy <IDeclContext>(() => {
                var cursorParent = CursorParent;

                while (!(cursorParent is IDeclContext) && (cursorParent != null))
                {
                    cursorParent = cursorParent.CursorParent;
                }

                return((IDeclContext)cursorParent);
            });
        }
示例#12
0
        private protected Stmt(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind)
        {
            if ((handle.StmtClass == CX_StmtClass.CX_StmtClass_Invalid) || (handle.StmtClass != expectedStmtClass))
            {
                throw new ArgumentException(nameof(handle));
            }

            _children    = new Lazy <IReadOnlyList <Stmt> >(() => CursorChildren.OfType <Stmt>().ToList());
            _declContext = new Lazy <IDeclContext>(() => {
                var semanticParent = TranslationUnit.GetOrCreate <Cursor>(Handle.SemanticParent);

                while (!(semanticParent is IDeclContext) && (semanticParent != null))
                {
                    semanticParent = TranslationUnit.GetOrCreate <Cursor>(semanticParent.Handle.SemanticParent);
                }

                return((IDeclContext)semanticParent);
            });
        }
示例#13
0
        private protected CastExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass)
        {
            if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastCastExpr or < CX_StmtClass.CX_StmtClass_FirstCastExpr)
            {
                throw new ArgumentOutOfRangeException(nameof(handle));
            }

            Debug.Assert(NumChildren is 1);

            _path = new Lazy <IReadOnlyList <CXXBaseSpecifier> >(() => {
                var pathSize = Handle.NumArguments;
                var path     = new List <CXXBaseSpecifier>(pathSize);

                for (var i = 0; i < pathSize; i++)
                {
                    var item = TranslationUnit.GetOrCreate <CXXBaseSpecifier>(Handle.GetArgument(unchecked ((uint)i)));
                    path.Add(item);
                }

                return(path);
            });
            _targetUnionField = new Lazy <FieldDecl>(() => TranslationUnit.GetOrCreate <FieldDecl>(Handle.TargetUnionField));
        }
示例#14
0
        private protected CallExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass)
        {
            if ((CX_StmtClass.CX_StmtClass_LastCallExpr < handle.StmtClass) || (handle.StmtClass < CX_StmtClass.CX_StmtClass_FirstCallExpr))
            {
                throw new ArgumentException(nameof(handle));
            }

            _args = new Lazy <IReadOnlyList <Expr> >(() => {
                var numArgs = NumArgs;
                var args    = new List <Expr>((int)numArgs);

                for (var index = 0u; index < numArgs; index++)
                {
                    var arg = Handle.GetArgument(index);
                    args.Add(TranslationUnit.GetOrCreate <Expr>(arg));
                }

                return(args);
            });

            _callee     = new Lazy <Expr>(() => Children.OfType <Expr>().First());
            _calleeDecl = new Lazy <Decl>(() => TranslationUnit.GetOrCreate <Decl>(Handle.Referenced));
        }
示例#15
0
        private protected CallExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass)
        {
            if ((CX_StmtClass.CX_StmtClass_LastCallExpr < handle.StmtClass) || (handle.StmtClass < CX_StmtClass.CX_StmtClass_FirstCallExpr))
            {
                throw new ArgumentException(nameof(handle));
            }

            _args = new Lazy <IReadOnlyList <Expr> >(() => {
                var numArgs = Handle.NumArguments;
                var args    = new List <Expr>(numArgs);

                for (var index = 0; index < numArgs; index++)
                {
                    var arg = TranslationUnit.GetOrCreate <Expr>(Handle.GetArgument(unchecked ((uint)index)));
                    args.Add(arg);
                }

                return(args);
            });
            _callee       = new Lazy <Expr>(() => TranslationUnit.GetOrCreate <Expr>(Handle.CalleeExpr));
            _calleeDecl   = new Lazy <Decl>(() => TranslationUnit.GetOrCreate <Decl>(Handle.Referenced));
            _directCallee = new Lazy <FunctionDecl>(() => TranslationUnit.GetOrCreate <FunctionDecl>(Handle.DirectCallee));
        }
示例#16
0
        private protected BinaryOperator(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass)
        {
            if ((CX_StmtClass.CX_StmtClass_LastBinaryOperator < handle.StmtClass) || (handle.StmtClass < CX_StmtClass.CX_StmtClass_FirstBinaryOperator))
            {
                throw new ArgumentException(nameof(handle));
            }
            Debug.Assert(Children.OfType <Expr>().Count() == 2);

            _lhs = new Lazy <Expr>(() => Children.OfType <Expr>().First());
            _rhs = new Lazy <Expr>(() => Children.OfType <Expr>().Last());
        }
 private protected OMPLoopTransformationDirective(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass)
 {
 }
示例#18
0
        private protected CXXConstructExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass)
        {
            if ((CX_StmtClass.CX_StmtClass_LastCXXConstructExpr < handle.StmtClass) || (handle.StmtClass < CX_StmtClass.CX_StmtClass_FirstCXXConstructExpr))
            {
                throw new ArgumentException(nameof(handle));
            }

            _args = new Lazy <IReadOnlyList <Expr> >(() => {
                var numArgs = NumArgs;
                var args    = new List <Expr>((int)numArgs);

                for (var index = 0u; index < numArgs; index++)
                {
                    var arg = Handle.GetArgument(index);
                    args.Add(TranslationUnit.GetOrCreate <Expr>(arg));
                }

                return(args);
            });
        }
示例#19
0
 private protected CoroutineSuspendExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass)
 {
     if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastCoroutineSuspendExpr or < CX_StmtClass.CX_StmtClass_FirstCoroutineSuspendExpr)
     {
         throw new ArgumentOutOfRangeException(nameof(handle));
     }
 }
示例#20
0
 private protected OMPExecutableDirective(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass)
 {
     if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastOMPExecutableDirective or < CX_StmtClass.CX_StmtClass_FirstOMPExecutableDirective)
     {
         throw new ArgumentOutOfRangeException(nameof(handle));
     }
 }
示例#21
0
        private protected OverloadExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass)
        {
            if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastOverloadExpr or < CX_StmtClass.CX_StmtClass_FirstOverloadExpr)
            {
                throw new ArgumentOutOfRangeException(nameof(handle));
            }

            _decls = new Lazy <IReadOnlyList <Decl> >(() => {
                var numDecls = Handle.NumDecls;
                var decls    = new List <Decl>(numDecls);

                for (var i = 0; i < numDecls; i++)
                {
                    var decl = TranslationUnit.GetOrCreate <Decl>(Handle.GetDecl(unchecked ((uint)i)));
                    decls.Add(decl);
                }

                return(decls);
            });

            _namingClass = new Lazy <CXXRecordDecl>(() => TranslationUnit.GetOrCreate <CXXRecordDecl>(Handle.Referenced));

            _templateArgs = new Lazy <IReadOnlyList <TemplateArgumentLoc> >(() => {
                var templateArgCount = Handle.NumTemplateArguments;
                var templateArgs     = new List <TemplateArgumentLoc>(templateArgCount);

                for (var i = 0; i < templateArgCount; i++)
                {
                    var templateArg = TranslationUnit.GetOrCreate(Handle.GetTemplateArgumentLoc(unchecked ((uint)i)));
                    templateArgs.Add(templateArg);
                }

                return(templateArgs);
            });
        }
示例#22
0
        private protected SwitchCase(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass)
        {
            if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastSwitchCase or < CX_StmtClass.CX_StmtClass_FirstSwitchCase)
            {
                throw new ArgumentOutOfRangeException(nameof(handle));
            }

            _nextSwitchCase = new Lazy <SwitchCase>(() => TranslationUnit.GetOrCreate <SwitchCase>(Handle.NextSwitchCase));
        }
示例#23
0
        private protected BinaryOperator(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass)
        {
            if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastBinaryOperator or < CX_StmtClass.CX_StmtClass_FirstBinaryOperator)
            {
                throw new ArgumentOutOfRangeException(nameof(handle));
            }

            Debug.Assert(NumChildren is 2);
        }
示例#24
0
        private protected CXXConstructExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass)
        {
            if ((CX_StmtClass.CX_StmtClass_LastCXXConstructExpr < handle.StmtClass) || (handle.StmtClass < CX_StmtClass.CX_StmtClass_FirstCXXConstructExpr))
            {
                throw new ArgumentException(nameof(handle));
            }
            Debug.Assert(NumChildren == NumArgs);

            _args        = new Lazy <IReadOnlyList <Expr> >(() => Children.Cast <Expr>().ToList());
            _constructor = new Lazy <CXXConstructorDecl>(() => TranslationUnit.GetOrCreate <CXXConstructorDecl>(Handle.Referenced));
        }
示例#25
0
 private protected OMPLoopDirective(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass)
 {
     if ((CX_StmtClass.CX_StmtClass_LastOMPLoopDirective < handle.StmtClass) || (handle.StmtClass < CX_StmtClass.CX_StmtClass_FirstOMPLoopDirective))
     {
         throw new ArgumentException(nameof(handle));
     }
 }
示例#26
0
 private protected AbstractConditionalOperator(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass)
 {
     if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastAbstractConditionalOperator or < CX_StmtClass.CX_StmtClass_FirstAbstractConditionalOperator)
     {
         throw new ArgumentOutOfRangeException(nameof(handle));
     }
 }
示例#27
0
        private protected AbstractConditionalOperator(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass)
        {
            if ((CX_StmtClass.CX_StmtClass_LastAbstractConditionalOperator < handle.StmtClass) || (handle.StmtClass < CX_StmtClass.CX_StmtClass_FirstAbstractConditionalOperator))
            {
                throw new ArgumentException(nameof(handle));
            }

            _cond      = new Lazy <Expr>(() => TranslationUnit.GetOrCreate <Expr>(Handle.CondExpr));
            _falseExpr = new Lazy <Expr>(() => TranslationUnit.GetOrCreate <Expr>(Handle.FalseExpr));
            _trueExpr  = new Lazy <Expr>(() => TranslationUnit.GetOrCreate <Expr>(Handle.TrueExpr));
        }
示例#28
0
 public StatementHandlerAttribute(CX_StmtClass statementClass)
 {
     Kind = statementClass;
 }
示例#29
0
        private protected BinaryOperator(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass)
        {
            if ((CX_StmtClass.CX_StmtClass_LastBinaryOperator < handle.StmtClass) || (handle.StmtClass < CX_StmtClass.CX_StmtClass_FirstBinaryOperator))
            {
                throw new ArgumentException(nameof(handle));
            }

            _lhs = new Lazy <Expr>(() => TranslationUnit.GetOrCreate <Expr>(Handle.LhsExpr));
            _rhs = new Lazy <Expr>(() => TranslationUnit.GetOrCreate <Expr>(Handle.RhsExpr));
        }
示例#30
0
        private protected SwitchCase(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass)
        {
            if ((CX_StmtClass.CX_StmtClass_LastSwitchCase < handle.StmtClass) || (handle.StmtClass < CX_StmtClass.CX_StmtClass_FirstSwitchCase))
            {
                throw new ArgumentException(nameof(handle));
            }

            _nextSwitchCase = new Lazy <SwitchCase>(() => TranslationUnit.GetOrCreate <SwitchCase>(Handle.NextSwitchCase));
            _subStmt        = new Lazy <Stmt>(() => TranslationUnit.GetOrCreate <Stmt>(Handle.SubStmt));
        }